From 859366ae0051bbad8e1a2a23dafd44466bf6e655 Mon Sep 17 00:00:00 2001 From: bitbeckers Date: Mon, 6 Nov 2023 19:40:13 +0100 Subject: [PATCH] SDK remove default chainID dependency (#1146) * Feat/batch burn (#1051) * feat(batch_burn): add batch burn function * fix(docs): update SemiFungible1155 docs * chore(lint): cleanup lint ignores * chore(lint): defender lint errors * chore(deploy): reduce optimizer run for kb limit * chore(script): update upgrade script * feat(gha): split graph deploy develop-main * chore(lint): line length rule to warn from err * chore(gha): run CI on PR to develop * chore(gha): run e2e,ci on pr,push to develop * feat(graph): update graph for burn methods * chore(turbo): split graph deploys (#1055) * Fix/workspace label (#1060) chore(yarn): update workspace label * 1052 subgraph a claimed token should indicate whether it was claimed from an allowlist (#1058) * fix(graph): link claim with allowlist * chore(tweak): yada * fix(graph): update mapping to claim (#1061) * nitial trader implementation (#1063) * feat(iface): draft of trader interface * feat(trader): simple offer, buy, cancel flow * feat(db): update allowlist query (#1057) * feat(test): tweaks and initial tests for Trader * chore(gha): remove hardcoded foundry nightly * feat(test): add initial test for trader sales * feat(test): sales tests * feat(deploy): deployed to goerli * chore(ci): updated hh scripts for trader contract * feat(pause): pausable controls and tests * feat(trader): init trader graph * feat(tokens): surface accepted tokens (#1065) * feat(tokens): surface accepted tokens * fix(tokens): acceptedTokens test and fix * Feat/accepted tokens (#1066) * feat(tokens): surface accepted tokens * fix(tokens): acceptedTokens test and fix * chore(address): update trader address graph * fix(import): add bigint to import * Feat/accepted tokens (#1067) * feat(tokens): surface accepted tokens * fix(tokens): acceptedTokens test and fix * chore(address): update trader address graph * fix(import): add bigint to import * fix(log): add logging to trader mapping * [Prod]:Deployed to Celo, updated Defender, version bumps for everyone (#1137) * Fix/package build (#1124) * chore(npm): sdk to workspace to stop link: * chore(npm): contracts in workspace, no link: * chore(bump): 0.8.7 * chore(bump): contracts 0.8.7 into sdk 0.8.8 * fix(ci): linting errors from updated ws * fix(doc): optimism chainId to 10 from 100 * chore(build): remove type module from package.json * chore(contracts): package sol files * chore(pack): add sol files to contracts package * chore(bump): contract 0.8.9 * chore(pack): exports setup * chore(pack): contracts dir in package * chore(pack): cleanup build scripts * chore(bump): contracts 0.8.10 * chore(pack): add all contracts for inheritence * chore(bump): contracts 0.8.11 * chore(bump): sdk 0.8.10 with updated contracts package * chore(bump): updated packages in frontend * chore(gha): run action on pr and push to develop * Feat/deploy to celo (#1135) * Add HC contracts to OpenZeppelin Defender (#1134) * Fix/package build (#1124) * chore(npm): sdk to workspace to stop link: * chore(npm): contracts in workspace, no link: * chore(bump): 0.8.7 * chore(bump): contracts 0.8.7 into sdk 0.8.8 * fix(ci): linting errors from updated ws * fix(doc): optimism chainId to 10 from 100 * chore(build): remove type module from package.json * chore(contracts): package sol files * chore(pack): add sol files to contracts package * chore(bump): contract 0.8.9 * chore(pack): exports setup * chore(pack): contracts dir in package * chore(pack): cleanup build scripts * chore(bump): contracts 0.8.10 * chore(pack): add all contracts for inheritence * chore(bump): contracts 0.8.11 * chore(bump): sdk 0.8.10 with updated contracts package * chore(bump): updated packages in frontend * chore(gha): run action on pr and push to develop * feat(defender): use hc packages in oz defender * feat(celo): graph deploy, sdk and defender config * chore(bump): SDK 0.8.14 Celo deployment * feat(celo): add celo support to frontend * chore(graph): fix turbo test flow * chore(graph): add comment to p.json * fix(gha): use pnpm cache in graph gha (#1138) * chore(prep): protocol contracts to protocol dir * chore(prep): tests to protocol dir and remappings * chore(license): MIT license * Feat/init marketplace (#1139) * chore(prep): protocol contracts to protocol dir * chore(prep): tests to protocol dir and remappings * chore(license): MIT license * feat(marketplace): inject, build, refactor, test * chore(gha): run gha on push and develop-branches * fix(build): build and lint errors * chore(pnpm): refresh lock file * chore(build): reduce turbo concurrency * fix(build): whac a mole * chore(build): restore prettier in solhint * chore(build): env.template vars * chore(dist): clean and remap output contracts * chore(clean): last tests * fix(build): ignore cors-proxy type errors * chore(gha): add rpc env vars for fork testing --------- Co-authored-by: jipstavenuiter * chore(lint): cleanup config and affiliate flows (#1140) * chore(license): dual licensing contracts + repo (#1141) * feat(config): updated sdk init config * feat(tests): fix all tests to use updated init * feat(test): uncommented all SDK tests * fix(log): remove result logging * [Test] Release marketplace contracts on testnet and add to contracts package (#1150) * feat(deploy): deploy to testnets * chore(build): hardhat build * feat(pack): release, test, bump updated contracts * chore(gha): updated env vars * chore(pnpm): updated lock file * fix(build): build error, replaced util with viem * fix(pnpm): root dir ethers resolution * chore(pnpm): updated lockfile * fix(pnpm): overrides * chore(build): resolving build issues sdk * chore(refactor): dep resolution bug - del eth v5 * fix(test): mock ipfs in minting, remove timeout * chore(build): fresh build * chore(clean): remove contracts/contracts dir * fix(gha): non-next env var in gha for sdk * chore(run): kick * fix(jest): forceExit hanging async call * chore(build): fresh run for sanity * fix(lint): ignore **/abi instead of **/src/abi * feat(fe): integrate in FE and SDK 0.9.1 * chore(bump): sdk 0.9.1-viem * feat(fe): update FE to use SDK 0.9.1 * chore(cleanup): code cleanup SDK * chore(bump): sdk version bump * chore(fe): update SDK dep version * fix(sdk): chainId config * chore(parse): fix parse calc * fix parse allowlist csv tests * fix injected chain id in config * update component config.tsx * chore(bump): updated sdk alpha * chore(run): sanity check passed * chore(build): graphSDK * feat(fe): plasmic rendering issues. * feat(sdk): web3 token * chore(defender): removed api_key sep network conf * chore(defender): remove verbose log batch action * chore(gha): deduplicate runs - now on all push * chore(lint): lint fe lib * chore(gha): cleaned up env vars --------- Co-authored-by: jipstavenuiter --- .github/workflows/ci-default.yml | 13 +- .github/workflows/e2e-tests.yml | 2 + .lintstagedignore | 10 + .lintstagedrc | 2 +- LICENSE | 203 +- LICENSE-APACHE | 13 + LICENSE-MIT | 21 + contracts/.env.example | 11 +- contracts/.eslintrc.yml | 10 - contracts/.gitignore | 3 +- contracts/.lintstagedrc | 5 +- contracts/.openzeppelin/goerli.json | 1500 ++++++++ contracts/.prettierignore | 4 +- contracts/.prettierrc.yml | 23 - contracts/.solcover.js | 7 - contracts/.solhint.json | 9 +- contracts/.vscode/settings.json | 2 - contracts/LICENSE | 4 + contracts/LICENSE-APACHE | 10 + contracts/{LICENSE.md => LICENSE-MIT} | 7 +- contracts/README.md | 4 +- contracts/contracts/AllowlistMinter.sol | 70 - contracts/contracts/HypercertMinter.sol | 229 -- contracts/contracts/SemiFungible1155.sol | 433 --- contracts/foundry.toml | 31 +- contracts/hardhat.config.ts | 80 +- .../.eslintrc | 31 +- contracts/package.json | 53 +- contracts/remappings.txt | 5 + contracts/rollup.config.mjs | 4 +- contracts/scripts/deployment/Deployment.s.sol | 117 + .../ProtocolFeeRecipientDeployment.s.sol | 43 + contracts/src/SemiFungible1155.sol | 433 --- contracts/src/deployments.json | 22 + contracts/src/index.ts | 60 +- contracts/src/interfaces/IAllowlist.sol | 14 - contracts/src/interfaces/IHypercertToken.sol | 62 - contracts/src/libs/Errors.sol | 15 - .../BatchOrderTypehashRegistry.sol | 62 + .../CreatorFeeManagerWithRebates.sol | 93 + .../CreatorFeeManagerWithRoyalties.sol | 95 + contracts/src/marketplace/CurrencyManager.sol | 37 + .../src/marketplace/ExecutionManager.sol | 304 ++ .../src/marketplace/InheritedStrategy.sol | 89 + .../src/marketplace/LooksRareProtocol.sol | 622 +++ contracts/src/marketplace/NonceManager.sol | 115 + .../src/marketplace/ProtocolFeeRecipient.sol | 54 + contracts/src/marketplace/StrategyManager.sol | 124 + contracts/src/marketplace/TransferManager.sol | 375 ++ .../src/marketplace/TransferSelectorNFT.sol | 67 + .../constants/AssemblyConstants.sol | 42 + .../constants/NumericConstants.sol | 14 + .../constants/ValidationCodeConstants.sol | 313 ++ .../src/marketplace/enums/CollectionType.sol | 13 + contracts/src/marketplace/enums/QuoteType.sol | 10 + .../marketplace/errors/ChainlinkErrors.sol | 41 + .../src/marketplace/errors/SharedErrors.sol | 65 + .../executionStrategies/BaseStrategy.sol | 46 + .../BaseStrategyChainlinkPriceLatency.sol | 33 + .../StrategyChainlinkUSDDynamicAsk.sol | 164 + .../StrategyCollectionOffer.sol | 138 + .../StrategyDutchAuction.sol | 102 + .../StrategyItemIdsRange.sol | 111 + .../marketplace/helpers/OrderValidatorV2A.sol | 845 +++++ .../marketplace/helpers/ProtocolHelpers.sol | 89 + .../interfaces/ICreatorFeeManager.sol | 35 + .../interfaces/ICurrencyManager.sol | 15 + .../interfaces/IExecutionManager.sol | 53 + .../interfaces/IImmutableCreate2Factory.sol | 9 + .../interfaces/ILooksRareProtocol.sol | 166 + .../marketplace/interfaces/INonceManager.sol | 40 + .../interfaces/IRoyaltyFeeRegistry.sol | 20 + .../src/marketplace/interfaces/IStrategy.sol | 30 + .../interfaces/IStrategyManager.sol | 80 + .../interfaces/ITransferManager.sol | 84 + .../libraries/CurrencyValidator.sol | 38 + .../MerkleProofCalldataWithNodes.sol | 61 + .../OpenZeppelin/MerkleProofMemory.sol | 51 + .../marketplace/libraries/OrderStructs.sol | 152 + .../src/{ => protocol}/AllowlistMinter.sol | 22 +- .../src/{ => protocol}/HypercertMinter.sol | 75 +- contracts/src/protocol/SemiFungible1155.sol | 641 ++++ .../protocol}/interfaces/IAllowlist.sol | 11 +- .../protocol}/interfaces/IHypercertToken.sol | 2 +- .../protocol}/libs/Errors.sol | 0 contracts/tasks/deploy.ts | 2 +- contracts/tasks/transfer-owner.ts | 36 +- contracts/tasks/upgrade.ts | 71 +- contracts/test/HypercertMinter.test.ts | 10 +- .../foundry/SemiFungible1155.burning.t.sol | 56 - .../BatchMakerCollectionOrders.t.sol | 111 + .../marketplace/BatchMakerOrders.t.sol | 333 ++ .../BatchOrderTypehashRegistry.t.sol | 120 + .../marketplace/BundleTransactions.t.sol | 260 ++ .../CreatorFeeManagerWithRebates.t.sol | 233 ++ .../CreatorFeeManagerWithRoyalties.t.sol | 350 ++ .../foundry/marketplace/CurrencyManager.t.sol | 42 + .../DelegationRecipientsTaker.t.sol | 172 + .../marketplace/DomainSeparatorUpdates.t.sol | 97 + .../marketplace/ExecutionManager.t.sol | 282 ++ .../foundry/marketplace/GasGriefing.t.sol | 135 + .../foundry/marketplace/InitialStates.t.sol | 55 + .../marketplace/LooksRareProtocol.t.sol | 268 ++ .../marketplace/NonceInvalidation.t.sol | 355 ++ .../marketplace/OrderValidatorV2A.t.sol | 378 ++ .../foundry/marketplace/ProtocolBase.t.sol | 257 ++ .../marketplace/ProtocolFeeRecipient.t.sol | 110 + .../test/foundry/marketplace/Sandbox.t.sol | 142 + .../marketplace/SignaturesEIP2098.t.sol | 66 + .../SignaturesERC1271WalletForERC1155.t.sol | 445 +++ .../SignaturesERC1271WalletForERC721.t.sol | 278 ++ .../marketplace/SignaturesRevertions.t.sol | 173 + .../marketplace/StandardTransactions.t.sol | 508 +++ .../foundry/marketplace/StrategyManager.t.sol | 213 ++ .../foundry/marketplace/TransferManager.t.sol | 527 +++ ...ifyOrderTimestampValidityEquivalence.t.sol | 91 + .../Chainlink/USDDynamicAskOrders.t.sol | 488 +++ .../CollectionOffers.t.sol | 449 +++ .../DutchAuctionOrders.t.sol | 407 ++ .../ItemIdsRangeOrders.t.sol | 486 +++ .../MultiFillCollectionOrders.t.sol | 187 + .../foundry/marketplace/utils/BytesLib.sol | 71 + .../marketplace/utils/EIP712MerkleTree.sol | 114 + .../marketplace/utils/ERC1271Wallet.sol | 20 + .../foundry/marketplace/utils/GasGriefer.sol | 15 + .../utils/MaliciousERC1271Wallet.sol | 66 + ...MaliciousIsValidSignatureERC1271Wallet.sol | 20 + ...aliciousOnERC1155ReceivedERC1271Wallet.sol | 36 + ...C1155ReceivedTheThirdTimeERC1271Wallet.sol | 24 + .../foundry/marketplace/utils/MathLib.sol | 50 + .../marketplace/utils/MerkleWithPosition.sol | 157 + .../marketplace/utils/MockOrderGenerator.sol | 146 + .../marketplace/utils/ProtocolHelpers.sol | 107 + .../StrategyTestMultiFillCollectionOrder.sol | 77 + .../foundry/marketplace/utils/TestHelpers.sol | 26 + .../marketplace/utils/TestParameters.sol | 55 + .../{ => protocol}/AllowlistMinter.t.sol | 27 +- .../foundry/{ => protocol}/Bitshifting.t.sol | 17 +- .../HypercertMinter.batchminting.t.sol | 48 +- .../HypercertMinter.pausable.t.sol | 18 +- .../{ => protocol}/HypercertMinter.t.sol | 42 +- .../HypercertMinter.transfers.t.sol | 14 +- .../{ => protocol}/PerformanceTesting.t.sol | 49 +- .../SemiFungible1155.allowances.t.sol | 8 +- .../protocol/SemiFungible1155.burning.t.sol | 121 + .../SemiFungible1155.minting.t.sol | 24 +- .../{ => protocol}/SemiFungible1155.t.sol | 14 +- .../SemiFungible1155.transfers.t.sol | 18 +- .../{ => protocol}/SemiFungible1155.units.sol | 14 +- .../{ => protocol}/SemiFungibleHelper.sol | 25 +- .../test/mock/MockChainlinkAggregator.sol | 31 + contracts/test/mock/MockERC1155.sol | 29 + .../mock/MockERC1155SupportsNoInterface.sol | 10 + .../mock/MockERC1155WithoutAnyBalanceOf.sol | 21 + .../mock/MockERC1155WithoutBalanceOfBatch.sol | 10 + .../MockERC1155WithoutIsApprovedForAll.sol | 21 + contracts/test/mock/MockERC20.sol | 10 + contracts/test/mock/MockERC721.sol | 31 + .../mock/MockERC721SupportsNoInterface.sol | 10 + .../test/mock/MockERC721WithRoyalties.sol | 53 + .../test/mock/MockRoyaltyFeeRegistry.sol | 95 + contracts/test/mock/MockSmartWallet.sol | 65 + contracts/tsconfig.build.json | 18 +- contracts/tsconfig.json | 21 +- cors-proxy/src/index.ts | 3 + defender/.eslintrc.yml | 2 +- defender/package.json | 8 +- .../batch-mint-claims-from-allowlists.ts | 8 - defender/src/networks.ts | 1 - defender/src/update.ts | 6 +- docs/.eslintrc.yml | 27 + .../api/contracts/HypercertMinter.md | 47 +- .../api/contracts/HypercertTrader.md | 434 +++ .../api/contracts/IHypercertMinter.md | 39 + .../api/contracts/SemiFungible1155.md | 28 +- .../v0.8/interfaces/AggregatorV3Interface.md | 77 + .../contracts/interfaces/IHypercertToken.md | 17 + .../contracts/interfaces/IHypercertTrader.md | 133 + .../marketplace/BatchOrderTypehashRegistry.md | 46 + .../CreatorFeeManagerWithRebates.md | 76 + .../CreatorFeeManagerWithRoyalties.md | 64 + .../contracts/marketplace/CurrencyManager.md | 250 ++ .../contracts/marketplace/ExecutionManager.md | 751 ++++ .../marketplace/InheritedStrategy.md | 9 + .../marketplace/LooksRareProtocol.md | 1157 ++++++ .../api/contracts/marketplace/NonceManager.md | 193 + .../marketplace/ProtocolFeeRecipient.md | 75 + .../contracts/marketplace/StrategyManager.md | 391 ++ .../contracts/marketplace/TransferManager.md | 547 +++ .../marketplace/TransferSelectorNFT.md | 779 ++++ .../executionStrategies/BaseStrategy.md | 41 + .../BaseStrategyChainlinkPriceLatency.md | 212 ++ .../StrategyChainlinkUSDDynamicAsk.md | 342 ++ .../StrategyCollectionOffer.md | 107 + .../StrategyDutchAuction.md | 83 + .../StrategyItemIdsRange.md | 75 + .../marketplace/helpers/OrderValidatorV2A.md | 201 + .../marketplace/helpers/ProtocolHelpers.md | 159 + .../interfaces/ICreatorFeeManager.md | 60 + .../interfaces/ICurrencyManager.md | 22 + .../interfaces/IExecutionManager.md | 99 + .../interfaces/IImmutableCreate2Factory.md | 22 + .../interfaces/ILooksRareProtocol.md | 157 + .../marketplace/interfaces/INonceManager.md | 53 + .../interfaces/IRoyaltyFeeRegistry.md | 29 + .../marketplace/interfaces/IStrategy.md | 41 + .../interfaces/IStrategyManager.md | 84 + .../interfaces/ITransferManager.md | 111 + .../libraries/CurrencyValidator.md | 7 + .../MerkleProofCalldataWithNodes.md | 7 + .../OpenZeppelin/MerkleProofMemory.md | 7 + .../marketplace/libraries/OrderStructs.md | 7 + .../api/contracts/protocol/AllowlistMinter.md | 84 + .../api/contracts/protocol/HypercertMinter.md | 895 +++++ .../contracts/protocol/SemiFungible1155.md | 457 +++ .../protocol/interfaces/IAllowlist.md | 29 + .../protocol/interfaces/IHypercertToken.md | 175 + .../api/contracts/protocol/libs/Errors.md | 59 + docs/package.json | 1 + frontend/.eslintrc.json | 5 - frontend/components/blueprint-create.tsx | 487 --- frontend/components/config.tsx | 15 +- .../contribution-blueprint-create.tsx | 28 - frontend/components/dapp-state.tsx | 4 - frontend/components/hypercert-fetcher.tsx | 2 +- frontend/hooks/burnFraction.ts | 14 +- frontend/hooks/hypercerts-client.ts | 74 +- frontend/hooks/mergeFractionUnits.ts | 13 +- frontend/hooks/mintClaim.ts | 16 +- frontend/hooks/mintClaimAllowlist.ts | 14 +- frontend/hooks/mintFractionAllowlist.ts | 19 +- frontend/hooks/mintFractionAllowlistBatch.ts | 18 +- frontend/hooks/splitClaimUnits.ts | 15 +- frontend/lib/config.ts | 14 +- frontend/lib/hypercert.test.ts | 4 +- frontend/lib/parse-blockchain-error.ts | 13 +- frontend/lib/parsing.test.ts | 44 +- frontend/lib/parsing.ts | 26 +- frontend/next.config.mjs | 1 + frontend/package.json | 10 +- frontend/plasmic-init.ts | 25 - graph/.eslintrc.yml | 11 + graph/abis/HypercertMinter.json | 2189 +++++------ .../HypercertMinter/HypercertMinter.ts | 255 +- graph/generated/schema.ts | 430 +++ graph/schema.graphql | 41 + graph/src/hypercert-minter.ts | 61 +- graph/src/utils.ts | 142 +- graph/subgraph.yaml | 6 +- graph/tests/.latest.json | 2 +- graph/tests/hypercert-minter-burn.test.ts | 189 + graph/tests/hypercert-minter-claim.test.ts | 6 +- graph/tests/hypercert-minter-utils.ts | 147 +- package.json | 9 +- pnpm-lock.yaml | 3363 +++++++++-------- pnpm-workspace.yaml | 2 +- sdk/.graphclient/index.ts | 61 +- sdk/.graphclient/schema.graphql | 4 +- sdk/.graphclientrc.yml | 6 +- sdk/jest.config.ts | 2 +- sdk/package.json | 18 +- sdk/src/client.ts | 361 +- sdk/src/constants.ts | 21 +- sdk/src/evaluations/eas.ts | 155 - sdk/src/evaluations/index.ts | 53 +- sdk/src/index.ts | 12 +- sdk/src/indexer.ts | 9 +- sdk/src/indexer/queries/claims.graphql | 6 +- sdk/src/indexer/queries/fractions.graphql | 6 +- sdk/src/indexer/utils.ts | 2 +- sdk/src/storage.ts | 77 +- sdk/src/types/client.ts | 73 +- sdk/src/types/hypercerts.ts | 4 +- sdk/src/types/index.ts | 16 +- sdk/src/utils/adapters.ts | 41 + sdk/src/utils/config.ts | 216 +- sdk/src/utils/errors.ts | 2 +- sdk/src/utils/formatter.ts | 4 +- sdk/src/utils/resolvers.ts | 6 +- sdk/src/validator/index.ts | 17 +- sdk/test/client.test.ts | 102 +- sdk/test/client/allowlist.minting.test.ts | 247 +- sdk/test/client/burn.test.ts | 109 +- sdk/test/client/minting.test.ts | 123 +- sdk/test/client/split.merge.test.ts | 406 +- sdk/test/evaluations/easEvaluator.test.ts | 90 - sdk/test/evaluations/evaluator.test.ts | 77 +- sdk/test/helpers.ts | 126 +- sdk/test/indexer.test.ts | 2 +- sdk/test/resources/HypercertMinter.json | 1139 ++++++ sdk/test/setup-env.ts | 11 + sdk/test/storage.test.ts | 26 +- sdk/test/storage/nft.storage.test.ts | 49 +- sdk/test/storage/web3.storage.test.ts | 41 +- sdk/test/types/errors.test.ts | 2 +- sdk/test/utils/config.test.ts | 181 +- sdk/test/utils/errors.test.ts | 4 +- sdk/test/utils/formatter.test.ts | 4 +- sdk/test/validator.test.ts | 19 +- sdk/tsconfig.json | 6 +- 300 files changed, 32665 insertions(+), 7033 deletions(-) create mode 100644 .lintstagedignore create mode 100644 LICENSE-APACHE create mode 100644 LICENSE-MIT delete mode 100644 contracts/.solcover.js create mode 100644 contracts/LICENSE create mode 100644 contracts/LICENSE-APACHE rename contracts/{LICENSE.md => LICENSE-MIT} (77%) delete mode 100644 contracts/contracts/AllowlistMinter.sol delete mode 100644 contracts/contracts/HypercertMinter.sol delete mode 100644 contracts/contracts/SemiFungible1155.sol create mode 100644 contracts/scripts/deployment/Deployment.s.sol create mode 100644 contracts/scripts/deployment/ProtocolFeeRecipientDeployment.s.sol delete mode 100644 contracts/src/SemiFungible1155.sol create mode 100644 contracts/src/deployments.json delete mode 100644 contracts/src/interfaces/IAllowlist.sol delete mode 100644 contracts/src/interfaces/IHypercertToken.sol delete mode 100644 contracts/src/libs/Errors.sol create mode 100644 contracts/src/marketplace/BatchOrderTypehashRegistry.sol create mode 100644 contracts/src/marketplace/CreatorFeeManagerWithRebates.sol create mode 100644 contracts/src/marketplace/CreatorFeeManagerWithRoyalties.sol create mode 100644 contracts/src/marketplace/CurrencyManager.sol create mode 100644 contracts/src/marketplace/ExecutionManager.sol create mode 100644 contracts/src/marketplace/InheritedStrategy.sol create mode 100644 contracts/src/marketplace/LooksRareProtocol.sol create mode 100644 contracts/src/marketplace/NonceManager.sol create mode 100644 contracts/src/marketplace/ProtocolFeeRecipient.sol create mode 100644 contracts/src/marketplace/StrategyManager.sol create mode 100644 contracts/src/marketplace/TransferManager.sol create mode 100644 contracts/src/marketplace/TransferSelectorNFT.sol create mode 100644 contracts/src/marketplace/constants/AssemblyConstants.sol create mode 100644 contracts/src/marketplace/constants/NumericConstants.sol create mode 100644 contracts/src/marketplace/constants/ValidationCodeConstants.sol create mode 100644 contracts/src/marketplace/enums/CollectionType.sol create mode 100644 contracts/src/marketplace/enums/QuoteType.sol create mode 100644 contracts/src/marketplace/errors/ChainlinkErrors.sol create mode 100644 contracts/src/marketplace/errors/SharedErrors.sol create mode 100644 contracts/src/marketplace/executionStrategies/BaseStrategy.sol create mode 100644 contracts/src/marketplace/executionStrategies/Chainlink/BaseStrategyChainlinkPriceLatency.sol create mode 100644 contracts/src/marketplace/executionStrategies/Chainlink/StrategyChainlinkUSDDynamicAsk.sol create mode 100644 contracts/src/marketplace/executionStrategies/StrategyCollectionOffer.sol create mode 100644 contracts/src/marketplace/executionStrategies/StrategyDutchAuction.sol create mode 100644 contracts/src/marketplace/executionStrategies/StrategyItemIdsRange.sol create mode 100644 contracts/src/marketplace/helpers/OrderValidatorV2A.sol create mode 100644 contracts/src/marketplace/helpers/ProtocolHelpers.sol create mode 100644 contracts/src/marketplace/interfaces/ICreatorFeeManager.sol create mode 100644 contracts/src/marketplace/interfaces/ICurrencyManager.sol create mode 100644 contracts/src/marketplace/interfaces/IExecutionManager.sol create mode 100644 contracts/src/marketplace/interfaces/IImmutableCreate2Factory.sol create mode 100644 contracts/src/marketplace/interfaces/ILooksRareProtocol.sol create mode 100644 contracts/src/marketplace/interfaces/INonceManager.sol create mode 100644 contracts/src/marketplace/interfaces/IRoyaltyFeeRegistry.sol create mode 100644 contracts/src/marketplace/interfaces/IStrategy.sol create mode 100644 contracts/src/marketplace/interfaces/IStrategyManager.sol create mode 100644 contracts/src/marketplace/interfaces/ITransferManager.sol create mode 100644 contracts/src/marketplace/libraries/CurrencyValidator.sol create mode 100644 contracts/src/marketplace/libraries/OpenZeppelin/MerkleProofCalldataWithNodes.sol create mode 100644 contracts/src/marketplace/libraries/OpenZeppelin/MerkleProofMemory.sol create mode 100644 contracts/src/marketplace/libraries/OrderStructs.sol rename contracts/src/{ => protocol}/AllowlistMinter.sol (83%) rename contracts/src/{ => protocol}/HypercertMinter.sol (80%) create mode 100644 contracts/src/protocol/SemiFungible1155.sol rename contracts/{contracts => src/protocol}/interfaces/IAllowlist.sol (61%) rename contracts/{contracts => src/protocol}/interfaces/IHypercertToken.sol (99%) rename contracts/{contracts => src/protocol}/libs/Errors.sol (100%) delete mode 100644 contracts/test/foundry/SemiFungible1155.burning.t.sol create mode 100644 contracts/test/foundry/marketplace/BatchMakerCollectionOrders.t.sol create mode 100644 contracts/test/foundry/marketplace/BatchMakerOrders.t.sol create mode 100644 contracts/test/foundry/marketplace/BatchOrderTypehashRegistry.t.sol create mode 100644 contracts/test/foundry/marketplace/BundleTransactions.t.sol create mode 100644 contracts/test/foundry/marketplace/CreatorFeeManagerWithRebates.t.sol create mode 100644 contracts/test/foundry/marketplace/CreatorFeeManagerWithRoyalties.t.sol create mode 100644 contracts/test/foundry/marketplace/CurrencyManager.t.sol create mode 100644 contracts/test/foundry/marketplace/DelegationRecipientsTaker.t.sol create mode 100644 contracts/test/foundry/marketplace/DomainSeparatorUpdates.t.sol create mode 100644 contracts/test/foundry/marketplace/ExecutionManager.t.sol create mode 100644 contracts/test/foundry/marketplace/GasGriefing.t.sol create mode 100644 contracts/test/foundry/marketplace/InitialStates.t.sol create mode 100644 contracts/test/foundry/marketplace/LooksRareProtocol.t.sol create mode 100644 contracts/test/foundry/marketplace/NonceInvalidation.t.sol create mode 100644 contracts/test/foundry/marketplace/OrderValidatorV2A.t.sol create mode 100644 contracts/test/foundry/marketplace/ProtocolBase.t.sol create mode 100644 contracts/test/foundry/marketplace/ProtocolFeeRecipient.t.sol create mode 100644 contracts/test/foundry/marketplace/Sandbox.t.sol create mode 100644 contracts/test/foundry/marketplace/SignaturesEIP2098.t.sol create mode 100644 contracts/test/foundry/marketplace/SignaturesERC1271WalletForERC1155.t.sol create mode 100644 contracts/test/foundry/marketplace/SignaturesERC1271WalletForERC721.t.sol create mode 100644 contracts/test/foundry/marketplace/SignaturesRevertions.t.sol create mode 100644 contracts/test/foundry/marketplace/StandardTransactions.t.sol create mode 100644 contracts/test/foundry/marketplace/StrategyManager.t.sol create mode 100644 contracts/test/foundry/marketplace/TransferManager.t.sol create mode 100644 contracts/test/foundry/marketplace/assembly/VerifyOrderTimestampValidityEquivalence.t.sol create mode 100644 contracts/test/foundry/marketplace/executionStrategies/Chainlink/USDDynamicAskOrders.t.sol create mode 100644 contracts/test/foundry/marketplace/executionStrategies/CollectionOffers.t.sol create mode 100644 contracts/test/foundry/marketplace/executionStrategies/DutchAuctionOrders.t.sol create mode 100644 contracts/test/foundry/marketplace/executionStrategies/ItemIdsRangeOrders.t.sol create mode 100644 contracts/test/foundry/marketplace/executionStrategies/MultiFillCollectionOrders.t.sol create mode 100644 contracts/test/foundry/marketplace/utils/BytesLib.sol create mode 100644 contracts/test/foundry/marketplace/utils/EIP712MerkleTree.sol create mode 100644 contracts/test/foundry/marketplace/utils/ERC1271Wallet.sol create mode 100644 contracts/test/foundry/marketplace/utils/GasGriefer.sol create mode 100644 contracts/test/foundry/marketplace/utils/MaliciousERC1271Wallet.sol create mode 100644 contracts/test/foundry/marketplace/utils/MaliciousIsValidSignatureERC1271Wallet.sol create mode 100644 contracts/test/foundry/marketplace/utils/MaliciousOnERC1155ReceivedERC1271Wallet.sol create mode 100644 contracts/test/foundry/marketplace/utils/MaliciousOnERC1155ReceivedTheThirdTimeERC1271Wallet.sol create mode 100644 contracts/test/foundry/marketplace/utils/MathLib.sol create mode 100644 contracts/test/foundry/marketplace/utils/MerkleWithPosition.sol create mode 100644 contracts/test/foundry/marketplace/utils/MockOrderGenerator.sol create mode 100644 contracts/test/foundry/marketplace/utils/ProtocolHelpers.sol create mode 100644 contracts/test/foundry/marketplace/utils/StrategyTestMultiFillCollectionOrder.sol create mode 100644 contracts/test/foundry/marketplace/utils/TestHelpers.sol create mode 100644 contracts/test/foundry/marketplace/utils/TestParameters.sol rename contracts/test/foundry/{ => protocol}/AllowlistMinter.t.sol (90%) rename contracts/test/foundry/{ => protocol}/Bitshifting.t.sol (86%) rename contracts/test/foundry/{ => protocol}/HypercertMinter.batchminting.t.sol (86%) rename contracts/test/foundry/{ => protocol}/HypercertMinter.pausable.t.sol (88%) rename contracts/test/foundry/{ => protocol}/HypercertMinter.t.sol (78%) rename contracts/test/foundry/{ => protocol}/HypercertMinter.transfers.t.sol (92%) rename contracts/test/foundry/{ => protocol}/PerformanceTesting.t.sol (82%) rename contracts/test/foundry/{ => protocol}/SemiFungible1155.allowances.t.sol (94%) create mode 100644 contracts/test/foundry/protocol/SemiFungible1155.burning.t.sol rename contracts/test/foundry/{ => protocol}/SemiFungible1155.minting.t.sol (88%) rename contracts/test/foundry/{ => protocol}/SemiFungible1155.t.sol (91%) rename contracts/test/foundry/{ => protocol}/SemiFungible1155.transfers.t.sol (94%) rename contracts/test/foundry/{ => protocol}/SemiFungible1155.units.sol (89%) rename contracts/test/foundry/{ => protocol}/SemiFungibleHelper.sol (87%) create mode 100644 contracts/test/mock/MockChainlinkAggregator.sol create mode 100644 contracts/test/mock/MockERC1155.sol create mode 100644 contracts/test/mock/MockERC1155SupportsNoInterface.sol create mode 100644 contracts/test/mock/MockERC1155WithoutAnyBalanceOf.sol create mode 100644 contracts/test/mock/MockERC1155WithoutBalanceOfBatch.sol create mode 100644 contracts/test/mock/MockERC1155WithoutIsApprovedForAll.sol create mode 100644 contracts/test/mock/MockERC20.sol create mode 100644 contracts/test/mock/MockERC721.sol create mode 100644 contracts/test/mock/MockERC721SupportsNoInterface.sol create mode 100644 contracts/test/mock/MockERC721WithRoyalties.sol create mode 100644 contracts/test/mock/MockRoyaltyFeeRegistry.sol create mode 100644 contracts/test/mock/MockSmartWallet.sol create mode 100644 docs/.eslintrc.yml create mode 100644 docs/docs/developer/api/contracts/HypercertTrader.md create mode 100644 docs/docs/developer/api/contracts/IHypercertMinter.md create mode 100644 docs/docs/developer/api/contracts/ainlink/contracts/src/v0.8/interfaces/AggregatorV3Interface.md create mode 100644 docs/docs/developer/api/contracts/interfaces/IHypercertTrader.md create mode 100644 docs/docs/developer/api/contracts/marketplace/BatchOrderTypehashRegistry.md create mode 100644 docs/docs/developer/api/contracts/marketplace/CreatorFeeManagerWithRebates.md create mode 100644 docs/docs/developer/api/contracts/marketplace/CreatorFeeManagerWithRoyalties.md create mode 100644 docs/docs/developer/api/contracts/marketplace/CurrencyManager.md create mode 100644 docs/docs/developer/api/contracts/marketplace/ExecutionManager.md create mode 100644 docs/docs/developer/api/contracts/marketplace/InheritedStrategy.md create mode 100644 docs/docs/developer/api/contracts/marketplace/LooksRareProtocol.md create mode 100644 docs/docs/developer/api/contracts/marketplace/NonceManager.md create mode 100644 docs/docs/developer/api/contracts/marketplace/ProtocolFeeRecipient.md create mode 100644 docs/docs/developer/api/contracts/marketplace/StrategyManager.md create mode 100644 docs/docs/developer/api/contracts/marketplace/TransferManager.md create mode 100644 docs/docs/developer/api/contracts/marketplace/TransferSelectorNFT.md create mode 100644 docs/docs/developer/api/contracts/marketplace/executionStrategies/BaseStrategy.md create mode 100644 docs/docs/developer/api/contracts/marketplace/executionStrategies/Chainlink/BaseStrategyChainlinkPriceLatency.md create mode 100644 docs/docs/developer/api/contracts/marketplace/executionStrategies/Chainlink/StrategyChainlinkUSDDynamicAsk.md create mode 100644 docs/docs/developer/api/contracts/marketplace/executionStrategies/StrategyCollectionOffer.md create mode 100644 docs/docs/developer/api/contracts/marketplace/executionStrategies/StrategyDutchAuction.md create mode 100644 docs/docs/developer/api/contracts/marketplace/executionStrategies/StrategyItemIdsRange.md create mode 100644 docs/docs/developer/api/contracts/marketplace/helpers/OrderValidatorV2A.md create mode 100644 docs/docs/developer/api/contracts/marketplace/helpers/ProtocolHelpers.md create mode 100644 docs/docs/developer/api/contracts/marketplace/interfaces/ICreatorFeeManager.md create mode 100644 docs/docs/developer/api/contracts/marketplace/interfaces/ICurrencyManager.md create mode 100644 docs/docs/developer/api/contracts/marketplace/interfaces/IExecutionManager.md create mode 100644 docs/docs/developer/api/contracts/marketplace/interfaces/IImmutableCreate2Factory.md create mode 100644 docs/docs/developer/api/contracts/marketplace/interfaces/ILooksRareProtocol.md create mode 100644 docs/docs/developer/api/contracts/marketplace/interfaces/INonceManager.md create mode 100644 docs/docs/developer/api/contracts/marketplace/interfaces/IRoyaltyFeeRegistry.md create mode 100644 docs/docs/developer/api/contracts/marketplace/interfaces/IStrategy.md create mode 100644 docs/docs/developer/api/contracts/marketplace/interfaces/IStrategyManager.md create mode 100644 docs/docs/developer/api/contracts/marketplace/interfaces/ITransferManager.md create mode 100644 docs/docs/developer/api/contracts/marketplace/libraries/CurrencyValidator.md create mode 100644 docs/docs/developer/api/contracts/marketplace/libraries/OpenZeppelin/MerkleProofCalldataWithNodes.md create mode 100644 docs/docs/developer/api/contracts/marketplace/libraries/OpenZeppelin/MerkleProofMemory.md create mode 100644 docs/docs/developer/api/contracts/marketplace/libraries/OrderStructs.md create mode 100644 docs/docs/developer/api/contracts/protocol/AllowlistMinter.md create mode 100644 docs/docs/developer/api/contracts/protocol/HypercertMinter.md create mode 100644 docs/docs/developer/api/contracts/protocol/SemiFungible1155.md create mode 100644 docs/docs/developer/api/contracts/protocol/interfaces/IAllowlist.md create mode 100644 docs/docs/developer/api/contracts/protocol/interfaces/IHypercertToken.md create mode 100644 docs/docs/developer/api/contracts/protocol/libs/Errors.md delete mode 100644 frontend/components/blueprint-create.tsx delete mode 100644 frontend/components/contribution-blueprint-create.tsx create mode 100644 graph/.eslintrc.yml create mode 100644 graph/tests/hypercert-minter-burn.test.ts delete mode 100644 sdk/src/evaluations/eas.ts create mode 100644 sdk/src/utils/adapters.ts delete mode 100644 sdk/test/evaluations/easEvaluator.test.ts create mode 100644 sdk/test/resources/HypercertMinter.json diff --git a/.github/workflows/ci-default.yml b/.github/workflows/ci-default.yml index a7242d72..a52e21bf 100644 --- a/.github/workflows/ci-default.yml +++ b/.github/workflows/ci-default.yml @@ -7,27 +7,22 @@ env: NEXT_PUBLIC_DEFAULT_CHAIN_ID: ${{ vars.NEXT_PUBLIC_DEFAULT_CHAIN_ID }} NEXT_PUBLIC_CONTRACT_ADDRESS: ${{ vars.NEXT_PUBLIC_CONTRACT_ADDRESS }} NEXT_PUBLIC_GRAPH_URL: ${{ vars.NEXT_PUBLIC_GRAPH_URL }} + NFT_STORAGE_TOKEN: ${{ secrets.NEXT_PUBLIC_NFT_STORAGE_TOKEN }} + WEB3_STORAGE_TOKEN: ${{ secrets.NEXT_PUBLIC_NFT_STORAGE_TOKEN }} NEXT_PUBLIC_NFT_STORAGE_TOKEN: ${{ secrets.NEXT_PUBLIC_NFT_STORAGE_TOKEN }} NEXT_PUBLIC_WEB3_STORAGE_TOKEN: ${{ secrets.NEXT_PUBLIC_NFT_STORAGE_TOKEN }} NEXT_PUBLIC_SUPABASE_URL: ${{ vars.NEXT_PUBLIC_SUPABASE_URL }} NEXT_PUBLIC_SUPABASE_ANON_KEY: ${{ secrets.NEXT_PUBLIC_SUPABASE_ANON_KEY }} NEXT_PUBLIC_SUPABASE_TABLE: ${{ vars.NEXT_PUBLIC_SUPABASE_TABLE }} NEXT_PUBLIC_WALLETCONNECT_ID: ${{ secrets.NEXT_PUBLIC_WALLETCONNECT_ID }} + INFURA_API_KEY: ${{ vars.INFURA_API_KEY }} + ALCHEMY_API_KEY: ${{ vars.ALCHEMY_API_KEY }} DOCKER_PLATFORM: "amd64" # Trigger the workflow when: on: # A push occurs to one of the matched branches. push: - branches: - - main - - develop - # Or when a pull request event occurs for a pull request against one of the - # matched branches. - pull_request: - branches: - - main - - develop # Allows you to run this workflow manually from the Actions tab workflow_dispatch: diff --git a/.github/workflows/e2e-tests.yml b/.github/workflows/e2e-tests.yml index 33c3be37..1337bfe4 100644 --- a/.github/workflows/e2e-tests.yml +++ b/.github/workflows/e2e-tests.yml @@ -16,11 +16,13 @@ on: push: branches: - main + - develop # Or when a pull request event occurs for a pull request against one of the # matched branches. pull_request: branches: - main + - develop # Allows you to run this workflow manually from the Actions tab workflow_dispatch: diff --git a/.lintstagedignore b/.lintstagedignore new file mode 100644 index 00000000..339baae4 --- /dev/null +++ b/.lintstagedignore @@ -0,0 +1,10 @@ +# See https://help.github.com/articles/ignoring-files/ for more about ignoring files. + +# root config +playwright.config.ts + +# patterns +graph/generated/ +e2e +docs +vendor \ No newline at end of file diff --git a/.lintstagedrc b/.lintstagedrc index e6715067..ad678de5 100644 --- a/.lintstagedrc +++ b/.lintstagedrc @@ -1,6 +1,6 @@ { "**/*.{js,jsx,ts,tsx,sol}": [ - "eslint --ignore-path .gitignore --ignore-pattern sdk/ --ignore-pattern graph/generated/ --ignore-pattern graph/", + "eslint --ignore-path .gitignore --ignore-path .lintstagedignore", "prettier --write" ], "**/*.{md,json}": ["prettier --write"] diff --git a/LICENSE b/LICENSE index 261eeb9e..dba11665 100644 --- a/LICENSE +++ b/LICENSE @@ -1,201 +1,4 @@ - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ +This project is dual licensed under MIT and Apache-2.0. - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. +MIT: https://www.opensource.org/licenses/mit +Apache-2.0: https://www.apache.org/licenses/license-2.0 \ No newline at end of file diff --git a/LICENSE-APACHE b/LICENSE-APACHE new file mode 100644 index 00000000..103c2143 --- /dev/null +++ b/LICENSE-APACHE @@ -0,0 +1,13 @@ +Copyright 2023 Hypercerts Foundation + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. diff --git a/LICENSE-MIT b/LICENSE-MIT new file mode 100644 index 00000000..d67b8580 --- /dev/null +++ b/LICENSE-MIT @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright © 2023 Hypercerts Foundation + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. \ No newline at end of file diff --git a/contracts/.env.example b/contracts/.env.example index b7c57fac..235bb631 100644 --- a/contracts/.env.example +++ b/contracts/.env.example @@ -2,7 +2,7 @@ MNEMONIC="test test test test test test test test test test test junk" MNEMONIC_CELO=="test test test test test test test test test test test junk" INFURA_API_KEY="zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz" -ALCHEMY_OPTIMISM_URL="https://opt-mainnet.g.alchemy.com/v2/zzzzzzzzzzzzzzzzzzz" +ALCHEMY_API_KEY="zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz" # OpenZeppelin OPENZEPPELIN_API_KEY="zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz" @@ -14,6 +14,13 @@ OPTIMISTIC_ETHERSCAN_API_KEY="zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz" CELOSCAN_API_KEY="zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz" # Unused, ignore below -POLYGONSCAN_API_KEY="zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz" REPORT_GAS=false CMC_API_KEY="zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz" + +# Marketplace +OWNER_ADDRESS="aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" +TRANSFER_MANAGER_SALT="bbbbbbbbbbbbbb" +LOOKSRARE_PROTOCOL_SALT="cccccccccccccc" +STRATEGY_COLLECTION_OFFER_SALT="dddddddddddddd" +PROTOCOL_FEE_RECIPIENT_ADDRESS="eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee" + diff --git a/contracts/.eslintrc.yml b/contracts/.eslintrc.yml index a6c77c81..bc63dc32 100644 --- a/contracts/.eslintrc.yml +++ b/contracts/.eslintrc.yml @@ -8,13 +8,3 @@ parserOptions: project: "./contracts/tsconfig.json" plugins: - "@typescript-eslint" -rules: - "@typescript-eslint/no-floating-promises": - - error - - ignoreIIFE: true - ignoreVoid: true - "@typescript-eslint/no-inferrable-types": "off" - "@typescript-eslint/no-unused-vars": - - error - - argsIgnorePattern: "_" - varsIgnorePattern: "_" diff --git a/contracts/.gitignore b/contracts/.gitignore index 41c2623f..2d812b19 100644 --- a/contracts/.gitignore +++ b/contracts/.gitignore @@ -18,7 +18,7 @@ **/deployments/localhost **/out* **/typechain -**/src/types +**/types **/cache** **/abi **/rollup-cache @@ -35,6 +35,7 @@ yarn-error.log* .DS_Store /.idea test*.svg +lcov.info # broadcasts !/broadcast diff --git a/contracts/.lintstagedrc b/contracts/.lintstagedrc index 45a7492d..0e2564c9 100644 --- a/contracts/.lintstagedrc +++ b/contracts/.lintstagedrc @@ -1,5 +1,4 @@ { - "*.{js,json,md,sol,ts,yml}": [ - "prettier --config ./.prettierrc.yml --write" - ] + "*.{js,json,md,ts,yml}": ["prettier --config ./.prettierrc.yml --write"], + "*.{sol}": ["forge fmt"] } diff --git a/contracts/.openzeppelin/goerli.json b/contracts/.openzeppelin/goerli.json index e9968158..4058c77b 100644 --- a/contracts/.openzeppelin/goerli.json +++ b/contracts/.openzeppelin/goerli.json @@ -30,6 +30,11 @@ "address": "0x822F17A9A5EeCFd66dBAFf7946a8071C265D1d07", "txHash": "0xeeb032f25fb656971f835204d0bd825f766593afadfe420110903420bb4f7071", "kind": "uups" + }, + { + "address": "0x689587461AA3103D3D7975c5e4B352Ab711C14C2", + "txHash": "0x236119a264468c853263e067fbde6781c2c4109a5a3027a9adcfdca56b9bdacb", + "kind": "uups" } ], "impls": { @@ -4403,6 +4408,1501 @@ } } } + }, + "a74a0b26cd000c4d5c3717e7e2b2c4060405bf4c2f315356073581f711bf134d": { + "address": "0xDb77A1fDC905685B4052a512522D502638DdA5E3", + "txHash": "0xfe64805f07143e91ce6d02ce69e95c21f688a0cc083495baafba764274de05ff", + "layout": { + "solcVersion": "0.8.16", + "storage": [ + { + "label": "_initialized", + "offset": 0, + "slot": "0", + "type": "t_uint8", + "contract": "Initializable", + "src": "lib/openzeppelin-contracts-upgradeable/contracts/proxy/utils/Initializable.sol:62", + "retypedFrom": "bool" + }, + { + "label": "_initializing", + "offset": 1, + "slot": "0", + "type": "t_bool", + "contract": "Initializable", + "src": "lib/openzeppelin-contracts-upgradeable/contracts/proxy/utils/Initializable.sol:67" + }, + { + "label": "__gap", + "offset": 0, + "slot": "1", + "type": "t_array(t_uint256)50_storage", + "contract": "ContextUpgradeable", + "src": "lib/openzeppelin-contracts-upgradeable/contracts/utils/ContextUpgradeable.sol:36" + }, + { + "label": "__gap", + "offset": 0, + "slot": "51", + "type": "t_array(t_uint256)50_storage", + "contract": "ERC165Upgradeable", + "src": "lib/openzeppelin-contracts-upgradeable/contracts/utils/introspection/ERC165Upgradeable.sol:41" + }, + { + "label": "_balances", + "offset": 0, + "slot": "101", + "type": "t_mapping(t_uint256,t_mapping(t_address,t_uint256))", + "contract": "ERC1155Upgradeable", + "src": "lib/openzeppelin-contracts-upgradeable/contracts/token/ERC1155/ERC1155Upgradeable.sol:25" + }, + { + "label": "_operatorApprovals", + "offset": 0, + "slot": "102", + "type": "t_mapping(t_address,t_mapping(t_address,t_bool))", + "contract": "ERC1155Upgradeable", + "src": "lib/openzeppelin-contracts-upgradeable/contracts/token/ERC1155/ERC1155Upgradeable.sol:28" + }, + { + "label": "_uri", + "offset": 0, + "slot": "103", + "type": "t_string_storage", + "contract": "ERC1155Upgradeable", + "src": "lib/openzeppelin-contracts-upgradeable/contracts/token/ERC1155/ERC1155Upgradeable.sol:31" + }, + { + "label": "__gap", + "offset": 0, + "slot": "104", + "type": "t_array(t_uint256)47_storage", + "contract": "ERC1155Upgradeable", + "src": "lib/openzeppelin-contracts-upgradeable/contracts/token/ERC1155/ERC1155Upgradeable.sol:528" + }, + { + "label": "__gap", + "offset": 0, + "slot": "151", + "type": "t_array(t_uint256)50_storage", + "contract": "ERC1155BurnableUpgradeable", + "src": "lib/openzeppelin-contracts-upgradeable/contracts/token/ERC1155/extensions/ERC1155BurnableUpgradeable.sol:52" + }, + { + "label": "_baseURI", + "offset": 0, + "slot": "201", + "type": "t_string_storage", + "contract": "ERC1155URIStorageUpgradeable", + "src": "lib/openzeppelin-contracts-upgradeable/contracts/token/ERC1155/extensions/ERC1155URIStorageUpgradeable.sol:27" + }, + { + "label": "_tokenURIs", + "offset": 0, + "slot": "202", + "type": "t_mapping(t_uint256,t_string_storage)", + "contract": "ERC1155URIStorageUpgradeable", + "src": "lib/openzeppelin-contracts-upgradeable/contracts/token/ERC1155/extensions/ERC1155URIStorageUpgradeable.sol:30" + }, + { + "label": "__gap", + "offset": 0, + "slot": "203", + "type": "t_array(t_uint256)48_storage", + "contract": "ERC1155URIStorageUpgradeable", + "src": "lib/openzeppelin-contracts-upgradeable/contracts/token/ERC1155/extensions/ERC1155URIStorageUpgradeable.sol:77" + }, + { + "label": "_owner", + "offset": 0, + "slot": "251", + "type": "t_address", + "contract": "OwnableUpgradeable", + "src": "lib/openzeppelin-contracts-upgradeable/contracts/access/OwnableUpgradeable.sol:22" + }, + { + "label": "__gap", + "offset": 0, + "slot": "252", + "type": "t_array(t_uint256)49_storage", + "contract": "OwnableUpgradeable", + "src": "lib/openzeppelin-contracts-upgradeable/contracts/access/OwnableUpgradeable.sol:94" + }, + { + "label": "__gap", + "offset": 0, + "slot": "301", + "type": "t_array(t_uint256)50_storage", + "contract": "ERC1967UpgradeUpgradeable", + "src": "lib/openzeppelin-contracts-upgradeable/contracts/proxy/ERC1967/ERC1967UpgradeUpgradeable.sol:211" + }, + { + "label": "__gap", + "offset": 0, + "slot": "351", + "type": "t_array(t_uint256)50_storage", + "contract": "UUPSUpgradeable", + "src": "lib/openzeppelin-contracts-upgradeable/contracts/proxy/utils/UUPSUpgradeable.sol:107" + }, + { + "label": "typeCounter", + "offset": 0, + "slot": "401", + "type": "t_uint256", + "contract": "SemiFungible1155", + "src": "src/SemiFungible1155.sol:27" + }, + { + "label": "owners", + "offset": 0, + "slot": "402", + "type": "t_mapping(t_uint256,t_address)", + "contract": "SemiFungible1155", + "src": "src/SemiFungible1155.sol:38" + }, + { + "label": "creators", + "offset": 0, + "slot": "403", + "type": "t_mapping(t_uint256,t_address)", + "contract": "SemiFungible1155", + "src": "src/SemiFungible1155.sol:41" + }, + { + "label": "tokenValues", + "offset": 0, + "slot": "404", + "type": "t_mapping(t_uint256,t_uint256)", + "contract": "SemiFungible1155", + "src": "src/SemiFungible1155.sol:44" + }, + { + "label": "maxIndex", + "offset": 0, + "slot": "405", + "type": "t_mapping(t_uint256,t_uint256)", + "contract": "SemiFungible1155", + "src": "src/SemiFungible1155.sol:47" + }, + { + "label": "__gap", + "offset": 0, + "slot": "406", + "type": "t_array(t_uint256)25_storage", + "contract": "SemiFungible1155", + "src": "src/SemiFungible1155.sol:612" + }, + { + "label": "merkleRoots", + "offset": 0, + "slot": "431", + "type": "t_mapping(t_uint256,t_bytes32)", + "contract": "AllowlistMinter", + "src": "src/AllowlistMinter.sol:17" + }, + { + "label": "hasBeenClaimed", + "offset": 0, + "slot": "432", + "type": "t_mapping(t_uint256,t_mapping(t_bytes32,t_bool))", + "contract": "AllowlistMinter", + "src": "src/AllowlistMinter.sol:18" + }, + { + "label": "maxUnits", + "offset": 0, + "slot": "433", + "type": "t_mapping(t_uint256,t_uint256)", + "contract": "AllowlistMinter", + "src": "src/AllowlistMinter.sol:19" + }, + { + "label": "minted", + "offset": 0, + "slot": "434", + "type": "t_mapping(t_uint256,t_uint256)", + "contract": "AllowlistMinter", + "src": "src/AllowlistMinter.sol:20" + }, + { + "label": "__gap", + "offset": 0, + "slot": "435", + "type": "t_array(t_uint256)26_storage", + "contract": "AllowlistMinter", + "src": "src/AllowlistMinter.sol:69" + }, + { + "label": "_paused", + "offset": 0, + "slot": "461", + "type": "t_bool", + "contract": "PausableUpgradeable", + "src": "lib/openzeppelin-contracts-upgradeable/contracts/security/PausableUpgradeable.sol:29" + }, + { + "label": "__gap", + "offset": 0, + "slot": "462", + "type": "t_array(t_uint256)49_storage", + "contract": "PausableUpgradeable", + "src": "lib/openzeppelin-contracts-upgradeable/contracts/security/PausableUpgradeable.sol:116" + }, + { + "label": "typeRestrictions", + "offset": 0, + "slot": "511", + "type": "t_mapping(t_uint256,t_enum(TransferRestrictions)6957)", + "contract": "HypercertMinter", + "src": "src/HypercertMinter.sol:20" + }, + { + "label": "__gap", + "offset": 0, + "slot": "512", + "type": "t_array(t_uint256)29_storage", + "contract": "HypercertMinter", + "src": "src/HypercertMinter.sol:246" + } + ], + "types": { + "t_address": { + "label": "address", + "numberOfBytes": "20" + }, + "t_array(t_uint256)25_storage": { + "label": "uint256[25]", + "numberOfBytes": "800" + }, + "t_array(t_uint256)26_storage": { + "label": "uint256[26]", + "numberOfBytes": "832" + }, + "t_array(t_uint256)29_storage": { + "label": "uint256[29]", + "numberOfBytes": "928" + }, + "t_array(t_uint256)47_storage": { + "label": "uint256[47]", + "numberOfBytes": "1504" + }, + "t_array(t_uint256)48_storage": { + "label": "uint256[48]", + "numberOfBytes": "1536" + }, + "t_array(t_uint256)49_storage": { + "label": "uint256[49]", + "numberOfBytes": "1568" + }, + "t_array(t_uint256)50_storage": { + "label": "uint256[50]", + "numberOfBytes": "1600" + }, + "t_bool": { + "label": "bool", + "numberOfBytes": "1" + }, + "t_bytes32": { + "label": "bytes32", + "numberOfBytes": "32" + }, + "t_enum(TransferRestrictions)6957": { + "label": "enum IHypercertToken.TransferRestrictions", + "members": [ + "AllowAll", + "DisallowAll", + "FromCreatorOnly" + ], + "numberOfBytes": "1" + }, + "t_mapping(t_address,t_bool)": { + "label": "mapping(address => bool)", + "numberOfBytes": "32" + }, + "t_mapping(t_address,t_mapping(t_address,t_bool))": { + "label": "mapping(address => mapping(address => bool))", + "numberOfBytes": "32" + }, + "t_mapping(t_address,t_uint256)": { + "label": "mapping(address => uint256)", + "numberOfBytes": "32" + }, + "t_mapping(t_bytes32,t_bool)": { + "label": "mapping(bytes32 => bool)", + "numberOfBytes": "32" + }, + "t_mapping(t_uint256,t_address)": { + "label": "mapping(uint256 => address)", + "numberOfBytes": "32" + }, + "t_mapping(t_uint256,t_bytes32)": { + "label": "mapping(uint256 => bytes32)", + "numberOfBytes": "32" + }, + "t_mapping(t_uint256,t_enum(TransferRestrictions)6957)": { + "label": "mapping(uint256 => enum IHypercertToken.TransferRestrictions)", + "numberOfBytes": "32" + }, + "t_mapping(t_uint256,t_mapping(t_address,t_uint256))": { + "label": "mapping(uint256 => mapping(address => uint256))", + "numberOfBytes": "32" + }, + "t_mapping(t_uint256,t_mapping(t_bytes32,t_bool))": { + "label": "mapping(uint256 => mapping(bytes32 => bool))", + "numberOfBytes": "32" + }, + "t_mapping(t_uint256,t_string_storage)": { + "label": "mapping(uint256 => string)", + "numberOfBytes": "32" + }, + "t_mapping(t_uint256,t_uint256)": { + "label": "mapping(uint256 => uint256)", + "numberOfBytes": "32" + }, + "t_string_storage": { + "label": "string", + "numberOfBytes": "32" + }, + "t_uint256": { + "label": "uint256", + "numberOfBytes": "32" + }, + "t_uint8": { + "label": "uint8", + "numberOfBytes": "1" + } + } + } + }, + "d1832c305d4610ff816070ba0b32f8fcbb0e86cead29b4261acf08bd5c0836e6": { + "address": "0x8561eAE9962FA3af19e2E972Ea717d4AD407BDbF", + "txHash": "0x0bcef85a53eb6fdec51cfa3c817e013b1ecf19f0a9387384202fae0ef66985a2", + "layout": { + "solcVersion": "0.8.16", + "storage": [ + { + "label": "_initialized", + "offset": 0, + "slot": "0", + "type": "t_uint8", + "contract": "Initializable", + "src": "lib/openzeppelin-contracts-upgradeable/contracts/proxy/utils/Initializable.sol:62", + "retypedFrom": "bool" + }, + { + "label": "_initializing", + "offset": 1, + "slot": "0", + "type": "t_bool", + "contract": "Initializable", + "src": "lib/openzeppelin-contracts-upgradeable/contracts/proxy/utils/Initializable.sol:67" + }, + { + "label": "__gap", + "offset": 0, + "slot": "1", + "type": "t_array(t_uint256)50_storage", + "contract": "ContextUpgradeable", + "src": "lib/openzeppelin-contracts-upgradeable/contracts/utils/ContextUpgradeable.sol:36" + }, + { + "label": "_owner", + "offset": 0, + "slot": "51", + "type": "t_address", + "contract": "OwnableUpgradeable", + "src": "lib/openzeppelin-contracts-upgradeable/contracts/access/OwnableUpgradeable.sol:22" + }, + { + "label": "__gap", + "offset": 0, + "slot": "52", + "type": "t_array(t_uint256)49_storage", + "contract": "OwnableUpgradeable", + "src": "lib/openzeppelin-contracts-upgradeable/contracts/access/OwnableUpgradeable.sol:94" + }, + { + "label": "_paused", + "offset": 0, + "slot": "101", + "type": "t_bool", + "contract": "PausableUpgradeable", + "src": "lib/openzeppelin-contracts-upgradeable/contracts/security/PausableUpgradeable.sol:29" + }, + { + "label": "__gap", + "offset": 0, + "slot": "102", + "type": "t_array(t_uint256)49_storage", + "contract": "PausableUpgradeable", + "src": "lib/openzeppelin-contracts-upgradeable/contracts/security/PausableUpgradeable.sol:116" + }, + { + "label": "__gap", + "offset": 0, + "slot": "151", + "type": "t_array(t_uint256)50_storage", + "contract": "ERC1967UpgradeUpgradeable", + "src": "lib/openzeppelin-contracts-upgradeable/contracts/proxy/ERC1967/ERC1967UpgradeUpgradeable.sol:211" + }, + { + "label": "__gap", + "offset": 0, + "slot": "201", + "type": "t_array(t_uint256)50_storage", + "contract": "UUPSUpgradeable", + "src": "lib/openzeppelin-contracts-upgradeable/contracts/proxy/utils/UUPSUpgradeable.sol:107" + }, + { + "label": "totalUnitsForSale", + "offset": 0, + "slot": "251", + "type": "t_mapping(t_address,t_mapping(t_uint256,t_uint256))", + "contract": "HypercertTrader", + "src": "src/HypercertTrader.sol:30" + }, + { + "label": "offers", + "offset": 0, + "slot": "252", + "type": "t_mapping(t_uint256,t_struct(Offer)7905_storage)", + "contract": "HypercertTrader", + "src": "src/HypercertTrader.sol:31" + }, + { + "label": "_offerCounter", + "offset": 0, + "slot": "253", + "type": "t_uint256", + "contract": "HypercertTrader", + "src": "src/HypercertTrader.sol:32" + }, + { + "label": "__gap", + "offset": 0, + "slot": "254", + "type": "t_array(t_uint256)27_storage", + "contract": "HypercertTrader", + "src": "src/HypercertTrader.sol:359" + } + ], + "types": { + "t_address": { + "label": "address", + "numberOfBytes": "20" + }, + "t_array(t_struct(AcceptedToken)7917_storage)dyn_storage": { + "label": "struct IHypercertTrader.AcceptedToken[]", + "numberOfBytes": "32" + }, + "t_array(t_uint256)27_storage": { + "label": "uint256[27]", + "numberOfBytes": "864" + }, + "t_array(t_uint256)49_storage": { + "label": "uint256[49]", + "numberOfBytes": "1568" + }, + "t_array(t_uint256)50_storage": { + "label": "uint256[50]", + "numberOfBytes": "1600" + }, + "t_bool": { + "label": "bool", + "numberOfBytes": "1" + }, + "t_enum(OfferStatus)7912": { + "label": "enum IHypercertTrader.OfferStatus", + "members": [ + "Open", + "Fulfilled", + "Cancelled" + ], + "numberOfBytes": "1" + }, + "t_enum(OfferType)7908": { + "label": "enum IHypercertTrader.OfferType", + "members": [ + "Units", + "Fraction" + ], + "numberOfBytes": "1" + }, + "t_mapping(t_address,t_mapping(t_uint256,t_uint256))": { + "label": "mapping(address => mapping(uint256 => uint256))", + "numberOfBytes": "32" + }, + "t_mapping(t_uint256,t_struct(Offer)7905_storage)": { + "label": "mapping(uint256 => struct IHypercertTrader.Offer)", + "numberOfBytes": "32" + }, + "t_mapping(t_uint256,t_uint256)": { + "label": "mapping(uint256 => uint256)", + "numberOfBytes": "32" + }, + "t_struct(AcceptedToken)7917_storage": { + "label": "struct IHypercertTrader.AcceptedToken", + "members": [ + { + "label": "token", + "type": "t_address", + "offset": 0, + "slot": "0" + }, + { + "label": "minimumAmountPerUnit", + "type": "t_uint256", + "offset": 0, + "slot": "1" + } + ], + "numberOfBytes": "64" + }, + "t_struct(Offer)7905_storage": { + "label": "struct IHypercertTrader.Offer", + "members": [ + { + "label": "offerer", + "type": "t_address", + "offset": 0, + "slot": "0" + }, + { + "label": "hypercertContract", + "type": "t_address", + "offset": 0, + "slot": "1" + }, + { + "label": "fractionID", + "type": "t_uint256", + "offset": 0, + "slot": "2" + }, + { + "label": "unitsAvailable", + "type": "t_uint256", + "offset": 0, + "slot": "3" + }, + { + "label": "minUnitsPerTrade", + "type": "t_uint256", + "offset": 0, + "slot": "4" + }, + { + "label": "maxUnitsPerTrade", + "type": "t_uint256", + "offset": 0, + "slot": "5" + }, + { + "label": "offerType", + "type": "t_enum(OfferType)7908", + "offset": 0, + "slot": "6" + }, + { + "label": "status", + "type": "t_enum(OfferStatus)7912", + "offset": 1, + "slot": "6" + }, + { + "label": "acceptedTokens", + "type": "t_array(t_struct(AcceptedToken)7917_storage)dyn_storage", + "offset": 0, + "slot": "7" + } + ], + "numberOfBytes": "256" + }, + "t_uint256": { + "label": "uint256", + "numberOfBytes": "32" + }, + "t_uint8": { + "label": "uint8", + "numberOfBytes": "1" + } + } + } + }, + "dd332b99b39b573f44ffeb5c8685891923934c7ddf4763cc7767f224483eff8a": { + "address": "0x0A00a2f09cd37B24E7429c5238323bfebCfF3Ed9", + "txHash": "0xa2c8831ddf933b36362efd3e4cd6a0f2ba640d0a4908f3f97ae43c4661077ead", + "layout": { + "solcVersion": "0.8.16", + "storage": [ + { + "label": "_initialized", + "offset": 0, + "slot": "0", + "type": "t_uint8", + "contract": "Initializable", + "src": "lib/openzeppelin-contracts-upgradeable/contracts/proxy/utils/Initializable.sol:62", + "retypedFrom": "bool" + }, + { + "label": "_initializing", + "offset": 1, + "slot": "0", + "type": "t_bool", + "contract": "Initializable", + "src": "lib/openzeppelin-contracts-upgradeable/contracts/proxy/utils/Initializable.sol:67" + }, + { + "label": "__gap", + "offset": 0, + "slot": "1", + "type": "t_array(t_uint256)50_storage", + "contract": "ContextUpgradeable", + "src": "lib/openzeppelin-contracts-upgradeable/contracts/utils/ContextUpgradeable.sol:36" + }, + { + "label": "__gap", + "offset": 0, + "slot": "51", + "type": "t_array(t_uint256)50_storage", + "contract": "ERC165Upgradeable", + "src": "lib/openzeppelin-contracts-upgradeable/contracts/utils/introspection/ERC165Upgradeable.sol:41" + }, + { + "label": "_balances", + "offset": 0, + "slot": "101", + "type": "t_mapping(t_uint256,t_mapping(t_address,t_uint256))", + "contract": "ERC1155Upgradeable", + "src": "lib/openzeppelin-contracts-upgradeable/contracts/token/ERC1155/ERC1155Upgradeable.sol:25" + }, + { + "label": "_operatorApprovals", + "offset": 0, + "slot": "102", + "type": "t_mapping(t_address,t_mapping(t_address,t_bool))", + "contract": "ERC1155Upgradeable", + "src": "lib/openzeppelin-contracts-upgradeable/contracts/token/ERC1155/ERC1155Upgradeable.sol:28" + }, + { + "label": "_uri", + "offset": 0, + "slot": "103", + "type": "t_string_storage", + "contract": "ERC1155Upgradeable", + "src": "lib/openzeppelin-contracts-upgradeable/contracts/token/ERC1155/ERC1155Upgradeable.sol:31" + }, + { + "label": "__gap", + "offset": 0, + "slot": "104", + "type": "t_array(t_uint256)47_storage", + "contract": "ERC1155Upgradeable", + "src": "lib/openzeppelin-contracts-upgradeable/contracts/token/ERC1155/ERC1155Upgradeable.sol:528" + }, + { + "label": "__gap", + "offset": 0, + "slot": "151", + "type": "t_array(t_uint256)50_storage", + "contract": "ERC1155BurnableUpgradeable", + "src": "lib/openzeppelin-contracts-upgradeable/contracts/token/ERC1155/extensions/ERC1155BurnableUpgradeable.sol:52" + }, + { + "label": "_baseURI", + "offset": 0, + "slot": "201", + "type": "t_string_storage", + "contract": "ERC1155URIStorageUpgradeable", + "src": "lib/openzeppelin-contracts-upgradeable/contracts/token/ERC1155/extensions/ERC1155URIStorageUpgradeable.sol:27" + }, + { + "label": "_tokenURIs", + "offset": 0, + "slot": "202", + "type": "t_mapping(t_uint256,t_string_storage)", + "contract": "ERC1155URIStorageUpgradeable", + "src": "lib/openzeppelin-contracts-upgradeable/contracts/token/ERC1155/extensions/ERC1155URIStorageUpgradeable.sol:30" + }, + { + "label": "__gap", + "offset": 0, + "slot": "203", + "type": "t_array(t_uint256)48_storage", + "contract": "ERC1155URIStorageUpgradeable", + "src": "lib/openzeppelin-contracts-upgradeable/contracts/token/ERC1155/extensions/ERC1155URIStorageUpgradeable.sol:77" + }, + { + "label": "_owner", + "offset": 0, + "slot": "251", + "type": "t_address", + "contract": "OwnableUpgradeable", + "src": "lib/openzeppelin-contracts-upgradeable/contracts/access/OwnableUpgradeable.sol:22" + }, + { + "label": "__gap", + "offset": 0, + "slot": "252", + "type": "t_array(t_uint256)49_storage", + "contract": "OwnableUpgradeable", + "src": "lib/openzeppelin-contracts-upgradeable/contracts/access/OwnableUpgradeable.sol:94" + }, + { + "label": "__gap", + "offset": 0, + "slot": "301", + "type": "t_array(t_uint256)50_storage", + "contract": "ERC1967UpgradeUpgradeable", + "src": "lib/openzeppelin-contracts-upgradeable/contracts/proxy/ERC1967/ERC1967UpgradeUpgradeable.sol:211" + }, + { + "label": "__gap", + "offset": 0, + "slot": "351", + "type": "t_array(t_uint256)50_storage", + "contract": "UUPSUpgradeable", + "src": "lib/openzeppelin-contracts-upgradeable/contracts/proxy/utils/UUPSUpgradeable.sol:107" + }, + { + "label": "typeCounter", + "offset": 0, + "slot": "401", + "type": "t_uint256", + "contract": "SemiFungible1155", + "src": "src/SemiFungible1155.sol:27" + }, + { + "label": "owners", + "offset": 0, + "slot": "402", + "type": "t_mapping(t_uint256,t_address)", + "contract": "SemiFungible1155", + "src": "src/SemiFungible1155.sol:38" + }, + { + "label": "creators", + "offset": 0, + "slot": "403", + "type": "t_mapping(t_uint256,t_address)", + "contract": "SemiFungible1155", + "src": "src/SemiFungible1155.sol:41" + }, + { + "label": "tokenValues", + "offset": 0, + "slot": "404", + "type": "t_mapping(t_uint256,t_uint256)", + "contract": "SemiFungible1155", + "src": "src/SemiFungible1155.sol:44" + }, + { + "label": "maxIndex", + "offset": 0, + "slot": "405", + "type": "t_mapping(t_uint256,t_uint256)", + "contract": "SemiFungible1155", + "src": "src/SemiFungible1155.sol:47" + }, + { + "label": "__gap", + "offset": 0, + "slot": "406", + "type": "t_array(t_uint256)25_storage", + "contract": "SemiFungible1155", + "src": "src/SemiFungible1155.sol:612" + }, + { + "label": "merkleRoots", + "offset": 0, + "slot": "431", + "type": "t_mapping(t_uint256,t_bytes32)", + "contract": "AllowlistMinter", + "src": "src/AllowlistMinter.sol:17" + }, + { + "label": "hasBeenClaimed", + "offset": 0, + "slot": "432", + "type": "t_mapping(t_uint256,t_mapping(t_bytes32,t_bool))", + "contract": "AllowlistMinter", + "src": "src/AllowlistMinter.sol:18" + }, + { + "label": "maxUnits", + "offset": 0, + "slot": "433", + "type": "t_mapping(t_uint256,t_uint256)", + "contract": "AllowlistMinter", + "src": "src/AllowlistMinter.sol:19" + }, + { + "label": "minted", + "offset": 0, + "slot": "434", + "type": "t_mapping(t_uint256,t_uint256)", + "contract": "AllowlistMinter", + "src": "src/AllowlistMinter.sol:20" + }, + { + "label": "__gap", + "offset": 0, + "slot": "435", + "type": "t_array(t_uint256)26_storage", + "contract": "AllowlistMinter", + "src": "src/AllowlistMinter.sol:69" + }, + { + "label": "_paused", + "offset": 0, + "slot": "461", + "type": "t_bool", + "contract": "PausableUpgradeable", + "src": "lib/openzeppelin-contracts-upgradeable/contracts/security/PausableUpgradeable.sol:29" + }, + { + "label": "__gap", + "offset": 0, + "slot": "462", + "type": "t_array(t_uint256)49_storage", + "contract": "PausableUpgradeable", + "src": "lib/openzeppelin-contracts-upgradeable/contracts/security/PausableUpgradeable.sol:116" + }, + { + "label": "typeRestrictions", + "offset": 0, + "slot": "511", + "type": "t_mapping(t_uint256,t_enum(TransferRestrictions)7777)", + "contract": "HypercertMinter", + "src": "src/HypercertMinter.sol:20" + }, + { + "label": "__gap", + "offset": 0, + "slot": "512", + "type": "t_array(t_uint256)29_storage", + "contract": "HypercertMinter", + "src": "src/HypercertMinter.sol:246" + } + ], + "types": { + "t_address": { + "label": "address", + "numberOfBytes": "20" + }, + "t_array(t_uint256)25_storage": { + "label": "uint256[25]", + "numberOfBytes": "800" + }, + "t_array(t_uint256)26_storage": { + "label": "uint256[26]", + "numberOfBytes": "832" + }, + "t_array(t_uint256)29_storage": { + "label": "uint256[29]", + "numberOfBytes": "928" + }, + "t_array(t_uint256)47_storage": { + "label": "uint256[47]", + "numberOfBytes": "1504" + }, + "t_array(t_uint256)48_storage": { + "label": "uint256[48]", + "numberOfBytes": "1536" + }, + "t_array(t_uint256)49_storage": { + "label": "uint256[49]", + "numberOfBytes": "1568" + }, + "t_array(t_uint256)50_storage": { + "label": "uint256[50]", + "numberOfBytes": "1600" + }, + "t_bool": { + "label": "bool", + "numberOfBytes": "1" + }, + "t_bytes32": { + "label": "bytes32", + "numberOfBytes": "32" + }, + "t_enum(TransferRestrictions)7777": { + "label": "enum IHypercertToken.TransferRestrictions", + "members": [ + "AllowAll", + "DisallowAll", + "FromCreatorOnly" + ], + "numberOfBytes": "1" + }, + "t_mapping(t_address,t_bool)": { + "label": "mapping(address => bool)", + "numberOfBytes": "32" + }, + "t_mapping(t_address,t_mapping(t_address,t_bool))": { + "label": "mapping(address => mapping(address => bool))", + "numberOfBytes": "32" + }, + "t_mapping(t_address,t_uint256)": { + "label": "mapping(address => uint256)", + "numberOfBytes": "32" + }, + "t_mapping(t_bytes32,t_bool)": { + "label": "mapping(bytes32 => bool)", + "numberOfBytes": "32" + }, + "t_mapping(t_uint256,t_address)": { + "label": "mapping(uint256 => address)", + "numberOfBytes": "32" + }, + "t_mapping(t_uint256,t_bytes32)": { + "label": "mapping(uint256 => bytes32)", + "numberOfBytes": "32" + }, + "t_mapping(t_uint256,t_enum(TransferRestrictions)7777)": { + "label": "mapping(uint256 => enum IHypercertToken.TransferRestrictions)", + "numberOfBytes": "32" + }, + "t_mapping(t_uint256,t_mapping(t_address,t_uint256))": { + "label": "mapping(uint256 => mapping(address => uint256))", + "numberOfBytes": "32" + }, + "t_mapping(t_uint256,t_mapping(t_bytes32,t_bool))": { + "label": "mapping(uint256 => mapping(bytes32 => bool))", + "numberOfBytes": "32" + }, + "t_mapping(t_uint256,t_string_storage)": { + "label": "mapping(uint256 => string)", + "numberOfBytes": "32" + }, + "t_mapping(t_uint256,t_uint256)": { + "label": "mapping(uint256 => uint256)", + "numberOfBytes": "32" + }, + "t_string_storage": { + "label": "string", + "numberOfBytes": "32" + }, + "t_uint256": { + "label": "uint256", + "numberOfBytes": "32" + }, + "t_uint8": { + "label": "uint8", + "numberOfBytes": "1" + } + } + } + }, + "18f4479dd70171f19657f8c092580a0d6e9ec28cf1867e45d3e9e87aff3e1ee2": { + "address": "0xFf3F27c6132c30d1098b97FfeC05C3150dA90432", + "txHash": "0xaf2c9d0708fafea03a10da1e6b25f340c4a2847b09032d2890d40167496c7b49", + "layout": { + "solcVersion": "0.8.16", + "storage": [ + { + "label": "_initialized", + "offset": 0, + "slot": "0", + "type": "t_uint8", + "contract": "Initializable", + "src": "lib/openzeppelin-contracts-upgradeable/contracts/proxy/utils/Initializable.sol:62", + "retypedFrom": "bool" + }, + { + "label": "_initializing", + "offset": 1, + "slot": "0", + "type": "t_bool", + "contract": "Initializable", + "src": "lib/openzeppelin-contracts-upgradeable/contracts/proxy/utils/Initializable.sol:67" + }, + { + "label": "__gap", + "offset": 0, + "slot": "1", + "type": "t_array(t_uint256)50_storage", + "contract": "ContextUpgradeable", + "src": "lib/openzeppelin-contracts-upgradeable/contracts/utils/ContextUpgradeable.sol:36" + }, + { + "label": "_owner", + "offset": 0, + "slot": "51", + "type": "t_address", + "contract": "OwnableUpgradeable", + "src": "lib/openzeppelin-contracts-upgradeable/contracts/access/OwnableUpgradeable.sol:22" + }, + { + "label": "__gap", + "offset": 0, + "slot": "52", + "type": "t_array(t_uint256)49_storage", + "contract": "OwnableUpgradeable", + "src": "lib/openzeppelin-contracts-upgradeable/contracts/access/OwnableUpgradeable.sol:94" + }, + { + "label": "_paused", + "offset": 0, + "slot": "101", + "type": "t_bool", + "contract": "PausableUpgradeable", + "src": "lib/openzeppelin-contracts-upgradeable/contracts/security/PausableUpgradeable.sol:29" + }, + { + "label": "__gap", + "offset": 0, + "slot": "102", + "type": "t_array(t_uint256)49_storage", + "contract": "PausableUpgradeable", + "src": "lib/openzeppelin-contracts-upgradeable/contracts/security/PausableUpgradeable.sol:116" + }, + { + "label": "__gap", + "offset": 0, + "slot": "151", + "type": "t_array(t_uint256)50_storage", + "contract": "ERC1967UpgradeUpgradeable", + "src": "lib/openzeppelin-contracts-upgradeable/contracts/proxy/ERC1967/ERC1967UpgradeUpgradeable.sol:211" + }, + { + "label": "__gap", + "offset": 0, + "slot": "201", + "type": "t_array(t_uint256)50_storage", + "contract": "UUPSUpgradeable", + "src": "lib/openzeppelin-contracts-upgradeable/contracts/proxy/utils/UUPSUpgradeable.sol:107" + }, + { + "label": "totalUnitsForSale", + "offset": 0, + "slot": "251", + "type": "t_mapping(t_address,t_mapping(t_uint256,t_uint256))", + "contract": "HypercertTrader", + "src": "src/HypercertTrader.sol:36" + }, + { + "label": "offers", + "offset": 0, + "slot": "252", + "type": "t_mapping(t_uint256,t_struct(Offer)2510_storage)", + "contract": "HypercertTrader", + "src": "src/HypercertTrader.sol:37" + }, + { + "label": "_offerCounter", + "offset": 0, + "slot": "253", + "type": "t_uint256", + "contract": "HypercertTrader", + "src": "src/HypercertTrader.sol:38" + }, + { + "label": "__gap", + "offset": 0, + "slot": "254", + "type": "t_array(t_uint256)27_storage", + "contract": "HypercertTrader", + "src": "src/HypercertTrader.sol:387" + } + ], + "types": { + "t_address": { + "label": "address", + "numberOfBytes": "20" + }, + "t_array(t_struct(AcceptedToken)2522_storage)dyn_storage": { + "label": "struct IHypercertTrader.AcceptedToken[]", + "numberOfBytes": "32" + }, + "t_array(t_uint256)27_storage": { + "label": "uint256[27]", + "numberOfBytes": "864" + }, + "t_array(t_uint256)49_storage": { + "label": "uint256[49]", + "numberOfBytes": "1568" + }, + "t_array(t_uint256)50_storage": { + "label": "uint256[50]", + "numberOfBytes": "1600" + }, + "t_bool": { + "label": "bool", + "numberOfBytes": "1" + }, + "t_enum(OfferStatus)2517": { + "label": "enum IHypercertTrader.OfferStatus", + "members": [ + "Open", + "Fulfilled", + "Cancelled" + ], + "numberOfBytes": "1" + }, + "t_enum(OfferType)2513": { + "label": "enum IHypercertTrader.OfferType", + "members": [ + "Units", + "Fraction" + ], + "numberOfBytes": "1" + }, + "t_mapping(t_address,t_mapping(t_uint256,t_uint256))": { + "label": "mapping(address => mapping(uint256 => uint256))", + "numberOfBytes": "32" + }, + "t_mapping(t_uint256,t_struct(Offer)2510_storage)": { + "label": "mapping(uint256 => struct IHypercertTrader.Offer)", + "numberOfBytes": "32" + }, + "t_mapping(t_uint256,t_uint256)": { + "label": "mapping(uint256 => uint256)", + "numberOfBytes": "32" + }, + "t_struct(AcceptedToken)2522_storage": { + "label": "struct IHypercertTrader.AcceptedToken", + "members": [ + { + "label": "token", + "type": "t_address", + "offset": 0, + "slot": "0" + }, + { + "label": "minimumAmountPerUnit", + "type": "t_uint256", + "offset": 0, + "slot": "1" + } + ], + "numberOfBytes": "64" + }, + "t_struct(Offer)2510_storage": { + "label": "struct IHypercertTrader.Offer", + "members": [ + { + "label": "offerer", + "type": "t_address", + "offset": 0, + "slot": "0" + }, + { + "label": "hypercertContract", + "type": "t_address", + "offset": 0, + "slot": "1" + }, + { + "label": "fractionID", + "type": "t_uint256", + "offset": 0, + "slot": "2" + }, + { + "label": "unitsAvailable", + "type": "t_uint256", + "offset": 0, + "slot": "3" + }, + { + "label": "minUnitsPerTrade", + "type": "t_uint256", + "offset": 0, + "slot": "4" + }, + { + "label": "maxUnitsPerTrade", + "type": "t_uint256", + "offset": 0, + "slot": "5" + }, + { + "label": "offerType", + "type": "t_enum(OfferType)2513", + "offset": 0, + "slot": "6" + }, + { + "label": "status", + "type": "t_enum(OfferStatus)2517", + "offset": 1, + "slot": "6" + }, + { + "label": "acceptedTokens", + "type": "t_array(t_struct(AcceptedToken)2522_storage)dyn_storage", + "offset": 0, + "slot": "7" + } + ], + "numberOfBytes": "256" + }, + "t_uint256": { + "label": "uint256", + "numberOfBytes": "32" + }, + "t_uint8": { + "label": "uint8", + "numberOfBytes": "1" + } + } + } + }, + "c448a5dca6b776aedb55eb5857ea7c6a03d1ccd3ff709786879396d71bf7dbb2": { + "address": "0x038c990018b9Aab4aA2496E592E668EAD77aF72B", + "txHash": "0xe07f42a41b70affd1fdd08ce8011f55a35b0e62a9ef67d0b5c4daa04b6028f60", + "layout": { + "solcVersion": "0.8.16", + "storage": [ + { + "label": "_initialized", + "offset": 0, + "slot": "0", + "type": "t_uint8", + "contract": "Initializable", + "src": "lib/openzeppelin-contracts-upgradeable/contracts/proxy/utils/Initializable.sol:62", + "retypedFrom": "bool" + }, + { + "label": "_initializing", + "offset": 1, + "slot": "0", + "type": "t_bool", + "contract": "Initializable", + "src": "lib/openzeppelin-contracts-upgradeable/contracts/proxy/utils/Initializable.sol:67" + }, + { + "label": "__gap", + "offset": 0, + "slot": "1", + "type": "t_array(t_uint256)50_storage", + "contract": "ContextUpgradeable", + "src": "lib/openzeppelin-contracts-upgradeable/contracts/utils/ContextUpgradeable.sol:36" + }, + { + "label": "_owner", + "offset": 0, + "slot": "51", + "type": "t_address", + "contract": "OwnableUpgradeable", + "src": "lib/openzeppelin-contracts-upgradeable/contracts/access/OwnableUpgradeable.sol:22" + }, + { + "label": "__gap", + "offset": 0, + "slot": "52", + "type": "t_array(t_uint256)49_storage", + "contract": "OwnableUpgradeable", + "src": "lib/openzeppelin-contracts-upgradeable/contracts/access/OwnableUpgradeable.sol:94" + }, + { + "label": "_paused", + "offset": 0, + "slot": "101", + "type": "t_bool", + "contract": "PausableUpgradeable", + "src": "lib/openzeppelin-contracts-upgradeable/contracts/security/PausableUpgradeable.sol:29" + }, + { + "label": "__gap", + "offset": 0, + "slot": "102", + "type": "t_array(t_uint256)49_storage", + "contract": "PausableUpgradeable", + "src": "lib/openzeppelin-contracts-upgradeable/contracts/security/PausableUpgradeable.sol:116" + }, + { + "label": "__gap", + "offset": 0, + "slot": "151", + "type": "t_array(t_uint256)50_storage", + "contract": "ERC1967UpgradeUpgradeable", + "src": "lib/openzeppelin-contracts-upgradeable/contracts/proxy/ERC1967/ERC1967UpgradeUpgradeable.sol:211" + }, + { + "label": "__gap", + "offset": 0, + "slot": "201", + "type": "t_array(t_uint256)50_storage", + "contract": "UUPSUpgradeable", + "src": "lib/openzeppelin-contracts-upgradeable/contracts/proxy/utils/UUPSUpgradeable.sol:107" + }, + { + "label": "totalUnitsForSale", + "offset": 0, + "slot": "251", + "type": "t_mapping(t_address,t_mapping(t_uint256,t_uint256))", + "contract": "HypercertTrader", + "src": "src/HypercertTrader.sol:36" + }, + { + "label": "offers", + "offset": 0, + "slot": "252", + "type": "t_mapping(t_uint256,t_struct(Offer)8003_storage)", + "contract": "HypercertTrader", + "src": "src/HypercertTrader.sol:37" + }, + { + "label": "_offerCounter", + "offset": 0, + "slot": "253", + "type": "t_uint256", + "contract": "HypercertTrader", + "src": "src/HypercertTrader.sol:38" + }, + { + "label": "__gap", + "offset": 0, + "slot": "254", + "type": "t_array(t_uint256)27_storage", + "contract": "HypercertTrader", + "src": "src/HypercertTrader.sol:392" + } + ], + "types": { + "t_address": { + "label": "address", + "numberOfBytes": "20" + }, + "t_array(t_struct(AcceptedToken)8015_storage)dyn_storage": { + "label": "struct IHypercertTrader.AcceptedToken[]", + "numberOfBytes": "32" + }, + "t_array(t_uint256)27_storage": { + "label": "uint256[27]", + "numberOfBytes": "864" + }, + "t_array(t_uint256)49_storage": { + "label": "uint256[49]", + "numberOfBytes": "1568" + }, + "t_array(t_uint256)50_storage": { + "label": "uint256[50]", + "numberOfBytes": "1600" + }, + "t_bool": { + "label": "bool", + "numberOfBytes": "1" + }, + "t_enum(OfferStatus)8010": { + "label": "enum IHypercertTrader.OfferStatus", + "members": [ + "Open", + "Fulfilled", + "Cancelled" + ], + "numberOfBytes": "1" + }, + "t_enum(OfferType)8006": { + "label": "enum IHypercertTrader.OfferType", + "members": [ + "Units", + "Fraction" + ], + "numberOfBytes": "1" + }, + "t_mapping(t_address,t_mapping(t_uint256,t_uint256))": { + "label": "mapping(address => mapping(uint256 => uint256))", + "numberOfBytes": "32" + }, + "t_mapping(t_uint256,t_struct(Offer)8003_storage)": { + "label": "mapping(uint256 => struct IHypercertTrader.Offer)", + "numberOfBytes": "32" + }, + "t_mapping(t_uint256,t_uint256)": { + "label": "mapping(uint256 => uint256)", + "numberOfBytes": "32" + }, + "t_struct(AcceptedToken)8015_storage": { + "label": "struct IHypercertTrader.AcceptedToken", + "members": [ + { + "label": "token", + "type": "t_address", + "offset": 0, + "slot": "0" + }, + { + "label": "minimumAmountPerUnit", + "type": "t_uint256", + "offset": 0, + "slot": "1" + } + ], + "numberOfBytes": "64" + }, + "t_struct(Offer)8003_storage": { + "label": "struct IHypercertTrader.Offer", + "members": [ + { + "label": "offerer", + "type": "t_address", + "offset": 0, + "slot": "0" + }, + { + "label": "hypercertContract", + "type": "t_address", + "offset": 0, + "slot": "1" + }, + { + "label": "fractionID", + "type": "t_uint256", + "offset": 0, + "slot": "2" + }, + { + "label": "unitsAvailable", + "type": "t_uint256", + "offset": 0, + "slot": "3" + }, + { + "label": "minUnitsPerTrade", + "type": "t_uint256", + "offset": 0, + "slot": "4" + }, + { + "label": "maxUnitsPerTrade", + "type": "t_uint256", + "offset": 0, + "slot": "5" + }, + { + "label": "offerType", + "type": "t_enum(OfferType)8006", + "offset": 0, + "slot": "6" + }, + { + "label": "status", + "type": "t_enum(OfferStatus)8010", + "offset": 1, + "slot": "6" + }, + { + "label": "acceptedTokens", + "type": "t_array(t_struct(AcceptedToken)8015_storage)dyn_storage", + "offset": 0, + "slot": "7" + } + ], + "numberOfBytes": "256" + }, + "t_uint256": { + "label": "uint256", + "numberOfBytes": "32" + }, + "t_uint8": { + "label": "uint8", + "numberOfBytes": "1" + } + } + } } } } diff --git a/contracts/.prettierignore b/contracts/.prettierignore index 406d1f27..87bdd5b4 100644 --- a/contracts/.prettierignore +++ b/contracts/.prettierignore @@ -17,13 +17,15 @@ **/deployments **/.openzeppelin **/docs -**/src/abi/ +**/abi # files *.env *.log +*.sol .pnp.* coverage.json npm-debug.log* yarn-debug.log* yarn-error.log* +.DS_Store diff --git a/contracts/.prettierrc.yml b/contracts/.prettierrc.yml index 0f125e7c..b8ea7e0f 100644 --- a/contracts/.prettierrc.yml +++ b/contracts/.prettierrc.yml @@ -6,26 +6,3 @@ singleQuote: false tabWidth: 2 trailingComma: "all" useTabs: false - -plugins: - - prettier-plugin-solidity - -overrides: - - files: "**/*.t.sol" - rules: - max-state-count": "off" - state-visibility": "off" - max-line-length": "off" - options: - tabWidth: 4 - - files: "*.sol" - rules: - compiler-version: "0.8.16" - options: - tabWidth: 4 - - files: "*.ts" - options: - importOrder: ["", "^[./]"] - importOrderParserPlugins: ["importAssertions", "typescript"] - importOrderSeparation: true - importOrderSortSpecifiers: true diff --git a/contracts/.solcover.js b/contracts/.solcover.js deleted file mode 100644 index a6b8e642..00000000 --- a/contracts/.solcover.js +++ /dev/null @@ -1,7 +0,0 @@ -module.exports = { - istanbulReporter: ["html", "lcov"], - providerOptions: { - mnemonic: process.env.MNEMONIC, - }, - skipFiles: ["test", "mocks", "lib"], -}; diff --git a/contracts/.solhint.json b/contracts/.solhint.json index 48849103..78d99a5a 100644 --- a/contracts/.solhint.json +++ b/contracts/.solhint.json @@ -1,13 +1,14 @@ { - "plugins": ["prettier"], "extends": "solhint:recommended", "rules": { - "code-complexity": ["error", 8], - "compiler-version": ["error", "0.8.16"], + "avoid-low-level-calls": "off", + "code-complexity": ["error", 12], + "compiler-version": ["error", ">=0.8.16"], "func-visibility": ["error", { "ignoreConstructors": true }], - "max-line-length": ["error", 120], "no-console": "off", + "no-empty-blocks": "off", "not-rely-on-time": "off", + "private-vars-leading-underscore": "off", "reason-string": ["warn", { "maxLength": 64 }], "one-contract-per-file": "off" } diff --git a/contracts/.vscode/settings.json b/contracts/.vscode/settings.json index 5a74fb60..ea8a1e8a 100644 --- a/contracts/.vscode/settings.json +++ b/contracts/.vscode/settings.json @@ -1,10 +1,8 @@ { "editor.formatOnSave": true, - "solidity.formatter": "prettier", "solidity.packageDefaultDependenciesContractsDirectory": "src", "solidity.packageDefaultDependenciesDirectory": "lib", "solidity.remappings": ["./remappings.txt"], - "solidity.defaultCompiler": "remoteFile", "files.exclude": { "**/.git": true, "**/.svn": true, diff --git a/contracts/LICENSE b/contracts/LICENSE new file mode 100644 index 00000000..dba11665 --- /dev/null +++ b/contracts/LICENSE @@ -0,0 +1,4 @@ +This project is dual licensed under MIT and Apache-2.0. + +MIT: https://www.opensource.org/licenses/mit +Apache-2.0: https://www.apache.org/licenses/license-2.0 \ No newline at end of file diff --git a/contracts/LICENSE-APACHE b/contracts/LICENSE-APACHE new file mode 100644 index 00000000..d4cc5a41 --- /dev/null +++ b/contracts/LICENSE-APACHE @@ -0,0 +1,10 @@ +Copyright 2023 Hypercerts Foundation + +Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the +License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an +"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific +language governing permissions and limitations under the License. diff --git a/contracts/LICENSE.md b/contracts/LICENSE-MIT similarity index 77% rename from contracts/LICENSE.md rename to contracts/LICENSE-MIT index 054bdbe3..4e9e555e 100644 --- a/contracts/LICENSE.md +++ b/contracts/LICENSE-MIT @@ -1,6 +1,11 @@ MIT License -Copyright (c) 2022 Paul Razvan Berg +Copyright (c) 2022 Hypercerts Foundation: Hypercerts protocol and marketplace. + +Copyright (c) 2022 LooksRare for portions of marketplace: https://github.com/LooksRare/contracts-exchange-v2 commit: +7fca565 + +Copyright (c) 2022 Paul Razvan Berg for inital template: https://github.com/paulrberg/foundry-template Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the diff --git a/contracts/README.md b/contracts/README.md index 6320a762..fc293242 100644 --- a/contracts/README.md +++ b/contracts/README.md @@ -88,7 +88,7 @@ yarn hardhat deploy --network goerli To transfer ownership of the proxy contract for upgrades, run the following: ```sh -yarn hardhat transfer-owner --network goerli --proxy PROXY_CONTRACT_ADDRESS --owner NEW_OWNER_ADDRESS +yarn hardhat transfer-owner-minter --network goerli --proxy PROXY_CONTRACT_ADDRESS --owner NEW_OWNER_ADDRESS ``` This is typically done to transfer control to a multi-sig (i.e. Gnosis Safe). @@ -110,7 +110,7 @@ Propose an upgrade via OpenZeppelin Defender. For more information, see this ```sh yarn build:hardhat -yarn hardhat propose-upgrade --network goerli --proxy PROXY_CONTRACT_ADDRESS --multisig OWNER_MULTISIG_ADDRESS +yarn hardhat propose-upgrade-minter --network goerli --proxy PROXY_CONTRACT_ADDRESS --multisig OWNER_MULTISIG_ADDRESS ``` This will output an OpenZeppelin URL that multi-sig members can use to approve/reject the upgrade. diff --git a/contracts/contracts/AllowlistMinter.sol b/contracts/contracts/AllowlistMinter.sol deleted file mode 100644 index 576b45ee..00000000 --- a/contracts/contracts/AllowlistMinter.sol +++ /dev/null @@ -1,70 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity 0.8.16; - -import { MerkleProofUpgradeable } from "oz-upgradeable/utils/cryptography/MerkleProofUpgradeable.sol"; -import { IAllowlist } from "./interfaces/IAllowlist.sol"; - -import { Errors } from "./libs/Errors.sol"; - -/// @title Interface for hypercert token interactions -/// @author bitbeckers -/// @notice This interface declares the required functionality for a hypercert token -/// @notice This interface does not specify the underlying token type (e.g. 721 or 1155) -contract AllowlistMinter is IAllowlist { - event AllowlistCreated(uint256 tokenID, bytes32 root); - event LeafClaimed(uint256 tokenID, bytes32 leaf); - - mapping(uint256 => bytes32) internal merkleRoots; - mapping(uint256 => mapping(bytes32 => bool)) public hasBeenClaimed; - mapping(uint256 => uint256) internal maxUnits; - mapping(uint256 => uint256) internal minted; - - function isAllowedToClaim( - bytes32[] calldata proof, - uint256 claimID, - bytes32 leaf - ) external view returns (bool isAllowed) { - if (merkleRoots[claimID].length == 0) revert Errors.DoesNotExist(); - isAllowed = MerkleProofUpgradeable.verifyCalldata(proof, merkleRoots[claimID], leaf); - } - - function _createAllowlist(uint256 claimID, bytes32 merkleRoot, uint256 units) internal { - if (merkleRoot == "" || units == 0) revert Errors.Invalid(); - if (merkleRoots[claimID] != "") revert Errors.DuplicateEntry(); - - merkleRoots[claimID] = merkleRoot; - maxUnits[claimID] = units; - emit AllowlistCreated(claimID, merkleRoot); - } - - function _processClaim(bytes32[] calldata proof, uint256 claimID, uint256 amount) internal { - if (merkleRoots[claimID].length == 0) revert Errors.DoesNotExist(); - - bytes32 leaf = _calculateLeaf(msg.sender, amount); - - if (hasBeenClaimed[claimID][leaf]) revert Errors.AlreadyClaimed(); - if ( - !MerkleProofUpgradeable.verifyCalldata(proof, merkleRoots[claimID], leaf) || - (minted[claimID] + amount) > maxUnits[claimID] - ) revert Errors.Invalid(); - hasBeenClaimed[claimID][leaf] = true; - - emit LeafClaimed(claimID, leaf); - } - - function _calculateLeaf(address account, uint256 amount) internal pure returns (bytes32 leaf) { - leaf = keccak256(bytes.concat(keccak256(abi.encode(account, amount)))); - } - - /** - * @dev This empty reserved space is put in place to allow future versions to add new - * variables without shifting down storage in the inheritance chain. - * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps - * Assuming 30 available slots (slots cost space, cost gas) - * 1. merkleRoots - * 2. hasBeenClaimed - * 3. maxUnits - * 4. minted - */ - uint256[26] private __gap; -} diff --git a/contracts/contracts/HypercertMinter.sol b/contracts/contracts/HypercertMinter.sol deleted file mode 100644 index 917c02c5..00000000 --- a/contracts/contracts/HypercertMinter.sol +++ /dev/null @@ -1,229 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity 0.8.16; - -import { IHypercertToken } from "./interfaces/IHypercertToken.sol"; -import { SemiFungible1155 } from "./SemiFungible1155.sol"; -import { AllowlistMinter } from "./AllowlistMinter.sol"; -import { PausableUpgradeable } from "oz-upgradeable/security/PausableUpgradeable.sol"; - -import { Errors } from "./libs/Errors.sol"; - -/// @title Contract for managing hypercert claims and whitelists -/// @author bitbeckers -/// @notice Implementation of the HypercertTokenInterface using { SemiFungible1155 } as underlying token. -/// @notice This contract supports whitelisted minting via { AllowlistMinter }. -/// @dev Wrapper contract to expose and chain functions. -contract HypercertMinter is IHypercertToken, SemiFungible1155, AllowlistMinter, PausableUpgradeable { - // solhint-disable-next-line const-name-snakecase - string public constant name = "HypercertMinter"; - /// @dev from typeID to a transfer policy - mapping(uint256 => TransferRestrictions) internal typeRestrictions; - - /// INIT - - /// @dev see { openzeppelin-contracts-upgradeable/contracts/proxy/utils/Initializable.sol } - /// @custom:oz-upgrades-unsafe-allow constructor - constructor() { - _disableInitializers(); - } - - /// @dev see { openzeppelin-contracts-upgradeable/contracts/proxy/utils/Initializable.sol } - function initialize() public virtual initializer { - __SemiFungible1155_init(); - __Pausable_init(); - } - - /// EXTERNAL - - /// @notice Mint a semi-fungible token for the impact claim referenced via `uri` - /// @dev see {IHypercertToken} - function mintClaim( - address account, - uint256 units, - string memory _uri, - TransferRestrictions restrictions - ) external override whenNotPaused { - // This enables us to release this restriction in the future - if (msg.sender != account) revert Errors.NotAllowed(); - uint256 claimID = _mintNewTypeWithToken(account, units, _uri); - typeRestrictions[claimID] = restrictions; - emit ClaimStored(claimID, _uri, units); - } - - /// @notice Mint semi-fungible tokens for the impact claim referenced via `uri` - /// @dev see {IHypercertToken} - function mintClaimWithFractions( - address account, - uint256 units, - uint256[] calldata fractions, - string memory _uri, - TransferRestrictions restrictions - ) external override whenNotPaused { - // This enables us to release this restriction in the future - if (msg.sender != account) revert Errors.NotAllowed(); - //Using sum to compare units and fractions (sanity check) - if (_getSum(fractions) != units) revert Errors.Invalid(); - - uint256 claimID = _mintNewTypeWithTokens(account, fractions, _uri); - typeRestrictions[claimID] = restrictions; - emit ClaimStored(claimID, _uri, units); - } - - /// @notice Mint a semi-fungible token representing a fraction of the claim - /// @dev Calls AllowlistMinter to verify `proof`. - /// @dev Mints the `amount` of units for the hypercert stored under `claimID` - function mintClaimFromAllowlist( - address account, - bytes32[] calldata proof, - uint256 claimID, - uint256 units - ) external whenNotPaused { - _processClaim(proof, claimID, units); - _mintToken(account, claimID, units); - } - - /// @notice Mint semi-fungible tokens representing a fraction of the claims in `claimIDs` - /// @dev Calls AllowlistMinter to verify `proofs`. - /// @dev Mints the `amount` of units for the hypercert stored under `claimIDs` - function batchMintClaimsFromAllowlists( - address account, - bytes32[][] calldata proofs, - uint256[] calldata claimIDs, - uint256[] calldata units - ) external whenNotPaused { - uint256 len = claimIDs.length; - for (uint256 i; i < len; ) { - _processClaim(proofs[i], claimIDs[i], units[i]); - unchecked { - ++i; - } - } - _batchMintTokens(account, claimIDs, units); - } - - /// @notice Register a claim and the whitelist for minting token(s) belonging to that claim - /// @dev Calls SemiFungible1155 to store the claim referenced in `uri` with amount of `units` - /// @dev Calls AllowlistMinter to store the `merkleRoot` as proof to authorize claims - function createAllowlist( - address account, - uint256 units, - bytes32 merkleRoot, - string memory _uri, - TransferRestrictions restrictions - ) external whenNotPaused { - uint256 claimID = _createTokenType(account, units, _uri); - _createAllowlist(claimID, merkleRoot, units); - typeRestrictions[claimID] = restrictions; - emit ClaimStored(claimID, _uri, units); - } - - /// @notice Split a claimtokens value into parts with summed value equal to the original - /// @dev see {IHypercertToken} - function splitFraction( - address _account, - uint256 _tokenID, - uint256[] calldata _newFractions - ) external whenNotPaused { - _splitTokenUnits(_account, _tokenID, _newFractions); - } - - /// @notice Merge the value of tokens belonging to the same claim - /// @dev see {IHypercertToken} - function mergeFractions(address _account, uint256[] calldata _fractionIDs) external whenNotPaused { - _mergeTokensUnits(_account, _fractionIDs); - } - - /// @notice Burn a claimtoken - /// @dev see {IHypercertToken} - function burnFraction(address _account, uint256 _tokenID) external whenNotPaused { - _burnToken(_account, _tokenID); - } - - /// @dev see {IHypercertToken} - function unitsOf(uint256 tokenID) external view override returns (uint256 units) { - units = _unitsOf(tokenID); - } - - /// @dev see {IHypercertToken} - function unitsOf(address account, uint256 tokenID) external view override returns (uint256 units) { - units = _unitsOf(account, tokenID); - } - - /// PAUSABLE - - function pause() external onlyOwner { - _pause(); - } - - function unpause() external onlyOwner { - _unpause(); - } - - /// METADATA - - /// @dev see { IHypercertMetadata} - function uri(uint256 tokenID) public view override(IHypercertToken, SemiFungible1155) returns (string memory _uri) { - _uri = SemiFungible1155.uri(tokenID); - } - - /// TRANSFER RESTRICTIONS - - function readTransferRestriction(uint256 tokenID) external view returns (string memory) { - TransferRestrictions temp = typeRestrictions[getBaseType(tokenID)]; - if (temp == TransferRestrictions.AllowAll) return "AllowAll"; - if (temp == TransferRestrictions.DisallowAll) return "DisallowAll"; - if (temp == TransferRestrictions.FromCreatorOnly) return "FromCreatorOnly"; - return ""; - } - - /// INTERNAL - - /// @dev see { openzeppelin-contracts-upgradeable/contracts/proxy/utils/UUPSUpgradeable.sol } - function _authorizeUpgrade(address newImplementation) internal virtual override onlyOwner { - // solhint-disable-previous-line no-empty-blocks - } - - function _beforeTokenTransfer( - address operator, - address from, - address to, - uint256[] memory ids, - uint256[] memory amounts, - bytes memory data - ) internal virtual override { - super._beforeTokenTransfer(operator, from, to, ids, amounts, data); - - // By-pass transfer restrictions for minting and burning - if (from == address(0)) { - // Minting - return; - } else if (to == address(0)) { - // Burning - return; - } - - // Transfer case, where to and from are non-zero - uint256 len = ids.length; - for (uint256 i; i < len; ) { - uint256 typeID = getBaseType(ids[i]); - TransferRestrictions policy = typeRestrictions[typeID]; - if (policy == TransferRestrictions.DisallowAll) { - revert Errors.TransfersNotAllowed(); - } else if (policy == TransferRestrictions.FromCreatorOnly && from != creators[typeID]) { - revert Errors.TransfersNotAllowed(); - } - unchecked { - ++i; - } - } - } - - /** - * @dev This empty reserved space is put in place to allow future versions to add new - * variables without shifting down storage in the inheritance chain. - * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps - * Assuming 30 available slots (slots cost space, cost gas) - * 1. typeRestrictions - */ - uint256[29] private __gap; -} diff --git a/contracts/contracts/SemiFungible1155.sol b/contracts/contracts/SemiFungible1155.sol deleted file mode 100644 index cd88714a..00000000 --- a/contracts/contracts/SemiFungible1155.sol +++ /dev/null @@ -1,433 +0,0 @@ -// SPDX-License-Identifier: MIT -// Used components of Enjin example implementation for mixed fungibility -// https://github.com/enjin/erc-1155/blob/master/contracts/ERC1155MixedFungibleMintable.sol -pragma solidity 0.8.16; - -import { ERC1155Upgradeable } from "oz-upgradeable/token/ERC1155/ERC1155Upgradeable.sol"; -import { ERC1155BurnableUpgradeable } from "oz-upgradeable/token/ERC1155/extensions/ERC1155BurnableUpgradeable.sol"; -import { ERC1155URIStorageUpgradeable } from "oz-upgradeable/token/ERC1155/extensions/ERC1155URIStorageUpgradeable.sol"; -import { OwnableUpgradeable } from "oz-upgradeable/access/OwnableUpgradeable.sol"; -import { Initializable } from "oz-upgradeable/proxy/utils/Initializable.sol"; -import { UUPSUpgradeable } from "oz-upgradeable/proxy/utils/UUPSUpgradeable.sol"; -import { Errors } from "./libs/Errors.sol"; - -/// @title Contract for minting semi-fungible EIP1155 tokens -/// @author bitbeckers -/// @notice Extends { Upgradeable1155 } token with semi-fungible properties and the concept of `units` -/// @dev Adds split bit strategy as described in [EIP-1155](https://eips.ethereum.org/EIPS/eip-1155#non-fungible-tokens) -contract SemiFungible1155 is - Initializable, - ERC1155Upgradeable, - ERC1155BurnableUpgradeable, - ERC1155URIStorageUpgradeable, - OwnableUpgradeable, - UUPSUpgradeable -{ - /// @dev Counter used to generate next typeID. - uint256 internal typeCounter; - - /// @dev Bitmask used to expose only upper 128 bits of uint256 - uint256 internal constant TYPE_MASK = type(uint256).max << 128; - - /// @dev Bitmask used to expose only lower 128 bits of uint256 - uint256 internal constant NF_INDEX_MASK = type(uint256).max >> 128; - - uint256 internal constant FRACTION_LIMIT = 253; - - /// @dev Mapping of `tokenID` to address of `owner` - mapping(uint256 => address) internal owners; - - /// @dev Mapping of `tokenID` to address of `creator` - mapping(uint256 => address) internal creators; - - /// @dev Used to determine amount of `units` stored in token at `tokenID` - mapping(uint256 => uint256) internal tokenValues; - - /// @dev Used to find highest index of token belonging to token at `typeID` - mapping(uint256 => uint256) internal maxIndex; - - /// @dev Emitted on transfer of `value` between `fromTokenID` to `toTokenID` of the same `claimID` - event ValueTransfer(uint256 claimID, uint256 fromTokenID, uint256 toTokenID, uint256 value); - - /// @dev Emitted on transfer of `values` between `fromTokenIDs` to `toTokenIDs` of `claimIDs` - event BatchValueTransfer(uint256[] claimIDs, uint256[] fromTokenIDs, uint256[] toTokenIDs, uint256[] values); - - /// @dev see { openzeppelin-contracts-upgradeable/contracts/proxy/utils/Initializable.sol } - // solhint-disable-next-line func-name-mixedcase - function __SemiFungible1155_init() public virtual onlyInitializing { - __ERC1155_init(""); - __ERC1155Burnable_init(); - __ERC1155URIStorage_init(); - __Ownable_init(); - __UUPSUpgradeable_init(); - } - - /// @dev Get index of fractional token at `_id` by returning lower 128 bit values - /// @dev Returns 0 if `_id` is a baseType - function getItemIndex(uint256 tokenID) internal pure returns (uint256) { - return tokenID & NF_INDEX_MASK; - } - - /// @dev Get base type ID for token at `_id` by returning upper 128 bit values - function getBaseType(uint256 tokenID) internal pure returns (uint256) { - return tokenID & TYPE_MASK; - } - - /// @dev Identify that token at `_id` is base type. - /// @dev Upper 128 bits identify base type ID, lower bits should be 0 - function isBaseType(uint256 tokenID) internal pure returns (bool) { - return (tokenID & TYPE_MASK == tokenID) && (tokenID & NF_INDEX_MASK == 0); - } - - /// @dev Identify that token at `_id` is fraction of a claim. - /// @dev Upper 128 bits identify base type ID, lower bits should be > 0 - function isTypedItem(uint256 tokenID) internal pure returns (bool) { - return (tokenID & TYPE_MASK != 0) && (tokenID & NF_INDEX_MASK != 0); - } - - /// READ - function ownerOf(uint256 tokenID) public view returns (address _owner) { - _owner = owners[tokenID]; - } - - /// @dev see {IHypercertToken} - function _unitsOf(uint256 tokenID) internal view returns (uint256 units) { - units = tokenValues[tokenID]; - } - - /// @dev see {IHypercertToken} - function _unitsOf(address account, uint256 tokenID) internal view returns (uint256 units) { - // Check if fraction token and accounts owns it - if (ownerOf(tokenID) == account) { - units = tokenValues[tokenID]; - } - } - - /// MUTATE - - /// @dev create token type ID based of token counter - - function _createTokenType(address _account, uint256 units, string memory _uri) internal returns (uint256 typeID) { - _notMaxType(typeCounter); - typeID = ++typeCounter << 128; - - creators[typeID] = _account; - tokenValues[typeID] = units; - - _setURI(typeID, _uri); - - //Event emitted for indexing purposes - emit TransferSingle(_account, address(0), address(0), typeID, 0); - } - - /// @dev Mint a new token type and the initial units - function _mintNewTypeWithToken( - address _account, - uint256 _units, - string memory _uri - ) internal returns (uint256 typeID) { - if (_units == 0) { - revert Errors.NotAllowed(); - } - typeID = _createTokenType(_account, _units, _uri); - - uint256 tokenID = typeID + ++maxIndex[typeID]; //1 based indexing, 0 holds type data - - tokenValues[tokenID] = _units; - - _mint(_account, tokenID, 1, ""); - emit ValueTransfer(typeID, 0, tokenID, _units); - } - - /// @dev Mint a new token type and the initial fractions - function _mintNewTypeWithTokens( - address _account, - uint256[] calldata _fractions, - string memory _uri - ) internal returns (uint256 typeID) { - typeID = _mintNewTypeWithToken(_account, _getSum(_fractions), _uri); - _splitTokenUnits(_account, typeID + maxIndex[typeID], _fractions); - } - - /// @dev Mint a new token for an existing type - function _mintToken(address _account, uint256 _typeID, uint256 _units) internal returns (uint256 tokenID) { - if (!isBaseType(_typeID)) revert Errors.NotAllowed(); - - _notMaxItem(maxIndex[_typeID]); - - unchecked { - tokenID = _typeID + ++maxIndex[_typeID]; //1 based indexing, 0 holds type data - } - - tokenValues[tokenID] = _units; - - _mint(_account, tokenID, 1, ""); - emit ValueTransfer(_typeID, 0, tokenID, _units); - } - - /// @dev Mint new tokens for existing types - /// @notice Enables batch claiming from multiple allowlists - function _batchMintTokens( - address _account, - uint256[] calldata _typeIDs, - uint256[] calldata _units - ) internal returns (uint256[] memory tokenIDs) { - uint256 len = _typeIDs.length; - - tokenIDs = new uint256[](len); - uint256[] memory amounts = new uint256[](len); - uint256[] memory zeroes = new uint256[](len); - - for (uint256 i; i < len; ) { - uint256 _typeID = _typeIDs[i]; - if (!isBaseType(_typeID)) revert Errors.NotAllowed(); - _notMaxItem(maxIndex[_typeID]); - - unchecked { - uint256 tokenID = _typeID + ++maxIndex[_typeID]; //1 based indexing, 0 holds type data - tokenValues[tokenID] = _units[i]; - tokenIDs[i] = tokenID; - amounts[i] = 1; - ++i; - } - } - - _mintBatch(_account, tokenIDs, amounts, ""); - emit BatchValueTransfer(_typeIDs, zeroes, tokenIDs, _units); - } - - /// @dev Split the units of `_tokenID` owned by `account` across `_values` - /// @dev `_values` must sum to total `units` held at `_tokenID` - function _splitTokenUnits(address _account, uint256 _tokenID, uint256[] calldata _values) internal { - if (_values.length > FRACTION_LIMIT || _values.length < 2) revert Errors.ArraySize(); - if (tokenValues[_tokenID] != _getSum(_values)) revert Errors.NotAllowed(); - - // Current token - uint256 _typeID = getBaseType(_tokenID); - uint256 valueLeft = tokenValues[_tokenID]; - - // Prepare batch processing, we want to skip the first entry - uint256 len = _values.length - 1; - - uint256[] memory typeIDs = new uint256[](len); - uint256[] memory fromIDs = new uint256[](len); - uint256[] memory toIDs = new uint256[](len); - uint256[] memory amounts = new uint256[](len); - uint256[] memory values = new uint256[](len); - - { - uint256[] memory _valuesCache = _values; - uint256 swapValue = _valuesCache[len]; - _valuesCache[len] = _valuesCache[0]; - _valuesCache[0] = swapValue; - - for (uint256 i; i < len; ) { - _notMaxItem(maxIndex[_typeID]); - - typeIDs[i] = _typeID; - fromIDs[i] = _tokenID; - toIDs[i] = _typeID + ++maxIndex[_typeID]; - amounts[i] = 1; - values[i] = _valuesCache[i]; - - unchecked { - ++i; - } - } - } - - _beforeUnitTransfer(_msgSender(), _account, fromIDs, toIDs, values, ""); - - for (uint256 i; i < len; ) { - valueLeft -= values[i]; - - tokenValues[toIDs[i]] = values[i]; - - unchecked { - ++i; - } - } - - tokenValues[_tokenID] = valueLeft; - - _mintBatch(_account, toIDs, amounts, ""); - - emit BatchValueTransfer(typeIDs, fromIDs, toIDs, values); - } - - /// @dev Merge the units of `_fractionIDs`. - /// @dev Base type of `_fractionIDs` must be identical for all tokens. - function _mergeTokensUnits(address _account, uint256[] memory _fractionIDs) internal { - if (_fractionIDs.length > FRACTION_LIMIT || _fractionIDs.length < 2) { - revert Errors.ArraySize(); - } - uint256 len = _fractionIDs.length - 1; - - uint256 target = _fractionIDs[len]; - - uint256 _totalValue; - uint256[] memory fromIDs = new uint256[](len); - uint256[] memory toIDs = new uint256[](len); - uint256[] memory values = new uint256[](len); - uint256[] memory amounts = new uint256[](len); - - { - for (uint256 i; i < len; ) { - uint256 _fractionID = _fractionIDs[i]; - fromIDs[i] = _fractionID; - toIDs[i] = target; - amounts[i] = 1; - values[i] = tokenValues[_fractionID]; - - unchecked { - ++i; - } - } - } - - _beforeUnitTransfer(_msgSender(), _account, fromIDs, toIDs, values, ""); - - for (uint256 i; i < len; ) { - _totalValue += values[i]; - - delete tokenValues[fromIDs[i]]; - unchecked { - ++i; - } - } - - tokenValues[target] += _totalValue; - - _burnBatch(_account, fromIDs, amounts); - } - - /// @dev Burn the token at `_tokenID` owned by `_account` - /// @dev Not allowed to burn base type. - /// @dev `_tokenID` must hold all value declared at base type - function _burnToken(address _account, uint256 _tokenID) internal { - if (_account != _msgSender() && !isApprovedForAll(_account, _msgSender())) revert Errors.NotApprovedOrOwner(); - - uint256 value = tokenValues[_tokenID]; - - delete tokenValues[_tokenID]; - - _burn(_account, _tokenID, 1); - emit ValueTransfer(getBaseType(_tokenID), _tokenID, 0, value); - } - - /// TRANSFERS - - // The following functions are overrides required by Solidity. - function _afterTokenTransfer( - address operator, - address from, - address to, - uint256[] memory ids, - uint256[] memory amounts, - bytes memory data - ) internal virtual override { - super._afterTokenTransfer(operator, from, to, ids, amounts, data); - - uint256 len = ids.length; - - for (uint256 i; i < len; ) { - owners[ids[i]] = to; - unchecked { - ++i; - } - } - } - - function _beforeUnitTransfer( - address operator, - address from, - uint256[] memory fromIDs, - uint256[] memory toIDs, - uint256[] memory values, - bytes memory data - ) internal virtual { - uint256 len = fromIDs.length; - - for (uint256 i; i < len; ) { - uint256 _from = fromIDs[i]; - uint256 _to = toIDs[i]; - - if (isBaseType(_from)) revert Errors.NotAllowed(); - if (getBaseType(_from) != getBaseType(_to)) revert Errors.TypeMismatch(); - if (from != _msgSender() && !isApprovedForAll(from, _msgSender())) revert Errors.NotApprovedOrOwner(); - unchecked { - ++i; - } - } - } - - /// METADATA - - /// @dev see { openzeppelin-contracts-upgradeable/token/ERC1155/extensions/ERC1155URIStorageUpgradeable.sol } - /// @dev Always returns the URI for the basetype so that it's managed in one place. - function uri( - uint256 tokenID - ) public view virtual override(ERC1155Upgradeable, ERC1155URIStorageUpgradeable) returns (string memory _uri) { - // All tokens share the same metadata at the moment - _uri = ERC1155URIStorageUpgradeable.uri(getBaseType(tokenID)); - } - - /// UTILS - - /** - * @dev Check if value is below max item index - */ - function _notMaxItem(uint256 tokenID) private pure { - uint128 _count = uint128(tokenID); - ++_count; - } - - /** - * @dev Check if value is below max type index - */ - function _notMaxType(uint256 tokenID) private pure { - uint128 _count = uint128(tokenID >> 128); - ++_count; - } - - /** - * @dev calculate the sum of the elements of an array - */ - function _getSum(uint256[] memory array) internal pure returns (uint256 sum) { - uint256 len = array.length; - for (uint256 i; i < len; ) { - if (array[i] == 0) revert Errors.NotAllowed(); - sum += array[i]; - unchecked { - ++i; - } - } - } - - function _getSingletonArray(uint256 element) private pure returns (uint256[] memory) { - uint256[] memory array = new uint256[](1); - array[0] = element; - - return array; - } - - // UUPS PROXY - - /// @dev see { openzeppelin-contracts-upgradeable/contracts/proxy/utils/UUPSUpgradeable.sol } - function _authorizeUpgrade(address newImplementation) internal virtual override onlyOwner { - // solhint-disable-previous-line no-empty-blocks - } - - /** - * @dev This empty reserved space is put in place to allow future versions to add new - * variables without shifting down storage in the inheritance chain. - * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps - * Assuming 30 available slots (slots cost space, cost gas) - * 1. typeCounter - * 2. owners - * 3. creators - * 4. tokenValues - * 5. maxIndex - */ - uint256[25] private __gap; -} diff --git a/contracts/foundry.toml b/contracts/foundry.toml index 20f19235..efe3aa83 100644 --- a/contracts/foundry.toml +++ b/contracts/foundry.toml @@ -1,19 +1,40 @@ # Full reference https://github.com/foundry-rs/foundry/tree/master/config [profile.default] -auto_detect_solc = false +auto_detect_solc = true +allow_paths = ["../node_modules", "node_modules", "lib"] bytecode_hash = "none" +force = false fuzz = { runs = 1025 } gas_reports = ["*"] -libs = ["lib"] +libraries = [] +libs = ["node_modules", "lib"] optimizer = true -optimizer_runs = 10_000 +optimizer_runs = 5_000 out = "out" -solc = "0.8.16" src = "src" +script = "scripts/deployment" test = "test/foundry" - +no_match_test = "testCannotExecuteOrderIfInvalidUserGlobal" [profile.ci] fuzz = { runs = 1024 } verbosity = 1 + +[etherscan] +mainnet = { key = "${ETHERSCAN_API_KEY}" } +goerli = { key = "${ETHERSCAN_API_KEY}" } +optimism = { key = "${OPTIMISTIC_ETHERSCAN_API_KEY}" } +sepolia = { key = "${ETHERSCAN_API_KEY}" } +celo = { key = "${CELOSCAN_API_KEY}" } + +[rpc_endpoints] +mainnet = "https://eth-mainnet.g.alchemy.com/v2/${ALCHEMY_API_KEY}" +goerli = "https://eth-goerli.g.alchemy.com/v2/${ALCHEMY_API_KEY}" +optimism = "https://opt-mainnet.g.alchemy.com/v2/${ALCHEMY_API_KEY}" +sepolia = "https://sepolia.infura.io/v3/${INFURA_API_KEY}" +celo = "https://forno.celo.org" + +[fmt] +number_underscore = "thousands" +wrap_comments = true diff --git a/contracts/hardhat.config.ts b/contracts/hardhat.config.ts index 48f3d3d6..dce7d9ca 100644 --- a/contracts/hardhat.config.ts +++ b/contracts/hardhat.config.ts @@ -1,8 +1,7 @@ -import "@nomicfoundation/hardhat-chai-matchers"; +import { HardhatUserConfig } from "hardhat/config"; import "@nomicfoundation/hardhat-toolbox"; -import "@nomiclabs/hardhat-ethers"; +import "@nomicfoundation/hardhat-chai-matchers"; import "@openzeppelin/hardhat-upgrades"; -import "@openzeppelin/hardhat-defender"; import "@primitivefi/hardhat-dodoc"; import { config as dotenvConfig } from "dotenv"; @@ -34,17 +33,20 @@ const dotenvConfigPath: string = process.env.DOTENV_PATH ?? fs.existsSync("./.en dotenvConfig({ path: resolve(__dirname, dotenvConfigPath) }); // Ensure that we have all the environment variables we need. -const mnemonic = requireEnv(process.env.MNEMONIC, "MNEMONIC"); -const mnemonic_celo = requireEnv(process.env.MNEMONIC_CELO, "MNEMONIC_CELO"); -const infuraApiKey = requireEnv(process.env.INFURA_API_KEY, "INFURA_API_KEY"); -const alchemyOptimismUrl = requireEnv(process.env.ALCHEMY_OPTIMISM_URL, "ALCHEMY_OPTIMISM_URL"); +const MNEMONIC = requireEnv(process.env.MNEMONIC, "MNEMONIC"); +const MNEMONIC_CELO = requireEnv(process.env.MNEMONIC_CELO, "MNEMONIC_CELO"); +const INFURA_API_KEY = requireEnv(process.env.INFURA_API_KEY, "INFURA_API_KEY"); +const ALCHEMY_API_KEY = requireEnv(process.env.ALCHEMY_API_KEY, "ALCHEMY_API_KEY"); -const etherscanApiKey = requireEnv(process.env.ETHERSCAN_API_KEY, "ETHERSCAN_API_KEY"); -const optimisticEtherscanApiKey = requireEnv(process.env.OPTIMISTIC_ETHERSCAN_API_KEY, "OPTIMISTIC_ETHERSCAN_API_KEY"); -const celoscanApiKey = requireEnv(process.env.CELOSCAN_API_KEY, "CELOSCAN_API_KEY"); +const ETHERSCAN_API_KEY = requireEnv(process.env.ETHERSCAN_API_KEY, "ETHERSCAN_API_KEY"); +const OPTIMISTIC_ETHERSCAN_API_KEY = requireEnv( + process.env.OPTIMISTIC_ETHERSCAN_API_KEY, + "OPTIMISTIC_ETHERSCAN_API_KEY", +); +const CELOSCAN_API_KEY = requireEnv(process.env.CELOSCAN_API_KEY, "CELOSCAN_API_KEY"); -const ozApiKey = requireEnv(process.env.OPENZEPPELIN_API_KEY, "OPENZEPPELIN_API_KEY"); -const ozSecretKey = requireEnv(process.env.OPENZEPPELIN_SECRET_KEY, "OPENZEPPELIN_SECRET_KEY"); +const OPENZEPPELIN_API_KEY = requireEnv(process.env.OPENZEPPELIN_API_KEY, "OPENZEPPELIN_API_KEY"); +const OPENZEPPELIN_SECRET_KEY = requireEnv(process.env.OPENZEPPELIN_SECRET_KEY, "OPENZEPPELIN_SECRET_KEY"); /** * Maps a key to the chain ID @@ -64,23 +66,30 @@ const chainIds = { }; function getChainConfig(chain: keyof typeof chainIds) { - const jsonRpcUrl = "https://" + chain + ".infura.io/v3/" + infuraApiKey; + const jsonRpcUrl = "https://" + chain + ".infura.io/v3/" + INFURA_API_KEY; let config = { accounts: { count: 10, - mnemonic, + mnemonic: MNEMONIC, path: "m/44'/60'/0'/0", }, chainId: chainIds[chain], url: jsonRpcUrl, }; + if (chain === "optimism-mainnet") { + config = { + ...config, + url: `https://opt-mainnet.g.alchemy.com/v2/${ALCHEMY_API_KEY}`, + }; + } + if (chain === "celo-mainnet") { config = { ...config, accounts: { count: 10, - mnemonic: mnemonic_celo, + mnemonic: MNEMONIC_CELO, path: "m/44'/52752'/0'/0", }, }; @@ -89,9 +98,9 @@ function getChainConfig(chain: keyof typeof chainIds) { return config; } -const config = { +const config: HardhatUserConfig = { abiExporter: { - path: "./src/abi", + path: "./abi", runOnCompile: true, clear: true, flat: true, @@ -99,8 +108,8 @@ const config = { except: ["@openzeppelin"], }, defender: { - apiKey: ozApiKey!, - apiSecret: ozSecretKey!, + apiKey: OPENZEPPELIN_API_KEY!, + apiSecret: OPENZEPPELIN_SECRET_KEY!, useDefenderDeploy: true, }, dodoc: { @@ -111,10 +120,10 @@ const config = { }, etherscan: { apiKey: { - goerli: etherscanApiKey!, - sepolia: etherscanApiKey!, - optimisticEthereum: optimisticEtherscanApiKey!, - celo: celoscanApiKey!, + goerli: ETHERSCAN_API_KEY!, + sepolia: ETHERSCAN_API_KEY!, + optimisticEthereum: OPTIMISTIC_ETHERSCAN_API_KEY!, + celo: CELOSCAN_API_KEY!, }, customChains: [ { @@ -133,7 +142,7 @@ const config = { // metamask can't transfer when connected to hardhat's network. initialBaseFeePerGas: 0, accounts: { - mnemonic, + mnemonic: MNEMONIC, }, chainId: chainIds.hardhat, }, @@ -145,10 +154,7 @@ const config = { sepolia: getChainConfig("sepolia"), mainnet: getChainConfig("mainnet"), "optimism-goerli": getChainConfig("optimism-goerli"), - "optimism-mainnet": { - ...getChainConfig("optimism-mainnet"), - url: alchemyOptimismUrl, - }, + "optimism-mainnet": getChainConfig("optimism-mainnet"), }, paths: { cache: "./cache_hardhat", // Use a different cache for Hardhat than Foundry @@ -156,31 +162,31 @@ const config = { tests: "./test", }, preprocess: { - eachLine: () => ({ + eachLine: (hre) => ({ transform: (line: string) => { if (line.match(/^\s*import /i)) { - getRemappings().forEach(([find, replace]) => { - if (line.match(find)) { - line = line.replace(find, replace); + for (const [from, to] of getRemappings()) { + if (line.includes(from)) { + line = line.replace(from, to); + break; } - }); + } } return line; }, }), }, solidity: { - version: "0.8.16", + version: "0.8.17", settings: { optimizer: { enabled: true, - runs: 10_000, + runs: 5_000, }, }, }, typechain: { - outDir: "./src/types", - target: "ethers-v5", + outDir: "./types", }, }; diff --git a/contracts/lib/openzeppelin-contracts-upgradeable/.eslintrc b/contracts/lib/openzeppelin-contracts-upgradeable/.eslintrc index 095d2754..22fb715f 100644 --- a/contracts/lib/openzeppelin-contracts-upgradeable/.eslintrc +++ b/contracts/lib/openzeppelin-contracts-upgradeable/.eslintrc @@ -1,35 +1,30 @@ { - "extends" : [ - "standard" - ], - "plugins": [ - "mocha" - ], + "extends": ["standard"], + "plugins": ["mocha"], "env": { - "browser" : true, - "node" : true, - "mocha" : true, - "jest" : true, + "browser": true, + "node": true, + "mocha": true, + "jest": true }, - "globals" : { + "globals": { "artifacts": false, "contract": false, "assert": false, "web3": false, "usePlugin": false, - "extendEnvironment": false, + "extendEnvironment": false }, "rules": { - // Strict mode "strict": ["error", "global"], // Code style "array-bracket-spacing": ["off"], - "camelcase": ["error", {"properties": "always"}], + "camelcase": ["error", { "properties": "always" }], "comma-dangle": ["error", "always-multiline"], - "comma-spacing": ["error", {"before": false, "after": true}], - "dot-notation": ["error", {"allowKeywords": true, "allowPattern": ""}], + "comma-spacing": ["error", { "before": false, "after": true }], + "dot-notation": ["error", { "allowKeywords": true, "allowPattern": "" }], "eol-last": ["error", "always"], "eqeqeq": ["error", "smart"], "generator-star-spacing": ["error", "before"], @@ -40,7 +35,7 @@ "no-dupe-args": "error", "no-dupe-keys": "error", "no-mixed-spaces-and-tabs": ["error", "smart-tabs"], - "no-redeclare": ["error", {"builtinGlobals": true}], + "no-redeclare": ["error", { "builtinGlobals": true }], "no-trailing-spaces": ["error", { "skipBlankLines": false }], "no-undef": "error", "no-use-before-define": "off", @@ -54,7 +49,7 @@ "mocha/no-exclusive-tests": ["error"], "promise/always-return": "off", - "promise/avoid-new": "off", + "promise/avoid-new": "off" }, "parserOptions": { "ecmaVersion": 2020 diff --git a/contracts/package.json b/contracts/package.json index a54becd4..78530c9c 100644 --- a/contracts/package.json +++ b/contracts/package.json @@ -1,7 +1,7 @@ { "name": "@hypercerts-org/contracts", "description": "EVM compatible protocol for managing impact claims", - "version": "0.8.11", + "version": "0.9.0", "author": { "name": "Hypercerts Foundation", "url": "https://github.com/hypercerts-org/hypercerts" @@ -26,47 +26,33 @@ "files": [ "dist", "README.md", - "package.json", - "contracts" + "package.json" ], "devDependencies": { + "@chainlink/contracts": "^0.8.0", "@commitlint/cli": "^17.1.2", "@commitlint/config-conventional": "^17.1.0", "@dlsl/hardhat-markup": "^1.0.0-rc.7", - "@ethersproject/abi": "^5.7.0", - "@ethersproject/bytes": "^5.7.0", - "@ethersproject/providers": "^5.7.2", - "@nomicfoundation/hardhat-chai-matchers": "^1.0.5", - "@nomicfoundation/hardhat-network-helpers": "^1.0.7", - "@nomicfoundation/hardhat-toolbox": "^2.0.0", - "@nomiclabs/hardhat-ethers": "^2.2.1", - "@nomiclabs/hardhat-etherscan": "^3.1.3", - "@openzeppelin/hardhat-defender": "^1.8.2", - "@openzeppelin/hardhat-upgrades": "^1.28", + "@looksrare/contracts-libs": "^3.4.0", + "@nomicfoundation/hardhat-toolbox": "^3.0.0", + "@openzeppelin/contracts": "<5.0.0", + "@openzeppelin/hardhat-upgrades": "2.3.3", "@primitivefi/hardhat-dodoc": "^0.2.3", "@rollup/plugin-commonjs": "^24.0.1", "@rollup/plugin-json": "^6.0.0", "@rollup/plugin-node-resolve": "^15.0.1", "@trivago/prettier-plugin-sort-imports": "^3.3.0", - "@typechain/ethers-v5": "^11.1.1", - "@typechain/hardhat": "^9.0.0", - "@types/chai": "^4.3.4", - "@types/mocha": "9.1.0", "@types/node": "^18.11.11", "@typescript-eslint/eslint-plugin": "^5.38.0", "@typescript-eslint/parser": "^5.38.0", - "chai": "^4.3.7", "commitizen": "^4.2.5", - "copyfiles": "^2.4.1", "cross-env": "^7.0.3", "cz-conventional-changelog": "^3.3.0", "dotenv": "^16.0.2", "eslint": "^8.23.1", "eslint-config-prettier": "^8.5.0", - "ethers": "^5.7.2", - "hardhat": "2.13.1", + "ethers": "^6.8.0", "hardhat-abi-exporter": "^2.10.1", - "hardhat-gas-reporter": "^1.0.9", "hardhat-preprocessor": "^0.1.5", "husky": "^8.0.1", "lint-staged": "^13.0.3", @@ -81,7 +67,7 @@ "shx": "^0.3.4", "solhint": "^3.6.2", "solhint-plugin-prettier": "^0.0.5", - "solidity-coverage": "^0.8.2", + "solmate": "^6.2.0", "ts-node": "^10.9.1", "typechain": "^8.3.1", "typescript": "^4.9.4" @@ -97,22 +83,27 @@ "template" ], "scripts": { - "build": "hardhat compile && pnpm tsc -p tsconfig.build.json && rollup -c && pnpm copy:contracts", - "build:forge": "forge build", - "clean": "rimraf cache out dist typechain abi", - "copy:contracts": "copyfiles -u 1 ./src/**/*.sol ./src/*.sol ./contracts", + "build": "pnpm clean && hardhat compile && pnpm tsc -p tsconfig.build.json && rollup -c", + "build:forge": "pnpm clean && forge build", + "clean": "rimraf abi artifacts build cache cache_hardhat dist out types", + "deploy:marketplace:goerli": "forge script scripts/deployment/Deployment.s.sol:Deployment --broadcast --verify --fork-url goerli", + "deploy:marketplace:sepolia": "forge script scripts/deployment/Deployment.s.sol:Deployment --broadcast --verify --fork-url sepolia", + "deploy:marketplace:test": "pnpm deploy:marketplace:goerli && pnpm deploy:marketplace:sepolia", + "deploy:marketplace:dryrun": "forge script scripts/deployment/Deployment.s.sol:Deployment --fork-url", "docs": "hardhat dodoc", "lint": "pnpm lint:sol && pnpm prettier:check", - "lint:sol": "solhint -w 5 \"./{src,test}/**/*.sol\"", - "prebuild": "pnpm clean", + "lint:sol": "forge fmt --check && solhint \"./{src,test/protocol,test/marketplace}/**/*.sol\"", "prepublish": "pnpm build", - "prettier": "prettier --config \"./.prettierrc.yml\" --write \"**/*.{json,md,sol,yml}\"", - "prettier:check": "prettier --config \"./.prettierrc.yml\" --check \"**/*.{json,md,sol,yml}\"", + "prettier": "prettier --config \"./.prettierrc.yml\" --write \"**/*.{json,md,ts,yml}\"", + "prettier:check": "prettier --config \"./.prettierrc.yml\" --check \"**/*.{json,md,ts,yml}\"", "slither": "slither ./src", "test": "pnpm test:hardhat && pnpm test:forge", "test:forge": "forge test", "test:hardhat": "hardhat test", "test:gas": "forge test --match-path test/foundry/PerformanceTesting.t.sol --gas-report", "hardhat": "hardhat" + }, + "dependencies": { + "hardhat": "^2.18.3" } } diff --git a/contracts/remappings.txt b/contracts/remappings.txt index bb8f23eb..6fdc5ec2 100644 --- a/contracts/remappings.txt +++ b/contracts/remappings.txt @@ -4,3 +4,8 @@ murky/=lib/murky/src/ oz-upgradeable/=lib/openzeppelin-contracts-upgradeable/contracts/ oz-contracts/=lib/murky/lib/openzeppelin-contracts/ prb-test/=lib/prb-test/src/ +@hypercerts/protocol/=src/protocol/ +@hypercerts/marketplace/=src/marketplace/ +@looksrare/=node_modules/@looksrare/ +hardhat/=node_modules/hardhat/ +solmate/=node_modules/solmate/ diff --git a/contracts/rollup.config.mjs b/contracts/rollup.config.mjs index f6e55c8b..77c81300 100644 --- a/contracts/rollup.config.mjs +++ b/contracts/rollup.config.mjs @@ -8,7 +8,7 @@ import nodePolyfills from "rollup-plugin-node-polyfills"; export default [ { - input: `build/index.js`, + input: `build/src/index.js`, plugins: [ autoExternal(), nodePolyfills(), @@ -33,7 +33,7 @@ export default [ ], }, { - input: `build/index.d.ts`, + input: `build/src/index.d.ts`, plugins: [json(), dts()], output: { file: `dist/index.d.ts`, diff --git a/contracts/scripts/deployment/Deployment.s.sol b/contracts/scripts/deployment/Deployment.s.sol new file mode 100644 index 00000000..244652e5 --- /dev/null +++ b/contracts/scripts/deployment/Deployment.s.sol @@ -0,0 +1,117 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.17; + +// Scripting tool +import {Script} from "forge-std/Script.sol"; + +// Core contracts +import {LooksRareProtocol} from "@hypercerts/marketplace/LooksRareProtocol.sol"; +import {TransferManager} from "@hypercerts/marketplace/TransferManager.sol"; +import {StrategyCollectionOffer} from "@hypercerts/marketplace/executionStrategies/StrategyCollectionOffer.sol"; + +// Create2 factory interface +import {IImmutableCreate2Factory} from "@hypercerts/marketplace/interfaces/IImmutableCreate2Factory.sol"; + +// Other contracts +import {OrderValidatorV2A} from "@hypercerts/marketplace/helpers/OrderValidatorV2A.sol"; + +contract Deployment is Script { + address internal deployer; + IImmutableCreate2Factory private constant IMMUTABLE_CREATE2_FACTORY = + IImmutableCreate2Factory(0x0000000000FFe8B47B3e2130213B802212439497); + + error ChainIdInvalid(uint256 chainId); + error MnemonicInvalid(); + + address public weth; + + // address public royaltyFeeRegistry; + + uint16 internal constant _standardProtocolFeeBp = uint16(50); + uint16 internal constant _minTotalFeeBp = uint16(50); + uint16 internal constant _maxProtocolFeeBp = uint16(200); + + function setUp() public virtual { + string memory mnemonic = vm.envString("MNEMONIC"); + if (bytes(mnemonic).length > 0) { + (deployer,) = deriveRememberKey(mnemonic, 0); + } else { + revert MnemonicInvalid(); + } + } + + function run() external { + uint256 chainId = block.chainid; + + if (chainId == 5) { + weth = 0xB4FBF271143F4FBf7B91A5ded31805e42b2208d6; + } else if (chainId == 11_155_111) { + weth = 0xfFf9976782d46CC05630D1f6eBAb18b2324d6B14; + } else { + revert ChainIdInvalid(chainId); + } + + vm.startBroadcast(deployer); + + // 1. Deploy TransferManager + address transferManagerAddress = IMMUTABLE_CREATE2_FACTORY.safeCreate2({ + salt: vm.envBytes32("TRANSFER_MANAGER_SALT"), + initializationCode: abi.encodePacked( + type(TransferManager).creationCode, abi.encode(vm.envAddress("OWNER_ADDRESS")) + ) + }); + + // 2. Transfer 1 wei to LooksRareProtocol before it is deployed. + // It cannot receive ETH after it is deployed. + payable(0x0000000000E655fAe4d56241588680F86E3b2377).transfer(1 wei); + + // 3. Deploy LooksRareProtocol + address looksRareProtocolAddress = IMMUTABLE_CREATE2_FACTORY.safeCreate2({ + salt: vm.envBytes32("LOOKSRARE_PROTOCOL_SALT"), + initializationCode: abi.encodePacked( + type(LooksRareProtocol).creationCode, + abi.encode( + vm.envAddress("OWNER_ADDRESS"), + vm.envAddress("PROTOCOL_FEE_RECIPIENT_ADDRESS"), + transferManagerAddress, + weth + ) + ) + }); + + // 4. Other operations + TransferManager(transferManagerAddress).allowOperator(looksRareProtocolAddress); + LooksRareProtocol(looksRareProtocolAddress).updateCurrencyStatus(address(0), true); + LooksRareProtocol(looksRareProtocolAddress).updateCurrencyStatus(weth, true); + + // 5. Deploy OrderValidatorV2A, this needs to happen after updateCreatorFeeManager + // as the order validator calls creator fee manager to retrieve the royalty fee registry + new OrderValidatorV2A(looksRareProtocolAddress); + + // 6. Deploy StrategyCollectionOffer + address strategyCollectionOfferAddress = IMMUTABLE_CREATE2_FACTORY.safeCreate2({ + salt: vm.envBytes32("STRATEGY_COLLECTION_OFFER_SALT"), + initializationCode: type(StrategyCollectionOffer).creationCode + }); + + LooksRareProtocol(looksRareProtocolAddress).addStrategy( + _standardProtocolFeeBp, + _minTotalFeeBp, + _maxProtocolFeeBp, + StrategyCollectionOffer.executeCollectionStrategyWithTakerAsk.selector, + true, + strategyCollectionOfferAddress + ); + + LooksRareProtocol(looksRareProtocolAddress).addStrategy( + _standardProtocolFeeBp, + _minTotalFeeBp, + _maxProtocolFeeBp, + StrategyCollectionOffer.executeCollectionStrategyWithTakerAskWithProof.selector, + true, + strategyCollectionOfferAddress + ); + + vm.stopBroadcast(); + } +} diff --git a/contracts/scripts/deployment/ProtocolFeeRecipientDeployment.s.sol b/contracts/scripts/deployment/ProtocolFeeRecipientDeployment.s.sol new file mode 100644 index 00000000..dc08c0b7 --- /dev/null +++ b/contracts/scripts/deployment/ProtocolFeeRecipientDeployment.s.sol @@ -0,0 +1,43 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.17; + +// Scripting tool +import {Script} from "forge-std/Script.sol"; + +// Core contracts +import {ProtocolFeeRecipient} from "@hypercerts/marketplace/ProtocolFeeRecipient.sol"; + +contract ProtocolFeeRecipientDeployment is Script { + error ChainIdInvalid(uint256 chainId); + + // WETH + address public weth; + address private feeSharingSetter; + + function run() external { + uint256 chainId = block.chainid; + uint256 deployerPrivateKey; + + if (chainId == 1) { + weth = 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2; + feeSharingSetter = 0x5924A28caAF1cc016617874a2f0C3710d881f3c1; + deployerPrivateKey = vm.envUint("MAINNET_KEY"); + } else if (chainId == 5) { + weth = 0xB4FBF271143F4FBf7B91A5ded31805e42b2208d6; + feeSharingSetter = 0x3d1E1521b659b0C942836DeF24dd254aBdEb873b; + deployerPrivateKey = vm.envUint("TESTNET_KEY"); + } else if (chainId == 11_155_111) { + weth = 0x7b79995e5f793A07Bc00c21412e50Ecae098E7f9; + feeSharingSetter = 0x8a7c709648160a5A1191D07dfAB316224E4C6b07; + deployerPrivateKey = vm.envUint("TESTNET_KEY"); + } else { + revert ChainIdInvalid(chainId); + } + + vm.startBroadcast(deployerPrivateKey); + + new ProtocolFeeRecipient(feeSharingSetter, weth); + + vm.stopBroadcast(); + } +} diff --git a/contracts/src/SemiFungible1155.sol b/contracts/src/SemiFungible1155.sol deleted file mode 100644 index cd88714a..00000000 --- a/contracts/src/SemiFungible1155.sol +++ /dev/null @@ -1,433 +0,0 @@ -// SPDX-License-Identifier: MIT -// Used components of Enjin example implementation for mixed fungibility -// https://github.com/enjin/erc-1155/blob/master/contracts/ERC1155MixedFungibleMintable.sol -pragma solidity 0.8.16; - -import { ERC1155Upgradeable } from "oz-upgradeable/token/ERC1155/ERC1155Upgradeable.sol"; -import { ERC1155BurnableUpgradeable } from "oz-upgradeable/token/ERC1155/extensions/ERC1155BurnableUpgradeable.sol"; -import { ERC1155URIStorageUpgradeable } from "oz-upgradeable/token/ERC1155/extensions/ERC1155URIStorageUpgradeable.sol"; -import { OwnableUpgradeable } from "oz-upgradeable/access/OwnableUpgradeable.sol"; -import { Initializable } from "oz-upgradeable/proxy/utils/Initializable.sol"; -import { UUPSUpgradeable } from "oz-upgradeable/proxy/utils/UUPSUpgradeable.sol"; -import { Errors } from "./libs/Errors.sol"; - -/// @title Contract for minting semi-fungible EIP1155 tokens -/// @author bitbeckers -/// @notice Extends { Upgradeable1155 } token with semi-fungible properties and the concept of `units` -/// @dev Adds split bit strategy as described in [EIP-1155](https://eips.ethereum.org/EIPS/eip-1155#non-fungible-tokens) -contract SemiFungible1155 is - Initializable, - ERC1155Upgradeable, - ERC1155BurnableUpgradeable, - ERC1155URIStorageUpgradeable, - OwnableUpgradeable, - UUPSUpgradeable -{ - /// @dev Counter used to generate next typeID. - uint256 internal typeCounter; - - /// @dev Bitmask used to expose only upper 128 bits of uint256 - uint256 internal constant TYPE_MASK = type(uint256).max << 128; - - /// @dev Bitmask used to expose only lower 128 bits of uint256 - uint256 internal constant NF_INDEX_MASK = type(uint256).max >> 128; - - uint256 internal constant FRACTION_LIMIT = 253; - - /// @dev Mapping of `tokenID` to address of `owner` - mapping(uint256 => address) internal owners; - - /// @dev Mapping of `tokenID` to address of `creator` - mapping(uint256 => address) internal creators; - - /// @dev Used to determine amount of `units` stored in token at `tokenID` - mapping(uint256 => uint256) internal tokenValues; - - /// @dev Used to find highest index of token belonging to token at `typeID` - mapping(uint256 => uint256) internal maxIndex; - - /// @dev Emitted on transfer of `value` between `fromTokenID` to `toTokenID` of the same `claimID` - event ValueTransfer(uint256 claimID, uint256 fromTokenID, uint256 toTokenID, uint256 value); - - /// @dev Emitted on transfer of `values` between `fromTokenIDs` to `toTokenIDs` of `claimIDs` - event BatchValueTransfer(uint256[] claimIDs, uint256[] fromTokenIDs, uint256[] toTokenIDs, uint256[] values); - - /// @dev see { openzeppelin-contracts-upgradeable/contracts/proxy/utils/Initializable.sol } - // solhint-disable-next-line func-name-mixedcase - function __SemiFungible1155_init() public virtual onlyInitializing { - __ERC1155_init(""); - __ERC1155Burnable_init(); - __ERC1155URIStorage_init(); - __Ownable_init(); - __UUPSUpgradeable_init(); - } - - /// @dev Get index of fractional token at `_id` by returning lower 128 bit values - /// @dev Returns 0 if `_id` is a baseType - function getItemIndex(uint256 tokenID) internal pure returns (uint256) { - return tokenID & NF_INDEX_MASK; - } - - /// @dev Get base type ID for token at `_id` by returning upper 128 bit values - function getBaseType(uint256 tokenID) internal pure returns (uint256) { - return tokenID & TYPE_MASK; - } - - /// @dev Identify that token at `_id` is base type. - /// @dev Upper 128 bits identify base type ID, lower bits should be 0 - function isBaseType(uint256 tokenID) internal pure returns (bool) { - return (tokenID & TYPE_MASK == tokenID) && (tokenID & NF_INDEX_MASK == 0); - } - - /// @dev Identify that token at `_id` is fraction of a claim. - /// @dev Upper 128 bits identify base type ID, lower bits should be > 0 - function isTypedItem(uint256 tokenID) internal pure returns (bool) { - return (tokenID & TYPE_MASK != 0) && (tokenID & NF_INDEX_MASK != 0); - } - - /// READ - function ownerOf(uint256 tokenID) public view returns (address _owner) { - _owner = owners[tokenID]; - } - - /// @dev see {IHypercertToken} - function _unitsOf(uint256 tokenID) internal view returns (uint256 units) { - units = tokenValues[tokenID]; - } - - /// @dev see {IHypercertToken} - function _unitsOf(address account, uint256 tokenID) internal view returns (uint256 units) { - // Check if fraction token and accounts owns it - if (ownerOf(tokenID) == account) { - units = tokenValues[tokenID]; - } - } - - /// MUTATE - - /// @dev create token type ID based of token counter - - function _createTokenType(address _account, uint256 units, string memory _uri) internal returns (uint256 typeID) { - _notMaxType(typeCounter); - typeID = ++typeCounter << 128; - - creators[typeID] = _account; - tokenValues[typeID] = units; - - _setURI(typeID, _uri); - - //Event emitted for indexing purposes - emit TransferSingle(_account, address(0), address(0), typeID, 0); - } - - /// @dev Mint a new token type and the initial units - function _mintNewTypeWithToken( - address _account, - uint256 _units, - string memory _uri - ) internal returns (uint256 typeID) { - if (_units == 0) { - revert Errors.NotAllowed(); - } - typeID = _createTokenType(_account, _units, _uri); - - uint256 tokenID = typeID + ++maxIndex[typeID]; //1 based indexing, 0 holds type data - - tokenValues[tokenID] = _units; - - _mint(_account, tokenID, 1, ""); - emit ValueTransfer(typeID, 0, tokenID, _units); - } - - /// @dev Mint a new token type and the initial fractions - function _mintNewTypeWithTokens( - address _account, - uint256[] calldata _fractions, - string memory _uri - ) internal returns (uint256 typeID) { - typeID = _mintNewTypeWithToken(_account, _getSum(_fractions), _uri); - _splitTokenUnits(_account, typeID + maxIndex[typeID], _fractions); - } - - /// @dev Mint a new token for an existing type - function _mintToken(address _account, uint256 _typeID, uint256 _units) internal returns (uint256 tokenID) { - if (!isBaseType(_typeID)) revert Errors.NotAllowed(); - - _notMaxItem(maxIndex[_typeID]); - - unchecked { - tokenID = _typeID + ++maxIndex[_typeID]; //1 based indexing, 0 holds type data - } - - tokenValues[tokenID] = _units; - - _mint(_account, tokenID, 1, ""); - emit ValueTransfer(_typeID, 0, tokenID, _units); - } - - /// @dev Mint new tokens for existing types - /// @notice Enables batch claiming from multiple allowlists - function _batchMintTokens( - address _account, - uint256[] calldata _typeIDs, - uint256[] calldata _units - ) internal returns (uint256[] memory tokenIDs) { - uint256 len = _typeIDs.length; - - tokenIDs = new uint256[](len); - uint256[] memory amounts = new uint256[](len); - uint256[] memory zeroes = new uint256[](len); - - for (uint256 i; i < len; ) { - uint256 _typeID = _typeIDs[i]; - if (!isBaseType(_typeID)) revert Errors.NotAllowed(); - _notMaxItem(maxIndex[_typeID]); - - unchecked { - uint256 tokenID = _typeID + ++maxIndex[_typeID]; //1 based indexing, 0 holds type data - tokenValues[tokenID] = _units[i]; - tokenIDs[i] = tokenID; - amounts[i] = 1; - ++i; - } - } - - _mintBatch(_account, tokenIDs, amounts, ""); - emit BatchValueTransfer(_typeIDs, zeroes, tokenIDs, _units); - } - - /// @dev Split the units of `_tokenID` owned by `account` across `_values` - /// @dev `_values` must sum to total `units` held at `_tokenID` - function _splitTokenUnits(address _account, uint256 _tokenID, uint256[] calldata _values) internal { - if (_values.length > FRACTION_LIMIT || _values.length < 2) revert Errors.ArraySize(); - if (tokenValues[_tokenID] != _getSum(_values)) revert Errors.NotAllowed(); - - // Current token - uint256 _typeID = getBaseType(_tokenID); - uint256 valueLeft = tokenValues[_tokenID]; - - // Prepare batch processing, we want to skip the first entry - uint256 len = _values.length - 1; - - uint256[] memory typeIDs = new uint256[](len); - uint256[] memory fromIDs = new uint256[](len); - uint256[] memory toIDs = new uint256[](len); - uint256[] memory amounts = new uint256[](len); - uint256[] memory values = new uint256[](len); - - { - uint256[] memory _valuesCache = _values; - uint256 swapValue = _valuesCache[len]; - _valuesCache[len] = _valuesCache[0]; - _valuesCache[0] = swapValue; - - for (uint256 i; i < len; ) { - _notMaxItem(maxIndex[_typeID]); - - typeIDs[i] = _typeID; - fromIDs[i] = _tokenID; - toIDs[i] = _typeID + ++maxIndex[_typeID]; - amounts[i] = 1; - values[i] = _valuesCache[i]; - - unchecked { - ++i; - } - } - } - - _beforeUnitTransfer(_msgSender(), _account, fromIDs, toIDs, values, ""); - - for (uint256 i; i < len; ) { - valueLeft -= values[i]; - - tokenValues[toIDs[i]] = values[i]; - - unchecked { - ++i; - } - } - - tokenValues[_tokenID] = valueLeft; - - _mintBatch(_account, toIDs, amounts, ""); - - emit BatchValueTransfer(typeIDs, fromIDs, toIDs, values); - } - - /// @dev Merge the units of `_fractionIDs`. - /// @dev Base type of `_fractionIDs` must be identical for all tokens. - function _mergeTokensUnits(address _account, uint256[] memory _fractionIDs) internal { - if (_fractionIDs.length > FRACTION_LIMIT || _fractionIDs.length < 2) { - revert Errors.ArraySize(); - } - uint256 len = _fractionIDs.length - 1; - - uint256 target = _fractionIDs[len]; - - uint256 _totalValue; - uint256[] memory fromIDs = new uint256[](len); - uint256[] memory toIDs = new uint256[](len); - uint256[] memory values = new uint256[](len); - uint256[] memory amounts = new uint256[](len); - - { - for (uint256 i; i < len; ) { - uint256 _fractionID = _fractionIDs[i]; - fromIDs[i] = _fractionID; - toIDs[i] = target; - amounts[i] = 1; - values[i] = tokenValues[_fractionID]; - - unchecked { - ++i; - } - } - } - - _beforeUnitTransfer(_msgSender(), _account, fromIDs, toIDs, values, ""); - - for (uint256 i; i < len; ) { - _totalValue += values[i]; - - delete tokenValues[fromIDs[i]]; - unchecked { - ++i; - } - } - - tokenValues[target] += _totalValue; - - _burnBatch(_account, fromIDs, amounts); - } - - /// @dev Burn the token at `_tokenID` owned by `_account` - /// @dev Not allowed to burn base type. - /// @dev `_tokenID` must hold all value declared at base type - function _burnToken(address _account, uint256 _tokenID) internal { - if (_account != _msgSender() && !isApprovedForAll(_account, _msgSender())) revert Errors.NotApprovedOrOwner(); - - uint256 value = tokenValues[_tokenID]; - - delete tokenValues[_tokenID]; - - _burn(_account, _tokenID, 1); - emit ValueTransfer(getBaseType(_tokenID), _tokenID, 0, value); - } - - /// TRANSFERS - - // The following functions are overrides required by Solidity. - function _afterTokenTransfer( - address operator, - address from, - address to, - uint256[] memory ids, - uint256[] memory amounts, - bytes memory data - ) internal virtual override { - super._afterTokenTransfer(operator, from, to, ids, amounts, data); - - uint256 len = ids.length; - - for (uint256 i; i < len; ) { - owners[ids[i]] = to; - unchecked { - ++i; - } - } - } - - function _beforeUnitTransfer( - address operator, - address from, - uint256[] memory fromIDs, - uint256[] memory toIDs, - uint256[] memory values, - bytes memory data - ) internal virtual { - uint256 len = fromIDs.length; - - for (uint256 i; i < len; ) { - uint256 _from = fromIDs[i]; - uint256 _to = toIDs[i]; - - if (isBaseType(_from)) revert Errors.NotAllowed(); - if (getBaseType(_from) != getBaseType(_to)) revert Errors.TypeMismatch(); - if (from != _msgSender() && !isApprovedForAll(from, _msgSender())) revert Errors.NotApprovedOrOwner(); - unchecked { - ++i; - } - } - } - - /// METADATA - - /// @dev see { openzeppelin-contracts-upgradeable/token/ERC1155/extensions/ERC1155URIStorageUpgradeable.sol } - /// @dev Always returns the URI for the basetype so that it's managed in one place. - function uri( - uint256 tokenID - ) public view virtual override(ERC1155Upgradeable, ERC1155URIStorageUpgradeable) returns (string memory _uri) { - // All tokens share the same metadata at the moment - _uri = ERC1155URIStorageUpgradeable.uri(getBaseType(tokenID)); - } - - /// UTILS - - /** - * @dev Check if value is below max item index - */ - function _notMaxItem(uint256 tokenID) private pure { - uint128 _count = uint128(tokenID); - ++_count; - } - - /** - * @dev Check if value is below max type index - */ - function _notMaxType(uint256 tokenID) private pure { - uint128 _count = uint128(tokenID >> 128); - ++_count; - } - - /** - * @dev calculate the sum of the elements of an array - */ - function _getSum(uint256[] memory array) internal pure returns (uint256 sum) { - uint256 len = array.length; - for (uint256 i; i < len; ) { - if (array[i] == 0) revert Errors.NotAllowed(); - sum += array[i]; - unchecked { - ++i; - } - } - } - - function _getSingletonArray(uint256 element) private pure returns (uint256[] memory) { - uint256[] memory array = new uint256[](1); - array[0] = element; - - return array; - } - - // UUPS PROXY - - /// @dev see { openzeppelin-contracts-upgradeable/contracts/proxy/utils/UUPSUpgradeable.sol } - function _authorizeUpgrade(address newImplementation) internal virtual override onlyOwner { - // solhint-disable-previous-line no-empty-blocks - } - - /** - * @dev This empty reserved space is put in place to allow future versions to add new - * variables without shifting down storage in the inheritance chain. - * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps - * Assuming 30 available slots (slots cost space, cost gas) - * 1. typeCounter - * 2. owners - * 3. creators - * 4. tokenValues - * 5. maxIndex - */ - uint256[25] private __gap; -} diff --git a/contracts/src/deployments.json b/contracts/src/deployments.json new file mode 100644 index 00000000..4156e8e6 --- /dev/null +++ b/contracts/src/deployments.json @@ -0,0 +1,22 @@ +{ + "5": { + "HypercertMinterUUPS": "0x822F17A9A5EeCFd66dBAFf7946a8071C265D1d07", + "HypercertMinterImplementation": "0x0a00a2f09cd37b24e7429c5238323bfebcff3ed9", + "TransferManager": "0x91CC106977934becc64e56987a89547077E95186", + "HypercertExchange": "0xE6563d73D19794d50526eB1B02441530ED190dc5" + }, + "11155111": { + "HypercertMinterUUPS": "0xa16DFb32Eb140a6f3F2AC68f41dAd8c7e83C4941", + "HypercertMinterImplementation": "0x0a0df97bddb36eef95fef089a4aeb7aceabf2101", + "TransferManager": "0x91CC106977934becc64e56987a89547077E95186", + "HypercertExchange": "0x7AFc7938130bd03b792C0B05C796f42E9beBB2D6" + }, + "10": { + "HypercertMinterUUPS": "0x822F17A9A5EeCFd66dBAFf7946a8071C265D1d07", + "HypercertMinterImplementation": "0x396d5f1ef3aa92ddad4dead04388374a03bc5577" + }, + "42220": { + "HypercertMinterUUPS": "0x16bA53B74c234C870c61EFC04cD418B8f2865959", + "HypercertMinterImplementation": "0x620257e9301a813be7cc5b75aae8dda3f6a926d2" + } +} diff --git a/contracts/src/index.ts b/contracts/src/index.ts index 486b728b..3019f4fc 100644 --- a/contracts/src/index.ts +++ b/contracts/src/index.ts @@ -1,10 +1,28 @@ -import HypercertMinterAbi from "./abi/HypercertMinter.json"; -// import { HypercertMinter__factory } from "./types/factories/src/HypercertMinter__factory"; -import type { AllowlistMinter } from "./types/src/AllowlistMinter"; -import type { HypercertMinter } from "./types/src/HypercertMinter"; -import type { IAllowlist } from "./types/src/interfaces/IAllowlist"; -import type { IHypercertToken } from "./types/src/interfaces/IHypercertToken"; -import type { Errors } from "./types/src/libs/Errors"; +import HypercertMinterAbi from "../abi/HypercertMinter.json"; +import AllowlistMinterAbi from "../abi/AllowlistMinter.json"; +import CurrencyManagerAbi from "../abi/CurrencyManager.json"; +import ExecutionManagerAbi from "../abi/ExecutionManager.json"; +import LooksRareProtocolAbi from "../abi/LooksRareProtocol.json"; +import NonceManagerAbi from "../abi/NonceManager.json"; +import OrderValidatorV2AAbi from "../abi/OrderValidatorV2A.json"; +import StrategyManagerAbi from "../abi/StrategyManager.json"; +import TransferManagerAbi from "../abi/TransferManager.json"; + +import type { CurrencyManager } from "../types/src/marketplace/CurrencyManager"; +import type { ExecutionManager } from "../types/src/marketplace/ExecutionManager"; +import type { LooksRareProtocol } from "../types/src/marketplace/LooksRareProtocol"; +import type { NonceManager } from "../types/src/marketplace/NonceManager"; +import type { OrderValidatorV2A } from "../types/src/marketplace/helpers/OrderValidatorV2A"; +import type { StrategyManager } from "../types/src/marketplace/StrategyManager"; +import type { TransferManager } from "../types/src/marketplace/TransferManager"; +import type { AllowlistMinter } from "../types/src/protocol/AllowlistMinter"; +import type { HypercertMinter } from "../types/src/protocol/HypercertMinter"; +import type { IAllowlist } from "../types/src/protocol/interfaces/IAllowlist"; +import type { IHypercertToken } from "../types/src/protocol/interfaces/IHypercertToken"; +import type { Errors } from "../types/src/protocol/libs/Errors"; + +import deployments from "./deployments.json"; + /* in order to adjust the build folder: 1) import any files here you want in the final build package. @@ -13,15 +31,35 @@ import type { Errors } from "./types/src/libs/Errors"; 4) bump package.json version to publish a new package to npm. */ -// Factory -// export { HypercertMinter__factory }; +// Deployments +export { deployments }; // Interfaces export { IAllowlist, IHypercertToken }; -export { HypercertMinterAbi }; +export { + HypercertMinterAbi, + AllowlistMinterAbi, + CurrencyManagerAbi, + ExecutionManagerAbi, + LooksRareProtocolAbi as HypercertExchangeAbi, + NonceManagerAbi, + OrderValidatorV2AAbi, + StrategyManagerAbi, + TransferManagerAbi, +}; // Contracts -export { HypercertMinter, AllowlistMinter }; +export { + HypercertMinter, + AllowlistMinter, + CurrencyManager, + ExecutionManager, + LooksRareProtocol as HypercertExchange, + NonceManager, + OrderValidatorV2A, + StrategyManager, + TransferManager, +}; // Libs export { Errors }; diff --git a/contracts/src/interfaces/IAllowlist.sol b/contracts/src/interfaces/IAllowlist.sol deleted file mode 100644 index fe4a9ec4..00000000 --- a/contracts/src/interfaces/IAllowlist.sol +++ /dev/null @@ -1,14 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity 0.8.16; - -/// @title Interface for allowlist -/// @author bitbeckers -/// @notice This interface declares the required functionality for a hypercert token -/// @notice This interface does not specify the underlying token type (e.g. 721 or 1155) -interface IAllowlist { - function isAllowedToClaim( - bytes32[] calldata proof, - uint256 tokenID, - bytes32 leaf - ) external view returns (bool isAllowed); -} diff --git a/contracts/src/interfaces/IHypercertToken.sol b/contracts/src/interfaces/IHypercertToken.sol deleted file mode 100644 index 1ed1e34e..00000000 --- a/contracts/src/interfaces/IHypercertToken.sol +++ /dev/null @@ -1,62 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity 0.8.16; - -/// @title Interface for hypercert token interactions -/// @author bitbeckers -/// @notice This interface declares the required functionality for a hypercert token -/// @notice This interface does not specify the underlying token type (e.g. 721 or 1155) -interface IHypercertToken { - /** - * AllowAll = Unrestricted - * DisallowAll = Transfers disabled after minting - * FromCreatorOnly = Only the original creator can transfer - */ - /// @dev Transfer restriction policies on hypercerts - enum TransferRestrictions { - AllowAll, - DisallowAll, - FromCreatorOnly - } - - /// @dev Emitted when token with tokenID `claimID` is stored, with external data reference via `uri`. - event ClaimStored(uint256 indexed claimID, string uri, uint256 totalUnits); - - /// @dev Function called to store a claim referenced via `uri` with a maximum number of fractions `units`. - function mintClaim(address account, uint256 units, string memory uri, TransferRestrictions restrictions) external; - - /// @dev Function called to store a claim referenced via `uri` with a set of `fractions`. - /// @dev Fractions are internally summed to total units. - function mintClaimWithFractions( - address account, - uint256 units, - uint256[] memory fractions, - string memory uri, - TransferRestrictions restrictions - ) external; - - /// @dev Function called to split `tokenID` owned by `account` into units declared in `values`. - /// @notice The sum of `values` must equal the current value of `_tokenID`. - function splitFraction(address account, uint256 tokenID, uint256[] memory _values) external; - - /// @dev Function called to merge tokens within `tokenIDs`. - /// @notice Tokens that have been merged are burned. - function mergeFractions(address account, uint256[] memory tokenIDs) external; - - /// @dev Function to burn the token at `tokenID` for `account` - /// @notice Operator must be allowed by `creator` and the token must represent the total amount of available units. - function burnFraction(address account, uint256 tokenID) external; - - /// @dev Returns the `units` held by a (fractional) token at `claimID` - /// @dev If `tokenID` is a base type, the total amount of `units` for the claim is returned. - /// @dev If `tokenID` is a fractional token, the `units` held by the token is returned - function unitsOf(uint256 tokenID) external view returns (uint256 units); - - /// @dev Returns the `units` held by `account` of a (fractional) token at `claimID` - /// @dev If `tokenID` is a base type, the total amount of `units` held by `account` for the claim is returned. - /// @dev If `tokenID` is a fractional token, the `units` held by `account` the token is returned - function unitsOf(address account, uint256 tokenID) external view returns (uint256 units); - - /// @dev Returns the `uri` for metadata of the claim represented by `tokenID` - /// @dev Metadata must conform to { Hypercert Metadata } spec (based on ERC1155 Metadata) - function uri(uint256 tokenID) external view returns (string memory metadata); -} diff --git a/contracts/src/libs/Errors.sol b/contracts/src/libs/Errors.sol deleted file mode 100644 index e19d6b5c..00000000 --- a/contracts/src/libs/Errors.sol +++ /dev/null @@ -1,15 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity ^0.8.16; - -/// @author bitbeckers -library Errors { - error AlreadyClaimed(); - error ArraySize(); - error DoesNotExist(); - error DuplicateEntry(); - error Invalid(); - error NotAllowed(); - error NotApprovedOrOwner(); - error TransfersNotAllowed(); - error TypeMismatch(); -} diff --git a/contracts/src/marketplace/BatchOrderTypehashRegistry.sol b/contracts/src/marketplace/BatchOrderTypehashRegistry.sol new file mode 100644 index 00000000..9710a735 --- /dev/null +++ b/contracts/src/marketplace/BatchOrderTypehashRegistry.sol @@ -0,0 +1,62 @@ +// SPDX-License-Identifier: MIT +pragma solidity 0.8.17; + +// Shared errors +import {MerkleProofTooLarge} from "./errors/SharedErrors.sol"; + +/** + * @title BatchOrderTypehashRegistry + * @notice The contract generates the batch order hash that is used to compute the digest for signature verification. + * @author LooksRare protocol team (👀,💎) + */ +contract BatchOrderTypehashRegistry { + /** + * @notice This function returns the hash of the concatenation of batch order type hash and merkle root. + * @param root Merkle root + * @param proofLength Merkle proof length + * @return batchOrderHash The batch order hash + */ + function hashBatchOrder(bytes32 root, uint256 proofLength) public pure returns (bytes32 batchOrderHash) { + batchOrderHash = keccak256(abi.encode(_getBatchOrderTypehash(proofLength), root)); + } + + /** + * @dev It looks like this for each height + * height == 1: BatchOrder(Maker[2] tree)Maker(uint8 quoteType,uint256 globalNonce,uint256 subsetNonce,uint256 + * orderNonce,uint256 strategyId,uint8 collectionType,address collection,address currency,address signer,uint256 + * startTime,uint256 endTime,uint256 price,uint256[] itemIds,uint256[] amounts,bytes additionalParameters) + * height == 2: BatchOrder(Maker[2][2] tree)Maker(uint8 quoteType,uint256 globalNonce,uint256 + * subsetNonce,uint256 orderNonce,uint256 strategyId,uint8 collectionType,address collection,address + * currency,address signer,uint256 startTime,uint256 endTime,uint256 price,uint256[] itemIds,uint256[] amounts,bytes + * additionalParameters) + * height == n: BatchOrder(Maker[2]...[2] tree)Maker(uint8 quoteType,uint256 globalNonce,uint256 + * subsetNonce,uint256 orderNonce,uint256 strategyId,uint8 collectionType,address collection,address + * currency,address signer,uint256 startTime,uint256 endTime,uint256 price,uint256[] itemIds,uint256[] amounts,bytes + * additionalParameters) + */ + function _getBatchOrderTypehash(uint256 height) internal pure returns (bytes32 typehash) { + if (height == 1) { + typehash = hex"9661287f7a4aa4867db46a2453ee15bebac4e8fc25667a58718da658f15de643"; + } else if (height == 2) { + typehash = hex"a54ab330ea9e1dfccee2b86f3666989e7fbd479704416c757c8de8e820142a08"; + } else if (height == 3) { + typehash = hex"93390f5d45ede9dea305f16aec86b2472af4f823851637f1b7019ad0775cea49"; + } else if (height == 4) { + typehash = hex"9dda2c8358da895e43d574bb15954ce5727b22e923a2d8f28261f297bce42f0b"; + } else if (height == 5) { + typehash = hex"92dc717124e161262f9d10c7079e7d54dc51271893fba54aa4a0f270fecdcc98"; + } else if (height == 6) { + typehash = hex"ce02aee5a7a35d40d974463c4c6e5534954fb07a7e7bc966fee268a15337bfd8"; + } else if (height == 7) { + typehash = hex"f7a65efd167a18f7091b2bb929d687dd94503cf0a43620487055ed7d6b727559"; + } else if (height == 8) { + typehash = hex"def24acacad1318b664520f7c10e8bc6d1e7f6f6f7c8b031e70624ceb42266a6"; + } else if (height == 9) { + typehash = hex"4cb4080dc4e7bae88b4dc4307ad5117fa4f26195998a1b5f40368809d7f4c7f2"; + } else if (height == 10) { + typehash = hex"f8b1f864164d8d6e0b45f1399bd711223117a4ab0b057a9c2d7779e86a7c88db"; + } else { + revert MerkleProofTooLarge(height); + } + } +} diff --git a/contracts/src/marketplace/CreatorFeeManagerWithRebates.sol b/contracts/src/marketplace/CreatorFeeManagerWithRebates.sol new file mode 100644 index 00000000..9f0bcc3d --- /dev/null +++ b/contracts/src/marketplace/CreatorFeeManagerWithRebates.sol @@ -0,0 +1,93 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.17; + +// LooksRare unopinionated libraries +import {IERC2981} from "@looksrare/contracts-libs/contracts/interfaces/generic/IERC2981.sol"; + +// Interfaces +import {ICreatorFeeManager} from "./interfaces/ICreatorFeeManager.sol"; +import {IRoyaltyFeeRegistry} from "./interfaces/IRoyaltyFeeRegistry.sol"; + +// Constants +import {ONE_HUNDRED_PERCENT_IN_BP} from "./constants/NumericConstants.sol"; + +/** + * @title CreatorFeeManagerWithRebates + * @notice This contract returns the creator fee address and the creator rebate amount. + * @author LooksRare protocol team (👀,💎) + */ +contract CreatorFeeManagerWithRebates is ICreatorFeeManager { + /** + * @notice Standard royalty fee (in basis point). + */ + uint256 public constant STANDARD_ROYALTY_FEE_BP = 50; + + /** + * @notice Royalty fee registry interface. + */ + IRoyaltyFeeRegistry public immutable royaltyFeeRegistry; + + /** + * @notice Constructor + * @param _royaltyFeeRegistry Royalty fee registry address. + */ + constructor(address _royaltyFeeRegistry) { + royaltyFeeRegistry = IRoyaltyFeeRegistry(_royaltyFeeRegistry); + } + + /** + * @inheritdoc ICreatorFeeManager + */ + function viewCreatorFeeInfo(address collection, uint256 price, uint256[] memory itemIds) + external + view + returns (address creator, uint256 creatorFeeAmount) + { + // Check if there is a royalty info in the system + (creator,) = royaltyFeeRegistry.royaltyInfo(collection, price); + + if (creator == address(0)) { + if (IERC2981(collection).supportsInterface(IERC2981.royaltyInfo.selector)) { + uint256 length = itemIds.length; + + for (uint256 i; i < length;) { + try IERC2981(collection).royaltyInfo(itemIds[i], price) returns ( + address newCreator, uint256 /* newCreatorFeeAmount */ + ) { + if (i == 0) { + creator = newCreator; + + unchecked { + ++i; + } + continue; + } + + if (newCreator != creator) { + revert BundleEIP2981NotAllowed(collection); + } + } catch { + // If creator address is not 0, that means there was at least 1 + // successful call. If all royaltyInfo calls fail, it should assume + // 0 royalty. + // If the first call reverts, even if creator is address(0), subsequent + // successful calls will still revert above with BundleEIP2981NotAllowed + // because newCreator will be different from creator. + if (creator != address(0)) { + revert BundleEIP2981NotAllowed(collection); + } + } + + unchecked { + ++i; + } + } + } + } + + // A fixed royalty fee is applied + if (creator != address(0)) { + creatorFeeAmount = (STANDARD_ROYALTY_FEE_BP * price) / ONE_HUNDRED_PERCENT_IN_BP; + } + } +} diff --git a/contracts/src/marketplace/CreatorFeeManagerWithRoyalties.sol b/contracts/src/marketplace/CreatorFeeManagerWithRoyalties.sol new file mode 100644 index 00000000..4b72630f --- /dev/null +++ b/contracts/src/marketplace/CreatorFeeManagerWithRoyalties.sol @@ -0,0 +1,95 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.17; + +// LooksRare unopinionated libraries +import {IERC2981} from "@looksrare/contracts-libs/contracts/interfaces/generic/IERC2981.sol"; + +// Interfaces +import {ICreatorFeeManager} from "./interfaces/ICreatorFeeManager.sol"; +import {IRoyaltyFeeRegistry} from "./interfaces/IRoyaltyFeeRegistry.sol"; + +/** + * @title CreatorFeeManagerWithRoyalties + * @notice This contract returns the creator fee address and the creator fee amount. + * @author LooksRare protocol team (👀,💎) + */ +contract CreatorFeeManagerWithRoyalties is ICreatorFeeManager { + /** + * @notice Royalty fee registry interface. + */ + IRoyaltyFeeRegistry public immutable royaltyFeeRegistry; + + /** + * @notice Constructor + * @param _royaltyFeeRegistry Royalty fee registry address. + */ + constructor(address _royaltyFeeRegistry) { + royaltyFeeRegistry = IRoyaltyFeeRegistry(_royaltyFeeRegistry); + } + + /** + * @inheritdoc ICreatorFeeManager + * @dev There are two on-chain sources for the royalty fee to distribute. + * 1. RoyaltyFeeRegistry: It is an on-chain registry where creator fee is defined + * for all items of a collection. + * 2. ERC2981: The NFT Royalty Standard where royalty fee is defined at a itemId level in a collection. + * The on-chain logic looks up the registry first. If it does not find anything, + * it checks if a collection is ERC2981. If so, it fetches the proper royalty information for the itemId. + * For a bundle that contains multiple itemIds (for a collection using ERC2981), if the royalty fee/recipient + * differ among the itemIds part of the bundle, the trade reverts. + * This contract DOES NOT enforce any restriction for extremely high creator fee, + * nor verifies the creator fee fetched is inferior to the total price. + * If any contract relies on it to build an on-chain royalty logic, + * it should implement protection against: + * (1) high royalties + * (2) potential unexpected royalty changes that can occur after the creation of the order. + */ + function viewCreatorFeeInfo(address collection, uint256 price, uint256[] memory itemIds) + external + view + returns (address creator, uint256 creatorFeeAmount) + { + // Check if there is a royalty info in the system + (creator, creatorFeeAmount) = royaltyFeeRegistry.royaltyInfo(collection, price); + + if (creator == address(0)) { + if (IERC2981(collection).supportsInterface(IERC2981.royaltyInfo.selector)) { + uint256 length = itemIds.length; + + for (uint256 i; i < length;) { + try IERC2981(collection).royaltyInfo(itemIds[i], price) returns ( + address newCreator, uint256 newCreatorFeeAmount + ) { + if (i == 0) { + creator = newCreator; + creatorFeeAmount = newCreatorFeeAmount; + + unchecked { + ++i; + } + continue; + } + + if (newCreator != creator || newCreatorFeeAmount != creatorFeeAmount) { + revert BundleEIP2981NotAllowed(collection); + } + } catch { + // If creator address is not 0, that means there was at least 1 + // successful call. If all royaltyInfo calls fail, it should assume + // 0 royalty. + // If the first call reverts, even if creator is address(0), subsequent + // successful calls will still revert above with BundleEIP2981NotAllowed + // because newCreator/newCreatorFeeAmount will be different from creator/creatorFeeAmount. + if (creator != address(0)) { + revert BundleEIP2981NotAllowed(collection); + } + } + + unchecked { + ++i; + } + } + } + } + } +} diff --git a/contracts/src/marketplace/CurrencyManager.sol b/contracts/src/marketplace/CurrencyManager.sol new file mode 100644 index 00000000..f72b5471 --- /dev/null +++ b/contracts/src/marketplace/CurrencyManager.sol @@ -0,0 +1,37 @@ +// SPDX-License-Identifier: MIT +pragma solidity 0.8.17; + +// LooksRare unopinionated libraries +import {OwnableTwoSteps} from "@looksrare/contracts-libs/contracts/OwnableTwoSteps.sol"; + +// Interfaces +import {ICurrencyManager} from "./interfaces/ICurrencyManager.sol"; + +/** + * @title CurrencyManager + * @notice This contract manages the list of valid fungible currencies. + * @author LooksRare protocol team (👀,💎) + */ +contract CurrencyManager is ICurrencyManager, OwnableTwoSteps { + /** + * @notice It checks whether the currency is allowed for transacting. + */ + mapping(address => bool) public isCurrencyAllowed; + + /** + * @notice Constructor + * @param _owner Owner address + */ + constructor(address _owner) OwnableTwoSteps(_owner) {} + + /** + * @notice This function allows the owner to update the status of a currency. + * @param currency Currency address (address(0) for ETH) + * @param isAllowed Whether the currency should be allowed for trading + * @dev Only callable by owner. + */ + function updateCurrencyStatus(address currency, bool isAllowed) external onlyOwner { + isCurrencyAllowed[currency] = isAllowed; + emit CurrencyStatusUpdated(currency, isAllowed); + } +} diff --git a/contracts/src/marketplace/ExecutionManager.sol b/contracts/src/marketplace/ExecutionManager.sol new file mode 100644 index 00000000..e3e132df --- /dev/null +++ b/contracts/src/marketplace/ExecutionManager.sol @@ -0,0 +1,304 @@ +// SPDX-License-Identifier: MIT +pragma solidity 0.8.17; + +// Libraries +import {OrderStructs} from "./libraries/OrderStructs.sol"; + +// Interfaces +import {IExecutionManager} from "./interfaces/IExecutionManager.sol"; +import {ICreatorFeeManager} from "./interfaces/ICreatorFeeManager.sol"; + +// Direct dependencies +import {InheritedStrategy} from "./InheritedStrategy.sol"; +import {NonceManager} from "./NonceManager.sol"; +import {StrategyManager} from "./StrategyManager.sol"; + +// Assembly +import { + NoSelectorForStrategy_error_selector, + NoSelectorForStrategy_error_length, + OutsideOfTimeRange_error_selector, + OutsideOfTimeRange_error_length, + Error_selector_offset +} from "./constants/AssemblyConstants.sol"; + +// Constants +import {ONE_HUNDRED_PERCENT_IN_BP} from "./constants/NumericConstants.sol"; + +// Enums +import {QuoteType} from "./enums/QuoteType.sol"; + +/** + * @title ExecutionManager + * @notice This contract handles the execution and resolution of transactions. A transaction is executed on-chain + * when an off-chain maker order is matched by on-chain taker order of a different kind. + * For instance, a taker ask is executed against a maker bid (or a taker bid against a maker ask). + * @author LooksRare protocol team (👀,💎) + */ +contract ExecutionManager is InheritedStrategy, NonceManager, StrategyManager, IExecutionManager { + /** + * @notice Protocol fee recipient. + */ + address public protocolFeeRecipient; + + /** + * @notice Maximum creator fee (in basis point). + */ + // TODO do we need a max? Is 1% max fair? + uint16 public maxCreatorFeeBp = 1000; + + /** + * @notice Creator fee manager. + */ + ICreatorFeeManager public creatorFeeManager; + + /** + * @notice Constructor + * @param _owner Owner address + * @param _protocolFeeRecipient Protocol fee recipient address + */ + constructor(address _owner, address _protocolFeeRecipient) StrategyManager(_owner) { + _updateProtocolFeeRecipient(_protocolFeeRecipient); + } + + /** + * @notice This function allows the owner to update the creator fee manager address. + * @param newCreatorFeeManager Address of the creator fee manager + * @dev Only callable by owner. + */ + function updateCreatorFeeManager(address newCreatorFeeManager) external onlyOwner { + creatorFeeManager = ICreatorFeeManager(newCreatorFeeManager); + emit NewCreatorFeeManager(newCreatorFeeManager); + } + + /** + * @notice This function allows the owner to update the maximum creator fee (in basis point). + * @param newMaxCreatorFeeBp New maximum creator fee (in basis point) + * @dev The maximum value that can be set is 25%. + * Only callable by owner. + */ + function updateMaxCreatorFeeBp(uint16 newMaxCreatorFeeBp) external onlyOwner { + if (newMaxCreatorFeeBp > 2500) { + revert CreatorFeeBpTooHigh(); + } + + maxCreatorFeeBp = newMaxCreatorFeeBp; + + emit NewMaxCreatorFeeBp(newMaxCreatorFeeBp); + } + + /** + * @notice This function allows the owner to update the protocol fee recipient. + * @param newProtocolFeeRecipient New protocol fee recipient address + * @dev Only callable by owner. + */ + function updateProtocolFeeRecipient(address newProtocolFeeRecipient) external onlyOwner { + _updateProtocolFeeRecipient(newProtocolFeeRecipient); + } + + /** + * @notice This function is internal and is used to execute a transaction initiated by a taker order. + * @param takerOrder Taker order struct (taker specific parameters for the execution) + * @param makerOrder Maker order struct (maker specific parameter for the execution) + * @param sender The address that sent the transaction + * @return itemIds Array of item ids to be traded + * @return amounts Array of amounts for each item id + * @return recipients Array of recipient addresses + * @return feeAmounts Array of fee amounts + * @return isNonceInvalidated Whether the order's nonce will be invalidated after executing the order + */ + function _executeStrategyForTakerOrder( + OrderStructs.Taker calldata takerOrder, + OrderStructs.Maker calldata makerOrder, + address sender + ) + internal + returns ( + uint256[] memory itemIds, + uint256[] memory amounts, + address[2] memory recipients, + uint256[3] memory feeAmounts, + bool isNonceInvalidated + ) + { + uint256 price; + + // Verify the order validity for timestamps + _verifyOrderTimestampValidity(makerOrder.startTime, makerOrder.endTime); + + if (makerOrder.strategyId == 0) { + _verifyItemIdsAndAmountsEqualLengthsAndValidAmounts(makerOrder.amounts, makerOrder.itemIds); + (price, itemIds, amounts) = (makerOrder.price, makerOrder.itemIds, makerOrder.amounts); + isNonceInvalidated = true; + } else { + if (strategyInfo[makerOrder.strategyId].isActive) { + /** + * @dev This is equivalent to + * + * if (makerOrder.quoteType == QuoteType.Bid) { + * if (!strategyInfo[makerOrder.strategyId].isMakerBid) { + * revert NoSelectorForStrategy(); + * } + * } else { + * if (strategyInfo[makerOrder.strategyId].isMakerBid) { + * revert NoSelectorForStrategy(); + * } + * } + * + * because one must be 0 and another must be 1 for the function + * to not revert. + * + * Both quoteType (an enum with 2 values) and isMakerBid (a bool) + * can only be 0 or 1. + */ + QuoteType quoteType = makerOrder.quoteType; + bool isMakerBid = strategyInfo[makerOrder.strategyId].isMakerBid; + assembly { + if eq(quoteType, isMakerBid) { + mstore(0x00, NoSelectorForStrategy_error_selector) + revert(Error_selector_offset, NoSelectorForStrategy_error_length) + } + } + + (bool status, bytes memory data) = strategyInfo[makerOrder.strategyId].implementation.call( + abi.encodeWithSelector(strategyInfo[makerOrder.strategyId].selector, takerOrder, makerOrder) + ); + + if (!status) { + // @dev It forwards the revertion message from the low-level call + assembly { + revert(add(data, 32), mload(data)) + } + } + + (price, itemIds, amounts, isNonceInvalidated) = abi.decode(data, (uint256, uint256[], uint256[], bool)); + } else { + revert StrategyNotAvailable(makerOrder.strategyId); + } + } + + // Creator fee and adjustment of protocol fee + (recipients[1], feeAmounts[1]) = + _getCreatorRecipientAndCalculateFeeAmount(makerOrder.collection, price, itemIds); + if (makerOrder.quoteType == QuoteType.Bid) { + _setTheRestOfFeeAmountsAndRecipients( + makerOrder.strategyId, + price, + takerOrder.recipient == address(0) ? sender : takerOrder.recipient, + feeAmounts, + recipients + ); + } else { + _setTheRestOfFeeAmountsAndRecipients( + makerOrder.strategyId, price, makerOrder.signer, feeAmounts, recipients + ); + } + } + + /** + * @notice This private function updates the protocol fee recipient. + * @param newProtocolFeeRecipient New protocol fee recipient address + */ + function _updateProtocolFeeRecipient(address newProtocolFeeRecipient) private { + if (newProtocolFeeRecipient == address(0)) { + revert NewProtocolFeeRecipientCannotBeNullAddress(); + } + + protocolFeeRecipient = newProtocolFeeRecipient; + emit NewProtocolFeeRecipient(newProtocolFeeRecipient); + } + + /** + * @notice This function is internal and is used to calculate + * the protocol fee amount for a set of fee amounts. + * @param price Transaction price + * @param strategyId Strategy id + * @param creatorFeeAmount Creator fee amount + * @param minTotalFeeAmount Min total fee amount + * @return protocolFeeAmount Protocol fee amount + */ + function _calculateProtocolFeeAmount( + uint256 price, + uint256 strategyId, + uint256 creatorFeeAmount, + uint256 minTotalFeeAmount + ) private view returns (uint256 protocolFeeAmount) { + protocolFeeAmount = (price * strategyInfo[strategyId].standardProtocolFeeBp) / ONE_HUNDRED_PERCENT_IN_BP; + + if (protocolFeeAmount + creatorFeeAmount < minTotalFeeAmount) { + protocolFeeAmount = minTotalFeeAmount - creatorFeeAmount; + } + } + + /** + * @notice This function is internal and is used to get the creator fee address + * and calculate the creator fee amount. + * @param collection Collection address + * @param price Transaction price + * @param itemIds Array of item ids + * @return creator Creator recipient + * @return creatorFeeAmount Creator fee amount + */ + function _getCreatorRecipientAndCalculateFeeAmount(address collection, uint256 price, uint256[] memory itemIds) + private + view + returns (address creator, uint256 creatorFeeAmount) + { + if (address(creatorFeeManager) != address(0)) { + (creator, creatorFeeAmount) = creatorFeeManager.viewCreatorFeeInfo(collection, price, itemIds); + + if (creator == address(0)) { + // If recipient is null address, creator fee is set to 0 + creatorFeeAmount = 0; + } else if (creatorFeeAmount * ONE_HUNDRED_PERCENT_IN_BP > (price * uint256(maxCreatorFeeBp))) { + // If creator fee is higher than tolerated, it reverts + revert CreatorFeeBpTooHigh(); + } + } + } + + /** + * @dev This function does not need to return feeAmounts and recipients as they are modified + * in memory. + */ + function _setTheRestOfFeeAmountsAndRecipients( + uint256 strategyId, + uint256 price, + address askRecipient, + uint256[3] memory feeAmounts, + address[2] memory recipients + ) private view { + // Compute minimum total fee amount + uint256 minTotalFeeAmount = (price * strategyInfo[strategyId].minTotalFeeBp) / ONE_HUNDRED_PERCENT_IN_BP; + + if (feeAmounts[1] == 0) { + // If creator fee is null, protocol fee is set as the minimum total fee amount + feeAmounts[2] = minTotalFeeAmount; + // Net fee amount for seller + feeAmounts[0] = price - feeAmounts[2]; + } else { + // If there is a creator fee information, the protocol fee amount can be calculated + feeAmounts[2] = _calculateProtocolFeeAmount(price, strategyId, feeAmounts[1], minTotalFeeAmount); + // Net fee amount for seller + feeAmounts[0] = price - feeAmounts[1] - feeAmounts[2]; + } + + recipients[0] = askRecipient; + } + + /** + * @notice This function is internal and is used to verify the validity of an order + * in the context of the current block timestamps. + * @param startTime Start timestamp + * @param endTime End timestamp + */ + function _verifyOrderTimestampValidity(uint256 startTime, uint256 endTime) private view { + // if (startTime > block.timestamp || endTime < block.timestamp) revert OutsideOfTimeRange(); + assembly { + if or(gt(startTime, timestamp()), lt(endTime, timestamp())) { + mstore(0x00, OutsideOfTimeRange_error_selector) + revert(Error_selector_offset, OutsideOfTimeRange_error_length) + } + } + } +} diff --git a/contracts/src/marketplace/InheritedStrategy.sol b/contracts/src/marketplace/InheritedStrategy.sol new file mode 100644 index 00000000..93d09414 --- /dev/null +++ b/contracts/src/marketplace/InheritedStrategy.sol @@ -0,0 +1,89 @@ +// SPDX-License-Identifier: MIT +pragma solidity 0.8.17; + +// Libraries +import {OrderStructs} from "./libraries/OrderStructs.sol"; + +// Shared errors +import {OrderInvalid} from "./errors/SharedErrors.sol"; + +// Assembly +import { + OrderInvalid_error_selector, + OrderInvalid_error_length, + Error_selector_offset, + OneWord +} from "./constants/AssemblyConstants.sol"; + +/** + * @title InheritedStrategy + * @notice This contract handles the verification of parameters for standard transactions. + * It does not verify the taker struct's itemIds and amounts array as well as + * minPrice (taker ask) / maxPrice (taker bid) because before the taker executes the + * transaction and the maker itemIds/amounts/price should have already been confirmed off-chain. + * @dev A standard transaction (bid or ask) is mapped to strategyId = 0. + * @author LooksRare protocol team (👀,💎) + */ +contract InheritedStrategy { + /** + * @notice This function is internal and is used to validate the parameters for a standard sale strategy + * when the standard transaction is initiated by a taker bid. + * @param amounts Array of amounts + * @param itemIds Array of item ids + */ + function _verifyItemIdsAndAmountsEqualLengthsAndValidAmounts(uint256[] calldata amounts, uint256[] calldata itemIds) + internal + pure + { + assembly { + let end + { + /* + * @dev If A == B, then A XOR B == 0. + * + * if (amountsLength == 0 || amountsLength != itemIdsLength) { + * revert OrderInvalid(); + * } + */ + let amountsLength := amounts.length + let itemIdsLength := itemIds.length + + if or(iszero(amountsLength), xor(amountsLength, itemIdsLength)) { + mstore(0x00, OrderInvalid_error_selector) + revert(Error_selector_offset, OrderInvalid_error_length) + } + + /** + * @dev Shifting left 5 times is equivalent to amountsLength * 32 bytes + */ + end := shl(5, amountsLength) + } + + let amountsOffset := amounts.offset + + for {} end {} { + /** + * @dev Starting from the end of the array minus 32 bytes to load the last item, + * ending with `end` equal to 0 to load the first item + * + * uint256 end = amountsLength; + * + * for (uint256 i = end - 1; i >= 0; i--) { + * uint256 amount = amounts[i]; + * if (amount == 0) { + * revert OrderInvalid(); + * } + * } + */ + end := sub(end, OneWord) + + let amount := calldataload(add(amountsOffset, end)) + + if iszero(amount) { + mstore(0x00, OrderInvalid_error_selector) + revert(Error_selector_offset, OrderInvalid_error_length) + } + } + } + } +} diff --git a/contracts/src/marketplace/LooksRareProtocol.sol b/contracts/src/marketplace/LooksRareProtocol.sol new file mode 100644 index 00000000..b60e6e30 --- /dev/null +++ b/contracts/src/marketplace/LooksRareProtocol.sol @@ -0,0 +1,622 @@ +// SPDX-License-Identifier: MIT +pragma solidity 0.8.17; + +// LooksRare unopinionated libraries +import {SignatureCheckerCalldata} from "@looksrare/contracts-libs/contracts/SignatureCheckerCalldata.sol"; +import {LowLevelETHReturnETHIfAnyExceptOneWei} from + "@looksrare/contracts-libs/contracts/lowLevelCallers/LowLevelETHReturnETHIfAnyExceptOneWei.sol"; +import {LowLevelWETH} from "@looksrare/contracts-libs/contracts/lowLevelCallers/LowLevelWETH.sol"; +import {LowLevelERC20Transfer} from "@looksrare/contracts-libs/contracts/lowLevelCallers/LowLevelERC20Transfer.sol"; + +// OpenZeppelin's library (adjusted) for verifying Merkle proofs +import {MerkleProofCalldataWithNodes} from "./libraries/OpenZeppelin/MerkleProofCalldataWithNodes.sol"; + +// Libraries +import {OrderStructs} from "./libraries/OrderStructs.sol"; + +// Interfaces +import {ILooksRareProtocol} from "./interfaces/ILooksRareProtocol.sol"; + +// Shared errors +import { + CallerInvalid, + CurrencyInvalid, + LengthsInvalid, + MerkleProofInvalid, + MerkleProofTooLarge, + QuoteTypeInvalid +} from "./errors/SharedErrors.sol"; + +// Direct dependencies +import {TransferSelectorNFT} from "./TransferSelectorNFT.sol"; +import {BatchOrderTypehashRegistry} from "./BatchOrderTypehashRegistry.sol"; + +// Constants +import {MAX_CALLDATA_PROOF_LENGTH, ONE_HUNDRED_PERCENT_IN_BP} from "./constants/NumericConstants.sol"; + +// Enums +import {QuoteType} from "./enums/QuoteType.sol"; + +/** + * @title LooksRareProtocol + * @notice This contract is the core smart contract of the LooksRare protocol ("v2"). + * It is the main entry point for users to initiate transactions with taker orders + * and manage the cancellation of maker orders, which exist off-chain. + * ~~~~~~ + * ~~~~ ~~~~ + * ~~~ ~~~ + * ~~~ ~~~ + * ~~~ ~~~ + * ~~~~~~~~~ ~~~ ~~~ ~~~~~~~~~ + * ~~~ ~~~~~~~~~ ~~~~ ~~~~ ~~~~~~~~~ ~~~ + * ~~~ ~~~~~~~ ~~~~~~~ ~~~ + * ~~~- ~~~~~~~~ ~~~~ + * ~~~ ~~~~ ~~~~ ~~~ + * ~~~ ~~~~~~~~~~~~ ~~~~~~~~~~~~ ~~~ + * ~~~ ~~~~~~~~~~~ ~~~~~~~~~~~ ~~~ + * ~~~ ~~~ ~~~ ~~~ + * ~~~ ~~~ ~~~~~~~~~~ ~~~ ~~~ + * ~~~~~ ~~~ ~~~~~~ ~~~~~~ ~~~ ~~~~~ + * ~~~~~~~ ~~~ ~~~ ~~~ ~~~ ~~~~~~~ + * ~~~~~~ ~~~~ ~~~ ~~~ ~~~~ ~~~~~~ + * ~~~~ ~~~ ~~~ ~~~ ~~~ ~~~~ + * ~~~ ~~~ ~~~ ~~~ ~~~ ~~~ + * ~~~~ ~~~ ~~~ ~~~ ~~~ ~~~~ + * ~~~~~~ ~~~~ ~~~ ~~~ ~~~~~ ~~~~~~ + * ~~~~~~~ ~~~ ~~~ ~~~ ~~~ ~~~~~~~ + * ~~~~~ ~~~ ~~~~~~ ~~~~~~ ~~~ ~~~~~ + * ~~~ ~~~ ~~~~~~~~~~ ~~~ ~~~ + * ~~ ~~~ ~~~ ~~~ + * ~~~ ~~~~~~~~~~~ ~~~~~~~~~~~ ~~~ + * ~~~ ~~~~~~~~~~~~ ~~~~~~~~~~~~ ~~~ + * ~~~ ~~~~ ~~~~ ~~~ + * ~~~~ ~~~~~~~~ ~~~~ + * ~~~ ~~~~~~~ ~~~~~~~ ~~~ + * ~~~ ~~~~~~~~ ~~~~ ~~~~ ~~~~~~~~ ~~~ + * ~~~~~~~~~ ~~~ ~~~ ~~~~~~~~~ + * ~~~ ~~~ + * ~~~ ~~~ + * ~~~ ~~~ + * ~~~~ ~~~~ + * ~~~~~~ + * @author LooksRare protocol team (👀,💎) + */ +contract LooksRareProtocol is + ILooksRareProtocol, + TransferSelectorNFT, + LowLevelETHReturnETHIfAnyExceptOneWei, + LowLevelWETH, + LowLevelERC20Transfer, + BatchOrderTypehashRegistry +{ + using OrderStructs for OrderStructs.Maker; + + /** + * @notice Wrapped ETH. + */ + address public immutable WETH; + + /** + * @notice Current chainId. + */ + uint256 public chainId; + + /** + * @notice Current domain separator. + */ + bytes32 public domainSeparator; + + /** + * @notice This variable is used as the gas limit for a ETH transfer. + * If a standard ETH transfer fails within this gas limit, ETH will get wrapped to WETH + * and transferred to the initial recipient. + */ + uint256 private _gasLimitETHTransfer = 2300; + + /** + * @notice Constructor + * @param _owner Owner address + * @param _protocolFeeRecipient Protocol fee recipient address + * @param _transferManager Transfer manager address + * @param _weth Wrapped ETH address + */ + constructor(address _owner, address _protocolFeeRecipient, address _transferManager, address _weth) + TransferSelectorNFT(_owner, _protocolFeeRecipient, _transferManager) + { + _updateDomainSeparator(); + WETH = _weth; + } + + /** + * @inheritdoc ILooksRareProtocol + */ + function executeTakerAsk( + OrderStructs.Taker calldata takerAsk, + OrderStructs.Maker calldata makerBid, + bytes calldata makerSignature, + OrderStructs.MerkleTree calldata merkleTree + ) external nonReentrant { + address currency = makerBid.currency; + + // Verify whether the currency is allowed and is not ETH (address(0)) + if (!isCurrencyAllowed[currency] || currency == address(0)) { + revert CurrencyInvalid(); + } + + address signer = makerBid.signer; + bytes32 orderHash = makerBid.hash(); + _verifyMerkleProofOrOrderHash(merkleTree, orderHash, makerSignature, signer); + + // Execute the transaction and fetch protocol fee amount + uint256 totalProtocolFeeAmount = _executeTakerAsk(takerAsk, makerBid, orderHash); + + // Pay protocol fee (and affiliate fee if any) + _payProtocolFeeAndAffiliateFee(currency, signer, totalProtocolFeeAmount); + } + + /** + * @inheritdoc ILooksRareProtocol + */ + function executeTakerBid( + OrderStructs.Taker calldata takerBid, + OrderStructs.Maker calldata makerAsk, + bytes calldata makerSignature, + OrderStructs.MerkleTree calldata merkleTree + ) external payable nonReentrant { + address currency = makerAsk.currency; + + // Verify whether the currency is allowed for trading. + if (!isCurrencyAllowed[currency]) { + revert CurrencyInvalid(); + } + + bytes32 orderHash = makerAsk.hash(); + _verifyMerkleProofOrOrderHash(merkleTree, orderHash, makerSignature, makerAsk.signer); + + // Execute the transaction and fetch protocol fee amount + uint256 totalProtocolFeeAmount = _executeTakerBid(takerBid, makerAsk, msg.sender, orderHash); + + // Pay protocol fee amount + _payProtocolFeeAndAffiliateFee(currency, msg.sender, totalProtocolFeeAmount); + + // Return ETH if any + _returnETHIfAnyWithOneWeiLeft(); + } + + /** + * @inheritdoc ILooksRareProtocol + */ + function executeMultipleTakerBids( + OrderStructs.Taker[] calldata takerBids, + OrderStructs.Maker[] calldata makerAsks, + bytes[] calldata makerSignatures, + OrderStructs.MerkleTree[] calldata merkleTrees, + bool isAtomic + ) external payable nonReentrant { + uint256 length = takerBids.length; + if ( + length == 0 + || (makerAsks.length ^ length) | (makerSignatures.length ^ length) | (merkleTrees.length ^ length) != 0 + ) { + revert LengthsInvalid(); + } + + // Verify whether the currency at index = 0 is allowed for trading + address currency = makerAsks[0].currency; + if (!isCurrencyAllowed[currency]) { + revert CurrencyInvalid(); + } + + { + // Initialize protocol fee amount + uint256 totalProtocolFeeAmount; + + // If atomic, it uses the executeTakerBid function. + // If not atomic, it uses a catch/revert pattern with external function. + if (isAtomic) { + for (uint256 i; i < length;) { + OrderStructs.Maker calldata makerAsk = makerAsks[i]; + + // Verify the currency is the same + if (i != 0) { + if (makerAsk.currency != currency) { + revert CurrencyInvalid(); + } + } + + OrderStructs.Taker calldata takerBid = takerBids[i]; + bytes32 orderHash = makerAsk.hash(); + + { + _verifyMerkleProofOrOrderHash(merkleTrees[i], orderHash, makerSignatures[i], makerAsk.signer); + + // Execute the transaction and add protocol fee + totalProtocolFeeAmount += _executeTakerBid(takerBid, makerAsk, msg.sender, orderHash); + + unchecked { + ++i; + } + } + } + } else { + for (uint256 i; i < length;) { + OrderStructs.Maker calldata makerAsk = makerAsks[i]; + + // Verify the currency is the same + if (i != 0) { + if (makerAsk.currency != currency) { + revert CurrencyInvalid(); + } + } + + OrderStructs.Taker calldata takerBid = takerBids[i]; + bytes32 orderHash = makerAsk.hash(); + + { + _verifyMerkleProofOrOrderHash(merkleTrees[i], orderHash, makerSignatures[i], makerAsk.signer); + + try this.restrictedExecuteTakerBid(takerBid, makerAsk, msg.sender, orderHash) returns ( + uint256 protocolFeeAmount + ) { + totalProtocolFeeAmount += protocolFeeAmount; + } catch {} + + unchecked { + ++i; + } + } + } + } + + // Pay protocol fee (and affiliate fee if any) + _payProtocolFeeAndAffiliateFee(currency, msg.sender, totalProtocolFeeAmount); + } + + // Return ETH if any + _returnETHIfAnyWithOneWeiLeft(); + } + + /** + * @notice This function is used to do a non-atomic matching in the context of a batch taker bid. + * @param takerBid Taker bid struct + * @param makerAsk Maker ask struct + * @param sender Sender address (i.e. the initial msg sender) + * @param orderHash Hash of the maker ask order + * @return protocolFeeAmount Protocol fee amount + * @dev This function is only callable by this contract. It is used for non-atomic batch order matching. + */ + function restrictedExecuteTakerBid( + OrderStructs.Taker calldata takerBid, + OrderStructs.Maker calldata makerAsk, + address sender, + bytes32 orderHash + ) external returns (uint256 protocolFeeAmount) { + if (msg.sender != address(this)) { + revert CallerInvalid(); + } + + protocolFeeAmount = _executeTakerBid(takerBid, makerAsk, sender, orderHash); + } + + /** + * @notice This function allows the owner to update the domain separator (if possible). + * @dev Only callable by owner. If there is a fork of the network with a new chainId, + * it allows the owner to reset the domain separator for the new chain id. + */ + function updateDomainSeparator() external onlyOwner { + if (block.chainid != chainId) { + _updateDomainSeparator(); + emit NewDomainSeparator(); + } else { + revert SameDomainSeparator(); + } + } + + /** + * @notice This function allows the owner to update the maximum ETH gas limit for a standard transfer. + * @param newGasLimitETHTransfer New gas limit for ETH transfer + * @dev Only callable by owner. + */ + function updateETHGasLimitForTransfer(uint256 newGasLimitETHTransfer) external onlyOwner { + if (newGasLimitETHTransfer < 2300) { + revert NewGasLimitETHTransferTooLow(); + } + + _gasLimitETHTransfer = newGasLimitETHTransfer; + + emit NewGasLimitETHTransfer(newGasLimitETHTransfer); + } + + /** + * @notice This function is internal and is used to execute a taker ask (against a maker bid). + * @param takerAsk Taker ask order struct + * @param makerBid Maker bid order struct + * @param orderHash Hash of the maker bid order + * @return protocolFeeAmount Protocol fee amount + */ + function _executeTakerAsk( + OrderStructs.Taker calldata takerAsk, + OrderStructs.Maker calldata makerBid, + bytes32 orderHash + ) internal returns (uint256) { + if (makerBid.quoteType != QuoteType.Bid) { + revert QuoteTypeInvalid(); + } + + address signer = makerBid.signer; + { + bytes32 userOrderNonceStatus = userOrderNonce[signer][makerBid.orderNonce]; + // Verify nonces + if ( + userBidAskNonces[signer].bidNonce != makerBid.globalNonce + || userSubsetNonce[signer][makerBid.subsetNonce] + || (userOrderNonceStatus != bytes32(0) && userOrderNonceStatus != orderHash) + ) { + revert NoncesInvalid(); + } + } + + ( + uint256[] memory itemIds, + uint256[] memory amounts, + address[2] memory recipients, + uint256[3] memory feeAmounts, + bool isNonceInvalidated + ) = _executeStrategyForTakerOrder(takerAsk, makerBid, msg.sender); + + // Order nonce status is updated + _updateUserOrderNonce(isNonceInvalidated, signer, makerBid.orderNonce, orderHash); + + // Taker action goes first + _transferNFT(makerBid.collection, makerBid.collectionType, msg.sender, signer, itemIds, amounts); + + // Maker action goes second + _transferToAskRecipientAndCreatorIfAny(recipients, feeAmounts, makerBid.currency, signer); + + emit TakerAsk( + NonceInvalidationParameters({ + orderHash: orderHash, + orderNonce: makerBid.orderNonce, + isNonceInvalidated: isNonceInvalidated + }), + msg.sender, + signer, + makerBid.strategyId, + makerBid.currency, + makerBid.collection, + itemIds, + amounts, + recipients, + feeAmounts + ); + + // It returns the protocol fee amount + return feeAmounts[2]; + } + + /** + * @notice This function is internal and is used to execute a taker bid (against a maker ask). + * @param takerBid Taker bid order struct + * @param makerAsk Maker ask order struct + * @param sender Sender of the transaction (i.e. msg.sender) + * @param orderHash Hash of the maker ask order + * @return protocolFeeAmount Protocol fee amount + */ + function _executeTakerBid( + OrderStructs.Taker calldata takerBid, + OrderStructs.Maker calldata makerAsk, + address sender, + bytes32 orderHash + ) internal returns (uint256) { + if (makerAsk.quoteType != QuoteType.Ask) { + revert QuoteTypeInvalid(); + } + + address signer = makerAsk.signer; + { + // Verify nonces + bytes32 userOrderNonceStatus = userOrderNonce[signer][makerAsk.orderNonce]; + + if ( + userBidAskNonces[signer].askNonce != makerAsk.globalNonce + || userSubsetNonce[signer][makerAsk.subsetNonce] + || (userOrderNonceStatus != bytes32(0) && userOrderNonceStatus != orderHash) + ) { + revert NoncesInvalid(); + } + } + + ( + uint256[] memory itemIds, + uint256[] memory amounts, + address[2] memory recipients, + uint256[3] memory feeAmounts, + bool isNonceInvalidated + ) = _executeStrategyForTakerOrder(takerBid, makerAsk, msg.sender); + + // Order nonce status is updated + _updateUserOrderNonce(isNonceInvalidated, signer, makerAsk.orderNonce, orderHash); + + // Taker action goes first + _transferToAskRecipientAndCreatorIfAny(recipients, feeAmounts, makerAsk.currency, sender); + + // Maker action goes second + _transferNFT( + makerAsk.collection, + makerAsk.collectionType, + signer, + takerBid.recipient == address(0) ? sender : takerBid.recipient, + itemIds, + amounts + ); + + emit TakerBid( + NonceInvalidationParameters({ + orderHash: orderHash, + orderNonce: makerAsk.orderNonce, + isNonceInvalidated: isNonceInvalidated + }), + sender, + takerBid.recipient == address(0) ? sender : takerBid.recipient, + makerAsk.strategyId, + makerAsk.currency, + makerAsk.collection, + itemIds, + amounts, + recipients, + feeAmounts + ); + + // It returns the protocol fee amount + return feeAmounts[2]; + } + + /** + * @notice This function is internal and is used to pay the protocol fee and affiliate fee (if any). + * @param currency Currency address to transfer (address(0) is ETH) + * @param bidUser Bid user address + * @param totalProtocolFeeAmount Total protocol fee amount (denominated in the currency) + */ + function _payProtocolFeeAndAffiliateFee(address currency, address bidUser, uint256 totalProtocolFeeAmount) + internal + { + if (totalProtocolFeeAmount != 0) { + // Transfer remaining protocol fee to the protocol fee recipient + _transferFungibleTokens(currency, bidUser, protocolFeeRecipient, totalProtocolFeeAmount); + } + } + + /** + * @notice This function is internal and is used to transfer fungible tokens. + * @param currency Currency address + * @param sender Sender address + * @param recipient Recipient address + * @param amount Amount (in fungible tokens) + */ + function _transferFungibleTokens(address currency, address sender, address recipient, uint256 amount) internal { + if (currency == address(0)) { + _transferETHAndWrapIfFailWithGasLimit(WETH, recipient, amount, _gasLimitETHTransfer); + } else { + _executeERC20TransferFrom(currency, sender, recipient, amount); + } + } + + /** + * @notice This function is private and used to transfer funds to + * (1) creator recipient (if any) + * (2) ask recipient. + * @param recipients Recipient addresses + * @param feeAmounts Fees + * @param currency Currency address + * @param bidUser Bid user address + * @dev It does not send to the 0-th element in the array since it is the protocol fee, + * which is paid later in the execution flow. + */ + function _transferToAskRecipientAndCreatorIfAny( + address[2] memory recipients, + uint256[3] memory feeAmounts, + address currency, + address bidUser + ) private { + // @dev There is no check for address(0) since the ask recipient can never be address(0) + // If ask recipient is the maker --> the signer cannot be the null address + // If ask is the taker --> either it is the sender address or + // if the recipient (in TakerAsk) is set to address(0), it is adjusted to the original taker address + uint256 sellerProceed = feeAmounts[0]; + if (sellerProceed != 0) { + _transferFungibleTokens(currency, bidUser, recipients[0], sellerProceed); + } + + // @dev There is no check for address(0), if the creator recipient is address(0), the fee is set to 0 + uint256 creatorFeeAmount = feeAmounts[1]; + if (creatorFeeAmount != 0) { + _transferFungibleTokens(currency, bidUser, recipients[1], creatorFeeAmount); + } + } + + /** + * @notice This function is private and used to compute the domain separator and store the current chain id. + */ + function _updateDomainSeparator() private { + domainSeparator = keccak256( + abi.encode( + keccak256("EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)"), + keccak256("LooksRareProtocol"), + keccak256(bytes("2")), + block.chainid, + address(this) + ) + ); + chainId = block.chainid; + } + + /** + * @notice This function is internal and is called during the execution of a transaction to decide + * how to map the user's order nonce. + * @param isNonceInvalidated Whether the nonce is being invalidated + * @param signer Signer address + * @param orderNonce Maker user order nonce + * @param orderHash Hash of the order struct + * @dev If isNonceInvalidated is true, this function invalidates the user order nonce for future execution. + * If it is equal to false, this function maps the order hash for this user order nonce + * to prevent other order structs sharing the same order nonce to be executed. + */ + function _updateUserOrderNonce(bool isNonceInvalidated, address signer, uint256 orderNonce, bytes32 orderHash) + private + { + userOrderNonce[signer][orderNonce] = (isNonceInvalidated ? MAGIC_VALUE_ORDER_NONCE_EXECUTED : orderHash); + } + + /** + * @notice This function is private and used to verify the chain id, compute the digest, and verify the signature. + * @dev If chainId is not equal to the cached chain id, it would revert. + * @param computedHash Hash of order (maker bid or maker ask) or merkle root + * @param makerSignature Signature of the maker + * @param signer Signer address + */ + function _computeDigestAndVerify(bytes32 computedHash, bytes calldata makerSignature, address signer) + private + view + { + if (chainId == block.chainid) { + // \x19\x01 is the standard encoding prefix + SignatureCheckerCalldata.verify( + keccak256(abi.encodePacked("\x19\x01", domainSeparator, computedHash)), signer, makerSignature + ); + } else { + revert ChainIdInvalid(); + } + } + + /** + * @notice This function is private and called to verify whether the merkle proofs provided for the order hash + * are correct or verify the order hash if the order is not part of a merkle tree. + * @param merkleTree Merkle tree + * @param orderHash Order hash (can be maker bid hash or maker ask hash) + * @param signature Maker order signature + * @param signer Maker address + * @dev It verifies (1) merkle proof (if necessary) (2) signature is from the expected signer + */ + function _verifyMerkleProofOrOrderHash( + OrderStructs.MerkleTree calldata merkleTree, + bytes32 orderHash, + bytes calldata signature, + address signer + ) private view { + uint256 proofLength = merkleTree.proof.length; + + if (proofLength != 0) { + if (proofLength > MAX_CALLDATA_PROOF_LENGTH) { + revert MerkleProofTooLarge(proofLength); + } + + if (!MerkleProofCalldataWithNodes.verifyCalldata(merkleTree.proof, merkleTree.root, orderHash)) { + revert MerkleProofInvalid(); + } + + orderHash = hashBatchOrder(merkleTree.root, proofLength); + } + + _computeDigestAndVerify(orderHash, signature, signer); + } +} diff --git a/contracts/src/marketplace/NonceManager.sol b/contracts/src/marketplace/NonceManager.sol new file mode 100644 index 00000000..d9a94cfc --- /dev/null +++ b/contracts/src/marketplace/NonceManager.sol @@ -0,0 +1,115 @@ +// SPDX-License-Identifier: MIT +pragma solidity 0.8.17; + +// Interfaces and errors +import {INonceManager} from "./interfaces/INonceManager.sol"; +import {LengthsInvalid} from "./errors/SharedErrors.sol"; + +/** + * @title NonceManager + * @notice This contract handles the nonce logic that is used for invalidating maker orders that exist off-chain. + * The nonce logic revolves around three parts at the user level: + * - order nonce (orders sharing an order nonce are conditional, OCO-like) + * - subset (orders can be grouped under a same subset) + * - bid/ask (all orders can be executed only if the bid/ask nonce matches the user's one on-chain) + * Only the order nonce is invalidated at the time of the execution of a maker order that contains it. + * @author LooksRare protocol team (👀,💎) + */ +contract NonceManager is INonceManager { + /** + * @notice Magic value nonce returned if executed (or cancelled). + */ + bytes32 public constant MAGIC_VALUE_ORDER_NONCE_EXECUTED = keccak256("ORDER_NONCE_EXECUTED"); + + /** + * @notice This tracks the bid and ask nonces for a user address. + */ + mapping(address => UserBidAskNonces) public userBidAskNonces; + + /** + * @notice This checks whether the order nonce for a user was executed or cancelled. + */ + mapping(address => mapping(uint256 => bytes32)) public userOrderNonce; + + /** + * @notice This checks whether the subset nonce for a user was cancelled. + */ + mapping(address => mapping(uint256 => bool)) public userSubsetNonce; + + /** + * @notice This function allows a user to cancel an array of order nonces. + * @param orderNonces Array of order nonces + * @dev It does not check the status of the nonces to save gas + * and to prevent revertion if one of the orders is filled in the same + * block. + */ + function cancelOrderNonces(uint256[] calldata orderNonces) external { + uint256 length = orderNonces.length; + if (length == 0) { + revert LengthsInvalid(); + } + + for (uint256 i; i < length;) { + userOrderNonce[msg.sender][orderNonces[i]] = MAGIC_VALUE_ORDER_NONCE_EXECUTED; + unchecked { + ++i; + } + } + + emit OrderNoncesCancelled(msg.sender, orderNonces); + } + + /** + * @notice This function allows a user to cancel an array of subset nonces. + * @param subsetNonces Array of subset nonces + * @dev It does not check the status of the nonces to save gas. + */ + function cancelSubsetNonces(uint256[] calldata subsetNonces) external { + uint256 length = subsetNonces.length; + + if (length == 0) { + revert LengthsInvalid(); + } + + for (uint256 i; i < length;) { + userSubsetNonce[msg.sender][subsetNonces[i]] = true; + unchecked { + ++i; + } + } + + emit SubsetNoncesCancelled(msg.sender, subsetNonces); + } + + /** + * @notice This function increments a user's bid/ask nonces. + * @param bid Whether to increment the user bid nonce + * @param ask Whether to increment the user ask nonce + * @dev The logic for computing the quasi-random number is inspired by Seaport v1.2. + * The pseudo-randomness allows non-deterministic computation of the next ask/bid nonce. + * A deterministic increment would make the cancel-all process non-effective in certain cases + * (orders signed with a greater ask/bid nonce). + * The same quasi-random number is used for incrementing both the bid and ask nonces if both values + * are incremented in the same transaction. + * If this function is used twice in the same block, it will return the same quasiRandomNumber + * but this will not impact the overall business logic. + */ + function incrementBidAskNonces(bool bid, bool ask) external { + // Use second half of the previous block hash as a quasi-random number + uint256 quasiRandomNumber = uint256(blockhash(block.number - 1) >> 128); + uint256 newBidNonce = userBidAskNonces[msg.sender].bidNonce; + uint256 newAskNonce = userBidAskNonces[msg.sender].askNonce; + + if (bid) { + newBidNonce += quasiRandomNumber; + userBidAskNonces[msg.sender].bidNonce = newBidNonce; + } + + if (ask) { + newAskNonce += quasiRandomNumber; + userBidAskNonces[msg.sender].askNonce = newAskNonce; + } + + emit NewBidAskNonces(msg.sender, newBidNonce, newAskNonce); + } +} diff --git a/contracts/src/marketplace/ProtocolFeeRecipient.sol b/contracts/src/marketplace/ProtocolFeeRecipient.sol new file mode 100644 index 00000000..4eb12174 --- /dev/null +++ b/contracts/src/marketplace/ProtocolFeeRecipient.sol @@ -0,0 +1,54 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.17; + +// LooksRare unopinionated libraries +import {LowLevelERC20Transfer} from "@looksrare/contracts-libs/contracts/lowLevelCallers/LowLevelERC20Transfer.sol"; +import {IWETH} from "@looksrare/contracts-libs/contracts/interfaces/generic/IWETH.sol"; +import {IERC20} from "@looksrare/contracts-libs/contracts/interfaces/generic/IERC20.sol"; + +/** + * @title ProtocolFeeRecipient + * @notice This contract is used to receive protocol fees and transfer them to the fee sharing setter. + * Fee sharing setter cannot receive ETH directly, so we need to use this contract as a middleman + * to convert ETH into WETH before sending it. + * @author LooksRare protocol team (👀,💎) + */ +contract ProtocolFeeRecipient is LowLevelERC20Transfer { + address public immutable FEE_SHARING_SETTER; + IWETH public immutable WETH; + + error NothingToTransfer(); + + constructor(address _feeSharingSetter, address _weth) { + FEE_SHARING_SETTER = _feeSharingSetter; + WETH = IWETH(_weth); + } + + function transferETH() external { + uint256 ethBalance = address(this).balance; + + if (ethBalance != 0) { + WETH.deposit{value: ethBalance}(); + } + + uint256 wethBalance = IERC20(address(WETH)).balanceOf(address(this)); + + if (wethBalance == 0) { + revert NothingToTransfer(); + } + _executeERC20DirectTransfer(address(WETH), FEE_SHARING_SETTER, wethBalance); + } + + /** + * @param currency ERC20 currency address + */ + function transferERC20(address currency) external { + uint256 balance = IERC20(currency).balanceOf(address(this)); + if (balance == 0) { + revert NothingToTransfer(); + } + _executeERC20DirectTransfer(currency, FEE_SHARING_SETTER, balance); + } + + receive() external payable {} +} diff --git a/contracts/src/marketplace/StrategyManager.sol b/contracts/src/marketplace/StrategyManager.sol new file mode 100644 index 00000000..4edb9d66 --- /dev/null +++ b/contracts/src/marketplace/StrategyManager.sol @@ -0,0 +1,124 @@ +// SPDX-License-Identifier: MIT +pragma solidity 0.8.17; + +// LooksRare unopinionated libraries +import {CurrencyManager} from "./CurrencyManager.sol"; + +// Interfaces +import {IStrategy} from "./interfaces/IStrategy.sol"; +import {IStrategyManager} from "./interfaces/IStrategyManager.sol"; + +/** + * @title StrategyManager + * @notice This contract handles the addition and the update of execution strategies. + * @author LooksRare protocol team (👀,💎) + */ +contract StrategyManager is IStrategyManager, CurrencyManager { + /** + * @notice This variable keeps the count of how many strategies exist. + * It includes strategies that have been removed. + */ + uint256 private _countStrategies = 1; + + /** + * @notice This returns the strategy information for a strategy id. + */ + mapping(uint256 => Strategy) public strategyInfo; + + /** + * @notice Constructor + * @param _owner Owner address + */ + constructor(address _owner) CurrencyManager(_owner) { + strategyInfo[0] = Strategy({ + isActive: true, + standardProtocolFeeBp: 50, + minTotalFeeBp: 50, + maxProtocolFeeBp: 200, + selector: bytes4(0), + isMakerBid: false, + implementation: address(0) + }); + + emit NewStrategy(0, 50, 50, 200, bytes4(0), false, address(0)); + } + + /** + * @notice This function allows the owner to add a new execution strategy to the protocol. + * @param standardProtocolFeeBp Standard protocol fee (in basis point) + * @param minTotalFeeBp Minimum total fee (in basis point) + * @param maxProtocolFeeBp Maximum protocol fee (in basis point) + * @param selector Function selector for the strategy + * @param isMakerBid Whether the function selector is for maker bid + * @param implementation Implementation address + * @dev Strategies have an id that is incremental. + * Only callable by owner. + */ + function addStrategy( + uint16 standardProtocolFeeBp, + uint16 minTotalFeeBp, + uint16 maxProtocolFeeBp, + bytes4 selector, + bool isMakerBid, + address implementation + ) external onlyOwner { + if (minTotalFeeBp > maxProtocolFeeBp || standardProtocolFeeBp > minTotalFeeBp || maxProtocolFeeBp > 500) { + revert StrategyProtocolFeeTooHigh(); + } + + if (selector == bytes4(0)) { + revert StrategyHasNoSelector(); + } + + if (!IStrategy(implementation).isLooksRareV2Strategy()) { + revert NotV2Strategy(); + } + + strategyInfo[_countStrategies] = Strategy({ + isActive: true, + standardProtocolFeeBp: standardProtocolFeeBp, + minTotalFeeBp: minTotalFeeBp, + maxProtocolFeeBp: maxProtocolFeeBp, + selector: selector, + isMakerBid: isMakerBid, + implementation: implementation + }); + + emit NewStrategy( + _countStrategies++, + standardProtocolFeeBp, + minTotalFeeBp, + maxProtocolFeeBp, + selector, + isMakerBid, + implementation + ); + } + + /** + * @notice This function allows the owner to update parameters for an existing execution strategy. + * @param strategyId Strategy id + * @param isActive Whether the strategy must be active + * @param newStandardProtocolFee New standard protocol fee (in basis point) + * @param newMinTotalFee New minimum total fee (in basis point) + * @dev Only callable by owner. + */ + function updateStrategy(uint256 strategyId, bool isActive, uint16 newStandardProtocolFee, uint16 newMinTotalFee) + external + onlyOwner + { + if (strategyId >= _countStrategies) { + revert StrategyNotUsed(); + } + + if (newMinTotalFee > strategyInfo[strategyId].maxProtocolFeeBp || newStandardProtocolFee > newMinTotalFee) { + revert StrategyProtocolFeeTooHigh(); + } + + strategyInfo[strategyId].isActive = isActive; + strategyInfo[strategyId].standardProtocolFeeBp = newStandardProtocolFee; + strategyInfo[strategyId].minTotalFeeBp = newMinTotalFee; + + emit StrategyUpdated(strategyId, isActive, newStandardProtocolFee, newMinTotalFee); + } +} diff --git a/contracts/src/marketplace/TransferManager.sol b/contracts/src/marketplace/TransferManager.sol new file mode 100644 index 00000000..cc1c9578 --- /dev/null +++ b/contracts/src/marketplace/TransferManager.sol @@ -0,0 +1,375 @@ +// SPDX-License-Identifier: MIT +pragma solidity 0.8.17; + +// LooksRare unopinionated libraries +import {OwnableTwoSteps} from "@looksrare/contracts-libs/contracts/OwnableTwoSteps.sol"; +import {LowLevelERC721Transfer} from "@looksrare/contracts-libs/contracts/lowLevelCallers/LowLevelERC721Transfer.sol"; +import {LowLevelERC1155Transfer} from "@looksrare/contracts-libs/contracts/lowLevelCallers/LowLevelERC1155Transfer.sol"; + +// Interfaces and errors +import {ITransferManager} from "./interfaces/ITransferManager.sol"; +import {AmountInvalid, LengthsInvalid} from "./errors/SharedErrors.sol"; + +// Libraries +import {OrderStructs} from "./libraries/OrderStructs.sol"; + +// Enums +import {CollectionType} from "./enums/CollectionType.sol"; + +/** + * @title TransferManager + * @notice This contract provides the transfer functions for ERC721/ERC1155/Hypercert/Hyperboard for contracts that + * require them. + * Collection type "0" refers to ERC721 transfer functions. + * Collection type "1" refers to ERC1155 transfer functions. + * Collection type "2" refers to Hypercert transfer functions. + * Collection type "3" refers to Hyperboard transfer functions. + * @dev "Safe" transfer functions for ERC721 are not implemented since they come with added gas costs + * to verify if the recipient is a contract as it requires verifying the receiver interface is valid. + * @author LooksRare protocol team (👀,💎) + */ +// TODO Needs to be updated to split a fraction and transfer the new fraction to the bidder +contract TransferManager is ITransferManager, LowLevelERC721Transfer, LowLevelERC1155Transfer, OwnableTwoSteps { + /** + * @notice This returns whether the user has approved the operator address. + * The first address is the user and the second address is the operator (e.g. LooksRareProtocol). + */ + mapping(address => mapping(address => bool)) public hasUserApprovedOperator; + + /** + * @notice This returns whether the operator address is allowed by this contract's owner. + */ + mapping(address => bool) public isOperatorAllowed; + + /** + * @notice Constructor + * @param _owner Owner address + */ + constructor(address _owner) OwnableTwoSteps(_owner) {} + + /** + * @notice This function transfers items for a single ERC721 collection. + * @param collection Collection address + * @param from Sender address + * @param to Recipient address + * @param itemIds Array of itemIds + * @param amounts Array of amounts + */ + function transferItemsERC721( + address collection, + address from, + address to, + uint256[] calldata itemIds, + uint256[] calldata amounts + ) external { + uint256 length = itemIds.length; + if (length == 0) { + revert LengthsInvalid(); + } + + _isOperatorValidForTransfer(from, msg.sender); + + for (uint256 i; i < length;) { + if (amounts[i] != 1) { + revert AmountInvalid(); + } + _executeERC721TransferFrom(collection, from, to, itemIds[i]); + unchecked { + ++i; + } + } + } + + /** + * @notice This function transfers items for a single ERC1155 collection. + * @param collection Collection address + * @param from Sender address + * @param to Recipient address + * @param itemIds Array of itemIds + * @param amounts Array of amounts + * @dev It does not allow batch transferring if from = msg.sender since native function should be used. + */ + function transferItemsERC1155( + address collection, + address from, + address to, + uint256[] calldata itemIds, + uint256[] calldata amounts + ) external { + uint256 length = itemIds.length; + + if (length == 0 || amounts.length != length) { + revert LengthsInvalid(); + } + + _isOperatorValidForTransfer(from, msg.sender); + + if (length == 1) { + if (amounts[0] == 0) { + revert AmountInvalid(); + } + _executeERC1155SafeTransferFrom(collection, from, to, itemIds[0], amounts[0]); + } else { + for (uint256 i; i < length;) { + if (amounts[i] == 0) { + revert AmountInvalid(); + } + + unchecked { + ++i; + } + } + _executeERC1155SafeBatchTransferFrom(collection, from, to, itemIds, amounts); + } + } + + /** + * @notice This function transfers items for a single Hypercert. + * @param collection Collection address + * @param from Sender address + * @param to Recipient address + * @param itemIds Array of itemIds + * @param amounts Array of amounts + * @dev It does not allow batch transferring if from = msg.sender since native function should be used. + */ + function transferItemsHypercert( + address collection, + address from, + address to, + uint256[] calldata itemIds, + uint256[] calldata amounts + ) external { + uint256 length = itemIds.length; + + if (length == 0 || amounts.length != length) { + revert LengthsInvalid(); + } + + _isOperatorValidForTransfer(from, msg.sender); + + if (length == 1) { + if (amounts[0] == 0) { + revert AmountInvalid(); + } + _executeERC1155SafeTransferFrom(collection, from, to, itemIds[0], amounts[0]); + } else { + for (uint256 i; i < length;) { + if (amounts[i] == 0) { + revert AmountInvalid(); + } + + unchecked { + ++i; + } + } + _executeERC1155SafeBatchTransferFrom(collection, from, to, itemIds, amounts); + } + } + + /** + * @notice This function transfers items for a single Hyperboard. + * @param collection Collection address + * @param from Sender address + * @param to Recipient address + * @param itemIds Array of itemIds + * @param amounts Array of amounts + * @dev It does not allow batch transferring if from = msg.sender since native function should be used. + */ + function transferItemsHyperboard( + address collection, + address from, + address to, + uint256[] calldata itemIds, + uint256[] calldata amounts + ) external { + uint256 length = itemIds.length; + + if (length == 0 || amounts.length != length) { + revert LengthsInvalid(); + } + + _isOperatorValidForTransfer(from, msg.sender); + + if (length == 1) { + if (amounts[0] == 0) { + revert AmountInvalid(); + } + _executeERC1155SafeTransferFrom(collection, from, to, itemIds[0], amounts[0]); + } else { + for (uint256 i; i < length;) { + if (amounts[i] == 0) { + revert AmountInvalid(); + } + + unchecked { + ++i; + } + } + _executeERC1155SafeBatchTransferFrom(collection, from, to, itemIds, amounts); + } + } + + /** + * @notice This function transfers items across an array of collections that can be both ERC721 and ERC1155. + * @param items Array of BatchTransferItem + * @param from Sender address + * @param to Recipient address + */ + function transferBatchItemsAcrossCollections(BatchTransferItem[] calldata items, address from, address to) + external + { + uint256 itemsLength = items.length; + + if (itemsLength == 0) { + revert LengthsInvalid(); + } + + if (from != msg.sender) { + _isOperatorValidForTransfer(from, msg.sender); + } + + for (uint256 i; i < itemsLength;) { + uint256[] calldata itemIds = items[i].itemIds; + uint256 itemIdsLengthForSingleCollection = itemIds.length; + uint256[] calldata amounts = items[i].amounts; + + if (itemIdsLengthForSingleCollection == 0 || amounts.length != itemIdsLengthForSingleCollection) { + revert LengthsInvalid(); + } + + CollectionType collectionType = items[i].collectionType; + if (collectionType == CollectionType.ERC721) { + for (uint256 j; j < itemIdsLengthForSingleCollection;) { + if (amounts[j] != 1) { + revert AmountInvalid(); + } + _executeERC721TransferFrom(items[i].collection, from, to, itemIds[j]); + unchecked { + ++j; + } + } + } else if (collectionType == CollectionType.ERC1155) { + for (uint256 j; j < itemIdsLengthForSingleCollection;) { + if (amounts[j] == 0) { + revert AmountInvalid(); + } + + unchecked { + ++j; + } + } + _executeERC1155SafeBatchTransferFrom(items[i].collection, from, to, itemIds, amounts); + } + + unchecked { + ++i; + } + } + } + + /** + * @notice This function allows a user to grant approvals for an array of operators. + * Users cannot grant approvals if the operator is not allowed by this contract's owner. + * @param operators Array of operator addresses + * @dev Each operator address must be globally allowed to be approved. + */ + function grantApprovals(address[] calldata operators) external { + uint256 length = operators.length; + + if (length == 0) { + revert LengthsInvalid(); + } + + for (uint256 i; i < length;) { + address operator = operators[i]; + + if (!isOperatorAllowed[operator]) { + revert OperatorNotAllowed(); + } + + if (hasUserApprovedOperator[msg.sender][operator]) { + revert OperatorAlreadyApprovedByUser(); + } + + hasUserApprovedOperator[msg.sender][operator] = true; + + unchecked { + ++i; + } + } + + emit ApprovalsGranted(msg.sender, operators); + } + + /** + * @notice This function allows a user to revoke existing approvals for an array of operators. + * @param operators Array of operator addresses + * @dev Each operator address must be approved at the user level to be revoked. + */ + function revokeApprovals(address[] calldata operators) external { + uint256 length = operators.length; + if (length == 0) { + revert LengthsInvalid(); + } + + for (uint256 i; i < length;) { + address operator = operators[i]; + + if (!hasUserApprovedOperator[msg.sender][operator]) { + revert OperatorNotApprovedByUser(); + } + + delete hasUserApprovedOperator[msg.sender][operator]; + unchecked { + ++i; + } + } + + emit ApprovalsRemoved(msg.sender, operators); + } + + /** + * @notice This function allows an operator to be added for the shared transfer system. + * Once the operator is allowed, users can grant NFT approvals to this operator. + * @param operator Operator address to allow + * @dev Only callable by owner. + */ + function allowOperator(address operator) external onlyOwner { + if (isOperatorAllowed[operator]) { + revert OperatorAlreadyAllowed(); + } + + isOperatorAllowed[operator] = true; + + emit OperatorAllowed(operator); + } + + /** + * @notice This function allows the user to remove an operator for the shared transfer system. + * @param operator Operator address to remove + * @dev Only callable by owner. + */ + function removeOperator(address operator) external onlyOwner { + if (!isOperatorAllowed[operator]) { + revert OperatorNotAllowed(); + } + + delete isOperatorAllowed[operator]; + + emit OperatorRemoved(operator); + } + + /** + * @notice This function is internal and verifies whether the transfer + * (by an operator on behalf of a user) is valid. If not, it reverts. + * @param user User address + * @param operator Operator address + */ + function _isOperatorValidForTransfer(address user, address operator) private view { + if (isOperatorAllowed[operator] && hasUserApprovedOperator[user][operator]) { + return; + } + + revert TransferCallerInvalid(); + } +} diff --git a/contracts/src/marketplace/TransferSelectorNFT.sol b/contracts/src/marketplace/TransferSelectorNFT.sol new file mode 100644 index 00000000..8b4d201c --- /dev/null +++ b/contracts/src/marketplace/TransferSelectorNFT.sol @@ -0,0 +1,67 @@ +// SPDX-License-Identifier: MIT +pragma solidity 0.8.17; + +// Direct dependencies +import {PackableReentrancyGuard} from "@looksrare/contracts-libs/contracts/PackableReentrancyGuard.sol"; +import {ExecutionManager} from "./ExecutionManager.sol"; +import {TransferManager} from "./TransferManager.sol"; + +// Libraries +import {OrderStructs} from "./libraries/OrderStructs.sol"; + +// Enums +import {CollectionType} from "./enums/CollectionType.sol"; + +/** + * @title TransferSelectorNFT + * @notice This contract handles the logic for transferring non-fungible items. + * @author LooksRare protocol team (👀,💎) + */ +contract TransferSelectorNFT is ExecutionManager, PackableReentrancyGuard { + error UnsupportedCollectionType(); + /** + * @notice Transfer manager for ERC721 and ERC1155. + */ + + TransferManager public immutable transferManager; + + /** + * @notice Constructor + * @param _owner Owner address + * @param _protocolFeeRecipient Protocol fee recipient address + * @param _transferManager Address of the transfer manager for ERC721/ERC1155 + */ + constructor(address _owner, address _protocolFeeRecipient, address _transferManager) + ExecutionManager(_owner, _protocolFeeRecipient) + { + transferManager = TransferManager(_transferManager); + } + + /** + * @notice This function is internal and used to transfer non-fungible tokens. + * @param collection Collection address + * @param collectionType Collection type (e.g. 0 = ERC721, 1 = ERC1155) + * @param sender Sender address + * @param recipient Recipient address + * @param itemIds Array of itemIds + * @param amounts Array of amounts + */ + function _transferNFT( + address collection, + CollectionType collectionType, + address sender, + address recipient, + uint256[] memory itemIds, + uint256[] memory amounts + ) internal { + if (collectionType == CollectionType.ERC721) { + transferManager.transferItemsERC721(collection, sender, recipient, itemIds, amounts); + } else if (collectionType == CollectionType.ERC1155) { + transferManager.transferItemsERC1155(collection, sender, recipient, itemIds, amounts); + } else if (collectionType == CollectionType.Hypercert) { + transferManager.transferItemsERC1155(collection, sender, recipient, itemIds, amounts); + } else if (collectionType == CollectionType.Hyperboard) { + revert UnsupportedCollectionType(); + } + } +} diff --git a/contracts/src/marketplace/constants/AssemblyConstants.sol b/contracts/src/marketplace/constants/AssemblyConstants.sol new file mode 100644 index 00000000..8557dece --- /dev/null +++ b/contracts/src/marketplace/constants/AssemblyConstants.sol @@ -0,0 +1,42 @@ +// SPDX-License-Identifier: MIT +pragma solidity 0.8.17; + +/* + * @dev error OrderInvalid() + * Memory layout: + * - 0x00: Left-padded selector (data begins at 0x1c) + * Revert buffer is memory[0x1c:0x20] + */ +uint256 constant OrderInvalid_error_selector = 0x2e0c0f71; +uint256 constant OrderInvalid_error_length = 0x04; + +/* + * @dev error CurrencyInvalid() + * Memory layout: + * - 0x00: Left-padded selector (data begins at 0x1c) + * Revert buffer is memory[0x1c:0x20] + */ +uint256 constant CurrencyInvalid_error_selector = 0x4f795487; +uint256 constant CurrencyInvalid_error_length = 0x04; + +/* + * @dev error OutsideOfTimeRange() + * Memory layout: + * - 0x00: Left-padded selector (data begins at 0x1c) + * Revert buffer is memory[0x1c:0x20] + */ +uint256 constant OutsideOfTimeRange_error_selector = 0x7476320f; +uint256 constant OutsideOfTimeRange_error_length = 0x04; + +/* + * @dev error NoSelectorForStrategy() + * Memory layout: + * - 0x00: Left-padded selector (data begins at 0x1c) + * Revert buffer is memory[0x1c:0x20] + */ +uint256 constant NoSelectorForStrategy_error_selector = 0xab984846; +uint256 constant NoSelectorForStrategy_error_length = 0x04; + +uint256 constant Error_selector_offset = 0x1c; + +uint256 constant OneWord = 0x20; diff --git a/contracts/src/marketplace/constants/NumericConstants.sol b/contracts/src/marketplace/constants/NumericConstants.sol new file mode 100644 index 00000000..63029eea --- /dev/null +++ b/contracts/src/marketplace/constants/NumericConstants.sol @@ -0,0 +1,14 @@ +// SPDX-License-Identifier: MIT +pragma solidity 0.8.17; + +/** + * @dev 100% represented in basis point is 10_000. + */ +uint256 constant ONE_HUNDRED_PERCENT_IN_BP = 10_000; + +/** + * @dev The maximum length of a proof for a batch order is 10. + * The maximum merkle tree that can used for signing has a height of + * 2**10 = 1_024. + */ +uint256 constant MAX_CALLDATA_PROOF_LENGTH = 10; diff --git a/contracts/src/marketplace/constants/ValidationCodeConstants.sol b/contracts/src/marketplace/constants/ValidationCodeConstants.sol new file mode 100644 index 00000000..73cbc996 --- /dev/null +++ b/contracts/src/marketplace/constants/ValidationCodeConstants.sol @@ -0,0 +1,313 @@ +// SPDX-License-Identifier: MIT +pragma solidity 0.8.17; + +/** + * 0. No error + */ + +/** + * @dev The maker order is expected to be valid. + * There can be other reasons that cause makers orders to be + * invalid (e.g. trading restrictions for the protocol, fallbacks). + */ +uint256 constant ORDER_EXPECTED_TO_BE_VALID = 0; + +/** + * 1. Strategy & currency-related codes + */ + +/** + * @dev The currency is not allowed in the protocol. + * This maker order could become valid only with owner action. + * If the order is a maker bid and currency = address(0), it is permanently invalid. + */ +uint256 constant CURRENCY_NOT_ALLOWED = 101; + +/** + * @dev The strategy is not implemented in the protocol. + * This maker order can become valid only with owner action. + */ +uint256 constant STRATEGY_NOT_IMPLEMENTED = 111; + +/** + * @dev The strategy is not for this quote type. + * This maker order can never become valid. + */ +uint256 constant STRATEGY_INVALID_QUOTE_TYPE = 112; + +/** + * @dev The strategy exists but is not currently active. + * This maker order can become valid again only with owner action. + */ +uint256 constant STRATEGY_NOT_ACTIVE = 113; + +/** + * 2. Maker order struct-related codes + */ + +/** + * @dev The maker order is permanently invalid for a standard sale (e.g. invalid collection type or amounts) + * This maker order cannot become valid again. + */ +uint256 constant MAKER_ORDER_INVALID_STANDARD_SALE = 201; + +/** + * @dev The maker order is permanently invalid for a non-standard sale strategy. + * This maker order cannot become valid again. + */ +uint256 constant MAKER_ORDER_PERMANENTLY_INVALID_NON_STANDARD_SALE = 211; + +/** + * @dev The maker order is invalid due to a currency support. + * This maker order may become valid in the future depending on the strategy's currency support. + * Please refer to the strategy's implementation code. + */ +uint256 constant MAKER_ORDER_INVALID_CURRENCY_NON_STANDARD_SALE = 212; + +/** + * @dev The maker order is temporarily invalid due to a strategy-specific reason. + * This maker order may become valid in the future. + * Please refer to the strategy's implementation code. + */ +uint256 constant MAKER_ORDER_TEMPORARILY_INVALID_NON_STANDARD_SALE = 213; + +/** + * 3. Nonce-related codes + */ + +/** + * @dev The signer's subset nonce is cancelled. + * This maker order will not become valid again. + */ +uint256 constant USER_SUBSET_NONCE_CANCELLED = 301; + +/** + * @dev The signer's order nonce is executed or cancelled. + * This maker order will not become valid again. + */ +uint256 constant USER_ORDER_NONCE_EXECUTED_OR_CANCELLED = 311; + +/** + * @dev The signer's order nonce is in partial fill status with an other order hash. + * This maker order will not become valid again. + */ +uint256 constant USER_ORDER_NONCE_IN_EXECUTION_WITH_OTHER_HASH = 312; + +/** + * @dev The signer's global bid nonce is not matching the order's bid nonce. + * This maker order will not become valid again. + */ +uint256 constant INVALID_USER_GLOBAL_BID_NONCE = 321; + +/** + * @dev The signer's global ask nonce is not matching the order's ask nonce. + * This maker order will not become valid again. + */ +uint256 constant INVALID_USER_GLOBAL_ASK_NONCE = 322; + +/** + * 4. Codes related to signatures (EOA, EIP-1271) and merkle tree computations + */ + +/** + * @dev The order hash proof is not in the merkle tree. + * This maker order is not valid with the set of merkle root and proofs. + * It cannot become valid with the current merkle proof and root. + */ +uint256 constant ORDER_HASH_PROOF_NOT_IN_MERKLE_TREE = 401; + +/** + * @dev The merkle proof is too large to be verified according. + * There is a proof's size limit defined in the MerkleProofCalldataWithNodes. + * It cannot become valid with the current merkle proof and root. + */ +uint256 constant MERKLE_PROOF_PROOF_TOO_LARGE = 402; + +/** + * @dev The signature's length is invalid. + * The signature's length must be either 64 or 65 bytes. + * This maker order will never be valid. + */ +uint256 constant INVALID_SIGNATURE_LENGTH = 411; + +/** + * @dev The signature's s parameter is invalid. + * This maker order will never be valid. + */ +uint256 constant INVALID_S_PARAMETER_EOA = 412; + +/** + * @dev The signature's v parameter is invalid. + * It must be either equal to 27 or 28. + * This maker order will never be valid with this signature. + */ +uint256 constant INVALID_V_PARAMETER_EOA = 413; + +/** + * @dev The signer recovered (using ecrecover) is the null address. + * This maker order will never be valid with this signature. + */ +uint256 constant NULL_SIGNER_EOA = 414; + +/** + * @dev The recovered signer is not the target signer. + * This maker order will never be valid with this signature. + */ +uint256 constant INVALID_SIGNER_EOA = 415; + +/** + * @dev The signature is generated by a EIP1271 signer contract but the + * contract does not implement the required function to verify the signature. + */ +uint256 constant MISSING_IS_VALID_SIGNATURE_FUNCTION_EIP1271 = 421; + +/** + * @dev The signature by the EIP1271 signer contract is invalid. + * This maker order may become valid again depending on the implementation of the + * contract signing the order. + */ +uint256 constant SIGNATURE_INVALID_EIP1271 = 422; + +/** + * 5. Timestamp-related codes + */ + +/** + * @dev The start time is greater than the end time. + * This maker order will never be valid. + */ +uint256 constant START_TIME_GREATER_THAN_END_TIME = 501; + +/** + * @dev The block time is greater than the end time. + * This maker order will never be valid. + */ +uint256 constant TOO_LATE_TO_EXECUTE_ORDER = 502; + +/** + * @dev The block time is earlier than the start time. + * A buffer of 5 minutes is included for orders that are about to be valid. + * This maker order will become valid without any user action. + */ +uint256 constant TOO_EARLY_TO_EXECUTE_ORDER = 503; + +/** + * 6. Transfer-related (ERC20, ERC721, ERC1155 tokens), including transfers and approvals, codes. + */ + +/** + * @dev The same itemId is twice in the bundle. + * This maker order can be valid for ERC1155 collections but will never be valid for ERC721. + */ +uint256 constant SAME_ITEM_ID_IN_BUNDLE = 601; + +/** + * @dev The ERC20 balance of the signer (maker bid user) is inferior to the order bid price. + * This maker order can become valid without any user's action. + */ +uint256 constant ERC20_BALANCE_INFERIOR_TO_PRICE = 611; + +/** + * @dev The ERC20 approval amount of the signer (maker bid user) is inferior to the order bid price. + * This maker order can become valid only with the user's action. + */ +uint256 constant ERC20_APPROVAL_INFERIOR_TO_PRICE = 612; + +/** + * @dev The ERC721 itemId does not exist. + * This maker order can become valid if the item is created later. + */ +uint256 constant ERC721_ITEM_ID_DOES_NOT_EXIST = 621; + +/** + * @dev The ERC721 itemId is not owned by the signer (maker ask user). + * This maker order can become valid without any user's action. + */ +uint256 constant ERC721_ITEM_ID_NOT_IN_BALANCE = 622; + +/** + * @dev The transfer manager contract has not been approved by the ERC721 collection + * contract, either for the entire collection or the itemId. + * This maker order can become valid only with the user's action. + * The collection may not follow the ERC721 standard. + */ +uint256 constant ERC721_NO_APPROVAL_FOR_ALL_OR_ITEM_ID = 623; + +/** + * @dev The ERC1155 collection contract does not implement balanceOf. + */ +uint256 constant ERC1155_BALANCE_OF_DOES_NOT_EXIST = 631; + +/** + * @dev The ERC20 balance of the signer (maker ask user) is inferior to the amount + * required to be sold. + * This maker order can become valid without any user's action. + */ +uint256 constant ERC1155_BALANCE_OF_ITEM_ID_INFERIOR_TO_AMOUNT = 632; + +/** + * @dev The ERC1155 collection contract does not implement isApprovedForAll. + * The collection may not follow the ERC1155 standard. + */ +uint256 constant ERC1155_IS_APPROVED_FOR_ALL_DOES_NOT_EXIST = 633; + +/** + * @dev The transfer manager contract has not been approved by the ERC1155 + * collection contract. + * This maker order can become valid only with the user's action. + */ +uint256 constant ERC1155_NO_APPROVAL_FOR_ALL = 634; + +/** + * 7. Asset-type codes + */ + +/** + * @dev The collection type specified in the order seems incorrect. + * It is expected to be collectionType = 0. + */ +uint256 constant POTENTIAL_INVALID_COLLECTION_TYPE_SHOULD_BE_ERC721 = 701; + +/** + * @dev The collection type specified in the order seems incorrect. + * It is expected to be collectionType = 1. + */ +uint256 constant POTENTIAL_INVALID_COLLECTION_TYPE_SHOULD_BE_ERC1155 = 702; + +/** + * 8. Transfer manager-related codes + */ + +/** + * @dev The user has not approved the protocol to transfer NFTs on behalf + * of the user. + * This maker order can become valid only with the user's action. + */ +uint256 constant NO_TRANSFER_MANAGER_APPROVAL_BY_USER_FOR_EXCHANGE = 801; + +/** + * @dev The transfer manager's owner has revoked the ability to transfer NFTs + * on behalf of all users that have also approved the protocol. + * This maker order can become valid again only with owner action. + */ +uint256 constant TRANSFER_MANAGER_APPROVAL_REVOKED_BY_OWNER_FOR_EXCHANGE = 802; + +/** + * 9. Creator fee-related codes + */ + +/** + * @dev The collection contract has a flexible royalty fee structure that + * prevents this bundle to be traded. + * It applies at the protocol level. + * For instance, 2 items in a bundle have different creator recipients. + */ +uint256 constant BUNDLE_ERC2981_NOT_SUPPORTED = 901; + +/** + * @dev The creator fee applied at the protocol is higher than the threshold + * allowed. The transaction will revert. + * It applies at the protocol level. + * This maker order can become valid only with the creator's action. + */ +uint256 constant CREATOR_FEE_TOO_HIGH = 902; diff --git a/contracts/src/marketplace/enums/CollectionType.sol b/contracts/src/marketplace/enums/CollectionType.sol new file mode 100644 index 00000000..d95a2dc7 --- /dev/null +++ b/contracts/src/marketplace/enums/CollectionType.sol @@ -0,0 +1,13 @@ +// SPDX-License-Identifier: MIT +pragma solidity 0.8.17; + +/** + * @notice CollectionType is used in OrderStructs.Maker's collectionType to determine the collection type being traded. + */ +//TODO remove 721??? +enum CollectionType { + ERC721, + ERC1155, + Hypercert, + Hyperboard +} diff --git a/contracts/src/marketplace/enums/QuoteType.sol b/contracts/src/marketplace/enums/QuoteType.sol new file mode 100644 index 00000000..2cb766d7 --- /dev/null +++ b/contracts/src/marketplace/enums/QuoteType.sol @@ -0,0 +1,10 @@ +// SPDX-License-Identifier: MIT +pragma solidity 0.8.17; + +/** + * @notice QuoteType is used in OrderStructs.Maker's quoteType to determine whether the maker order is a bid or an ask. + */ +enum QuoteType { + Bid, + Ask +} diff --git a/contracts/src/marketplace/errors/ChainlinkErrors.sol b/contracts/src/marketplace/errors/ChainlinkErrors.sol new file mode 100644 index 00000000..bb21b470 --- /dev/null +++ b/contracts/src/marketplace/errors/ChainlinkErrors.sol @@ -0,0 +1,41 @@ +// SPDX-License-Identifier: MIT +pragma solidity 0.8.17; + +/** + * @notice It is returned if the Chainlink price is invalid (e.g. negative). + */ +error ChainlinkPriceInvalid(); + +/** + * @notice It is returned if the decimals from the NFT floor price feed is invalid. + * Chainlink price feeds are expected to have 18 decimals. + * @dev It can only be returned for owner operations. + */ +error DecimalsInvalid(); + +/** + * @notice It is returned if the fixed discount for a maker bid is greater than floor price. + */ +error DiscountGreaterThanFloorPrice(); + +/** + * @notice It is returned if the latency tolerance is set too high (i.e. greater than 3,600 sec). + */ +error LatencyToleranceTooHigh(); + +/** + * @notice It is returned if the price feed for a collection is already set. + * @dev It can only be returned for owner operations. + */ +error PriceFeedAlreadySet(); + +/** + * @notice It is returned when the price feed is not available. + */ +error PriceFeedNotAvailable(); + +/** + * @notice It is returned if the current block time relative to the latest price's update time + * is greater than the latency tolerance. + */ +error PriceNotRecentEnough(); diff --git a/contracts/src/marketplace/errors/SharedErrors.sol b/contracts/src/marketplace/errors/SharedErrors.sol new file mode 100644 index 00000000..bb123902 --- /dev/null +++ b/contracts/src/marketplace/errors/SharedErrors.sol @@ -0,0 +1,65 @@ +// SPDX-License-Identifier: MIT +pragma solidity 0.8.17; + +/** + * @notice It is returned if the amount is invalid. + * For ERC721, any number that is not 1. For ERC1155, if amount is 0. + */ +error AmountInvalid(); + +/** + * @notice It is returned if the ask price is too high for the bid user. + */ +error AskTooHigh(); + +/** + * @notice It is returned if the bid price is too low for the ask user. + */ +error BidTooLow(); + +/** + * @notice It is returned if the function cannot be called by the sender. + */ +error CallerInvalid(); + +/** + * @notice It is returned if the currency is invalid. + */ +error CurrencyInvalid(); + +/** + * @notice The function selector is invalid for this strategy implementation. + */ +error FunctionSelectorInvalid(); + +/** + * @notice It is returned if there is either a mismatch or an error in the length of the array(s). + */ +error LengthsInvalid(); + +/** + * @notice It is returned if the merkle proof provided is invalid. + */ +error MerkleProofInvalid(); + +/** + * @notice It is returned if the length of the merkle proof provided is greater than tolerated. + * @param length Proof length + */ +error MerkleProofTooLarge(uint256 length); + +/** + * @notice It is emitted if the call recipient is not a contract. + */ +error NotAContract(); + +/** + * @notice It is returned if the order is permanently invalid. + * There may be an issue with the order formatting. + */ +error OrderInvalid(); + +/** + * @notice It is returned if the maker quote type is invalid. + */ +error QuoteTypeInvalid(); diff --git a/contracts/src/marketplace/executionStrategies/BaseStrategy.sol b/contracts/src/marketplace/executionStrategies/BaseStrategy.sol new file mode 100644 index 00000000..9d0bec3c --- /dev/null +++ b/contracts/src/marketplace/executionStrategies/BaseStrategy.sol @@ -0,0 +1,46 @@ +// SPDX-License-Identifier: MIT +pragma solidity 0.8.17; + +// Interfaces +import {IStrategy} from "../interfaces/IStrategy.sol"; + +// Assembly constants +import {OrderInvalid_error_selector} from "../constants/AssemblyConstants.sol"; + +// Libraries +import {OrderStructs} from "../libraries/OrderStructs.sol"; + +// Enums +import {CollectionType} from "../enums/CollectionType.sol"; + +/** + * @title BaseStrategy + * @author LooksRare protocol team (👀,💎) + */ +abstract contract BaseStrategy is IStrategy { + /** + * @inheritdoc IStrategy + */ + function isLooksRareV2Strategy() external pure override returns (bool) { + return true; + } + + /** + * @dev This is equivalent to + * if (amount == 0 || (amount != 1 && collectionType == 0)) { + * return (0, OrderInvalid.selector); + * } + * @dev OrderInvalid_error_selector is a left-padded 4 bytes. If the error selector is returned + * instead of reverting, the error selector needs to be right-padded by + * 28 bytes. Therefore it needs to be left shifted by 28 x 8 = 224 bits. + */ + function _validateAmountNoRevert(uint256 amount, CollectionType collectionType) internal pure { + assembly { + if or(iszero(amount), and(xor(amount, 1), iszero(collectionType))) { + mstore(0x00, 0x00) + mstore(0x20, shl(224, OrderInvalid_error_selector)) + return(0, 0x40) + } + } + } +} diff --git a/contracts/src/marketplace/executionStrategies/Chainlink/BaseStrategyChainlinkPriceLatency.sol b/contracts/src/marketplace/executionStrategies/Chainlink/BaseStrategyChainlinkPriceLatency.sol new file mode 100644 index 00000000..09cb3dc3 --- /dev/null +++ b/contracts/src/marketplace/executionStrategies/Chainlink/BaseStrategyChainlinkPriceLatency.sol @@ -0,0 +1,33 @@ +// SPDX-License-Identifier: MIT +pragma solidity 0.8.17; + +// LooksRare unopinionated libraries +import {OwnableTwoSteps} from "@looksrare/contracts-libs/contracts/OwnableTwoSteps.sol"; + +/** + * @title BaseStrategyChainlinkPriceLatency + * @notice This contract allows the owner to define the maximum acceptable Chainlink price latency. + * @author LooksRare protocol team (👀,💎) + */ +contract BaseStrategyChainlinkPriceLatency is OwnableTwoSteps { + /** + * @notice Maximum latency accepted after which + * the execution strategy rejects the retrieved price. + * + * For ETH, it cannot be higher than 3,600 as Chainlink will at least update the + * price every 3,600 seconds, provided ETH's price does not deviate more than 0.5%. + * + * For NFTs, it cannot be higher than 86,400 as Chainlink will at least update the + * price every 86,400 seconds, provided ETH's price does not deviate more than 2%. + */ + uint256 public immutable maxLatency; + + /** + * @notice Constructor + * @param _owner Owner address + * @param _maxLatency Maximum price latency allowed + */ + constructor(address _owner, uint256 _maxLatency) OwnableTwoSteps(_owner) { + maxLatency = _maxLatency; + } +} diff --git a/contracts/src/marketplace/executionStrategies/Chainlink/StrategyChainlinkUSDDynamicAsk.sol b/contracts/src/marketplace/executionStrategies/Chainlink/StrategyChainlinkUSDDynamicAsk.sol new file mode 100644 index 00000000..137c1e86 --- /dev/null +++ b/contracts/src/marketplace/executionStrategies/Chainlink/StrategyChainlinkUSDDynamicAsk.sol @@ -0,0 +1,164 @@ +// SPDX-License-Identifier: MIT +pragma solidity 0.8.17; + +// Libraries +import {OrderStructs} from "../../libraries/OrderStructs.sol"; +import {CurrencyValidator} from "../../libraries/CurrencyValidator.sol"; + +// Interfaces +import {AggregatorV3Interface} from "@chainlink/contracts/src/v0.8/interfaces/AggregatorV3Interface.sol"; + +// Enums +import {QuoteType} from "../../enums/QuoteType.sol"; + +// Shared errors +import { + BidTooLow, + OrderInvalid, + CurrencyInvalid, + FunctionSelectorInvalid, + QuoteTypeInvalid +} from "../../errors/SharedErrors.sol"; +import {ChainlinkPriceInvalid, PriceFeedNotAvailable, PriceNotRecentEnough} from "../../errors/ChainlinkErrors.sol"; + +// Base strategy contracts +import {BaseStrategy, IStrategy} from "../BaseStrategy.sol"; +import {BaseStrategyChainlinkPriceLatency} from "./BaseStrategyChainlinkPriceLatency.sol"; + +/** + * @title StrategyChainlinkUSDDynamicAsk + * @notice This contract allows a seller to sell an NFT priced in USD and the receivable amount to be in ETH. + * @author LooksRare protocol team (👀,💎) + */ +contract StrategyChainlinkUSDDynamicAsk is BaseStrategy, BaseStrategyChainlinkPriceLatency { + /** + * @dev It is possible to call priceFeed.decimals() to get the decimals, + * but to save gas, it is hard coded instead. + */ + uint256 public constant ETH_USD_PRICE_FEED_DECIMALS = 1e8; + + /** + * @notice Wrapped ether (WETH) address. + */ + address public immutable WETH; + + /** + * @notice ETH/USD Chainlink price feed + */ + AggregatorV3Interface public immutable priceFeed; + + /** + * @notice Constructor + * @param _weth Wrapped ether address + * @param _owner Owner address + * @param _priceFeed Address of the ETH/USD price feed + */ + constructor(address _owner, address _weth, address _priceFeed) BaseStrategyChainlinkPriceLatency(_owner, 3600) { + WETH = _weth; + priceFeed = AggregatorV3Interface(_priceFeed); + } + + /** + * @notice This function validates the order under the context of the chosen strategy + * and returns the fulfillable items/amounts/price/nonce invalidation status. + * This strategy looks at the seller's desired sale price in USD and minimum sale price in ETH, + * converts the USD value into ETH using Chainlink's price feed and chooses the higher price. + * @param takerBid Taker bid struct (taker bid-specific parameters for the execution) + * @param makerAsk Maker ask struct (maker ask-specific parameters for the execution) + * @dev The client has to provide the seller's desired sale price in USD as the additionalParameters + */ + function executeStrategyWithTakerBid(OrderStructs.Taker calldata takerBid, OrderStructs.Maker calldata makerAsk) + external + view + returns (uint256 price, uint256[] memory itemIds, uint256[] memory amounts, bool isNonceInvalidated) + { + uint256 itemIdsLength = makerAsk.itemIds.length; + + if (itemIdsLength == 0 || itemIdsLength != makerAsk.amounts.length) { + revert OrderInvalid(); + } + + CurrencyValidator.allowNativeOrAllowedCurrency(makerAsk.currency, WETH); + + (, int256 answer,, uint256 updatedAt,) = priceFeed.latestRoundData(); + + if (answer <= 0) { + revert ChainlinkPriceInvalid(); + } + + if (block.timestamp - updatedAt > maxLatency) { + revert PriceNotRecentEnough(); + } + + // The client has to provide a USD value that is augmented by 1e18. + uint256 desiredSalePriceInUSD = abi.decode(makerAsk.additionalParameters, (uint256)); + + uint256 ethPriceInUSD = uint256(answer); + uint256 minPriceInETH = makerAsk.price; + uint256 desiredSalePriceInETH = (desiredSalePriceInUSD * ETH_USD_PRICE_FEED_DECIMALS) / ethPriceInUSD; + + if (minPriceInETH >= desiredSalePriceInETH) { + price = minPriceInETH; + } else { + price = desiredSalePriceInETH; + } + + uint256 maxPrice = abi.decode(takerBid.additionalParameters, (uint256)); + if (maxPrice < price) { + revert BidTooLow(); + } + + itemIds = makerAsk.itemIds; + amounts = makerAsk.amounts; + isNonceInvalidated = true; + } + + /** + * @inheritdoc IStrategy + */ + function isMakerOrderValid(OrderStructs.Maker calldata makerAsk, bytes4 functionSelector) + external + view + override + returns (bool isValid, bytes4 errorSelector) + { + if (functionSelector != StrategyChainlinkUSDDynamicAsk.executeStrategyWithTakerBid.selector) { + return (isValid, FunctionSelectorInvalid.selector); + } + + if (makerAsk.quoteType != QuoteType.Ask) { + return (isValid, QuoteTypeInvalid.selector); + } + + uint256 itemIdsLength = makerAsk.itemIds.length; + + if (itemIdsLength == 0 || itemIdsLength != makerAsk.amounts.length) { + return (isValid, OrderInvalid.selector); + } + + for (uint256 i; i < itemIdsLength;) { + _validateAmountNoRevert(makerAsk.amounts[i], makerAsk.collectionType); + unchecked { + ++i; + } + } + + if (makerAsk.currency != address(0)) { + if (makerAsk.currency != WETH) { + return (isValid, CurrencyInvalid.selector); + } + } + + (, int256 answer,, uint256 updatedAt,) = priceFeed.latestRoundData(); + + if (answer <= 0) { + return (isValid, ChainlinkPriceInvalid.selector); + } + + if (block.timestamp - updatedAt > maxLatency) { + return (isValid, PriceNotRecentEnough.selector); + } + + isValid = true; + } +} diff --git a/contracts/src/marketplace/executionStrategies/StrategyCollectionOffer.sol b/contracts/src/marketplace/executionStrategies/StrategyCollectionOffer.sol new file mode 100644 index 00000000..9f0d04bf --- /dev/null +++ b/contracts/src/marketplace/executionStrategies/StrategyCollectionOffer.sol @@ -0,0 +1,138 @@ +// SPDX-License-Identifier: MIT +pragma solidity 0.8.17; + +// Libraries +import {OrderStructs} from "../libraries/OrderStructs.sol"; + +// OpenZeppelin's library for verifying Merkle proofs +import {MerkleProofMemory} from "../libraries/OpenZeppelin/MerkleProofMemory.sol"; + +// Enums +import {QuoteType} from "../enums/QuoteType.sol"; + +// Shared errors +import {OrderInvalid, FunctionSelectorInvalid, MerkleProofInvalid, QuoteTypeInvalid} from "../errors/SharedErrors.sol"; + +// Base strategy contracts +import {BaseStrategy, IStrategy} from "./BaseStrategy.sol"; + +/** + * @title StrategyCollectionOffer + * @notice This contract offers execution strategies for users to create maker bid offers for items in a collection. + * There are two available functions: + * 1. executeCollectionStrategyWithTakerAsk --> it applies to all itemIds in a collection + * 2. executeCollectionStrategyWithTakerAskWithProof --> it allows adding merkle proof criteria. + * @notice The bidder can only bid on 1 item id at a time. + * 1. If ERC721, the amount must be 1. + * 2. If ERC1155, the amount can be greater than 1. + * @dev Use cases can include trait-based offers or rarity score offers. + * @author LooksRare protocol team (👀,💎) + */ +// TODO This allows for a buyer to declare a set of items they're willing to buy in a merkle tree +contract StrategyCollectionOffer is BaseStrategy { + /** + * @notice This function validates the order under the context of the chosen strategy and + * returns the fulfillable items/amounts/price/nonce invalidation status. + * This strategy executes a collection offer against a taker ask order without the need of merkle proofs. + * @param takerAsk Taker ask struct (taker ask-specific parameters for the execution) + * @param makerBid Maker bid struct (maker bid-specific parameters for the execution) + */ + function executeCollectionStrategyWithTakerAsk( + OrderStructs.Taker calldata takerAsk, + OrderStructs.Maker calldata makerBid + ) + external + pure + returns (uint256 price, uint256[] memory itemIds, uint256[] calldata amounts, bool isNonceInvalidated) + { + price = makerBid.price; + amounts = makerBid.amounts; + + // A collection order can only be executable for 1 itemId but quantity to fill can vary + if (amounts.length != 1) { + revert OrderInvalid(); + } + + uint256 offeredItemId = abi.decode(takerAsk.additionalParameters, (uint256)); + itemIds = new uint256[](1); + itemIds[0] = offeredItemId; + isNonceInvalidated = true; + } + + /** + * @notice This function validates the order under the context of the chosen strategy + * and returns the fulfillable items/amounts/price/nonce invalidation status. + * This strategy executes a collection offer against a taker ask order with the need of a merkle proof. + * @param takerAsk Taker ask struct (taker ask-specific parameters for the execution) + * @param makerBid Maker bid struct (maker bid-specific parameters for the execution) + * @dev The transaction reverts if the maker does not include a merkle root in the additionalParameters. + */ + function executeCollectionStrategyWithTakerAskWithProof( + OrderStructs.Taker calldata takerAsk, + OrderStructs.Maker calldata makerBid + ) + external + pure + returns (uint256 price, uint256[] memory itemIds, uint256[] calldata amounts, bool isNonceInvalidated) + { + price = makerBid.price; + amounts = makerBid.amounts; + + // A collection order can only be executable for 1 itemId but the actual quantity to fill can vary + if (amounts.length != 1) { + revert OrderInvalid(); + } + + (uint256 offeredItemId, bytes32[] memory proof) = + abi.decode(takerAsk.additionalParameters, (uint256, bytes32[])); + itemIds = new uint256[](1); + itemIds[0] = offeredItemId; + isNonceInvalidated = true; + + bytes32 root = abi.decode(makerBid.additionalParameters, (bytes32)); + bytes32 node = keccak256(abi.encodePacked(offeredItemId)); + + // Verify the merkle root for the given merkle proof + if (!MerkleProofMemory.verify(proof, root, node)) { + revert MerkleProofInvalid(); + } + } + + /** + * @inheritdoc IStrategy + */ + function isMakerOrderValid(OrderStructs.Maker calldata makerBid, bytes4 functionSelector) + external + pure + override + returns (bool isValid, bytes4 errorSelector) + { + if ( + functionSelector != StrategyCollectionOffer.executeCollectionStrategyWithTakerAskWithProof.selector + && functionSelector != StrategyCollectionOffer.executeCollectionStrategyWithTakerAsk.selector + ) { + return (isValid, FunctionSelectorInvalid.selector); + } + + if (makerBid.quoteType != QuoteType.Bid) { + return (isValid, QuoteTypeInvalid.selector); + } + + if (makerBid.amounts.length != 1) { + return (isValid, OrderInvalid.selector); + } + + _validateAmountNoRevert(makerBid.amounts[0], makerBid.collectionType); + + // If no root is provided or invalid length, it should be invalid. + // @dev It does not mean the merkle root is valid against a specific itemId that exists in the collection. + if ( + functionSelector == StrategyCollectionOffer.executeCollectionStrategyWithTakerAskWithProof.selector + && makerBid.additionalParameters.length != 32 + ) { + return (isValid, OrderInvalid.selector); + } + + isValid = true; + } +} diff --git a/contracts/src/marketplace/executionStrategies/StrategyDutchAuction.sol b/contracts/src/marketplace/executionStrategies/StrategyDutchAuction.sol new file mode 100644 index 00000000..3c4fcf27 --- /dev/null +++ b/contracts/src/marketplace/executionStrategies/StrategyDutchAuction.sol @@ -0,0 +1,102 @@ +// SPDX-License-Identifier: MIT +pragma solidity 0.8.17; + +// Libraries +import {OrderStructs} from "../libraries/OrderStructs.sol"; + +// Enums +import {QuoteType} from "../enums/QuoteType.sol"; + +// Shared errors +import {BidTooLow, OrderInvalid, FunctionSelectorInvalid, QuoteTypeInvalid} from "../errors/SharedErrors.sol"; + +// Base strategy contracts +import {BaseStrategy, IStrategy} from "./BaseStrategy.sol"; + +/** + * @title StrategyDutchAuction + * @notice This contract offers a single execution strategy for users to create Dutch auctions. + * @author LooksRare protocol team (👀,💎) + */ +contract StrategyDutchAuction is BaseStrategy { + /** + * @notice This function validates the order under the context of the chosen strategy + * and returns the fulfillable items/amounts/price/nonce invalidation status. + * The execution price set by the seller decreases linearly within the defined period. + * @param takerBid Taker bid struct (taker ask-specific parameters for the execution) + * @param makerAsk Maker ask struct (maker bid-specific parameters for the execution) + * @dev The client has to provide the seller's desired initial start price as the additionalParameters. + */ + function executeStrategyWithTakerBid(OrderStructs.Taker calldata takerBid, OrderStructs.Maker calldata makerAsk) + external + view + returns (uint256 price, uint256[] memory itemIds, uint256[] memory amounts, bool isNonceInvalidated) + { + uint256 itemIdsLength = makerAsk.itemIds.length; + + if (itemIdsLength == 0 || itemIdsLength != makerAsk.amounts.length) { + revert OrderInvalid(); + } + + uint256 startPrice = abi.decode(makerAsk.additionalParameters, (uint256)); + + if (startPrice < makerAsk.price) { + revert OrderInvalid(); + } + + uint256 startTime = makerAsk.startTime; + uint256 endTime = makerAsk.endTime; + + price = ((endTime - block.timestamp) * startPrice + (block.timestamp - startTime) * makerAsk.price) + / (endTime - startTime); + + uint256 maxPrice = abi.decode(takerBid.additionalParameters, (uint256)); + if (maxPrice < price) { + revert BidTooLow(); + } + + isNonceInvalidated = true; + + itemIds = makerAsk.itemIds; + amounts = makerAsk.amounts; + } + + /** + * @inheritdoc IStrategy + */ + function isMakerOrderValid(OrderStructs.Maker calldata makerAsk, bytes4 functionSelector) + external + pure + override + returns (bool isValid, bytes4 errorSelector) + { + if (functionSelector != StrategyDutchAuction.executeStrategyWithTakerBid.selector) { + return (isValid, FunctionSelectorInvalid.selector); + } + + if (makerAsk.quoteType != QuoteType.Ask) { + return (isValid, QuoteTypeInvalid.selector); + } + + uint256 itemIdsLength = makerAsk.itemIds.length; + + if (itemIdsLength == 0 || itemIdsLength != makerAsk.amounts.length) { + return (isValid, OrderInvalid.selector); + } + + for (uint256 i; i < itemIdsLength;) { + _validateAmountNoRevert(makerAsk.amounts[i], makerAsk.collectionType); + unchecked { + ++i; + } + } + + uint256 startPrice = abi.decode(makerAsk.additionalParameters, (uint256)); + + if (startPrice < makerAsk.price) { + return (isValid, OrderInvalid.selector); + } + + isValid = true; + } +} diff --git a/contracts/src/marketplace/executionStrategies/StrategyItemIdsRange.sol b/contracts/src/marketplace/executionStrategies/StrategyItemIdsRange.sol new file mode 100644 index 00000000..96470011 --- /dev/null +++ b/contracts/src/marketplace/executionStrategies/StrategyItemIdsRange.sol @@ -0,0 +1,111 @@ +// SPDX-License-Identifier: MIT +pragma solidity 0.8.17; + +// Libraries +import {OrderStructs} from "../libraries/OrderStructs.sol"; + +// Enums +import {QuoteType} from "../enums/QuoteType.sol"; + +// Shared errors +import {OrderInvalid, FunctionSelectorInvalid, QuoteTypeInvalid} from "../errors/SharedErrors.sol"; + +// Base strategy contracts +import {BaseStrategy, IStrategy} from "./BaseStrategy.sol"; + +/** + * @title StrategyItemIdsRange + * @notice This contract offers a single execution strategy for users to bid on + * a specific amount of items in a range bounded by 2 item ids. + * @author LooksRare protocol team (👀,💎) + */ +// TODO this enables bidding on all fractions belonging to a claimID +contract StrategyItemIdsRange is BaseStrategy { + /** + * @notice This function validates the order under the context of the chosen strategy + * and returns the fulfillable items/amounts/price/nonce invalidation status. + * With this strategy, the bidder picks a item id range (e.g. 1-100) + * and a seller can fulfill the order with any tokens within the specified id range. + * @param takerAsk Taker ask struct (taker ask-specific parameters for the execution) + * @param makerBid Maker bid struct (maker bid-specific parameters for the execution) + */ + function executeStrategyWithTakerAsk(OrderStructs.Taker calldata takerAsk, OrderStructs.Maker calldata makerBid) + external + pure + returns (uint256 price, uint256[] memory itemIds, uint256[] memory amounts, bool isNonceInvalidated) + { + (itemIds, amounts) = abi.decode(takerAsk.additionalParameters, (uint256[], uint256[])); + uint256 length = itemIds.length; + if (length != amounts.length) { + revert OrderInvalid(); + } + + (uint256 minItemId, uint256 maxItemId, uint256 desiredAmount) = + abi.decode(makerBid.additionalParameters, (uint256, uint256, uint256)); + + if (minItemId >= maxItemId || desiredAmount == 0) { + revert OrderInvalid(); + } + + uint256 totalOfferedAmount; + uint256 lastItemId; + + for (uint256 i; i < length;) { + uint256 offeredItemId = itemIds[i]; + // Force the client to sort the item ids in ascending order, + // in order to prevent taker ask from providing duplicated + // item ids + if (offeredItemId <= lastItemId) { + if (i != 0) { + revert OrderInvalid(); + } + } + + if (offeredItemId < minItemId || offeredItemId > maxItemId) { + revert OrderInvalid(); + } + + totalOfferedAmount += amounts[i]; + + lastItemId = offeredItemId; + + unchecked { + ++i; + } + } + + if (totalOfferedAmount != desiredAmount) { + revert OrderInvalid(); + } + + price = makerBid.price; + isNonceInvalidated = true; + } + + /** + * @inheritdoc IStrategy + */ + function isMakerOrderValid(OrderStructs.Maker calldata makerBid, bytes4 functionSelector) + external + pure + override + returns (bool isValid, bytes4 errorSelector) + { + if (functionSelector != StrategyItemIdsRange.executeStrategyWithTakerAsk.selector) { + return (isValid, FunctionSelectorInvalid.selector); + } + + if (makerBid.quoteType != QuoteType.Bid) { + return (isValid, QuoteTypeInvalid.selector); + } + + (uint256 minItemId, uint256 maxItemId, uint256 desiredAmount) = + abi.decode(makerBid.additionalParameters, (uint256, uint256, uint256)); + + if (minItemId >= maxItemId || desiredAmount == 0) { + return (isValid, OrderInvalid.selector); + } + + isValid = true; + } +} diff --git a/contracts/src/marketplace/helpers/OrderValidatorV2A.sol b/contracts/src/marketplace/helpers/OrderValidatorV2A.sol new file mode 100644 index 00000000..808a8386 --- /dev/null +++ b/contracts/src/marketplace/helpers/OrderValidatorV2A.sol @@ -0,0 +1,845 @@ +// SPDX-License-Identifier: MIT +pragma solidity 0.8.17; + +// LooksRare unopinionated libraries +import {IERC165} from "@looksrare/contracts-libs/contracts/interfaces/generic/IERC165.sol"; +import {IERC20} from "@looksrare/contracts-libs/contracts/interfaces/generic/IERC20.sol"; +import {IERC721} from "@looksrare/contracts-libs/contracts/interfaces/generic/IERC721.sol"; +import {IERC1155} from "@looksrare/contracts-libs/contracts/interfaces/generic/IERC1155.sol"; +import {IERC1271} from "@looksrare/contracts-libs/contracts/interfaces/generic/IERC1271.sol"; + +// Libraries +import {OrderStructs} from "../libraries/OrderStructs.sol"; +import {MerkleProofCalldataWithNodes} from "../libraries/OpenZeppelin/MerkleProofCalldataWithNodes.sol"; + +// Interfaces +import {ICreatorFeeManager} from "../interfaces/ICreatorFeeManager.sol"; +import {IStrategy} from "../interfaces/IStrategy.sol"; +import {IRoyaltyFeeRegistry} from "../interfaces/IRoyaltyFeeRegistry.sol"; + +// Shared errors +import {OrderInvalid} from "../errors/SharedErrors.sol"; + +// Other dependencies +import {LooksRareProtocol} from "../LooksRareProtocol.sol"; +import {TransferManager} from "../TransferManager.sol"; + +// Constants +import "../constants/ValidationCodeConstants.sol"; +import {MAX_CALLDATA_PROOF_LENGTH, ONE_HUNDRED_PERCENT_IN_BP} from "../constants/NumericConstants.sol"; + +// Enums +import {CollectionType} from "../enums/CollectionType.sol"; +import {QuoteType} from "../enums/QuoteType.sol"; + +/** + * @title OrderValidatorV2A + * @notice This contract is used to check the validity of maker ask/bid orders in the LooksRareProtocol (v2). + * It performs checks for: + * 1. Protocol allowlist issues (i.e. currency or strategy not allowed) + * 2. Maker order-specific issues (e.g., order invalid due to format or other-strategy specific issues) + * 3. Nonce related issues (e.g., nonce executed or cancelled) + * 4. Signature related issues and merkle tree parameters + * 5. Timestamp related issues (e.g., order expired) + * 6. Asset-related issues for ERC20/ERC721/ERC1155 (approvals and balances) + * 7. Collection-type suggestions + * 8. Transfer manager related issues + * 9. Creator fee related issues (e.g., creator fee too high, ERC2981 bundles) + * @dev This version does not handle strategies with partial fills. + * @author LooksRare protocol team (👀,💎) + */ +//TODO this might need hypercerts specific changes like checking on amount of units in a fraction +contract OrderValidatorV2A { + using OrderStructs for OrderStructs.Maker; + + /** + * @notice ERC721 potential interfaceId. + */ + bytes4 public constant ERC721_INTERFACE_ID_1 = 0x5b5e139f; + + /** + * @notice ERC721 potential interfaceId. + */ + bytes4 public constant ERC721_INTERFACE_ID_2 = 0x80ac58cd; + + /** + * @notice ERC1155 interfaceId. + */ + bytes4 public constant ERC1155_INTERFACE_ID = 0xd9b67a26; + + /** + * @notice Magic value nonce returned if executed (or cancelled). + */ + bytes32 public constant MAGIC_VALUE_ORDER_NONCE_EXECUTED = keccak256("ORDER_NONCE_EXECUTED"); + + /** + * @notice Number of distinct criteria groups checked to evaluate the validity of an order. + */ + uint256 public constant CRITERIA_GROUPS = 9; + + /** + * @notice LooksRareProtocol domain separator. + */ + bytes32 public domainSeparator; + + /** + * @notice Maximum creator fee (in basis point). + */ + uint256 public maxCreatorFeeBp; + + /** + * @notice CreatorFeeManager. + */ + ICreatorFeeManager public creatorFeeManager; + + /** + * @notice LooksRareProtocol. + */ + LooksRareProtocol public looksRareProtocol; + + /** + * @notice TransferManager + */ + TransferManager public transferManager; + + /** + * @notice Constructor + * @param _looksRareProtocol LooksRare protocol address + * @dev It derives automatically other external variables such as the creator fee manager and domain separator. + */ + constructor(address _looksRareProtocol) { + looksRareProtocol = LooksRareProtocol(_looksRareProtocol); + transferManager = looksRareProtocol.transferManager(); + + _deriveProtocolParameters(); + } + + /** + * @notice Derive protocol parameters. Anyone can call this function. + * @dev It allows adjusting if the domain separator or creator fee manager address were to change. + */ + function deriveProtocolParameters() external { + _deriveProtocolParameters(); + } + + /** + * @notice This function verifies the validity of an array of maker orders. + * @param makerOrders Array of maker orders + * @param signatures Array of signatures + * @param merkleTrees Array of merkle trees + * @return validationCodes Arrays of validation codes + */ + function checkMultipleMakerOrderValidities( + OrderStructs.Maker[] calldata makerOrders, + bytes[] calldata signatures, + OrderStructs.MerkleTree[] calldata merkleTrees + ) external view returns (uint256[9][] memory validationCodes) { + uint256 length = makerOrders.length; + + validationCodes = new uint256[CRITERIA_GROUPS][](length); + + for (uint256 i; i < length;) { + validationCodes[i] = checkMakerOrderValidity(makerOrders[i], signatures[i], merkleTrees[i]); + unchecked { + ++i; + } + } + } + + /** + * @notice This function verifies the validity of a maker order. + * @param makerOrder Maker struct + * @param signature Signature + * @param merkleTree Merkle tree + * @return validationCodes Array of validation codes + */ + function checkMakerOrderValidity( + OrderStructs.Maker calldata makerOrder, + bytes calldata signature, + OrderStructs.MerkleTree calldata merkleTree + ) public view returns (uint256[9] memory validationCodes) { + bytes32 orderHash = makerOrder.hash(); + + validationCodes[0] = + _checkValidityCurrencyAndStrategy(makerOrder.quoteType, makerOrder.currency, makerOrder.strategyId); + + // It will exit here if the strategy does not exist. + // However, if the strategy is implemented but invalid (except if wrong quote type), + // it can continue the validation process. + if (validationCodes[0] == STRATEGY_NOT_IMPLEMENTED || validationCodes[0] == STRATEGY_INVALID_QUOTE_TYPE) { + return validationCodes; + } + + uint256 validationCode1; + uint256[] memory itemIds; + uint256[] memory amounts; + uint256 price; + + if (makerOrder.quoteType == QuoteType.Ask) { + (validationCode1, itemIds, amounts, price) = _checkValidityMakerAskItemIdsAndAmountsAndPrice(makerOrder); + } else { + (validationCode1, itemIds,, price) = _checkValidityMakerBidItemIdsAndAmountsAndPrice(makerOrder); + } + + validationCodes[1] = validationCode1; + + validationCodes[2] = _checkValidityNonces( + makerOrder.quoteType, + makerOrder.signer, + makerOrder.globalNonce, + makerOrder.orderNonce, + makerOrder.subsetNonce, + orderHash + ); + + validationCodes[3] = _checkValidityMerkleProofAndOrderHash(merkleTree, orderHash, signature, makerOrder.signer); + validationCodes[4] = _checkValidityTimestamps(makerOrder.startTime, makerOrder.endTime); + + validationCodes[3] = _checkValidityMerkleProofAndOrderHash(merkleTree, orderHash, signature, makerOrder.signer); + validationCodes[4] = _checkValidityTimestamps(makerOrder.startTime, makerOrder.endTime); + + if (makerOrder.quoteType == QuoteType.Bid) { + validationCodes[5] = _checkValidityMakerBidERC20Assets(makerOrder.currency, makerOrder.signer, price); + } else { + validationCodes[5] = _checkValidityMakerAskNFTAssets( + makerOrder.collection, makerOrder.collectionType, makerOrder.signer, itemIds, amounts + ); + } + + validationCodes[6] = _checkIfPotentialInvalidCollectionTypes(makerOrder.collection, makerOrder.collectionType); + + if (makerOrder.quoteType == QuoteType.Bid) { + validationCodes[7] = ORDER_EXPECTED_TO_BE_VALID; + } else { + validationCodes[7] = _checkValidityTransferManagerApprovals(makerOrder.signer); + } + + validationCodes[8] = _checkValidityCreatorFee(makerOrder.collection, price, itemIds); + } + + /** + * @notice This function is private and is used to adjust the protocol parameters. + */ + function _deriveProtocolParameters() private { + domainSeparator = looksRareProtocol.domainSeparator(); + creatorFeeManager = looksRareProtocol.creatorFeeManager(); + maxCreatorFeeBp = looksRareProtocol.maxCreatorFeeBp(); + } + + /** + * @notice This function is private and verifies the validity of nonces for maker order. + * @param makerSigner Address of the maker signer + * @param globalNonce Global nonce + * @param orderNonce Order nonce + * @param subsetNonce Subset nonce + * @param orderHash Order hash + * @return validationCode Validation code + */ + function _checkValidityNonces( + QuoteType quoteType, + address makerSigner, + uint256 globalNonce, + uint256 orderNonce, + uint256 subsetNonce, + bytes32 orderHash + ) private view returns (uint256 validationCode) { + // 1. Check subset nonce + if (looksRareProtocol.userSubsetNonce(makerSigner, subsetNonce)) { + return USER_SUBSET_NONCE_CANCELLED; + } + + // 2. Check order nonce + bytes32 orderNonceStatus = looksRareProtocol.userOrderNonce(makerSigner, orderNonce); + + if (orderNonceStatus == MAGIC_VALUE_ORDER_NONCE_EXECUTED) { + return USER_ORDER_NONCE_EXECUTED_OR_CANCELLED; + } + + if (orderNonceStatus != bytes32(0) && orderNonceStatus != orderHash) { + return USER_ORDER_NONCE_IN_EXECUTION_WITH_OTHER_HASH; + } + + // 3. Check global nonces + (uint256 globalBidNonce, uint256 globalAskNonce) = looksRareProtocol.userBidAskNonces(makerSigner); + + if (quoteType == QuoteType.Bid && globalNonce != globalBidNonce) { + return INVALID_USER_GLOBAL_BID_NONCE; + } + if (quoteType == QuoteType.Ask && globalNonce != globalAskNonce) { + return INVALID_USER_GLOBAL_ASK_NONCE; + } + } + + /** + * @notice This function is private and verifies the validity of the currency and strategy. + * @param quoteType Quote type + * @param currency Address of the currency + * @param strategyId Strategy id + * @return validationCode Validation code + */ + function _checkValidityCurrencyAndStrategy(QuoteType quoteType, address currency, uint256 strategyId) + private + view + returns (uint256 validationCode) + { + // 1. Verify whether the currency is allowed + if (!looksRareProtocol.isCurrencyAllowed(currency)) { + return CURRENCY_NOT_ALLOWED; + } + + if (currency == address(0) && quoteType == QuoteType.Bid) { + return CURRENCY_NOT_ALLOWED; + } + + // 2. Verify whether the strategy is valid + (bool strategyIsActive,,,,, bool strategyIsMakerBid, address strategyImplementation) = + looksRareProtocol.strategyInfo(strategyId); + + if (strategyId != 0 && strategyImplementation == address(0)) { + return STRATEGY_NOT_IMPLEMENTED; + } + + if (strategyId != 0) { + if ( + (strategyIsMakerBid && quoteType != QuoteType.Bid) + || (!strategyIsMakerBid && quoteType != QuoteType.Ask) + ) { + return STRATEGY_INVALID_QUOTE_TYPE; + } + } + + if (!strategyIsActive) { + return STRATEGY_NOT_ACTIVE; + } + } + + /** + * @notice This function verifies the validity for order timestamps. + * @param startTime Start time + * @param endTime End time + * @return validationCode Validation code + */ + function _checkValidityTimestamps(uint256 startTime, uint256 endTime) + private + view + returns (uint256 validationCode) + { + // @dev It is possible for startTime to be equal to endTime. + // If so, the execution only succeeds when the startTime = endTime = block.timestamp. + // For order invalidation, if the call succeeds, it is already too late for later execution since the + // next block will have a greater timestamp than the current one. + if (startTime >= endTime) { + return START_TIME_GREATER_THAN_END_TIME; + } + + if (endTime <= block.timestamp) { + return TOO_LATE_TO_EXECUTE_ORDER; + } + if (startTime >= block.timestamp + 5 minutes) { + return TOO_EARLY_TO_EXECUTE_ORDER; + } + } + + /** + * @notice This function is private and checks if the collection type may be potentially invalid. + * @param collection Address of the collection + * @param collectionType Collection type in the maker order + * @return validationCode Validation code + * @dev This function may return false positives. + * (i.e. collections that are tradable but do not implement the proper interfaceId). + * If ERC165 is not implemented, it will revert. + */ + function _checkIfPotentialInvalidCollectionTypes(address collection, CollectionType collectionType) + private + view + returns (uint256 validationCode) + { + if (collectionType == CollectionType.ERC721) { + bool isERC721 = IERC165(collection).supportsInterface(ERC721_INTERFACE_ID_1) + || IERC165(collection).supportsInterface(ERC721_INTERFACE_ID_2); + + if (!isERC721) { + return POTENTIAL_INVALID_COLLECTION_TYPE_SHOULD_BE_ERC721; + } + } else if (collectionType == CollectionType.ERC1155) { + if (!IERC165(collection).supportsInterface(ERC1155_INTERFACE_ID)) { + return POTENTIAL_INVALID_COLLECTION_TYPE_SHOULD_BE_ERC1155; + } + } + } + + /** + * @notice This function verifies that (1) ERC20 approvals + * and (2) balances are sufficient to process the maker bid order. + * @param currency Currency address + * @param user User address + * @param price Price (defined by the maker order) + * @return validationCode Validation code + */ + function _checkValidityMakerBidERC20Assets(address currency, address user, uint256 price) + private + view + returns (uint256 validationCode) + { + if (currency != address(0)) { + if (IERC20(currency).balanceOf(user) < price) { + return ERC20_BALANCE_INFERIOR_TO_PRICE; + } + + if (IERC20(currency).allowance(user, address(looksRareProtocol)) < price) { + return ERC20_APPROVAL_INFERIOR_TO_PRICE; + } + } + } + + /** + * @notice This function verifies the validity of NFT assets (approvals, balances, and others). + * @param collection Collection address + * @param collectionType Collection type + * @param user User address + * @param itemIds Array of item ids + * @param amounts Array of amounts + * @return validationCode Validation code + */ + function _checkValidityMakerAskNFTAssets( + address collection, + CollectionType collectionType, + address user, + uint256[] memory itemIds, + uint256[] memory amounts + ) private view returns (uint256 validationCode) { + validationCode = _checkIfItemIdsDiffer(itemIds); + + if (validationCode != ORDER_EXPECTED_TO_BE_VALID) { + return validationCode; + } + + if (collectionType == CollectionType.ERC721) { + validationCode = _checkValidityERC721AndEquivalents(collection, user, itemIds); + } else if (collectionType == CollectionType.ERC1155) { + validationCode = _checkValidityERC1155(collection, user, itemIds, amounts); + } + } + + /** + * @notice This function verifies the validity of (1) ERC721 approvals + * and (2) balances to process the maker ask order. + * @param collection Collection address + * @param user User address + * @param itemIds Array of item ids + * @return validationCode Validation code + */ + function _checkValidityERC721AndEquivalents(address collection, address user, uint256[] memory itemIds) + private + view + returns (uint256 validationCode) + { + // 1. Verify itemId is owned by user and catch revertion if ERC721 ownerOf fails + uint256 length = itemIds.length; + + bool success; + bytes memory data; + + for (uint256 i; i < length;) { + (success, data) = collection.staticcall(abi.encodeCall(IERC721.ownerOf, (itemIds[i]))); + + if (!success) { + return ERC721_ITEM_ID_DOES_NOT_EXIST; + } + + if (abi.decode(data, (address)) != user) { + return ERC721_ITEM_ID_NOT_IN_BALANCE; + } + + unchecked { + ++i; + } + } + + // 2. Verify if collection is approved by transfer manager + (success, data) = + collection.staticcall(abi.encodeCall(IERC721.isApprovedForAll, (user, address(transferManager)))); + + bool isApprovedAll; + if (success) { + isApprovedAll = abi.decode(data, (bool)); + } + + if (!isApprovedAll) { + for (uint256 i; i < length;) { + // 3. If collection is not approved by transfer manager, try to see if it is approved individually + (success, data) = collection.staticcall(abi.encodeCall(IERC721.getApproved, (itemIds[i]))); + + address approvedAddress; + + if (success) { + approvedAddress = abi.decode(data, (address)); + } + + if (approvedAddress != address(transferManager)) { + return ERC721_NO_APPROVAL_FOR_ALL_OR_ITEM_ID; + } + + unchecked { + ++i; + } + } + } + } + + /** + * @notice This function verifies the validity of (1) ERC1155 approvals + * (2) and balances to process the maker ask order. + * @param collection Collection address + * @param user User address + * @param itemIds Array of item ids + * @param amounts Array of amounts + * @return validationCode Validation code + */ + function _checkValidityERC1155(address collection, address user, uint256[] memory itemIds, uint256[] memory amounts) + private + view + returns (uint256 validationCode) + { + // 1. Verify each itemId is owned by user and catch revertion if ERC1155 ownerOf fails + address[] memory users = new address[](1); + users[0] = user; + + uint256 length = itemIds.length; + + // 1.1 Use balanceOfBatch + (bool success, bytes memory data) = + collection.staticcall(abi.encodeCall(IERC1155.balanceOfBatch, (users, itemIds))); + + if (success) { + uint256[] memory balances = abi.decode(data, (uint256[])); + for (uint256 i; i < length;) { + if (balances[i] < amounts[i]) { + return ERC1155_BALANCE_OF_ITEM_ID_INFERIOR_TO_AMOUNT; + } + unchecked { + ++i; + } + } + } else { + // 1.2 If the balanceOfBatch does not work, use loop with balanceOf function + for (uint256 i; i < length;) { + (success, data) = collection.staticcall(abi.encodeCall(IERC1155.balanceOf, (user, itemIds[i]))); + + if (!success) { + return ERC1155_BALANCE_OF_DOES_NOT_EXIST; + } + + if (abi.decode(data, (uint256)) < amounts[i]) { + return ERC1155_BALANCE_OF_ITEM_ID_INFERIOR_TO_AMOUNT; + } + + unchecked { + ++i; + } + } + } + + // 2. Verify if collection is approved by transfer manager + (success, data) = + collection.staticcall(abi.encodeCall(IERC1155.isApprovedForAll, (user, address(transferManager)))); + + if (!success) { + return ERC1155_IS_APPROVED_FOR_ALL_DOES_NOT_EXIST; + } + + if (!abi.decode(data, (bool))) { + return ERC1155_NO_APPROVAL_FOR_ALL; + } + } + + /** + * @notice This function verifies the validity of a Merkle proof and the order hash. + * @param merkleTree Merkle tree struct + * @param orderHash Order hash + * @param signature Signature + * @param signer Signer address + * @return validationCode Validation code + */ + function _checkValidityMerkleProofAndOrderHash( + OrderStructs.MerkleTree calldata merkleTree, + bytes32 orderHash, + bytes calldata signature, + address signer + ) private view returns (uint256 validationCode) { + if (merkleTree.proof.length != 0) { + if (merkleTree.proof.length > MAX_CALLDATA_PROOF_LENGTH) { + return MERKLE_PROOF_PROOF_TOO_LARGE; + } + + if (!MerkleProofCalldataWithNodes.verifyCalldata(merkleTree.proof, merkleTree.root, orderHash)) { + return ORDER_HASH_PROOF_NOT_IN_MERKLE_TREE; + } + + bytes32 batchOrderHash = looksRareProtocol.hashBatchOrder(merkleTree.root, merkleTree.proof.length); + + return _computeDigestAndVerify(batchOrderHash, signature, signer); + } else { + return _computeDigestAndVerify(orderHash, signature, signer); + } + } + + /** + * @notice Check the validity of creator fee + * @param collection Collection address + * @param itemIds Item ids + * @return validationCode Validation code + */ + function _checkValidityCreatorFee(address collection, uint256 price, uint256[] memory itemIds) + private + view + returns (uint256 validationCode) + { + if (address(creatorFeeManager) != address(0)) { + (bool status, bytes memory data) = address(creatorFeeManager).staticcall( + abi.encodeCall(ICreatorFeeManager.viewCreatorFeeInfo, (collection, price, itemIds)) + ); + + // The only path possible (to revert) in the fee manager is the bundle being not supported. + if (!status) { + return BUNDLE_ERC2981_NOT_SUPPORTED; + } + + (address creator, uint256 creatorFeeAmount) = abi.decode(data, (address, uint256)); + + if (creator != address(0)) { + if (creatorFeeAmount * ONE_HUNDRED_PERCENT_IN_BP > (price * uint256(maxCreatorFeeBp))) { + return CREATOR_FEE_TOO_HIGH; + } + } + } + } + + /** + * @notice This function computes the digest and verify the signature. + * @param computedHash Hash of order or merkle root + * @param makerSignature Signature of the maker + * @param signer Signer address + * @return validationCode Validation code + */ + function _computeDigestAndVerify(bytes32 computedHash, bytes calldata makerSignature, address signer) + private + view + returns (uint256 validationCode) + { + return _validateSignature( + keccak256(abi.encodePacked("\x19\x01", domainSeparator, computedHash)), makerSignature, signer + ); + } + + /** + * @notice This function checks the validity of the signature. + * @param hash Message hash + * @param signature A 64 or 65 bytes signature + * @param signer Signer address + * @return validationCode Validation code + */ + function _validateSignature(bytes32 hash, bytes calldata signature, address signer) + private + view + returns (uint256 validationCode) + { + // Logic if EOA + if (signer.code.length == 0) { + bytes32 r; + bytes32 s; + uint8 v; + + if (signature.length == 64) { + bytes32 vs; + assembly { + r := calldataload(signature.offset) + vs := calldataload(add(signature.offset, 0x20)) + s := and(vs, 0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) + v := add(shr(255, vs), 27) + } + } else if (signature.length == 65) { + assembly { + r := calldataload(signature.offset) + s := calldataload(add(signature.offset, 0x20)) + v := byte(0, calldataload(add(signature.offset, 0x40))) + } + } else { + return INVALID_SIGNATURE_LENGTH; + } + + if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) { + return INVALID_S_PARAMETER_EOA; + } + + if (v != 27 && v != 28) { + return INVALID_V_PARAMETER_EOA; + } + + address recoveredSigner = ecrecover(hash, v, r, s); + + if (recoveredSigner == address(0)) { + return NULL_SIGNER_EOA; + } + + if (signer != recoveredSigner) { + return INVALID_SIGNER_EOA; + } + } else { + // Logic if ERC1271 + (bool success, bytes memory data) = + signer.staticcall(abi.encodeCall(IERC1271.isValidSignature, (hash, signature))); + + if (!success) { + return MISSING_IS_VALID_SIGNATURE_FUNCTION_EIP1271; + } + + if (abi.decode(data, (bytes4)) != IERC1271.isValidSignature.selector) { + return SIGNATURE_INVALID_EIP1271; + } + } + } + + /** + * @dev This function checks if transfer manager approvals are not revoked by user, nor by the owner + * @param user Address of the user + * @return validationCode Validation code + */ + function _checkValidityTransferManagerApprovals(address user) private view returns (uint256 validationCode) { + if (!transferManager.hasUserApprovedOperator(user, address(looksRareProtocol))) { + return NO_TRANSFER_MANAGER_APPROVAL_BY_USER_FOR_EXCHANGE; + } + + if (!transferManager.isOperatorAllowed(address(looksRareProtocol))) { + return TRANSFER_MANAGER_APPROVAL_REVOKED_BY_OWNER_FOR_EXCHANGE; + } + } + + function _checkValidityMakerAskItemIdsAndAmountsAndPrice(OrderStructs.Maker memory makerAsk) + private + view + returns (uint256 validationCode, uint256[] memory itemIds, uint256[] memory amounts, uint256 price) + { + if (makerAsk.strategyId == 0) { + itemIds = makerAsk.itemIds; + amounts = makerAsk.amounts; + price = makerAsk.price; + + validationCode = + _getOrderValidationCodeForStandardStrategy(makerAsk.collectionType, itemIds.length, amounts); + } else { + itemIds = makerAsk.itemIds; + amounts = makerAsk.amounts; + // @dev It should ideally be adjusted by real price + price = makerAsk.price; + + (,,,, bytes4 strategySelector,, address strategyImplementation) = + looksRareProtocol.strategyInfo(makerAsk.strategyId); + + (bool isValid, bytes4 errorSelector) = + IStrategy(strategyImplementation).isMakerOrderValid(makerAsk, strategySelector); + + validationCode = _getOrderValidationCodeForNonStandardStrategies(isValid, errorSelector); + } + } + + function _checkValidityMakerBidItemIdsAndAmountsAndPrice(OrderStructs.Maker memory makerBid) + private + view + returns (uint256 validationCode, uint256[] memory itemIds, uint256[] memory amounts, uint256 price) + { + if (makerBid.strategyId == 0) { + itemIds = makerBid.itemIds; + amounts = makerBid.amounts; + price = makerBid.price; + + validationCode = + _getOrderValidationCodeForStandardStrategy(makerBid.collectionType, itemIds.length, amounts); + } else { + // @dev It should ideally be adjusted by real price + // amounts and itemIds are not used since most non-native maker bids won't target a single item + price = makerBid.price; + + (,,,, bytes4 strategySelector,, address strategyImplementation) = + looksRareProtocol.strategyInfo(makerBid.strategyId); + + (bool isValid, bytes4 errorSelector) = + IStrategy(strategyImplementation).isMakerOrderValid(makerBid, strategySelector); + + validationCode = _getOrderValidationCodeForNonStandardStrategies(isValid, errorSelector); + } + } + + /** + * @notice This function checks if the same itemId is repeated + * in an array of item ids. + * @param itemIds Array of item ids + * @dev This is for bundles. + * For example, if itemIds = [1,2,1], it will return SAME_ITEM_ID_IN_BUNDLE. + * @return validationCode Validation code + */ + function _checkIfItemIdsDiffer(uint256[] memory itemIds) private pure returns (uint256 validationCode) { + uint256 length = itemIds.length; + + // Only check if length of array is greater than 1 + if (length > 1) { + for (uint256 i = 0; i < length - 1;) { + for (uint256 j = i + 1; j < length;) { + if (itemIds[i] == itemIds[j]) { + return SAME_ITEM_ID_IN_BUNDLE; + } + + unchecked { + ++j; + } + } + + unchecked { + ++i; + } + } + } + } + + function _getOrderValidationCodeForStandardStrategy( + CollectionType collectionType, + uint256 expectedLength, + uint256[] memory amounts + ) private pure returns (uint256 validationCode) { + if (expectedLength == 0 || (amounts.length != expectedLength)) { + validationCode = MAKER_ORDER_INVALID_STANDARD_SALE; + } else { + for (uint256 i; i < expectedLength;) { + uint256 amount = amounts[i]; + + if (amount == 0) { + validationCode = MAKER_ORDER_INVALID_STANDARD_SALE; + } + + if (collectionType == CollectionType.ERC721 && amount != 1) { + validationCode = MAKER_ORDER_INVALID_STANDARD_SALE; + } + + unchecked { + ++i; + } + } + } + } + + function _getOrderValidationCodeForNonStandardStrategies(bool isValid, bytes4 errorSelector) + private + pure + returns (uint256 validationCode) + { + if (isValid) { + validationCode = ORDER_EXPECTED_TO_BE_VALID; + } else { + if (errorSelector == OrderInvalid.selector) { + validationCode = MAKER_ORDER_PERMANENTLY_INVALID_NON_STANDARD_SALE; + } else { + validationCode = MAKER_ORDER_TEMPORARILY_INVALID_NON_STANDARD_SALE; + } + } + } +} diff --git a/contracts/src/marketplace/helpers/ProtocolHelpers.sol b/contracts/src/marketplace/helpers/ProtocolHelpers.sol new file mode 100644 index 00000000..99c37c0d --- /dev/null +++ b/contracts/src/marketplace/helpers/ProtocolHelpers.sol @@ -0,0 +1,89 @@ +// SPDX-License-Identifier: MIT +pragma solidity 0.8.17; + +// LooksRare unopinionated libraries +import {SignatureCheckerCalldata} from "@looksrare/contracts-libs/contracts/SignatureCheckerCalldata.sol"; + +// Libraries +import {OrderStructs} from "../libraries/OrderStructs.sol"; + +// Other dependencies +import {LooksRareProtocol} from "../LooksRareProtocol.sol"; + +/** + * @title ProtocolHelpers + * @notice This contract contains helper view functions for order creation. + * @author LooksRare protocol team (👀,💎) + */ +contract ProtocolHelpers { + using OrderStructs for OrderStructs.Maker; + + // Encoding prefix for EIP-712 signatures + string internal constant _ENCODING_PREFIX = "\x19\x01"; + + // LooksRareProtocol + LooksRareProtocol public looksRareProtocol; + + /** + * @notice Constructor + * @param _looksRareProtocol LooksRare protocol address + */ + constructor(address _looksRareProtocol) { + looksRareProtocol = LooksRareProtocol(_looksRareProtocol); + } + + /** + * @notice Compute digest for maker bid struct + * @param maker Maker struct + * @return digest Digest + */ + function computeMakerDigest(OrderStructs.Maker memory maker) public view returns (bytes32 digest) { + bytes32 domainSeparator = looksRareProtocol.domainSeparator(); + return keccak256(abi.encodePacked(_ENCODING_PREFIX, domainSeparator, maker.hash())); + } + + /** + * @notice Compute digest for merkle tree struct + * @param merkleTree Merkle tree struct + * @return digest Digest + */ + function computeDigestMerkleTree(OrderStructs.MerkleTree memory merkleTree) public view returns (bytes32 digest) { + bytes32 domainSeparator = looksRareProtocol.domainSeparator(); + bytes32 batchOrderHash = looksRareProtocol.hashBatchOrder(merkleTree.root, merkleTree.proof.length); + return keccak256(abi.encodePacked(_ENCODING_PREFIX, domainSeparator, batchOrderHash)); + } + + /** + * @notice Verify maker order signature + * @param maker Maker struct + * @param makerSignature Maker signature + * @param signer Signer address + * @dev It returns true only if the SignatureCheckerCalldata does not revert before. + */ + function verifyMakerSignature(OrderStructs.Maker memory maker, bytes calldata makerSignature, address signer) + public + view + returns (bool) + { + bytes32 digest = computeMakerDigest(maker); + SignatureCheckerCalldata.verify(digest, signer, makerSignature); + return true; + } + + /** + * @notice Verify merkle tree signature + * @param merkleTree Merkle tree struct + * @param makerSignature Maker signature + * @param signer Signer address + * @dev It returns true only if the SignatureCheckerCalldata does not revert before. + */ + function verifyMerkleTree(OrderStructs.MerkleTree memory merkleTree, bytes calldata makerSignature, address signer) + public + view + returns (bool) + { + bytes32 digest = computeDigestMerkleTree(merkleTree); + SignatureCheckerCalldata.verify(digest, signer, makerSignature); + return true; + } +} diff --git a/contracts/src/marketplace/interfaces/ICreatorFeeManager.sol b/contracts/src/marketplace/interfaces/ICreatorFeeManager.sol new file mode 100644 index 00000000..6b6728e7 --- /dev/null +++ b/contracts/src/marketplace/interfaces/ICreatorFeeManager.sol @@ -0,0 +1,35 @@ +// SPDX-License-Identifier: MIT +pragma solidity 0.8.17; + +// Interfaces +import {IRoyaltyFeeRegistry} from "./IRoyaltyFeeRegistry.sol"; + +/** + * @title ICreatorFeeManager + * @author LooksRare protocol team (👀,💎) + */ +interface ICreatorFeeManager { + /** + * @notice It is returned if the bundle contains multiple itemIds with different creator fee structure. + */ + error BundleEIP2981NotAllowed(address collection); + + /** + * @notice It returns the royalty fee registry address/interface. + * @return royaltyFeeRegistry Interface of the royalty fee registry + */ + function royaltyFeeRegistry() external view returns (IRoyaltyFeeRegistry royaltyFeeRegistry); + + /** + * @notice This function returns the creator address and calculates the creator fee amount. + * @param collection Collection address + * @param price Transaction price + * @param itemIds Array of item ids + * @return creator Creator address + * @return creatorFeeAmount Creator fee amount + */ + function viewCreatorFeeInfo(address collection, uint256 price, uint256[] memory itemIds) + external + view + returns (address creator, uint256 creatorFeeAmount); +} diff --git a/contracts/src/marketplace/interfaces/ICurrencyManager.sol b/contracts/src/marketplace/interfaces/ICurrencyManager.sol new file mode 100644 index 00000000..72d50d2e --- /dev/null +++ b/contracts/src/marketplace/interfaces/ICurrencyManager.sol @@ -0,0 +1,15 @@ +// SPDX-License-Identifier: MIT +pragma solidity 0.8.17; + +/** + * @title ICurrencyManager + * @author LooksRare protocol team (👀,💎) + */ +interface ICurrencyManager { + /** + * @notice It is emitted if the currency status in the allowlist is updated. + * @param currency Currency address (address(0) = ETH) + * @param isAllowed Whether the currency is allowed + */ + event CurrencyStatusUpdated(address currency, bool isAllowed); +} diff --git a/contracts/src/marketplace/interfaces/IExecutionManager.sol b/contracts/src/marketplace/interfaces/IExecutionManager.sol new file mode 100644 index 00000000..945637b5 --- /dev/null +++ b/contracts/src/marketplace/interfaces/IExecutionManager.sol @@ -0,0 +1,53 @@ +// SPDX-License-Identifier: MIT +pragma solidity 0.8.17; + +/** + * @title IExecutionManager + * @author LooksRare protocol team (👀,💎) + */ +interface IExecutionManager { + /** + * @notice It is issued when there is a new creator fee manager. + * @param creatorFeeManager Address of the new creator fee manager + */ + event NewCreatorFeeManager(address creatorFeeManager); + + /** + * @notice It is issued when there is a new maximum creator fee (in basis point). + * @param maxCreatorFeeBp New maximum creator fee (in basis point) + */ + event NewMaxCreatorFeeBp(uint256 maxCreatorFeeBp); + + /** + * @notice It is issued when there is a new protocol fee recipient address. + * @param protocolFeeRecipient Address of the new protocol fee recipient + */ + event NewProtocolFeeRecipient(address protocolFeeRecipient); + + /** + * @notice It is returned if the creator fee (in basis point) is too high. + */ + error CreatorFeeBpTooHigh(); + + /** + * @notice It is returned if the new protocol fee recipient is set to address(0). + */ + error NewProtocolFeeRecipientCannotBeNullAddress(); + + /** + * @notice It is returned if there is no selector for maker ask/bid for a given strategyId, + * depending on the quote type. + */ + error NoSelectorForStrategy(); + + /** + * @notice It is returned if the current block timestamp is not between start and end times in the maker order. + */ + error OutsideOfTimeRange(); + + /** + * @notice It is returned if the strategy id has no implementation. + * @dev It is returned if there is no implementation address and the strategyId is strictly greater than 0. + */ + error StrategyNotAvailable(uint256 strategyId); +} diff --git a/contracts/src/marketplace/interfaces/IImmutableCreate2Factory.sol b/contracts/src/marketplace/interfaces/IImmutableCreate2Factory.sol new file mode 100644 index 00000000..efbecb66 --- /dev/null +++ b/contracts/src/marketplace/interfaces/IImmutableCreate2Factory.sol @@ -0,0 +1,9 @@ +// SPDX-License-Identifier: MIT +pragma solidity 0.8.17; + +interface IImmutableCreate2Factory { + function safeCreate2(bytes32 salt, bytes calldata initializationCode) + external + payable + returns (address deploymentAddress); +} diff --git a/contracts/src/marketplace/interfaces/ILooksRareProtocol.sol b/contracts/src/marketplace/interfaces/ILooksRareProtocol.sol new file mode 100644 index 00000000..e2a52119 --- /dev/null +++ b/contracts/src/marketplace/interfaces/ILooksRareProtocol.sol @@ -0,0 +1,166 @@ +// SPDX-License-Identifier: MIT +pragma solidity 0.8.17; + +// Libraries +import {OrderStructs} from "../libraries/OrderStructs.sol"; + +/** + * @title ILooksRareProtocol + * @author LooksRare protocol team (👀,💎) + */ +interface ILooksRareProtocol { + /** + * @notice This struct contains an order nonce's invalidation status + * and the order hash that triggered the status change. + * @param orderHash Maker order hash + * @param orderNonce Order nonce + * @param isNonceInvalidated Whether this transaction invalidated the maker user's order nonce at the protocol level + */ + struct NonceInvalidationParameters { + bytes32 orderHash; + uint256 orderNonce; + bool isNonceInvalidated; + } + + /** + * @notice It is emitted if there is a change in the domain separator. + */ + event NewDomainSeparator(); + + /** + * @notice It is emitted when there is a new gas limit for a ETH transfer (before it is wrapped to WETH). + * @param gasLimitETHTransfer Gas limit for an ETH transfer + */ + event NewGasLimitETHTransfer(uint256 gasLimitETHTransfer); + + /** + * @notice It is emitted when a taker ask transaction is completed. + * @param nonceInvalidationParameters Struct about nonce invalidation parameters + * @param askUser Address of the ask user + * @param bidUser Address of the bid user + * @param strategyId Id of the strategy + * @param currency Address of the currency + * @param collection Address of the collection + * @param itemIds Array of item ids + * @param amounts Array of amounts (for item ids) + * @param feeRecipients Array of fee recipients + * feeRecipients[0] User who receives the proceeds of the sale (it can be the taker ask user or different) + * feeRecipients[1] Creator fee recipient (if none, address(0)) + * @param feeAmounts Array of fee amounts + * feeAmounts[0] Fee amount for the user receiving sale proceeds + * feeAmounts[1] Creator fee amount + * feeAmounts[2] Protocol fee amount prior to adjustment for a potential affiliate payment + */ + // maker (receives the NFT) + // taker (initiates the transaction) + event TakerAsk( + NonceInvalidationParameters nonceInvalidationParameters, + address askUser, + address bidUser, + uint256 strategyId, + address currency, + address collection, + uint256[] itemIds, + uint256[] amounts, + address[2] feeRecipients, + uint256[3] feeAmounts + ); + + /** + * @notice It is emitted when a taker bid transaction is completed. + * @param nonceInvalidationParameters Struct about nonce invalidation parameters + * @param bidUser Address of the bid user + * @param bidRecipient Address of the recipient of the bid + * @param strategyId Id of the strategy + * @param currency Address of the currency + * @param collection Address of the collection + * @param itemIds Array of item ids + * @param amounts Array of amounts (for item ids) + * @param feeRecipients Array of fee recipients + * feeRecipients[0] User who receives the proceeds of the sale (it is the maker ask user) + * feeRecipients[1] Creator fee recipient (if none, address(0)) + * @param feeAmounts Array of fee amounts + * feeAmounts[0] Fee amount for the user receiving sale proceeds + * feeAmounts[1] Creator fee amount + * feeAmounts[2] Protocol fee amount prior to adjustment for a potential affiliate payment + */ + // taker (receives the NFT) + // taker (initiates the transaction) + event TakerBid( + NonceInvalidationParameters nonceInvalidationParameters, + address bidUser, + address bidRecipient, + uint256 strategyId, + address currency, + address collection, + uint256[] itemIds, + uint256[] amounts, + address[2] feeRecipients, + uint256[3] feeAmounts + ); + + /** + * @notice It is returned if the gas limit for a standard ETH transfer is too low. + */ + error NewGasLimitETHTransferTooLow(); + + /** + * @notice It is returned if the domain separator cannot be updated (i.e. the chainId is the same). + */ + error SameDomainSeparator(); + + /** + * @notice It is returned if the domain separator should change. + */ + error ChainIdInvalid(); + + /** + * @notice It is returned if the nonces are invalid. + */ + error NoncesInvalid(); + + /** + * @notice This function allows a user to execute a taker ask (against a maker bid). + * @param takerAsk Taker ask struct + * @param makerBid Maker bid struct + * @param makerSignature Maker signature + * @param merkleTree Merkle tree struct (if the signature contains multiple maker orders) + */ + function executeTakerAsk( + OrderStructs.Taker calldata takerAsk, + OrderStructs.Maker calldata makerBid, + bytes calldata makerSignature, + OrderStructs.MerkleTree calldata merkleTree + ) external; + + /** + * @notice This function allows a user to execute a taker bid (against a maker ask). + * @param takerBid Taker bid struct + * @param makerAsk Maker ask struct + * @param makerSignature Maker signature + * @param merkleTree Merkle tree struct (if the signature contains multiple maker orders) + */ + function executeTakerBid( + OrderStructs.Taker calldata takerBid, + OrderStructs.Maker calldata makerAsk, + bytes calldata makerSignature, + OrderStructs.MerkleTree calldata merkleTree + ) external payable; + + /** + * @notice This function allows a user to batch buy with an array of taker bids (against an array of maker asks). + * @param takerBids Array of taker bid structs + * @param makerAsks Array of maker ask structs + * @param makerSignatures Array of maker signatures + * @param merkleTrees Array of merkle tree structs if the signature contains multiple maker orders + * @param isAtomic Whether the execution should be atomic + * i.e. whether it should revert if 1 or more transactions fail + */ + function executeMultipleTakerBids( + OrderStructs.Taker[] calldata takerBids, + OrderStructs.Maker[] calldata makerAsks, + bytes[] calldata makerSignatures, + OrderStructs.MerkleTree[] calldata merkleTrees, + bool isAtomic + ) external payable; +} diff --git a/contracts/src/marketplace/interfaces/INonceManager.sol b/contracts/src/marketplace/interfaces/INonceManager.sol new file mode 100644 index 00000000..6011291d --- /dev/null +++ b/contracts/src/marketplace/interfaces/INonceManager.sol @@ -0,0 +1,40 @@ +// SPDX-License-Identifier: MIT +pragma solidity 0.8.17; + +/** + * @title INonceManager + * @author LooksRare protocol team (👀,💎) + */ +interface INonceManager { + /** + * @notice This struct contains the global bid and ask nonces of a user. + * @param bidNonce Bid nonce + * @param askNonce Ask nonce + */ + struct UserBidAskNonces { + uint256 bidNonce; + uint256 askNonce; + } + + /** + * @notice It is emitted when there is an update of the global bid/ask nonces for a user. + * @param user Address of the user + * @param bidNonce New bid nonce + * @param askNonce New ask nonce + */ + event NewBidAskNonces(address user, uint256 bidNonce, uint256 askNonce); + + /** + * @notice It is emitted when order nonces are cancelled for a user. + * @param user Address of the user + * @param orderNonces Array of order nonces cancelled + */ + event OrderNoncesCancelled(address user, uint256[] orderNonces); + + /** + * @notice It is emitted when subset nonces are cancelled for a user. + * @param user Address of the user + * @param subsetNonces Array of subset nonces cancelled + */ + event SubsetNoncesCancelled(address user, uint256[] subsetNonces); +} diff --git a/contracts/src/marketplace/interfaces/IRoyaltyFeeRegistry.sol b/contracts/src/marketplace/interfaces/IRoyaltyFeeRegistry.sol new file mode 100644 index 00000000..766d4603 --- /dev/null +++ b/contracts/src/marketplace/interfaces/IRoyaltyFeeRegistry.sol @@ -0,0 +1,20 @@ +// SPDX-License-Identifier: MIT +pragma solidity 0.8.17; + +/** + * @title IRoyaltyFeeRegistry + * @author LooksRare protocol team (👀,💎) + */ +interface IRoyaltyFeeRegistry { + /** + * @notice This function returns the royalty information for a collection at a given transaction price. + * @param collection Collection address + * @param price Transaction price + * @return receiver Receiver address + * @return royaltyFee Royalty fee amount + */ + function royaltyInfo(address collection, uint256 price) + external + view + returns (address receiver, uint256 royaltyFee); +} diff --git a/contracts/src/marketplace/interfaces/IStrategy.sol b/contracts/src/marketplace/interfaces/IStrategy.sol new file mode 100644 index 00000000..a9b7e450 --- /dev/null +++ b/contracts/src/marketplace/interfaces/IStrategy.sol @@ -0,0 +1,30 @@ +// SPDX-License-Identifier: MIT +pragma solidity 0.8.17; + +// Libraries +import {OrderStructs} from "../libraries/OrderStructs.sol"; + +/** + * @title IStrategy + * @author LooksRare protocol team (👀,💎) + */ +interface IStrategy { + /** + * @notice Validate *only the maker* order under the context of the chosen strategy. It does not revert if + * the maker order is invalid. Instead it returns false and the error's 4 bytes selector. + * @param makerOrder Maker struct (maker specific parameters for the execution) + * @param functionSelector Function selector for the strategy + * @return isValid Whether the maker struct is valid + * @return errorSelector If isValid is false, it returns the error's 4 bytes selector + */ + function isMakerOrderValid(OrderStructs.Maker calldata makerOrder, bytes4 functionSelector) + external + view + returns (bool isValid, bytes4 errorSelector); + + /** + * @notice This function acts as a safety check for the protocol's owner when adding new execution strategies. + * @return isStrategy Whether it is a LooksRare V2 protocol strategy + */ + function isLooksRareV2Strategy() external pure returns (bool isStrategy); +} diff --git a/contracts/src/marketplace/interfaces/IStrategyManager.sol b/contracts/src/marketplace/interfaces/IStrategyManager.sol new file mode 100644 index 00000000..283431a2 --- /dev/null +++ b/contracts/src/marketplace/interfaces/IStrategyManager.sol @@ -0,0 +1,80 @@ +// SPDX-License-Identifier: MIT +pragma solidity 0.8.17; + +/** + * @title IStrategyManager + * @author LooksRare protocol team (👀,💎) + */ +interface IStrategyManager { + /** + * @notice This struct contains the parameter of an execution strategy. + * @param strategyId Id of the new strategy + * @param standardProtocolFeeBp Standard protocol fee (in basis point) + * @param minTotalFeeBp Minimum total fee (in basis point) + * @param maxProtocolFeeBp Maximum protocol fee (in basis point) + * @param selector Function selector for the transaction to be executed + * @param isMakerBid Whether the strategyId is for maker bid + * @param implementation Address of the implementation of the strategy + */ + struct Strategy { + bool isActive; + uint16 standardProtocolFeeBp; + uint16 minTotalFeeBp; + uint16 maxProtocolFeeBp; + bytes4 selector; + bool isMakerBid; + address implementation; + } + + /** + * @notice It is emitted when a new strategy is added. + * @param strategyId Id of the new strategy + * @param standardProtocolFeeBp Standard protocol fee (in basis point) + * @param minTotalFeeBp Minimum total fee (in basis point) + * @param maxProtocolFeeBp Maximum protocol fee (in basis point) + * @param selector Function selector for the transaction to be executed + * @param isMakerBid Whether the strategyId is for maker bid + * @param implementation Address of the implementation of the strategy + */ + event NewStrategy( + uint256 strategyId, + uint16 standardProtocolFeeBp, + uint16 minTotalFeeBp, + uint16 maxProtocolFeeBp, + bytes4 selector, + bool isMakerBid, + address implementation + ); + + /** + * @notice It is emitted when an existing strategy is updated. + * @param strategyId Id of the strategy + * @param isActive Whether the strategy is active (or not) after the update + * @param standardProtocolFeeBp Standard protocol fee (in basis point) + * @param minTotalFeeBp Minimum total fee (in basis point) + */ + event StrategyUpdated(uint256 strategyId, bool isActive, uint16 standardProtocolFeeBp, uint16 minTotalFeeBp); + + /** + * @notice If the strategy has not set properly its implementation contract. + * @dev It can only be returned for owner operations. + */ + error NotV2Strategy(); + + /** + * @notice It is returned if the strategy has no selector. + * @dev It can only be returned for owner operations. + */ + error StrategyHasNoSelector(); + + /** + * @notice It is returned if the strategyId is invalid. + */ + error StrategyNotUsed(); + + /** + * @notice It is returned if the strategy's protocol fee is too high. + * @dev It can only be returned for owner operations. + */ + error StrategyProtocolFeeTooHigh(); +} diff --git a/contracts/src/marketplace/interfaces/ITransferManager.sol b/contracts/src/marketplace/interfaces/ITransferManager.sol new file mode 100644 index 00000000..8f19f9a4 --- /dev/null +++ b/contracts/src/marketplace/interfaces/ITransferManager.sol @@ -0,0 +1,84 @@ +// SPDX-License-Identifier: MIT +pragma solidity 0.8.17; + +// Libraries +import {OrderStructs} from "../libraries/OrderStructs.sol"; + +// Enums +import {CollectionType} from "../enums/CollectionType.sol"; + +/** + * @title ITransferManager + * @author LooksRare protocol team (👀,💎) + */ +interface ITransferManager { + /** + * @notice This struct is only used for transferBatchItemsAcrossCollections. + * @param collection Collection address + * @param collectionType 0 for ERC721, 1 for ERC1155 + * @param itemIds Array of item ids to transfer + * @param amounts Array of amounts to transfer + */ + struct BatchTransferItem { + address collection; + CollectionType collectionType; + uint256[] itemIds; + uint256[] amounts; + } + + /** + * @notice It is emitted if operators' approvals to transfer NFTs are granted by a user. + * @param user Address of the user + * @param operators Array of operator addresses + */ + event ApprovalsGranted(address user, address[] operators); + + /** + * @notice It is emitted if operators' approvals to transfer NFTs are revoked by a user. + * @param user Address of the user + * @param operators Array of operator addresses + */ + event ApprovalsRemoved(address user, address[] operators); + + /** + * @notice It is emitted if a new operator is added to the global allowlist. + * @param operator Operator address + */ + event OperatorAllowed(address operator); + + /** + * @notice It is emitted if an operator is removed from the global allowlist. + * @param operator Operator address + */ + event OperatorRemoved(address operator); + + /** + * @notice It is returned if the operator to approve has already been approved by the user. + */ + error OperatorAlreadyApprovedByUser(); + + /** + * @notice It is returned if the operator to revoke has not been previously approved by the user. + */ + error OperatorNotApprovedByUser(); + + /** + * @notice It is returned if the transfer caller is already allowed by the owner. + * @dev This error can only be returned for owner operations. + */ + error OperatorAlreadyAllowed(); + + /** + * @notice It is returned if the operator to approve is not in the global allowlist defined by the owner. + * @dev This error can be returned if the user tries to grant approval to an operator address not in the + * allowlist or if the owner tries to remove the operator from the global allowlist. + */ + error OperatorNotAllowed(); + + /** + * @notice It is returned if the transfer caller is invalid. + * For a transfer called to be valid, the operator must be in the global allowlist and + * approved by the 'from' user. + */ + error TransferCallerInvalid(); +} diff --git a/contracts/src/marketplace/libraries/CurrencyValidator.sol b/contracts/src/marketplace/libraries/CurrencyValidator.sol new file mode 100644 index 00000000..61208646 --- /dev/null +++ b/contracts/src/marketplace/libraries/CurrencyValidator.sol @@ -0,0 +1,38 @@ +// SPDX-License-Identifier: MIT +pragma solidity 0.8.17; + +// Assembly +import { + CurrencyInvalid_error_selector, + CurrencyInvalid_error_length, + Error_selector_offset +} from "../constants/AssemblyConstants.sol"; + +/** + * @title CurrencyValidator + * @notice This library validates the order currency to be the + * chain's native currency or the specified ERC20 token. + * @author LooksRare protocol team (👀,💎) + */ +library CurrencyValidator { + /** + * @dev This is equivalent to + * if (orderCurrency != address(0)) { + * if (orderCurrency != allowedCurrency) { + * revert CurrencyInvalid(); + * } + * } + * + * 1. If orderCurrency == WETH, allowedCurrency == WETH -> WETH * 0 == 0 + * 2. If orderCurrency == ETH, allowedCurrency == WETH -> 0 * 1 == 0 + * 3. If orderCurrency == USDC, allowedCurrency == WETH -> USDC * 1 != 0 + */ + function allowNativeOrAllowedCurrency(address orderCurrency, address allowedCurrency) internal pure { + assembly { + if mul(orderCurrency, iszero(eq(orderCurrency, allowedCurrency))) { + mstore(0x00, CurrencyInvalid_error_selector) + revert(Error_selector_offset, CurrencyInvalid_error_length) + } + } + } +} diff --git a/contracts/src/marketplace/libraries/OpenZeppelin/MerkleProofCalldataWithNodes.sol b/contracts/src/marketplace/libraries/OpenZeppelin/MerkleProofCalldataWithNodes.sol new file mode 100644 index 00000000..f3af4e8b --- /dev/null +++ b/contracts/src/marketplace/libraries/OpenZeppelin/MerkleProofCalldataWithNodes.sol @@ -0,0 +1,61 @@ +// SPDX-License-Identifier: MIT +pragma solidity 0.8.17; + +// Libraries +import {OrderStructs} from "../../libraries/OrderStructs.sol"; + +/** + * @title MerkleProofCalldataWithNodes + * @notice This library is adjusted from the work of OpenZeppelin. + * It is based on the 4.7.0 (utils/cryptography/MerkleProof.sol). + * @author OpenZeppelin (adjusted by LooksRare) + */ +library MerkleProofCalldataWithNodes { + /** + * @notice This returns true if a `leaf` can be proved to be a part of a Merkle tree defined by `root`. + * For this, a `proof` must be provided, containing sibling hashes on the branch from the leaf to the + * root of the tree. Each pair of leaves and each pair of pre-images are assumed to be sorted. + */ + function verifyCalldata(OrderStructs.MerkleTreeNode[] calldata proof, bytes32 root, bytes32 leaf) + internal + pure + returns (bool) + { + return processProofCalldata(proof, leaf) == root; + } + + /** + * @notice This returns the rebuilt hash obtained by traversing a Merkle tree up from `leaf` using `proof`. + * A `proof` is valid if and only if the rebuilt hash matches the root of the tree. + * When processing the proof, the pairs of leafs & pre-images are assumed to be sorted. + */ + function processProofCalldata(OrderStructs.MerkleTreeNode[] calldata proof, bytes32 leaf) + internal + pure + returns (bytes32) + { + bytes32 computedHash = leaf; + uint256 length = proof.length; + + for (uint256 i = 0; i < length;) { + if (proof[i].position == OrderStructs.MerkleTreeNodePosition.Left) { + computedHash = _efficientHash(proof[i].value, computedHash); + } else { + computedHash = _efficientHash(computedHash, proof[i].value); + } + unchecked { + ++i; + } + } + return computedHash; + } + + function _efficientHash(bytes32 a, bytes32 b) private pure returns (bytes32 value) { + /// @solidity memory-safe-assembly + assembly { + mstore(0x00, a) + mstore(0x20, b) + value := keccak256(0x00, 0x40) + } + } +} diff --git a/contracts/src/marketplace/libraries/OpenZeppelin/MerkleProofMemory.sol b/contracts/src/marketplace/libraries/OpenZeppelin/MerkleProofMemory.sol new file mode 100644 index 00000000..02ab8737 --- /dev/null +++ b/contracts/src/marketplace/libraries/OpenZeppelin/MerkleProofMemory.sol @@ -0,0 +1,51 @@ +// SPDX-License-Identifier: MIT +pragma solidity 0.8.17; + +/** + * @title MerkleProofMemory + * @notice This library is adjusted from the work of OpenZeppelin. + * It is based on the 4.7.0 (utils/cryptography/MerkleProof.sol). + * @author OpenZeppelin (adjusted by LooksRare) + */ +// TODO compare changes with OpenZeppelin +library MerkleProofMemory { + /** + * @notice This returns true if a `leaf` can be proved to be a part of a Merkle tree defined by `root`. + * For this, a `proof` must be provided, containing sibling hashes on the branch from the leaf to the + * root of the tree. Each pair of leaves and each pair of pre-images are assumed to be sorted. + */ + function verify(bytes32[] memory proof, bytes32 root, bytes32 leaf) internal pure returns (bool) { + return processProof(proof, leaf) == root; + } + + /** + * @notice This returns the rebuilt hash obtained by traversing a Merkle tree up from `leaf` using `proof`. + * A `proof` is valid if and only if the rebuilt hash matches the root of the tree. + * When processing the proof, the pairs of leafs & pre-images are assumed to be sorted. + */ + function processProof(bytes32[] memory proof, bytes32 leaf) internal pure returns (bytes32) { + bytes32 computedHash = leaf; + uint256 length = proof.length; + + for (uint256 i = 0; i < length;) { + computedHash = _hashPair(computedHash, proof[i]); + unchecked { + ++i; + } + } + return computedHash; + } + + function _hashPair(bytes32 a, bytes32 b) private pure returns (bytes32) { + return a < b ? _efficientHash(a, b) : _efficientHash(b, a); + } + + function _efficientHash(bytes32 a, bytes32 b) private pure returns (bytes32 value) { + /// @solidity memory-safe-assembly + assembly { + mstore(0x00, a) + mstore(0x20, b) + value := keccak256(0x00, 0x40) + } + } +} diff --git a/contracts/src/marketplace/libraries/OrderStructs.sol b/contracts/src/marketplace/libraries/OrderStructs.sol new file mode 100644 index 00000000..19b3a88d --- /dev/null +++ b/contracts/src/marketplace/libraries/OrderStructs.sol @@ -0,0 +1,152 @@ +// SPDX-License-Identifier: MIT +pragma solidity 0.8.17; + +// Enums +import {CollectionType} from "../enums/CollectionType.sol"; +import {QuoteType} from "../enums/QuoteType.sol"; + +/** + * @title OrderStructs + * @notice This library contains all order struct types for the LooksRare protocol (v2). + * @author LooksRare protocol team (👀,💎) + */ +library OrderStructs { + /** + * 1. Maker struct + */ + + /** + * @notice Maker is the struct for a maker order. + * @param quoteType Quote type (i.e. 0 = BID, 1 = ASK) + * @param globalNonce Global user order nonce for maker orders + * @param subsetNonce Subset nonce (shared across bid/ask maker orders) + * @param orderNonce Order nonce (it can be shared across bid/ask maker orders) + * @param strategyId Strategy id + * @param collectionType Collection type (i.e. 0 = ERC721, 1 = ERC1155, 2 = Hypercert, 3 = Hyperboard) + * @param collection Collection address + * @param currency Currency address (@dev address(0) = ETH) + * @param signer Signer address + * @param startTime Start timestamp + * @param endTime End timestamp + * @param price Minimum price for maker ask, maximum price for maker bid + * @param itemIds Array of itemIds + * @param amounts Array of amounts + * @param additionalParameters Extra data specific for the order + */ + struct Maker { + QuoteType quoteType; + uint256 globalNonce; + uint256 subsetNonce; + uint256 orderNonce; + uint256 strategyId; + CollectionType collectionType; + address collection; + address currency; + address signer; + uint256 startTime; + uint256 endTime; + uint256 price; + uint256[] itemIds; + uint256[] amounts; + bytes additionalParameters; + } + + /** + * 2. Taker struct + */ + + /** + * @notice Taker is the struct for a taker ask/bid order. It contains the parameters required for a direct purchase. + * @dev Taker struct is matched against MakerAsk/MakerBid structs at the protocol level. + * @param recipient Recipient address (to receive NFTs or non-fungible tokens) + * @param additionalParameters Extra data specific for the order + */ + struct Taker { + address recipient; + bytes additionalParameters; + } + + /** + * 3. Merkle tree struct + */ + + enum MerkleTreeNodePosition { + Left, + Right + } + + /** + * @notice MerkleTreeNode is a MerkleTree's node. + * @param value It can be an order hash or a proof + * @param position The node's position in its branch. + * It can be left or right or none + * (before the tree is sorted). + */ + struct MerkleTreeNode { + bytes32 value; + MerkleTreeNodePosition position; + } + + /** + * @notice MerkleTree is the struct for a merkle tree of order hashes. + * @dev A Merkle tree can be computed with order hashes. + * It can contain order hashes from both maker bid and maker ask structs. + * @param root Merkle root + * @param proof Array containing the merkle proof + */ + struct MerkleTree { + bytes32 root; + MerkleTreeNode[] proof; + } + + /** + * 4. Constants + */ + + /** + * @notice This is the type hash constant used to compute the maker order hash. + */ + bytes32 internal constant _MAKER_TYPEHASH = keccak256( + "Maker(" "uint8 quoteType," "uint256 globalNonce," "uint256 subsetNonce," "uint256 orderNonce," + "uint256 strategyId," "uint8 collectionType," "address collection," "address currency," "address signer," + "uint256 startTime," "uint256 endTime," "uint256 price," "uint256[] itemIds," "uint256[] amounts," + "bytes additionalParameters" ")" + ); + + /** + * 5. Hash functions + */ + + /** + * @notice This function is used to compute the order hash for a maker struct. + * @param maker Maker order struct + * @return makerHash Hash of the maker struct + */ + function hash(Maker memory maker) internal pure returns (bytes32) { + // Encoding is done into two parts to avoid stack too deep issues + return keccak256( + bytes.concat( + abi.encode( + _MAKER_TYPEHASH, + maker.quoteType, + maker.globalNonce, + maker.subsetNonce, + maker.orderNonce, + maker.strategyId, + maker.collectionType, + maker.collection, + maker.currency + ), + abi.encode( + maker.signer, + maker.startTime, + maker.endTime, + maker.price, + keccak256(abi.encodePacked(maker.itemIds)), + keccak256(abi.encodePacked(maker.amounts)), + keccak256(maker.additionalParameters) + ) + ) + ); + } +} diff --git a/contracts/src/AllowlistMinter.sol b/contracts/src/protocol/AllowlistMinter.sol similarity index 83% rename from contracts/src/AllowlistMinter.sol rename to contracts/src/protocol/AllowlistMinter.sol index 576b45ee..881e0e68 100644 --- a/contracts/src/AllowlistMinter.sol +++ b/contracts/src/protocol/AllowlistMinter.sol @@ -1,10 +1,10 @@ // SPDX-License-Identifier: MIT -pragma solidity 0.8.16; +pragma solidity ^0.8.16; -import { MerkleProofUpgradeable } from "oz-upgradeable/utils/cryptography/MerkleProofUpgradeable.sol"; -import { IAllowlist } from "./interfaces/IAllowlist.sol"; +import {MerkleProofUpgradeable} from "oz-upgradeable/utils/cryptography/MerkleProofUpgradeable.sol"; +import {IAllowlist} from "./interfaces/IAllowlist.sol"; -import { Errors } from "./libs/Errors.sol"; +import {Errors} from "./libs/Errors.sol"; /// @title Interface for hypercert token interactions /// @author bitbeckers @@ -19,11 +19,11 @@ contract AllowlistMinter is IAllowlist { mapping(uint256 => uint256) internal maxUnits; mapping(uint256 => uint256) internal minted; - function isAllowedToClaim( - bytes32[] calldata proof, - uint256 claimID, - bytes32 leaf - ) external view returns (bool isAllowed) { + function isAllowedToClaim(bytes32[] calldata proof, uint256 claimID, bytes32 leaf) + external + view + returns (bool isAllowed) + { if (merkleRoots[claimID].length == 0) revert Errors.DoesNotExist(); isAllowed = MerkleProofUpgradeable.verifyCalldata(proof, merkleRoots[claimID], leaf); } @@ -44,8 +44,8 @@ contract AllowlistMinter is IAllowlist { if (hasBeenClaimed[claimID][leaf]) revert Errors.AlreadyClaimed(); if ( - !MerkleProofUpgradeable.verifyCalldata(proof, merkleRoots[claimID], leaf) || - (minted[claimID] + amount) > maxUnits[claimID] + !MerkleProofUpgradeable.verifyCalldata(proof, merkleRoots[claimID], leaf) + || (minted[claimID] + amount) > maxUnits[claimID] ) revert Errors.Invalid(); hasBeenClaimed[claimID][leaf] = true; diff --git a/contracts/src/HypercertMinter.sol b/contracts/src/protocol/HypercertMinter.sol similarity index 80% rename from contracts/src/HypercertMinter.sol rename to contracts/src/protocol/HypercertMinter.sol index 917c02c5..63cf8cb4 100644 --- a/contracts/src/HypercertMinter.sol +++ b/contracts/src/protocol/HypercertMinter.sol @@ -1,12 +1,12 @@ // SPDX-License-Identifier: MIT -pragma solidity 0.8.16; +pragma solidity ^0.8.16; -import { IHypercertToken } from "./interfaces/IHypercertToken.sol"; -import { SemiFungible1155 } from "./SemiFungible1155.sol"; -import { AllowlistMinter } from "./AllowlistMinter.sol"; -import { PausableUpgradeable } from "oz-upgradeable/security/PausableUpgradeable.sol"; +import {IHypercertToken} from "./interfaces/IHypercertToken.sol"; +import {SemiFungible1155} from "./SemiFungible1155.sol"; +import {AllowlistMinter} from "./AllowlistMinter.sol"; +import {PausableUpgradeable} from "oz-upgradeable/security/PausableUpgradeable.sol"; -import { Errors } from "./libs/Errors.sol"; +import {Errors} from "./libs/Errors.sol"; /// @title Contract for managing hypercert claims and whitelists /// @author bitbeckers @@ -37,12 +37,11 @@ contract HypercertMinter is IHypercertToken, SemiFungible1155, AllowlistMinter, /// @notice Mint a semi-fungible token for the impact claim referenced via `uri` /// @dev see {IHypercertToken} - function mintClaim( - address account, - uint256 units, - string memory _uri, - TransferRestrictions restrictions - ) external override whenNotPaused { + function mintClaim(address account, uint256 units, string memory _uri, TransferRestrictions restrictions) + external + override + whenNotPaused + { // This enables us to release this restriction in the future if (msg.sender != account) revert Errors.NotAllowed(); uint256 claimID = _mintNewTypeWithToken(account, units, _uri); @@ -72,12 +71,10 @@ contract HypercertMinter is IHypercertToken, SemiFungible1155, AllowlistMinter, /// @notice Mint a semi-fungible token representing a fraction of the claim /// @dev Calls AllowlistMinter to verify `proof`. /// @dev Mints the `amount` of units for the hypercert stored under `claimID` - function mintClaimFromAllowlist( - address account, - bytes32[] calldata proof, - uint256 claimID, - uint256 units - ) external whenNotPaused { + function mintClaimFromAllowlist(address account, bytes32[] calldata proof, uint256 claimID, uint256 units) + external + whenNotPaused + { _processClaim(proof, claimID, units); _mintToken(account, claimID, units); } @@ -92,7 +89,7 @@ contract HypercertMinter is IHypercertToken, SemiFungible1155, AllowlistMinter, uint256[] calldata units ) external whenNotPaused { uint256 len = claimIDs.length; - for (uint256 i; i < len; ) { + for (uint256 i; i < len;) { _processClaim(proofs[i], claimIDs[i], units[i]); unchecked { ++i; @@ -119,11 +116,10 @@ contract HypercertMinter is IHypercertToken, SemiFungible1155, AllowlistMinter, /// @notice Split a claimtokens value into parts with summed value equal to the original /// @dev see {IHypercertToken} - function splitFraction( - address _account, - uint256 _tokenID, - uint256[] calldata _newFractions - ) external whenNotPaused { + function splitFraction(address _account, uint256 _tokenID, uint256[] calldata _newFractions) + external + whenNotPaused + { _splitTokenUnits(_account, _tokenID, _newFractions); } @@ -139,6 +135,28 @@ contract HypercertMinter is IHypercertToken, SemiFungible1155, AllowlistMinter, _burnToken(_account, _tokenID); } + /// @notice Burn a claimtoken + /// @dev see {IHypercertToken} + function batchBurnFraction(address _account, uint256[] memory _tokenIDs) external whenNotPaused { + _batchBurnToken(_account, _tokenIDs); + } + + /// @notice Burn a claimtoken; override is needed to update units/values + /// @dev see {ERC1155Burnable} + function burn(address account, uint256 id, uint256 /*value*/ ) public override whenNotPaused { + _burnToken(account, id); + } + + /// @notice Batch burn claimtokens; override is needed to update units/values + /// @dev see {ERC1155Burnable} + function burnBatch(address account, uint256[] memory ids, uint256[] memory /*values*/ ) + public + override + whenNotPaused + { + _batchBurnToken(account, ids); + } + /// @dev see {IHypercertToken} function unitsOf(uint256 tokenID) external view override returns (uint256 units) { units = _unitsOf(tokenID); @@ -162,7 +180,12 @@ contract HypercertMinter is IHypercertToken, SemiFungible1155, AllowlistMinter, /// METADATA /// @dev see { IHypercertMetadata} - function uri(uint256 tokenID) public view override(IHypercertToken, SemiFungible1155) returns (string memory _uri) { + function uri(uint256 tokenID) + public + view + override(IHypercertToken, SemiFungible1155) + returns (string memory _uri) + { _uri = SemiFungible1155.uri(tokenID); } @@ -204,7 +227,7 @@ contract HypercertMinter is IHypercertToken, SemiFungible1155, AllowlistMinter, // Transfer case, where to and from are non-zero uint256 len = ids.length; - for (uint256 i; i < len; ) { + for (uint256 i; i < len;) { uint256 typeID = getBaseType(ids[i]); TransferRestrictions policy = typeRestrictions[typeID]; if (policy == TransferRestrictions.DisallowAll) { diff --git a/contracts/src/protocol/SemiFungible1155.sol b/contracts/src/protocol/SemiFungible1155.sol new file mode 100644 index 00000000..4fe25e1c --- /dev/null +++ b/contracts/src/protocol/SemiFungible1155.sol @@ -0,0 +1,641 @@ +// SPDX-License-Identifier: MIT +// Used components of Enjin example implementation for mixed fungibility +// https://github.com/enjin/erc-1155/blob/master/contracts/ERC1155MixedFungibleMintable.sol +pragma solidity ^0.8.16; + +import {ERC1155Upgradeable} from "oz-upgradeable/token/ERC1155/ERC1155Upgradeable.sol"; +import {ERC1155BurnableUpgradeable} from "oz-upgradeable/token/ERC1155/extensions/ERC1155BurnableUpgradeable.sol"; +import {ERC1155URIStorageUpgradeable} from "oz-upgradeable/token/ERC1155/extensions/ERC1155URIStorageUpgradeable.sol"; +import {OwnableUpgradeable} from "oz-upgradeable/access/OwnableUpgradeable.sol"; +import {Initializable} from "oz-upgradeable/proxy/utils/Initializable.sol"; +import {UUPSUpgradeable} from "oz-upgradeable/proxy/utils/UUPSUpgradeable.sol"; +import {Errors} from "./libs/Errors.sol"; + +/// @title Contract for minting semi-fungible EIP1155 tokens +/// @author bitbeckers +/// @notice Extends { Upgradeable1155 } token with semi-fungible properties and the concept of `units` +/// @dev Adds split bit strategy as described in [EIP-1155](https://eips.ethereum.org/EIPS/eip-1155#non-fungible-tokens) +contract SemiFungible1155 is + Initializable, + ERC1155Upgradeable, + ERC1155BurnableUpgradeable, + ERC1155URIStorageUpgradeable, + OwnableUpgradeable, + UUPSUpgradeable +{ + /// @dev Counter used to generate next typeID. + uint256 internal typeCounter; + + /// @dev Bitmask used to expose only upper 128 bits of uint256 + uint256 internal constant TYPE_MASK = type(uint256).max << 128; + + /// @dev Bitmask used to expose only lower 128 bits of uint256 + uint256 internal constant NF_INDEX_MASK = type(uint256).max >> 128; + + uint256 internal constant FRACTION_LIMIT = 253; + + /// @dev Mapping of `tokenID` to address of `owner` + mapping(uint256 => address) internal owners; + + /// @dev Mapping of `tokenID` to address of `creator` + mapping(uint256 => address) internal creators; + + /// @dev Used to determine amount of `units` stored in token at `tokenID` + mapping(uint256 => uint256) internal tokenValues; + + /// @dev Used to find highest index of token belonging to token at `typeID` + mapping(uint256 => uint256) internal maxIndex; + + /// @dev Emitted on transfer of `value` between `fromTokenID` to `toTokenID` of the same `claimID` + event ValueTransfer(uint256 claimID, uint256 fromTokenID, uint256 toTokenID, uint256 value); + + /// @dev Emitted on transfer of `values` between `fromTokenIDs` to `toTokenIDs` of `claimIDs` + event BatchValueTransfer(uint256[] claimIDs, uint256[] fromTokenIDs, uint256[] toTokenIDs, uint256[] values); + + /// @dev see { openzeppelin-contracts-upgradeable/contracts/proxy/utils/Initializable.sol } + // solhint-disable-next-line func-name-mixedcase + function __SemiFungible1155_init() public virtual onlyInitializing { + __ERC1155_init(""); + __ERC1155Burnable_init(); + __ERC1155URIStorage_init(); + __Ownable_init(); + __UUPSUpgradeable_init(); + } + + /** + * @dev Returns the index of the fractional token at `_id` by returning lower 128 bit values. + * @param tokenID The ID of the token to query. + * @return The index of the fractional token. + * @dev This function returns 0 if `_id` is a baseType. + */ + function getItemIndex(uint256 tokenID) internal pure returns (uint256) { + return tokenID & NF_INDEX_MASK; + } + + /** + * @dev Get base type ID for token at `_id` by returning upper 128 bit values. + * @param tokenID The ID of the token to query. + * @return The base type ID of the token. + */ + function getBaseType(uint256 tokenID) internal pure returns (uint256) { + return tokenID & TYPE_MASK; + } + + /** + * @dev Identify that token at `_id` is base type. + * @param tokenID The ID of the token to query. + * @return A boolean indicating whether the token is a base type. + * @dev Upper 128 bits identify base type ID, lower bits should be 0. + */ + function isBaseType(uint256 tokenID) internal pure returns (bool) { + return (tokenID & TYPE_MASK == tokenID) && (tokenID & NF_INDEX_MASK == 0); + } + + /** + * @dev Returns a boolean indicating whether the token at `_id` belongs to a base type. + * @param tokenID The ID of the token to query. + * @return A boolean indicating whether the token is a typed item. + * @dev Upper 128 bits identify the type ID, lower bits identify the index of the typed item. + */ + function isTypedItem(uint256 tokenID) internal pure returns (bool) { + return (tokenID & TYPE_MASK != 0) && (tokenID & NF_INDEX_MASK != 0); + } + + /// READ + /** + * @dev Returns the owner of a given token ID. + * @param tokenID The ID of the token to query. + * @return _owner The address of the owner of the token. + */ + function ownerOf(uint256 tokenID) public view returns (address _owner) { + _owner = owners[tokenID]; + } + + /** + * @dev Returns the number of units of a given token ID. + * @param tokenID The ID of the token to query. + * @return units The number of units of the token. + * @dev This function is used internally to get the number of units of a token. + */ + function _unitsOf(uint256 tokenID) internal view returns (uint256 units) { + units = tokenValues[tokenID]; + } + + /** + * @dev Returns the number of units of a given token ID owned by a given account. + * @param account The address of the account to query. + * @param tokenID The ID of the token to query. + * @return units The number of units of the token owned by the account. + * @dev This function is used internally to get the number of units of a token owned by an account. + */ + function _unitsOf(address account, uint256 tokenID) internal view returns (uint256 units) { + // Check if fraction token and accounts owns it + if (ownerOf(tokenID) == account) { + units = tokenValues[tokenID]; + } + } + + /// MUTATE + + /** + * @dev Creates a new token type ID based on the token counter. + * @param _account The address of the account that will own the new token type. + * @param units The number of units associated with the new token type. + * @param _uri The URI for the metadata associated with the new token type. + * @return typeID The new token type ID. + */ + function _createTokenType(address _account, uint256 units, string memory _uri) internal returns (uint256 typeID) { + _notMaxType(typeCounter); + typeID = ++typeCounter << 128; + + creators[typeID] = _account; + tokenValues[typeID] = units; + + _setURI(typeID, _uri); + + //Event emitted for indexing purposes + emit TransferSingle(_account, address(0), address(0), typeID, 0); + } + + /** + * @dev Mints a new token with a new token type ID and assigns it to the specified account. + * @param _account The address of the account that will receive the new token. + * @param _units The number of units associated with the new token. + * @param _uri The URI for the metadata associated with the new token. + * @return typeID The new token type ID. + * @dev This function creates a new token type ID by calling the `_createTokenType` function and then mints a new + * token with the new type ID. + * @dev The `tokenID` is calculated by adding the `typeID` to the current maximum index for the `typeID`. + * @dev The `tokenValues` mapping is updated with the number of units associated with the new token. + * @dev A `ValueTransfer` event is emitted to indicate that a new token has been minted and assigned to the + * specified account. + * @dev If `_units` is zero, the function will revert with an error. + */ + function _mintNewTypeWithToken(address _account, uint256 _units, string memory _uri) + internal + returns (uint256 typeID) + { + if (_units == 0) { + revert Errors.NotAllowed(); + } + typeID = _createTokenType(_account, _units, _uri); + + uint256 tokenID = typeID + ++maxIndex[typeID]; //1 based indexing, 0 holds type data + + tokenValues[tokenID] = _units; + + _mint(_account, tokenID, 1, ""); + emit ValueTransfer(typeID, 0, tokenID, _units); + } + + /** + * @dev Mints a new token with a new token type ID and assigns it to the specified account. + * @param _account The address of the account that will receive the new token. + * @param _fractions An array of values associated with the new token. + * @param _uri The URI for the metadata associated with the new token. + * @return typeID The new token type ID. + * @dev This function creates a new token type ID by calling the `_createTokenType` function and then mints a new + * token with the new type ID. + * @dev The `tokenID` is calculated by adding the `typeID` to the current maximum index for the `typeID`. + * @dev The `tokenValues` mapping is updated with the number of units associated with the new token. + * @dev A `ValueTransfer` event is emitted to indicate that a new token has been minted and assigned to the + * specified account. + * @dev If any of the fractional values in `_fractions` are zero, the function will revert with an error. + * @dev This function also calls the `_splitTokenUnits` function to split the new token into multiple sub-tokens + * with the specified fractional values. + */ + function _mintNewTypeWithTokens(address _account, uint256[] calldata _fractions, string memory _uri) + internal + returns (uint256 typeID) + { + typeID = _mintNewTypeWithToken(_account, _getSum(_fractions), _uri); + _splitTokenUnits(_account, typeID + maxIndex[typeID], _fractions); + } + + /** + * @dev Mints a new token with the specified token type ID and assigns it to the specified account. + * @param _account The address of the account that will receive the new token. + * @param _typeID The ID of the token type to mint. + * @param _units The number of units associated with the new token. + * @return tokenID The ID of the newly minted token. + * @dev This function checks that the specified token type ID is a base type and that the maximum number of tokens + * for the token type has not been reached. + * @dev The function then calculates the new token ID by adding the specified token type ID to the current maximum + * index for the token type. + * @dev The `tokenValues` mapping is updated with the number of units associated with the new token. + * @dev A `ValueTransfer` event is emitted to indicate that a new token has been minted and assigned to the + * specified account. + */ + function _mintToken(address _account, uint256 _typeID, uint256 _units) internal returns (uint256 tokenID) { + if (!isBaseType(_typeID)) revert Errors.NotAllowed(); + + _notMaxItem(maxIndex[_typeID]); + + unchecked { + tokenID = _typeID + ++maxIndex[_typeID]; //1 based indexing, 0 holds type data + } + + tokenValues[tokenID] = _units; + + _mint(_account, tokenID, 1, ""); + emit ValueTransfer(_typeID, 0, tokenID, _units); + } + + /** + * @dev Mints multiple tokens with the specified token type IDs and assigns them to the specified account. + * @param _account The address of the account that will receive the new tokens. + * @param _typeIDs An array of token type IDs to mint. + * @param _units An array of numbers of units associated with the new tokens. + * @return tokenIDs An array of the IDs of the newly minted tokens. + * @dev This function checks that each specified token type ID is a base type and that the maximum number of tokens + * for each token type has not been reached. + * @dev The function then calculates the new token IDs by adding the specified token type IDs to the current maximum + * index for each token type. + * @dev The `tokenValues` mapping is updated with the number of units associated with each new token. + * @dev A `BatchValueTransfer` event is emitted to indicate that new tokens have been minted and assigned to the + * specified account. + */ + function _batchMintTokens(address _account, uint256[] calldata _typeIDs, uint256[] calldata _units) + internal + returns (uint256[] memory tokenIDs) + { + uint256 len = _typeIDs.length; + + tokenIDs = new uint256[](len); + uint256[] memory amounts = new uint256[](len); + uint256[] memory zeroes = new uint256[](len); + + for (uint256 i; i < len;) { + uint256 _typeID = _typeIDs[i]; + if (!isBaseType(_typeID)) revert Errors.NotAllowed(); + _notMaxItem(maxIndex[_typeID]); + + unchecked { + uint256 tokenID = _typeID + ++maxIndex[_typeID]; //1 based indexing, 0 holds type data + tokenValues[tokenID] = _units[i]; + tokenIDs[i] = tokenID; + amounts[i] = 1; + ++i; + } + } + + _mintBatch(_account, tokenIDs, amounts, ""); + emit BatchValueTransfer(_typeIDs, zeroes, tokenIDs, _units); + } + + /** + * @dev Splits a token into multiple tokens with different unit values. + * @param _account The address of the account that will receive the new tokens. + * @param _tokenID The ID of the token to split. + * @param _values An array of numbers of units associated with the new tokens. + * @dev This function splits a token into multiple tokens with different unit values. + * @dev The `_values` array specifies the number of units associated with each new token. + * @dev The function checks that the length of the `_values` array is between 2 and `FRACTION_LIMIT`, and that the + * sum of the values in the `_values` array is equal to the number of units associated with the original token. + * @dev The function then creates new tokens with the specified unit values and assigns them to the specified + * account. + * @dev A `BatchValueTransfer` event is emitted to indicate that the original token has been split into multiple + * tokens. + */ + function _splitTokenUnits(address _account, uint256 _tokenID, uint256[] calldata _values) internal { + if (_values.length > FRACTION_LIMIT || _values.length < 2) revert Errors.ArraySize(); + if (tokenValues[_tokenID] != _getSum(_values)) revert Errors.NotAllowed(); + + // Current token + uint256 _typeID = getBaseType(_tokenID); + uint256 valueLeft = tokenValues[_tokenID]; + + // Prepare batch processing, we want to skip the first entry + uint256 len = _values.length - 1; + + uint256[] memory typeIDs = new uint256[](len); + uint256[] memory fromIDs = new uint256[](len); + uint256[] memory toIDs = new uint256[](len); + uint256[] memory amounts = new uint256[](len); + uint256[] memory values = new uint256[](len); + + { + uint256[] memory _valuesCache = _values; + uint256 swapValue = _valuesCache[len]; + _valuesCache[len] = _valuesCache[0]; + _valuesCache[0] = swapValue; + + for (uint256 i; i < len;) { + _notMaxItem(maxIndex[_typeID]); + + typeIDs[i] = _typeID; + fromIDs[i] = _tokenID; + toIDs[i] = _typeID + ++maxIndex[_typeID]; + amounts[i] = 1; + values[i] = _valuesCache[i]; + + unchecked { + ++i; + } + } + } + + _beforeUnitTransfer(_msgSender(), owners[_tokenID], fromIDs, toIDs, values, ""); + + for (uint256 i; i < len;) { + valueLeft -= values[i]; + + tokenValues[toIDs[i]] = values[i]; + + unchecked { + ++i; + } + } + + tokenValues[_tokenID] = valueLeft; + + _mintBatch(_account, toIDs, amounts, ""); + + emit BatchValueTransfer(typeIDs, fromIDs, toIDs, values); + } + + /** + * @dev Merges the units of multiple tokens into a single token. + * @param _account The address of the account that will receive the merged token. + * @param _fractionIDs An array of token IDs to merge. + * @dev This function merges the units of multiple tokens into a single token. + * @dev The `_fractionIDs` array specifies the IDs of the tokens to merge. + * @dev The function checks that the length of the `_fractionIDs` array is between 2 and `FRACTION_LIMIT`. + * @dev The function then calculates the total value of the merged token by summing the values of the tokens to be + * merged. + * @dev The `tokenValues` mapping is updated with the total value of the merged token. + * @dev The tokens to be merged are burned except the last one that receives all the units. + * @dev A `BatchValueTransfer` event is emitted to indicate that the tokens have been merged into a single token. + */ + function _mergeTokensUnits(address _account, uint256[] memory _fractionIDs) internal { + if (_fractionIDs.length > FRACTION_LIMIT || _fractionIDs.length < 2) { + revert Errors.ArraySize(); + } + uint256 len = _fractionIDs.length - 1; + + uint256 target = _fractionIDs[len]; + + uint256 _totalValue; + uint256[] memory fromIDs = new uint256[](len); + uint256[] memory toIDs = new uint256[](len); + uint256[] memory values = new uint256[](len); + uint256[] memory amounts = new uint256[](len); + + { + for (uint256 i; i < len;) { + uint256 _fractionID = _fractionIDs[i]; + fromIDs[i] = _fractionID; + toIDs[i] = target; + amounts[i] = 1; + values[i] = tokenValues[_fractionID]; + + unchecked { + ++i; + } + } + } + + _beforeUnitTransfer(_msgSender(), _account, fromIDs, toIDs, values, ""); + + for (uint256 i; i < len;) { + _totalValue += values[i]; + + delete tokenValues[fromIDs[i]]; + unchecked { + ++i; + } + } + + tokenValues[target] += _totalValue; + + _burnBatch(_account, fromIDs, amounts); + } + + /** + * @dev Burns a single token and emits a `ValueTransfer` event with a value of 0. + * @param _account The address of the account that owns the token to burn. + * @param _tokenID The ID of the token to burn. + * @dev This function burns a single token with the specified ID and emits a `ValueTransfer` event `toTokenID` 0. + * @dev The function checks that the caller is the owner of the token or is approved to burn the token on behalf of + * the owner. + * @dev The function then deletes the token from the `tokenValues` mapping and calls the `_burn` function to burn + * the token. + */ + function _burnToken(address _account, uint256 _tokenID) internal { + if (_account != _msgSender() && !isApprovedForAll(_account, _msgSender())) revert Errors.NotApprovedOrOwner(); + + uint256 value = tokenValues[_tokenID]; + + delete tokenValues[_tokenID]; + + _burn(_account, _tokenID, 1); + emit ValueTransfer(getBaseType(_tokenID), _tokenID, 0, value); + } + + /** + * @dev Burns multiple tokens and emits a `BatchValueTransfer` event with a value of 0 for each token burned. + * @param _account The address of the account that owns the tokens to burn. + * @param _tokenIDs An array of token IDs to burn. + * @dev This function burns multiple tokens with the specified IDs and emits a `BatchValueTransfer` event. + * @dev The function checks that the caller is the owner of the tokens or is approved to burn the tokens on behalf + * of the owner. + * @dev The function then deletes the tokens from the `tokenValues` mapping and calls the `_burnBatch` function to + * burn the tokens. + * @dev Finally, the function emits a `BatchValueTransfer` event with a value of 1 and `toTokenIDs` as 0 for each + * token burned to indicate that the tokens have been burned. + */ + function _batchBurnToken(address _account, uint256[] memory _tokenIDs) internal { + if (_account != _msgSender() && !isApprovedForAll(_account, _msgSender())) revert Errors.NotApprovedOrOwner(); + + uint256 len = _tokenIDs.length; + + // ERC115 requires values + uint256[] memory claimIDs = new uint256[](len); + uint256[] memory toTokens = new uint256[](len); + uint256[] memory claimUnits = new uint256[](len); + uint256[] memory values = new uint256[](len); + + for (uint256 i; i < len; i++) { + uint256 _tokenId = _tokenIDs[i]; + uint256 value = tokenValues[_tokenId]; + + delete tokenValues[_tokenId]; + + claimIDs[i] = getBaseType(_tokenId); + claimUnits[i] = value; + values[i] = 1; + } + + _burnBatch(_account, _tokenIDs, values); + emit BatchValueTransfer(claimIDs, _tokenIDs, toTokens, claimUnits); + } + + /// TRANSFERS + + // The following functions are overrides required by Solidity. + /** + * @dev Called after a token transfer has been completed. + * @param operator The address of the operator performing the transfer. + * @param from The address of the sender of the tokens. + * @param to The address of the recipient of the tokens. + * @param ids An array of token IDs that were transferred. + * @param amounts An array of token amounts that were transferred. + * @param data Additional data that was passed along with the transfer. + * @dev This function updates the `owners` mapping to reflect the new owner of each token that was transferred. + */ + function _afterTokenTransfer( + address operator, + address from, + address to, + uint256[] memory ids, + uint256[] memory amounts, + bytes memory data + ) internal virtual override { + super._afterTokenTransfer(operator, from, to, ids, amounts, data); + + uint256 len = ids.length; + + for (uint256 i; i < len;) { + owners[ids[i]] = to; + unchecked { + ++i; + } + } + } + + /** + * @dev Called before a batch of tokens is transferred. + * @param {operator} The address of the operator performing the transfer. + * @param from The address of the sender of the tokens. + * @param fromIDs An array of token IDs that are being transferred. + * @param toIDs An array of token IDs that the tokens are being transferred to. + * @param {values} An array of token amounts that are being transferred. + * @param {data} Additional data that was passed along with the transfer. + * @dev This function checks that the transfer is allowed by verifying that the sender is approved to transfer the + * tokens and that the tokens being transferred are of the same base type. + */ + function _beforeUnitTransfer( + address, /*operator*/ + address from, + uint256[] memory fromIDs, + uint256[] memory toIDs, + uint256[] memory, /*values*/ + bytes memory /*data*/ + ) internal virtual { + uint256 len = fromIDs.length; + + for (uint256 i; i < len;) { + uint256 _from = fromIDs[i]; + uint256 _to = toIDs[i]; + + if (isBaseType(_from)) revert Errors.NotAllowed(); + if (getBaseType(_from) != getBaseType(_to)) revert Errors.TypeMismatch(); + if (from != _msgSender() && !isApprovedForAll(from, _msgSender())) revert Errors.NotApprovedOrOwner(); + unchecked { + ++i; + } + } + } + + /// METADATA + + /** + * @dev Returns the metadata URI for a given token ID. + * @param tokenID The ID of the token to retrieve the metadata URI for. + * @return _uri The metadata URI for the specified token ID. + * @dev This function retrieves the metadata URI for the specified token ID by calling the `uri` function of the + * `ERC1155URIStorageUpgradeable` contract. + * @dev The metadata URI is a string that points to a JSON file containing information about the token, such as its + * name, symbol, and image. + * @dev This function always returns the URI for the basetype so that it's managed in one place. + */ + function uri(uint256 tokenID) + public + view + virtual + override(ERC1155Upgradeable, ERC1155URIStorageUpgradeable) + returns (string memory _uri) + { + // All tokens share the same metadata at the moment + _uri = ERC1155URIStorageUpgradeable.uri(getBaseType(tokenID)); + } + + /// UTILS + + /** + * @dev Checks if the specified token ID is below the maximum item index. + * @param tokenID The ID of the token to check. + * @dev This function checks if the specified token ID is below the maximum item index by converting the token ID to + * a `uint128` value and incrementing it. + * @dev If the token ID is greater than or equal to the maximum item index, the function will revert with an error. + */ + function _notMaxItem(uint256 tokenID) private pure { + uint128 _count = uint128(tokenID); + ++_count; + } + + /** + * @dev Checks if the specified token ID is below the maximum type index. + * @param tokenID The ID of the token to check. + * @dev This function checks if the specified token ID is below the maximum type index by shifting the token ID + * right by 128 bits to get the type ID and converting it to a `uint128` value. + * @dev If the type ID is greater than or equal to the maximum type index, the function will revert with an error. + */ + function _notMaxType(uint256 tokenID) private pure { + uint128 _count = uint128(tokenID >> 128); + ++_count; + } + + /** + * @dev Calculates the sum of the elements of an array. + * @param array The array of uint256 values to sum. + * @return sum The sum of the elements of the array. + * @dev This function calculates the sum of the elements of the specified array by iterating over the array and + * adding each element to a running total. + * @dev If an element in the array is 0, the function will revert with an error. + */ + function _getSum(uint256[] memory array) internal pure returns (uint256 sum) { + uint256 len = array.length; + for (uint256 i; i < len;) { + if (array[i] == 0) revert Errors.NotAllowed(); + sum += array[i]; + unchecked { + ++i; + } + } + } + + /** + * @dev Returns an array containing a single element. + * @param element The element to include in the array. + * @return An array containing a single element. + * @dev This function returns an array containing a single element by creating a new array with a length of 1 and + * setting the first element to the specified value. + */ + function _getSingletonArray(uint256 element) private pure returns (uint256[] memory) { + uint256[] memory array = new uint256[](1); + array[0] = element; + + return array; + } + + // UUPS PROXY + + /// @dev see { openzeppelin-contracts-upgradeable/contracts/proxy/utils/UUPSUpgradeable.sol } + function _authorizeUpgrade(address newImplementation) internal virtual override onlyOwner { + // solhint-disable-previous-line no-empty-blocks + } + + /** + * @dev This empty reserved space is put in place to allow future versions to add new + * variables without shifting down storage in the inheritance chain. + * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps + * Assuming 30 available slots (slots cost space, cost gas) + * 1. typeCounter + * 2. owners + * 3. creators + * 4. tokenValues + * 5. maxIndex + */ + uint256[25] private __gap; +} diff --git a/contracts/contracts/interfaces/IAllowlist.sol b/contracts/src/protocol/interfaces/IAllowlist.sol similarity index 61% rename from contracts/contracts/interfaces/IAllowlist.sol rename to contracts/src/protocol/interfaces/IAllowlist.sol index fe4a9ec4..b4415d42 100644 --- a/contracts/contracts/interfaces/IAllowlist.sol +++ b/contracts/src/protocol/interfaces/IAllowlist.sol @@ -1,14 +1,13 @@ // SPDX-License-Identifier: MIT -pragma solidity 0.8.16; +pragma solidity ^0.8.16; /// @title Interface for allowlist /// @author bitbeckers /// @notice This interface declares the required functionality for a hypercert token /// @notice This interface does not specify the underlying token type (e.g. 721 or 1155) interface IAllowlist { - function isAllowedToClaim( - bytes32[] calldata proof, - uint256 tokenID, - bytes32 leaf - ) external view returns (bool isAllowed); + function isAllowedToClaim(bytes32[] calldata proof, uint256 tokenID, bytes32 leaf) + external + view + returns (bool isAllowed); } diff --git a/contracts/contracts/interfaces/IHypercertToken.sol b/contracts/src/protocol/interfaces/IHypercertToken.sol similarity index 99% rename from contracts/contracts/interfaces/IHypercertToken.sol rename to contracts/src/protocol/interfaces/IHypercertToken.sol index 1ed1e34e..ff280c2e 100644 --- a/contracts/contracts/interfaces/IHypercertToken.sol +++ b/contracts/src/protocol/interfaces/IHypercertToken.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -pragma solidity 0.8.16; +pragma solidity ^0.8.16; /// @title Interface for hypercert token interactions /// @author bitbeckers diff --git a/contracts/contracts/libs/Errors.sol b/contracts/src/protocol/libs/Errors.sol similarity index 100% rename from contracts/contracts/libs/Errors.sol rename to contracts/src/protocol/libs/Errors.sol diff --git a/contracts/tasks/deploy.ts b/contracts/tasks/deploy.ts index 30927db5..28767a74 100644 --- a/contracts/tasks/deploy.ts +++ b/contracts/tasks/deploy.ts @@ -1,7 +1,7 @@ import { task } from "hardhat/config"; import { writeFile } from "node:fs/promises"; -task("deploy", "Deploy contracts and verify") +task("deploy-minter", "Deploy contracts and verify") .addOptionalParam("output", "write the details of the deployment to this file if this is set") .setAction(async ({ output }, { ethers, upgrades, network, run }) => { console.log("Using address: ", await ethers.getSigners().then((res) => res[0])); diff --git a/contracts/tasks/transfer-owner.ts b/contracts/tasks/transfer-owner.ts index 03421503..20c80c66 100644 --- a/contracts/tasks/transfer-owner.ts +++ b/contracts/tasks/transfer-owner.ts @@ -1,13 +1,13 @@ import { task } from "hardhat/config"; -task("transfer-owner", "Transfer ownership of ProxyAdmin contract") +task("transfer-owner-minter", "Transfer ownership of ProxyAdmin contract HypercertMinter") .addParam("proxy", "Proxy contract address") .addParam("owner", "Address of new owner") .setAction(async ({ proxy, owner }, { ethers, upgrades }) => { const HypercertMinter = await ethers.getContractFactory("HypercertMinter"); const hypercertMinter = await HypercertMinter.attach(proxy); - console.log('Transferring ownership of proxy contract...'); + console.log("Transferring ownership of proxy contract..."); const transferTransaction = await hypercertMinter.transferOwnership(owner); console.log("Sent transfer transaction, waiting for transaction receipt..."); @@ -27,5 +27,33 @@ task("transfer-owner", "Transfer ownership of ProxyAdmin contract") } console.log(`Successfully verified that the HypercertMinter contract was transferred. Contract address: ${proxy}`); - } -); + }); + +task("transfer-owner-trader", "Transfer ownership of ProxyAdmin contract HypercertTrader") + .addParam("proxy", "Proxy contract address") + .addParam("owner", "Address of new owner") + .setAction(async ({ proxy, owner }, { ethers, upgrades }) => { + const HypercertTrader = await ethers.getContractFactory("HypercertTrader"); + const hypercertTrader = await HypercertTrader.attach(proxy); + + console.log("Transferring ownership of proxy contract..."); + const transferTransaction = await hypercertTrader.transferOwnership(owner); + console.log("Sent transfer transaction, waiting for transaction receipt..."); + + const transferReceipt = await transferTransaction.wait(); + if (transferReceipt == null || transferReceipt.status == 0) { + console.error(transferReceipt); + console.error("Transaction failed, failed to transfer contract"); + return; + } + + console.log(`Transaction succeeded. Transaction Hash: ${transferReceipt.transactionHash}`); + + const newOwner = await hypercertTrader.owner(); + if (newOwner !== owner) { + console.error(`Verification failed: the contract is owned by ${newOwner}.`); + return; + } + + console.log(`Successfully verified that the HypercertTrader contract was transferred. Contract address: ${proxy}`); + }); diff --git a/contracts/tasks/upgrade.ts b/contracts/tasks/upgrade.ts index 9f547d43..082e36a4 100644 --- a/contracts/tasks/upgrade.ts +++ b/contracts/tasks/upgrade.ts @@ -3,7 +3,7 @@ import { task } from "hardhat/config"; /** * Used to upgrade a contract directly via local keys */ -task("upgrade", "Upgrade implementation contract and verify") +task("upgrade-minter", "Upgrade implementation contract of Minter and verify") .addParam("proxy", "Provider proxy address") .setAction(async ({ proxy }, { ethers, upgrades, run }) => { const HypercertMinter = await ethers.getContractFactory("HypercertMinter"); @@ -40,16 +40,77 @@ task("upgrade", "Upgrade implementation contract and verify") }); /** - * Used to propose a multi-sig upgrade via OpenZeppelin Defender + * Used to upgrade a contract directly via local keys */ -task("propose-upgrade", "Propose an upgrade to OpenZeppelin Defender") +task("upgrade-trader", "Upgrade implementation contract of Trader and verify") + .addParam("proxy", "Provider proxy address") + .setAction(async ({ proxy }, { ethers, upgrades, run }) => { + const HypercertTrader = await ethers.getContractFactory("HypercertTrader"); + + // Validate (redundant?) + console.log("Validating upgrade.."); + await upgrades.validateUpgrade(proxy, HypercertTrader).then(() => console.log("Valid upgrade. Deploying..")); + + // Upgrade + const hypercertTraderUpgrade = await upgrades.upgradeProxy(proxy, HypercertTrader, { + kind: "uups", + unsafeAllow: ["constructor"], + }); + await hypercertTraderUpgrade.deployed(); + console.log(`HypercertTrader at proxy address ${hypercertTraderUpgrade.address} was upgraded`); + + try { + const code = await hypercertTraderUpgrade.instance?.provider.getCode(hypercertTraderUpgrade.address); + if (code === "0x") { + console.log(`${hypercertTraderUpgrade.name} contract upgrade has not completed. waiting to verify...`); + await hypercertTraderUpgrade.instance?.deployed(); + } + await run("verify:verify", { + address: hypercertTraderUpgrade.address, + }); + } catch (error) { + const errorMessage = (error as Error).message; + if (errorMessage.includes("Reason: Already Verified")) { + console.log("Reason: Already Verified"); + } + console.error(errorMessage); + } + }); + +/** + * Used to propose a multi-sig upgrade via OpenZeppelin Defender for HypercertMinter + */ +task("propose-upgrade-minter", "Propose an upgrade to OpenZeppelin Defender") .addParam("proxy", "Proxy contract address") .addParam("multisig", "Owner multisig address") - .setAction(async ({ proxy, multisig }, { ethers, defender }) => { + .addOptionalParam("description", "Description of upgrade") + .setAction(async ({ proxy, multisig, description = "Upgrade Minter contract" }, { ethers, defender }) => { const HypercertMinter = await ethers.getContractFactory("HypercertMinter"); - console.log("Proposing upgrade.."); + console.log(`Proposing upgrade to multisig ${multisig} as address ${proxy}`); const proposal = await defender.proposeUpgrade(proxy, HypercertMinter, { + description, + multisig, + multisigType: "Gnosis Safe", + title: "Upgrade Minter contract", + }); + console.log("Upgrade proposal created at: ", proposal.url); + }); + +/** + * Used to propose a multi-sig upgrade via OpenZeppelin Defender for HypercertTrader + */ +task("propose-upgrade-trader", "Propose an upgrade to OpenZeppelin Defender") + .addParam("proxy", "Proxy contract address") + .addParam("multisig", "Owner multisig address") + .addOptionalParam("description", "Description of upgrade") + .setAction(async ({ proxy, multisig, description = "Upgrade Trader contract" }, { ethers, defender }) => { + const HypercertTrader = await ethers.getContractFactory("HypercertTrader"); + console.log(`Proposing upgrade to multisig ${multisig} as address ${proxy}`); + const proposal = await defender.proposeUpgrade(proxy, HypercertTrader, { + description, multisig, + multisigType: "Gnosis Safe", + title: "Upgrade Trader contract", }); console.log("Upgrade proposal created at: ", proposal.url); }); diff --git a/contracts/test/HypercertMinter.test.ts b/contracts/test/HypercertMinter.test.ts index 9cb0af6f..437b1fe4 100644 --- a/contracts/test/HypercertMinter.test.ts +++ b/contracts/test/HypercertMinter.test.ts @@ -1,16 +1,16 @@ -import { expect } from "chai"; import { ethers, upgrades } from "hardhat"; +import { expect } from "chai"; -import { HypercertMinter } from "../src/types"; - -describe("Hypercert Minter", function () { +describe("HypercertMinter", function () { it("is upgradeable", async () => { const HypercertMinter = await ethers.getContractFactory("HypercertMinter"); - const instance = await upgrades.deployProxy(HypercertMinter, { + const instance = await upgrades.deployProxy(HypercertMinter, { kind: "uups", unsafeAllow: ["constructor"], + useDefenderDeploy: false, }); + await instance.waitForDeployment(); const name = await instance.name(); expect(name).to.equal("HypercertMinter"); await expect(instance.initialize()).to.be.revertedWith("Initializable: contract is already initialized"); diff --git a/contracts/test/foundry/SemiFungible1155.burning.t.sol b/contracts/test/foundry/SemiFungible1155.burning.t.sol deleted file mode 100644 index e816d35f..00000000 --- a/contracts/test/foundry/SemiFungible1155.burning.t.sol +++ /dev/null @@ -1,56 +0,0 @@ -// SPDX-License-Identifier: UNLICENSED -pragma solidity >=0.8.16; - -import { PRBTest } from "prb-test/PRBTest.sol"; -import { StdCheats } from "forge-std/StdCheats.sol"; -import { StdUtils } from "forge-std/StdUtils.sol"; -import { SemiFungible1155Helper } from "./SemiFungibleHelper.sol"; - -/// @dev See the "Writing Tests" section in the Foundry Book if this is your first time with Forge. -/// https://book.getfoundry.sh/forge/writing-tests -contract SemiFungible1155BurnTest is PRBTest, StdCheats, StdUtils, SemiFungible1155Helper { - SemiFungible1155Helper internal semiFungible; - string internal _uri; - address internal alice; - address internal bob; - - function setUp() public { - semiFungible = new SemiFungible1155Helper(); - _uri = "ipfs://bafybeigdyrzt5sfp7udm7hu76uh7y26nf3efuylqabf3oclgtqy55fbzdi"; - alice = address(1); - bob = address(2); - } - - function testBurnFraction() public { - uint256 baseID = 1 << 128; - - uint256 size = 20; - uint256 value = 2000; - uint256[] memory values = semiFungible.buildValues(size, value); - uint256[] memory tokenIDs = semiFungible.buildIDs(baseID, size); - - startHoax(alice, 100 ether); - - semiFungible.mintValue(alice, values, _uri); - semiFungible.validateOwnerBalanceUnits(tokenIDs[1], alice, 1, values[1]); - - vm.expectEmit(true, true, true, true); - emit TransferSingle(alice, alice, address(0), tokenIDs[1], 1); - semiFungible.burnValue(alice, tokenIDs[1]); - - semiFungible.validateNotOwnerNoBalanceNoUnits(tokenIDs[1], alice); - } - - function testCannotBurnClaim() public { - uint256 size = 20; - uint256 value = 2000; - uint256[] memory values = semiFungible.buildValues(size, value); - - startHoax(alice, 100 ether); - - uint256 baseID = semiFungible.mintValue(alice, values, _uri); - - vm.expectRevert("ERC1155: burn amount exceeds balance"); - semiFungible.burnValue(alice, baseID); - } -} diff --git a/contracts/test/foundry/marketplace/BatchMakerCollectionOrders.t.sol b/contracts/test/foundry/marketplace/BatchMakerCollectionOrders.t.sol new file mode 100644 index 00000000..8810028b --- /dev/null +++ b/contracts/test/foundry/marketplace/BatchMakerCollectionOrders.t.sol @@ -0,0 +1,111 @@ +/// SPDX-License-Identifier: MIT +pragma solidity 0.8.17; + +// Strategies +import {StrategyCollectionOffer} from "@hypercerts/marketplace/executionStrategies/StrategyCollectionOffer.sol"; + +// Libraries +import {OrderStructs} from "@hypercerts/marketplace/libraries/OrderStructs.sol"; + +// Constants +import {ONE_HUNDRED_PERCENT_IN_BP} from "@hypercerts/marketplace/constants/NumericConstants.sol"; + +// Base test +import {ProtocolBase} from "./ProtocolBase.t.sol"; + +// Helpers +import {EIP712MerkleTree} from "./utils/EIP712MerkleTree.sol"; + +// Enums +import {CollectionType} from "@hypercerts/marketplace/enums/CollectionType.sol"; +import {QuoteType} from "@hypercerts/marketplace/enums/QuoteType.sol"; + +contract BatchMakerCollectionOrdersTest is ProtocolBase { + StrategyCollectionOffer private strategy; + uint256 private constant price = 1 ether; // Fixed price of sale + EIP712MerkleTree private eip712MerkleTree; + + function setUp() public { + _setUp(); + + strategy = new StrategyCollectionOffer(); + vm.prank(_owner); + looksRareProtocol.addStrategy( + _standardProtocolFeeBp, + _minTotalFeeBp, + _maxProtocolFeeBp, + StrategyCollectionOffer.executeCollectionStrategyWithTakerAsk.selector, + true, + address(strategy) + ); + + _setUpUsers(); + eip712MerkleTree = new EIP712MerkleTree(looksRareProtocol); + } + + function testTakerAskMultipleOrdersSignedERC721(uint256 numberOrders) public { + vm.assume(numberOrders > 0 && numberOrders <= 10); + + mockERC721.batchMint(takerUser, numberOrders); + + OrderStructs.Maker[] memory makerBids = _createBatchMakerBids(numberOrders); + + (bytes memory signature,) = eip712MerkleTree.sign(makerUserPK, makerBids, 0); + + for (uint256 i; i < numberOrders; i++) { + // To prove that we only need 1 signature for multiple collection offers, + // we are not using the signature from the sign call in the loop. + (, OrderStructs.MerkleTree memory merkleTree) = eip712MerkleTree.sign(makerUserPK, makerBids, i); + + OrderStructs.Maker memory makerBidToExecute = makerBids[i]; + + // Verify validity + _assertValidMakerOrderWithMerkleTree(makerBidToExecute, signature, merkleTree); + + OrderStructs.Taker memory takerOrder = OrderStructs.Taker(takerUser, abi.encode(i)); + + // Execute taker ask transaction + vm.prank(takerUser); + looksRareProtocol.executeTakerAsk(takerOrder, makerBidToExecute, signature, merkleTree); + + // Maker user has received the asset + assertEq(mockERC721.ownerOf(i), makerUser); + + // Verify the nonce is marked as executed + assertEq( + looksRareProtocol.userOrderNonce(makerUser, makerBidToExecute.orderNonce), + MAGIC_VALUE_ORDER_NONCE_EXECUTED + ); + } + + uint256 totalValue = price * numberOrders; + assertEq( + weth.balanceOf(makerUser), _initialWETHBalanceUser - totalValue, "Maker bid user should pay the whole price" + ); + assertEq( + weth.balanceOf(takerUser), + _initialWETHBalanceUser + + (totalValue * _sellerProceedBpWithStandardProtocolFeeBp) / ONE_HUNDRED_PERCENT_IN_BP, + "Taker ask user should receive 99.5% of the whole price (0.5% protocol)" + ); + } + + function _createBatchMakerBids(uint256 numberOrders) private view returns (OrderStructs.Maker[] memory makerBids) { + makerBids = new OrderStructs.Maker[](numberOrders); + for (uint256 i; i < numberOrders; i++) { + makerBids[i] = _createSingleItemMakerOrder({ + quoteType: QuoteType.Bid, + globalNonce: 0, + subsetNonce: 0, + strategyId: 1, + collectionType: CollectionType.ERC721, + orderNonce: i, // incremental + collection: address(mockERC721), + currency: address(weth), + signer: makerUser, + price: price, + itemId: 0 // Not used + }); + } + } +} diff --git a/contracts/test/foundry/marketplace/BatchMakerOrders.t.sol b/contracts/test/foundry/marketplace/BatchMakerOrders.t.sol new file mode 100644 index 00000000..35bb3570 --- /dev/null +++ b/contracts/test/foundry/marketplace/BatchMakerOrders.t.sol @@ -0,0 +1,333 @@ +/// SPDX-License-Identifier: MIT +pragma solidity 0.8.17; + +// Murky (third-party) library is used to compute Merkle trees in Solidity +import {Merkle} from "murky/Merkle.sol"; + +// Libraries +import {OrderStructs} from "@hypercerts/marketplace/libraries/OrderStructs.sol"; + +// Errors and constants +import {MerkleProofTooLarge, MerkleProofInvalid} from "@hypercerts/marketplace/errors/SharedErrors.sol"; +import { + MERKLE_PROOF_PROOF_TOO_LARGE, + ORDER_HASH_PROOF_NOT_IN_MERKLE_TREE +} from "@hypercerts/marketplace/constants/ValidationCodeConstants.sol"; +import { + ONE_HUNDRED_PERCENT_IN_BP, + MAX_CALLDATA_PROOF_LENGTH +} from "@hypercerts/marketplace/constants/NumericConstants.sol"; + +// Base test +import {ProtocolBase} from "./ProtocolBase.t.sol"; + +// Helpers +import {EIP712MerkleTree} from "./utils/EIP712MerkleTree.sol"; + +// Enums +import {CollectionType} from "@hypercerts/marketplace/enums/CollectionType.sol"; +import {QuoteType} from "@hypercerts/marketplace/enums/QuoteType.sol"; + +contract BatchMakerOrdersTest is ProtocolBase { + uint256 private constant price = 1.2222 ether; // Fixed price of sale + EIP712MerkleTree private eip712MerkleTree; + + function setUp() public { + _setUp(); + _setUpUsers(); + eip712MerkleTree = new EIP712MerkleTree(looksRareProtocol); + } + + function testTakerBidMultipleOrdersSignedERC721(uint256 numberOrders, uint256 orderIndex) public { + _assertMerkleTreeAssumptions(numberOrders, orderIndex); + + mockERC721.batchMint(makerUser, numberOrders); + + OrderStructs.Maker[] memory makerAsks = _createBatchMakerAsks(numberOrders); + + (bytes memory signature, OrderStructs.MerkleTree memory merkleTree) = + eip712MerkleTree.sign(makerUserPK, makerAsks, orderIndex); + + OrderStructs.Maker memory makerAskToExecute = makerAsks[orderIndex]; + + // Verify validity + _assertValidMakerOrderWithMerkleTree(makerAskToExecute, signature, merkleTree); + + // Execute taker bid transaction + vm.prank(takerUser); + looksRareProtocol.executeTakerBid{value: price}(_genericTakerOrder(), makerAskToExecute, signature, merkleTree); + + // Taker user has received the asset + assertEq(mockERC721.ownerOf(orderIndex), takerUser); + // Taker bid user pays the whole price + assertEq(address(takerUser).balance, _initialETHBalanceUser - price); + // Maker ask user receives 99.5% of the whole price (0.5% protocol) + assertEq( + address(makerUser).balance, + _initialETHBalanceUser + (price * _sellerProceedBpWithStandardProtocolFeeBp) / ONE_HUNDRED_PERCENT_IN_BP + ); + // No leftover in the balance of the contract + assertEq(address(looksRareProtocol).balance, 0); + // Verify the nonce is marked as executed + assertEq( + looksRareProtocol.userOrderNonce(makerUser, makerAskToExecute.orderNonce), MAGIC_VALUE_ORDER_NONCE_EXECUTED + ); + } + + function testTakerAskMultipleOrdersSignedERC721(uint256 numberOrders, uint256 orderIndex) public { + _assertMerkleTreeAssumptions(numberOrders, orderIndex); + + mockERC721.batchMint(takerUser, numberOrders); + + OrderStructs.Maker[] memory makerBids = _createBatchMakerBids(numberOrders); + + (bytes memory signature, OrderStructs.MerkleTree memory merkleTree) = + eip712MerkleTree.sign(makerUserPK, makerBids, orderIndex); + + OrderStructs.Maker memory makerBidToExecute = makerBids[orderIndex]; + + // Verify validity + _assertValidMakerOrderWithMerkleTree(makerBidToExecute, signature, merkleTree); + + // Execute taker ask transaction + vm.prank(takerUser); + looksRareProtocol.executeTakerAsk(_genericTakerOrder(), makerBidToExecute, signature, merkleTree); + + // Maker user has received the asset + assertEq(mockERC721.ownerOf(orderIndex), makerUser); + // Maker bid user pays the whole price + assertEq(weth.balanceOf(makerUser), _initialWETHBalanceUser - price); + // Taker ask user receives 99.5% of the whole price (0.5% protocol) + assertEq( + weth.balanceOf(takerUser), + _initialWETHBalanceUser + (price * _sellerProceedBpWithStandardProtocolFeeBp) / ONE_HUNDRED_PERCENT_IN_BP + ); + // Verify the nonce is marked as executed + assertEq( + looksRareProtocol.userOrderNonce(makerUser, makerBidToExecute.orderNonce), MAGIC_VALUE_ORDER_NONCE_EXECUTED + ); + } + + function testTakerBidMultipleOrdersSignedERC721MerkleProofInvalid(uint256 numberOrders, uint256 orderIndex) + public + { + _assertMerkleTreeAssumptions(numberOrders, orderIndex); + + mockERC721.batchMint(makerUser, numberOrders); + + OrderStructs.Maker[] memory makerAsks = _createBatchMakerAsks(numberOrders); + + (bytes memory signature, OrderStructs.MerkleTree memory merkleTree) = + eip712MerkleTree.sign(makerUserPK, makerAsks, orderIndex); + + bytes32 tamperedRoot = bytes32(uint256(merkleTree.root) + 1); + merkleTree.root = tamperedRoot; + + OrderStructs.Maker memory makerAskToExecute = makerAsks[orderIndex]; + + // Verify invalidity of maker ask order + _assertMakerOrderReturnValidationCodeWithMerkleTree( + makerAskToExecute, signature, merkleTree, ORDER_HASH_PROOF_NOT_IN_MERKLE_TREE + ); + + vm.prank(takerUser); + vm.expectRevert(MerkleProofInvalid.selector); + looksRareProtocol.executeTakerBid{value: price}(_genericTakerOrder(), makerAskToExecute, signature, merkleTree); + } + + function testTakerAskMultipleOrdersSignedERC721MerkleProofInvalid(uint256 numberOrders, uint256 orderIndex) + public + { + _assertMerkleTreeAssumptions(numberOrders, orderIndex); + + mockERC721.batchMint(takerUser, numberOrders); + + OrderStructs.Maker[] memory makerBids = _createBatchMakerBids(numberOrders); + + (bytes memory signature, OrderStructs.MerkleTree memory merkleTree) = + eip712MerkleTree.sign(makerUserPK, makerBids, orderIndex); + + bytes32 tamperedRoot = bytes32(uint256(merkleTree.root) + 1); + merkleTree.root = tamperedRoot; + + OrderStructs.Maker memory makerBidToExecute = makerBids[orderIndex]; + + // Verify invalidity of maker bid order + _assertMakerOrderReturnValidationCodeWithMerkleTree( + makerBidToExecute, signature, merkleTree, ORDER_HASH_PROOF_NOT_IN_MERKLE_TREE + ); + + vm.prank(takerUser); + vm.expectRevert(MerkleProofInvalid.selector); + looksRareProtocol.executeTakerAsk(_genericTakerOrder(), makerBidToExecute, signature, merkleTree); + } + + function testTakerBidMultipleOrdersSignedERC721MerkleProofWrongPosition(uint256 numberOrders, uint256 orderIndex) + public + { + _assertMerkleTreeAssumptions(numberOrders, orderIndex); + + mockERC721.batchMint(makerUser, numberOrders); + + OrderStructs.Maker[] memory makerAsks = _createBatchMakerAsks(numberOrders); + + (bytes memory signature, OrderStructs.MerkleTree memory merkleTree) = + eip712MerkleTree.sign(makerUserPK, makerAsks, orderIndex); + + // Swap every node's position + OrderStructs.MerkleTreeNode[] memory proof = merkleTree.proof; + for (uint256 i; i < proof.length; i++) { + if (proof[i].position == OrderStructs.MerkleTreeNodePosition.Left) { + proof[i].position = OrderStructs.MerkleTreeNodePosition.Right; + } else { + proof[i].position = OrderStructs.MerkleTreeNodePosition.Left; + } + } + + OrderStructs.Maker memory makerAskToExecute = makerAsks[orderIndex]; + + // Verify invalidity of maker ask order + _assertMakerOrderReturnValidationCodeWithMerkleTree( + makerAskToExecute, signature, merkleTree, ORDER_HASH_PROOF_NOT_IN_MERKLE_TREE + ); + + vm.prank(takerUser); + vm.expectRevert(MerkleProofInvalid.selector); + looksRareProtocol.executeTakerBid{value: price}(_genericTakerOrder(), makerAskToExecute, signature, merkleTree); + } + + function testTakerAskMultipleOrdersSignedERC721MerkleProofWrongPosition(uint256 numberOrders, uint256 orderIndex) + public + { + _assertMerkleTreeAssumptions(numberOrders, orderIndex); + + mockERC721.batchMint(takerUser, numberOrders); + + OrderStructs.Maker[] memory makerBids = _createBatchMakerBids(numberOrders); + + (bytes memory signature, OrderStructs.MerkleTree memory merkleTree) = + eip712MerkleTree.sign(makerUserPK, makerBids, orderIndex); + + // Swap every node's position + OrderStructs.MerkleTreeNode[] memory proof = merkleTree.proof; + for (uint256 i; i < proof.length; i++) { + if (proof[i].position == OrderStructs.MerkleTreeNodePosition.Left) { + proof[i].position = OrderStructs.MerkleTreeNodePosition.Right; + } else { + proof[i].position = OrderStructs.MerkleTreeNodePosition.Left; + } + } + + OrderStructs.Maker memory makerBidToExecute = makerBids[orderIndex]; + + // Verify invalidity of maker bid order + _assertMakerOrderReturnValidationCodeWithMerkleTree( + makerBidToExecute, signature, merkleTree, ORDER_HASH_PROOF_NOT_IN_MERKLE_TREE + ); + + vm.prank(takerUser); + vm.expectRevert(MerkleProofInvalid.selector); + looksRareProtocol.executeTakerAsk(_genericTakerOrder(), makerBidToExecute, signature, merkleTree); + } + + function testTakerBidRevertsIfProofTooLarge() public { + uint256 testProofLengthUpTo = MAX_CALLDATA_PROOF_LENGTH + 3; + mockERC721.batchMint(makerUser, 2 ** testProofLengthUpTo); + + // Keep it reasonably large + for (uint256 proofLength = MAX_CALLDATA_PROOF_LENGTH + 1; proofLength <= testProofLengthUpTo; proofLength++) { + uint256 numberOrders = 2 ** proofLength; + uint256 orderIndex = numberOrders - 1; + + OrderStructs.Maker[] memory makerAsks = _createBatchMakerAsks(numberOrders); + + (bytes memory signature, OrderStructs.MerkleTree memory merkleTree) = + eip712MerkleTree.sign(makerUserPK, makerAsks, orderIndex); + + OrderStructs.Maker memory makerAskToExecute = makerAsks[orderIndex]; + + // Verify validity + _assertMakerOrderReturnValidationCodeWithMerkleTree( + makerAskToExecute, signature, merkleTree, MERKLE_PROOF_PROOF_TOO_LARGE + ); + + vm.prank(takerUser); + vm.expectRevert(abi.encodeWithSelector(MerkleProofTooLarge.selector, proofLength)); + looksRareProtocol.executeTakerBid{value: price}( + _genericTakerOrder(), makerAskToExecute, signature, merkleTree + ); + } + } + + function testTakerAskRevertsIfProofTooLarge() public { + uint256 testProofLengthUpTo = MAX_CALLDATA_PROOF_LENGTH + 3; + mockERC721.batchMint(takerUser, 2 ** testProofLengthUpTo); + + // Keep it reasonably large + for (uint256 proofLength = MAX_CALLDATA_PROOF_LENGTH + 1; proofLength <= testProofLengthUpTo; proofLength++) { + uint256 numberOrders = 2 ** proofLength; + uint256 orderIndex = numberOrders - 1; + + OrderStructs.Maker[] memory makerBids = _createBatchMakerBids(numberOrders); + + (bytes memory signature, OrderStructs.MerkleTree memory merkleTree) = + eip712MerkleTree.sign(makerUserPK, makerBids, orderIndex); + + OrderStructs.Maker memory makerBidToExecute = makerBids[orderIndex]; + + // Verify validity + _assertMakerOrderReturnValidationCodeWithMerkleTree( + makerBidToExecute, signature, merkleTree, MERKLE_PROOF_PROOF_TOO_LARGE + ); + + vm.prank(takerUser); + vm.expectRevert(abi.encodeWithSelector(MerkleProofTooLarge.selector, proofLength)); + looksRareProtocol.executeTakerBid{value: price}( + _genericTakerOrder(), makerBidToExecute, signature, merkleTree + ); + } + } + + function _createBatchMakerAsks(uint256 numberOrders) private view returns (OrderStructs.Maker[] memory makerAsks) { + makerAsks = new OrderStructs.Maker[](numberOrders); + for (uint256 i; i < numberOrders; i++) { + makerAsks[i] = _createSingleItemMakerOrder({ + quoteType: QuoteType.Ask, + globalNonce: 0, + subsetNonce: 0, + strategyId: STANDARD_SALE_FOR_FIXED_PRICE_STRATEGY, + collectionType: CollectionType.ERC721, + orderNonce: i, // incremental + collection: address(mockERC721), + currency: ETH, + signer: makerUser, + price: price, + itemId: i + }); + } + } + + function _createBatchMakerBids(uint256 numberOrders) private view returns (OrderStructs.Maker[] memory makerBids) { + makerBids = new OrderStructs.Maker[](numberOrders); + for (uint256 i; i < numberOrders; i++) { + makerBids[i] = _createSingleItemMakerOrder({ + quoteType: QuoteType.Bid, + globalNonce: 0, + subsetNonce: 0, + strategyId: STANDARD_SALE_FOR_FIXED_PRICE_STRATEGY, + collectionType: CollectionType.ERC721, + orderNonce: i, // incremental + collection: address(mockERC721), + currency: address(weth), + signer: makerUser, + price: price, + itemId: i + }); + } + } + + function _assertMerkleTreeAssumptions(uint256 numberOrders, uint256 orderIndex) private pure { + vm.assume(numberOrders > 0 && numberOrders <= 2 ** MAX_CALLDATA_PROOF_LENGTH); + vm.assume(orderIndex < numberOrders); + } +} diff --git a/contracts/test/foundry/marketplace/BatchOrderTypehashRegistry.t.sol b/contracts/test/foundry/marketplace/BatchOrderTypehashRegistry.t.sol new file mode 100644 index 00000000..e44c2af4 --- /dev/null +++ b/contracts/test/foundry/marketplace/BatchOrderTypehashRegistry.t.sol @@ -0,0 +1,120 @@ +// SPDX-License-Identifier: MIT +pragma solidity 0.8.17; + +import {Test} from "forge-std/Test.sol"; + +import {BatchOrderTypehashRegistry} from "@hypercerts/marketplace/BatchOrderTypehashRegistry.sol"; + +// Shared errors +import {MerkleProofTooLarge} from "@hypercerts/marketplace/errors/SharedErrors.sol"; + +contract BatchOrderTypehashRegistryInheriter is BatchOrderTypehashRegistry { + function getBatchOrderTypehash(uint256 height) external pure returns (bytes32 typehash) { + return _getBatchOrderTypehash(height); + } +} + +contract BatchOrderTypehashRegistryTest is Test { + function testHash() public { + BatchOrderTypehashRegistryInheriter registry = new BatchOrderTypehashRegistryInheriter(); + bytes32 root = hex"6942000000000000000000000000000000000000000000000000000000000000"; + assertEq( + registry.hashBatchOrder(root, 1), hex"8f0c85a215cff55fe39cf62ee7a1e0b5205a8ade02ff12ffee9ece02d626ffc3" + ); + assertEq( + registry.hashBatchOrder(root, 2), hex"f04a7d8a4688cf084b00b51ed583de7e5a19e59b073635e00a45a474899e89ec" + ); + assertEq( + registry.hashBatchOrder(root, 3), hex"56ef3bb8c564d19cfe494776934aa5e7ed84c41ae609d5f10e726f76281dd30b" + ); + assertEq( + registry.hashBatchOrder(root, 4), hex"2b0cb021eacab73e36d9ac9a04c1cf58589ff5bb4dc0d9b88ec29f67358ca812" + ); + assertEq( + registry.hashBatchOrder(root, 5), hex"253b3cc8d591a8b01fc8967cefe3ac3d0e078b884d96aa589f1ffd4536921bbb" + ); + assertEq( + registry.hashBatchOrder(root, 6), hex"7e4c4a2c5806fc4765bca325e8b78ccf9633bd1c7643144a56210293daefcbca" + ); + assertEq( + registry.hashBatchOrder(root, 7), hex"e8e39cebe7137f0fadf6b88ba611044ac79c0168444eab66ca53bddd0c5fb717" + ); + assertEq( + registry.hashBatchOrder(root, 8), hex"6e02f123509255ed381c7552de5e2ac1c1ea401a23e026e2452f01b70564affb" + ); + assertEq( + registry.hashBatchOrder(root, 9), hex"7eeb4a7fe4655841fdd66f8ecfcf6cd261d50eafabbaebb10f63f5fe84ddddc9" + ); + assertEq( + registry.hashBatchOrder(root, 10), hex"a96dee8b7b88deda5d50b55f641ca08c1ee00825eeb1db7a324f392fa0b8bb83" + ); + } + + function testGetTypehash() public { + BatchOrderTypehashRegistryInheriter registry = new BatchOrderTypehashRegistryInheriter(); + bytes memory makerOrderString = bytes( + "Maker(" "uint8 quoteType," "uint256 globalNonce," "uint256 subsetNonce," "uint256 orderNonce," + "uint256 strategyId," "uint8 collectionType," "address collection," "address currency," "address signer," + "uint256 startTime," "uint256 endTime," "uint256 price," "uint256[] itemIds," "uint256[] amounts," + "bytes additionalParameters" ")" + ); + + assertEq( + registry.getBatchOrderTypehash(1), + keccak256(bytes.concat(bytes("BatchOrder(Maker[2] tree)"), makerOrderString)) + ); + + assertEq( + registry.getBatchOrderTypehash(2), + keccak256(bytes.concat(bytes("BatchOrder(Maker[2][2] tree)"), makerOrderString)) + ); + + assertEq( + registry.getBatchOrderTypehash(3), + keccak256(bytes.concat(bytes("BatchOrder(Maker[2][2][2] tree)"), makerOrderString)) + ); + + assertEq( + registry.getBatchOrderTypehash(4), + keccak256(bytes.concat(bytes("BatchOrder(Maker[2][2][2][2] tree)"), makerOrderString)) + ); + + assertEq( + registry.getBatchOrderTypehash(5), + keccak256(bytes.concat(bytes("BatchOrder(Maker[2][2][2][2][2] tree)"), makerOrderString)) + ); + + assertEq( + registry.getBatchOrderTypehash(6), + keccak256(bytes.concat(bytes("BatchOrder(Maker[2][2][2][2][2][2] tree)"), makerOrderString)) + ); + + assertEq( + registry.getBatchOrderTypehash(7), + keccak256(bytes.concat(bytes("BatchOrder(Maker[2][2][2][2][2][2][2] tree)"), makerOrderString)) + ); + + assertEq( + registry.getBatchOrderTypehash(8), + keccak256(bytes.concat(bytes("BatchOrder(Maker[2][2][2][2][2][2][2][2] tree)"), makerOrderString)) + ); + + assertEq( + registry.getBatchOrderTypehash(9), + keccak256(bytes.concat(bytes("BatchOrder(Maker[2][2][2][2][2][2][2][2][2] tree)"), makerOrderString)) + ); + + assertEq( + registry.getBatchOrderTypehash(10), + keccak256(bytes.concat(bytes("BatchOrder(Maker[2][2][2][2][2][2][2][2][2][2] tree)"), makerOrderString)) + ); + } + + function testGetTypehashMerkleProofTooLarge(uint256 height) public { + vm.assume(height > 10); + + BatchOrderTypehashRegistryInheriter registry = new BatchOrderTypehashRegistryInheriter(); + vm.expectRevert(abi.encodeWithSelector(MerkleProofTooLarge.selector, height)); + registry.getBatchOrderTypehash(height); + } +} diff --git a/contracts/test/foundry/marketplace/BundleTransactions.t.sol b/contracts/test/foundry/marketplace/BundleTransactions.t.sol new file mode 100644 index 00000000..62ffccf9 --- /dev/null +++ b/contracts/test/foundry/marketplace/BundleTransactions.t.sol @@ -0,0 +1,260 @@ +// SPDX-License-Identifier: MIT +pragma solidity 0.8.17; + +// Libraries +import {OrderStructs} from "@hypercerts/marketplace/libraries/OrderStructs.sol"; + +// Other tests +import {ProtocolBase} from "./ProtocolBase.t.sol"; + +// Constants +import {ONE_HUNDRED_PERCENT_IN_BP} from "@hypercerts/marketplace/constants/NumericConstants.sol"; + +contract BundleTransactionsTest is ProtocolBase { + function setUp() public { + _setUp(); + } + + function testTakerAskERC721BundleNoRoyalties() public { + _setUpUsers(); + uint256 numberItemsInBundle = 5; + + (OrderStructs.Maker memory makerBid, OrderStructs.Taker memory takerAsk) = + _createMockMakerBidAndTakerAskWithBundle(address(mockERC721), address(weth), numberItemsInBundle); + + // Sign the order + bytes memory signature = _signMakerOrder(makerBid, makerUserPK); + + // Verify validity + _assertValidMakerOrder(makerBid, signature); + + // Mint the items + mockERC721.batchMint(takerUser, makerBid.itemIds); + + // Execute taker ask transaction + vm.prank(takerUser); + looksRareProtocol.executeTakerAsk(takerAsk, makerBid, signature, _EMPTY_MERKLE_TREE); + + _assertMockERC721Ownership(makerBid.itemIds, makerUser); + + _assertSuccessfulTakerAskNoRoyalties(makerBid); + } + + function testTakerAskERC1155BundleNoRoyalties() public { + _setUpUsers(); + uint256 numberItemsInBundle = 5; + + (OrderStructs.Maker memory makerBid, OrderStructs.Taker memory takerAsk) = + _createMockMakerBidAndTakerAskWithBundle(address(mockERC1155), address(weth), numberItemsInBundle); + + // Sign the order + bytes memory signature = _signMakerOrder(makerBid, makerUserPK); + + // Verify validity + _assertValidMakerOrder(makerBid, signature); + + // Mint the items + mockERC1155.batchMint(takerUser, makerBid.itemIds, makerBid.amounts); + + // Execute taker ask transaction + vm.prank(takerUser); + looksRareProtocol.executeTakerAsk(takerAsk, makerBid, signature, _EMPTY_MERKLE_TREE); + + for (uint256 i; i < makerBid.itemIds.length; i++) { + // Maker user has received all the assets in the bundle + assertEq(mockERC1155.balanceOf(makerUser, makerBid.itemIds[i]), makerBid.amounts[i]); + } + + _assertSuccessfulTakerAskNoRoyalties(makerBid); + } + + function testTakerAskERC721BundleWithRoyaltiesFromRegistry() public { + _setUpUsers(); + _setupRegistryRoyalties(address(mockERC721), _standardRoyaltyFee); + uint256 numberItemsInBundle = 5; + + (OrderStructs.Maker memory makerBid, OrderStructs.Taker memory takerAsk) = + _createMockMakerBidAndTakerAskWithBundle(address(mockERC721), address(weth), numberItemsInBundle); + + uint256 price = makerBid.price; + + // Sign the order + bytes memory signature = _signMakerOrder(makerBid, makerUserPK); + + // Verify validity + _assertValidMakerOrder(makerBid, signature); + + // Mint the items + mockERC721.batchMint(takerUser, makerBid.itemIds); + + // Execute taker ask transaction + vm.prank(takerUser); + looksRareProtocol.executeTakerAsk(takerAsk, makerBid, signature, _EMPTY_MERKLE_TREE); + + _assertMockERC721Ownership(makerBid.itemIds, makerUser); + + // Maker bid user pays the whole price + assertEq(weth.balanceOf(makerUser), _initialWETHBalanceUser - price); + // Royalty recipient receives royalties + assertEq( + weth.balanceOf(_royaltyRecipient), + _initialWETHBalanceRoyaltyRecipient + (price * _standardRoyaltyFee) / ONE_HUNDRED_PERCENT_IN_BP + ); + assertEq( + weth.balanceOf(address(protocolFeeRecipient)), + (price * _standardProtocolFeeBp) / ONE_HUNDRED_PERCENT_IN_BP, + "ProtocolFeeRecipient should receive protocol fee" + ); + // Taker ask user receives 99.5% of the whole price + assertEq( + weth.balanceOf(takerUser), + _initialWETHBalanceUser + (price * _sellerProceedBpWithStandardProtocolFeeBp) / ONE_HUNDRED_PERCENT_IN_BP + ); + // Verify the nonce is marked as executed + assertEq(looksRareProtocol.userOrderNonce(makerUser, makerBid.orderNonce), MAGIC_VALUE_ORDER_NONCE_EXECUTED); + } + + function testTakerBidERC721BundleNoRoyalties() public { + _setUpUsers(); + uint256 numberItemsInBundle = 5; + + (OrderStructs.Maker memory makerAsk, OrderStructs.Taker memory takerBid) = + _createMockMakerAskAndTakerBidWithBundle(address(mockERC721), numberItemsInBundle); + + uint256 price = makerAsk.price; + + // Mint the items and sign the order + mockERC721.batchMint(makerUser, makerAsk.itemIds); + bytes memory signature = _signMakerOrder(makerAsk, makerUserPK); + + // Verify validity + _assertValidMakerOrder(makerAsk, signature); + + // Execute taker bid transaction + vm.prank(takerUser); + looksRareProtocol.executeTakerBid{value: price}(takerBid, makerAsk, signature, _EMPTY_MERKLE_TREE); + + _assertMockERC721Ownership(makerAsk.itemIds, takerUser); + + _assertSuccessfulTakerBidNoRoyalties(makerAsk); + } + + function testTakerBidERC1155BundleNoRoyalties() public { + _setUpUsers(); + uint256 numberItemsInBundle = 5; + + (OrderStructs.Maker memory makerAsk, OrderStructs.Taker memory takerBid) = + _createMockMakerAskAndTakerBidWithBundle(address(mockERC1155), numberItemsInBundle); + + uint256 price = makerAsk.price; + + // Mint the items and sign the order + mockERC1155.batchMint(makerUser, makerAsk.itemIds, makerAsk.amounts); + bytes memory signature = _signMakerOrder(makerAsk, makerUserPK); + + // Verify validity + _assertValidMakerOrder(makerAsk, signature); + + // Execute taker bid transaction + vm.prank(takerUser); + looksRareProtocol.executeTakerBid{value: price}(takerBid, makerAsk, signature, _EMPTY_MERKLE_TREE); + + for (uint256 i; i < makerAsk.itemIds.length; i++) { + // Taker user has received all the assets in the bundle + assertEq(mockERC1155.balanceOf(takerUser, makerAsk.itemIds[i]), makerAsk.amounts[i]); + } + + _assertSuccessfulTakerBidNoRoyalties(makerAsk); + } + + function testTakerBidERC721BundleWithRoyaltiesFromRegistry() public { + _setUpUsers(); + _setupRegistryRoyalties(address(mockERC721), _standardRoyaltyFee); + uint256 numberItemsInBundle = 5; + + (OrderStructs.Maker memory makerAsk, OrderStructs.Taker memory takerBid) = + _createMockMakerAskAndTakerBidWithBundle(address(mockERC721), numberItemsInBundle); + + uint256 price = makerAsk.price; + + // Mint the items and sign the order + mockERC721.batchMint(makerUser, makerAsk.itemIds); + bytes memory signature = _signMakerOrder(makerAsk, makerUserPK); + + // Verify validity + _assertValidMakerOrder(makerAsk, signature); + + // Execute taker bid transaction + vm.prank(takerUser); + + looksRareProtocol.executeTakerBid{value: price}(takerBid, makerAsk, signature, _EMPTY_MERKLE_TREE); + + _assertMockERC721Ownership(makerAsk.itemIds, takerUser); + + // Taker bid user pays the whole price + assertEq(address(takerUser).balance, _initialETHBalanceUser - price); + // Royalty recipient receives the royalties + assertEq( + address(_royaltyRecipient).balance, + _initialETHBalanceRoyaltyRecipient + (price * _standardRoyaltyFee) / ONE_HUNDRED_PERCENT_IN_BP + ); + assertEq( + address(protocolFeeRecipient).balance, + (price * _standardProtocolFeeBp) / ONE_HUNDRED_PERCENT_IN_BP, + "ProtocolFeeRecipient should receive protocol fee" + ); + // Maker ask user receives 99.5% of the whole price + assertEq( + address(makerUser).balance, + _initialETHBalanceUser + (price * _sellerProceedBpWithStandardProtocolFeeBp) / ONE_HUNDRED_PERCENT_IN_BP + ); + // No leftover in the balance of the contract + assertEq(address(looksRareProtocol).balance, 0); + // Verify the nonce is marked as executed + assertEq(looksRareProtocol.userOrderNonce(makerUser, makerAsk.orderNonce), MAGIC_VALUE_ORDER_NONCE_EXECUTED); + } + + function _assertSuccessfulTakerAskNoRoyalties(OrderStructs.Maker memory makerBid) private { + uint256 price = makerBid.price; + + // Maker bid user pays the whole price + assertEq(weth.balanceOf(makerUser), _initialWETHBalanceUser - price); + // Royalty recipient receives no royalty + assertEq(weth.balanceOf(_royaltyRecipient), _initialWETHBalanceRoyaltyRecipient); + assertEq( + weth.balanceOf(address(protocolFeeRecipient)), + (price * _minTotalFeeBp) / ONE_HUNDRED_PERCENT_IN_BP, + "ProtocolFeeRecipient should receive protocol fee" + ); + // Taker ask user receives 99.5% of the whole price (no royalties are paid) + assertEq( + weth.balanceOf(takerUser), + _initialWETHBalanceUser + (price * _sellerProceedBpWithStandardProtocolFeeBp) / ONE_HUNDRED_PERCENT_IN_BP + ); + // Verify the nonce is marked as executed + assertEq(looksRareProtocol.userOrderNonce(makerUser, makerBid.orderNonce), MAGIC_VALUE_ORDER_NONCE_EXECUTED); + } + + function _assertSuccessfulTakerBidNoRoyalties(OrderStructs.Maker memory makerAsk) private { + uint256 price = makerAsk.price; + + // Taker bid user pays the whole price + assertEq(address(takerUser).balance, _initialETHBalanceUser - price); + // Royalty recipient receives no royalty + assertEq(address(_royaltyRecipient).balance, _initialETHBalanceRoyaltyRecipient); + assertEq( + address(protocolFeeRecipient).balance, + (price * _minTotalFeeBp) / ONE_HUNDRED_PERCENT_IN_BP, + "ProtocolFeeRecipient should receive protocol fee" + ); + // Maker ask user receives 99.5% of the whole price (no royalties are paid) + assertEq( + address(makerUser).balance, + _initialETHBalanceUser + (price * _sellerProceedBpWithStandardProtocolFeeBp) / ONE_HUNDRED_PERCENT_IN_BP + ); + // No leftover in the balance of the contract + assertEq(address(looksRareProtocol).balance, 0); + // Verify the nonce is marked as executed + assertEq(looksRareProtocol.userOrderNonce(makerUser, makerAsk.orderNonce), MAGIC_VALUE_ORDER_NONCE_EXECUTED); + } +} diff --git a/contracts/test/foundry/marketplace/CreatorFeeManagerWithRebates.t.sol b/contracts/test/foundry/marketplace/CreatorFeeManagerWithRebates.t.sol new file mode 100644 index 00000000..93a552db --- /dev/null +++ b/contracts/test/foundry/marketplace/CreatorFeeManagerWithRebates.t.sol @@ -0,0 +1,233 @@ +// SPDX-License-Identifier: MIT +pragma solidity 0.8.17; + +// LooksRare unopinionated libraries +import {IERC721} from "@looksrare/contracts-libs/contracts/interfaces/generic/IERC721.sol"; + +import {CreatorFeeManagerWithRebates} from "@hypercerts/marketplace/CreatorFeeManagerWithRebates.sol"; + +// Libraries and interfaces +import {OrderStructs} from "@hypercerts/marketplace/libraries/OrderStructs.sol"; +import {ICreatorFeeManager} from "@hypercerts/marketplace/interfaces/ICreatorFeeManager.sol"; +import {IExecutionManager} from "@hypercerts/marketplace/interfaces/IExecutionManager.sol"; + +// Shared errors +import {BUNDLE_ERC2981_NOT_SUPPORTED} from "@hypercerts/marketplace/constants/ValidationCodeConstants.sol"; + +// Base test +import {ProtocolBase} from "./ProtocolBase.t.sol"; + +// Constants +import {ONE_HUNDRED_PERCENT_IN_BP} from "@hypercerts/marketplace/constants/NumericConstants.sol"; + +contract CreatorFeeManagerWithRebatesTest is ProtocolBase { + function setUp() public { + _setUp(); + CreatorFeeManagerWithRebates creatorFeeManager = new CreatorFeeManagerWithRebates(address(royaltyFeeRegistry)); + vm.prank(_owner); + looksRareProtocol.updateCreatorFeeManager(address(creatorFeeManager)); + orderValidator.deriveProtocolParameters(); + } + + function _setUpRoyaltiesRegistry(uint256 fee) private { + vm.prank(_owner); + royaltyFeeRegistry.updateRoyaltyInfoForCollection( + address(mockERC721), _royaltyRecipient, _royaltyRecipient, fee + ); + } + + function _testCreatorFeeRebatesArePaid(address erc721) private { + _setUpUsers(); + + (OrderStructs.Maker memory makerBid, OrderStructs.Taker memory takerAsk) = + _createMockMakerBidAndTakerAsk(erc721, address(weth)); + + bytes memory signature = _signMakerOrder(makerBid, makerUserPK); + + if (erc721 == address(mockERC721)) { + // Adjust royalties + _setUpRoyaltiesRegistry(_standardRoyaltyFee); + // Mint asset + mockERC721.mint(takerUser, makerBid.itemIds[0]); + } else if (erc721 == address(mockERC721WithRoyalties)) { + // Adjust ERC721 with royalties + mockERC721WithRoyalties.addCustomRoyaltyInformationForTokenId( + makerBid.itemIds[0], _royaltyRecipient, _standardRoyaltyFee + ); + // Mint asset + mockERC721WithRoyalties.mint(takerUser, makerBid.itemIds[0]); + } + + _assertValidMakerOrder(makerBid, signature); + + // Execute taker ask transaction + vm.prank(takerUser); + looksRareProtocol.executeTakerAsk(takerAsk, makerBid, signature, _EMPTY_MERKLE_TREE); + + // Verify ownership is transferred + assertEq(IERC721(erc721).ownerOf(makerBid.itemIds[0]), makerUser); + _assertSuccessfulTakerAsk(makerBid); + } + + function _testCreatorFeeRebatesArePaidForBundles(address erc721) private { + _setUpUsers(); + _setUpRoyaltiesRegistry(_standardRoyaltyFee); + + // Parameters + uint256 numberItemsInBundle = 5; + + // Create order + (OrderStructs.Maker memory makerBid, OrderStructs.Taker memory takerAsk) = + _createMockMakerBidAndTakerAskWithBundle(erc721, address(weth), numberItemsInBundle); + + if (erc721 == address(mockERC721)) { + // Adjust royalties + _setUpRoyaltiesRegistry(_standardRoyaltyFee); + // Mint the items + mockERC721.batchMint(takerUser, makerBid.itemIds); + } else if (erc721 == address(mockERC721WithRoyalties)) { + // Adjust ERC721 with royalties + for (uint256 i; i < makerBid.itemIds.length; i++) { + mockERC721WithRoyalties.addCustomRoyaltyInformationForTokenId( + makerBid.itemIds[i], _royaltyRecipient, _standardRoyaltyFee + ); + } + // Mint the items + mockERC721WithRoyalties.batchMint(takerUser, makerBid.itemIds); + } + + // Sign the order + bytes memory signature = _signMakerOrder(makerBid, makerUserPK); + + _assertValidMakerOrder(makerBid, signature); + + // Taker user actions + vm.prank(takerUser); + + // Execute taker ask transaction + looksRareProtocol.executeTakerAsk(takerAsk, makerBid, signature, _EMPTY_MERKLE_TREE); + + // Verify ownership is transferred + for (uint256 i; i < makerBid.itemIds.length; i++) { + // Maker user has received all the assets in the bundle + assertEq(IERC721(erc721).ownerOf(makerBid.itemIds[i]), makerUser); + } + _assertSuccessfulTakerAsk(makerBid); + } + + function testCreatorRebatesArePaidForRoyaltyFeeManager() public { + _testCreatorFeeRebatesArePaid(address(mockERC721)); + } + + function testCreatorRebatesArePaidForERC2981() public { + _testCreatorFeeRebatesArePaid(address(mockERC721WithRoyalties)); + } + + function testCreatorRebatesArePaidForRoyaltyFeeManagerWithBundles() public { + _testCreatorFeeRebatesArePaidForBundles(address(mockERC721)); + } + + function testCreatorRoyaltiesGetPaidForERC2981WithBundles() public { + _testCreatorFeeRebatesArePaidForBundles(address(mockERC721WithRoyalties)); + } + + function testCreatorRoyaltiesRevertForEIP2981WithBundlesIfInfoDiffer() public { + _setUpUsers(); + + uint256 numberItemsInBundle = 5; + + (OrderStructs.Maker memory makerBid, OrderStructs.Taker memory takerAsk) = + _createMockMakerBidAndTakerAskWithBundle(address(mockERC721WithRoyalties), address(weth), numberItemsInBundle); + + // Sign the order + bytes memory signature = _signMakerOrder(makerBid, makerUserPK); + + // Mint the items + mockERC721WithRoyalties.batchMint(takerUser, makerBid.itemIds); + + _assertValidMakerOrder(makerBid, signature); + + /** + * Different recipient + */ + + // Adjust ERC721 with royalties + for (uint256 i; i < makerBid.itemIds.length; i++) { + mockERC721WithRoyalties.addCustomRoyaltyInformationForTokenId( + makerBid.itemIds[i], i == 0 ? _royaltyRecipient : address(50), 50 + ); + } + + _assertMakerOrderReturnValidationCode(makerBid, signature, BUNDLE_ERC2981_NOT_SUPPORTED); + + vm.prank(takerUser); + vm.expectRevert( + abi.encodeWithSelector( + ICreatorFeeManager.BundleEIP2981NotAllowed.selector, address(mockERC721WithRoyalties) + ) + ); + looksRareProtocol.executeTakerAsk(takerAsk, makerBid, signature, _EMPTY_MERKLE_TREE); + } + + function testCreatorRoyaltiesRevertForEIP2981WithBundlesIfAtLeastOneCallReverts(uint256 revertIndex) public { + _setUpUsers(); + + uint256 numberItemsInBundle = 5; + vm.assume(revertIndex < numberItemsInBundle); + + (OrderStructs.Maker memory makerBid, OrderStructs.Taker memory takerAsk) = + _createMockMakerBidAndTakerAskWithBundle(address(mockERC721WithRoyalties), address(weth), numberItemsInBundle); + + // Sign the order + bytes memory signature = _signMakerOrder(makerBid, makerUserPK); + + // Mint the items + mockERC721WithRoyalties.batchMint(takerUser, makerBid.itemIds); + + _assertValidMakerOrder(makerBid, signature); + + // Adjust ERC721 with royalties + for (uint256 i; i < makerBid.itemIds.length; i++) { + mockERC721WithRoyalties.addCustomRoyaltyInformationForTokenId( + makerBid.itemIds[i], + _royaltyRecipient, + // if greater than 10,000, will revert in royaltyInfo + i == revertIndex ? 10_001 : 50 + ); + } + + _assertMakerOrderReturnValidationCode(makerBid, signature, BUNDLE_ERC2981_NOT_SUPPORTED); + + vm.prank(takerUser); + vm.expectRevert( + abi.encodeWithSelector( + ICreatorFeeManager.BundleEIP2981NotAllowed.selector, address(mockERC721WithRoyalties) + ) + ); + looksRareProtocol.executeTakerAsk(takerAsk, makerBid, signature, _EMPTY_MERKLE_TREE); + } + + function _assertSuccessfulTakerAsk(OrderStructs.Maker memory makerBid) private { + uint256 price = makerBid.price; + + // Maker bid user pays the whole price + assertEq(weth.balanceOf(makerUser), _initialWETHBalanceUser - price); + assertEq( + weth.balanceOf(address(protocolFeeRecipient)), + (price * _standardProtocolFeeBp) / ONE_HUNDRED_PERCENT_IN_BP, + "Protocol fee recipient should receive 0.5% of the whole price" + ); + assertEq( + weth.balanceOf(takerUser), + _initialWETHBalanceUser + (price * 9900) / ONE_HUNDRED_PERCENT_IN_BP, + "Taker ask user should receive 99% of the whole price" + ); + assertEq( + weth.balanceOf(_royaltyRecipient), + _initialWETHBalanceRoyaltyRecipient + (price * 50) / ONE_HUNDRED_PERCENT_IN_BP, + "Royalty recipient receives 0.5% of the whole price" + ); + // Verify the nonce is marked as executed + assertEq(looksRareProtocol.userOrderNonce(makerUser, makerBid.orderNonce), MAGIC_VALUE_ORDER_NONCE_EXECUTED); + } +} diff --git a/contracts/test/foundry/marketplace/CreatorFeeManagerWithRoyalties.t.sol b/contracts/test/foundry/marketplace/CreatorFeeManagerWithRoyalties.t.sol new file mode 100644 index 00000000..3ba84222 --- /dev/null +++ b/contracts/test/foundry/marketplace/CreatorFeeManagerWithRoyalties.t.sol @@ -0,0 +1,350 @@ +// SPDX-License-Identifier: MIT +pragma solidity 0.8.17; + +// Libraries and interfaces +import {OrderStructs} from "@hypercerts/marketplace/libraries/OrderStructs.sol"; +import {ICreatorFeeManager} from "@hypercerts/marketplace/interfaces/ICreatorFeeManager.sol"; +import {IExecutionManager} from "@hypercerts/marketplace/interfaces/IExecutionManager.sol"; + +// Core contract +import {CreatorFeeManagerWithRoyalties} from "@hypercerts/marketplace/CreatorFeeManagerWithRoyalties.sol"; + +// Shared errors +import { + BUNDLE_ERC2981_NOT_SUPPORTED, + CREATOR_FEE_TOO_HIGH +} from "@hypercerts/marketplace/constants/ValidationCodeConstants.sol"; + +// Base test +import {ProtocolBase} from "./ProtocolBase.t.sol"; + +// Constants +import {ONE_HUNDRED_PERCENT_IN_BP} from "@hypercerts/marketplace/constants/NumericConstants.sol"; + +contract CreatorFeeManagerWithRoyaltiesTest is ProtocolBase { + CreatorFeeManagerWithRoyalties public creatorFeeManagerWithRoyalties; + + // New protocol fee + uint16 internal constant _newProtocolFee = 200; + + // New creator royalty fee + uint256 internal constant _newCreatorRoyaltyFee = 300; + + function _setUpRoyaltiesRegistry(uint256 fee) internal { + vm.prank(_owner); + royaltyFeeRegistry.updateRoyaltyInfoForCollection( + address(mockERC721), _royaltyRecipient, _royaltyRecipient, fee + ); + } + + function setUp() public { + _setUp(); + creatorFeeManagerWithRoyalties = new CreatorFeeManagerWithRoyalties(address(royaltyFeeRegistry)); + vm.startPrank(_owner); + looksRareProtocol.updateCreatorFeeManager(address(creatorFeeManagerWithRoyalties)); + // Set up 2% as protocol fee, which is now equal to minimum fee + looksRareProtocol.updateStrategy(0, true, _newProtocolFee, _newProtocolFee); + vm.stopPrank(); + + // Adjust for new creator fee manager + orderValidator.deriveProtocolParameters(); + } + + function testCreatorRoyaltiesGetPaidForRoyaltyFeeManager() public { + _setUpUsers(); + + // Adjust royalties + _setUpRoyaltiesRegistry(_newCreatorRoyaltyFee); + + (OrderStructs.Maker memory makerBid,) = _createMockMakerBidAndTakerAsk(address(mockERC721), address(weth)); + + // Sign order + bytes memory signature = _signMakerOrder(makerBid, makerUserPK); + + // Mint asset + mockERC721.mint(takerUser, makerBid.itemIds[0]); + + _assertValidMakerOrder(makerBid, signature); + + // Execute taker ask transaction + vm.prank(takerUser); + looksRareProtocol.executeTakerAsk(_genericTakerOrder(), makerBid, signature, _EMPTY_MERKLE_TREE); + + // Taker user has received the asset + assertEq(mockERC721.ownerOf(makerBid.itemIds[0]), makerUser); + _assertSuccessfulTakerAsk(makerBid); + } + + function testCreatorRoyaltiesGetPaidForERC2981() public { + _setUpUsers(); + + (OrderStructs.Maker memory makerBid,) = + _createMockMakerBidAndTakerAsk(address(mockERC721WithRoyalties), address(weth)); + + // Adjust ERC721 with royalties + mockERC721WithRoyalties.addCustomRoyaltyInformationForTokenId( + makerBid.itemIds[0], _royaltyRecipient, _newCreatorRoyaltyFee + ); + + // Sign order + bytes memory signature = _signMakerOrder(makerBid, makerUserPK); + + // Mint asset + mockERC721WithRoyalties.mint(takerUser, makerBid.itemIds[0]); + + _assertValidMakerOrder(makerBid, signature); + + // Execute taker ask transaction + vm.prank(takerUser); + looksRareProtocol.executeTakerAsk(_genericTakerOrder(), makerBid, signature, _EMPTY_MERKLE_TREE); + + // Taker user has received the asset + assertEq(mockERC721WithRoyalties.ownerOf(makerBid.itemIds[0]), makerUser); + _assertSuccessfulTakerAsk(makerBid); + } + + function testCreatorRoyaltiesGetPaidForRoyaltyFeeManagerWithBundles() public { + _setUpUsers(); + + // Adjust royalties + _setUpRoyaltiesRegistry(_newCreatorRoyaltyFee); + + uint256 numberItemsInBundle = 5; + + (OrderStructs.Maker memory makerBid, OrderStructs.Taker memory takerAsk) = + _createMockMakerBidAndTakerAskWithBundle(address(mockERC721), address(weth), numberItemsInBundle); + + // Sign the order + bytes memory signature = _signMakerOrder(makerBid, makerUserPK); + + // Mint the items + mockERC721.batchMint(takerUser, makerBid.itemIds); + + // Check order validity + _assertValidMakerOrder(makerBid, signature); + + // Taker user actions + vm.prank(takerUser); + + // Execute taker ask transaction + looksRareProtocol.executeTakerAsk(takerAsk, makerBid, signature, _EMPTY_MERKLE_TREE); + + _assertMockERC721Ownership(makerBid.itemIds, makerUser); + + _assertSuccessfulTakerAskBundle(makerBid); + } + + function testCreatorRoyaltiesGetPaidForERC2981WithBundles() public { + _setUpUsers(); + + uint256 numberItemsInBundle = 5; + + (OrderStructs.Maker memory makerBid, OrderStructs.Taker memory takerAsk) = + _createMockMakerBidAndTakerAskWithBundle(address(mockERC721WithRoyalties), address(weth), numberItemsInBundle); + + // Sign the order + bytes memory signature = _signMakerOrder(makerBid, makerUserPK); + + // Mint the items + mockERC721WithRoyalties.batchMint(takerUser, makerBid.itemIds); + + // Adjust ERC721 with royalties + for (uint256 i; i < makerBid.itemIds.length; i++) { + mockERC721WithRoyalties.addCustomRoyaltyInformationForTokenId( + makerBid.itemIds[i], _royaltyRecipient, _newCreatorRoyaltyFee + ); + } + + _assertValidMakerOrder(makerBid, signature); + + // Taker user actions + vm.prank(takerUser); + + // Execute taker ask transaction + looksRareProtocol.executeTakerAsk(takerAsk, makerBid, signature, _EMPTY_MERKLE_TREE); + + _assertSuccessfulTakerAskBundle(makerBid); + } + + function testCreatorRoyaltiesRevertForEIP2981WithBundlesIfInfoDiffer() public { + _setUpUsers(); + + uint256 numberItemsInBundle = 5; + + (OrderStructs.Maker memory makerBid, OrderStructs.Taker memory takerAsk) = + _createMockMakerBidAndTakerAskWithBundle(address(mockERC721WithRoyalties), address(weth), numberItemsInBundle); + + // Sign the order + bytes memory signature = _signMakerOrder(makerBid, makerUserPK); + + // Mint the items + mockERC721WithRoyalties.batchMint(takerUser, makerBid.itemIds); + + /** + * 1. Different fee structure but same recipient + */ + + // Adjust ERC721 with royalties + for (uint256 i; i < makerBid.itemIds.length; i++) { + mockERC721WithRoyalties.addCustomRoyaltyInformationForTokenId( + makerBid.itemIds[i], + _royaltyRecipient, + _newCreatorRoyaltyFee - i // It is not equal + ); + } + + _assertMakerOrderReturnValidationCode(makerBid, signature, BUNDLE_ERC2981_NOT_SUPPORTED); + + // Taker user action should revert + vm.prank(takerUser); + vm.expectRevert( + abi.encodeWithSelector( + ICreatorFeeManager.BundleEIP2981NotAllowed.selector, address(mockERC721WithRoyalties) + ) + ); + + looksRareProtocol.executeTakerAsk(takerAsk, makerBid, signature, _EMPTY_MERKLE_TREE); + + /** + * 2. Same fee structure but different recipient + */ + // Adjust ERC721 with royalties + for (uint256 i; i < makerBid.itemIds.length; i++) { + mockERC721WithRoyalties.addCustomRoyaltyInformationForTokenId( + makerBid.itemIds[i], i == 0 ? _royaltyRecipient : address(50), _newCreatorRoyaltyFee + ); + } + + _assertMakerOrderReturnValidationCode(makerBid, signature, BUNDLE_ERC2981_NOT_SUPPORTED); + + vm.prank(takerUser); + vm.expectRevert( + abi.encodeWithSelector( + ICreatorFeeManager.BundleEIP2981NotAllowed.selector, address(mockERC721WithRoyalties) + ) + ); + + looksRareProtocol.executeTakerAsk(takerAsk, makerBid, signature, _EMPTY_MERKLE_TREE); + } + + function testCreatorRoyaltiesRevertForEIP2981WithBundlesIfAtLeastOneCallReverts(uint256 revertIndex) public { + _setUpUsers(); + + uint256 numberItemsInBundle = 5; + vm.assume(revertIndex < numberItemsInBundle); + + (OrderStructs.Maker memory makerBid, OrderStructs.Taker memory takerAsk) = + _createMockMakerBidAndTakerAskWithBundle(address(mockERC721WithRoyalties), address(weth), numberItemsInBundle); + + // Sign the order + bytes memory signature = _signMakerOrder(makerBid, makerUserPK); + + // Mint the items + mockERC721WithRoyalties.batchMint(takerUser, makerBid.itemIds); + + // Adjust ERC721 with royalties + for (uint256 i; i < makerBid.itemIds.length; i++) { + mockERC721WithRoyalties.addCustomRoyaltyInformationForTokenId( + makerBid.itemIds[i], + _royaltyRecipient, + // if greater than 10,000, will revert in royaltyInfo + i == revertIndex ? 10_001 : _newCreatorRoyaltyFee + ); + } + + _assertMakerOrderReturnValidationCode(makerBid, signature, BUNDLE_ERC2981_NOT_SUPPORTED); + + // Taker user action should revert + vm.prank(takerUser); + vm.expectRevert( + abi.encodeWithSelector( + ICreatorFeeManager.BundleEIP2981NotAllowed.selector, address(mockERC721WithRoyalties) + ) + ); + + looksRareProtocol.executeTakerAsk(takerAsk, makerBid, signature, _EMPTY_MERKLE_TREE); + } + + function testCreatorRoyaltiesRevertIfFeeHigherThanLimit() public { + _setUpUsers(); + uint256 _creatorRoyaltyFeeTooHigh = looksRareProtocol.maxCreatorFeeBp() + 1; + + // Adjust royalties + _setUpRoyaltiesRegistry(_creatorRoyaltyFeeTooHigh); + + (OrderStructs.Maker memory makerBid, OrderStructs.Taker memory takerAsk) = + _createMockMakerBidAndTakerAsk(address(mockERC721), address(weth)); + + bytes memory signature = _signMakerOrder(makerBid, makerUserPK); + + // Mint asset + mockERC721.mint(takerUser, makerBid.itemIds[0]); + + _assertMakerOrderReturnValidationCode(makerBid, signature, CREATOR_FEE_TOO_HIGH); + + vm.expectRevert(IExecutionManager.CreatorFeeBpTooHigh.selector); + vm.prank(takerUser); + looksRareProtocol.executeTakerAsk(takerAsk, makerBid, signature, _EMPTY_MERKLE_TREE); + + // 2. Maker ask + + // Mint asset + mockERC721.mint(makerUser, 1); + + (OrderStructs.Maker memory makerAsk, OrderStructs.Taker memory takerBid) = + _createMockMakerAskAndTakerBid(address(mockERC721)); + // The itemId changes as it is already minted before + makerAsk.itemIds[0] = 1; + + signature = _signMakerOrder(makerAsk, makerUserPK); + + _assertMakerOrderReturnValidationCode(makerAsk, signature, CREATOR_FEE_TOO_HIGH); + + vm.expectRevert(IExecutionManager.CreatorFeeBpTooHigh.selector); + vm.prank(takerUser); + + looksRareProtocol.executeTakerBid{value: 1 ether}(takerBid, makerAsk, signature, _EMPTY_MERKLE_TREE); + } + + function _assertSuccessfulTakerAsk(OrderStructs.Maker memory makerBid) private { + uint256 price = makerBid.price; + + // Maker bid user pays the whole price + assertEq(weth.balanceOf(makerUser), _initialWETHBalanceUser - price); + assertEq( + weth.balanceOf(address(protocolFeeRecipient)), + (price * _newProtocolFee) / ONE_HUNDRED_PERCENT_IN_BP, + "ProtocolFeeRecipient should receive 2% of the whole price" + ); + // Taker ask user receives 95% of the whole price + assertEq(weth.balanceOf(takerUser), _initialWETHBalanceUser + (price * 9500) / ONE_HUNDRED_PERCENT_IN_BP); + // Royalty recipient receives 3% of the whole price + assertEq( + weth.balanceOf(_royaltyRecipient), + _initialWETHBalanceRoyaltyRecipient + (price * _newCreatorRoyaltyFee) / ONE_HUNDRED_PERCENT_IN_BP + ); + // Verify the nonce is marked as executed + assertEq(looksRareProtocol.userOrderNonce(makerUser, makerBid.orderNonce), MAGIC_VALUE_ORDER_NONCE_EXECUTED); + } + + function _assertSuccessfulTakerAskBundle(OrderStructs.Maker memory makerBid) private { + uint256 price = makerBid.price; + + // Maker bid user pays the whole price + assertEq(weth.balanceOf(makerUser), _initialWETHBalanceUser - price); + // Royalty recipient receives royalties + assertEq( + weth.balanceOf(_royaltyRecipient), + _initialWETHBalanceRoyaltyRecipient + (price * _newCreatorRoyaltyFee) / ONE_HUNDRED_PERCENT_IN_BP + ); + assertEq( + weth.balanceOf(address(protocolFeeRecipient)), + (price * _newProtocolFee) / ONE_HUNDRED_PERCENT_IN_BP, + "ProtocolFeeRecipient should receive protocol fee" + ); + // Taker ask user receives 95% of the whole price + assertEq(weth.balanceOf(takerUser), _initialWETHBalanceUser + (price * 9500) / ONE_HUNDRED_PERCENT_IN_BP); + // Verify the nonce is marked as executed + assertEq(looksRareProtocol.userOrderNonce(makerUser, makerBid.orderNonce), MAGIC_VALUE_ORDER_NONCE_EXECUTED); + } +} diff --git a/contracts/test/foundry/marketplace/CurrencyManager.t.sol b/contracts/test/foundry/marketplace/CurrencyManager.t.sol new file mode 100644 index 00000000..8c410dca --- /dev/null +++ b/contracts/test/foundry/marketplace/CurrencyManager.t.sol @@ -0,0 +1,42 @@ +// SPDX-License-Identifier: MIT +pragma solidity 0.8.17; + +// LooksRare unopinionated libraries +import {IOwnableTwoSteps} from "@looksrare/contracts-libs/contracts/interfaces/IOwnableTwoSteps.sol"; + +// Core contracts +import {CurrencyManager, ICurrencyManager} from "@hypercerts/marketplace/CurrencyManager.sol"; + +// Other mocks and utils +import {TestHelpers} from "./utils/TestHelpers.sol"; +import {TestParameters} from "./utils/TestParameters.sol"; +import {MockERC20} from "../../mock/MockERC20.sol"; + +contract CurrencyManagerTest is TestHelpers, TestParameters, ICurrencyManager { + CurrencyManager private currencyManager; + MockERC20 private mockERC20; + + function setUp() public asPrankedUser(_owner) { + currencyManager = new CurrencyManager(_owner); + mockERC20 = new MockERC20(); + } + + function testUpdateCurrencyStatus() public asPrankedUser(_owner) { + // Set to true + vm.expectEmit(true, false, false, true); + emit CurrencyStatusUpdated(address(mockERC20), true); + currencyManager.updateCurrencyStatus(address(mockERC20), true); + assertTrue(currencyManager.isCurrencyAllowed(address(mockERC20))); + + // Set to false + vm.expectEmit(true, false, false, true); + emit CurrencyStatusUpdated(address(mockERC20), false); + currencyManager.updateCurrencyStatus(address(mockERC20), false); + assertFalse(currencyManager.isCurrencyAllowed(address(mockERC20))); + } + + function testUpdateCurrencyStatusNotOwner() public { + vm.expectRevert(IOwnableTwoSteps.NotOwner.selector); + currencyManager.updateCurrencyStatus(address(mockERC20), true); + } +} diff --git a/contracts/test/foundry/marketplace/DelegationRecipientsTaker.t.sol b/contracts/test/foundry/marketplace/DelegationRecipientsTaker.t.sol new file mode 100644 index 00000000..ea5e6445 --- /dev/null +++ b/contracts/test/foundry/marketplace/DelegationRecipientsTaker.t.sol @@ -0,0 +1,172 @@ +// SPDX-License-Identifier: MIT +pragma solidity 0.8.17; + +// Libraries and interfaces +import {OrderStructs} from "@hypercerts/marketplace/libraries/OrderStructs.sol"; +import {CreatorFeeManagerWithRoyalties} from "@hypercerts/marketplace/CreatorFeeManagerWithRoyalties.sol"; + +// Base test +import {ProtocolBase} from "./ProtocolBase.t.sol"; + +// Constants +import {ONE_HUNDRED_PERCENT_IN_BP} from "@hypercerts/marketplace/constants/NumericConstants.sol"; + +contract DelegationRecipientsTakerTest is ProtocolBase { + function setUp() public { + _setUp(); + CreatorFeeManagerWithRoyalties creatorFeeManager = new CreatorFeeManagerWithRoyalties( + address(royaltyFeeRegistry) + ); + vm.prank(_owner); + looksRareProtocol.updateCreatorFeeManager(address(creatorFeeManager)); + } + + // Fixed price of sale + uint256 private constant price = 1 ether; + + /** + * One ERC721 is sold through a taker ask using WETH and the proceeds of the sale goes to a random recipient. + */ + function testTakerAskERC721WithRoyaltiesFromRegistryWithDelegation() public { + _setUpUsers(); + _setupRegistryRoyalties(address(mockERC721), _standardRoyaltyFee); + address randomRecipientSaleProceeds = address(420); + + (OrderStructs.Maker memory makerBid, OrderStructs.Taker memory takerAsk) = + _createMockMakerBidAndTakerAsk(address(mockERC721), address(weth)); + + bytes memory signature = _signMakerOrder(makerBid, makerUserPK); + + // Mint asset + mockERC721.mint(takerUser, makerBid.itemIds[0]); + + // Adjust recipient + takerAsk.recipient = randomRecipientSaleProceeds; + + // Verify maker bid order + _assertValidMakerOrder(makerBid, signature); + + // Arrays for events + address[2] memory expectedRecipients; + expectedRecipients[0] = randomRecipientSaleProceeds; + expectedRecipients[1] = _royaltyRecipient; + + uint256[3] memory expectedFees; + expectedFees[2] = (price * _standardProtocolFeeBp) / ONE_HUNDRED_PERCENT_IN_BP; + expectedFees[1] = (price * _standardRoyaltyFee) / ONE_HUNDRED_PERCENT_IN_BP; + expectedFees[0] = price - (expectedFees[1] + expectedFees[2]); + + vm.prank(takerUser); + vm.expectEmit(true, false, false, true); + + emit TakerAsk( + NonceInvalidationParameters({ + orderHash: _computeOrderHash(makerBid), + orderNonce: makerBid.orderNonce, + isNonceInvalidated: true + }), + takerUser, + makerUser, + makerBid.strategyId, + makerBid.currency, + makerBid.collection, + makerBid.itemIds, + makerBid.amounts, + expectedRecipients, + expectedFees + ); + looksRareProtocol.executeTakerAsk(takerAsk, makerBid, signature, _EMPTY_MERKLE_TREE); + + // Taker user has received the asset + assertEq(mockERC721.ownerOf(makerBid.itemIds[0]), makerUser); + // Maker bid user pays the whole price + assertEq(weth.balanceOf(makerUser), _initialWETHBalanceUser - price); + // Random recipient user receives 99.5% of the whole price and taker user receives nothing. + assertEq(weth.balanceOf(takerUser), _initialWETHBalanceUser); + assertEq( + weth.balanceOf(randomRecipientSaleProceeds), + (price * _sellerProceedBpWithStandardProtocolFeeBp) / ONE_HUNDRED_PERCENT_IN_BP + ); + // Royalty recipient receives 0.5% of the whole price + assertEq( + weth.balanceOf(_royaltyRecipient), + _initialWETHBalanceRoyaltyRecipient + (price * _standardRoyaltyFee) / ONE_HUNDRED_PERCENT_IN_BP + ); + // Verify the nonce is marked as executed + assertEq(looksRareProtocol.userOrderNonce(makerUser, makerBid.orderNonce), MAGIC_VALUE_ORDER_NONCE_EXECUTED); + } + + /** + * One ERC721 is sold through a taker bid and the NFT transfer goes to a random recipient. + */ + function testTakerBidERC721WithRoyaltiesFromRegistryWithDelegation() public { + address randomRecipientNFT = address(420); + + _setUpUsers(); + _setupRegistryRoyalties(address(mockERC721), _standardRoyaltyFee); + + (OrderStructs.Maker memory makerAsk, OrderStructs.Taker memory takerBid) = + _createMockMakerAskAndTakerBid(address(mockERC721)); + + // Mint asset + mockERC721.mint(makerUser, makerAsk.itemIds[0]); + + bytes memory signature = _signMakerOrder(makerAsk, makerUserPK); + + // Adjust recipient to random recipient + takerBid.recipient = randomRecipientNFT; + + // Verify validity of maker ask order + _assertValidMakerOrder(makerAsk, signature); + + // Arrays for events + address[2] memory expectedRecipients; + expectedRecipients[0] = makerUser; + expectedRecipients[1] = _royaltyRecipient; + + uint256[3] memory expectedFees; + expectedFees[0] = price - (expectedFees[1] + expectedFees[0]); + expectedFees[1] = (price * _standardRoyaltyFee) / ONE_HUNDRED_PERCENT_IN_BP; + expectedFees[2] = (price * _standardProtocolFeeBp) / ONE_HUNDRED_PERCENT_IN_BP; + + vm.prank(takerUser); + + emit TakerBid( + NonceInvalidationParameters({ + orderHash: _computeOrderHash(makerAsk), + orderNonce: makerAsk.orderNonce, + isNonceInvalidated: true + }), + takerUser, + randomRecipientNFT, + makerAsk.strategyId, + makerAsk.currency, + makerAsk.collection, + makerAsk.itemIds, + makerAsk.amounts, + expectedRecipients, + expectedFees + ); + + looksRareProtocol.executeTakerBid{value: price}(takerBid, makerAsk, signature, _EMPTY_MERKLE_TREE); + + // Random recipient user has received the asset + assertEq(mockERC721.ownerOf(makerAsk.itemIds[0]), randomRecipientNFT); + // Taker bid user pays the whole price + assertEq(address(takerUser).balance, _initialETHBalanceUser - price); + // Maker ask user receives 99.5% of the whole price + assertEq( + address(makerUser).balance, + _initialETHBalanceUser + (price * _sellerProceedBpWithStandardProtocolFeeBp) / ONE_HUNDRED_PERCENT_IN_BP + ); + // Royalty recipient receives 0.5% of the whole price + assertEq( + address(_royaltyRecipient).balance, + _initialETHBalanceRoyaltyRecipient + (price * _standardRoyaltyFee) / ONE_HUNDRED_PERCENT_IN_BP + ); + // No leftover in the balance of the contract + assertEq(address(looksRareProtocol).balance, 0); + // Verify the nonce is marked as executed + assertEq(looksRareProtocol.userOrderNonce(makerUser, makerAsk.orderNonce), MAGIC_VALUE_ORDER_NONCE_EXECUTED); + } +} diff --git a/contracts/test/foundry/marketplace/DomainSeparatorUpdates.t.sol b/contracts/test/foundry/marketplace/DomainSeparatorUpdates.t.sol new file mode 100644 index 00000000..c1ed9701 --- /dev/null +++ b/contracts/test/foundry/marketplace/DomainSeparatorUpdates.t.sol @@ -0,0 +1,97 @@ +// SPDX-License-Identifier: MIT +pragma solidity 0.8.17; + +// LooksRare unopinionated libraries +import {IOwnableTwoSteps} from "@looksrare/contracts-libs/contracts/interfaces/IOwnableTwoSteps.sol"; +import {SignatureEOAInvalid} from "@looksrare/contracts-libs/contracts/errors/SignatureCheckerErrors.sol"; + +// Libraries and interfaces +import {OrderStructs} from "@hypercerts/marketplace/libraries/OrderStructs.sol"; +import {ILooksRareProtocol} from "@hypercerts/marketplace/interfaces/ILooksRareProtocol.sol"; + +// Base test +import {ProtocolBase} from "./ProtocolBase.t.sol"; + +contract DomainSeparatorUpdatesTest is ProtocolBase { + function setUp() public { + _setUp(); + } + + function testUpdateDomainSeparator(uint64 newChainId) public asPrankedUser(_owner) { + vm.assume(newChainId != block.chainid); + + vm.chainId(newChainId); + vm.expectEmit(true, false, false, true); + emit NewDomainSeparator(); + looksRareProtocol.updateDomainSeparator(); + assertEq(looksRareProtocol.chainId(), newChainId); + assertEq( + looksRareProtocol.domainSeparator(), + keccak256( + abi.encode( + keccak256("EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)"), + keccak256("LooksRareProtocol"), + keccak256(bytes("2")), + newChainId, + address(looksRareProtocol) + ) + ) + ); + } + + function testCannotTradeIfDomainSeparatorHasBeenUpdated(uint64 newChainId) public { + vm.assume(newChainId != block.chainid); + + _setUpUsers(); + + // ChainId update + vm.chainId(newChainId); + + // Owner updates the domain separator + vm.prank(_owner); + looksRareProtocol.updateDomainSeparator(); + + (OrderStructs.Maker memory makerAsk, OrderStructs.Taker memory takerBid) = + _createMockMakerAskAndTakerBid(address(mockERC721)); + + bytes memory signature = _signMakerOrder(makerAsk, makerUserPK); + + // Mint asset + mockERC721.mint(makerUser, makerAsk.itemIds[0]); + + vm.prank(takerUser); + vm.expectRevert(SignatureEOAInvalid.selector); + looksRareProtocol.executeTakerBid{value: makerAsk.price}(takerBid, makerAsk, signature, _EMPTY_MERKLE_TREE); + } + + function testCannotTradeIfChainIdHasChanged(uint64 newChainId) public { + vm.assume(newChainId != block.chainid); + + _setUpUsers(); + + // ChainId update + vm.chainId(newChainId); + + (OrderStructs.Maker memory makerAsk, OrderStructs.Taker memory takerBid) = + _createMockMakerAskAndTakerBid(address(mockERC721)); + + bytes memory signature = _signMakerOrder(makerAsk, makerUserPK); + + // Mint asset + mockERC721.mint(makerUser, makerAsk.itemIds[0]); + + vm.prank(takerUser); + vm.expectRevert(ILooksRareProtocol.ChainIdInvalid.selector); + looksRareProtocol.executeTakerBid{value: makerAsk.price}(takerBid, makerAsk, signature, _EMPTY_MERKLE_TREE); + } + + function testUpdateDomainSeparatorSameDomainSeparator() public asPrankedUser(_owner) { + vm.expectRevert(SameDomainSeparator.selector); + looksRareProtocol.updateDomainSeparator(); + } + + function testUpdateDomainSeparatorNotOwner() public { + vm.expectRevert(IOwnableTwoSteps.NotOwner.selector); + looksRareProtocol.updateDomainSeparator(); + } +} diff --git a/contracts/test/foundry/marketplace/ExecutionManager.t.sol b/contracts/test/foundry/marketplace/ExecutionManager.t.sol new file mode 100644 index 00000000..b330d91a --- /dev/null +++ b/contracts/test/foundry/marketplace/ExecutionManager.t.sol @@ -0,0 +1,282 @@ +// SPDX-License-Identifier: MIT +pragma solidity 0.8.17; + +// LooksRare unopinionated libraries +import {IOwnableTwoSteps} from "@looksrare/contracts-libs/contracts/interfaces/IOwnableTwoSteps.sol"; + +// Libraries and interfaces +import {OrderStructs} from "@hypercerts/marketplace/libraries/OrderStructs.sol"; +import {IExecutionManager} from "@hypercerts/marketplace/interfaces/IExecutionManager.sol"; +import {IStrategyManager} from "@hypercerts/marketplace/interfaces/IStrategyManager.sol"; + +// Shared errors +import {OrderInvalid} from "@hypercerts/marketplace/errors/SharedErrors.sol"; +import { + MAKER_ORDER_INVALID_STANDARD_SALE, + STRATEGY_INVALID_QUOTE_TYPE, + STRATEGY_INVALID_QUOTE_TYPE, + STRATEGY_NOT_ACTIVE, + START_TIME_GREATER_THAN_END_TIME, + TOO_LATE_TO_EXECUTE_ORDER, + TOO_EARLY_TO_EXECUTE_ORDER +} from "@hypercerts/marketplace/constants/ValidationCodeConstants.sol"; + +// Base test +import {ProtocolBase} from "./ProtocolBase.t.sol"; + +contract ExecutionManagerTest is ProtocolBase, IExecutionManager, IStrategyManager { + function setUp() public { + _setUp(); + } + + function testUpdateCreatorFeeManager() public asPrankedUser(_owner) { + vm.expectEmit(true, false, false, true); + emit NewCreatorFeeManager(address(1)); + looksRareProtocol.updateCreatorFeeManager(address(1)); + assertEq(address(looksRareProtocol.creatorFeeManager()), address(1)); + } + + function testUpdateCreatorFeeManagerNotOwner() public { + vm.expectRevert(IOwnableTwoSteps.NotOwner.selector); + looksRareProtocol.updateCreatorFeeManager(address(1)); + } + + function testUpdateMaxCreatorFeeBp(uint16 newMaxCreatorFeeBp) public asPrankedUser(_owner) { + vm.assume(newMaxCreatorFeeBp <= 2500); + vm.expectEmit(true, false, false, true); + emit NewMaxCreatorFeeBp(newMaxCreatorFeeBp); + looksRareProtocol.updateMaxCreatorFeeBp(newMaxCreatorFeeBp); + assertEq(looksRareProtocol.maxCreatorFeeBp(), newMaxCreatorFeeBp); + } + + function testUpdateMaxCreatorFeeBpNotOwner() public { + vm.expectRevert(IOwnableTwoSteps.NotOwner.selector); + looksRareProtocol.updateMaxCreatorFeeBp(uint16(2500)); + } + + function testUpdateMaxCreatorFeeBpTooHigh(uint16 newMaxCreatorFeeBp) public asPrankedUser(_owner) { + vm.assume(newMaxCreatorFeeBp > 2500); + vm.expectRevert(CreatorFeeBpTooHigh.selector); + looksRareProtocol.updateMaxCreatorFeeBp(newMaxCreatorFeeBp); + } + + function testUpdateProtocolFeeRecipient() public asPrankedUser(_owner) { + vm.expectEmit(true, false, false, true); + emit NewProtocolFeeRecipient(address(1)); + looksRareProtocol.updateProtocolFeeRecipient(address(1)); + assertEq(looksRareProtocol.protocolFeeRecipient(), address(1)); + } + + function testUpdateProtocolFeeRecipientCannotBeNullAddress() public asPrankedUser(_owner) { + vm.expectRevert(IExecutionManager.NewProtocolFeeRecipientCannotBeNullAddress.selector); + looksRareProtocol.updateProtocolFeeRecipient(address(0)); + } + + function testUpdateProtocolFeeRecipientNotOwner() public { + vm.expectRevert(IOwnableTwoSteps.NotOwner.selector); + looksRareProtocol.updateProtocolFeeRecipient(address(1)); + } + + function testCannotValidateOrderIfTooEarlyToExecute(uint256 timestamp) public asPrankedUser(takerUser) { + // 300 because because it is deducted by 5 minutes + 1 second + vm.assume(timestamp > 300 && timestamp < type(uint256).max); + // Change timestamp to avoid underflow issues + vm.warp(timestamp); + + (OrderStructs.Maker memory makerBid, OrderStructs.Taker memory takerAsk) = + _createMockMakerBidAndTakerAsk(address(mockERC721), address(weth)); + + makerBid.startTime = block.timestamp; + makerBid.endTime = block.timestamp + 1 seconds; + + // Maker bid is valid if its start time is within 5 minutes into the future + vm.warp(makerBid.startTime - 5 minutes); + bytes memory signature = _signMakerOrder(makerBid, makerUserPK); + _assertMakerOrderReturnValidationCode(makerBid, signature, TOO_EARLY_TO_EXECUTE_ORDER); + + // Maker bid is invalid if its start time is not within 5 minutes into the future + vm.warp(makerBid.startTime - 5 minutes - 1 seconds); + vm.expectRevert(OutsideOfTimeRange.selector); + looksRareProtocol.executeTakerAsk(takerAsk, makerBid, signature, _EMPTY_MERKLE_TREE); + } + + function testCannotValidateOrderIfTooLateToExecute(uint256 timestamp) public asPrankedUser(takerUser) { + vm.assume(timestamp > 0 && timestamp < type(uint256).max); + // Change timestamp to avoid underflow issues + vm.warp(timestamp); + + (OrderStructs.Maker memory makerBid, OrderStructs.Taker memory takerAsk) = + _createMockMakerBidAndTakerAsk(address(mockERC721), address(weth)); + + makerBid.startTime = block.timestamp - 1 seconds; + makerBid.endTime = block.timestamp; + bytes memory signature = _signMakerOrder(makerBid, makerUserPK); + + vm.warp(block.timestamp); + _assertMakerOrderReturnValidationCode(makerBid, signature, TOO_LATE_TO_EXECUTE_ORDER); + + vm.warp(block.timestamp + 1 seconds); + vm.expectRevert(OutsideOfTimeRange.selector); + looksRareProtocol.executeTakerAsk(takerAsk, makerBid, signature, _EMPTY_MERKLE_TREE); + } + + function testCannotValidateOrderIfStartTimeLaterThanEndTime(uint256 timestamp) public asPrankedUser(takerUser) { + vm.assume(timestamp < type(uint256).max); + // Change timestamp to avoid underflow issues + vm.warp(timestamp); + + (OrderStructs.Maker memory makerBid, OrderStructs.Taker memory takerAsk) = + _createMockMakerBidAndTakerAsk(address(mockERC721), address(weth)); + + makerBid.startTime = block.timestamp + 1 seconds; + makerBid.endTime = block.timestamp; + bytes memory signature = _signMakerOrder(makerBid, makerUserPK); + + _assertMakerOrderReturnValidationCode(makerBid, signature, START_TIME_GREATER_THAN_END_TIME); + + vm.expectRevert(OutsideOfTimeRange.selector); + looksRareProtocol.executeTakerAsk(takerAsk, makerBid, signature, _EMPTY_MERKLE_TREE); + } + + function testCannotValidateOrderIfMakerBidItemIdsIsEmpty() public { + (OrderStructs.Maker memory makerBid, OrderStructs.Taker memory takerAsk) = + _createMockMakerBidAndTakerAsk(address(mockERC721), address(weth)); + + uint256[] memory itemIds = new uint256[](0); + makerBid.itemIds = itemIds; + bytes memory signature = _signMakerOrder(makerBid, makerUserPK); + + _assertMakerOrderReturnValidationCode(makerBid, signature, MAKER_ORDER_INVALID_STANDARD_SALE); + + vm.expectRevert(OrderInvalid.selector); + looksRareProtocol.executeTakerAsk(takerAsk, makerBid, signature, _EMPTY_MERKLE_TREE); + } + + function testCannotValidateOrderIfMakerBidItemIdsLengthMismatch(uint256 makerBidItemIdsLength) + public + asPrankedUser(takerUser) + { + vm.assume(makerBidItemIdsLength > 1 && makerBidItemIdsLength < 100_000); + + (OrderStructs.Maker memory makerBid, OrderStructs.Taker memory takerAsk) = + _createMockMakerBidAndTakerAsk(address(mockERC721), address(weth)); + + uint256[] memory itemIds = new uint256[](makerBidItemIdsLength); + makerBid.itemIds = itemIds; + bytes memory signature = _signMakerOrder(makerBid, makerUserPK); + + _assertMakerOrderReturnValidationCode(makerBid, signature, MAKER_ORDER_INVALID_STANDARD_SALE); + + vm.expectRevert(OrderInvalid.selector); + looksRareProtocol.executeTakerAsk(takerAsk, makerBid, signature, _EMPTY_MERKLE_TREE); + } + + function testCannotValidateOrderIfMakerAskItemIdsIsEmpty() public asPrankedUser(takerUser) { + vm.deal(takerUser, 100 ether); + + (OrderStructs.Maker memory makerAsk, OrderStructs.Taker memory takerBid) = + _createMockMakerAskAndTakerBid(address(mockERC721)); + + // Change maker itemIds array to make its length equal to 0 + uint256[] memory itemIds = new uint256[](0); + makerAsk.itemIds = itemIds; + bytes memory signature = _signMakerOrder(makerAsk, makerUserPK); + + _assertMakerOrderReturnValidationCode(makerAsk, signature, MAKER_ORDER_INVALID_STANDARD_SALE); + + vm.expectRevert(OrderInvalid.selector); + looksRareProtocol.executeTakerBid{value: makerAsk.price}(takerBid, makerAsk, signature, _EMPTY_MERKLE_TREE); + } + + function testCannotValidateOrderIfMakerAskItemIdsLengthMismatch(uint256 makerAskItemIdsLength) + public + asPrankedUser(takerUser) + { + vm.deal(takerUser, 100 ether); + + vm.assume(makerAskItemIdsLength > 1 && makerAskItemIdsLength < 100_000); + + (OrderStructs.Maker memory makerAsk, OrderStructs.Taker memory takerBid) = + _createMockMakerAskAndTakerBid(address(mockERC721)); + + uint256[] memory itemIds = new uint256[](makerAskItemIdsLength); + makerAsk.itemIds = itemIds; + bytes memory signature = _signMakerOrder(makerAsk, makerUserPK); + + _assertMakerOrderReturnValidationCode(makerAsk, signature, MAKER_ORDER_INVALID_STANDARD_SALE); + + vm.expectRevert(OrderInvalid.selector); + looksRareProtocol.executeTakerBid{value: makerAsk.price}(takerBid, makerAsk, signature, _EMPTY_MERKLE_TREE); + } + + // TODO check is we need this test and replace the chainlink floor strategy + // function testCannotExecuteTransactionIfMakerBidWithStrategyForMakerAsk() public { + // _setUpUsers(); + + // vm.prank(_owner); + // StrategyChainlinkFloor strategy = new StrategyChainlinkFloor(_owner, address(weth)); + + // bool isMakerBid = true; + // vm.prank(_owner); + // looksRareProtocol.addStrategy( + // 250, + // 250, + // 300, + // StrategyChainlinkFloor.executeBasisPointsDiscountCollectionOfferStrategyWithTakerAsk.selector, + // isMakerBid, + // address(strategy) + // ); + + // (OrderStructs.Maker memory makerAsk, OrderStructs.Taker memory takerBid) = + // _createMockMakerAskAndTakerBid(address(mockERC721)); + // makerAsk.strategyId = 1; // Fake strategy + + // bytes memory signature = _signMakerOrder(makerAsk, makerUserPK); + + // // Mint asset + // mockERC721.mint(makerUser, makerAsk.itemIds[0]); + + // _assertMakerOrderReturnValidationCode(makerAsk, signature, STRATEGY_INVALID_QUOTE_TYPE); + + // vm.prank(takerUser); + // vm.expectRevert(IExecutionManager.NoSelectorForStrategy.selector); + // looksRareProtocol.executeTakerBid{value: makerAsk.price}( + // takerBid, makerAsk, signature, _EMPTY_MERKLE_TREE + // ); + // } + + // TODO check is we need this test and replace the chainlink floor strategy + // function testCannotExecuteTransactionIfMakerAskWithStrategyForMakerBid() public { + // _setUpUsers(); + + // vm.prank(_owner); + // StrategyChainlinkFloor strategy = new StrategyChainlinkFloor(_owner, address(weth)); + + // bool isMakerBid = false; + // vm.prank(_owner); + // // All parameters are random, including the selector and the implementation + // looksRareProtocol.addStrategy( + // 250, + // 250, + // 300, + // StrategyChainlinkFloor.executeFixedPremiumStrategyWithTakerBid.selector, + // isMakerBid, + // address(strategy) + // ); + + // (OrderStructs.Maker memory makerBid, OrderStructs.Taker memory takerAsk) = + // _createMockMakerBidAndTakerAsk(address(mockERC721), address(weth)); + // makerBid.strategyId = 1; // Fake strategy + + // bytes memory signature = _signMakerOrder(makerBid, makerUserPK); + + // // Mint asset to ask user + // mockERC721.mint(takerUser, makerBid.itemIds[0]); + + // _assertMakerOrderReturnValidationCode(makerBid, signature, STRATEGY_INVALID_QUOTE_TYPE); + + // vm.prank(takerUser); + // vm.expectRevert(IExecutionManager.NoSelectorForStrategy.selector); + // looksRareProtocol.executeTakerAsk(takerAsk, makerBid, signature, _EMPTY_MERKLE_TREE); + // } +} diff --git a/contracts/test/foundry/marketplace/GasGriefing.t.sol b/contracts/test/foundry/marketplace/GasGriefing.t.sol new file mode 100644 index 00000000..b973ddff --- /dev/null +++ b/contracts/test/foundry/marketplace/GasGriefing.t.sol @@ -0,0 +1,135 @@ +// SPDX-License-Identifier: MIT +pragma solidity 0.8.17; + +// Libraries and interfaces +import {OrderStructs} from "@hypercerts/marketplace/libraries/OrderStructs.sol"; +import {WETH} from "solmate/src/tokens/WETH.sol"; + +// Base test +import {ProtocolBase} from "./ProtocolBase.t.sol"; + +// Mocks and other utils +import {GasGriefer} from "./utils/GasGriefer.sol"; + +// Constants +import {ONE_HUNDRED_PERCENT_IN_BP} from "@hypercerts/marketplace/constants/NumericConstants.sol"; + +// Enums +import {CollectionType} from "@hypercerts/marketplace/enums/CollectionType.sol"; +import {QuoteType} from "@hypercerts/marketplace/enums/QuoteType.sol"; + +contract GasGriefingTest is ProtocolBase { + uint256 private constant price = 1 ether; // Fixed price of sale + address private gasGriefer; + + // WETH events + event Deposit(address indexed from, uint256 amount); + event Transfer(address indexed from, address indexed to, uint256 amount); + + function setUp() public { + _setUp(); + gasGriefer = address(new GasGriefer()); + _setUpUser(gasGriefer); + _setUpUser(takerUser); + } + + function testTakerBidGasGriefing() public { + _setupRegistryRoyalties(address(mockERC721), _standardRoyaltyFee); + + (OrderStructs.Maker memory makerAsk, OrderStructs.Taker memory takerBid) = + _createMockMakerAskAndTakerBid(address(mockERC721)); + makerAsk.signer = gasGriefer; + + // Mint asset + mockERC721.mint(gasGriefer, makerAsk.itemIds[0]); + + bytes memory signature; + + uint256 sellerProceed = (price * _sellerProceedBpWithStandardProtocolFeeBp) / ONE_HUNDRED_PERCENT_IN_BP; + + vm.expectEmit(true, true, false, true); + emit Deposit(address(looksRareProtocol), sellerProceed); + + vm.expectEmit(true, true, true, true); + emit Transfer(address(looksRareProtocol), gasGriefer, sellerProceed); + + vm.prank(takerUser); + // Execute taker bid transaction + looksRareProtocol.executeTakerBid{value: price}(takerBid, makerAsk, signature, _EMPTY_MERKLE_TREE); + + // Taker user has received the asset + assertEq(mockERC721.ownerOf(makerAsk.itemIds[0]), takerUser); + // Taker bid user pays the whole price + assertEq(address(takerUser).balance, _initialETHBalanceUser - price); + // Maker ask user receives 99.5% of the whole price + assertEq(weth.balanceOf(gasGriefer), _initialWETHBalanceUser + sellerProceed); + // Royalty recipient receives 0.5% of the whole price + assertEq( + address(_royaltyRecipient).balance, + _initialETHBalanceRoyaltyRecipient + (price * _standardRoyaltyFee) / ONE_HUNDRED_PERCENT_IN_BP + ); + // No leftover in the balance of the contract + assertEq(address(looksRareProtocol).balance, 0); + // Verify the nonce is marked as executed + assertEq(looksRareProtocol.userOrderNonce(gasGriefer, makerAsk.orderNonce), MAGIC_VALUE_ORDER_NONCE_EXECUTED); + } + + function testThreeTakerBidsGasGriefing() public { + uint256 numberPurchases = 3; + + OrderStructs.Maker[] memory makerAsks = new OrderStructs.Maker[](numberPurchases); + OrderStructs.Taker[] memory takerBids = new OrderStructs.Taker[](numberPurchases); + bytes[] memory signatures = new bytes[](numberPurchases); + + for (uint256 i; i < numberPurchases; i++) { + // Mint asset + mockERC721.mint(gasGriefer, i); + + makerAsks[i] = _createSingleItemMakerOrder({ + quoteType: QuoteType.Ask, + globalNonce: 0, + subsetNonce: 0, + strategyId: STANDARD_SALE_FOR_FIXED_PRICE_STRATEGY, + collectionType: CollectionType.ERC721, + orderNonce: i, + collection: address(mockERC721), + currency: ETH, + signer: gasGriefer, + price: price, // Fixed + itemId: i // (0, 1, etc.) + }); + + takerBids[i] = _genericTakerOrder(); + } + + // Other execution parameters + OrderStructs.MerkleTree[] memory merkleTrees = new OrderStructs.MerkleTree[](numberPurchases); + + uint256 sellerProceedPerItem = (price * _sellerProceedBpWithStandardProtocolFeeBp) / ONE_HUNDRED_PERCENT_IN_BP; + + vm.expectEmit(true, true, false, true); + emit Deposit(address(looksRareProtocol), sellerProceedPerItem); + + vm.expectEmit(true, true, true, true); + emit Transfer(address(looksRareProtocol), gasGriefer, sellerProceedPerItem); + + vm.prank(takerUser); + // Execute taker bid transaction + looksRareProtocol.executeMultipleTakerBids{value: price * numberPurchases}( + takerBids, makerAsks, signatures, merkleTrees, false + ); + + for (uint256 i; i < numberPurchases; i++) { + // Taker user has received the asset + assertEq(mockERC721.ownerOf(i), takerUser); + // Verify the nonce is marked as executed + assertEq(looksRareProtocol.userOrderNonce(gasGriefer, i), MAGIC_VALUE_ORDER_NONCE_EXECUTED); + } + // Taker bid user pays the whole price + assertEq(address(takerUser).balance, _initialETHBalanceUser - (numberPurchases * price)); + // Maker ask user receives 99.5% of the whole price (0.5% protocol) + assertEq(weth.balanceOf(gasGriefer), _initialWETHBalanceUser + sellerProceedPerItem * numberPurchases); + // No leftover in the balance of the contract + assertEq(address(looksRareProtocol).balance, 0); + } +} diff --git a/contracts/test/foundry/marketplace/InitialStates.t.sol b/contracts/test/foundry/marketplace/InitialStates.t.sol new file mode 100644 index 00000000..5817a403 --- /dev/null +++ b/contracts/test/foundry/marketplace/InitialStates.t.sol @@ -0,0 +1,55 @@ +// SPDX-License-Identifier: MIT +pragma solidity 0.8.17; + +// Interfaces +import {IStrategyManager} from "@hypercerts/marketplace/interfaces/IStrategyManager.sol"; + +// Base test +import {ProtocolBase} from "./ProtocolBase.t.sol"; + +contract InitialStatesTest is ProtocolBase, IStrategyManager { + function setUp() public { + _setUp(); + } + + /** + * Verify initial post-deployment states are as expected + */ + function testInitialStates() public { + assertEq(looksRareProtocol.owner(), _owner); + assertEq(looksRareProtocol.protocolFeeRecipient(), address(protocolFeeRecipient)); + assertEq(address(looksRareProtocol.transferManager()), address(transferManager)); + assertEq(looksRareProtocol.WETH(), address(weth)); + assertEq(looksRareProtocol.chainId(), block.chainid); + + bytes32 domainSeparator = looksRareProtocol.domainSeparator(); + bytes32 expectedDomainSeparator = keccak256( + abi.encode( + keccak256("EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)"), + keccak256("LooksRareProtocol"), + keccak256(bytes("2")), + block.chainid, + address(looksRareProtocol) + ) + ); + assertEq(domainSeparator, expectedDomainSeparator); + + ( + bool strategyIsActive, + uint16 strategyStandardProtocolFee, + uint16 strategyMinTotalFee, + uint16 strategyMaxProtocolFee, + bytes4 strategySelector, + bool strategyIsMakerBid, + address strategyImplementation + ) = looksRareProtocol.strategyInfo(0); + + assertTrue(strategyIsActive); + assertEq(strategyStandardProtocolFee, _standardProtocolFeeBp); + assertEq(strategyMinTotalFee, _minTotalFeeBp); + assertEq(strategyMaxProtocolFee, _maxProtocolFeeBp); + assertEq(strategySelector, _EMPTY_BYTES4); + assertFalse(strategyIsMakerBid); + assertEq(strategyImplementation, address(0)); + } +} diff --git a/contracts/test/foundry/marketplace/LooksRareProtocol.t.sol b/contracts/test/foundry/marketplace/LooksRareProtocol.t.sol new file mode 100644 index 00000000..5f685cec --- /dev/null +++ b/contracts/test/foundry/marketplace/LooksRareProtocol.t.sol @@ -0,0 +1,268 @@ +// SPDX-License-Identifier: MIT +pragma solidity 0.8.17; + +// LooksRare unopinionated libraries +import {IOwnableTwoSteps} from "@looksrare/contracts-libs/contracts/interfaces/IOwnableTwoSteps.sol"; + +// Libraries +import {OrderStructs} from "@hypercerts/marketplace/libraries/OrderStructs.sol"; + +// Base test +import {ProtocolBase} from "./ProtocolBase.t.sol"; + +// Shared errors +import { + AmountInvalid, + CallerInvalid, + CurrencyInvalid, + OrderInvalid, + QuoteTypeInvalid +} from "@hypercerts/marketplace/errors/SharedErrors.sol"; +import { + CURRENCY_NOT_ALLOWED, + MAKER_ORDER_INVALID_STANDARD_SALE +} from "@hypercerts/marketplace/constants/ValidationCodeConstants.sol"; + +// Other mocks and utils +import {MockERC20} from "../../mock/MockERC20.sol"; + +// Enums +import {CollectionType} from "@hypercerts/marketplace/enums/CollectionType.sol"; +import {QuoteType} from "@hypercerts/marketplace/enums/QuoteType.sol"; + +contract LooksRareProtocolTest is ProtocolBase { + // Fixed price of sale + uint256 private constant price = 1 ether; + + // Mock files + MockERC20 private mockERC20; + + function setUp() public { + _setUp(); + vm.prank(_owner); + mockERC20 = new MockERC20(); + } + + function testCannotTradeIfInvalidAmounts() public { + _setUpUsers(); + + (OrderStructs.Maker memory makerAsk, OrderStructs.Taker memory takerBid) = + _createMockMakerAskAndTakerBid(address(mockERC721)); + + // Mint asset + mockERC721.mint(makerUser, makerAsk.itemIds[0]); + + // 1. Amount = 0 + makerAsk.amounts[0] = 0; + + // Sign order + bytes memory signature = _signMakerOrder(makerAsk, makerUserPK); + + _assertMakerOrderReturnValidationCode(makerAsk, signature, MAKER_ORDER_INVALID_STANDARD_SALE); + + vm.prank(takerUser); + vm.expectRevert(OrderInvalid.selector); + looksRareProtocol.executeTakerBid{value: price}(takerBid, makerAsk, signature, _EMPTY_MERKLE_TREE); + + // 2. Amount > 1 for ERC721 + makerAsk.amounts[0] = 2; + + // Sign order + signature = _signMakerOrder(makerAsk, makerUserPK); + + _assertMakerOrderReturnValidationCode(makerAsk, signature, MAKER_ORDER_INVALID_STANDARD_SALE); + + vm.prank(takerUser); + vm.expectRevert(AmountInvalid.selector); + looksRareProtocol.executeTakerBid{value: price}(takerBid, makerAsk, signature, _EMPTY_MERKLE_TREE); + } + + function testCannotTradeIfCurrencyInvalid() public { + _setUpUsers(); + + (OrderStructs.Maker memory makerAsk, OrderStructs.Taker memory takerBid) = + _createMockMakerAskAndTakerBid(address(mockERC721)); + makerAsk.currency = address(mockERC20); + + // Mint asset + mockERC721.mint(makerUser, makerAsk.itemIds[0]); + + // Sign order + bytes memory signature = _signMakerOrder(makerAsk, makerUserPK); + + // Verify validity of maker ask order + _assertMakerOrderReturnValidationCode(makerAsk, signature, CURRENCY_NOT_ALLOWED); + + vm.prank(takerUser); + vm.expectRevert(CurrencyInvalid.selector); + looksRareProtocol.executeTakerBid{value: price}(takerBid, makerAsk, signature, _EMPTY_MERKLE_TREE); + + OrderStructs.Maker[] memory makerAsks = new OrderStructs.Maker[](1); + OrderStructs.Taker[] memory takerBids = new OrderStructs.Taker[](1); + bytes[] memory signatures = new bytes[](1); + OrderStructs.MerkleTree[] memory merkleTrees = new OrderStructs.MerkleTree[](1); + + makerAsks[0] = makerAsk; + takerBids[0] = takerBid; + signatures[0] = signature; + + vm.prank(takerUser); + vm.expectRevert(CurrencyInvalid.selector); + looksRareProtocol.executeMultipleTakerBids{value: price}( + takerBids, + makerAsks, + signatures, + merkleTrees, + true // Atomic + ); + + vm.prank(takerUser); + vm.expectRevert(CurrencyInvalid.selector); + looksRareProtocol.executeMultipleTakerBids{value: price}( + takerBids, + makerAsks, + signatures, + merkleTrees, + false // Non-atomic + ); + } + + function testCannotTradeIfETHIsUsedForMakerBid() public { + (OrderStructs.Maker memory makerBid, OrderStructs.Taker memory takerAsk) = + _createMockMakerBidAndTakerAsk(address(mockERC721), ETH); + + // Sign order + bytes memory signature = _signMakerOrder(makerBid, makerUserPK); + + // Verify maker bid order + _assertMakerOrderReturnValidationCode(makerBid, signature, CURRENCY_NOT_ALLOWED); + + // Mint asset + mockERC721.mint(takerUser, makerBid.itemIds[0]); + + // Execute taker ask transaction + vm.prank(takerUser); + vm.expectRevert(CurrencyInvalid.selector); + looksRareProtocol.executeTakerAsk(takerAsk, makerBid, signature, _EMPTY_MERKLE_TREE); + } + + function testCannotTradeIfInvalidQuoteType() public { + // 1. QuoteType = BID but executeTakerBid + (OrderStructs.Maker memory makerBid, OrderStructs.Taker memory takerAsk) = + _createMockMakerBidAndTakerAsk(address(mockERC721), address(weth)); + + // Sign order + bytes memory signature = _signMakerOrder(makerBid, makerUserPK); + + vm.prank(takerUser); + vm.expectRevert(QuoteTypeInvalid.selector); + looksRareProtocol.executeTakerBid(takerAsk, makerBid, signature, _EMPTY_MERKLE_TREE); + + // 2. QuoteType = ASK but executeTakerAsk + (OrderStructs.Maker memory makerAsk, OrderStructs.Taker memory takerBid) = + _createMockMakerAskAndTakerBid(address(mockERC721)); + makerAsk.currency = address(weth); + + // Sign order + signature = _signMakerOrder(makerAsk, makerUserPK); + + vm.prank(takerUser); + vm.expectRevert(QuoteTypeInvalid.selector); + looksRareProtocol.executeTakerAsk(takerBid, makerAsk, signature, _EMPTY_MERKLE_TREE); + } + + function testUpdateETHGasLimitForTransfer() public asPrankedUser(_owner) { + vm.expectEmit(true, false, false, true); + emit NewGasLimitETHTransfer(10_000); + looksRareProtocol.updateETHGasLimitForTransfer(10_000); + assertEq(uint256(vm.load(address(looksRareProtocol), bytes32(uint256(12)))), 10_000); + } + + function testUpdateETHGasLimitForTransferRevertsIfTooLow() public asPrankedUser(_owner) { + uint256 newGasLimitETHTransfer = 2300; + vm.expectRevert(NewGasLimitETHTransferTooLow.selector); + looksRareProtocol.updateETHGasLimitForTransfer(newGasLimitETHTransfer - 1); + + looksRareProtocol.updateETHGasLimitForTransfer(newGasLimitETHTransfer); + assertEq(uint256(vm.load(address(looksRareProtocol), bytes32(uint256(12)))), newGasLimitETHTransfer); + } + + function testUpdateETHGasLimitForTransferNotOwner() public { + vm.expectRevert(IOwnableTwoSteps.NotOwner.selector); + looksRareProtocol.updateETHGasLimitForTransfer(10_000); + } + + function testCannotCallRestrictedExecuteTakerBid() public { + _setUpUsers(); + + (OrderStructs.Maker memory makerAsk, OrderStructs.Taker memory takerBid) = + _createMockMakerAskAndTakerBid(address(mockERC721)); + + // Mint asset + mockERC721.mint(makerUser, makerAsk.itemIds[0]); + + vm.prank(takerUser); + vm.expectRevert(CallerInvalid.selector); + looksRareProtocol.restrictedExecuteTakerBid(takerBid, makerAsk, takerUser, _computeOrderHash(makerAsk)); + } + + /** + * Cannot execute two or more taker bids if the currencies are different + */ + function testCannotExecuteMultipleTakerBidsIfDifferentCurrenciesIsAtomic() public { + _testCannotExecuteMultipleTakerBidsIfDifferentCurrencies(true); + } + + function testCannotExecuteMultipleTakerBidsIfDifferentCurrenciesIsNonAtomic() public { + _testCannotExecuteMultipleTakerBidsIfDifferentCurrencies(false); + } + + function _testCannotExecuteMultipleTakerBidsIfDifferentCurrencies(bool isAtomic) public { + _setUpUsers(); + vm.prank(_owner); + looksRareProtocol.updateCurrencyStatus(address(mockERC20), true); + + uint256 numberPurchases = 2; + + OrderStructs.Maker[] memory makerAsks = new OrderStructs.Maker[](numberPurchases); + OrderStructs.Taker[] memory takerBids = new OrderStructs.Taker[](numberPurchases); + bytes[] memory signatures = new bytes[](numberPurchases); + + for (uint256 i; i < numberPurchases; i++) { + // Mint asset + mockERC721.mint(makerUser, i); + + makerAsks[i] = _createSingleItemMakerOrder({ + quoteType: QuoteType.Ask, + globalNonce: 0, + subsetNonce: 0, + strategyId: STANDARD_SALE_FOR_FIXED_PRICE_STRATEGY, + collectionType: CollectionType.ERC721, + orderNonce: i, + collection: address(mockERC721), + currency: ETH, + signer: makerUser, + price: price, // Fixed + itemId: i // (0, 1, etc.) + }); + + if (i == 1) { + makerAsks[i].currency = address(mockERC20); + } + + // Sign order + signatures[i] = _signMakerOrder(makerAsks[i], makerUserPK); + + takerBids[i] = _genericTakerOrder(); + } + + // Other execution parameters + OrderStructs.MerkleTree[] memory merkleTrees = new OrderStructs.MerkleTree[](numberPurchases); + + vm.prank(takerUser); + vm.expectRevert(CurrencyInvalid.selector); + looksRareProtocol.executeMultipleTakerBids{value: price}( + takerBids, makerAsks, signatures, merkleTrees, isAtomic + ); + } +} diff --git a/contracts/test/foundry/marketplace/NonceInvalidation.t.sol b/contracts/test/foundry/marketplace/NonceInvalidation.t.sol new file mode 100644 index 00000000..ae497f79 --- /dev/null +++ b/contracts/test/foundry/marketplace/NonceInvalidation.t.sol @@ -0,0 +1,355 @@ +// SPDX-License-Identifier: MIT +pragma solidity 0.8.17; + +// Libraries, interfaces, errors +import {OrderStructs} from "@hypercerts/marketplace/libraries/OrderStructs.sol"; +import {INonceManager} from "@hypercerts/marketplace/interfaces/INonceManager.sol"; +import {LengthsInvalid} from "@hypercerts/marketplace/errors/SharedErrors.sol"; +import { + INVALID_USER_GLOBAL_BID_NONCE, + INVALID_USER_GLOBAL_ASK_NONCE, + USER_SUBSET_NONCE_CANCELLED, + USER_ORDER_NONCE_IN_EXECUTION_WITH_OTHER_HASH, + USER_ORDER_NONCE_EXECUTED_OR_CANCELLED +} from "@hypercerts/marketplace/constants/ValidationCodeConstants.sol"; + +// Other utils and tests +import {StrategyTestMultiFillCollectionOrder} from "./utils/StrategyTestMultiFillCollectionOrder.sol"; +import {ProtocolBase} from "./ProtocolBase.t.sol"; + +// Enums +import {CollectionType} from "@hypercerts/marketplace/enums/CollectionType.sol"; +import {QuoteType} from "@hypercerts/marketplace/enums/QuoteType.sol"; + +contract NonceInvalidationTest is INonceManager, ProtocolBase { + uint256 private constant price = 1 ether; // Fixed price of sale + + function setUp() public { + _setUp(); + } + + /** + * Cannot execute an order if subset nonce is used + */ + function testCannotExecuteOrderIfSubsetNonceIsUsed(uint256 subsetNonce) public { + uint256 itemId = 420; + + // Mint asset + mockERC721.mint(makerUser, itemId); + + (OrderStructs.Maker memory makerAsk, OrderStructs.Taker memory takerBid) = + _createMockMakerAskAndTakerBid(address(mockERC721)); + makerAsk.subsetNonce = subsetNonce; + + // Sign order + bytes memory signature = _signMakerOrder(makerAsk, makerUserPK); + + uint256[] memory subsetNonces = new uint256[](1); + subsetNonces[0] = subsetNonce; + + vm.prank(makerUser); + vm.expectEmit(false, false, false, true); + emit SubsetNoncesCancelled(makerUser, subsetNonces); + looksRareProtocol.cancelSubsetNonces(subsetNonces); + + _assertMakerOrderReturnValidationCode(makerAsk, signature, USER_SUBSET_NONCE_CANCELLED); + + vm.deal(takerUser, price); + + // Execute taker bid transaction + // Taker user actions + vm.prank(takerUser); + vm.expectRevert(NoncesInvalid.selector); + looksRareProtocol.executeTakerBid{value: price}(takerBid, makerAsk, signature, _EMPTY_MERKLE_TREE); + } + + /** + * Cannot execute an order if maker is at a different global ask nonce than signed + */ + function testCannotExecuteOrderIfInvalidUserGlobalAskNonce(uint256 userGlobalAskNonce) public { + uint256 quasiRandomNumber = 54_570_651_553_685_478_358_117_286_254_199_992_264; + vm.assume(userGlobalAskNonce < quasiRandomNumber); + // Change block number + vm.roll(1); + assertEq(quasiRandomNumber, uint256(blockhash(block.number - 1) >> 128)); + + uint256 newAskNonce = 0 + quasiRandomNumber; + + vm.prank(makerUser); + vm.expectEmit(false, false, false, true); + emit NewBidAskNonces(makerUser, 0, newAskNonce); + looksRareProtocol.incrementBidAskNonces(false, true); + + (OrderStructs.Maker memory makerAsk, OrderStructs.Taker memory takerBid) = + _createMockMakerAskAndTakerBid(address(mockERC721)); + + // Mint asset + mockERC721.mint(makerUser, makerAsk.itemIds[0]); + + // Sign order + bytes memory signature = _signMakerOrder(makerAsk, makerUserPK); + + _assertMakerOrderReturnValidationCode(makerAsk, signature, INVALID_USER_GLOBAL_ASK_NONCE); + + vm.deal(takerUser, price); + + // Execute taker bid transaction + // Taker user actions + vm.prank(takerUser); + vm.expectRevert(NoncesInvalid.selector); + looksRareProtocol.executeTakerBid{value: price}(takerBid, makerAsk, signature, _EMPTY_MERKLE_TREE); + } + + /** + * Cannot execute an order if maker is at a different global bid nonce than signed + */ + function testCannotExecuteOrderIfInvalidUserGlobalBidNonce(uint256 userGlobalBidNonce) public { + uint256 quasiRandomNumber = 54_570_651_553_685_478_358_117_286_254_199_992_264; + vm.assume(userGlobalBidNonce < quasiRandomNumber); + // Change block number + vm.roll(1); + assertEq(quasiRandomNumber, uint256(blockhash(block.number - 1) >> 128)); + + uint256 newBidNonce = 0 + quasiRandomNumber; + + vm.prank(makerUser); + vm.expectEmit(false, false, false, true); + emit NewBidAskNonces(makerUser, newBidNonce, 0); + looksRareProtocol.incrementBidAskNonces(true, false); + + uint256 itemId = 420; + + OrderStructs.Maker memory makerBid = _createSingleItemMakerOrder({ + quoteType: QuoteType.Bid, + globalNonce: userGlobalBidNonce, + subsetNonce: 0, + strategyId: STANDARD_SALE_FOR_FIXED_PRICE_STRATEGY, + collectionType: CollectionType.ERC721, + orderNonce: 0, + collection: address(mockERC721), + currency: address(weth), + signer: makerUser, + price: price, + itemId: itemId + }); + + // Sign order + bytes memory signature = _signMakerOrder(makerBid, makerUserPK); + + _assertMakerOrderReturnValidationCode(makerBid, signature, INVALID_USER_GLOBAL_BID_NONCE); + + // Mint asset + mockERC721.mint(takerUser, itemId); + + // Execute taker ask transaction + // Taker user actions + vm.prank(takerUser); + vm.expectRevert(NoncesInvalid.selector); + looksRareProtocol.executeTakerAsk(_genericTakerOrder(), makerBid, signature, _EMPTY_MERKLE_TREE); + } + + /** + * Cannot execute an order twice + */ + function testCannotExecuteAnOrderTwice() public { + _setUpUsers(); + _setupRegistryRoyalties(address(mockERC721), _standardRoyaltyFee); + + (OrderStructs.Maker memory makerBid, OrderStructs.Taker memory takerAsk) = + _createMockMakerBidAndTakerAsk(address(mockERC721), address(weth)); + + // Sign order + bytes memory signature = _signMakerOrder(makerBid, makerUserPK); + + // Mint asset + mockERC721.mint(takerUser, makerBid.itemIds[0]); + + // Taker user actions + vm.startPrank(takerUser); + + { + looksRareProtocol.executeTakerAsk(takerAsk, makerBid, signature, _EMPTY_MERKLE_TREE); + + _assertMakerOrderReturnValidationCode(makerBid, signature, USER_ORDER_NONCE_EXECUTED_OR_CANCELLED); + + // Second one fails + vm.expectRevert(NoncesInvalid.selector); + looksRareProtocol.executeTakerAsk(takerAsk, makerBid, signature, _EMPTY_MERKLE_TREE); + } + + vm.stopPrank(); + } + + /** + * Cannot execute an order sharing the same order nonce as another that is being partially filled + */ + function testCannotExecuteAnotherOrderAtNonceIfExecutionIsInProgress(uint256 orderNonce) public { + _setUpUsers(); + + // 0. Add the new strategy + bytes4 selector = StrategyTestMultiFillCollectionOrder.executeStrategyWithTakerAsk.selector; + + StrategyTestMultiFillCollectionOrder strategyMultiFillCollectionOrder = + new StrategyTestMultiFillCollectionOrder( + address(looksRareProtocol) + ); + + vm.prank(_owner); + _addStrategy(address(strategyMultiFillCollectionOrder), selector, true); + + // 1. Maker signs a message and execute a partial fill on it + uint256 amountsToFill = 4; + + uint256[] memory itemIds = new uint256[](0); + uint256[] memory amounts = new uint256[](1); + amounts[0] = amountsToFill; + + // Prepare the first order + OrderStructs.Maker memory makerBid = _createMultiItemMakerOrder({ + quoteType: QuoteType.Bid, + globalNonce: 0, + subsetNonce: 0, + strategyId: 1, // Multi-fill bid offer + collectionType: CollectionType.ERC721, + orderNonce: orderNonce, + collection: address(mockERC721), + currency: address(weth), + signer: makerUser, + price: price, + itemIds: itemIds, + amounts: amounts + }); + + // Sign order + bytes memory signature = _signMakerOrder(makerBid, makerUserPK); + + // First taker user actions + { + itemIds = new uint256[](1); + amounts = new uint256[](1); + itemIds[0] = 0; + amounts[0] = 1; + + mockERC721.mint(takerUser, itemIds[0]); + + // Prepare the taker ask + OrderStructs.Taker memory takerAsk = OrderStructs.Taker(takerUser, abi.encode(itemIds, amounts)); + + vm.prank(takerUser); + + // Execute taker ask transaction + looksRareProtocol.executeTakerAsk(takerAsk, makerBid, signature, _EMPTY_MERKLE_TREE); + } + + // 2. Second maker order is signed sharing the same order nonce as the first one + { + uint256 itemId = 420; + + itemIds = new uint256[](1); + amounts = new uint256[](1); + itemIds[0] = itemId; + amounts[0] = 1; + + // Prepare the second order + makerBid = _createMultiItemMakerOrder({ + quoteType: QuoteType.Bid, + globalNonce: 0, + subsetNonce: 0, + strategyId: STANDARD_SALE_FOR_FIXED_PRICE_STRATEGY, + collectionType: CollectionType.ERC721, + orderNonce: orderNonce, + collection: address(mockERC721), + currency: address(weth), + signer: makerUser, + price: price, + itemIds: itemIds, + amounts: amounts + }); + + // Sign order + signature = _signMakerOrder(makerBid, makerUserPK); + + _assertMakerOrderReturnValidationCode(makerBid, signature, USER_ORDER_NONCE_IN_EXECUTION_WITH_OTHER_HASH); + + // Prepare the taker ask + OrderStructs.Taker memory takerAsk = + OrderStructs.Taker(takerUser, abi.encode(new uint256[](0), new uint256[](0))); + + vm.prank(takerUser); + + // Second one fails when a taker user tries to execute + vm.expectRevert(NoncesInvalid.selector); + looksRareProtocol.executeTakerAsk(takerAsk, makerBid, signature, _EMPTY_MERKLE_TREE); + } + } + + function testCancelOrderNonces(uint256 nonceOne, uint256 nonceTwo) public asPrankedUser(makerUser) { + assertEq(looksRareProtocol.userOrderNonce(makerUser, nonceOne), bytes32(0)); + assertEq(looksRareProtocol.userOrderNonce(makerUser, nonceTwo), bytes32(0)); + + uint256[] memory orderNonces = new uint256[](2); + orderNonces[0] = nonceOne; + orderNonces[1] = nonceTwo; + vm.expectEmit(true, false, false, true); + emit OrderNoncesCancelled(makerUser, orderNonces); + looksRareProtocol.cancelOrderNonces(orderNonces); + + assertEq(looksRareProtocol.userOrderNonce(makerUser, nonceOne), MAGIC_VALUE_ORDER_NONCE_EXECUTED); + assertEq(looksRareProtocol.userOrderNonce(makerUser, nonceTwo), MAGIC_VALUE_ORDER_NONCE_EXECUTED); + } + + /** + * Cannot execute an order if its nonce has been cancelled + */ + function testCannotExecuteAnOrderWhoseNonceIsCancelled(uint256 orderNonce) public { + _setUpUsers(); + _setupRegistryRoyalties(address(mockERC721), _standardRoyaltyFee); + + uint256 itemId = 0; + + uint256[] memory orderNonces = new uint256[](1); + orderNonces[0] = orderNonce; + vm.prank(makerUser); + looksRareProtocol.cancelOrderNonces(orderNonces); + + OrderStructs.Maker memory makerBid = _createSingleItemMakerOrder({ + quoteType: QuoteType.Bid, + globalNonce: 0, + subsetNonce: 0, + strategyId: STANDARD_SALE_FOR_FIXED_PRICE_STRATEGY, + collectionType: CollectionType.ERC721, + orderNonce: orderNonce, + collection: address(mockERC721), + currency: address(weth), + signer: makerUser, + price: price, + itemId: itemId + }); + + // Sign order + bytes memory signature = _signMakerOrder(makerBid, makerUserPK); + + _assertMakerOrderReturnValidationCode(makerBid, signature, USER_ORDER_NONCE_EXECUTED_OR_CANCELLED); + + // Mint asset + mockERC721.mint(takerUser, itemId); + + // Prepare the taker ask + OrderStructs.Taker memory takerAsk = + OrderStructs.Taker(takerUser, abi.encode(new uint256[](0), new uint256[](0))); + + vm.prank(takerUser); + vm.expectRevert(NoncesInvalid.selector); + looksRareProtocol.executeTakerAsk(takerAsk, makerBid, signature, _EMPTY_MERKLE_TREE); + } + + function testCancelNoncesRevertIfEmptyArrays() public { + uint256[] memory nonces = new uint256[](0); + + vm.expectRevert(LengthsInvalid.selector); + looksRareProtocol.cancelSubsetNonces(nonces); + + vm.expectRevert(LengthsInvalid.selector); + looksRareProtocol.cancelOrderNonces(nonces); + } +} diff --git a/contracts/test/foundry/marketplace/OrderValidatorV2A.t.sol b/contracts/test/foundry/marketplace/OrderValidatorV2A.t.sol new file mode 100644 index 00000000..ca9a5c9c --- /dev/null +++ b/contracts/test/foundry/marketplace/OrderValidatorV2A.t.sol @@ -0,0 +1,378 @@ +// SPDX-License-Identifier: MIT +pragma solidity 0.8.17; + +import {LooksRareProtocol} from "@hypercerts/marketplace/LooksRareProtocol.sol"; +import {TransferManager} from "@hypercerts/marketplace/TransferManager.sol"; +import {CreatorFeeManagerWithRoyalties} from "@hypercerts/marketplace/CreatorFeeManagerWithRoyalties.sol"; + +import {OrderValidatorV2A} from "@hypercerts/marketplace/helpers/OrderValidatorV2A.sol"; + +// Libraries +import {OrderStructs} from "@hypercerts/marketplace/libraries/OrderStructs.sol"; + +// Shared errors +import { + ERC20_APPROVAL_INFERIOR_TO_PRICE, + ERC721_ITEM_ID_NOT_IN_BALANCE, + ERC721_NO_APPROVAL_FOR_ALL_OR_ITEM_ID, + ERC1155_BALANCE_OF_DOES_NOT_EXIST, + ERC1155_BALANCE_OF_ITEM_ID_INFERIOR_TO_AMOUNT, + ERC1155_IS_APPROVED_FOR_ALL_DOES_NOT_EXIST, + ERC1155_NO_APPROVAL_FOR_ALL, + MAKER_ORDER_INVALID_STANDARD_SALE, + MISSING_IS_VALID_SIGNATURE_FUNCTION_EIP1271, + POTENTIAL_INVALID_COLLECTION_TYPE_SHOULD_BE_ERC721, + POTENTIAL_INVALID_COLLECTION_TYPE_SHOULD_BE_ERC1155, + STRATEGY_NOT_IMPLEMENTED, + TRANSFER_MANAGER_APPROVAL_REVOKED_BY_OWNER_FOR_EXCHANGE +} from "@hypercerts/marketplace/constants/ValidationCodeConstants.sol"; + +// Utils +import {TestParameters} from "./utils/TestParameters.sol"; + +// Mocks +import {MockRoyaltyFeeRegistry} from "../../mock/MockRoyaltyFeeRegistry.sol"; +import {MockERC721} from "../../mock/MockERC721.sol"; +import {MockERC1155} from "../../mock/MockERC1155.sol"; +import {MockERC1155WithoutBalanceOfBatch} from "../../mock/MockERC1155WithoutBalanceOfBatch.sol"; +import {MockERC1155WithoutAnyBalanceOf} from "../../mock/MockERC1155WithoutAnyBalanceOf.sol"; +import {MockERC1155WithoutIsApprovedForAll} from "../../mock/MockERC1155WithoutIsApprovedForAll.sol"; +import {MockERC721SupportsNoInterface} from "../../mock/MockERC721SupportsNoInterface.sol"; +import {MockERC1155SupportsNoInterface} from "../../mock/MockERC1155SupportsNoInterface.sol"; +import {MockERC20} from "../../mock/MockERC20.sol"; + +// Enums +import {CollectionType} from "@hypercerts/marketplace/enums/CollectionType.sol"; +import {QuoteType} from "@hypercerts/marketplace/enums/QuoteType.sol"; + +/** + * @dev Not everything is tested in this file. Most tests live in other files + * with the assert functions living in ProtocolBase.t.sol. + */ +contract OrderValidatorV2ATest is TestParameters { + CreatorFeeManagerWithRoyalties private creatorFeeManager; + LooksRareProtocol private looksRareProtocol; + MockRoyaltyFeeRegistry private royaltyFeeRegistry; + OrderValidatorV2A private orderValidator; + TransferManager private transferManager; + + function setUp() public { + transferManager = new TransferManager(address(this)); + looksRareProtocol = new LooksRareProtocol( + address(this), + address(this), + address(transferManager), + 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2 + ); + royaltyFeeRegistry = new MockRoyaltyFeeRegistry(address(this), 9_500); + creatorFeeManager = new CreatorFeeManagerWithRoyalties(address(royaltyFeeRegistry)); + looksRareProtocol.updateCreatorFeeManager(address(creatorFeeManager)); + looksRareProtocol.updateCurrencyStatus(ETH, true); + orderValidator = new OrderValidatorV2A(address(looksRareProtocol)); + } + + function testDeriveProtocolParameters() public { + orderValidator.deriveProtocolParameters(); + assertEq( + orderValidator.domainSeparator(), + keccak256( + abi.encode( + keccak256("EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)"), + keccak256("LooksRareProtocol"), + keccak256(bytes("2")), + block.chainid, + address(looksRareProtocol) + ) + ) + ); + + assertEq(address(orderValidator.creatorFeeManager()), address(creatorFeeManager)); + assertEq(orderValidator.maxCreatorFeeBp(), 1000); + } + + function testMakerAskStrategyNotImplemented() public { + OrderStructs.Maker memory makerAsk; + makerAsk.quoteType = QuoteType.Ask; + makerAsk.strategyId = 1; + uint256[9] memory validationCodes = + orderValidator.checkMakerOrderValidity(makerAsk, new bytes(65), _EMPTY_MERKLE_TREE); + assertEq(validationCodes[0], STRATEGY_NOT_IMPLEMENTED); + } + + function testMakerBidStrategyNotImplemented() public { + OrderStructs.Maker memory makerBid; + makerBid.quoteType = QuoteType.Bid; + address currency = address(1); // it cannot be 0 + looksRareProtocol.updateCurrencyStatus(currency, true); + makerBid.currency = currency; + makerBid.strategyId = 1; + uint256[9] memory validationCodes = + orderValidator.checkMakerOrderValidity(makerBid, new bytes(65), _EMPTY_MERKLE_TREE); + assertEq(validationCodes[0], STRATEGY_NOT_IMPLEMENTED); + } + + function testMakerAskLooksRareProtocolIsNotAWhitelistedOperator() public { + OrderStructs.Maker memory makerAsk; + makerAsk.quoteType = QuoteType.Ask; + makerAsk.signer = makerUser; + makerAsk.collectionType = CollectionType.ERC721; + makerAsk.collection = address(new MockERC721()); + + address[] memory operators = new address[](1); + operators[0] = address(orderValidator.looksRareProtocol()); + + transferManager.allowOperator(operators[0]); + + vm.prank(makerUser); + transferManager.grantApprovals(operators); + + transferManager.removeOperator(operators[0]); + + uint256[9] memory validationCodes = + orderValidator.checkMakerOrderValidity(makerAsk, new bytes(65), _EMPTY_MERKLE_TREE); + assertEq(validationCodes[7], TRANSFER_MANAGER_APPROVAL_REVOKED_BY_OWNER_FOR_EXCHANGE); + } + + function testMakerAskWrongCollectionTypeERC721() public { + OrderStructs.Maker memory makerAsk; + makerAsk.quoteType = QuoteType.Ask; + makerAsk.collectionType = CollectionType.ERC721; + makerAsk.collection = address(new MockERC721SupportsNoInterface()); + uint256[9] memory validationCodes = + orderValidator.checkMakerOrderValidity(makerAsk, new bytes(65), _EMPTY_MERKLE_TREE); + assertEq(validationCodes[6], POTENTIAL_INVALID_COLLECTION_TYPE_SHOULD_BE_ERC721); + } + + function testMakerBidWrongCollectionTypeERC721() public { + OrderStructs.Maker memory makerBid; + makerBid.quoteType = QuoteType.Bid; + makerBid.collectionType = CollectionType.ERC721; + makerBid.collection = address(new MockERC721SupportsNoInterface()); + uint256[9] memory validationCodes = + orderValidator.checkMakerOrderValidity(makerBid, new bytes(65), _EMPTY_MERKLE_TREE); + assertEq(validationCodes[6], POTENTIAL_INVALID_COLLECTION_TYPE_SHOULD_BE_ERC721); + } + + function testMakerBidZeroAmount() public { + _testMakerBidERC721InvalidAmount(0); + } + + function testMakerBidERC721AmountNotEqualToOne() public { + _testMakerBidERC721InvalidAmount(2); + } + + function _testMakerBidERC721InvalidAmount(uint256 amount) public { + OrderStructs.Maker memory makerBid; + makerBid.quoteType = QuoteType.Bid; + makerBid.collectionType = CollectionType.ERC721; + makerBid.collection = address(new MockERC721()); + uint256[] memory itemIds = new uint256[](1); + itemIds[0] = amount; + makerBid.itemIds = itemIds; + uint256[] memory amounts = new uint256[](1); + amounts[0] = amount; + makerBid.amounts = amounts; + uint256[9] memory validationCodes = + orderValidator.checkMakerOrderValidity(makerBid, new bytes(65), _EMPTY_MERKLE_TREE); + assertEq(validationCodes[1], MAKER_ORDER_INVALID_STANDARD_SALE); + } + + function testMakerBidMissingIsValidSignature() public { + OrderStructs.Maker memory makerBid; + // This contract does not have isValidSignature implemented + makerBid.quoteType = QuoteType.Bid; + makerBid.signer = address(this); + makerBid.collectionType = CollectionType.ERC721; + makerBid.collection = address(new MockERC721()); + uint256[9] memory validationCodes = + orderValidator.checkMakerOrderValidity(makerBid, new bytes(65), _EMPTY_MERKLE_TREE); + assertEq(validationCodes[3], MISSING_IS_VALID_SIGNATURE_FUNCTION_EIP1271); + } + + function testMakerAskWrongCollectionTypeERC1155() public { + OrderStructs.Maker memory makerAsk; + makerAsk.collectionType = CollectionType.ERC1155; + makerAsk.collection = address(new MockERC1155SupportsNoInterface()); + uint256[9] memory validationCodes = + orderValidator.checkMakerOrderValidity(makerAsk, new bytes(65), _EMPTY_MERKLE_TREE); + assertEq(validationCodes[6], POTENTIAL_INVALID_COLLECTION_TYPE_SHOULD_BE_ERC1155); + } + + function testMakerBidWrongCollectionTypeERC1155() public { + OrderStructs.Maker memory makerBid; + makerBid.quoteType = QuoteType.Bid; + makerBid.collectionType = CollectionType.ERC1155; + makerBid.collection = address(new MockERC1155SupportsNoInterface()); + uint256[9] memory validationCodes = + orderValidator.checkMakerOrderValidity(makerBid, new bytes(65), _EMPTY_MERKLE_TREE); + assertEq(validationCodes[6], POTENTIAL_INVALID_COLLECTION_TYPE_SHOULD_BE_ERC1155); + } + + function testMakerBidInsufficientERC20Allowance() public { + OrderStructs.Maker memory makerBid; + makerBid.quoteType = QuoteType.Bid; + MockERC20 mockERC20 = new MockERC20(); + makerBid.collectionType = CollectionType.ERC721; + makerBid.collection = address(new MockERC721()); + makerBid.signer = makerUser; + makerBid.currency = address(mockERC20); + makerBid.collectionType = CollectionType.ERC721; + makerBid.price = 1 ether; + + mockERC20.mint(makerUser, 1 ether); + + vm.startPrank(makerUser); + mockERC20.approve(address(orderValidator.looksRareProtocol()), makerBid.price - 1 wei); + vm.stopPrank(); + + uint256[9] memory validationCodes = + orderValidator.checkMakerOrderValidity(makerBid, new bytes(65), _EMPTY_MERKLE_TREE); + assertEq(validationCodes[5], ERC20_APPROVAL_INFERIOR_TO_PRICE); + } + + function testMakerAskERC721NotAllTokensAreApproved() public { + MockERC721 mockERC721 = new MockERC721(); + mockERC721.mint(makerUser, 0); + mockERC721.mint(makerUser, 1); + + OrderStructs.Maker memory makerAsk; + makerAsk.quoteType = QuoteType.Ask; + makerAsk.collectionType = CollectionType.ERC721; + makerAsk.collection = address(mockERC721); + makerAsk.signer = makerUser; + makerAsk.collectionType = CollectionType.ERC721; + + // Only approve token 0 but not token 1, this is to test the loop + vm.prank(makerUser); + mockERC721.approve(address(transferManager), 0); + + uint256[] memory itemIds = new uint256[](2); + itemIds[0] = 0; + itemIds[1] = 1; + makerAsk.itemIds = itemIds; + + uint256[] memory amounts = new uint256[](2); + amounts[0] = 1; + amounts[1] = 1; + makerAsk.amounts = amounts; + + uint256[9] memory validationCodes = + orderValidator.checkMakerOrderValidity(makerAsk, new bytes(65), _EMPTY_MERKLE_TREE); + assertEq(validationCodes[5], ERC721_NO_APPROVAL_FOR_ALL_OR_ITEM_ID); + } + + function testMakerAskDoesNotOwnERC721() public { + OrderStructs.Maker memory makerAsk; + makerAsk.quoteType = QuoteType.Ask; + makerAsk.collectionType = CollectionType.ERC721; + MockERC721 mockERC721 = new MockERC721(); + mockERC721.mint(address(this), 0); + makerAsk.collection = address(mockERC721); + makerAsk.signer = makerUser; + makerAsk.collectionType = CollectionType.ERC721; + uint256[] memory itemIds = new uint256[](1); + makerAsk.itemIds = itemIds; + + uint256[9] memory validationCodes = + orderValidator.checkMakerOrderValidity(makerAsk, new bytes(65), _EMPTY_MERKLE_TREE); + + assertEq(validationCodes[5], ERC721_ITEM_ID_NOT_IN_BALANCE); + } + + function testMakerAskERC1155BalanceInferiorToAmountThroughBalanceOfBatch() public { + _testMakerAskERC1155BalanceInferiorToAmount(true); + } + + function testMakerAskERC1155BalanceInferiorToAmountThroughBalanceOf() public { + _testMakerAskERC1155BalanceInferiorToAmount(false); + } + + function _testMakerAskERC1155BalanceInferiorToAmount(bool revertBalanceOfBatch) public { + address collection; + if (revertBalanceOfBatch) { + MockERC1155WithoutBalanceOfBatch mockERC1155 = new MockERC1155WithoutBalanceOfBatch(); + collection = address(mockERC1155); + } else { + MockERC1155 mockERC1155 = new MockERC1155(); + collection = address(mockERC1155); + } + + OrderStructs.Maker memory makerAsk; + makerAsk.quoteType = QuoteType.Ask; + makerAsk.collectionType = CollectionType.ERC1155; + makerAsk.collection = collection; + makerAsk.signer = makerUser; + makerAsk.collectionType = CollectionType.ERC1155; + uint256[] memory itemIds = new uint256[](1); + makerAsk.itemIds = itemIds; + uint256[] memory amounts = new uint256[](1); + amounts[0] = 1; + makerAsk.amounts = amounts; + + uint256[9] memory validationCodes = + orderValidator.checkMakerOrderValidity(makerAsk, new bytes(65), _EMPTY_MERKLE_TREE); + assertEq(validationCodes[5], ERC1155_BALANCE_OF_ITEM_ID_INFERIOR_TO_AMOUNT); + } + + function testMakerAskERC1155BalanceOfDoesNotExist() public { + MockERC1155WithoutAnyBalanceOf mockERC1155 = new MockERC1155WithoutAnyBalanceOf(); + + OrderStructs.Maker memory makerAsk; + makerAsk.quoteType = QuoteType.Ask; + makerAsk.collectionType = CollectionType.ERC1155; + makerAsk.collection = address(mockERC1155); + makerAsk.signer = makerUser; + makerAsk.collectionType = CollectionType.ERC1155; + uint256[] memory itemIds = new uint256[](1); + makerAsk.itemIds = itemIds; + uint256[] memory amounts = new uint256[](1); + amounts[0] = 1; + makerAsk.amounts = amounts; + + uint256[9] memory validationCodes = + orderValidator.checkMakerOrderValidity(makerAsk, new bytes(65), _EMPTY_MERKLE_TREE); + assertEq(validationCodes[5], ERC1155_BALANCE_OF_DOES_NOT_EXIST); + } + + function testMakerAskERC1155IsApprovedForAllDoesNotExist() public { + MockERC1155WithoutIsApprovedForAll mockERC1155 = new MockERC1155WithoutIsApprovedForAll(); + mockERC1155.mint({to: makerUser, tokenId: 0, amount: 1}); + + OrderStructs.Maker memory makerAsk; + makerAsk.quoteType = QuoteType.Ask; + makerAsk.collectionType = CollectionType.ERC1155; + makerAsk.collection = address(mockERC1155); + makerAsk.signer = makerUser; + makerAsk.collectionType = CollectionType.ERC1155; + uint256[] memory itemIds = new uint256[](1); + makerAsk.itemIds = itemIds; + uint256[] memory amounts = new uint256[](1); + amounts[0] = 1; + makerAsk.amounts = amounts; + + uint256[9] memory validationCodes = + orderValidator.checkMakerOrderValidity(makerAsk, new bytes(65), _EMPTY_MERKLE_TREE); + assertEq(validationCodes[5], ERC1155_IS_APPROVED_FOR_ALL_DOES_NOT_EXIST); + } + + function testMakerAskERC1155IsApprovedForAllReturnsFalse() public { + MockERC1155 mockERC1155 = new MockERC1155(); + mockERC1155.mint({to: makerUser, tokenId: 0, amount: 1}); + + OrderStructs.Maker memory makerAsk; + makerAsk.quoteType = QuoteType.Ask; + makerAsk.collectionType = CollectionType.ERC1155; + makerAsk.collection = address(mockERC1155); + makerAsk.signer = makerUser; + makerAsk.collectionType = CollectionType.ERC1155; + uint256[] memory itemIds = new uint256[](1); + makerAsk.itemIds = itemIds; + uint256[] memory amounts = new uint256[](1); + amounts[0] = 1; + makerAsk.amounts = amounts; + + uint256[9] memory validationCodes = + orderValidator.checkMakerOrderValidity(makerAsk, new bytes(65), _EMPTY_MERKLE_TREE); + assertEq(validationCodes[5], ERC1155_NO_APPROVAL_FOR_ALL); + } +} diff --git a/contracts/test/foundry/marketplace/ProtocolBase.t.sol b/contracts/test/foundry/marketplace/ProtocolBase.t.sol new file mode 100644 index 00000000..8c3cee4b --- /dev/null +++ b/contracts/test/foundry/marketplace/ProtocolBase.t.sol @@ -0,0 +1,257 @@ +// SPDX-License-Identifier: MIT +pragma solidity >=0.8.7; + +// WETH +import {WETH} from "solmate/src/tokens/WETH.sol"; + +// Libraries +import {OrderStructs} from "@hypercerts/marketplace/libraries/OrderStructs.sol"; + +// Core contracts +import {LooksRareProtocol, ILooksRareProtocol} from "@hypercerts/marketplace/LooksRareProtocol.sol"; +import {TransferManager} from "@hypercerts/marketplace/TransferManager.sol"; +import {ProtocolFeeRecipient} from "@hypercerts/marketplace/ProtocolFeeRecipient.sol"; + +// Other contracts +import {OrderValidatorV2A} from "@hypercerts/marketplace/helpers/OrderValidatorV2A.sol"; + +// Mock files +import {MockERC20} from "../../mock/MockERC20.sol"; +import {MockERC721} from "../../mock/MockERC721.sol"; +import {MockERC721WithRoyalties} from "../../mock/MockERC721WithRoyalties.sol"; +import {MockERC1155} from "../../mock/MockERC1155.sol"; +import {MockRoyaltyFeeRegistry} from "../../mock/MockRoyaltyFeeRegistry.sol"; + +// Utils +import {MockOrderGenerator} from "./utils/MockOrderGenerator.sol"; + +contract ProtocolBase is MockOrderGenerator, ILooksRareProtocol { + address[] public operators; + + MockERC20 public looksRareToken; + MockERC721WithRoyalties public mockERC721WithRoyalties; + MockERC721 public mockERC721; + MockERC1155 public mockERC1155; + + ProtocolFeeRecipient public protocolFeeRecipient; + LooksRareProtocol public looksRareProtocol; + TransferManager public transferManager; + MockRoyaltyFeeRegistry public royaltyFeeRegistry; + OrderValidatorV2A public orderValidator; + + WETH public weth; + + function _assertMakerOrderReturnValidationCode( + OrderStructs.Maker memory makerOrder, + bytes memory signature, + uint256 expectedValidationCode + ) internal { + _assertMakerOrderReturnValidationCode(makerOrder, signature, _EMPTY_MERKLE_TREE, expectedValidationCode); + } + + function _assertMakerOrderReturnValidationCodeWithMerkleTree( + OrderStructs.Maker memory makerOrder, + bytes memory signature, + OrderStructs.MerkleTree memory merkleTree, + uint256 expectedValidationCode + ) internal { + _assertMakerOrderReturnValidationCode(makerOrder, signature, merkleTree, expectedValidationCode); + } + + function _assertMakerOrderReturnValidationCode( + OrderStructs.Maker memory makerOrder, + bytes memory signature, + OrderStructs.MerkleTree memory merkleTree, + uint256 expectedValidationCode + ) private { + OrderStructs.Maker[] memory makerOrders = new OrderStructs.Maker[](1); + makerOrders[0] = makerOrder; + + bytes[] memory signatures = new bytes[](1); + signatures[0] = signature; + + OrderStructs.MerkleTree[] memory merkleTrees = new OrderStructs.MerkleTree[](1); + merkleTrees[0] = merkleTree; + + uint256[9][] memory validationCodes = + orderValidator.checkMultipleMakerOrderValidities(makerOrders, signatures, merkleTrees); + + uint256 index = expectedValidationCode / 100; + assertEq(validationCodes[0][index - 1], expectedValidationCode); + } + + function _assertValidMakerOrder(OrderStructs.Maker memory makerOrder, bytes memory signature) internal { + _assertValidMakerOrder(makerOrder, signature, _EMPTY_MERKLE_TREE); + } + + function _assertValidMakerOrderWithMerkleTree( + OrderStructs.Maker memory makerOrder, + bytes memory signature, + OrderStructs.MerkleTree memory merkleTree + ) internal { + _assertValidMakerOrder(makerOrder, signature, merkleTree); + } + + function _assertValidMakerOrder( + OrderStructs.Maker memory makerOrder, + bytes memory signature, + OrderStructs.MerkleTree memory merkleTree + ) private { + OrderStructs.Maker[] memory makerOrders = new OrderStructs.Maker[](1); + makerOrders[0] = makerOrder; + + bytes[] memory signatures = new bytes[](1); + signatures[0] = signature; + + OrderStructs.MerkleTree[] memory merkleTrees = new OrderStructs.MerkleTree[](1); + merkleTrees[0] = merkleTree; + + uint256[9][] memory validationCodes = + orderValidator.checkMultipleMakerOrderValidities(makerOrders, signatures, merkleTrees); + + _assertValidationCodesAllZeroes(validationCodes); + } + + function _assertValidationCodesAllZeroes(uint256[9][] memory validationCodes) private { + for (uint256 i; i < validationCodes.length; i++) { + for (uint256 j; j < 9; j++) { + assertEq(validationCodes[i][j], 0); + } + } + } + + function _setUpUser(address user) internal asPrankedUser(user) { + // Do approvals for collections and WETH + mockERC721.setApprovalForAll(address(transferManager), true); + mockERC1155.setApprovalForAll(address(transferManager), true); + mockERC721WithRoyalties.setApprovalForAll(address(transferManager), true); + weth.approve(address(looksRareProtocol), type(uint256).max); + + // Grant approvals for transfer manager + transferManager.grantApprovals(operators); + + // Receive ETH and WETH + vm.deal(user, _initialETHBalanceUser + _initialWETHBalanceUser); + weth.deposit{value: _initialWETHBalanceUser}(); + } + + function _setUpUsers() internal { + _setUpUser(makerUser); + _setUpUser(takerUser); + } + + function _setupRegistryRoyalties(address collection, uint256 standardRoyaltyFee) internal { + vm.prank(royaltyFeeRegistry.owner()); + royaltyFeeRegistry.updateRoyaltyInfoForCollection( + collection, _royaltyRecipient, _royaltyRecipient, standardRoyaltyFee + ); + } + + function _setUp() internal { + vm.startPrank(_owner); + weth = new WETH(); + looksRareToken = new MockERC20(); + mockERC721 = new MockERC721(); + mockERC1155 = new MockERC1155(); + + transferManager = new TransferManager(_owner); + royaltyFeeRegistry = new MockRoyaltyFeeRegistry(_owner, 9500); + protocolFeeRecipient = new ProtocolFeeRecipient(0x5924A28caAF1cc016617874a2f0C3710d881f3c1, address(weth)); + looksRareProtocol = new LooksRareProtocol( + _owner, + address(protocolFeeRecipient), + address(transferManager), + address(weth) + ); + mockERC721WithRoyalties = new MockERC721WithRoyalties(_royaltyRecipient, _standardRoyaltyFee); + + // Operations + transferManager.allowOperator(address(looksRareProtocol)); + looksRareProtocol.updateCurrencyStatus(ETH, true); + looksRareProtocol.updateCurrencyStatus(address(weth), true); + + // Fetch domain separator and store it as one of the operators + _domainSeparator = looksRareProtocol.domainSeparator(); + operators.push(address(looksRareProtocol)); + + // Deploy order validator contract + orderValidator = new OrderValidatorV2A(address(looksRareProtocol)); + + // Distribute ETH and WETH to protocol owner + vm.deal(_owner, _initialETHBalanceOwner + _initialWETHBalanceOwner); + weth.deposit{value: _initialWETHBalanceOwner}(); + vm.stopPrank(); + + // Distribute ETH and WETH to royalty recipient + vm.deal(_royaltyRecipient, _initialETHBalanceRoyaltyRecipient + _initialWETHBalanceRoyaltyRecipient); + vm.startPrank(_royaltyRecipient); + weth.deposit{value: _initialWETHBalanceRoyaltyRecipient}(); + vm.stopPrank(); + } + + function _genericTakerOrder() internal pure returns (OrderStructs.Taker memory takerOrder) { + takerOrder = OrderStructs.Taker(takerUser, abi.encode()); + } + + function _addStrategy(address strategy, bytes4 selector, bool isMakerBid) internal { + looksRareProtocol.addStrategy( + _standardProtocolFeeBp, _minTotalFeeBp, _maxProtocolFeeBp, selector, isMakerBid, strategy + ); + } + + function _assertStrategyAttributes( + address expectedStrategyAddress, + bytes4 expectedSelector, + bool expectedIsMakerBid + ) internal { + ( + bool strategyIsActive, + uint16 strategyStandardProtocolFee, + uint16 strategyMinTotalFee, + uint16 strategyMaxProtocolFee, + bytes4 strategySelector, + bool strategyIsMakerBid, + address strategyImplementation + ) = looksRareProtocol.strategyInfo(1); + + assertTrue(strategyIsActive); + assertEq(strategyStandardProtocolFee, _standardProtocolFeeBp); + assertEq(strategyMinTotalFee, _minTotalFeeBp); + assertEq(strategyMaxProtocolFee, _maxProtocolFeeBp); + assertEq(strategySelector, expectedSelector); + assertEq(strategyIsMakerBid, expectedIsMakerBid); + assertEq(strategyImplementation, expectedStrategyAddress); + } + + function _assertMockERC721Ownership(uint256[] memory itemIds, address owner) internal { + for (uint256 i; i < itemIds.length; i++) { + assertEq(mockERC721.ownerOf(itemIds[i]), owner); + } + } + + /** + * NOTE: It inherits from ILooksRareProtocol, so it + * needs to at least define the functions below. + */ + function executeTakerAsk( + OrderStructs.Taker calldata takerAsk, + OrderStructs.Maker calldata makerBid, + bytes calldata makerSignature, + OrderStructs.MerkleTree calldata merkleTree + ) external {} + + function executeTakerBid( + OrderStructs.Taker calldata takerBid, + OrderStructs.Maker calldata makerAsk, + bytes calldata makerSignature, + OrderStructs.MerkleTree calldata merkleTree + ) external payable {} + + function executeMultipleTakerBids( + OrderStructs.Taker[] calldata takerBids, + OrderStructs.Maker[] calldata makerAsks, + bytes[] calldata makerSignatures, + OrderStructs.MerkleTree[] calldata merkleTrees, + bool isAtomic + ) external payable {} +} diff --git a/contracts/test/foundry/marketplace/ProtocolFeeRecipient.t.sol b/contracts/test/foundry/marketplace/ProtocolFeeRecipient.t.sol new file mode 100644 index 00000000..0b30803f --- /dev/null +++ b/contracts/test/foundry/marketplace/ProtocolFeeRecipient.t.sol @@ -0,0 +1,110 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.17; + +// LooksRare unopinionated libraries +import {IERC20} from "@looksrare/contracts-libs/contracts/interfaces/generic/IERC20.sol"; +import {IWETH} from "@looksrare/contracts-libs/contracts/interfaces/generic/IWETH.sol"; + +// Core contracts +import {ProtocolFeeRecipient} from "@hypercerts/marketplace/ProtocolFeeRecipient.sol"; + +// Other mocks and utils +import {MockERC20} from "../../mock/MockERC20.sol"; +import {TestParameters} from "./utils/TestParameters.sol"; + +contract ProtocolFeeRecipientTest is TestParameters { + ProtocolFeeRecipient private protocolFeeRecipient; + uint256 private feeSharingSetterInitialWETHBalance; + + address private constant FEE_SHARING_SETTER = 0x5924A28caAF1cc016617874a2f0C3710d881f3c1; + uint256 private constant DUST = 0.6942 ether; + + function setUp() public { + vm.createSelectFork(vm.rpcUrl("mainnet")); + protocolFeeRecipient = new ProtocolFeeRecipient(FEE_SHARING_SETTER, WETH_MAINNET); + feeSharingSetterInitialWETHBalance = IERC20(WETH_MAINNET).balanceOf(FEE_SHARING_SETTER); + + vm.deal(address(protocolFeeRecipient), 0); + deal(WETH_MAINNET, address(protocolFeeRecipient), 0); + } + + function test_TransferETH_NoWETHBalance_WithETHBalance() public { + _sendETHToProtocolFeeRecipient(); + + protocolFeeRecipient.transferETH(); + + assertEq(address(protocolFeeRecipient).balance, 0); + assertEq(IERC20(WETH_MAINNET).balanceOf(address(protocolFeeRecipient)), 0); + assertEq(IERC20(WETH_MAINNET).balanceOf(FEE_SHARING_SETTER), feeSharingSetterInitialWETHBalance + 1 ether); + } + + function test_TransferETH_WithWETHBalance_WithETHBalance() public { + _sendETHToProtocolFeeRecipient(); + _sendWETHToProtocolFeeRecipient(); + + protocolFeeRecipient.transferETH(); + + assertEq(address(protocolFeeRecipient).balance, 0); + assertEq(IERC20(WETH_MAINNET).balanceOf(address(protocolFeeRecipient)), 0); + assertEq( + IERC20(WETH_MAINNET).balanceOf(FEE_SHARING_SETTER), feeSharingSetterInitialWETHBalance + 1 ether + DUST + ); + } + + function test_TransferETH_WithWETHBalance_NoETHBalance() public { + _sendWETHToProtocolFeeRecipient(); + + protocolFeeRecipient.transferETH(); + + assertEq(address(protocolFeeRecipient).balance, 0); + assertEq(IERC20(WETH_MAINNET).balanceOf(address(protocolFeeRecipient)), 0); + assertEq(IERC20(WETH_MAINNET).balanceOf(FEE_SHARING_SETTER), feeSharingSetterInitialWETHBalance + DUST); + } + + function test_TransferETH_RevertIf_NothingToTransfer() public { + vm.expectRevert(ProtocolFeeRecipient.NothingToTransfer.selector); + protocolFeeRecipient.transferETH(); + } + + function test_TransferWETH() public { + _sendWETHToProtocolFeeRecipient(); + + protocolFeeRecipient.transferERC20(WETH_MAINNET); + + assertEq(IERC20(WETH_MAINNET).balanceOf(address(protocolFeeRecipient)), 0); + assertEq(IERC20(WETH_MAINNET).balanceOf(FEE_SHARING_SETTER), feeSharingSetterInitialWETHBalance + DUST); + } + + function test_TransferWETH_RevertIf_NothingToTransfer() public { + vm.expectRevert(ProtocolFeeRecipient.NothingToTransfer.selector); + protocolFeeRecipient.transferERC20(WETH_MAINNET); + } + + function test_TransferERC20() public { + MockERC20 mockERC20 = new MockERC20(); + mockERC20.mint(address(protocolFeeRecipient), DUST); + + protocolFeeRecipient.transferERC20(address(mockERC20)); + + assertEq(mockERC20.balanceOf(address(protocolFeeRecipient)), 0); + assertEq(mockERC20.balanceOf(FEE_SHARING_SETTER), DUST); + } + + function test_TransferERC20_RevertIf_NothingToTransfer() public { + MockERC20 mockERC20 = new MockERC20(); + vm.expectRevert(ProtocolFeeRecipient.NothingToTransfer.selector); + protocolFeeRecipient.transferERC20(address(mockERC20)); + } + + function _sendETHToProtocolFeeRecipient() private { + (bool success,) = address(protocolFeeRecipient).call{value: 1 ether}(""); + assertTrue(success); + assertEq(address(protocolFeeRecipient).balance, 1 ether); + } + + function _sendWETHToProtocolFeeRecipient() private { + IWETH(WETH_MAINNET).deposit{value: DUST}(); + IERC20(WETH_MAINNET).transfer(address(protocolFeeRecipient), DUST); + assertEq(IERC20(WETH_MAINNET).balanceOf(address(protocolFeeRecipient)), DUST); + } +} diff --git a/contracts/test/foundry/marketplace/Sandbox.t.sol b/contracts/test/foundry/marketplace/Sandbox.t.sol new file mode 100644 index 00000000..9a349fd5 --- /dev/null +++ b/contracts/test/foundry/marketplace/Sandbox.t.sol @@ -0,0 +1,142 @@ +// SPDX-License-Identifier: MIT +pragma solidity 0.8.17; + +// LooksRare unopinionated libraries +import {IERC721} from "@looksrare/contracts-libs/contracts/interfaces/generic/IERC721.sol"; +import {IERC1155} from "@looksrare/contracts-libs/contracts/interfaces/generic/IERC1155.sol"; + +// Libraries and interfaces +import {OrderStructs} from "@hypercerts/marketplace/libraries/OrderStructs.sol"; + +// Base test +import {ProtocolBase} from "./ProtocolBase.t.sol"; + +// Enums +import {CollectionType} from "@hypercerts/marketplace/enums/CollectionType.sol"; +import {QuoteType} from "@hypercerts/marketplace/enums/QuoteType.sol"; + +contract SandboxTest is ProtocolBase { + error ERC721TransferFromFail(); + + // Fixed price of sale + uint256 private constant price = 1 ether; + + // Sandbox on Ethereum mainnet + address private constant SANDBOX = 0xa342f5D851E866E18ff98F351f2c6637f4478dB5; + + // Forked block number to run the tests + uint256 private constant FORKED_BLOCK_NUMBER = 16_268_000; + + function _transferItemIdToUser(address user) private returns (uint256 itemId) { + // @dev This user had 23 of the itemId at the forked block number + address ownerOfItemId = 0x7A9fe22691c811ea339D9B73150e6911a5343DcA; + itemId = 55_464_657_044_963_196_816_950_587_289_035_428_064_568_320_970_692_304_673_817_341_489_688_428_423_171; + vm.prank(ownerOfItemId); + IERC1155(SANDBOX).safeTransferFrom(ownerOfItemId, user, itemId, 23, ""); + } + + function _setUpApprovalsForSandbox(address user) internal { + vm.prank(user); + IERC1155(SANDBOX).setApprovalForAll(address(transferManager), true); + } + + function setUp() public { + vm.createSelectFork(vm.rpcUrl("mainnet"), FORKED_BLOCK_NUMBER); + _setUp(); + _setUpUsers(); + } + + /** + * @notice Sandbox implements both ERC721 and ERC1155 interfaceIds. + * This test verifies that only collectionType = 1 works. + * It is for taker ask (matching maker bid). + */ + function testTakerAskCannotTransferSandboxWithERC721CollectionTypeButERC1155CollectionTypeWorks() public { + // Taker user is the one selling the item + _setUpApprovalsForSandbox(takerUser); + uint256 itemId = _transferItemIdToUser(takerUser); + + OrderStructs.Maker memory makerBid = _createSingleItemMakerOrder({ + quoteType: QuoteType.Bid, + globalNonce: 0, + subsetNonce: 0, + strategyId: STANDARD_SALE_FOR_FIXED_PRICE_STRATEGY, + collectionType: CollectionType.ERC721, // it should be ERC1155 + orderNonce: 0, + collection: SANDBOX, + currency: address(weth), + signer: makerUser, + price: price, + itemId: itemId + }); + + // Sign order + bytes memory signature = _signMakerOrder(makerBid, makerUserPK); + + // Prepare the taker ask + OrderStructs.Taker memory takerAsk = _genericTakerOrder(); + + // It should fail with collectionType = 0 + vm.expectRevert(abi.encodeWithSelector(ERC721TransferFromFail.selector)); + vm.prank(takerUser); + looksRareProtocol.executeTakerAsk(takerAsk, makerBid, signature, _EMPTY_MERKLE_TREE); + + // Adjust the collection type and sign order again + makerBid.collectionType = CollectionType.ERC1155; + signature = _signMakerOrder(makerBid, makerUserPK); + + // It shouldn't fail with collectionType = 0 + vm.prank(takerUser); + looksRareProtocol.executeTakerAsk(takerAsk, makerBid, signature, _EMPTY_MERKLE_TREE); + + // Maker user has received the Sandbox asset + assertEq(IERC1155(SANDBOX).balanceOf(makerUser, itemId), makerBid.amounts[0]); + } + + /** + * @notice Sandbox implements both ERC721 and ERC1155 interfaceIds. + * This test verifies that only collectionType = 1 works. + * It is for taker bid (matching maker ask). + */ + function testTakerBidCannotTransferSandboxWithERC721CollectionTypeButERC1155CollectionTypeWorks() public { + // Maker user is the one selling the item + _setUpApprovalsForSandbox(makerUser); + uint256 itemId = _transferItemIdToUser(makerUser); + + OrderStructs.Maker memory makerAsk = _createSingleItemMakerOrder({ + quoteType: QuoteType.Ask, + globalNonce: 0, + subsetNonce: 0, + strategyId: STANDARD_SALE_FOR_FIXED_PRICE_STRATEGY, + collectionType: CollectionType.ERC721, // it should be ERC1155 + orderNonce: 0, + collection: SANDBOX, + currency: ETH, + signer: makerUser, + price: price, + itemId: itemId + }); + + // Sign order + bytes memory signature = _signMakerOrder(makerAsk, makerUserPK); + + // Prepare the taker bid + OrderStructs.Taker memory takerBid = _genericTakerOrder(); + + // It should fail with collectionType = 0 + vm.expectRevert(abi.encodeWithSelector(ERC721TransferFromFail.selector)); + vm.prank(takerUser); + looksRareProtocol.executeTakerBid{value: price}(takerBid, makerAsk, signature, _EMPTY_MERKLE_TREE); + + // Adjust the collection type and sign order again + makerAsk.collectionType = CollectionType.ERC1155; + signature = _signMakerOrder(makerAsk, makerUserPK); + + // It shouldn't fail with collectionType = 0 + vm.prank(takerUser); + looksRareProtocol.executeTakerBid{value: price}(takerBid, makerAsk, signature, _EMPTY_MERKLE_TREE); + + // Taker user has received the Sandbox asset + assertEq(IERC1155(SANDBOX).balanceOf(takerUser, itemId), makerAsk.amounts[0]); + } +} diff --git a/contracts/test/foundry/marketplace/SignaturesEIP2098.t.sol b/contracts/test/foundry/marketplace/SignaturesEIP2098.t.sol new file mode 100644 index 00000000..ea02561a --- /dev/null +++ b/contracts/test/foundry/marketplace/SignaturesEIP2098.t.sol @@ -0,0 +1,66 @@ +// SPDX-License-Identifier: MIT +pragma solidity 0.8.17; + +// Libraries, interfaces, errors +import "@looksrare/contracts-libs/contracts/errors/SignatureCheckerErrors.sol"; +import {OrderStructs} from "@hypercerts/marketplace/libraries/OrderStructs.sol"; + +// Base test +import {ProtocolBase} from "./ProtocolBase.t.sol"; + +// Constants +import {ONE_HUNDRED_PERCENT_IN_BP} from "@hypercerts/marketplace/constants/NumericConstants.sol"; + +// Enums +import {CollectionType} from "@hypercerts/marketplace/enums/CollectionType.sol"; +import {QuoteType} from "@hypercerts/marketplace/enums/QuoteType.sol"; + +contract SignaturesEIP2098Test is ProtocolBase { + function setUp() public { + _setUp(); + } + + function testCanSignValidMakerAskEIP2098(uint256 price, uint256 itemId) public { + vm.assume(price <= 2 ether); + + _setUpUsers(); + _setupRegistryRoyalties(address(mockERC721), _standardRoyaltyFee); + + (OrderStructs.Maker memory makerAsk,) = _createMockMakerAskAndTakerBid(address(mockERC721)); + makerAsk.price = price; + makerAsk.itemIds[0] = itemId; + + bytes memory signature = _signMakerOrder(makerAsk, makerUserPK); + + // Mint asset + mockERC721.mint(makerUser, makerAsk.itemIds[0]); + + // Adjust the signature + signature = _eip2098Signature(signature); + + // Verify validity of maker ask order + _assertValidMakerOrder(makerAsk, signature); + } + + function testCanSignValidMakerBidEIP2098(uint256 price, uint256 itemId) public { + vm.assume(price <= 2 ether); + + _setUpUsers(); + _setupRegistryRoyalties(address(mockERC721), _standardRoyaltyFee); + + (OrderStructs.Maker memory makerBid,) = _createMockMakerBidAndTakerAsk(address(mockERC721), address(weth)); + makerBid.price = price; + makerBid.itemIds[0] = itemId; + + bytes memory signature = _signMakerOrder(makerBid, makerUserPK); + + // Adjust the signature + signature = _eip2098Signature(signature); + + // Mint asset + mockERC721.mint(takerUser, makerBid.itemIds[0]); + + // Verify validity of maker bid order + _assertValidMakerOrder(makerBid, signature); + } +} diff --git a/contracts/test/foundry/marketplace/SignaturesERC1271WalletForERC1155.t.sol b/contracts/test/foundry/marketplace/SignaturesERC1271WalletForERC1155.t.sol new file mode 100644 index 00000000..2a96743c --- /dev/null +++ b/contracts/test/foundry/marketplace/SignaturesERC1271WalletForERC1155.t.sol @@ -0,0 +1,445 @@ +// SPDX-License-Identifier: MIT +pragma solidity 0.8.17; + +// Libraries and interfaces +import {IReentrancyGuard} from "@looksrare/contracts-libs/contracts/interfaces/IReentrancyGuard.sol"; +import {OrderStructs} from "@hypercerts/marketplace/libraries/OrderStructs.sol"; + +// Base test +import {ProtocolBase} from "./ProtocolBase.t.sol"; + +// Mocks and other utils +import {ERC1271Wallet} from "./utils/ERC1271Wallet.sol"; +import {MaliciousERC1271Wallet} from "./utils/MaliciousERC1271Wallet.sol"; +import {MaliciousOnERC1155ReceivedERC1271Wallet} from "./utils/MaliciousOnERC1155ReceivedERC1271Wallet.sol"; +import {MaliciousOnERC1155ReceivedTheThirdTimeERC1271Wallet} from + "./utils/MaliciousOnERC1155ReceivedTheThirdTimeERC1271Wallet.sol"; +import {MaliciousIsValidSignatureERC1271Wallet} from "./utils/MaliciousIsValidSignatureERC1271Wallet.sol"; + +// Errors +import {SignatureERC1271Invalid} from "@looksrare/contracts-libs/contracts/errors/SignatureCheckerErrors.sol"; +import { + ERC1155SafeTransferFromFail, + ERC1155SafeBatchTransferFromFail +} from "@looksrare/contracts-libs/contracts/errors/LowLevelErrors.sol"; +import {SIGNATURE_INVALID_EIP1271} from "@hypercerts/marketplace/constants/ValidationCodeConstants.sol"; + +// Enums +import {CollectionType} from "@hypercerts/marketplace/enums/CollectionType.sol"; +import {QuoteType} from "@hypercerts/marketplace/enums/QuoteType.sol"; + +/** + * @dev ERC1271Wallet recovers a signature's signer using ECDSA. If it matches the mock wallet's + * owner, it returns the magic value. Otherwise it returns an empty bytes4 value. + */ +contract SignaturesERC1271WalletForERC1155Test is ProtocolBase { + uint256 private constant price = 1 ether; // Fixed price of sale + uint256 private constant itemId = 0; + bytes private constant _EMPTY_SIGNATURE = new bytes(0); + + function setUp() public { + _setUp(); + _setUpUser(takerUser); + _setupRegistryRoyalties(address(mockERC1155), _standardRoyaltyFee); + } + + function testTakerBid() public { + ERC1271Wallet wallet = new ERC1271Wallet(address(makerUser)); + (OrderStructs.Maker memory makerAsk, OrderStructs.Taker memory takerBid) = _takerBidSetup(address(wallet)); + + bytes memory signature = _signMakerOrder(makerAsk, makerUserPK); + + vm.startPrank(address(wallet)); + mockERC1155.setApprovalForAll(address(transferManager), true); + transferManager.grantApprovals(operators); + vm.stopPrank(); + + _assertValidMakerOrder(makerAsk, signature); + + vm.prank(takerUser); + looksRareProtocol.executeTakerBid{value: price}(takerBid, makerAsk, signature, _EMPTY_MERKLE_TREE); + + assertEq(mockERC1155.balanceOf(takerUser, itemId), 1); + } + + function testTakerBidInvalidSignature() public { + ERC1271Wallet wallet = new ERC1271Wallet(address(makerUser)); + (OrderStructs.Maker memory makerAsk, OrderStructs.Taker memory takerBid) = _takerBidSetup(address(wallet)); + + // Signed by a different private key + bytes memory signature = _signMakerOrder(makerAsk, takerUserPK); + + vm.startPrank(address(wallet)); + mockERC1155.setApprovalForAll(address(transferManager), true); + transferManager.grantApprovals(operators); + vm.stopPrank(); + + _assertMakerOrderReturnValidationCode(makerAsk, signature, SIGNATURE_INVALID_EIP1271); + + vm.expectRevert(SignatureERC1271Invalid.selector); + vm.prank(takerUser); + looksRareProtocol.executeTakerBid{value: price}(takerBid, makerAsk, signature, _EMPTY_MERKLE_TREE); + } + + function testTakerBidIsInvalidSignatureReentrancy() public { + MaliciousIsValidSignatureERC1271Wallet maliciousERC1271Wallet = new MaliciousIsValidSignatureERC1271Wallet( + address(looksRareProtocol) + ); + _setUpUser(address(maliciousERC1271Wallet)); + maliciousERC1271Wallet.setFunctionToReenter(MaliciousERC1271Wallet.FunctionToReenter.ExecuteTakerBid); + + (OrderStructs.Maker memory makerAsk, OrderStructs.Taker memory takerBid) = + _takerBidSetup(address(maliciousERC1271Wallet)); + + vm.expectRevert(IReentrancyGuard.ReentrancyFail.selector); + vm.prank(takerUser); + looksRareProtocol.executeTakerBid{value: price}(takerBid, makerAsk, _EMPTY_SIGNATURE, _EMPTY_MERKLE_TREE); + } + + function testTakerAsk() public { + ERC1271Wallet wallet = new ERC1271Wallet(address(makerUser)); + (OrderStructs.Taker memory takerAsk, OrderStructs.Maker memory makerBid) = _takerAskSetup(address(wallet)); + + bytes memory signature = _signMakerOrder(makerBid, makerUserPK); + + // Wallet needs to hold WETH and have given WETH approval + deal(address(weth), address(wallet), price); + vm.prank(address(wallet)); + weth.approve(address(looksRareProtocol), price); + + _assertValidMakerOrder(makerBid, signature); + + vm.prank(takerUser); + looksRareProtocol.executeTakerAsk(takerAsk, makerBid, signature, _EMPTY_MERKLE_TREE); + + assertEq(mockERC1155.balanceOf(address(wallet), itemId), 1); + } + + function testTakerAskInvalidSignature() public { + ERC1271Wallet wallet = new ERC1271Wallet(address(makerUser)); + (OrderStructs.Taker memory takerAsk, OrderStructs.Maker memory makerBid) = _takerAskSetup(address(wallet)); + + // Signed by a different private key + bytes memory signature = _signMakerOrder(makerBid, takerUserPK); + + // Wallet needs to hold WETH and have given WETH approval + deal(address(weth), address(wallet), price); + vm.prank(address(wallet)); + weth.approve(address(looksRareProtocol), price); + + _assertMakerOrderReturnValidationCode(makerBid, signature, SIGNATURE_INVALID_EIP1271); + + vm.expectRevert(SignatureERC1271Invalid.selector); + vm.prank(takerUser); + looksRareProtocol.executeTakerAsk(takerAsk, makerBid, signature, _EMPTY_MERKLE_TREE); + } + + function testTakerAskIsValidSignatureReentrancy() public { + MaliciousIsValidSignatureERC1271Wallet maliciousERC1271Wallet = new MaliciousIsValidSignatureERC1271Wallet( + address(looksRareProtocol) + ); + _setUpUser(address(maliciousERC1271Wallet)); + maliciousERC1271Wallet.setFunctionToReenter(MaliciousERC1271Wallet.FunctionToReenter.ExecuteTakerAsk); + + (OrderStructs.Taker memory takerAsk, OrderStructs.Maker memory makerBid) = + _takerAskSetup(address(maliciousERC1271Wallet)); + + vm.expectRevert(IReentrancyGuard.ReentrancyFail.selector); + vm.prank(takerUser); + looksRareProtocol.executeTakerAsk(takerAsk, makerBid, _EMPTY_SIGNATURE, _EMPTY_MERKLE_TREE); + } + + function testTakerAskOnERC1155ReceivedReentrancy() public { + MaliciousOnERC1155ReceivedERC1271Wallet maliciousERC1271Wallet = new MaliciousOnERC1155ReceivedERC1271Wallet( + address(looksRareProtocol) + ); + _setUpUser(address(maliciousERC1271Wallet)); + + (OrderStructs.Taker memory takerAsk, OrderStructs.Maker memory makerBid) = + _takerAskSetup(address(maliciousERC1271Wallet)); + + maliciousERC1271Wallet.setFunctionToReenter(MaliciousERC1271Wallet.FunctionToReenter.ExecuteTakerAsk); + + vm.expectRevert(ERC1155SafeTransferFromFail.selector); + vm.prank(takerUser); + looksRareProtocol.executeTakerAsk(takerAsk, makerBid, _EMPTY_SIGNATURE, _EMPTY_MERKLE_TREE); + } + + function testBatchTakerAsk() public { + ERC1271Wallet wallet = new ERC1271Wallet(makerUser); + (OrderStructs.Taker memory takerAsk, OrderStructs.Maker memory makerBid) = _batchTakerAskSetup(address(wallet)); + + bytes memory signature = _signMakerOrder(makerBid, makerUserPK); + + // Wallet needs to hold WETH and have given WETH approval + deal(address(weth), address(wallet), price); + vm.prank(address(wallet)); + weth.approve(address(looksRareProtocol), price); + + vm.prank(takerUser); + looksRareProtocol.executeTakerAsk(takerAsk, makerBid, signature, _EMPTY_MERKLE_TREE); + + for (uint256 i; i < 10; i++) { + assertEq(mockERC1155.balanceOf(address(wallet), i), 1); + } + } + + function testBatchTakerAskOnERC1155BatchReceivedReentrancy() public { + MaliciousOnERC1155ReceivedERC1271Wallet maliciousERC1271Wallet = new MaliciousOnERC1155ReceivedERC1271Wallet( + address(looksRareProtocol) + ); + _setUpUser(address(maliciousERC1271Wallet)); + + (OrderStructs.Taker memory takerAsk, OrderStructs.Maker memory makerBid) = + _batchTakerAskSetup(address(maliciousERC1271Wallet)); + + bytes memory signature = _signMakerOrder(makerBid, makerUserPK); + + // Wallet needs to hold WETH and have given WETH approval + deal(address(weth), address(maliciousERC1271Wallet), price); + vm.prank(address(maliciousERC1271Wallet)); + weth.approve(address(looksRareProtocol), price); + + maliciousERC1271Wallet.setFunctionToReenter(MaliciousERC1271Wallet.FunctionToReenter.ExecuteTakerAsk); + + vm.expectRevert(ERC1155SafeBatchTransferFromFail.selector); + vm.prank(takerUser); + looksRareProtocol.executeTakerAsk(takerAsk, makerBid, signature, _EMPTY_MERKLE_TREE); + } + + uint256 private constant numberOfPurchases = 3; + + function testExecuteMultipleTakerBids() public { + ERC1271Wallet wallet = new ERC1271Wallet(address(makerUser)); + + ( + OrderStructs.Maker[] memory makerAsks, + OrderStructs.Taker[] memory takerBids, + OrderStructs.MerkleTree[] memory merkleTrees, + bytes[] memory signatures + ) = _multipleTakerBidsSetup(address(wallet)); + + vm.startPrank(address(wallet)); + mockERC1155.setApprovalForAll(address(transferManager), true); + transferManager.grantApprovals(operators); + vm.stopPrank(); + + vm.prank(takerUser); + looksRareProtocol.executeMultipleTakerBids{value: price * numberOfPurchases}( + takerBids, makerAsks, signatures, merkleTrees, false + ); + + for (uint256 i; i < numberOfPurchases; i++) { + assertEq(mockERC1155.balanceOf(takerUser, i), 1); + } + } + + function testExecuteMultipleTakerBidsInvalidSignatures() public { + ERC1271Wallet wallet = new ERC1271Wallet(address(makerUser)); + + ( + OrderStructs.Maker[] memory makerAsks, + OrderStructs.Taker[] memory takerBids, + OrderStructs.MerkleTree[] memory merkleTrees, + bytes[] memory signatures + ) = _multipleTakerBidsSetup(address(wallet)); + + // Signed by a different private key + for (uint256 i; i < signatures.length; i++) { + signatures[i] = _signMakerOrder(makerAsks[i], takerUserPK); + } + + vm.startPrank(address(wallet)); + mockERC1155.setApprovalForAll(address(transferManager), true); + transferManager.grantApprovals(operators); + vm.stopPrank(); + + vm.expectRevert(SignatureERC1271Invalid.selector); + vm.prank(takerUser); + looksRareProtocol.executeMultipleTakerBids{value: price * numberOfPurchases}( + takerBids, makerAsks, signatures, merkleTrees, false + ); + } + + function testExecuteMultipleTakerBidsIsValidSignatureReentrancy() public { + MaliciousIsValidSignatureERC1271Wallet maliciousERC1271Wallet = new MaliciousIsValidSignatureERC1271Wallet( + address(looksRareProtocol) + ); + _setUpUser(address(maliciousERC1271Wallet)); + maliciousERC1271Wallet.setFunctionToReenter(MaliciousERC1271Wallet.FunctionToReenter.ExecuteMultipleTakerBids); + + ( + OrderStructs.Maker[] memory makerAsks, + OrderStructs.Taker[] memory takerBids, + OrderStructs.MerkleTree[] memory merkleTrees, + bytes[] memory signatures + ) = _multipleTakerBidsSetup(address(maliciousERC1271Wallet)); + + vm.expectRevert(IReentrancyGuard.ReentrancyFail.selector); + vm.prank(takerUser); + looksRareProtocol.executeMultipleTakerBids{value: price * numberOfPurchases}( + takerBids, makerAsks, signatures, merkleTrees, false + ); + + for (uint256 i; i < numberOfPurchases - 1; i++) { + assertEq(mockERC1155.balanceOf(takerUser, i), 0); + } + } + + function testExecuteMultipleTakerBidsOnERC1155ReceivedReentrancyOnlyInTheLastCall() public { + MaliciousOnERC1155ReceivedTheThirdTimeERC1271Wallet maliciousERC1271Wallet = + new MaliciousOnERC1155ReceivedTheThirdTimeERC1271Wallet( + takerUser + ); + _setUpUser(makerUser); + maliciousERC1271Wallet.setFunctionToReenter(MaliciousERC1271Wallet.FunctionToReenter.ExecuteMultipleTakerBids); + + ( + OrderStructs.Maker[] memory makerAsks, + OrderStructs.Taker[] memory takerBids, + OrderStructs.MerkleTree[] memory merkleTrees, + bytes[] memory signatures + ) = _multipleTakerBidsSetup(makerUser); + + // Set the NFT recipient as the ERC1271 wallet to trigger onERC1155Received + for (uint256 i; i < numberOfPurchases; i++) { + takerBids[i].recipient = address(maliciousERC1271Wallet); + } + + vm.prank(takerUser); + looksRareProtocol.executeMultipleTakerBids{value: price * numberOfPurchases}( + takerBids, makerAsks, signatures, merkleTrees, false + ); + + // First 2 purchases should go through, but the last one fails silently + for (uint256 i; i < numberOfPurchases - 1; i++) { + assertEq(mockERC1155.balanceOf(address(maliciousERC1271Wallet), i), 1); + } + assertEq(mockERC1155.balanceOf(address(maliciousERC1271Wallet), numberOfPurchases - 1), 0); + } + + function _takerBidSetup(address signer) + private + returns (OrderStructs.Maker memory makerAsk, OrderStructs.Taker memory takerBid) + { + // Mint asset + mockERC1155.mint(signer, itemId, 1); + + makerAsk = _createSingleItemMakerOrder({ + quoteType: QuoteType.Ask, + globalNonce: 0, + subsetNonce: 0, + strategyId: STANDARD_SALE_FOR_FIXED_PRICE_STRATEGY, + collectionType: CollectionType.ERC1155, + orderNonce: 0, + collection: address(mockERC1155), + currency: ETH, + signer: signer, + price: price, + itemId: itemId + }); + + // Prepare the taker bid + takerBid = _genericTakerOrder(); + } + + function _takerAskSetup(address signer) + private + returns (OrderStructs.Taker memory takerAsk, OrderStructs.Maker memory makerBid) + { + makerBid = _createSingleItemMakerOrder({ + quoteType: QuoteType.Bid, + globalNonce: 0, + subsetNonce: 0, + strategyId: STANDARD_SALE_FOR_FIXED_PRICE_STRATEGY, + collectionType: CollectionType.ERC1155, + orderNonce: 0, + collection: address(mockERC1155), + currency: address(weth), + signer: signer, + price: price, + itemId: itemId + }); + + // Mint asset + mockERC1155.mint(takerUser, itemId, 1); + + // Prepare the taker ask + takerAsk = _genericTakerOrder(); + } + + function _batchTakerAskSetup(address signer) + private + returns (OrderStructs.Taker memory takerAsk, OrderStructs.Maker memory makerBid) + { + uint256[] memory itemIds = new uint256[](10); + uint256[] memory amounts = new uint256[](10); + + for (uint256 i; i < 10; i++) { + itemIds[i] = i; + amounts[i] = 1; + + // Mint asset + mockERC1155.mint(takerUser, i, 1); + } + + // Prepare the first order + makerBid = _createMultiItemMakerOrder({ + quoteType: QuoteType.Bid, + globalNonce: 0, + subsetNonce: 0, + strategyId: STANDARD_SALE_FOR_FIXED_PRICE_STRATEGY, + collectionType: CollectionType.ERC1155, + orderNonce: 0, + collection: address(mockERC1155), + currency: address(weth), + signer: signer, + price: price, + itemIds: itemIds, + amounts: amounts + }); + + // Prepare the taker ask + takerAsk = _genericTakerOrder(); + } + + function _multipleTakerBidsSetup(address signer) + private + returns ( + OrderStructs.Maker[] memory makerAsks, + OrderStructs.Taker[] memory takerBids, + OrderStructs.MerkleTree[] memory merkleTrees, + bytes[] memory signatures + ) + { + makerAsks = new OrderStructs.Maker[](numberOfPurchases); + takerBids = new OrderStructs.Taker[](numberOfPurchases); + signatures = new bytes[](numberOfPurchases); + + for (uint256 i; i < numberOfPurchases; i++) { + // Mint asset + mockERC1155.mint(signer, i, 1); + + makerAsks[i] = _createSingleItemMakerOrder({ + quoteType: QuoteType.Ask, + globalNonce: 0, + subsetNonce: 0, + strategyId: STANDARD_SALE_FOR_FIXED_PRICE_STRATEGY, + collectionType: CollectionType.ERC1155, + orderNonce: i, + collection: address(mockERC1155), + currency: ETH, + signer: signer, + price: price, + itemId: i // 0, 1, etc. + }); + + signatures[i] = _signMakerOrder(makerAsks[i], makerUserPK); + + takerBids[i] = _genericTakerOrder(); + } + + // Other execution parameters + merkleTrees = new OrderStructs.MerkleTree[](numberOfPurchases); + } +} diff --git a/contracts/test/foundry/marketplace/SignaturesERC1271WalletForERC721.t.sol b/contracts/test/foundry/marketplace/SignaturesERC1271WalletForERC721.t.sol new file mode 100644 index 00000000..638c416e --- /dev/null +++ b/contracts/test/foundry/marketplace/SignaturesERC1271WalletForERC721.t.sol @@ -0,0 +1,278 @@ +// SPDX-License-Identifier: MIT +pragma solidity 0.8.17; + +// Libraries and interfaces +import {IReentrancyGuard} from "@looksrare/contracts-libs/contracts/interfaces/IReentrancyGuard.sol"; +import {OrderStructs} from "@hypercerts/marketplace/libraries/OrderStructs.sol"; + +// Base test +import {ProtocolBase} from "./ProtocolBase.t.sol"; + +// Mocks and other utils +import {ERC1271Wallet} from "./utils/ERC1271Wallet.sol"; +import {MaliciousERC1271Wallet} from "./utils/MaliciousERC1271Wallet.sol"; +import {MaliciousIsValidSignatureERC1271Wallet} from "./utils/MaliciousIsValidSignatureERC1271Wallet.sol"; + +// Errors +import {SignatureERC1271Invalid} from "@looksrare/contracts-libs/contracts/errors/SignatureCheckerErrors.sol"; +import {SIGNATURE_INVALID_EIP1271} from "@hypercerts/marketplace/constants/ValidationCodeConstants.sol"; + +// Enums +import {CollectionType} from "@hypercerts/marketplace/enums/CollectionType.sol"; +import {QuoteType} from "@hypercerts/marketplace/enums/QuoteType.sol"; + +/** + * @dev ERC1271Wallet recovers a signature's signer using ECDSA. If it matches the mock wallet's + * owner, it returns the magic value. Otherwise it returns an empty bytes4 value. + */ +contract SignaturesERC1271WalletForERC721Test is ProtocolBase { + uint256 private constant price = 1 ether; // Fixed price of sale + bytes private constant _EMPTY_SIGNATURE = new bytes(0); + + function setUp() public { + _setUp(); + _setUpUser(takerUser); + _setupRegistryRoyalties(address(mockERC721), _standardRoyaltyFee); + } + + function testTakerBid() public { + ERC1271Wallet wallet = new ERC1271Wallet(address(makerUser)); + (OrderStructs.Maker memory makerAsk, OrderStructs.Taker memory takerBid) = _takerBidSetup(address(wallet)); + + bytes memory signature = _signMakerOrder(makerAsk, makerUserPK); + + vm.startPrank(address(wallet)); + mockERC721.setApprovalForAll(address(transferManager), true); + transferManager.grantApprovals(operators); + vm.stopPrank(); + + _assertValidMakerOrder(makerAsk, signature); + + vm.prank(takerUser); + looksRareProtocol.executeTakerBid{value: price}(takerBid, makerAsk, signature, _EMPTY_MERKLE_TREE); + + assertEq(mockERC721.ownerOf(makerAsk.itemIds[0]), takerUser); + } + + function testTakerBidInvalidSignature() public { + ERC1271Wallet wallet = new ERC1271Wallet(address(makerUser)); + (OrderStructs.Maker memory makerAsk, OrderStructs.Taker memory takerBid) = _takerBidSetup(address(wallet)); + + // Signed by a different private key + bytes memory signature = _signMakerOrder(makerAsk, takerUserPK); + + vm.startPrank(address(wallet)); + mockERC721.setApprovalForAll(address(transferManager), true); + transferManager.grantApprovals(operators); + vm.stopPrank(); + + _assertMakerOrderReturnValidationCode(makerAsk, signature, SIGNATURE_INVALID_EIP1271); + + vm.expectRevert(SignatureERC1271Invalid.selector); + vm.prank(takerUser); + looksRareProtocol.executeTakerBid{value: price}(takerBid, makerAsk, signature, _EMPTY_MERKLE_TREE); + } + + function testTakerBidReentrancy() public { + MaliciousIsValidSignatureERC1271Wallet maliciousERC1271Wallet = new MaliciousIsValidSignatureERC1271Wallet( + address(looksRareProtocol) + ); + _setUpUser(address(maliciousERC1271Wallet)); + maliciousERC1271Wallet.setFunctionToReenter(MaliciousERC1271Wallet.FunctionToReenter.ExecuteTakerBid); + + (OrderStructs.Maker memory makerAsk, OrderStructs.Taker memory takerBid) = + _takerBidSetup(address(maliciousERC1271Wallet)); + + vm.expectRevert(IReentrancyGuard.ReentrancyFail.selector); + vm.prank(takerUser); + looksRareProtocol.executeTakerBid{value: price}(takerBid, makerAsk, _EMPTY_SIGNATURE, _EMPTY_MERKLE_TREE); + } + + function testTakerAsk() public { + ERC1271Wallet wallet = new ERC1271Wallet(address(makerUser)); + (OrderStructs.Taker memory takerAsk, OrderStructs.Maker memory makerBid) = _takerAskSetup(address(wallet)); + + bytes memory signature = _signMakerOrder(makerBid, makerUserPK); + + // Wallet needs to hold WETH and have given WETH approval + deal(address(weth), address(wallet), price); + vm.prank(address(wallet)); + weth.approve(address(looksRareProtocol), price); + + _assertValidMakerOrder(makerBid, signature); + + vm.prank(takerUser); + looksRareProtocol.executeTakerAsk(takerAsk, makerBid, signature, _EMPTY_MERKLE_TREE); + + assertEq(mockERC721.ownerOf(makerBid.itemIds[0]), address(wallet)); + } + + function testTakerAskInvalidSignature() public { + ERC1271Wallet wallet = new ERC1271Wallet(address(makerUser)); + (OrderStructs.Taker memory takerAsk, OrderStructs.Maker memory makerBid) = _takerAskSetup(address(wallet)); + + // Signed by a different private key + bytes memory signature = _signMakerOrder(makerBid, takerUserPK); + + // Wallet needs to hold WETH and have given WETH approval + deal(address(weth), address(wallet), price); + vm.prank(address(wallet)); + weth.approve(address(looksRareProtocol), price); + + _assertMakerOrderReturnValidationCode(makerBid, signature, SIGNATURE_INVALID_EIP1271); + + vm.expectRevert(SignatureERC1271Invalid.selector); + vm.prank(takerUser); + looksRareProtocol.executeTakerAsk(takerAsk, makerBid, signature, _EMPTY_MERKLE_TREE); + } + + function testTakerAskReentrancy() public { + MaliciousIsValidSignatureERC1271Wallet maliciousERC1271Wallet = new MaliciousIsValidSignatureERC1271Wallet( + address(looksRareProtocol) + ); + _setUpUser(address(maliciousERC1271Wallet)); + maliciousERC1271Wallet.setFunctionToReenter(MaliciousERC1271Wallet.FunctionToReenter.ExecuteTakerAsk); + + (OrderStructs.Taker memory takerAsk, OrderStructs.Maker memory makerBid) = + _takerAskSetup(address(maliciousERC1271Wallet)); + + vm.expectRevert(IReentrancyGuard.ReentrancyFail.selector); + vm.prank(takerUser); + looksRareProtocol.executeTakerAsk(takerAsk, makerBid, _EMPTY_SIGNATURE, _EMPTY_MERKLE_TREE); + } + + uint256 private constant numberPurchases = 3; + + function testExecuteMultipleTakerBids() public { + ERC1271Wallet wallet = new ERC1271Wallet(address(makerUser)); + + ( + OrderStructs.Maker[] memory makerAsks, + OrderStructs.Taker[] memory takerBids, + OrderStructs.MerkleTree[] memory merkleTrees, + bytes[] memory signatures + ) = _multipleTakerBidsSetup(address(wallet)); + + vm.startPrank(address(wallet)); + mockERC721.setApprovalForAll(address(transferManager), true); + transferManager.grantApprovals(operators); + vm.stopPrank(); + + vm.prank(takerUser); + looksRareProtocol.executeMultipleTakerBids{value: price * numberPurchases}( + takerBids, makerAsks, signatures, merkleTrees, false + ); + + for (uint256 i; i < numberPurchases; i++) { + assertEq(mockERC721.ownerOf(i), takerUser); + } + } + + function testExecuteMultipleTakerBidsInvalidSignatures() public { + ERC1271Wallet wallet = new ERC1271Wallet(address(makerUser)); + + ( + OrderStructs.Maker[] memory makerAsks, + OrderStructs.Taker[] memory takerBids, + OrderStructs.MerkleTree[] memory merkleTrees, + bytes[] memory signatures + ) = _multipleTakerBidsSetup(address(wallet)); + + // Signed by a different private key + for (uint256 i; i < signatures.length; i++) { + signatures[i] = _signMakerOrder(makerAsks[i], takerUserPK); + } + + vm.startPrank(address(wallet)); + mockERC721.setApprovalForAll(address(transferManager), true); + transferManager.grantApprovals(operators); + vm.stopPrank(); + + vm.expectRevert(SignatureERC1271Invalid.selector); + vm.prank(takerUser); + looksRareProtocol.executeMultipleTakerBids{value: price * numberPurchases}( + takerBids, makerAsks, signatures, merkleTrees, false + ); + } + + function testExecuteMultipleTakerBidsReentrancy() public { + MaliciousIsValidSignatureERC1271Wallet maliciousERC1271Wallet = new MaliciousIsValidSignatureERC1271Wallet( + address(looksRareProtocol) + ); + _setUpUser(address(maliciousERC1271Wallet)); + maliciousERC1271Wallet.setFunctionToReenter(MaliciousERC1271Wallet.FunctionToReenter.ExecuteMultipleTakerBids); + + ( + OrderStructs.Maker[] memory makerAsks, + OrderStructs.Taker[] memory takerBids, + OrderStructs.MerkleTree[] memory merkleTrees, + bytes[] memory signatures + ) = _multipleTakerBidsSetup(address(maliciousERC1271Wallet)); + + vm.expectRevert(IReentrancyGuard.ReentrancyFail.selector); + vm.prank(takerUser); + looksRareProtocol.executeMultipleTakerBids{value: price * numberPurchases}( + takerBids, makerAsks, signatures, merkleTrees, false + ); + } + + function _takerBidSetup(address signer) + private + returns (OrderStructs.Maker memory makerAsk, OrderStructs.Taker memory takerBid) + { + (makerAsk, takerBid) = _createMockMakerAskAndTakerBid(address(mockERC721)); + makerAsk.signer = signer; + // Mint asset + mockERC721.mint(signer, makerAsk.itemIds[0]); + } + + function _takerAskSetup(address signer) + private + returns (OrderStructs.Taker memory takerAsk, OrderStructs.Maker memory makerBid) + { + (makerBid, takerAsk) = _createMockMakerBidAndTakerAsk(address(mockERC721), address(weth)); + makerBid.signer = signer; + // Mint asset + mockERC721.mint(takerUser, makerBid.itemIds[0]); + } + + function _multipleTakerBidsSetup(address signer) + private + returns ( + OrderStructs.Maker[] memory makerAsks, + OrderStructs.Taker[] memory takerBids, + OrderStructs.MerkleTree[] memory merkleTrees, + bytes[] memory signatures + ) + { + makerAsks = new OrderStructs.Maker[](numberPurchases); + takerBids = new OrderStructs.Taker[](numberPurchases); + signatures = new bytes[](numberPurchases); + + for (uint256 i; i < numberPurchases; i++) { + // Mint asset + mockERC721.mint(signer, i); + + makerAsks[i] = _createSingleItemMakerOrder({ + quoteType: QuoteType.Ask, + globalNonce: 0, + subsetNonce: 0, + strategyId: STANDARD_SALE_FOR_FIXED_PRICE_STRATEGY, + collectionType: CollectionType.ERC721, + orderNonce: i, + collection: address(mockERC721), + currency: ETH, + signer: signer, + price: price, + itemId: i // 0, 1, etc. + }); + + signatures[i] = _signMakerOrder(makerAsks[i], makerUserPK); + + takerBids[i] = _genericTakerOrder(); + } + + // Other execution parameters + merkleTrees = new OrderStructs.MerkleTree[](numberPurchases); + } +} diff --git a/contracts/test/foundry/marketplace/SignaturesRevertions.t.sol b/contracts/test/foundry/marketplace/SignaturesRevertions.t.sol new file mode 100644 index 00000000..c5f1ef18 --- /dev/null +++ b/contracts/test/foundry/marketplace/SignaturesRevertions.t.sol @@ -0,0 +1,173 @@ +// SPDX-License-Identifier: MIT +pragma solidity 0.8.17; + +// Libraries, interfaces, errors +import { + SignatureParameterVInvalid, + SignatureParameterSInvalid, + SignatureEOAInvalid, + NullSignerAddress, + SignatureLengthInvalid +} from "@looksrare/contracts-libs/contracts/errors/SignatureCheckerErrors.sol"; +import {OrderStructs} from "@hypercerts/marketplace/libraries/OrderStructs.sol"; + +// Base test +import {ProtocolBase} from "./ProtocolBase.t.sol"; + +// Constants +import {ONE_HUNDRED_PERCENT_IN_BP} from "@hypercerts/marketplace/constants/NumericConstants.sol"; +import { + INVALID_S_PARAMETER_EOA, + INVALID_V_PARAMETER_EOA, + NULL_SIGNER_EOA, + INVALID_SIGNATURE_LENGTH, + INVALID_SIGNER_EOA +} from "@hypercerts/marketplace/constants/ValidationCodeConstants.sol"; + +// Enums +import {CollectionType} from "@hypercerts/marketplace/enums/CollectionType.sol"; +import {QuoteType} from "@hypercerts/marketplace/enums/QuoteType.sol"; + +contract SignaturesRevertionsTest is ProtocolBase { + uint256 internal constant _MAX_PRIVATE_KEY = + 115_792_089_237_316_195_423_570_985_008_687_907_852_837_564_279_074_904_382_605_163_141_518_161_494_337; + + function setUp() public { + _setUp(); + } + + function testRevertIfSignatureEOAInvalid(uint256 itemId, uint256 price, uint256 randomPK) public { + // @dev Private keys 1 and 2 are used for maker/taker users + vm.assume(randomPK > 2 && randomPK < _MAX_PRIVATE_KEY); + + OrderStructs.Maker memory makerAsk = _createSingleItemMakerOrder({ + quoteType: QuoteType.Ask, + globalNonce: 0, + subsetNonce: 0, + strategyId: STANDARD_SALE_FOR_FIXED_PRICE_STRATEGY, + collectionType: CollectionType.ERC721, + orderNonce: 0, + collection: address(mockERC721), + currency: ETH, + signer: makerUser, + price: price, + itemId: itemId + }); + + address randomUser = vm.addr(randomPK); + _setUpUser(randomUser); + bytes memory signature = _signMakerOrder(makerAsk, randomPK); + _assertMakerOrderReturnValidationCode(makerAsk, signature, INVALID_SIGNER_EOA); + + vm.expectRevert(SignatureEOAInvalid.selector); + vm.prank(takerUser); + looksRareProtocol.executeTakerBid(_genericTakerOrder(), makerAsk, signature, _EMPTY_MERKLE_TREE); + } + + function testRevertIfInvalidVParameter(uint256 itemId, uint256 price, uint8 v) public { + vm.assume(v != 27 && v != 28); + + OrderStructs.Maker memory makerAsk = _createSingleItemMakerOrder({ + quoteType: QuoteType.Ask, + globalNonce: 0, + subsetNonce: 0, + strategyId: STANDARD_SALE_FOR_FIXED_PRICE_STRATEGY, + collectionType: CollectionType.ERC721, + orderNonce: 0, + collection: address(mockERC721), + currency: ETH, + signer: makerUser, + price: price, + itemId: itemId + }); + + // Sign but replace v by the fuzzed v + bytes32 orderHash = _computeOrderHash(makerAsk); + (, bytes32 r, bytes32 s) = + vm.sign(makerUserPK, keccak256(abi.encodePacked("\x19\x01", _domainSeparator, orderHash))); + bytes memory signature = abi.encodePacked(r, s, v); + + _assertMakerOrderReturnValidationCode(makerAsk, signature, INVALID_V_PARAMETER_EOA); + + vm.expectRevert(abi.encodeWithSelector(SignatureParameterVInvalid.selector, v)); + vm.prank(takerUser); + looksRareProtocol.executeTakerBid(_genericTakerOrder(), makerAsk, signature, _EMPTY_MERKLE_TREE); + } + + function testRevertIfInvalidSParameter(uint256 itemId, uint256 price, bytes32 s) public { + vm.assume(uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0); + + OrderStructs.Maker memory makerAsk = _createSingleItemMakerOrder({ + quoteType: QuoteType.Ask, + globalNonce: 0, + subsetNonce: 0, + strategyId: STANDARD_SALE_FOR_FIXED_PRICE_STRATEGY, + collectionType: CollectionType.ERC721, + orderNonce: 0, + collection: address(mockERC721), + currency: ETH, + signer: makerUser, + price: price, + itemId: itemId + }); + + // Sign but replace s by the fuzzed s + bytes32 orderHash = _computeOrderHash(makerAsk); + (uint8 v, bytes32 r,) = + vm.sign(makerUserPK, keccak256(abi.encodePacked("\x19\x01", _domainSeparator, orderHash))); + bytes memory signature = abi.encodePacked(r, s, v); + + _assertMakerOrderReturnValidationCode(makerAsk, signature, INVALID_S_PARAMETER_EOA); + + vm.expectRevert(abi.encodeWithSelector(SignatureParameterSInvalid.selector)); + vm.prank(takerUser); + looksRareProtocol.executeTakerBid(_genericTakerOrder(), makerAsk, signature, _EMPTY_MERKLE_TREE); + } + + function testRevertIfRecoveredSignerIsNullAddress(uint256 itemId, uint256 price) public { + OrderStructs.Maker memory makerAsk = _createSingleItemMakerOrder({ + quoteType: QuoteType.Ask, + globalNonce: 0, + subsetNonce: 0, + strategyId: STANDARD_SALE_FOR_FIXED_PRICE_STRATEGY, + collectionType: CollectionType.ERC721, + orderNonce: 0, + collection: address(mockERC721), + currency: ETH, + signer: makerUser, + price: price, + itemId: itemId + }); + + // Sign but replace r by empty bytes32 + bytes32 orderHash = _computeOrderHash(makerAsk); + (uint8 v,, bytes32 s) = + vm.sign(makerUserPK, keccak256(abi.encodePacked("\x19\x01", _domainSeparator, orderHash))); + + bytes32 r; + bytes memory signature = abi.encodePacked(r, s, v); + + _assertMakerOrderReturnValidationCode(makerAsk, signature, NULL_SIGNER_EOA); + + vm.expectRevert(abi.encodeWithSelector(NullSignerAddress.selector)); + vm.prank(takerUser); + looksRareProtocol.executeTakerBid(_genericTakerOrder(), makerAsk, signature, _EMPTY_MERKLE_TREE); + } + + function testRevertIfInvalidSignatureLength(uint256 itemId, uint256 price, uint256 length) public { + // @dev Getting OutOfGas starting from 16,776,985, probably due to memory cost + vm.assume(length != 64 && length != 65 && length < 16_776_985); + + (OrderStructs.Maker memory makerAsk, OrderStructs.Taker memory takerBid) = + _createMockMakerAskAndTakerBid(address(mockERC721)); + makerAsk.itemIds[0] = itemId; + makerAsk.price = price; + + bytes memory signature = new bytes(length); + _assertMakerOrderReturnValidationCode(makerAsk, signature, INVALID_SIGNATURE_LENGTH); + + vm.expectRevert(abi.encodeWithSelector(SignatureLengthInvalid.selector, length)); + vm.prank(takerUser); + looksRareProtocol.executeTakerBid(takerBid, makerAsk, signature, _EMPTY_MERKLE_TREE); + } +} diff --git a/contracts/test/foundry/marketplace/StandardTransactions.t.sol b/contracts/test/foundry/marketplace/StandardTransactions.t.sol new file mode 100644 index 00000000..6d5d8b38 --- /dev/null +++ b/contracts/test/foundry/marketplace/StandardTransactions.t.sol @@ -0,0 +1,508 @@ +// SPDX-License-Identifier: MIT +pragma solidity 0.8.17; + +// Libraries, interfaces, errors +import {OrderStructs} from "@hypercerts/marketplace/libraries/OrderStructs.sol"; +import {LengthsInvalid} from "@hypercerts/marketplace/errors/SharedErrors.sol"; + +import {CreatorFeeManagerWithRoyalties} from "@hypercerts/marketplace/CreatorFeeManagerWithRoyalties.sol"; + +// Base test +import {ProtocolBase} from "./ProtocolBase.t.sol"; + +// Constants +import {ONE_HUNDRED_PERCENT_IN_BP} from "@hypercerts/marketplace/constants/NumericConstants.sol"; + +// Enums +import {CollectionType} from "@hypercerts/marketplace/enums/CollectionType.sol"; +import {QuoteType} from "@hypercerts/marketplace/enums/QuoteType.sol"; + +contract StandardTransactionsTest is ProtocolBase { + error ERC721TransferFromFail(); + + uint256 private constant itemId = 420; + uint16 private constant NEW_ROYALTY_FEE = uint16(50); + + function setUp() public { + _setUp(); + CreatorFeeManagerWithRoyalties creatorFeeManager = new CreatorFeeManagerWithRoyalties( + address(royaltyFeeRegistry) + ); + vm.prank(_owner); + looksRareProtocol.updateCreatorFeeManager(address(creatorFeeManager)); + } + + /** + * One ERC721 (where royalties come from the registry) is sold through a taker bid + */ + function testTakerBidERC721WithRoyaltiesFromRegistry(uint256 price) public { + vm.assume(price <= 2 ether); + _setUpUsers(); + _setupRegistryRoyalties(address(mockERC721), NEW_ROYALTY_FEE); + + (OrderStructs.Maker memory makerAsk, OrderStructs.Taker memory takerBid) = + _createMockMakerAskAndTakerBid(address(mockERC721)); + makerAsk.price = price; + + bytes memory signature = _signMakerOrder(makerAsk, makerUserPK); + + // Mint asset + mockERC721.mint(makerUser, makerAsk.itemIds[0]); + + // Verify validity of maker ask order + _assertValidMakerOrder(makerAsk, signature); + + // Arrays for events + uint256[3] memory expectedFees = _calculateExpectedFees({price: price, royaltyFeeBp: NEW_ROYALTY_FEE}); + address[2] memory expectedRecipients; + + expectedRecipients[0] = makerUser; + expectedRecipients[1] = _royaltyRecipient; + + // Execute taker bid transaction + vm.prank(takerUser); + vm.expectEmit(true, false, false, true); + + emit TakerBid( + NonceInvalidationParameters({ + orderHash: _computeOrderHash(makerAsk), + orderNonce: makerAsk.orderNonce, + isNonceInvalidated: true + }), + takerUser, + takerUser, + makerAsk.strategyId, + makerAsk.currency, + makerAsk.collection, + makerAsk.itemIds, + makerAsk.amounts, + expectedRecipients, + expectedFees + ); + + looksRareProtocol.executeTakerBid{value: price}(takerBid, makerAsk, signature, _EMPTY_MERKLE_TREE); + + _assertSuccessfulExecutionThroughETH(takerUser, makerUser, price, expectedFees); + + // No leftover in the balance of the contract + assertEq(address(looksRareProtocol).balance, 0); + // Verify the nonce is marked as executed + assertEq(looksRareProtocol.userOrderNonce(makerUser, makerAsk.orderNonce), MAGIC_VALUE_ORDER_NONCE_EXECUTED); + } + + /** + * One ERC721 is sold through taker bid. Address zero is specified as the recipient in the taker struct. + */ + function testTakerBidERC721WithAddressZeroSpecifiedAsRecipient(uint256 price) public { + vm.assume(price <= 2 ether); + _setUpUsers(); + + (OrderStructs.Maker memory makerAsk, OrderStructs.Taker memory takerBid) = + _createMockMakerAskAndTakerBid(address(mockERC721)); + makerAsk.price = price; + + bytes memory signature = _signMakerOrder(makerAsk, makerUserPK); + + // Mint asset + mockERC721.mint(makerUser, makerAsk.itemIds[0]); + + // Adjustment + takerBid.recipient = address(0); + + // Verify validity of maker ask order + _assertValidMakerOrder(makerAsk, signature); + + // Arrays for events + uint256[3] memory expectedFees = _calculateExpectedFees({price: price, royaltyFeeBp: 0}); + address[2] memory expectedRecipients; + + expectedRecipients[0] = makerUser; + expectedRecipients[1] = address(0); // No royalties + + // Execute taker bid transaction + vm.prank(takerUser); + vm.expectEmit(true, false, false, true); + + emit TakerBid( + NonceInvalidationParameters({ + orderHash: _computeOrderHash(makerAsk), + orderNonce: makerAsk.orderNonce, + isNonceInvalidated: true + }), + takerUser, + takerUser, + makerAsk.strategyId, + makerAsk.currency, + makerAsk.collection, + makerAsk.itemIds, + makerAsk.amounts, + expectedRecipients, + expectedFees + ); + + looksRareProtocol.executeTakerBid{value: price}(takerBid, makerAsk, signature, _EMPTY_MERKLE_TREE); + + _assertSuccessfulExecutionThroughETH(takerUser, makerUser, price, expectedFees); + } + + /** + * One ERC721 (where royalties come from the registry) is sold through a taker ask using WETH + */ + function testTakerAskERC721WithRoyaltiesFromRegistry(uint256 price) public { + vm.assume(price <= 2 ether); + + _setUpUsers(); + _setupRegistryRoyalties(address(mockERC721), NEW_ROYALTY_FEE); + + (OrderStructs.Maker memory makerBid, OrderStructs.Taker memory takerAsk) = + _createMockMakerBidAndTakerAsk(address(mockERC721), address(weth)); + makerBid.price = price; + + bytes memory signature = _signMakerOrder(makerBid, makerUserPK); + + // Verify maker bid order + _assertValidMakerOrder(makerBid, signature); + + // Mint asset + mockERC721.mint(takerUser, makerBid.itemIds[0]); + + // Arrays for events + uint256[3] memory expectedFees = _calculateExpectedFees({price: price, royaltyFeeBp: NEW_ROYALTY_FEE}); + address[2] memory expectedRecipients; + + expectedRecipients[0] = takerUser; + expectedRecipients[1] = _royaltyRecipient; + + // Execute taker ask transaction + vm.prank(takerUser); + + vm.expectEmit(true, false, false, true); + + emit TakerAsk( + NonceInvalidationParameters({ + orderHash: _computeOrderHash(makerBid), + orderNonce: makerBid.orderNonce, + isNonceInvalidated: true + }), + takerUser, + makerUser, + makerBid.strategyId, + makerBid.currency, + makerBid.collection, + makerBid.itemIds, + makerBid.amounts, + expectedRecipients, + expectedFees + ); + + looksRareProtocol.executeTakerAsk(takerAsk, makerBid, signature, _EMPTY_MERKLE_TREE); + + _assertSuccessfulExecutionThroughWETH(makerUser, takerUser, price, expectedFees); + // Verify the nonce is marked as executed + assertEq(looksRareProtocol.userOrderNonce(makerUser, makerBid.orderNonce), MAGIC_VALUE_ORDER_NONCE_EXECUTED); + } + + /** + * One ERC721 is sold through a taker ask using WETH. Address zero is specified as the recipient in the taker + * struct. + */ + function testTakerAskERC721WithAddressZeroSpecifiedAsRecipient(uint256 price) public { + vm.assume(price <= 2 ether); + _setUpUsers(); + + (OrderStructs.Maker memory makerBid, OrderStructs.Taker memory takerAsk) = + _createMockMakerBidAndTakerAsk(address(mockERC721), address(weth)); + makerBid.price = price; + + bytes memory signature = _signMakerOrder(makerBid, makerUserPK); + + // Verify maker bid order + _assertValidMakerOrder(makerBid, signature); + + // Adjustment + takerAsk.recipient = address(0); + + // Mint asset + mockERC721.mint(takerUser, makerBid.itemIds[0]); + + // Arrays for events + uint256[3] memory expectedFees = _calculateExpectedFees({price: price, royaltyFeeBp: 0}); + address[2] memory expectedRecipients; + + expectedRecipients[0] = takerUser; + expectedRecipients[1] = address(0); // No royalties + + // Execute taker ask transaction + vm.prank(takerUser); + vm.expectEmit(true, false, false, true); + + emit TakerAsk( + NonceInvalidationParameters({ + orderHash: _computeOrderHash(makerBid), + orderNonce: makerBid.orderNonce, + isNonceInvalidated: true + }), + takerUser, + makerUser, + makerBid.strategyId, + makerBid.currency, + makerBid.collection, + makerBid.itemIds, + makerBid.amounts, + expectedRecipients, + expectedFees + ); + + looksRareProtocol.executeTakerAsk(takerAsk, makerBid, signature, _EMPTY_MERKLE_TREE); + + _assertSuccessfulExecutionThroughWETH(makerUser, takerUser, price, expectedFees); + } + + /** + * Three ERC721 are sold through 3 taker bids in one transaction with non-atomicity. + */ + function testThreeTakerBidsERC721() public { + uint256 price = 0.015 ether; + _setUpUsers(); + + uint256 numberPurchases = 3; + + OrderStructs.Maker[] memory makerAsks = new OrderStructs.Maker[](numberPurchases); + OrderStructs.Taker[] memory takerBids = new OrderStructs.Taker[](numberPurchases); + bytes[] memory signatures = new bytes[](numberPurchases); + + for (uint256 i; i < numberPurchases; i++) { + // Mint asset + mockERC721.mint(makerUser, i); + + makerAsks[i] = _createSingleItemMakerOrder({ + quoteType: QuoteType.Ask, + globalNonce: 0, + subsetNonce: 0, + strategyId: STANDARD_SALE_FOR_FIXED_PRICE_STRATEGY, + collectionType: CollectionType.ERC721, + orderNonce: i, + collection: address(mockERC721), + currency: ETH, + signer: makerUser, + price: price, // Fixed + itemId: i // (0, 1, etc.) + }); + + // Sign order + signatures[i] = _signMakerOrder(makerAsks[i], makerUserPK); + + takerBids[i] = _genericTakerOrder(); + } + + // Other execution parameters + OrderStructs.MerkleTree[] memory merkleTrees = new OrderStructs.MerkleTree[](numberPurchases); + + // Execute taker bid transaction + vm.prank(takerUser); + looksRareProtocol.executeMultipleTakerBids{value: price * numberPurchases}( + takerBids, makerAsks, signatures, merkleTrees, false + ); + + for (uint256 i; i < numberPurchases; i++) { + // Taker user has received the asset + assertEq(mockERC721.ownerOf(i), takerUser); + // Verify the nonce is marked as executed + assertEq(looksRareProtocol.userOrderNonce(makerUser, i), MAGIC_VALUE_ORDER_NONCE_EXECUTED); + } + + // Taker bid user pays the whole price + assertEq(address(takerUser).balance, _initialETHBalanceUser - (numberPurchases * price)); + // Maker ask user receives 99.5% of the whole price (0.5% protocol) + assertEq( + address(makerUser).balance, + _initialETHBalanceUser + + ((price * _sellerProceedBpWithStandardProtocolFeeBp) * numberPurchases) / ONE_HUNDRED_PERCENT_IN_BP + ); + // No leftover in the balance of the contract + assertEq(address(looksRareProtocol).balance, 0); + } + + /** + * Transaction cannot go through if atomic, goes through if non-atomic (fund returns to buyer). + */ + function testThreeTakerBidsERC721OneFails() public { + _setUpUsers(); + + uint256 numberPurchases = 3; + uint256 faultyTokenId = numberPurchases - 1; + + OrderStructs.Maker[] memory makerAsks = new OrderStructs.Maker[](numberPurchases); + OrderStructs.Taker[] memory takerBids = new OrderStructs.Taker[](numberPurchases); + bytes[] memory signatures = new bytes[](numberPurchases); + + for (uint256 i; i < numberPurchases; i++) { + // Mint asset + mockERC721.mint(makerUser, i); + + makerAsks[i] = _createSingleItemMakerOrder({ + quoteType: QuoteType.Ask, + globalNonce: 0, + subsetNonce: 0, + strategyId: STANDARD_SALE_FOR_FIXED_PRICE_STRATEGY, + collectionType: CollectionType.ERC721, + orderNonce: i, + collection: address(mockERC721), + currency: ETH, + signer: makerUser, + price: 1.4 ether, // Fixed + itemId: i // (0, 1, etc.) + }); + + // Sign order + signatures[i] = _signMakerOrder(makerAsks[i], makerUserPK); + + takerBids[i] = _genericTakerOrder(); + } + + // Transfer tokenId = 2 to random user + address randomUser = address(55); + vm.prank(makerUser); + mockERC721.transferFrom(makerUser, randomUser, faultyTokenId); + + /** + * 1. The whole purchase fails if execution is atomic + */ + { + // Other execution parameters + OrderStructs.MerkleTree[] memory merkleTrees = new OrderStructs.MerkleTree[](numberPurchases); + + vm.expectRevert(abi.encodeWithSelector(ERC721TransferFromFail.selector)); + vm.prank(takerUser); + looksRareProtocol.executeMultipleTakerBids{value: 1.4 ether * numberPurchases}( + takerBids, makerAsks, signatures, merkleTrees, true + ); + } + + /** + * 2. The whole purchase doesn't fail if execution is not-atomic + */ + { + // Other execution parameters + OrderStructs.MerkleTree[] memory merkleTrees = new OrderStructs.MerkleTree[](numberPurchases); + + vm.prank(takerUser); + // Execute taker bid transaction + looksRareProtocol.executeMultipleTakerBids{value: 1.4 ether * numberPurchases}( + takerBids, makerAsks, signatures, merkleTrees, false + ); + } + + for (uint256 i; i < faultyTokenId; i++) { + // Taker user has received the first two assets + assertEq(mockERC721.ownerOf(i), takerUser); + // Verify the first two nonces are marked as executed + assertEq(looksRareProtocol.userOrderNonce(makerUser, i), MAGIC_VALUE_ORDER_NONCE_EXECUTED); + } + + // Taker user has not received the asset + assertEq(mockERC721.ownerOf(faultyTokenId), randomUser); + // Verify the nonce is NOT marked as executed + assertEq(looksRareProtocol.userOrderNonce(makerUser, faultyTokenId), bytes32(0)); + // Taker bid user pays the whole price + assertEq(address(takerUser).balance, _initialETHBalanceUser - 1 - ((numberPurchases - 1) * 1.4 ether)); + // Maker ask user receives 99.5% of the whole price (0.5% protocol) + assertEq( + address(makerUser).balance, + _initialETHBalanceUser + + ((1.4 ether * _sellerProceedBpWithStandardProtocolFeeBp) * (numberPurchases - 1)) + / ONE_HUNDRED_PERCENT_IN_BP + ); + // 1 wei left in the balance of the contract + assertEq(address(looksRareProtocol).balance, 1); + } + + function testThreeTakerBidsERC721LengthsInvalid() public { + _setUpUsers(); + + uint256 price = 1.12121111111 ether; + uint256 numberPurchases = 3; + + OrderStructs.Taker[] memory takerBids = new OrderStructs.Taker[](numberPurchases); + bytes[] memory signatures = new bytes[](numberPurchases); + OrderStructs.MerkleTree[] memory merkleTrees = new OrderStructs.MerkleTree[](numberPurchases); + + // 1. Invalid maker asks length + OrderStructs.Maker[] memory makerAsks = new OrderStructs.Maker[](numberPurchases - 1); + + vm.expectRevert(LengthsInvalid.selector); + vm.prank(takerUser); + looksRareProtocol.executeMultipleTakerBids{value: price * numberPurchases}( + takerBids, makerAsks, signatures, merkleTrees, false + ); + + // 2. Invalid signatures length + makerAsks = new OrderStructs.Maker[](numberPurchases); + signatures = new bytes[](numberPurchases - 1); + + vm.expectRevert(LengthsInvalid.selector); + vm.prank(takerUser); + looksRareProtocol.executeMultipleTakerBids{value: price * numberPurchases}( + takerBids, makerAsks, signatures, merkleTrees, false + ); + + // 3. Invalid merkle trees length + signatures = new bytes[](numberPurchases); + merkleTrees = new OrderStructs.MerkleTree[](numberPurchases - 1); + + vm.expectRevert(LengthsInvalid.selector); + vm.prank(takerUser); + looksRareProtocol.executeMultipleTakerBids{value: price * numberPurchases}( + takerBids, makerAsks, signatures, merkleTrees, false + ); + } + + function _calculateExpectedFees(uint256 price, uint256 royaltyFeeBp) + private + pure + returns (uint256[3] memory expectedFees) + { + expectedFees[2] = (price * _standardProtocolFeeBp) / ONE_HUNDRED_PERCENT_IN_BP; + expectedFees[1] = (price * royaltyFeeBp) / ONE_HUNDRED_PERCENT_IN_BP; + if (expectedFees[2] + expectedFees[1] < ((price * _minTotalFeeBp) / ONE_HUNDRED_PERCENT_IN_BP)) { + expectedFees[2] = ((price * _minTotalFeeBp) / ONE_HUNDRED_PERCENT_IN_BP) - expectedFees[1]; + } + expectedFees[0] = price - (expectedFees[1] + expectedFees[2]); + } + + function _assertSuccessfulExecutionThroughWETH( + address buyer, + address seller, + uint256 price, + uint256[3] memory expectedFees + ) private { + // Buyer has received the asset + assertEq(mockERC721.ownerOf(itemId), buyer); + // Buyer pays the whole price + assertEq(weth.balanceOf(buyer), _initialWETHBalanceUser - price); + // Seller receives 99.5% of the whole price + assertEq(weth.balanceOf(seller), _initialWETHBalanceUser + expectedFees[0]); + assertEq( + weth.balanceOf(address(protocolFeeRecipient)), + expectedFees[2], + "ProtocolFeeRecipient should receive 1.5% of the whole price" + ); + // Royalty recipient receives 0.5% of the whole price + assertEq(weth.balanceOf(_royaltyRecipient), _initialWETHBalanceRoyaltyRecipient + expectedFees[1]); + } + + function _assertSuccessfulExecutionThroughETH( + address buyer, + address seller, + uint256 price, + uint256[3] memory expectedFees + ) private { + assertEq(mockERC721.ownerOf(itemId), buyer); + // Buyer pays the whole price + assertEq(address(buyer).balance, _initialETHBalanceUser - price); + // Seller receives 99.5% of the whole price + assertEq(address(seller).balance, _initialETHBalanceUser + expectedFees[0]); + // Royalty recipient receives 0.5% of the whole price + assertEq(address(_royaltyRecipient).balance, _initialETHBalanceRoyaltyRecipient + expectedFees[1]); + } +} diff --git a/contracts/test/foundry/marketplace/StrategyManager.t.sol b/contracts/test/foundry/marketplace/StrategyManager.t.sol new file mode 100644 index 00000000..e59128f2 --- /dev/null +++ b/contracts/test/foundry/marketplace/StrategyManager.t.sol @@ -0,0 +1,213 @@ +// SPDX-License-Identifier: MIT +pragma solidity 0.8.17; + +// LooksRare unopinionated libraries +import {IOwnableTwoSteps} from "@looksrare/contracts-libs/contracts/interfaces/IOwnableTwoSteps.sol"; + +// Libraries +import {OrderStructs} from "@hypercerts/marketplace/libraries/OrderStructs.sol"; + +// Interfaces +import {IStrategyManager} from "@hypercerts/marketplace/interfaces/IStrategyManager.sol"; +import {IStrategy} from "@hypercerts/marketplace/interfaces/IStrategy.sol"; + +// Random strategy +import {StrategyCollectionOffer} from "@hypercerts/marketplace/executionStrategies/StrategyCollectionOffer.sol"; + +// Base test +import {ProtocolBase} from "./ProtocolBase.t.sol"; + +contract FalseBaseStrategy is IStrategy { + /** + * @inheritdoc IStrategy + */ + function isMakerOrderValid(OrderStructs.Maker calldata, bytes4) + external + view + override + returns (bool isValid, bytes4 errorSelector) + { + // + } + + /** + * @inheritdoc IStrategy + */ + function isLooksRareV2Strategy() external pure override returns (bool) { + return false; + } +} + +contract StrategyManagerTest is ProtocolBase, IStrategyManager { + function setUp() public { + _setUp(); + } + + /** + * Owner can discontinue strategy + */ + function testOwnerCanDiscontinueStrategy() public asPrankedUser(_owner) { + uint256 strategyId = 0; + uint16 standardProtocolFeeBp = 100; + uint16 minTotalFeeBp = 200; + bool isActive = false; + + vm.expectEmit(false, false, false, true); + emit StrategyUpdated(strategyId, isActive, standardProtocolFeeBp, minTotalFeeBp); + looksRareProtocol.updateStrategy(strategyId, isActive, standardProtocolFeeBp, minTotalFeeBp); + + ( + bool strategyIsActive, + uint16 strategyStandardProtocolFee, + uint16 strategyMinTotalFee, + uint16 strategyMaxProtocolFee, + bytes4 strategySelector, + bool strategyIsMakerBid, + address strategyImplementation + ) = looksRareProtocol.strategyInfo(strategyId); + + assertFalse(strategyIsActive); + assertEq(strategyStandardProtocolFee, standardProtocolFeeBp); + assertEq(strategyMinTotalFee, minTotalFeeBp); + assertEq(strategyMaxProtocolFee, _maxProtocolFeeBp); + assertEq(strategySelector, _EMPTY_BYTES4); + assertFalse(strategyIsMakerBid); + assertEq(strategyImplementation, address(0)); + } + + function testNewStrategyEventIsEmitted() public asPrankedUser(_owner) { + StrategyCollectionOffer strategy = new StrategyCollectionOffer(); + + uint256 strategyId = 1; + bytes4 selector = StrategyCollectionOffer.executeCollectionStrategyWithTakerAsk.selector; + bool isMakerBid = true; + address implementation = address(strategy); + + vm.expectEmit(true, false, false, true); + emit NewStrategy( + strategyId, _standardProtocolFeeBp, _minTotalFeeBp, _maxProtocolFeeBp, selector, isMakerBid, implementation + ); + + _addStrategy(implementation, selector, isMakerBid); + } + + /** + * Owner can change protocol fee information + */ + function testOwnerCanChangeStrategyProtocolFees() public asPrankedUser(_owner) { + uint256 strategyId = 0; + uint16 newStandardProtocolFeeBp = 100; + uint16 newMinTotalFeeBp = 200; + bool isActive = true; + + vm.expectEmit(false, false, false, true); + emit StrategyUpdated(strategyId, isActive, newStandardProtocolFeeBp, newMinTotalFeeBp); + looksRareProtocol.updateStrategy(strategyId, isActive, newStandardProtocolFeeBp, newMinTotalFeeBp); + + ( + bool strategyIsActive, + uint16 strategyStandardProtocolFee, + uint16 strategyMinTotalFee, + uint16 strategyMaxProtocolFee, + bytes4 strategySelector, + bool strategyIsMakerBid, + address strategyImplementation + ) = looksRareProtocol.strategyInfo(strategyId); + + assertTrue(strategyIsActive); + assertEq(strategyStandardProtocolFee, newStandardProtocolFeeBp); + assertEq(strategyMinTotalFee, newMinTotalFeeBp); + assertEq(strategyMaxProtocolFee, _maxProtocolFeeBp); + assertEq(strategySelector, _EMPTY_BYTES4); + assertFalse(strategyIsMakerBid); + assertEq(strategyImplementation, address(0)); + } + + /** + * Owner functions for strategy updates revert as expected under multiple revertion scenarios + */ + function testOwnerRevertionsForInvalidParametersUpdateStrategy() public asPrankedUser(_owner) { + (, uint16 currentStandardProtocolFee, uint16 currentMinTotalFee, uint16 maxProtocolFeeBp,,,) = + looksRareProtocol.strategyInfo(0); + + // 1. newStandardProtocolFee is higher than maxProtocolFeeBp + uint16 newStandardProtocolFee = maxProtocolFeeBp + 1; + uint16 newMinTotalFee = currentMinTotalFee; + vm.expectRevert(StrategyProtocolFeeTooHigh.selector); + looksRareProtocol.updateStrategy(0, true, newStandardProtocolFee, newMinTotalFee); + + // 2. newMinTotalFee is higher than maxProtocolFeeBp + newStandardProtocolFee = currentStandardProtocolFee; + newMinTotalFee = maxProtocolFeeBp + 1; + vm.expectRevert(StrategyProtocolFeeTooHigh.selector); + looksRareProtocol.updateStrategy(0, true, newStandardProtocolFee, newMinTotalFee); + + // 3. It reverts if strategy doesn't exist + vm.expectRevert(StrategyNotUsed.selector); + looksRareProtocol.updateStrategy(1, true, currentStandardProtocolFee, currentMinTotalFee); + } + + /** + * Owner functions for strategy additions revert as expected under multiple revertion scenarios + */ + function testOwnerRevertionsForInvalidParametersAddStrategy() public asPrankedUser(_owner) { + uint16 standardProtocolFeeBp = 250; + uint16 minTotalFeeBp = 300; + uint16 maxProtocolFeeBp = 300; + address implementation = address(0); + + // 1. standardProtocolFeeBp is higher than maxProtocolFeeBp + maxProtocolFeeBp = standardProtocolFeeBp - 1; + vm.expectRevert(abi.encodeWithSelector(IStrategyManager.StrategyProtocolFeeTooHigh.selector)); + looksRareProtocol.addStrategy( + standardProtocolFeeBp, minTotalFeeBp, maxProtocolFeeBp, _EMPTY_BYTES4, true, implementation + ); + + // 2. minTotalFeeBp is higher than maxProtocolFeeBp + maxProtocolFeeBp = minTotalFeeBp - 1; + vm.expectRevert(abi.encodeWithSelector(IStrategyManager.StrategyProtocolFeeTooHigh.selector)); + looksRareProtocol.addStrategy( + standardProtocolFeeBp, minTotalFeeBp, maxProtocolFeeBp, _EMPTY_BYTES4, true, implementation + ); + + // 3. maxProtocolFeeBp is higher than _MAX_PROTOCOL_FEE + maxProtocolFeeBp = 500 + 1; + vm.expectRevert(abi.encodeWithSelector(IStrategyManager.StrategyProtocolFeeTooHigh.selector)); + looksRareProtocol.addStrategy( + standardProtocolFeeBp, minTotalFeeBp, maxProtocolFeeBp, _EMPTY_BYTES4, true, implementation + ); + } + + function testAddStrategyNoSelector() public asPrankedUser(_owner) { + vm.expectRevert(IStrategyManager.StrategyHasNoSelector.selector); + _addStrategy(address(0), _EMPTY_BYTES4, true); + } + + function testAddStrategyNotV2Strategy() public asPrankedUser(_owner) { + bytes4 randomSelector = StrategyCollectionOffer.executeCollectionStrategyWithTakerAsk.selector; + + // 1. EOA + vm.expectRevert(); + _addStrategy(address(0), randomSelector, true); + + // 2. Invalid contract (e.g. LooksRareProtocol) + vm.expectRevert(); + _addStrategy(address(looksRareProtocol), randomSelector, true); + + // 3. Contract that implements the function but returns false + FalseBaseStrategy falseStrategy = new FalseBaseStrategy(); + + vm.expectRevert(NotV2Strategy.selector); + _addStrategy(address(falseStrategy), randomSelector, true); + } + + function testAddStrategyNotOwner() public { + vm.expectRevert(IOwnableTwoSteps.NotOwner.selector); + _addStrategy(address(0), _EMPTY_BYTES4, true); + } + + function testUpdateStrategyNotOwner() public { + vm.expectRevert(IOwnableTwoSteps.NotOwner.selector); + looksRareProtocol.updateStrategy(0, false, 299, 100); + } +} diff --git a/contracts/test/foundry/marketplace/TransferManager.t.sol b/contracts/test/foundry/marketplace/TransferManager.t.sol new file mode 100644 index 00000000..d223cc59 --- /dev/null +++ b/contracts/test/foundry/marketplace/TransferManager.t.sol @@ -0,0 +1,527 @@ +// SPDX-License-Identifier: MIT +pragma solidity 0.8.17; + +// LooksRare unopinionated libraries +import {IOwnableTwoSteps} from "@looksrare/contracts-libs/contracts/interfaces/IOwnableTwoSteps.sol"; + +// Libraries +import {OrderStructs} from "@hypercerts/marketplace/libraries/OrderStructs.sol"; + +// Core contracts +import {LooksRareProtocol} from "@hypercerts/marketplace/LooksRareProtocol.sol"; +import {ITransferManager, TransferManager} from "@hypercerts/marketplace/TransferManager.sol"; +import {AmountInvalid, LengthsInvalid} from "@hypercerts/marketplace/errors/SharedErrors.sol"; + +// Mocks and other utils +import {MockERC721} from "../../mock/MockERC721.sol"; +import {MockERC1155} from "../../mock/MockERC1155.sol"; +import {TestHelpers} from "./utils/TestHelpers.sol"; +import {TestParameters} from "./utils/TestParameters.sol"; + +// Enums +import {CollectionType} from "@hypercerts/marketplace/enums/CollectionType.sol"; + +contract TransferManagerTest is ITransferManager, TestHelpers, TestParameters { + address[] public operators; + MockERC721 public mockERC721; + MockERC1155 public mockERC1155; + TransferManager public transferManager; + + uint256 private constant tokenIdERC721 = 55; + uint256 private constant tokenId1ERC1155 = 1; + uint256 private constant amount1ERC1155 = 2; + uint256 private constant tokenId2ERC1155 = 2; + uint256 private constant amount2ERC1155 = 5; + + /** + * 0. Internal helper functions + */ + + function _grantApprovals(address user) private asPrankedUser(user) { + mockERC721.setApprovalForAll(address(transferManager), true); + mockERC1155.setApprovalForAll(address(transferManager), true); + address[] memory approvedOperators = new address[](1); + approvedOperators[0] = _transferrer; + + vm.expectEmit(true, false, false, true); + emit ApprovalsGranted(user, approvedOperators); + transferManager.grantApprovals(approvedOperators); + } + + function _allowOperator(address transferrer) private { + vm.prank(_owner); + vm.expectEmit(true, false, false, true); + emit OperatorAllowed(transferrer); + transferManager.allowOperator(transferrer); + } + + function setUp() public asPrankedUser(_owner) { + transferManager = new TransferManager(_owner); + mockERC721 = new MockERC721(); + mockERC1155 = new MockERC1155(); + operators.push(_transferrer); + + vm.deal(_transferrer, 100 ether); + vm.deal(_sender, 100 ether); + } + + /** + * 1. Happy cases + */ + + function testTransferSingleItemERC721() public { + _allowOperator(_transferrer); + _grantApprovals(_sender); + + uint256 itemId = 500; + + vm.prank(_sender); + mockERC721.mint(_sender, itemId); + + uint256[] memory itemIds = new uint256[](1); + itemIds[0] = itemId; + uint256[] memory amounts = new uint256[](1); + amounts[0] = 1; + + vm.prank(_transferrer); + transferManager.transferItemsERC721(address(mockERC721), _sender, _recipient, itemIds, amounts); + + assertEq(mockERC721.ownerOf(itemId), _recipient); + } + + function testTransferSingleItemERC1155() public { + _allowOperator(_transferrer); + _grantApprovals(_sender); + + uint256 itemId = 1; + uint256 amount = 2; + + mockERC1155.mint(_sender, itemId, amount); + + uint256[] memory itemIds = new uint256[](1); + itemIds[0] = itemId; + uint256[] memory amounts = new uint256[](1); + amounts[0] = amount; + + vm.prank(_transferrer); + transferManager.transferItemsERC1155(address(mockERC1155), _sender, _recipient, itemIds, amounts); + + assertEq(mockERC1155.balanceOf(_recipient, itemId), amount); + } + + function testTransferBatchItemsERC721() public { + _allowOperator(_transferrer); + _grantApprovals(_sender); + + uint256 tokenId1 = 1; + uint256 tokenId2 = 2; + + uint256[] memory itemIds = new uint256[](2); + itemIds[0] = tokenId1; + itemIds[1] = tokenId2; + + uint256[] memory amounts = new uint256[](2); + amounts[0] = 1; + amounts[1] = 1; + + mockERC721.batchMint(_sender, itemIds); + + vm.prank(_transferrer); + transferManager.transferItemsERC721(address(mockERC721), _sender, _recipient, itemIds, amounts); + + assertEq(mockERC721.ownerOf(tokenId1), _recipient); + assertEq(mockERC721.ownerOf(tokenId2), _recipient); + } + + function testTransferBatchItemsERC1155() public { + _allowOperator(_transferrer); + _grantApprovals(_sender); + + uint256 tokenId1 = 1; + uint256 amount1 = 2; + uint256 tokenId2 = 2; + uint256 amount2 = 5; + + mockERC1155.mint(_sender, tokenId1, amount1); + mockERC1155.mint(_sender, tokenId2, amount2); + + uint256[] memory itemIds = new uint256[](2); + itemIds[0] = tokenId1; + itemIds[1] = tokenId2; + + uint256[] memory amounts = new uint256[](2); + amounts[0] = amount1; + amounts[1] = amount2; + + vm.prank(_transferrer); + transferManager.transferItemsERC1155(address(mockERC1155), _sender, _recipient, itemIds, amounts); + + assertEq(mockERC1155.balanceOf(_recipient, tokenId1), amount1); + assertEq(mockERC1155.balanceOf(_recipient, tokenId2), amount2); + } + + function testTransferBatchItemsAcrossCollectionERC721AndERC1155() public { + _allowOperator(_transferrer); + _grantApprovals(_sender); + + ITransferManager.BatchTransferItem[] memory items = _generateValidBatchTransferItems(); + + vm.prank(_transferrer); + transferManager.transferBatchItemsAcrossCollections(items, _sender, _recipient); + + assertEq(mockERC721.ownerOf(tokenIdERC721), _recipient); + assertEq(mockERC1155.balanceOf(_recipient, tokenId1ERC1155), amount1ERC1155); + assertEq(mockERC1155.balanceOf(_recipient, tokenId2ERC1155), amount2ERC1155); + } + + function testTransferBatchItemsAcrossCollectionERC721AndERC1155ByOwner() public asPrankedUser(_sender) { + mockERC721.setApprovalForAll(address(transferManager), true); + mockERC1155.setApprovalForAll(address(transferManager), true); + + ITransferManager.BatchTransferItem[] memory items = _generateValidBatchTransferItems(); + + transferManager.transferBatchItemsAcrossCollections(items, _sender, _recipient); + + assertEq(mockERC721.ownerOf(tokenIdERC721), _recipient); + assertEq(mockERC1155.balanceOf(_recipient, tokenId1ERC1155), amount1ERC1155); + assertEq(mockERC1155.balanceOf(_recipient, tokenId2ERC1155), amount2ERC1155); + } + + /** + * 2. Revertion patterns + */ + function testTransferItemsERC721AmountIsNotOne(uint256 amount) public { + vm.assume(amount != 1); + + _allowOperator(_transferrer); + _grantApprovals(_sender); + + uint256 itemId = 500; + + mockERC721.mint(_sender, itemId); + + uint256[] memory itemIds = new uint256[](1); + itemIds[0] = itemId; + uint256[] memory amounts = new uint256[](1); + amounts[0] = amount; + + vm.expectRevert(AmountInvalid.selector); + vm.prank(_transferrer); + transferManager.transferItemsERC721(address(mockERC721), _sender, _recipient, itemIds, amounts); + } + + function testTransferSingleItemERC1155AmountIsZero() public { + _allowOperator(_transferrer); + _grantApprovals(_sender); + + uint256 itemId = 500; + + mockERC1155.mint(_sender, itemId, 1); + + uint256[] memory itemIds = new uint256[](1); + itemIds[0] = itemId; + uint256[] memory amounts = new uint256[](1); + amounts[0] = 0; + + vm.expectRevert(AmountInvalid.selector); + vm.prank(_transferrer); + transferManager.transferItemsERC1155(address(mockERC1155), _sender, _recipient, itemIds, amounts); + } + + function testTransferMultipleItemsERC1155AmountIsZero() public { + _allowOperator(_transferrer); + _grantApprovals(_sender); + + uint256 itemIdOne = 500; + uint256 itemIdTwo = 501; + + mockERC1155.mint(_sender, itemIdOne, 1); + mockERC1155.mint(_sender, itemIdTwo, 1); + + uint256[] memory itemIds = new uint256[](2); + itemIds[0] = itemIdOne; + itemIds[1] = itemIdTwo; + uint256[] memory amounts = new uint256[](2); + amounts[0] = 0; + amounts[1] = 0; + + vm.expectRevert(AmountInvalid.selector); + vm.prank(_transferrer); + transferManager.transferItemsERC1155(address(mockERC1155), _sender, _recipient, itemIds, amounts); + } + + function testTransferBatchItemsAcrossCollectionZeroLength() public { + _allowOperator(_transferrer); + _grantApprovals(_sender); + + ITransferManager.BatchTransferItem[] memory items = new ITransferManager.BatchTransferItem[](0); + + vm.expectRevert(LengthsInvalid.selector); + vm.prank(_transferrer); + transferManager.transferBatchItemsAcrossCollections(items, _sender, _recipient); + } + + function testCannotBatchTransferIfERC721AmountIsNotOne(uint256 amount) public { + vm.assume(amount != 1); + + _allowOperator(_transferrer); + _grantApprovals(_sender); + + ITransferManager.BatchTransferItem[] memory items = _generateValidBatchTransferItems(); + items[1].amounts[0] = amount; + + vm.expectRevert(AmountInvalid.selector); + vm.prank(_sender); + transferManager.transferBatchItemsAcrossCollections(items, _sender, _recipient); + } + + function testCannotBatchTransferIfERC1155AmountIsZero() public { + _allowOperator(_transferrer); + _grantApprovals(_sender); + + ITransferManager.BatchTransferItem[] memory items = _generateValidBatchTransferItems(); + items[0].amounts[0] = 0; + + vm.expectRevert(AmountInvalid.selector); + vm.prank(_sender); + transferManager.transferBatchItemsAcrossCollections(items, _sender, _recipient); + } + + function testTransferBatchItemsAcrossCollectionPerCollectionItemIdsLengthZero() public { + _allowOperator(_transferrer); + _grantApprovals(_sender); + + ITransferManager.BatchTransferItem[] memory items = _generateValidBatchTransferItems(); + items[0].itemIds = new uint256[](0); + items[0].amounts = new uint256[](0); + + vm.prank(_transferrer); + vm.expectRevert(LengthsInvalid.selector); + transferManager.transferBatchItemsAcrossCollections(items, _sender, _recipient); + } + + function testCannotTransferERC721IfOperatorApprovalsRevokedByUserOrOperatorRemovedByOwner() public { + _allowOperator(_transferrer); + _grantApprovals(_sender); + + // 1. User revokes the operator + vm.prank(_sender); + vm.expectEmit(false, false, false, true); + emit ApprovalsRemoved(_sender, operators); + transferManager.revokeApprovals(operators); + + uint256 itemId = 500; + uint256[] memory itemIds = new uint256[](1); + itemIds[0] = itemId; + uint256[] memory amounts = new uint256[](1); + amounts[0] = 1; + + vm.prank(_transferrer); + vm.expectRevert(ITransferManager.TransferCallerInvalid.selector); + transferManager.transferItemsERC721(address(mockERC721), _sender, _recipient, itemIds, amounts); + + // 2. Sender grants again approvals but owner removes the operators + _grantApprovals(_sender); + vm.prank(_owner); + vm.expectEmit(false, false, false, true); + emit OperatorRemoved(_transferrer); + transferManager.removeOperator(_transferrer); + + vm.prank(_transferrer); + vm.expectRevert(ITransferManager.TransferCallerInvalid.selector); + transferManager.transferItemsERC721(address(mockERC721), _sender, _recipient, itemIds, amounts); + } + + function testCannotTransferERC1155IfOperatorApprovalsRevokedByUserOrOperatorRemovedByOwner() public { + _allowOperator(_transferrer); + _grantApprovals(_sender); + + // 1. User revokes the operator + vm.prank(_sender); + vm.expectEmit(false, false, false, true); + emit ApprovalsRemoved(_sender, operators); + transferManager.revokeApprovals(operators); + + uint256 itemId = 500; + uint256[] memory itemIds = new uint256[](1); + itemIds[0] = itemId; + uint256[] memory amounts = new uint256[](1); + amounts[0] = 5; + + vm.prank(_transferrer); + vm.expectRevert(ITransferManager.TransferCallerInvalid.selector); + transferManager.transferItemsERC1155(address(mockERC1155), _sender, _recipient, itemIds, amounts); + + // 2. Sender grants again approvals but owner removes the operators + _grantApprovals(_sender); + vm.prank(_owner); + vm.expectEmit(false, false, false, true); + emit OperatorRemoved(_transferrer); + transferManager.removeOperator(_transferrer); + + vm.prank(_transferrer); + vm.expectRevert(ITransferManager.TransferCallerInvalid.selector); + transferManager.transferItemsERC1155(address(mockERC1155), _sender, _recipient, itemIds, amounts); + } + + function testCannotBatchTransferIfOperatorApprovalsRevoked() public { + _allowOperator(_transferrer); + _grantApprovals(_sender); + + // 1. User revokes the operator + vm.prank(_sender); + vm.expectEmit(false, false, false, true); + emit ApprovalsRemoved(_sender, operators); + transferManager.revokeApprovals(operators); + + ITransferManager.BatchTransferItem[] memory items = _generateValidBatchTransferItems(); + + vm.prank(_transferrer); + vm.expectRevert(ITransferManager.TransferCallerInvalid.selector); + transferManager.transferBatchItemsAcrossCollections(items, _sender, _recipient); + + // 2. Sender grants again approvals but owner removes the operators + _grantApprovals(_sender); + vm.prank(_owner); + vm.expectEmit(false, false, false, true); + emit OperatorRemoved(_transferrer); + transferManager.removeOperator(_transferrer); + + vm.prank(_transferrer); + vm.expectRevert(ITransferManager.TransferCallerInvalid.selector); + transferManager.transferBatchItemsAcrossCollections(items, _sender, _recipient); + } + + function testCannotTransferERC721OrERC1155IfArrayLengthIs0() public { + uint256[] memory emptyArrayUint256 = new uint256[](0); + + // 1. ERC721 + vm.expectRevert(LengthsInvalid.selector); + transferManager.transferItemsERC721( + address(mockERC721), _sender, _recipient, emptyArrayUint256, emptyArrayUint256 + ); + + // 2. ERC1155 length is 0 + vm.expectRevert(LengthsInvalid.selector); + transferManager.transferItemsERC1155( + address(mockERC1155), _sender, _recipient, emptyArrayUint256, emptyArrayUint256 + ); + } + + function testCannotTransferERC1155IfArrayLengthDiffers() public { + uint256[] memory itemIds = new uint256[](2); + uint256[] memory amounts = new uint256[](3); + + vm.expectRevert(LengthsInvalid.selector); + transferManager.transferItemsERC1155(address(mockERC1155), _sender, _recipient, itemIds, amounts); + } + + function testUserCannotGrantOrRevokeApprovalsIfArrayLengthIs0() public { + address[] memory emptyArrayAddresses = new address[](0); + + // 1. Grant approvals + vm.expectRevert(LengthsInvalid.selector); + transferManager.grantApprovals(emptyArrayAddresses); + + // 2. Revoke approvals + vm.expectRevert(LengthsInvalid.selector); + transferManager.revokeApprovals(emptyArrayAddresses); + } + + function testUserCannotGrantApprovalIfOperatorOperatorNotAllowed() public asPrankedUser(_owner) { + address randomOperator = address(420); + transferManager.allowOperator(randomOperator); + vm.expectRevert(ITransferManager.OperatorAlreadyAllowed.selector); + transferManager.allowOperator(randomOperator); + } + + function testAllowOperatorNotOwner() public { + vm.expectRevert(IOwnableTwoSteps.NotOwner.selector); + transferManager.allowOperator(address(0)); + } + + function testOwnerCannotallowOperatorIfOperatorAlreadyAllowed() public asPrankedUser(_owner) { + address randomOperator = address(420); + transferManager.allowOperator(randomOperator); + vm.expectRevert(ITransferManager.OperatorAlreadyAllowed.selector); + transferManager.allowOperator(randomOperator); + } + + function testOwnerCannotRemoveOperatorIfOperatorNotAllowed() public asPrankedUser(_owner) { + address notOperator = address(420); + vm.expectRevert(ITransferManager.OperatorNotAllowed.selector); + transferManager.removeOperator(notOperator); + } + + function testUserCannotGrantApprovalsIfOperatorNotAllowed() public { + address[] memory approvedOperators = new address[](1); + approvedOperators[0] = _transferrer; + + vm.expectRevert(ITransferManager.OperatorNotAllowed.selector); + vm.prank(_sender); + transferManager.grantApprovals(approvedOperators); + } + + function testUserCannotGrantApprovalsIfOperatorAlreadyApprovedByUser() public { + _allowOperator(_transferrer); + _grantApprovals(_sender); + + address[] memory approvedOperators = new address[](1); + approvedOperators[0] = _transferrer; + + vm.expectRevert(ITransferManager.OperatorAlreadyApprovedByUser.selector); + vm.prank(_sender); + transferManager.grantApprovals(approvedOperators); + } + + function testUserCannotRevokeApprovalsIfOperatorNotApprovedByUser() public { + address[] memory approvedOperators = new address[](1); + approvedOperators[0] = _transferrer; + + vm.expectRevert(ITransferManager.OperatorNotApprovedByUser.selector); + vm.prank(_sender); + transferManager.revokeApprovals(approvedOperators); + } + + function testRemoveOperatorNotOwner() public { + vm.expectRevert(IOwnableTwoSteps.NotOwner.selector); + transferManager.removeOperator(address(0)); + } + + function _generateValidBatchTransferItems() private returns (BatchTransferItem[] memory items) { + items = new ITransferManager.BatchTransferItem[](2); + + { + mockERC721.mint(_sender, tokenIdERC721); + mockERC1155.mint(_sender, tokenId1ERC1155, amount1ERC1155); + mockERC1155.mint(_sender, tokenId2ERC1155, amount2ERC1155); + + uint256[] memory tokenIdsERC1155 = new uint256[](2); + tokenIdsERC1155[0] = tokenId1ERC1155; + tokenIdsERC1155[1] = tokenId2ERC1155; + + uint256[] memory amountsERC1155 = new uint256[](2); + amountsERC1155[0] = amount1ERC1155; + amountsERC1155[1] = amount2ERC1155; + + uint256[] memory tokenIdsERC721 = new uint256[](1); + tokenIdsERC721[0] = tokenIdERC721; + + uint256[] memory amountsERC721 = new uint256[](1); + amountsERC721[0] = 1; + + items[0] = ITransferManager.BatchTransferItem({ + collection: address(mockERC1155), + collectionType: CollectionType.ERC1155, + itemIds: tokenIdsERC1155, + amounts: amountsERC1155 + }); + items[1] = ITransferManager.BatchTransferItem({ + collection: address(mockERC721), + collectionType: CollectionType.ERC721, + itemIds: tokenIdsERC721, + amounts: amountsERC721 + }); + } + } +} diff --git a/contracts/test/foundry/marketplace/assembly/VerifyOrderTimestampValidityEquivalence.t.sol b/contracts/test/foundry/marketplace/assembly/VerifyOrderTimestampValidityEquivalence.t.sol new file mode 100644 index 00000000..504f0049 --- /dev/null +++ b/contracts/test/foundry/marketplace/assembly/VerifyOrderTimestampValidityEquivalence.t.sol @@ -0,0 +1,91 @@ +// SPDX-License-Identifier: MIT +pragma solidity 0.8.17; + +import {Test} from "forge-std/Test.sol"; + +// Assembly +import { + OutsideOfTimeRange_error_selector, + OutsideOfTimeRange_error_length, + Error_selector_offset +} from "@hypercerts/marketplace/constants/AssemblyConstants.sol"; + +contract NonAssemblyCode { + error OutsideOfTimeRange(); + + function run(uint256 startTime, uint256 endTime) external view returns (bool) { + if (startTime > block.timestamp || endTime < block.timestamp) revert OutsideOfTimeRange(); + return true; + } +} + +contract AssemblyCode { + function run(uint256 startTime, uint256 endTime) external view returns (bool) { + assembly { + if or(gt(startTime, timestamp()), lt(endTime, timestamp())) { + mstore(0x00, OutsideOfTimeRange_error_selector) + revert(Error_selector_offset, OutsideOfTimeRange_error_length) + } + } + return true; + } +} + +contract VerifyOrderTimestampValidityEquivalenceTest is Test { + AssemblyCode private assemblyCode; + NonAssemblyCode private nonAssemblyCode; + + function setUp() public { + assemblyCode = new AssemblyCode(); + nonAssemblyCode = new NonAssemblyCode(); + } + + /** + * @dev The gap between start and end time is always at least + * 3 seconds so that we can test the 2 boundaries as well + * as the 2 timestamps inside the boundaries + */ + function testEquivalenceWithinBoundaries(uint256 startTime, uint256 endTime) public { + vm.assume(endTime > 3 && startTime < endTime - 3); + + vm.warp(startTime); + assertTrue(assemblyCode.run(startTime, endTime)); + assertTrue(nonAssemblyCode.run(startTime, endTime)); + + vm.warp(startTime + 1); + assertTrue(assemblyCode.run(startTime, endTime)); + assertTrue(nonAssemblyCode.run(startTime, endTime)); + + vm.warp(endTime - 1); + assertTrue(assemblyCode.run(startTime, endTime)); + assertTrue(nonAssemblyCode.run(startTime, endTime)); + + vm.warp(endTime); + assertTrue(assemblyCode.run(startTime, endTime)); + assertTrue(nonAssemblyCode.run(startTime, endTime)); + } + + function testEquivalenceTooEarly(uint256 startTime, uint256 endTime) public { + vm.assume(startTime > 0 && startTime < endTime); + + vm.warp(startTime - 1); + + vm.expectRevert(NonAssemblyCode.OutsideOfTimeRange.selector); + assemblyCode.run(startTime, endTime); + + vm.expectRevert(NonAssemblyCode.OutsideOfTimeRange.selector); + nonAssemblyCode.run(startTime, endTime); + } + + function testEquivalenceTooLate(uint256 startTime, uint256 endTime) public { + vm.assume(endTime > 0 && endTime < type(uint256).max && startTime < endTime); + + vm.warp(endTime + 1); + + vm.expectRevert(NonAssemblyCode.OutsideOfTimeRange.selector); + assemblyCode.run(startTime, endTime); + + vm.expectRevert(NonAssemblyCode.OutsideOfTimeRange.selector); + nonAssemblyCode.run(startTime, endTime); + } +} diff --git a/contracts/test/foundry/marketplace/executionStrategies/Chainlink/USDDynamicAskOrders.t.sol b/contracts/test/foundry/marketplace/executionStrategies/Chainlink/USDDynamicAskOrders.t.sol new file mode 100644 index 00000000..40a74239 --- /dev/null +++ b/contracts/test/foundry/marketplace/executionStrategies/Chainlink/USDDynamicAskOrders.t.sol @@ -0,0 +1,488 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.17; + +// Libraries and interfaces +import {OrderStructs} from "@hypercerts/marketplace/libraries/OrderStructs.sol"; +import {IExecutionManager} from "@hypercerts/marketplace/interfaces/IExecutionManager.sol"; +import {IStrategyManager} from "@hypercerts/marketplace/interfaces/IStrategyManager.sol"; + +// Errors and constants +import { + AmountInvalid, + BidTooLow, + OrderInvalid, + CurrencyInvalid, + FunctionSelectorInvalid, + QuoteTypeInvalid +} from "@hypercerts/marketplace/errors/SharedErrors.sol"; +import {ChainlinkPriceInvalid, PriceNotRecentEnough} from "@hypercerts/marketplace/errors/ChainlinkErrors.sol"; +import { + MAKER_ORDER_PERMANENTLY_INVALID_NON_STANDARD_SALE, + MAKER_ORDER_TEMPORARILY_INVALID_NON_STANDARD_SALE, + STRATEGY_NOT_ACTIVE +} from "@hypercerts/marketplace/constants/ValidationCodeConstants.sol"; + +// Strategies +import {StrategyChainlinkUSDDynamicAsk} from + "@hypercerts/marketplace/executionStrategies/Chainlink/StrategyChainlinkUSDDynamicAsk.sol"; + +// Mocks and other tests +import {MockChainlinkAggregator} from "../../../../mock/MockChainlinkAggregator.sol"; +import {MockERC20} from "../../../../mock/MockERC20.sol"; +import {ProtocolBase} from "../../ProtocolBase.t.sol"; + +// Enums +import {CollectionType} from "@hypercerts/marketplace/enums/CollectionType.sol"; +import {QuoteType} from "@hypercerts/marketplace/enums/QuoteType.sol"; + +contract USDDynamicAskOrdersTest is ProtocolBase, IStrategyManager { + StrategyChainlinkUSDDynamicAsk public strategyUSDDynamicAsk; + bytes4 public selector = StrategyChainlinkUSDDynamicAsk.executeStrategyWithTakerBid.selector; + + // At block 15740567 + // roundId uint80 : 92233720368547793259 + // answer int256 : 126533075631 + // startedAt uint256 : 1665680123 + // updatedAt uint256 : 1665680123 + // answeredInRound uint80 : 92233720368547793259 + uint256 private constant CHAINLINK_PRICE_UPDATED_AT = 1_665_680_123; + uint256 private constant FORKED_BLOCK_NUMBER = 15_740_567; + uint256 private constant LATEST_CHAINLINK_ANSWER_IN_WAD = 126_533_075_631 * 1e10; + uint256 private constant MAXIMUM_LATENCY = 3600 seconds; + + function setUp() public { + vm.createSelectFork(vm.rpcUrl("mainnet"), FORKED_BLOCK_NUMBER); + _setUp(); + _setUpUsers(); + _setUpNewStrategy(); + } + + function _setUpNewStrategy() private asPrankedUser(_owner) { + strategyUSDDynamicAsk = new StrategyChainlinkUSDDynamicAsk( + _owner, + address(weth), + 0x5f4eC3Df9cbd43714FE2740f5E3616155c5b8419 // Mainnet address of the Chainlink price feed + ); + _addStrategy(address(strategyUSDDynamicAsk), selector, false); + } + + function _createMakerAskAndTakerBid(uint256 numberOfItems, uint256 numberOfAmounts, uint256 desiredSalePriceInUSD) + private + returns (OrderStructs.Maker memory newMakerAsk, OrderStructs.Taker memory newTakerBid) + { + uint256[] memory itemIds = new uint256[](numberOfItems); + for (uint256 i; i < numberOfItems;) { + mockERC721.mint(makerUser, i + 1); + itemIds[i] = i + 1; + unchecked { + ++i; + } + } + + uint256[] memory amounts = new uint256[](numberOfAmounts); + for (uint256 i; i < numberOfAmounts;) { + amounts[i] = 1; + unchecked { + ++i; + } + } + + newMakerAsk = _createSingleItemMakerOrder({ + quoteType: QuoteType.Ask, + globalNonce: 0, + subsetNonce: 0, + strategyId: 1, + collectionType: CollectionType.ERC721, + orderNonce: 0, + collection: address(mockERC721), + currency: address(weth), + signer: makerUser, + price: 0.99 ether, + itemId: 1 + }); + + newMakerAsk.itemIds = itemIds; + newMakerAsk.amounts = amounts; + newMakerAsk.additionalParameters = abi.encode(desiredSalePriceInUSD); + + newTakerBid = OrderStructs.Taker(takerUser, abi.encode(1 ether)); + } + + function testNewStrategy() public { + _assertStrategyAttributes(address(strategyUSDDynamicAsk), selector, false); + } + + function testMaxLatency() public { + assertEq(strategyUSDDynamicAsk.maxLatency(), 3600); + } + + function testUSDDynamicAskChainlinkPriceInvalid() public { + (OrderStructs.Maker memory makerAsk, OrderStructs.Taker memory takerBid) = _createMakerAskAndTakerBid({ + numberOfItems: 1, + numberOfAmounts: 1, + desiredSalePriceInUSD: LATEST_CHAINLINK_ANSWER_IN_WAD + }); + + bytes memory signature = _signMakerOrder(makerAsk, makerUserPK); + + MockChainlinkAggregator priceFeed = new MockChainlinkAggregator(); + vm.etch(CHAINLINK_ETH_USD_PRICE_FEED, address(priceFeed).code); + + MockChainlinkAggregator(CHAINLINK_ETH_USD_PRICE_FEED).setAnswer(-1); + (bool isValid, bytes4 errorSelector) = strategyUSDDynamicAsk.isMakerOrderValid(makerAsk, selector); + assertFalse(isValid); + assertEq(errorSelector, ChainlinkPriceInvalid.selector); + + vm.expectRevert(errorSelector); + vm.prank(takerUser); + looksRareProtocol.executeTakerBid(takerBid, makerAsk, signature, _EMPTY_MERKLE_TREE); + + MockChainlinkAggregator(CHAINLINK_ETH_USD_PRICE_FEED).setAnswer(0); + (isValid, errorSelector) = strategyUSDDynamicAsk.isMakerOrderValid(makerAsk, selector); + assertFalse(isValid); + assertEq(errorSelector, ChainlinkPriceInvalid.selector); + + vm.expectRevert(errorSelector); + vm.prank(takerUser); + looksRareProtocol.executeTakerBid(takerBid, makerAsk, signature, _EMPTY_MERKLE_TREE); + } + + function testUSDDynamicAskUSDValueGreaterThanOrEqualToMinAcceptedEthValue() public { + (OrderStructs.Maker memory makerAsk, OrderStructs.Taker memory takerBid) = _createMakerAskAndTakerBid({ + numberOfItems: 1, + numberOfAmounts: 1, + desiredSalePriceInUSD: LATEST_CHAINLINK_ANSWER_IN_WAD + }); + + bytes memory signature = _signMakerOrder(makerAsk, makerUserPK); + + (bool isValid, bytes4 errorSelector) = strategyUSDDynamicAsk.isMakerOrderValid(makerAsk, selector); + assertTrue(isValid); + assertEq(errorSelector, _EMPTY_BYTES4); + + // Execute taker bid transaction + vm.prank(takerUser); + looksRareProtocol.executeTakerBid(takerBid, makerAsk, signature, _EMPTY_MERKLE_TREE); + + // Taker user has received the asset + assertEq(mockERC721.ownerOf(1), takerUser); + // Taker bid user pays the whole price + assertEq(weth.balanceOf(takerUser), _initialWETHBalanceUser - 1 ether); + // Maker ask user receives 99.5% of the whole price (0.5% protocol) + assertEq(weth.balanceOf(makerUser), _initialWETHBalanceUser + 0.995 ether); + } + + function testUSDDynamicAskUSDValueLessThanMinAcceptedEthValue() public { + (OrderStructs.Maker memory makerAsk, OrderStructs.Taker memory takerBid) = _createMakerAskAndTakerBid({ + numberOfItems: 1, + numberOfAmounts: 1, + desiredSalePriceInUSD: (LATEST_CHAINLINK_ANSWER_IN_WAD * 98) / 100 + }); + + bytes memory signature = _signMakerOrder(makerAsk, makerUserPK); + + (bool isValid, bytes4 errorSelector) = strategyUSDDynamicAsk.isMakerOrderValid(makerAsk, selector); + assertTrue(isValid); + assertEq(errorSelector, _EMPTY_BYTES4); + + // Execute taker bid transaction + vm.prank(takerUser); + looksRareProtocol.executeTakerBid(takerBid, makerAsk, signature, _EMPTY_MERKLE_TREE); + + // Taker user has received the asset + assertEq(mockERC721.ownerOf(1), takerUser); + + // Taker bid user pays the whole price + assertEq(weth.balanceOf(takerUser), _initialWETHBalanceUser - 0.99 ether); + // Maker ask user receives 99.5% of the whole price (0.5% protocol) + assertEq(weth.balanceOf(makerUser), _initialWETHBalanceUser + 0.98505 ether); + } + + // This tests that we can handle fractions + function testUSDDynamicAskUSDValueLessThanOneETH() public { + (OrderStructs.Maker memory makerAsk, OrderStructs.Taker memory takerBid) = _createMakerAskAndTakerBid({ + numberOfItems: 1, + numberOfAmounts: 1, + desiredSalePriceInUSD: LATEST_CHAINLINK_ANSWER_IN_WAD / 2 + }); + + makerAsk.price = 0.49 ether; + + bytes memory signature = _signMakerOrder(makerAsk, makerUserPK); + + (bool isValid, bytes4 errorSelector) = strategyUSDDynamicAsk.isMakerOrderValid(makerAsk, selector); + assertTrue(isValid); + assertEq(errorSelector, _EMPTY_BYTES4); + + // Execute taker bid transaction + vm.prank(takerUser); + looksRareProtocol.executeTakerBid(takerBid, makerAsk, signature, _EMPTY_MERKLE_TREE); + + // Taker user has received the asset + assertEq(mockERC721.ownerOf(1), takerUser); + + // Taker bid user pays the whole price + assertEq(weth.balanceOf(takerUser), _initialWETHBalanceUser - 0.5 ether); + // Maker ask user receives 99.5% of the whole price (0.5% protocol) + assertEq(weth.balanceOf(makerUser), _initialWETHBalanceUser + 0.4975 ether); + } + + function testUSDDynamicAskBidderOverpaid() public { + (OrderStructs.Maker memory makerAsk, OrderStructs.Taker memory takerBid) = _createMakerAskAndTakerBid({ + numberOfItems: 1, + numberOfAmounts: 1, + desiredSalePriceInUSD: LATEST_CHAINLINK_ANSWER_IN_WAD + }); + + makerAsk.currency = ETH; + // Bidder overpays by 0.1 ETH + uint256 maxPrice = 1.1 ether; + takerBid.additionalParameters = abi.encode(maxPrice); + + bytes memory signature = _signMakerOrder(makerAsk, makerUserPK); + + uint256 initialETHBalanceTakerUser = address(takerUser).balance; + uint256 initialETHBalanceMakerUser = address(makerUser).balance; + + (bool isValid, bytes4 errorSelector) = strategyUSDDynamicAsk.isMakerOrderValid(makerAsk, selector); + assertTrue(isValid); + assertEq(errorSelector, _EMPTY_BYTES4); + + // Execute taker bid transaction + vm.prank(takerUser); + looksRareProtocol.executeTakerBid{value: maxPrice}(takerBid, makerAsk, signature, _EMPTY_MERKLE_TREE); + + // Taker user has received the asset + assertEq(mockERC721.ownerOf(1), takerUser); + // Taker bid user pays the whole price, but without overpaying + assertEq(address(takerUser).balance, initialETHBalanceTakerUser - 1 ether - 1); + // Maker ask user receives 99.5% of the whole price (0.5% protocol) + assertEq(address(makerUser).balance, initialETHBalanceMakerUser + 0.995 ether); + } + + function testOraclePriceNotRecentEnough() public { + (OrderStructs.Maker memory makerAsk, OrderStructs.Taker memory takerBid) = _createMakerAskAndTakerBid({ + numberOfItems: 1, + numberOfAmounts: 1, + desiredSalePriceInUSD: LATEST_CHAINLINK_ANSWER_IN_WAD + }); + + makerAsk.startTime = CHAINLINK_PRICE_UPDATED_AT; + uint256 latencyViolationTimestamp = CHAINLINK_PRICE_UPDATED_AT + MAXIMUM_LATENCY + 1 seconds; + makerAsk.endTime = latencyViolationTimestamp; + + bytes memory signature = _signMakerOrder(makerAsk, makerUserPK); + + vm.warp(latencyViolationTimestamp); + + bytes4 errorSelector = PriceNotRecentEnough.selector; + + _assertOrderIsInvalid(makerAsk, errorSelector); + _assertMakerOrderReturnValidationCode(makerAsk, signature, MAKER_ORDER_TEMPORARILY_INVALID_NON_STANDARD_SALE); + + vm.expectRevert(errorSelector); + vm.prank(takerUser); + looksRareProtocol.executeTakerBid(takerBid, makerAsk, signature, _EMPTY_MERKLE_TREE); + } + + function testCannotExecuteIfNotWETHOrETH() public { + MockERC20 fakeCurrency = new MockERC20(); + vm.prank(_owner); + looksRareProtocol.updateCurrencyStatus(address(fakeCurrency), true); + + (OrderStructs.Maker memory makerAsk, OrderStructs.Taker memory takerBid) = _createMakerAskAndTakerBid({ + numberOfItems: 1, + numberOfAmounts: 1, + desiredSalePriceInUSD: LATEST_CHAINLINK_ANSWER_IN_WAD + }); + + // Adjust the currency to something creative + makerAsk.currency = address(fakeCurrency); + + bytes memory signature = _signMakerOrder(makerAsk, makerUserPK); + + (bool isValid, bytes4 errorSelector) = strategyUSDDynamicAsk.isMakerOrderValid(makerAsk, selector); + assertFalse(isValid); + assertEq(errorSelector, CurrencyInvalid.selector); + + vm.expectRevert(errorSelector); + vm.prank(takerUser); + looksRareProtocol.executeTakerBid(takerBid, makerAsk, signature, _EMPTY_MERKLE_TREE); + } + + function testZeroItemIdsLength() public { + (OrderStructs.Maker memory makerAsk, OrderStructs.Taker memory takerBid) = _createMakerAskAndTakerBid({ + numberOfItems: 0, + numberOfAmounts: 0, + desiredSalePriceInUSD: LATEST_CHAINLINK_ANSWER_IN_WAD + }); + + bytes memory signature = _signMakerOrder(makerAsk, makerUserPK); + + (bool isValid, bytes4 errorSelector) = strategyUSDDynamicAsk.isMakerOrderValid(makerAsk, selector); + assertFalse(isValid); + assertEq(errorSelector, OrderInvalid.selector); + + vm.expectRevert(errorSelector); + vm.prank(takerUser); + looksRareProtocol.executeTakerBid(takerBid, makerAsk, signature, _EMPTY_MERKLE_TREE); + } + + function testItemIdsAndAmountsLengthMismatch() public { + (OrderStructs.Maker memory makerAsk, OrderStructs.Taker memory takerBid) = _createMakerAskAndTakerBid({ + numberOfItems: 1, + numberOfAmounts: 2, + desiredSalePriceInUSD: LATEST_CHAINLINK_ANSWER_IN_WAD + }); + + bytes memory signature = _signMakerOrder(makerAsk, makerUserPK); + + (bool isValid, bytes4 errorSelector) = strategyUSDDynamicAsk.isMakerOrderValid(makerAsk, selector); + assertFalse(isValid); + assertEq(errorSelector, OrderInvalid.selector); + + vm.expectRevert(errorSelector); + vm.prank(takerUser); + looksRareProtocol.executeTakerBid(takerBid, makerAsk, signature, _EMPTY_MERKLE_TREE); + } + + function testWrongQuoteType() public { + OrderStructs.Maker memory makerBid = _createSingleItemMakerOrder({ + quoteType: QuoteType.Bid, + globalNonce: 0, + subsetNonce: 0, + strategyId: 1, + collectionType: CollectionType.ERC721, + orderNonce: 0, + collection: address(mockERC721), + currency: address(weth), + signer: makerUser, + price: 1 ether, + itemId: 420 + }); + + (bool orderIsValid, bytes4 errorSelector) = strategyUSDDynamicAsk.isMakerOrderValid(makerBid, selector); + + assertFalse(orderIsValid); + assertEq(errorSelector, QuoteTypeInvalid.selector); + } + + function testZeroAmount() public { + (OrderStructs.Maker memory makerAsk, OrderStructs.Taker memory takerBid) = _createMakerAskAndTakerBid({ + numberOfItems: 1, + numberOfAmounts: 1, + desiredSalePriceInUSD: LATEST_CHAINLINK_ANSWER_IN_WAD + }); + + uint256[] memory amounts = new uint256[](1); + amounts[0] = 0; + makerAsk.amounts = amounts; + + bytes memory signature = _signMakerOrder(makerAsk, makerUserPK); + + // Valid, taker struct validation only happens during execution + (bool isValid, bytes4 errorSelector) = strategyUSDDynamicAsk.isMakerOrderValid(makerAsk, selector); + assertFalse(isValid); + assertEq(errorSelector, OrderInvalid.selector); + + vm.prank(takerUser); + vm.expectRevert(AmountInvalid.selector); + looksRareProtocol.executeTakerBid(takerBid, makerAsk, signature, _EMPTY_MERKLE_TREE); + } + + function testAmountGreaterThanOneForERC721() public { + (OrderStructs.Maker memory makerAsk, OrderStructs.Taker memory takerBid) = _createMakerAskAndTakerBid({ + numberOfItems: 1, + numberOfAmounts: 1, + desiredSalePriceInUSD: LATEST_CHAINLINK_ANSWER_IN_WAD + }); + + uint256[] memory amounts = new uint256[](1); + amounts[0] = 2; + makerAsk.amounts = amounts; + + bytes memory signature = _signMakerOrder(makerAsk, makerUserPK); + + // Valid, taker struct validation only happens during execution + _assertOrderIsInvalid(makerAsk, OrderInvalid.selector); + _assertMakerOrderReturnValidationCode(makerAsk, signature, MAKER_ORDER_PERMANENTLY_INVALID_NON_STANDARD_SALE); + + vm.prank(takerUser); + vm.expectRevert(AmountInvalid.selector); + looksRareProtocol.executeTakerBid(takerBid, makerAsk, signature, _EMPTY_MERKLE_TREE); + } + + function testTakerBidTooLow() public { + (OrderStructs.Maker memory makerAsk, OrderStructs.Taker memory takerBid) = _createMakerAskAndTakerBid({ + numberOfItems: 1, + numberOfAmounts: 1, + desiredSalePriceInUSD: LATEST_CHAINLINK_ANSWER_IN_WAD + }); + + takerBid.additionalParameters = abi.encode(0.99 ether); + + bytes memory signature = _signMakerOrder(makerAsk, makerUserPK); + + // Valid, taker struct validation only happens during execution + _assertOrderIsValid(makerAsk); + _assertValidMakerOrder(makerAsk, signature); + + vm.expectRevert(BidTooLow.selector); + vm.prank(takerUser); + + looksRareProtocol.executeTakerBid(takerBid, makerAsk, signature, _EMPTY_MERKLE_TREE); + } + + function testInactiveStrategy() public { + (OrderStructs.Maker memory makerAsk, OrderStructs.Taker memory takerBid) = _createMakerAskAndTakerBid({ + numberOfItems: 1, + numberOfAmounts: 1, + desiredSalePriceInUSD: LATEST_CHAINLINK_ANSWER_IN_WAD + }); + + bytes memory signature = _signMakerOrder(makerAsk, makerUserPK); + + vm.prank(_owner); + looksRareProtocol.updateStrategy(1, false, _standardProtocolFeeBp, _minTotalFeeBp); + + _assertOrderIsValid(makerAsk); + _assertMakerOrderReturnValidationCode(makerAsk, signature, STRATEGY_NOT_ACTIVE); + + vm.expectRevert(abi.encodeWithSelector(IExecutionManager.StrategyNotAvailable.selector, 1)); + vm.prank(takerUser); + + looksRareProtocol.executeTakerBid(takerBid, makerAsk, signature, _EMPTY_MERKLE_TREE); + } + + function testInvalidSelector() public { + OrderStructs.Maker memory makerAsk = _createSingleItemMakerOrder({ + quoteType: QuoteType.Ask, + globalNonce: 0, + subsetNonce: 0, + strategyId: 2, + collectionType: CollectionType.ERC721, + orderNonce: 0, + collection: address(mockERC721), + currency: address(weth), + signer: makerUser, + price: 1 ether, + itemId: 420 + }); + + (bool orderIsValid, bytes4 errorSelector) = strategyUSDDynamicAsk.isMakerOrderValid(makerAsk, bytes4(0)); + assertFalse(orderIsValid); + assertEq(errorSelector, FunctionSelectorInvalid.selector); + } + + function _assertOrderIsInvalid(OrderStructs.Maker memory makerAsk, bytes4 expectedErrorSelector) private { + (bool isValid, bytes4 errorSelector) = strategyUSDDynamicAsk.isMakerOrderValid(makerAsk, selector); + assertFalse(isValid); + assertEq(errorSelector, expectedErrorSelector); + } + + function _assertOrderIsValid(OrderStructs.Maker memory makerAsk) private { + (bool isValid, bytes4 errorSelector) = strategyUSDDynamicAsk.isMakerOrderValid(makerAsk, selector); + assertTrue(isValid); + assertEq(errorSelector, _EMPTY_BYTES4); + } +} diff --git a/contracts/test/foundry/marketplace/executionStrategies/CollectionOffers.t.sol b/contracts/test/foundry/marketplace/executionStrategies/CollectionOffers.t.sol new file mode 100644 index 00000000..9f9efa3f --- /dev/null +++ b/contracts/test/foundry/marketplace/executionStrategies/CollectionOffers.t.sol @@ -0,0 +1,449 @@ +// SPDX-License-Identifier: MIT +pragma solidity 0.8.17; + +// Murky (third-party) library is used to compute Merkle trees in Solidity +import {Merkle} from "murky/Merkle.sol"; + +// Libraries +import {OrderStructs} from "@hypercerts/marketplace/libraries/OrderStructs.sol"; + +// Shared errors +import { + AmountInvalid, + OrderInvalid, + FunctionSelectorInvalid, + MerkleProofInvalid, + QuoteTypeInvalid +} from "@hypercerts/marketplace/errors/SharedErrors.sol"; +import {MAKER_ORDER_PERMANENTLY_INVALID_NON_STANDARD_SALE} from + "@hypercerts/marketplace/constants/ValidationCodeConstants.sol"; + +// Strategies +import {StrategyCollectionOffer} from "@hypercerts/marketplace/executionStrategies/StrategyCollectionOffer.sol"; + +// Base test +import {ProtocolBase} from "../ProtocolBase.t.sol"; + +// Constants +import {ONE_HUNDRED_PERCENT_IN_BP} from "@hypercerts/marketplace/constants/NumericConstants.sol"; + +// Enums +import {CollectionType} from "@hypercerts/marketplace/enums/CollectionType.sol"; +import {QuoteType} from "@hypercerts/marketplace/enums/QuoteType.sol"; + +contract CollectionOrdersTest is ProtocolBase { + StrategyCollectionOffer public strategyCollectionOffer; + bytes4 public selectorNoProof = strategyCollectionOffer.executeCollectionStrategyWithTakerAsk.selector; + bytes4 public selectorWithProof = strategyCollectionOffer.executeCollectionStrategyWithTakerAskWithProof.selector; + + uint256 private constant price = 1 ether; // Fixed price of sale + bytes32 private constant mockMerkleRoot = bytes32(keccak256("Mock")); // Mock merkle root + + function setUp() public { + _setUp(); + _setUpNewStrategies(); + } + + function _setUpNewStrategies() private asPrankedUser(_owner) { + strategyCollectionOffer = new StrategyCollectionOffer(); + _addStrategy(address(strategyCollectionOffer), selectorNoProof, true); + _addStrategy(address(strategyCollectionOffer), selectorWithProof, true); + } + + function testNewStrategies() public { + _assertStrategyAttributes(address(strategyCollectionOffer), selectorNoProof, true); + + ( + bool strategyIsActive, + uint16 strategyStandardProtocolFee, + uint16 strategyMinTotalFee, + uint16 strategyMaxProtocolFee, + bytes4 strategySelector, + bool strategyIsMakerBid, + address strategyImplementation + ) = looksRareProtocol.strategyInfo(2); + + assertTrue(strategyIsActive); + assertEq(strategyStandardProtocolFee, _standardProtocolFeeBp); + assertEq(strategyMinTotalFee, _minTotalFeeBp); + assertEq(strategyMaxProtocolFee, _maxProtocolFeeBp); + assertEq(strategySelector, selectorWithProof); + assertTrue(strategyIsMakerBid); + assertEq(strategyImplementation, address(strategyCollectionOffer)); + } + + function testMakerBidAmountsLengthNotOne() public { + _setUpUsers(); + + (OrderStructs.Maker memory makerBid, OrderStructs.Taker memory takerAsk) = + _createMockMakerBidAndTakerAsk(address(mockERC721), address(weth)); + + // Adjust strategy for collection order and sign order + // Change array to make it bigger than expected + uint256[] memory amounts = new uint256[](2); + amounts[0] = 1; + makerBid.strategyId = 1; + makerBid.amounts = amounts; + takerAsk.additionalParameters = abi.encode(1, 1); + bytes memory signature = _signMakerOrder(makerBid, makerUserPK); + + _assertOrderIsInvalid(makerBid, false); + _assertMakerOrderReturnValidationCode(makerBid, signature, MAKER_ORDER_PERMANENTLY_INVALID_NON_STANDARD_SALE); + + vm.expectRevert(OrderInvalid.selector); + looksRareProtocol.executeTakerAsk(takerAsk, makerBid, signature, _EMPTY_MERKLE_TREE); + + // With proof + makerBid.strategyId = 2; + makerBid.additionalParameters = abi.encode(mockMerkleRoot); + signature = _signMakerOrder(makerBid, makerUserPK); + + _assertOrderIsInvalid(makerBid, true); + _assertMakerOrderReturnValidationCode(makerBid, signature, MAKER_ORDER_PERMANENTLY_INVALID_NON_STANDARD_SALE); + + vm.expectRevert(OrderInvalid.selector); + looksRareProtocol.executeTakerAsk(takerAsk, makerBid, signature, _EMPTY_MERKLE_TREE); + } + + function testZeroAmount() public { + _setUpUsers(); + + (OrderStructs.Maker memory makerBid, OrderStructs.Taker memory takerAsk) = + _createMockMakerBidAndTakerAsk(address(mockERC721), address(weth)); + + uint256[] memory amounts = new uint256[](1); + amounts[0] = 0; + makerBid.amounts = amounts; + makerBid.strategyId = 1; + makerBid.additionalParameters = abi.encode(mockMerkleRoot); + takerAsk.additionalParameters = abi.encode(1, 1); + bytes memory signature = _signMakerOrder(makerBid, makerUserPK); + + _assertOrderIsInvalid(makerBid, false); + _assertMakerOrderReturnValidationCode(makerBid, signature, MAKER_ORDER_PERMANENTLY_INVALID_NON_STANDARD_SALE); + + vm.prank(takerUser); + vm.expectRevert(AmountInvalid.selector); + looksRareProtocol.executeTakerAsk(takerAsk, makerBid, signature, _EMPTY_MERKLE_TREE); + } + + /** + * Any itemId for ERC721 (where royalties come from the registry) is sold through a collection taker ask using WETH. + * We use fuzzing to generate the tokenId that is sold. + */ + function testTakerAskCollectionOrderERC721(uint256 tokenId) public { + _setUpUsers(); + + OrderStructs.Maker memory makerBid = _createSingleItemMakerOrder({ + quoteType: QuoteType.Bid, + globalNonce: 0, + subsetNonce: 0, + strategyId: 1, + collectionType: CollectionType.ERC721, + orderNonce: 0, + collection: address(mockERC721), + currency: address(weth), + signer: makerUser, + price: price, + itemId: 0 // Not used + }); + + // Sign order + bytes memory signature = _signMakerOrder(makerBid, makerUserPK); + + // Mint asset + mockERC721.mint(takerUser, tokenId); + + // Prepare the taker ask + OrderStructs.Taker memory takerAsk = OrderStructs.Taker(takerUser, abi.encode(tokenId, 1)); + + _assertOrderIsValid(makerBid, false); + _assertValidMakerOrder(makerBid, signature); + + // Execute taker ask transaction + vm.prank(takerUser); + looksRareProtocol.executeTakerAsk(takerAsk, makerBid, signature, _EMPTY_MERKLE_TREE); + + _assertSuccessfulTakerAsk(makerBid, tokenId); + } + + /** + * A collection offer with merkle tree criteria + */ + function testTakerAskCollectionOrderWithMerkleTreeERC721() public { + _setUpUsers(); + + OrderStructs.Maker memory makerBid = _createSingleItemMakerOrder({ + quoteType: QuoteType.Bid, + globalNonce: 0, + subsetNonce: 0, + strategyId: 2, + collectionType: CollectionType.ERC721, + orderNonce: 0, + collection: address(mockERC721), + currency: address(weth), + signer: makerUser, + price: price, + itemId: 0 // Not used + }); + + uint256 itemIdInMerkleTree = 2; + (bytes32 merkleRoot, bytes32[] memory proof) = _mintNFTsToOwnerAndGetMerkleRootAndProof({ + owner: takerUser, + numberOfItemsInMerkleTree: 5, + itemIdInMerkleTree: itemIdInMerkleTree + }); + + makerBid.additionalParameters = abi.encode(merkleRoot); + + // Sign order + bytes memory signature = _signMakerOrder(makerBid, makerUserPK); + + // Prepare the taker ask + OrderStructs.Taker memory takerAsk = OrderStructs.Taker(takerUser, abi.encode(itemIdInMerkleTree, proof)); + + // Verify validity of maker bid order + _assertOrderIsValid(makerBid, true); + _assertValidMakerOrder(makerBid, signature); + + // Execute taker ask transaction + vm.prank(takerUser); + looksRareProtocol.executeTakerAsk(takerAsk, makerBid, signature, _EMPTY_MERKLE_TREE); + + _assertSuccessfulTakerAsk(makerBid, itemIdInMerkleTree); + } + + function testTakerAskCannotExecuteWithInvalidProof(uint256 itemIdSold) public { + vm.assume(itemIdSold > 5); + _setUpUsers(); + + OrderStructs.Maker memory makerBid = _createSingleItemMakerOrder({ + quoteType: QuoteType.Bid, + globalNonce: 0, + subsetNonce: 0, + strategyId: 2, + collectionType: CollectionType.ERC721, + orderNonce: 0, + collection: address(mockERC721), + currency: address(weth), + signer: makerUser, + price: price, + itemId: 0 // Not used + }); + + (bytes32 merkleRoot, bytes32[] memory proof) = _mintNFTsToOwnerAndGetMerkleRootAndProof({ + owner: takerUser, + numberOfItemsInMerkleTree: 5, + // Doesn't matter what itemIdInMerkleTree is as we are are going to tamper with the proof + itemIdInMerkleTree: 4 + }); + makerBid.additionalParameters = abi.encode(merkleRoot); + + // Sign order + bytes memory signature = _signMakerOrder(makerBid, makerUserPK); + + // Prepare the taker ask + proof[0] = bytes32(0); // Tamper with the proof + OrderStructs.Taker memory takerAsk = OrderStructs.Taker(takerUser, abi.encode(itemIdSold, proof)); + + // Verify validity of maker bid order + _assertOrderIsValid(makerBid, true); + _assertValidMakerOrder(makerBid, signature); + + vm.prank(takerUser); + vm.expectRevert(MerkleProofInvalid.selector); + looksRareProtocol.executeTakerAsk(takerAsk, makerBid, signature, _EMPTY_MERKLE_TREE); + } + + function testInvalidAmounts() public { + _setUpUsers(); + + OrderStructs.Maker memory makerBid = _createSingleItemMakerOrder({ + quoteType: QuoteType.Bid, + globalNonce: 0, + subsetNonce: 0, + strategyId: 1, + collectionType: CollectionType.ERC721, + orderNonce: 0, + collection: address(mockERC721), + currency: address(weth), + signer: makerUser, + price: price, + itemId: 0 + }); + + // Prepare the taker ask + OrderStructs.Taker memory takerAsk = OrderStructs.Taker(takerUser, abi.encode(5)); + + // 1. Amount is 0 (without merkle proof) + makerBid.amounts[0] = 0; + bytes memory signature = _signMakerOrder(makerBid, makerUserPK); + _assertOrderIsInvalid(makerBid, false); + _assertMakerOrderReturnValidationCode(makerBid, signature, MAKER_ORDER_PERMANENTLY_INVALID_NON_STANDARD_SALE); + + vm.prank(takerUser); + vm.expectRevert(AmountInvalid.selector); + looksRareProtocol.executeTakerAsk(takerAsk, makerBid, signature, _EMPTY_MERKLE_TREE); + + // 2. Amount is too high for ERC721 (without merkle proof) + makerBid.amounts[0] = 2; + signature = _signMakerOrder(makerBid, makerUserPK); + _assertOrderIsInvalid(makerBid, false); + _assertMakerOrderReturnValidationCode(makerBid, signature, MAKER_ORDER_PERMANENTLY_INVALID_NON_STANDARD_SALE); + + vm.prank(takerUser); + vm.expectRevert(AmountInvalid.selector); + looksRareProtocol.executeTakerAsk(takerAsk, makerBid, signature, _EMPTY_MERKLE_TREE); + + // 3. Amount is 0 (with merkle proof) + makerBid.strategyId = 2; + uint256 itemIdInMerkleTree = 5; + (bytes32 merkleRoot, bytes32[] memory proof) = _mintNFTsToOwnerAndGetMerkleRootAndProof({ + owner: takerUser, + numberOfItemsInMerkleTree: 6, + itemIdInMerkleTree: itemIdInMerkleTree + }); + + makerBid.additionalParameters = abi.encode(merkleRoot); + makerBid.amounts[0] = 0; + signature = _signMakerOrder(makerBid, makerUserPK); + + takerAsk.additionalParameters = abi.encode(itemIdInMerkleTree, proof); + + _assertOrderIsInvalid(makerBid, true); + _assertMakerOrderReturnValidationCode(makerBid, signature, MAKER_ORDER_PERMANENTLY_INVALID_NON_STANDARD_SALE); + + vm.prank(takerUser); + vm.expectRevert(AmountInvalid.selector); + looksRareProtocol.executeTakerAsk(takerAsk, makerBid, signature, _EMPTY_MERKLE_TREE); + + // 4. Amount is too high for ERC721 (with merkle proof) + makerBid.amounts[0] = 2; + signature = _signMakerOrder(makerBid, makerUserPK); + _assertOrderIsInvalid(makerBid, true); + _assertMakerOrderReturnValidationCode(makerBid, signature, MAKER_ORDER_PERMANENTLY_INVALID_NON_STANDARD_SALE); + + vm.prank(takerUser); + vm.expectRevert(AmountInvalid.selector); + looksRareProtocol.executeTakerAsk(takerAsk, makerBid, signature, _EMPTY_MERKLE_TREE); + } + + function testMerkleRootLengthIsNot32() public { + OrderStructs.Maker memory makerBid = _createSingleItemMakerOrder({ + quoteType: QuoteType.Bid, + globalNonce: 0, + subsetNonce: 0, + strategyId: 2, + collectionType: CollectionType.ERC721, + orderNonce: 0, + collection: address(mockERC721), + currency: address(weth), + signer: makerUser, + price: price, + itemId: 0 + }); + + bytes memory signature = _signMakerOrder(makerBid, makerUserPK); + + _assertOrderIsInvalid(makerBid, true); + _assertMakerOrderReturnValidationCode(makerBid, signature, MAKER_ORDER_PERMANENTLY_INVALID_NON_STANDARD_SALE); + + vm.prank(takerUser); + vm.expectRevert(); // It should revert without data (since the root cannot be extracted since the + // additionalParameters length is 0) + looksRareProtocol.executeTakerAsk(_genericTakerOrder(), makerBid, signature, _EMPTY_MERKLE_TREE); + } + + function testInvalidSelector() public { + OrderStructs.Maker memory makerBid = _createSingleItemMakerOrder({ + quoteType: QuoteType.Bid, + globalNonce: 0, + subsetNonce: 0, + strategyId: 3, + collectionType: CollectionType.ERC721, + orderNonce: 0, + collection: address(mockERC721), + currency: address(weth), + signer: makerUser, + price: price, + itemId: 0 + }); + + (bool orderIsValid, bytes4 errorSelector) = strategyCollectionOffer.isMakerOrderValid(makerBid, bytes4(0)); + assertFalse(orderIsValid); + assertEq(errorSelector, FunctionSelectorInvalid.selector); + } + + function testWrongQuoteType() public { + OrderStructs.Maker memory makerAsk = _createSingleItemMakerOrder({ + quoteType: QuoteType.Ask, + globalNonce: 0, + subsetNonce: 0, + strategyId: 2, + collectionType: CollectionType.ERC721, + orderNonce: 0, + collection: address(mockERC721), + currency: address(weth), + signer: makerUser, + price: price, + itemId: 0 + }); + + (bool orderIsValid, bytes4 errorSelector) = strategyCollectionOffer.isMakerOrderValid(makerAsk, selectorNoProof); + + assertFalse(orderIsValid); + assertEq(errorSelector, QuoteTypeInvalid.selector); + } + + function _assertOrderIsValid(OrderStructs.Maker memory makerBid, bool withProof) private { + (bool orderIsValid, bytes4 errorSelector) = + strategyCollectionOffer.isMakerOrderValid(makerBid, withProof ? selectorWithProof : selectorNoProof); + assertTrue(orderIsValid); + assertEq(errorSelector, _EMPTY_BYTES4); + } + + function _assertOrderIsInvalid(OrderStructs.Maker memory makerBid, bool withProof) private { + (bool orderIsValid, bytes4 errorSelector) = + strategyCollectionOffer.isMakerOrderValid(makerBid, withProof ? selectorWithProof : selectorNoProof); + + assertFalse(orderIsValid); + assertEq(errorSelector, OrderInvalid.selector); + } + + function _mintNFTsToOwnerAndGetMerkleRootAndProof( + address owner, + uint256 numberOfItemsInMerkleTree, + uint256 itemIdInMerkleTree + ) private returns (bytes32 merkleRoot, bytes32[] memory proof) { + require(itemIdInMerkleTree < numberOfItemsInMerkleTree, "Invalid itemIdInMerkleTree"); + + // Initialize Merkle Tree + Merkle m = new Merkle(); + + bytes32[] memory merkleTreeIds = new bytes32[](numberOfItemsInMerkleTree); + for (uint256 i; i < numberOfItemsInMerkleTree; i++) { + mockERC721.mint(owner, i); + merkleTreeIds[i] = keccak256(abi.encodePacked(i)); + } + + // Compute merkle root + merkleRoot = m.getRoot(merkleTreeIds); + proof = m.getProof(merkleTreeIds, itemIdInMerkleTree); + + assertTrue(m.verifyProof(merkleRoot, proof, merkleTreeIds[itemIdInMerkleTree])); + } + + function _assertSuccessfulTakerAsk(OrderStructs.Maker memory makerBid, uint256 tokenId) private { + // Taker user has received the asset + assertEq(mockERC721.ownerOf(tokenId), makerUser); + // Maker bid user pays the whole price + assertEq(weth.balanceOf(makerUser), _initialWETHBalanceUser - price); + // Taker ask user receives 99.5% of the whole price (0.5% protocol) + assertEq( + weth.balanceOf(takerUser), + _initialWETHBalanceUser + (price * _sellerProceedBpWithStandardProtocolFeeBp) / ONE_HUNDRED_PERCENT_IN_BP + ); + // Verify the nonce is marked as executed + assertEq(looksRareProtocol.userOrderNonce(makerUser, makerBid.orderNonce), MAGIC_VALUE_ORDER_NONCE_EXECUTED); + } +} diff --git a/contracts/test/foundry/marketplace/executionStrategies/DutchAuctionOrders.t.sol b/contracts/test/foundry/marketplace/executionStrategies/DutchAuctionOrders.t.sol new file mode 100644 index 00000000..4370cb3d --- /dev/null +++ b/contracts/test/foundry/marketplace/executionStrategies/DutchAuctionOrders.t.sol @@ -0,0 +1,407 @@ +/// SPDX-License-Identifier: MIT +pragma solidity 0.8.17; + +// Libraries and interfaces +import {OrderStructs} from "@hypercerts/marketplace/libraries/OrderStructs.sol"; +import {IExecutionManager} from "@hypercerts/marketplace/interfaces/IExecutionManager.sol"; +import {IStrategyManager} from "@hypercerts/marketplace/interfaces/IStrategyManager.sol"; + +// Shared errors +import { + AmountInvalid, + BidTooLow, + OrderInvalid, + FunctionSelectorInvalid, + QuoteTypeInvalid +} from "@hypercerts/marketplace/errors/SharedErrors.sol"; +import { + STRATEGY_NOT_ACTIVE, + MAKER_ORDER_TEMPORARILY_INVALID_NON_STANDARD_SALE, + MAKER_ORDER_PERMANENTLY_INVALID_NON_STANDARD_SALE +} from "@hypercerts/marketplace/constants/ValidationCodeConstants.sol"; + +// Strategies +import {StrategyDutchAuction} from "@hypercerts/marketplace/executionStrategies/StrategyDutchAuction.sol"; + +// Other tests +import {ProtocolBase} from "../ProtocolBase.t.sol"; + +// Constants +import {ONE_HUNDRED_PERCENT_IN_BP} from "@hypercerts/marketplace/constants/NumericConstants.sol"; + +// Enums +import {CollectionType} from "@hypercerts/marketplace/enums/CollectionType.sol"; +import {QuoteType} from "@hypercerts/marketplace/enums/QuoteType.sol"; + +contract DutchAuctionOrdersTest is ProtocolBase, IStrategyManager { + StrategyDutchAuction public strategyDutchAuction; + bytes4 public selector = StrategyDutchAuction.executeStrategyWithTakerBid.selector; + + function setUp() public { + _setUp(); + } + + function _setUpNewStrategy() private asPrankedUser(_owner) { + strategyDutchAuction = new StrategyDutchAuction(); + _addStrategy(address(strategyDutchAuction), selector, false); + } + + function _createMakerAskAndTakerBid( + uint256 numberOfItems, + uint256 numberOfAmounts, + uint256 startPrice, + uint256 endPrice, + uint256 endTime + ) private returns (OrderStructs.Maker memory newMakerAsk, OrderStructs.Taker memory newTakerBid) { + uint256[] memory itemIds = new uint256[](numberOfItems); + for (uint256 i; i < numberOfItems;) { + mockERC721.mint(makerUser, i + 1); + itemIds[i] = i + 1; + unchecked { + ++i; + } + } + + uint256[] memory amounts = new uint256[](numberOfAmounts); + for (uint256 i; i < numberOfAmounts;) { + amounts[i] = 1; + unchecked { + ++i; + } + } + + newMakerAsk = _createSingleItemMakerOrder({ + quoteType: QuoteType.Ask, + globalNonce: 0, + subsetNonce: 0, + strategyId: 1, + collectionType: CollectionType.ERC721, + orderNonce: 0, + collection: address(mockERC721), + currency: address(weth), + signer: makerUser, + price: endPrice, + itemId: 1 + }); + + newMakerAsk.itemIds = itemIds; + newMakerAsk.amounts = amounts; + + newMakerAsk.endTime = endTime; + newMakerAsk.additionalParameters = abi.encode(startPrice); + + // Using startPrice as the maxPrice + newTakerBid = OrderStructs.Taker(takerUser, abi.encode(startPrice)); + } + + function testNewStrategy() public { + _setUpNewStrategy(); + _assertStrategyAttributes(address(strategyDutchAuction), selector, false); + } + + function _fuzzAssumptions(uint256 _startPrice, uint256 _duration, uint256 _decayPerSecond, uint256 _elapsedTime) + private + returns (uint256 startPrice, uint256 duration, uint256 decayPerSecond, uint256 elapsedTime) + { + // Bound instead of assume to handle too many rejections + // These limits should be realistically way more than enough + // vm.assume(duration > 0 && duration <= 31_536_000); + // Assume the NFT is worth at least 0.01 USD at today's ETH price (2023-01-13 18:00:00 UTC) + // vm.assume(startPrice > 1e12 && startPrice <= 100_000 ether); + // vm.assume(decayPerSecond > 0 && decayPerSecond < startPrice); + // vm.assume(elapsedTime <= duration && startPrice > decayPerSecond * duration); + + duration = bound(_duration, 1, 31_536_600); + startPrice = bound(_startPrice, 1e12, 100_000 ether); + decayPerSecond = bound(_decayPerSecond, 1, startPrice); + + vm.assume(_elapsedTime <= duration && startPrice > decayPerSecond * duration); + elapsedTime = _elapsedTime; + } + + function _calculatePrices(uint256 startPrice, uint256 duration, uint256 decayPerSecond, uint256 elapsedTime) + private + pure + returns (uint256 endPrice, uint256 executionPrice) + { + endPrice = startPrice - decayPerSecond * duration; + uint256 discount = decayPerSecond * elapsedTime; + executionPrice = startPrice - discount; + } + + function testDutchAuction(uint256 _startPrice, uint256 _duration, uint256 _decayPerSecond, uint256 _elapsedTime) + public + { + (uint256 startPrice, uint256 duration, uint256 decayPerSecond, uint256 elapsedTime) = + _fuzzAssumptions(_startPrice, _duration, _decayPerSecond, _elapsedTime); + _setUpUsers(); + _setUpNewStrategy(); + + (uint256 endPrice, uint256 executionPrice) = _calculatePrices(startPrice, duration, decayPerSecond, elapsedTime); + + deal(address(weth), takerUser, executionPrice); + + (OrderStructs.Maker memory makerAsk, OrderStructs.Taker memory takerBid) = _createMakerAskAndTakerBid({ + numberOfItems: 1, + numberOfAmounts: 1, + startPrice: startPrice, + endPrice: endPrice, + endTime: block.timestamp + duration + }); + + // Sign order + bytes memory signature = _signMakerOrder(makerAsk, makerUserPK); + + _assertOrderIsValid(makerAsk); + _assertValidMakerOrder(makerAsk, signature); + + vm.warp(block.timestamp + elapsedTime); + + // Execute taker bid transaction + vm.prank(takerUser); + looksRareProtocol.executeTakerBid(takerBid, makerAsk, signature, _EMPTY_MERKLE_TREE); + + // Taker user has received the asset + assertEq(mockERC721.ownerOf(1), takerUser); + + // Taker bid user pays the whole price + assertEq(weth.balanceOf(takerUser), 0, "taker balance incorrect"); + // Maker ask user receives 99.5% of the whole price (0.5% protocol) + uint256 protocolFee = (executionPrice * _standardProtocolFeeBp) / ONE_HUNDRED_PERCENT_IN_BP; + assertEq( + weth.balanceOf(makerUser), + _initialWETHBalanceUser + (executionPrice - protocolFee), + "maker balance incorrect" + ); + } + + function testStartPriceTooLow(uint256 _startPrice, uint256 _duration, uint256 _decayPerSecond, uint256 _elapsedTime) + public + { + (uint256 startPrice, uint256 duration, uint256 decayPerSecond, uint256 elapsedTime) = + _fuzzAssumptions(_startPrice, _duration, _decayPerSecond, _elapsedTime); + _setUpUsers(); + _setUpNewStrategy(); + + (uint256 endPrice, uint256 executionPrice) = _calculatePrices(startPrice, duration, decayPerSecond, elapsedTime); + deal(address(weth), takerUser, executionPrice); + + (OrderStructs.Maker memory makerAsk, OrderStructs.Taker memory takerBid) = _createMakerAskAndTakerBid({ + numberOfItems: 1, + numberOfAmounts: 1, + startPrice: startPrice, + endPrice: endPrice, + endTime: block.timestamp + duration + }); + + makerAsk.price = startPrice + 1 wei; + + // Sign order + bytes memory signature = _signMakerOrder(makerAsk, makerUserPK); + + bytes4 errorSelector = _assertOrderIsInvalid(makerAsk); + _assertMakerOrderReturnValidationCode(makerAsk, signature, MAKER_ORDER_PERMANENTLY_INVALID_NON_STANDARD_SALE); + + vm.expectRevert(errorSelector); + vm.prank(takerUser); + looksRareProtocol.executeTakerBid(takerBid, makerAsk, signature, _EMPTY_MERKLE_TREE); + } + + function testTakerBidTooLow(uint256 _startPrice, uint256 _duration, uint256 _decayPerSecond, uint256 _elapsedTime) + public + { + (uint256 startPrice, uint256 duration, uint256 decayPerSecond, uint256 elapsedTime) = + _fuzzAssumptions(_startPrice, _duration, _decayPerSecond, _elapsedTime); + _setUpUsers(); + _setUpNewStrategy(); + + (uint256 endPrice, uint256 executionPrice) = _calculatePrices(startPrice, duration, decayPerSecond, elapsedTime); + deal(address(weth), takerUser, executionPrice); + + (OrderStructs.Maker memory makerAsk, OrderStructs.Taker memory takerBid) = _createMakerAskAndTakerBid({ + numberOfItems: 1, + numberOfAmounts: 1, + startPrice: startPrice, + endPrice: endPrice, + endTime: block.timestamp + duration + }); + + takerBid.additionalParameters = abi.encode(executionPrice - 1 wei); + + // Sign order + bytes memory signature = _signMakerOrder(makerAsk, makerUserPK); + + // Valid, taker struct validation only happens during execution + _assertOrderIsValid(makerAsk); + _assertValidMakerOrder(makerAsk, signature); + + vm.expectRevert(BidTooLow.selector); + vm.prank(takerUser); + looksRareProtocol.executeTakerBid(takerBid, makerAsk, signature, _EMPTY_MERKLE_TREE); + } + + function testInactiveStrategy() public { + _setUpUsers(); + _setUpNewStrategy(); + (OrderStructs.Maker memory makerAsk, OrderStructs.Taker memory takerBid) = _createMakerAskAndTakerBid({ + numberOfItems: 1, + numberOfAmounts: 1, + startPrice: 10 ether, + endPrice: 1 ether, + endTime: block.timestamp + 1 hours + }); + + vm.prank(_owner); + looksRareProtocol.updateStrategy(1, false, _standardProtocolFeeBp, _minTotalFeeBp); + + // Sign order + bytes memory signature = _signMakerOrder(makerAsk, makerUserPK); + + _assertOrderIsValid(makerAsk); + _assertMakerOrderReturnValidationCode(makerAsk, signature, STRATEGY_NOT_ACTIVE); + + vm.prank(takerUser); + vm.expectRevert(abi.encodeWithSelector(IExecutionManager.StrategyNotAvailable.selector, 1)); + looksRareProtocol.executeTakerBid(takerBid, makerAsk, signature, _EMPTY_MERKLE_TREE); + } + + function testZeroItemIdsLength() public { + _setUpUsers(); + _setUpNewStrategy(); + (OrderStructs.Maker memory makerAsk, OrderStructs.Taker memory takerBid) = _createMakerAskAndTakerBid({ + numberOfItems: 0, + numberOfAmounts: 0, + startPrice: 10 ether, + endPrice: 1 ether, + endTime: block.timestamp + 1 hours + }); + + // Sign order + bytes memory signature = _signMakerOrder(makerAsk, makerUserPK); + + bytes4 errorSelector = _assertOrderIsInvalid(makerAsk); + _assertMakerOrderReturnValidationCode(makerAsk, signature, MAKER_ORDER_PERMANENTLY_INVALID_NON_STANDARD_SALE); + + vm.expectRevert(errorSelector); + vm.prank(takerUser); + looksRareProtocol.executeTakerBid(takerBid, makerAsk, signature, _EMPTY_MERKLE_TREE); + } + + function testItemIdsAndAmountsLengthMismatch() public { + _setUpUsers(); + _setUpNewStrategy(); + (OrderStructs.Maker memory makerAsk, OrderStructs.Taker memory takerBid) = _createMakerAskAndTakerBid({ + numberOfItems: 1, + numberOfAmounts: 2, + startPrice: 10 ether, + endPrice: 1 ether, + endTime: block.timestamp + 1 hours + }); + + // Sign order + bytes memory signature = _signMakerOrder(makerAsk, makerUserPK); + + bytes4 errorSelector = _assertOrderIsInvalid(makerAsk); + _assertMakerOrderReturnValidationCode(makerAsk, signature, MAKER_ORDER_PERMANENTLY_INVALID_NON_STANDARD_SALE); + + vm.expectRevert(errorSelector); + vm.prank(takerUser); + looksRareProtocol.executeTakerBid(takerBid, makerAsk, signature, _EMPTY_MERKLE_TREE); + } + + function testInvalidAmounts() public { + _setUpUsers(); + _setUpNewStrategy(); + + // 1. Amount = 0 + (OrderStructs.Maker memory makerAsk, OrderStructs.Taker memory takerBid) = _createMakerAskAndTakerBid({ + numberOfItems: 1, + numberOfAmounts: 1, + startPrice: 10 ether, + endPrice: 1 ether, + endTime: block.timestamp + 1 hours + }); + + makerAsk.amounts[0] = 0; + + // Sign order + bytes memory signature = _signMakerOrder(makerAsk, makerUserPK); + + bytes4 errorSelector = _assertOrderIsInvalid(makerAsk); + _assertMakerOrderReturnValidationCode(makerAsk, signature, MAKER_ORDER_PERMANENTLY_INVALID_NON_STANDARD_SALE); + + vm.expectRevert(AmountInvalid.selector); + vm.prank(takerUser); + looksRareProtocol.executeTakerBid(takerBid, makerAsk, signature, _EMPTY_MERKLE_TREE); + + // 2. ERC721 amount > 1 + makerAsk.amounts[0] = 2; + signature = _signMakerOrder(makerAsk, makerUserPK); + + errorSelector = _assertOrderIsInvalid(makerAsk); + _assertMakerOrderReturnValidationCode(makerAsk, signature, MAKER_ORDER_PERMANENTLY_INVALID_NON_STANDARD_SALE); + + vm.prank(takerUser); + vm.expectRevert(AmountInvalid.selector); + looksRareProtocol.executeTakerBid(takerBid, makerAsk, signature, _EMPTY_MERKLE_TREE); + } + + function testWrongQuoteType() public { + _setUpNewStrategy(); + + OrderStructs.Maker memory makerBid = _createSingleItemMakerOrder({ + quoteType: QuoteType.Bid, + globalNonce: 0, + subsetNonce: 0, + strategyId: 1, + collectionType: CollectionType.ERC721, + orderNonce: 0, + collection: address(mockERC721), + currency: address(weth), + signer: makerUser, + price: 1 ether, + itemId: 420 + }); + + (bool orderIsValid, bytes4 errorSelector) = strategyDutchAuction.isMakerOrderValid(makerBid, selector); + + assertFalse(orderIsValid); + assertEq(errorSelector, QuoteTypeInvalid.selector); + } + + function testInvalidSelector() public { + _setUpNewStrategy(); + + OrderStructs.Maker memory makerAsk = _createSingleItemMakerOrder({ + quoteType: QuoteType.Ask, + globalNonce: 0, + subsetNonce: 0, + strategyId: 2, + collectionType: CollectionType.ERC721, + orderNonce: 0, + collection: address(mockERC721), + currency: address(weth), + signer: makerUser, + price: 1 ether, + itemId: 420 + }); + + (bool orderIsValid, bytes4 errorSelector) = strategyDutchAuction.isMakerOrderValid(makerAsk, bytes4(0)); + assertFalse(orderIsValid); + assertEq(errorSelector, FunctionSelectorInvalid.selector); + } + + function _assertOrderIsValid(OrderStructs.Maker memory makerAsk) private { + (bool isValid, bytes4 errorSelector) = strategyDutchAuction.isMakerOrderValid(makerAsk, selector); + assertTrue(isValid); + assertEq(errorSelector, _EMPTY_BYTES4); + } + + function _assertOrderIsInvalid(OrderStructs.Maker memory makerAsk) private returns (bytes4) { + (bool isValid, bytes4 errorSelector) = strategyDutchAuction.isMakerOrderValid(makerAsk, selector); + assertFalse(isValid); + assertEq(errorSelector, OrderInvalid.selector); + + return errorSelector; + } +} diff --git a/contracts/test/foundry/marketplace/executionStrategies/ItemIdsRangeOrders.t.sol b/contracts/test/foundry/marketplace/executionStrategies/ItemIdsRangeOrders.t.sol new file mode 100644 index 00000000..07199143 --- /dev/null +++ b/contracts/test/foundry/marketplace/executionStrategies/ItemIdsRangeOrders.t.sol @@ -0,0 +1,486 @@ +/// SPDX-License-Identifier: MIT +pragma solidity 0.8.17; + +// Libraries and interfaces +import {OrderStructs} from "@hypercerts/marketplace/libraries/OrderStructs.sol"; +import {IExecutionManager} from "@hypercerts/marketplace/interfaces/IExecutionManager.sol"; +import {IStrategyManager} from "@hypercerts/marketplace/interfaces/IStrategyManager.sol"; + +// Shared errors +import { + OrderInvalid, FunctionSelectorInvalid, QuoteTypeInvalid +} from "@hypercerts/marketplace/errors/SharedErrors.sol"; +import { + STRATEGY_NOT_ACTIVE, + MAKER_ORDER_TEMPORARILY_INVALID_NON_STANDARD_SALE, + MAKER_ORDER_PERMANENTLY_INVALID_NON_STANDARD_SALE +} from "@hypercerts/marketplace/constants/ValidationCodeConstants.sol"; + +// Strategies +import {StrategyItemIdsRange} from "@hypercerts/marketplace/executionStrategies/StrategyItemIdsRange.sol"; + +// Base test +import {ProtocolBase} from "../ProtocolBase.t.sol"; + +// Enums +import {CollectionType} from "@hypercerts/marketplace/enums/CollectionType.sol"; +import {QuoteType} from "@hypercerts/marketplace/enums/QuoteType.sol"; + +contract ItemIdsRangeOrdersTest is ProtocolBase, IStrategyManager { + StrategyItemIdsRange public strategyItemIdsRange; + bytes4 public selector = StrategyItemIdsRange.executeStrategyWithTakerAsk.selector; + + function setUp() public { + _setUp(); + } + + function _setUpNewStrategy() private asPrankedUser(_owner) { + strategyItemIdsRange = new StrategyItemIdsRange(); + _addStrategy(address(strategyItemIdsRange), selector, true); + } + + function _offeredAmounts(uint256 length, uint256 amount) private pure returns (uint256[] memory offeredAmounts) { + offeredAmounts = new uint256[](length); + for (uint256 i; i < length; i++) { + offeredAmounts[i] = amount; + } + } + + function _createMakerBidAndTakerAsk(uint256 lowerBound, uint256 upperBound) + private + returns (OrderStructs.Maker memory newMakerBid, OrderStructs.Taker memory newTakerAsk) + { + uint256 mid = (lowerBound + upperBound) / 2; + + newMakerBid = _createMultiItemMakerOrder({ + quoteType: QuoteType.Bid, + globalNonce: 0, + subsetNonce: 0, + strategyId: 1, + collectionType: CollectionType.ERC721, + orderNonce: 0, + collection: address(mockERC721), + currency: address(weth), + signer: makerUser, + price: 1 ether, + itemIds: new uint256[](0), + amounts: new uint256[](0) + }); + + newMakerBid.additionalParameters = abi.encode(lowerBound, upperBound, 3); + + // This way, we can test + // 1. lower bound is 0 + // 2. lower bound is > 0, and 0 is excluded + if (lowerBound > 0) { + mockERC721.mint(takerUser, lowerBound - 1); + } + + mockERC721.mint(takerUser, lowerBound); + mockERC721.mint(takerUser, mid); + mockERC721.mint(takerUser, upperBound); + mockERC721.mint(takerUser, upperBound + 1); + + uint256[] memory takerAskItemIds = new uint256[](3); + takerAskItemIds[0] = lowerBound; + takerAskItemIds[1] = mid; + takerAskItemIds[2] = upperBound; + + newTakerAsk = OrderStructs.Taker({ + recipient: takerUser, + additionalParameters: abi.encode(takerAskItemIds, _offeredAmounts({length: 3, amount: 1})) + }); + } + + function testNewStrategy() public { + _setUpNewStrategy(); + _assertStrategyAttributes(address(strategyItemIdsRange), selector, true); + } + + function testTokenIdsRangeERC721(uint256 lowerBound, uint256 upperBound) public { + vm.assume(lowerBound < type(uint128).max && upperBound < type(uint128).max && lowerBound + 1 < upperBound); + + uint256 mid = (lowerBound + upperBound) / 2; + + _setUpUsers(); + _setUpNewStrategy(); + (OrderStructs.Maker memory makerBid, OrderStructs.Taker memory takerAsk) = + _createMakerBidAndTakerAsk(lowerBound, upperBound); + + // Sign order + bytes memory signature = _signMakerOrder(makerBid, makerUserPK); + + _assertOrderIsValid(makerBid); + _assertValidMakerOrder(makerBid, signature); + + // Execute taker ask transaction + vm.prank(takerUser); + looksRareProtocol.executeTakerAsk(takerAsk, makerBid, signature, _EMPTY_MERKLE_TREE); + + // Maker user has received the asset + assertEq(mockERC721.ownerOf(lowerBound), makerUser); + assertEq(mockERC721.ownerOf(mid), makerUser); + assertEq(mockERC721.ownerOf(upperBound), makerUser); + + // Maker bid user pays the whole price + assertEq(weth.balanceOf(makerUser), _initialWETHBalanceUser - 1 ether); + // Taker ask user receives 99.5% of the whole price (0.5% protocol fee) + assertEq(weth.balanceOf(takerUser), _initialWETHBalanceUser + 0.995 ether); + } + + function testTokenIdsRangeERC1155(uint256 lowerBound, uint256 upperBound) public { + vm.assume(lowerBound < type(uint128).max && upperBound < type(uint128).max && lowerBound + 1 < upperBound); + + uint256 mid = (lowerBound + upperBound) / 2; + + _setUpUsers(); + _setUpNewStrategy(); + + OrderStructs.Maker memory makerBid = _createMultiItemMakerOrder({ + quoteType: QuoteType.Bid, + globalNonce: 0, + subsetNonce: 0, + strategyId: 1, + collectionType: CollectionType.ERC1155, + orderNonce: 0, + collection: address(mockERC1155), + currency: address(weth), + signer: makerUser, + price: 1 ether, + itemIds: new uint256[](0), + amounts: new uint256[](0) + }); + + makerBid.additionalParameters = abi.encode(lowerBound, upperBound, 6); + + mockERC1155.mint(takerUser, lowerBound, 2); + mockERC1155.mint(takerUser, mid, 2); + mockERC1155.mint(takerUser, upperBound, 2); + + uint256[] memory takerAskItemIds = new uint256[](3); + takerAskItemIds[0] = lowerBound; + takerAskItemIds[1] = mid; + takerAskItemIds[2] = upperBound; + + OrderStructs.Taker memory takerAsk = OrderStructs.Taker({ + recipient: takerUser, + additionalParameters: abi.encode(takerAskItemIds, _offeredAmounts({length: 3, amount: 2})) + }); + + // Sign order + bytes memory signature = _signMakerOrder(makerBid, makerUserPK); + + _assertOrderIsValid(makerBid); + _assertValidMakerOrder(makerBid, signature); + + // Execute taker ask transaction + vm.prank(takerUser); + looksRareProtocol.executeTakerAsk(takerAsk, makerBid, signature, _EMPTY_MERKLE_TREE); + + // Maker user has received the asset + assertEq(mockERC1155.balanceOf(makerUser, lowerBound), 2); + assertEq(mockERC1155.balanceOf(makerUser, mid), 2); + assertEq(mockERC1155.balanceOf(makerUser, upperBound), 2); + + // Maker bid user pays the whole price + assertEq(weth.balanceOf(makerUser), _initialWETHBalanceUser - 1 ether); + // Taker ask user receives 99.5% of the whole price (0.5% protocol fee) + assertEq(weth.balanceOf(takerUser), _initialWETHBalanceUser + 0.995 ether); + } + + function testInvalidMakerBidAdditionalParameters() public { + _setUpUsers(); + _setUpNewStrategy(); + (OrderStructs.Maker memory makerBid, OrderStructs.Taker memory takerAsk) = _createMakerBidAndTakerAsk(5, 10); + + makerBid.additionalParameters = abi.encode(6, 9); + + bytes memory signature = _signMakerOrder(makerBid, makerUserPK); + + vm.expectRevert(); // EVM revert + strategyItemIdsRange.isMakerOrderValid(makerBid, selector); + + vm.expectRevert(); // EVM revert + orderValidator.checkMakerOrderValidity(makerBid, signature, _EMPTY_MERKLE_TREE); + + vm.expectRevert(); // EVM revert + vm.prank(takerUser); + looksRareProtocol.executeTakerAsk(takerAsk, makerBid, signature, _EMPTY_MERKLE_TREE); + } + + function testZeroDesiredAmount() public { + _setUpUsers(); + _setUpNewStrategy(); + (OrderStructs.Maker memory makerBid, OrderStructs.Taker memory takerAsk) = _createMakerBidAndTakerAsk(5, 10); + + makerBid.additionalParameters = abi.encode(5, 10, 0); + + bytes memory signature = _signMakerOrder(makerBid, makerUserPK); + + bytes4 errorSelector = _assertOrderIsInvalid(makerBid); + _assertMakerOrderReturnValidationCode(makerBid, signature, MAKER_ORDER_PERMANENTLY_INVALID_NON_STANDARD_SALE); + + vm.expectRevert(errorSelector); + vm.prank(takerUser); + looksRareProtocol.executeTakerAsk(takerAsk, makerBid, signature, _EMPTY_MERKLE_TREE); + } + + function testWrongQuoteType() public { + _setUpNewStrategy(); + (OrderStructs.Maker memory makerBid,) = _createMakerBidAndTakerAsk(5, 10); + makerBid.quoteType = QuoteType.Ask; + + (bool isValid, bytes4 errorSelector) = strategyItemIdsRange.isMakerOrderValid(makerBid, selector); + + assertFalse(isValid); + assertEq(errorSelector, QuoteTypeInvalid.selector); + } + + function testTakerAskItemIdsAmountsLengthMismatch() public { + _setUpUsers(); + _setUpNewStrategy(); + (OrderStructs.Maker memory makerBid, OrderStructs.Taker memory takerAsk) = _createMakerBidAndTakerAsk(5, 10); + + bytes memory signature = _signMakerOrder(makerBid, makerUserPK); + + _assertOrderIsValid(makerBid); + _assertValidMakerOrder(makerBid, signature); + + uint256[] memory takerAskItemIds = new uint256[](3); + takerAskItemIds[0] = 5; + takerAskItemIds[1] = 7; + takerAskItemIds[2] = 10; + takerAsk.additionalParameters = abi.encode(takerAskItemIds, _offeredAmounts({length: 4, amount: 1})); + + vm.prank(takerUser); + vm.expectRevert(OrderInvalid.selector); + looksRareProtocol.executeTakerAsk(takerAsk, makerBid, signature, _EMPTY_MERKLE_TREE); + } + + function testTakerAskRevertIfAmountIsZeroOrGreaterThanOneERC721() public { + _setUpUsers(); + _setUpNewStrategy(); + (OrderStructs.Maker memory makerBid, OrderStructs.Taker memory takerAsk) = _createMakerBidAndTakerAsk(5, 10); + + // Sign order + bytes memory signature = _signMakerOrder(makerBid, makerUserPK); + + uint256[] memory takerAskItemIds = new uint256[](3); + takerAskItemIds[0] = 5; + takerAskItemIds[1] = 7; + takerAskItemIds[2] = 10; + + uint256[] memory invalidAmounts = new uint256[](3); + invalidAmounts[0] = 1; + invalidAmounts[1] = 2; + invalidAmounts[2] = 2; + + takerAsk.additionalParameters = abi.encode(takerAskItemIds, invalidAmounts); + + // The maker bid order is still valid since the error comes from the taker ask amounts + _assertOrderIsValid(makerBid); + _assertValidMakerOrder(makerBid, signature); + + // It fails at 2nd item in the array (greater than 1) + vm.expectRevert(OrderInvalid.selector); + vm.prank(takerUser); + looksRareProtocol.executeTakerAsk(takerAsk, makerBid, signature, _EMPTY_MERKLE_TREE); + + // Re-adjust the amounts + invalidAmounts[0] = 0; + invalidAmounts[1] = 1; + invalidAmounts[2] = 1; + + takerAsk.additionalParameters = abi.encode(takerAskItemIds, invalidAmounts); + + // It now fails at 1st item in the array (equal to 0) + vm.expectRevert(OrderInvalid.selector); + vm.prank(takerUser); + looksRareProtocol.executeTakerAsk(takerAsk, makerBid, signature, _EMPTY_MERKLE_TREE); + } + + function testMakerBidItemIdsLowerBandHigherThanOrEqualToUpperBand() public { + _setUpUsers(); + _setUpNewStrategy(); + (OrderStructs.Maker memory makerBid, OrderStructs.Taker memory takerAsk) = _createMakerBidAndTakerAsk(5, 10); + + // lower band > upper band + makerBid.additionalParameters = abi.encode(5, 4, 1); + + // Sign order + bytes memory signature = _signMakerOrder(makerBid, makerUserPK); + + bytes4 errorSelector = _assertOrderIsInvalid(makerBid); + _assertMakerOrderReturnValidationCode(makerBid, signature, MAKER_ORDER_PERMANENTLY_INVALID_NON_STANDARD_SALE); + + vm.expectRevert(errorSelector); + vm.prank(takerUser); + looksRareProtocol.executeTakerAsk(takerAsk, makerBid, signature, _EMPTY_MERKLE_TREE); + + // lower band == upper band + makerBid.additionalParameters = abi.encode(5, 5, 1); + + // Sign order + signature = _signMakerOrder(makerBid, makerUserPK); + + vm.expectRevert(OrderInvalid.selector); + vm.prank(takerUser); + looksRareProtocol.executeTakerAsk(takerAsk, makerBid, signature, _EMPTY_MERKLE_TREE); + } + + function testTakerAskDuplicatedItemIds() public { + _setUpUsers(); + _setUpNewStrategy(); + (OrderStructs.Maker memory makerBid, OrderStructs.Taker memory takerAsk) = _createMakerBidAndTakerAsk(5, 10); + + uint256[] memory invalidItemIds = new uint256[](3); + invalidItemIds[0] = 5; + invalidItemIds[1] = 7; + invalidItemIds[2] = 7; + + takerAsk.additionalParameters = abi.encode(invalidItemIds, _offeredAmounts({length: 3, amount: 1})); + + // Sign order + bytes memory signature = _signMakerOrder(makerBid, makerUserPK); + + // Valid, taker struct validation only happens during execution + _assertOrderIsValid(makerBid); + _assertValidMakerOrder(makerBid, signature); + + vm.expectRevert(OrderInvalid.selector); + vm.prank(takerUser); + looksRareProtocol.executeTakerAsk(takerAsk, makerBid, signature, _EMPTY_MERKLE_TREE); + } + + function testTakerAskUnsortedItemIds() public { + _setUpUsers(); + _setUpNewStrategy(); + (OrderStructs.Maker memory makerBid, OrderStructs.Taker memory takerAsk) = _createMakerBidAndTakerAsk(5, 10); + + uint256[] memory invalidItemIds = new uint256[](3); + invalidItemIds[0] = 5; + invalidItemIds[1] = 10; + invalidItemIds[2] = 7; + + takerAsk.additionalParameters = abi.encode(invalidItemIds, _offeredAmounts({length: 3, amount: 1})); + + // Sign order + bytes memory signature = _signMakerOrder(makerBid, makerUserPK); + + // Valid, taker struct validation only happens during execution + _assertOrderIsValid(makerBid); + _assertValidMakerOrder(makerBid, signature); + + vm.expectRevert(OrderInvalid.selector); + vm.prank(takerUser); + looksRareProtocol.executeTakerAsk(takerAsk, makerBid, signature, _EMPTY_MERKLE_TREE); + } + + function testTakerAskOfferedAmountNotEqualToDesiredAmount() public { + _setUpUsers(); + _setUpNewStrategy(); + (OrderStructs.Maker memory makerBid, OrderStructs.Taker memory takerAsk) = _createMakerBidAndTakerAsk(5, 10); + + uint256[] memory itemIds = new uint256[](2); + itemIds[0] = 5; + itemIds[1] = 10; + + takerAsk.additionalParameters = abi.encode(itemIds, _offeredAmounts({length: 2, amount: 1})); + + // Sign order + bytes memory signature = _signMakerOrder(makerBid, makerUserPK); + + // Valid, taker struct validation only happens during execution + _assertOrderIsValid(makerBid); + _assertValidMakerOrder(makerBid, signature); + + vm.expectRevert(OrderInvalid.selector); + vm.prank(takerUser); + looksRareProtocol.executeTakerAsk(takerAsk, makerBid, signature, _EMPTY_MERKLE_TREE); + } + + function testTakerAskOfferedItemIdTooLow() public { + _testTakerAskOfferedItemIdOutOfRange(3, 4); + } + + function testTakerAskOfferedItemIdTooHigh() public { + _testTakerAskOfferedItemIdOutOfRange(11, 12); + } + + function _testTakerAskOfferedItemIdOutOfRange(uint256 itemIdOne, uint256 itemIdTwo) private { + _setUpUsers(); + _setUpNewStrategy(); + (OrderStructs.Maker memory makerBid, OrderStructs.Taker memory takerAsk) = _createMakerBidAndTakerAsk(5, 10); + uint256[] memory itemIds = new uint256[](2); + itemIds[0] = itemIdOne; + itemIds[1] = itemIdTwo; + + takerAsk.additionalParameters = abi.encode(itemIds, _offeredAmounts({length: 2, amount: 1})); + + // Sign order + bytes memory signature = _signMakerOrder(makerBid, makerUserPK); + + _assertOrderIsValid(makerBid); + _assertValidMakerOrder(makerBid, signature); + + vm.expectRevert(OrderInvalid.selector); + vm.prank(takerUser); + looksRareProtocol.executeTakerAsk(takerAsk, makerBid, signature, _EMPTY_MERKLE_TREE); + } + + function testInactiveStrategy() public { + _setUpUsers(); + _setUpNewStrategy(); + (OrderStructs.Maker memory makerBid, OrderStructs.Taker memory takerAsk) = _createMakerBidAndTakerAsk(5, 10); + + // Sign order + bytes memory signature = _signMakerOrder(makerBid, makerUserPK); + + vm.prank(_owner); + looksRareProtocol.updateStrategy(1, false, _standardProtocolFeeBp, _minTotalFeeBp); + + // Valid, taker struct validation only happens during execution + _assertOrderIsValid(makerBid); + // but... the OrderValidator catches this + _assertMakerOrderReturnValidationCode(makerBid, signature, STRATEGY_NOT_ACTIVE); + + vm.expectRevert(abi.encodeWithSelector(IExecutionManager.StrategyNotAvailable.selector, 1)); + vm.prank(takerUser); + looksRareProtocol.executeTakerAsk(takerAsk, makerBid, signature, _EMPTY_MERKLE_TREE); + } + + function testInvalidSelector() public { + _setUpNewStrategy(); + + OrderStructs.Maker memory makerBid = _createSingleItemMakerOrder({ + quoteType: QuoteType.Bid, + globalNonce: 0, + subsetNonce: 0, + strategyId: 2, + collectionType: CollectionType.ERC721, + orderNonce: 0, + collection: address(mockERC721), + currency: address(weth), + signer: makerUser, + price: 1 ether, + itemId: 0 + }); + + (bool orderIsValid, bytes4 errorSelector) = strategyItemIdsRange.isMakerOrderValid(makerBid, bytes4(0)); + assertFalse(orderIsValid); + assertEq(errorSelector, FunctionSelectorInvalid.selector); + } + + function _assertOrderIsValid(OrderStructs.Maker memory makerBid) private { + (bool isValid, bytes4 errorSelector) = strategyItemIdsRange.isMakerOrderValid(makerBid, selector); + assertTrue(isValid); + assertEq(errorSelector, _EMPTY_BYTES4); + } + + function _assertOrderIsInvalid(OrderStructs.Maker memory makerBid) private returns (bytes4) { + (bool isValid, bytes4 errorSelector) = strategyItemIdsRange.isMakerOrderValid(makerBid, selector); + assertFalse(isValid); + assertEq(errorSelector, OrderInvalid.selector); + return errorSelector; + } +} diff --git a/contracts/test/foundry/marketplace/executionStrategies/MultiFillCollectionOrders.t.sol b/contracts/test/foundry/marketplace/executionStrategies/MultiFillCollectionOrders.t.sol new file mode 100644 index 00000000..5fd15bda --- /dev/null +++ b/contracts/test/foundry/marketplace/executionStrategies/MultiFillCollectionOrders.t.sol @@ -0,0 +1,187 @@ +/// SPDX-License-Identifier: MIT +pragma solidity >=0.8.7; + +// Libraries +import {OrderStructs} from "@hypercerts/marketplace/libraries/OrderStructs.sol"; + +// Interfaces +import {IExecutionManager} from "@hypercerts/marketplace/interfaces/IExecutionManager.sol"; +import {IStrategyManager} from "@hypercerts/marketplace/interfaces/IStrategyManager.sol"; + +// Mock files and other tests +import {StrategyTestMultiFillCollectionOrder} from "../utils/StrategyTestMultiFillCollectionOrder.sol"; +import {ProtocolBase} from "../ProtocolBase.t.sol"; + +// Constants +import {ONE_HUNDRED_PERCENT_IN_BP} from "@hypercerts/marketplace/constants/NumericConstants.sol"; + +// Enums +import {CollectionType} from "@hypercerts/marketplace/enums/CollectionType.sol"; +import {QuoteType} from "@hypercerts/marketplace/enums/QuoteType.sol"; + +contract MultiFillCollectionOrdersTest is ProtocolBase, IStrategyManager { + uint256 private constant price = 1 ether; // Fixed price of sale + + bytes4 public selector = StrategyTestMultiFillCollectionOrder.executeStrategyWithTakerAsk.selector; + + StrategyTestMultiFillCollectionOrder public strategyMultiFillCollectionOrder; + + function setUp() public { + _setUp(); + } + + function _setUpNewStrategy() private asPrankedUser(_owner) { + strategyMultiFillCollectionOrder = new StrategyTestMultiFillCollectionOrder(address(looksRareProtocol)); + _addStrategy(address(strategyMultiFillCollectionOrder), selector, true); + } + + function testNewStrategy() public { + _setUpNewStrategy(); + _assertStrategyAttributes(address(strategyMultiFillCollectionOrder), selector, true); + } + + /** + * Maker bid user wants to buy 4 ERC721 items in a collection. The order can be filled in multiple parts. + * First takerUser sells 1 item. + * Second takerUser sells 3 items. + */ + function testMultiFill() public { + _setUpUsers(); + _setUpNewStrategy(); + + uint256 amountsToFill = 4; + + uint256[] memory itemIds = new uint256[](0); + uint256[] memory amounts = new uint256[](1); + amounts[0] = amountsToFill; + + OrderStructs.Maker memory makerBid = _createMultiItemMakerOrder({ + quoteType: QuoteType.Bid, + globalNonce: 0, + subsetNonce: 0, + strategyId: 1, // Multi-fill bid offer + collectionType: CollectionType.ERC721, + orderNonce: 0, + collection: address(mockERC721), + currency: address(weth), + signer: makerUser, + price: price, + itemIds: itemIds, + amounts: amounts + }); + + // Sign order + bytes memory signature = _signMakerOrder(makerBid, makerUserPK); + + itemIds = new uint256[](1); + amounts = new uint256[](1); + itemIds[0] = 0; + amounts[0] = 1; + + mockERC721.mint(takerUser, itemIds[0]); + + // Prepare the taker ask + OrderStructs.Taker memory takerAsk = OrderStructs.Taker(takerUser, abi.encode(itemIds, amounts)); + + // Execute the first taker ask transaction by the first taker user + vm.prank(takerUser); + looksRareProtocol.executeTakerAsk(takerAsk, makerBid, signature, _EMPTY_MERKLE_TREE); + + // Taker user has received the asset + assertEq(mockERC721.ownerOf(0), makerUser); + // Maker bid user pays the whole price + assertEq(weth.balanceOf(makerUser), _initialWETHBalanceUser - price); + // Taker ask user receives 99.5% of the whole price (0.5% protocol) + assertEq( + weth.balanceOf(takerUser), + _initialWETHBalanceUser + (price * _sellerProceedBpWithStandardProtocolFeeBp) / ONE_HUNDRED_PERCENT_IN_BP + ); + // Verify the nonce is not marked as executed + assertEq(looksRareProtocol.userOrderNonce(makerUser, makerBid.orderNonce), _computeOrderHash(makerBid)); + + // Second taker user actions + address secondTakerUser = address(420); + _setUpUser(secondTakerUser); + + itemIds = new uint256[](3); + amounts = new uint256[](3); + + itemIds[0] = 1; // tokenId = 1 + itemIds[1] = 2; // tokenId = 2 + itemIds[2] = 3; // tokenId = 3 + amounts[0] = 1; + amounts[1] = 1; + amounts[2] = 1; + + mockERC721.batchMint(secondTakerUser, itemIds); + + // Prepare the taker ask + takerAsk = OrderStructs.Taker(secondTakerUser, abi.encode(itemIds, amounts)); + + // Execute a second taker ask transaction from the second taker user + vm.prank(secondTakerUser); + looksRareProtocol.executeTakerAsk(takerAsk, makerBid, signature, _EMPTY_MERKLE_TREE); + + // Taker user has received the 3 assets + assertEq(mockERC721.ownerOf(1), makerUser); + assertEq(mockERC721.ownerOf(2), makerUser); + assertEq(mockERC721.ownerOf(3), makerUser); + + // Maker bid user pays the whole price + assertEq(weth.balanceOf(makerUser), _initialWETHBalanceUser - 4 * price); + // Taker ask user receives 99.5% of the whole price (0.5% protocol) + assertEq( + weth.balanceOf(secondTakerUser), + _initialWETHBalanceUser + + 3 * ((price * _sellerProceedBpWithStandardProtocolFeeBp) / ONE_HUNDRED_PERCENT_IN_BP) + ); + // Verify the nonce is now marked as executed + assertEq(looksRareProtocol.userOrderNonce(makerUser, makerBid.orderNonce), MAGIC_VALUE_ORDER_NONCE_EXECUTED); + } + + function testInactiveStrategy() public { + _setUpUsers(); + _setUpNewStrategy(); + + uint256 amountsToFill = 4; + + uint256[] memory itemIds = new uint256[](0); + uint256[] memory amounts = new uint256[](1); + amounts[0] = amountsToFill; + + OrderStructs.Maker memory makerBid = _createMultiItemMakerOrder({ + quoteType: QuoteType.Bid, + globalNonce: 0, + subsetNonce: 0, + strategyId: 1, // Multi-fill bid offer + collectionType: CollectionType.ERC721, + orderNonce: 0, + collection: address(mockERC721), + currency: address(weth), + signer: makerUser, + price: price, + itemIds: itemIds, + amounts: amounts + }); + + // Sign order + bytes memory signature = _signMakerOrder(makerBid, makerUserPK); + + vm.prank(_owner); + looksRareProtocol.updateStrategy(1, false, _standardProtocolFeeBp, _minTotalFeeBp); + + { + itemIds = new uint256[](1); + amounts = new uint256[](1); + itemIds[0] = 0; + amounts[0] = 1; + + mockERC721.mint(takerUser, itemIds[0]); + + // It should revert if strategy is not available + vm.prank(takerUser); + vm.expectRevert(abi.encodeWithSelector(IExecutionManager.StrategyNotAvailable.selector, 1)); + looksRareProtocol.executeTakerAsk(_genericTakerOrder(), makerBid, signature, _EMPTY_MERKLE_TREE); + } + } +} diff --git a/contracts/test/foundry/marketplace/utils/BytesLib.sol b/contracts/test/foundry/marketplace/utils/BytesLib.sol new file mode 100644 index 00000000..7d0a3ffa --- /dev/null +++ b/contracts/test/foundry/marketplace/utils/BytesLib.sol @@ -0,0 +1,71 @@ +// SPDX-License-Identifier: MIT +pragma solidity 0.8.17; + +/* + * @title Solidity Bytes Arrays Utils + * @author Gonçalo Sá + * @notice We only copied the `slice` function from the original https://github.com/GNSPS/solidity-bytes-utils + * as that's the only function needed. + * @dev Bytes tightly packed arrays utility library for ethereum contracts written in Solidity. + * The library lets you slice bytes arrays in memory. + */ +library BytesLib { + function slice(bytes memory _bytes, uint256 _start, uint256 _length) internal pure returns (bytes memory) { + require(_length + 31 >= _length, "slice_overflow"); + require(_bytes.length >= _start + _length, "slice_outOfBounds"); + + bytes memory tempBytes; + + assembly { + switch iszero(_length) + case 0 { + // Get a location of some free memory and store it in tempBytes as + // Solidity does for memory variables. + tempBytes := mload(0x40) + + // The first word of the slice result is potentially a partial + // word read from the original array. To read it, we calculate + // the length of that partial word and start copying that many + // bytes into the array. The first word we copy will start with + // data we don't care about, but the last `lengthmod` bytes will + // land at the beginning of the contents of the new array. When + // we're done copying, we overwrite the full first word with + // the actual length of the slice. + let lengthmod := and(_length, 31) + + // The multiplication in the next line is necessary + // because when slicing multiples of 32 bytes (lengthmod == 0) + // the following copy loop was copying the origin's length + // and then ending prematurely not copying everything it should. + let mc := add(add(tempBytes, lengthmod), mul(0x20, iszero(lengthmod))) + let end := add(mc, _length) + + for { + // The multiplication in the next line has the same exact purpose + // as the one above. + let cc := add(add(add(_bytes, lengthmod), mul(0x20, iszero(lengthmod))), _start) + } lt(mc, end) { + mc := add(mc, 0x20) + cc := add(cc, 0x20) + } { mstore(mc, mload(cc)) } + + mstore(tempBytes, _length) + + //update free-memory pointer + //allocating the array padded to 32 bytes like the compiler does now + mstore(0x40, and(add(mc, 31), not(31))) + } + //if we want a zero-length slice let's just return a zero-length array + default { + tempBytes := mload(0x40) + //zero out the 32 bytes slice we are about to return + //we need to do it because Solidity does not garbage collect + mstore(tempBytes, 0) + + mstore(0x40, add(tempBytes, 0x20)) + } + } + + return tempBytes; + } +} diff --git a/contracts/test/foundry/marketplace/utils/EIP712MerkleTree.sol b/contracts/test/foundry/marketplace/utils/EIP712MerkleTree.sol new file mode 100644 index 00000000..00e89a30 --- /dev/null +++ b/contracts/test/foundry/marketplace/utils/EIP712MerkleTree.sol @@ -0,0 +1,114 @@ +// SPDX-License-Identifier: MIT +pragma solidity 0.8.17; + +// Forge test +import {Test} from "forge-std/Test.sol"; + +// Libraries +import {OrderStructs} from "@hypercerts/marketplace/libraries/OrderStructs.sol"; + +// Core contracts +import {LooksRareProtocol} from "@hypercerts/marketplace/LooksRareProtocol.sol"; + +// Utils +import {MerkleWithPosition} from "./MerkleWithPosition.sol"; +import {MathLib} from "./MathLib.sol"; + +// Constants +import {MAX_CALLDATA_PROOF_LENGTH} from "@hypercerts/marketplace/constants/NumericConstants.sol"; + +contract EIP712MerkleTree is Test { + using OrderStructs for OrderStructs.Maker; + + LooksRareProtocol private looksRareProtocol; + + constructor(LooksRareProtocol _looksRareProtocol) { + looksRareProtocol = _looksRareProtocol; + } + + function sign(uint256 privateKey, OrderStructs.Maker[] memory makerOrders, uint256 makerOrderIndex) + external + returns (bytes memory signature, OrderStructs.MerkleTree memory merkleTree) + { + uint256 bidCount = makerOrders.length; + uint256 treeHeight = MathLib.log2(bidCount); + if (2 ** treeHeight != bidCount || treeHeight == 0) { + treeHeight += 1; + } + bytes32 batchOrderTypehash = _getBatchOrderTypehash(treeHeight); + uint256 leafCount = 2 ** treeHeight; + OrderStructs.MerkleTreeNode[] memory leaves = new OrderStructs.MerkleTreeNode[](leafCount); + + for (uint256 i; i < bidCount; i++) { + leaves[i] = OrderStructs.MerkleTreeNode({ + value: makerOrders[i].hash(), + position: i % 2 == 0 ? OrderStructs.MerkleTreeNodePosition.Left : OrderStructs.MerkleTreeNodePosition.Right + }); + } + + bytes32 emptyMakerOrderHash = _emptyMakerOrderHash(); + for (uint256 i = bidCount; i < leafCount; i++) { + leaves[i] = OrderStructs.MerkleTreeNode({ + value: emptyMakerOrderHash, + position: i % 2 == 0 ? OrderStructs.MerkleTreeNodePosition.Left : OrderStructs.MerkleTreeNodePosition.Right + }); + } + + MerkleWithPosition merkle = new MerkleWithPosition(); + OrderStructs.MerkleTreeNode[] memory proof = merkle.getProof(leaves, makerOrderIndex); + bytes32 root = merkle.getRoot(leaves); + + signature = _sign(privateKey, batchOrderTypehash, root); + merkleTree = OrderStructs.MerkleTree({root: root, proof: proof}); + } + + function _emptyMakerOrderHash() private pure returns (bytes32 makerOrderHash) { + OrderStructs.Maker memory makerOrder; + makerOrderHash = makerOrder.hash(); + } + + function _sign(uint256 privateKey, bytes32 batchOrderTypehash, bytes32 root) + private + view + returns (bytes memory signature) + { + bytes32 digest = keccak256(abi.encode(batchOrderTypehash, root)); + + bytes32 domainSeparator = looksRareProtocol.domainSeparator(); + + (uint8 v, bytes32 r, bytes32 s) = + vm.sign(privateKey, keccak256(abi.encodePacked("\x19\x01", domainSeparator, digest))); + + signature = abi.encodePacked(r, s, v); + } + + function _getBatchOrderTypehash(uint256 treeHeight) private pure returns (bytes32 batchOrderTypehash) { + if (treeHeight == 1) { + batchOrderTypehash = hex"9661287f7a4aa4867db46a2453ee15bebac4e8fc25667a58718da658f15de643"; + } else if (treeHeight == 2) { + batchOrderTypehash = hex"a54ab330ea9e1dfccee2b86f3666989e7fbd479704416c757c8de8e820142a08"; + } else if (treeHeight == 3) { + batchOrderTypehash = hex"93390f5d45ede9dea305f16aec86b2472af4f823851637f1b7019ad0775cea49"; + } else if (treeHeight == 4) { + batchOrderTypehash = hex"9dda2c8358da895e43d574bb15954ce5727b22e923a2d8f28261f297bce42f0b"; + } else if (treeHeight == 5) { + batchOrderTypehash = hex"92dc717124e161262f9d10c7079e7d54dc51271893fba54aa4a0f270fecdcc98"; + } else if (treeHeight == 6) { + batchOrderTypehash = hex"ce02aee5a7a35d40d974463c4c6e5534954fb07a7e7bc966fee268a15337bfd8"; + } else if (treeHeight == 7) { + batchOrderTypehash = hex"f7a65efd167a18f7091b2bb929d687dd94503cf0a43620487055ed7d6b727559"; + } else if (treeHeight == 8) { + batchOrderTypehash = hex"def24acacad1318b664520f7c10e8bc6d1e7f6f6f7c8b031e70624ceb42266a6"; + } else if (treeHeight == 9) { + batchOrderTypehash = hex"4cb4080dc4e7bae88b4dc4307ad5117fa4f26195998a1b5f40368809d7f4c7f2"; + } else if (treeHeight == 10) { + batchOrderTypehash = hex"f8b1f864164d8d6e0b45f1399bd711223117a4ab0b057a9c2d7779e86a7c88db"; + } else if (treeHeight == 11) { + batchOrderTypehash = hex"4787f505db237e03a7193c312d5159add8a5705278e1c7dcf92ab87126cbe490"; + } else if (treeHeight == 12) { + batchOrderTypehash = hex"7a6517e5a16c56b29947b57b748aa91736987376e1a366d948e7a802a9df3431"; + } else if (treeHeight == 13) { + batchOrderTypehash = hex"35806d347e9929042ce209d143da48f100f0ff0cbdb1fde68cf13af8059d79df"; + } + } +} diff --git a/contracts/test/foundry/marketplace/utils/ERC1271Wallet.sol b/contracts/test/foundry/marketplace/utils/ERC1271Wallet.sol new file mode 100644 index 00000000..f6eaf418 --- /dev/null +++ b/contracts/test/foundry/marketplace/utils/ERC1271Wallet.sol @@ -0,0 +1,20 @@ +// SPDX-License-Identifier: MIT +pragma solidity 0.8.17; + +import {ERC1271WalletMock} from "openzeppelin-contracts/contracts/mocks/ERC1271WalletMock.sol"; + +contract ERC1271Wallet is ERC1271WalletMock { + constructor(address originalOwner) ERC1271WalletMock(originalOwner) {} + + function onERC1155Received(address, address, uint256, uint256, bytes calldata) external pure returns (bytes4) { + return this.onERC1155Received.selector; + } + + function onERC1155BatchReceived(address, address, uint256[] calldata, uint256[] calldata, bytes calldata) + external + pure + returns (bytes4) + { + return this.onERC1155BatchReceived.selector; + } +} diff --git a/contracts/test/foundry/marketplace/utils/GasGriefer.sol b/contracts/test/foundry/marketplace/utils/GasGriefer.sol new file mode 100644 index 00000000..2589681c --- /dev/null +++ b/contracts/test/foundry/marketplace/utils/GasGriefer.sol @@ -0,0 +1,15 @@ +// SPDX-License-Identifier: MIT +pragma solidity 0.8.17; + +contract GasGriefer { + receive() external payable { + uint256 count; + while (true) { + count += 1; + } + } + + function isValidSignature(bytes32, bytes memory) external pure returns (bytes4 magicValue) { + magicValue = this.isValidSignature.selector; + } +} diff --git a/contracts/test/foundry/marketplace/utils/MaliciousERC1271Wallet.sol b/contracts/test/foundry/marketplace/utils/MaliciousERC1271Wallet.sol new file mode 100644 index 00000000..c13ff909 --- /dev/null +++ b/contracts/test/foundry/marketplace/utils/MaliciousERC1271Wallet.sol @@ -0,0 +1,66 @@ +/// SPDX-License-Identifier: MIT +pragma solidity 0.8.17; + +import {ILooksRareProtocol} from "@hypercerts/marketplace/interfaces/ILooksRareProtocol.sol"; +import {OrderStructs} from "@hypercerts/marketplace/libraries/OrderStructs.sol"; + +abstract contract MaliciousERC1271Wallet { + enum FunctionToReenter { + None, + ExecuteTakerAsk, + ExecuteTakerBid, + ExecuteMultipleTakerBids + } + + ILooksRareProtocol internal immutable looksRareProtocol; + FunctionToReenter internal functionToReenter; + + constructor(address _looksRareProtocol) { + looksRareProtocol = ILooksRareProtocol(_looksRareProtocol); + } + + function setFunctionToReenter(FunctionToReenter _functionToReenter) external { + functionToReenter = _functionToReenter; + } + + function isValidSignature(bytes32, bytes calldata) external virtual returns (bytes4 magicValue) { + magicValue = this.isValidSignature.selector; + } + + function onERC1155Received(address, address, uint256, uint256, bytes calldata) external virtual returns (bytes4) { + return this.onERC1155Received.selector; + } + + function onERC1155BatchReceived(address, address, uint256[] calldata, uint256[] calldata, bytes calldata) + external + virtual + returns (bytes4) + { + return this.onERC1155BatchReceived.selector; + } + + function _executeTakerAsk(bytes memory signature) internal { + OrderStructs.Taker memory takerAsk; + OrderStructs.Maker memory makerBid; + OrderStructs.MerkleTree memory merkleTree; + + looksRareProtocol.executeTakerAsk(takerAsk, makerBid, signature, merkleTree); + } + + function _executeTakerBid(bytes memory signature) internal { + OrderStructs.Taker memory takerBid; + OrderStructs.Maker memory makerAsk; + OrderStructs.MerkleTree memory merkleTree; + + looksRareProtocol.executeTakerBid(takerBid, makerAsk, signature, merkleTree); + } + + function _executeMultipleTakerBids() internal { + OrderStructs.Taker[] memory takerBids = new OrderStructs.Taker[](2); + OrderStructs.Maker[] memory makerAsks = new OrderStructs.Maker[](2); + bytes[] memory signatures = new bytes[](2); + OrderStructs.MerkleTree[] memory merkleTrees = new OrderStructs.MerkleTree[](2); + + looksRareProtocol.executeMultipleTakerBids(takerBids, makerAsks, signatures, merkleTrees, false); + } +} diff --git a/contracts/test/foundry/marketplace/utils/MaliciousIsValidSignatureERC1271Wallet.sol b/contracts/test/foundry/marketplace/utils/MaliciousIsValidSignatureERC1271Wallet.sol new file mode 100644 index 00000000..c8aaf1ef --- /dev/null +++ b/contracts/test/foundry/marketplace/utils/MaliciousIsValidSignatureERC1271Wallet.sol @@ -0,0 +1,20 @@ +// SPDX-License-Identifier: MIT +pragma solidity 0.8.17; + +import {MaliciousERC1271Wallet} from "./MaliciousERC1271Wallet.sol"; + +contract MaliciousIsValidSignatureERC1271Wallet is MaliciousERC1271Wallet { + constructor(address _looksRareProtocol) MaliciousERC1271Wallet(_looksRareProtocol) {} + + function isValidSignature(bytes32, bytes calldata signature) external override returns (bytes4 magicValue) { + if (functionToReenter == FunctionToReenter.ExecuteTakerAsk) { + _executeTakerAsk(signature); + } else if (functionToReenter == FunctionToReenter.ExecuteTakerBid) { + _executeTakerBid(signature); + } else if (functionToReenter == FunctionToReenter.ExecuteMultipleTakerBids) { + _executeMultipleTakerBids(); + } + + magicValue = this.isValidSignature.selector; + } +} diff --git a/contracts/test/foundry/marketplace/utils/MaliciousOnERC1155ReceivedERC1271Wallet.sol b/contracts/test/foundry/marketplace/utils/MaliciousOnERC1155ReceivedERC1271Wallet.sol new file mode 100644 index 00000000..cc790326 --- /dev/null +++ b/contracts/test/foundry/marketplace/utils/MaliciousOnERC1155ReceivedERC1271Wallet.sol @@ -0,0 +1,36 @@ +// SPDX-License-Identifier: MIT +pragma solidity 0.8.17; + +import {MaliciousERC1271Wallet} from "./MaliciousERC1271Wallet.sol"; + +contract MaliciousOnERC1155ReceivedERC1271Wallet is MaliciousERC1271Wallet { + constructor(address _looksRareProtocol) MaliciousERC1271Wallet(_looksRareProtocol) {} + + function onERC1155Received(address, address, uint256, uint256, bytes memory) external override returns (bytes4) { + if (functionToReenter == FunctionToReenter.ExecuteTakerAsk) { + _executeTakerAsk(new bytes(0)); + } else if (functionToReenter == FunctionToReenter.ExecuteTakerBid) { + _executeTakerBid(new bytes(0)); + } else if (functionToReenter == FunctionToReenter.ExecuteMultipleTakerBids) { + _executeMultipleTakerBids(); + } + + return this.onERC1155Received.selector; + } + + function onERC1155BatchReceived(address, address, uint256[] calldata, uint256[] calldata, bytes calldata) + external + override + returns (bytes4) + { + if (functionToReenter == FunctionToReenter.ExecuteTakerAsk) { + _executeTakerAsk(new bytes(0)); + } else if (functionToReenter == FunctionToReenter.ExecuteTakerBid) { + _executeTakerBid(new bytes(0)); + } else if (functionToReenter == FunctionToReenter.ExecuteMultipleTakerBids) { + _executeMultipleTakerBids(); + } + + return this.onERC1155BatchReceived.selector; + } +} diff --git a/contracts/test/foundry/marketplace/utils/MaliciousOnERC1155ReceivedTheThirdTimeERC1271Wallet.sol b/contracts/test/foundry/marketplace/utils/MaliciousOnERC1155ReceivedTheThirdTimeERC1271Wallet.sol new file mode 100644 index 00000000..95ba4347 --- /dev/null +++ b/contracts/test/foundry/marketplace/utils/MaliciousOnERC1155ReceivedTheThirdTimeERC1271Wallet.sol @@ -0,0 +1,24 @@ +// SPDX-License-Identifier: MIT +pragma solidity 0.8.17; + +import {MaliciousERC1271Wallet} from "./MaliciousERC1271Wallet.sol"; + +contract MaliciousOnERC1155ReceivedTheThirdTimeERC1271Wallet is MaliciousERC1271Wallet { + uint256 private isValidSignatureEnterCount; + + constructor(address _looksRareProtocol) MaliciousERC1271Wallet(_looksRareProtocol) {} + + function onERC1155Received(address, address, uint256, uint256, bytes memory) external override returns (bytes4) { + if (++isValidSignatureEnterCount == 3) { + if (functionToReenter == FunctionToReenter.ExecuteTakerAsk) { + _executeTakerAsk(new bytes(0)); + } else if (functionToReenter == FunctionToReenter.ExecuteTakerBid) { + _executeTakerBid(new bytes(0)); + } else if (functionToReenter == FunctionToReenter.ExecuteMultipleTakerBids) { + _executeMultipleTakerBids(); + } + } + + return this.onERC1155Received.selector; + } +} diff --git a/contracts/test/foundry/marketplace/utils/MathLib.sol b/contracts/test/foundry/marketplace/utils/MathLib.sol new file mode 100644 index 00000000..f0897c30 --- /dev/null +++ b/contracts/test/foundry/marketplace/utils/MathLib.sol @@ -0,0 +1,50 @@ +// SPDX-License-Identifier: MIT +pragma solidity 0.8.17; + +/** + * @author OpenZeppelin (last updated v4.8.0) (utils/math/Math.sol) + * @dev Standard math utilities missing in the Solidity language. + */ +library MathLib { + /** + * @dev Return the log in base 2, rounded down, of a positive value. + * Returns 0 if given 0. + */ + function log2(uint256 value) internal pure returns (uint256) { + uint256 result = 0; + unchecked { + if (value >> 128 > 0) { + value >>= 128; + result += 128; + } + if (value >> 64 > 0) { + value >>= 64; + result += 64; + } + if (value >> 32 > 0) { + value >>= 32; + result += 32; + } + if (value >> 16 > 0) { + value >>= 16; + result += 16; + } + if (value >> 8 > 0) { + value >>= 8; + result += 8; + } + if (value >> 4 > 0) { + value >>= 4; + result += 4; + } + if (value >> 2 > 0) { + value >>= 2; + result += 2; + } + if (value >> 1 > 0) { + result += 1; + } + } + return result; + } +} diff --git a/contracts/test/foundry/marketplace/utils/MerkleWithPosition.sol b/contracts/test/foundry/marketplace/utils/MerkleWithPosition.sol new file mode 100644 index 00000000..43857193 --- /dev/null +++ b/contracts/test/foundry/marketplace/utils/MerkleWithPosition.sol @@ -0,0 +1,157 @@ +// SPDX-License-Identifier: MIT +pragma solidity 0.8.17; + +import {OrderStructs} from "@hypercerts/marketplace/libraries/OrderStructs.sol"; + +/** + * @dev Modified from MurkyBase to add each node's position after hashing. + * hashLeafPair does not sort the nodes to match EIP-712. + */ +contract MerkleWithPosition { + /** + * + * PROOF GENERATION * + * + */ + + function getRoot(OrderStructs.MerkleTreeNode[] memory data) public pure returns (bytes32) { + require(data.length > 1, "won't generate root for single leaf"); + while (data.length > 1) { + data = hashLevel(data); + } + return data[0].value; + } + + function getProof(OrderStructs.MerkleTreeNode[] memory data, uint256 node) + public + pure + returns (OrderStructs.MerkleTreeNode[] memory result) + { + require(data.length > 1, "won't generate proof for single leaf"); + // The size of the proof is equal to the ceiling of log2(numLeaves) + result = new OrderStructs.MerkleTreeNode[](log2ceilBitMagic(data.length)); + uint256 pos = 0; + + // Two overflow risks: node, pos + // node: max array size is 2**256-1. Largest index in the array will be 1 less than that. Also, + // for dynamic arrays, size is limited to 2**64-1 + // pos: pos is bounded by log2(data.length), which should be less than type(uint256).max + while (data.length > 1) { + unchecked { + if (node & 0x1 == 1) { + result[pos] = data[node - 1]; + } else if (node + 1 == data.length) { + result[pos] = OrderStructs.MerkleTreeNode({ + value: bytes32(0), + position: OrderStructs.MerkleTreeNodePosition.Left + }); + } else { + result[pos] = data[node + 1]; + } + ++pos; + node /= 2; + } + data = hashLevel(data); + } + return result; + } + + ///@dev function is private to prevent unsafe data from being passed + function hashLevel(OrderStructs.MerkleTreeNode[] memory data) + private + pure + returns (OrderStructs.MerkleTreeNode[] memory result) + { + // Function is private, and all internal callers check that data.length >=2. + // Underflow is not possible as lowest possible value for data/result index is 1 + // overflow should be safe as length is / 2 always. + unchecked { + uint256 length = data.length; + if (length & 0x1 == 1) { + result = new OrderStructs.MerkleTreeNode[](length / 2 + 1); + bytes32 hashed = hashLeafPairs(data[length - 1].value, bytes32(0)); + result[result.length - 1] = + OrderStructs.MerkleTreeNode({value: hashed, position: OrderStructs.MerkleTreeNodePosition.Left}); + } else { + result = new OrderStructs.MerkleTreeNode[](length / 2); + } + // pos is upper bounded by data.length / 2, so safe even if array is at max size + uint256 pos = 0; + bool nextIsLeft = true; + for (uint256 i = 0; i < length - 1; i += 2) { + bytes32 hashed = hashLeafPairs(data[i].value, data[i + 1].value); + result[pos] = OrderStructs.MerkleTreeNode({ + value: hashed, + position: nextIsLeft + ? OrderStructs.MerkleTreeNodePosition.Left + : OrderStructs.MerkleTreeNodePosition.Right + }); + nextIsLeft = !nextIsLeft; + ++pos; + } + } + return result; + } + + /** + * + * MATH "LIBRARY" * + * + */ + + /// Original bitmagic adapted from https://github.com/paulrberg/prb-math/blob/main/contracts/PRBMath.sol + /// @dev Note that x assumed > 1 + function log2ceilBitMagic(uint256 x) public pure returns (uint256) { + if (x <= 1) { + return 0; + } + uint256 msb = 0; + uint256 _x = x; + if (x >= 2 ** 128) { + x >>= 128; + msb += 128; + } + if (x >= 2 ** 64) { + x >>= 64; + msb += 64; + } + if (x >= 2 ** 32) { + x >>= 32; + msb += 32; + } + if (x >= 2 ** 16) { + x >>= 16; + msb += 16; + } + if (x >= 2 ** 8) { + x >>= 8; + msb += 8; + } + if (x >= 2 ** 4) { + x >>= 4; + msb += 4; + } + if (x >= 2 ** 2) { + x >>= 2; + msb += 2; + } + if (x >= 2 ** 1) { + msb += 1; + } + + uint256 lsb = (~_x + 1) & _x; + if ((lsb == _x) && (msb > 0)) { + return msb; + } else { + return msb + 1; + } + } + + function hashLeafPairs(bytes32 left, bytes32 right) public pure returns (bytes32 _hash) { + assembly { + mstore(0x0, left) + mstore(0x20, right) + _hash := keccak256(0x0, 0x40) + } + } +} diff --git a/contracts/test/foundry/marketplace/utils/MockOrderGenerator.sol b/contracts/test/foundry/marketplace/utils/MockOrderGenerator.sol new file mode 100644 index 00000000..d6e695f5 --- /dev/null +++ b/contracts/test/foundry/marketplace/utils/MockOrderGenerator.sol @@ -0,0 +1,146 @@ +/// SPDX-License-Identifier: MIT +pragma solidity 0.8.17; + +// Generic interfaces +import {IERC165} from "@looksrare/contracts-libs/contracts/interfaces/generic/IERC165.sol"; + +// Libraries +import {OrderStructs} from "@hypercerts/marketplace/libraries/OrderStructs.sol"; + +// Other helpers +import {ProtocolHelpers} from "../utils/ProtocolHelpers.sol"; + +// Enums +import {CollectionType} from "@hypercerts/marketplace/enums/CollectionType.sol"; +import {QuoteType} from "@hypercerts/marketplace/enums/QuoteType.sol"; + +contract MockOrderGenerator is ProtocolHelpers { + function _createMockMakerAskAndTakerBid(address collection) + internal + view + returns (OrderStructs.Maker memory newMakerAsk, OrderStructs.Taker memory newTakerBid) + { + CollectionType collectionType = _getCollectionType(collection); + + newMakerAsk = _createSingleItemMakerOrder({ + quoteType: QuoteType.Ask, + globalNonce: 0, + subsetNonce: 0, + strategyId: STANDARD_SALE_FOR_FIXED_PRICE_STRATEGY, + collectionType: collectionType, + orderNonce: 0, + collection: collection, + currency: ETH, + signer: makerUser, + price: 1 ether, + itemId: 420 + }); + + newTakerBid = OrderStructs.Taker(takerUser, abi.encode()); + } + + function _createMockMakerBidAndTakerAsk(address collection, address currency) + internal + view + returns (OrderStructs.Maker memory newMakerBid, OrderStructs.Taker memory newTakerAsk) + { + CollectionType collectionType = _getCollectionType(collection); + + newMakerBid = _createSingleItemMakerOrder({ + quoteType: QuoteType.Bid, + globalNonce: 0, + subsetNonce: 0, + strategyId: STANDARD_SALE_FOR_FIXED_PRICE_STRATEGY, + collectionType: collectionType, + orderNonce: 0, + collection: collection, + currency: currency, + signer: makerUser, + price: 1 ether, + itemId: 420 + }); + + newTakerAsk = OrderStructs.Taker(takerUser, abi.encode()); + } + + function _createMockMakerAskAndTakerBidWithBundle(address collection, uint256 numberTokens) + internal + view + returns (OrderStructs.Maker memory newMakerAsk, OrderStructs.Taker memory newTakerBid) + { + CollectionType collectionType = _getCollectionType(collection); + + (uint256[] memory itemIds, uint256[] memory amounts) = _setBundleItemIdsAndAmounts(collectionType, numberTokens); + + newMakerAsk = _createMultiItemMakerOrder({ + quoteType: QuoteType.Ask, + globalNonce: 0, + subsetNonce: 0, + strategyId: STANDARD_SALE_FOR_FIXED_PRICE_STRATEGY, + collectionType: collectionType, + orderNonce: 0, + collection: collection, + currency: ETH, + signer: makerUser, + price: 1 ether, + itemIds: itemIds, + amounts: amounts + }); + + newTakerBid = OrderStructs.Taker(takerUser, abi.encode()); + } + + function _createMockMakerBidAndTakerAskWithBundle(address collection, address currency, uint256 numberTokens) + internal + view + returns (OrderStructs.Maker memory newMakerBid, OrderStructs.Taker memory newTakerAsk) + { + CollectionType collectionType = _getCollectionType(collection); + + (uint256[] memory itemIds, uint256[] memory amounts) = _setBundleItemIdsAndAmounts(collectionType, numberTokens); + + newMakerBid = _createMultiItemMakerOrder({ + quoteType: QuoteType.Bid, + globalNonce: 0, + subsetNonce: 0, + strategyId: STANDARD_SALE_FOR_FIXED_PRICE_STRATEGY, + collectionType: collectionType, + orderNonce: 0, + collection: collection, + currency: currency, + signer: makerUser, + price: 1 ether, + itemIds: itemIds, + amounts: amounts + }); + + newTakerAsk = OrderStructs.Taker(takerUser, abi.encode()); + } + + function _getCollectionType(address collection) private view returns (CollectionType collectionType) { + collectionType = CollectionType.ERC721; + + // If ERC1155, adjust the collection type + if (IERC165(collection).supportsInterface(0xd9b67a26)) { + collectionType = CollectionType.ERC1155; + } + } + + function _setBundleItemIdsAndAmounts(CollectionType collectionType, uint256 numberTokens) + private + pure + returns (uint256[] memory itemIds, uint256[] memory amounts) + { + itemIds = new uint256[](numberTokens); + amounts = new uint256[](numberTokens); + + for (uint256 i; i < itemIds.length; i++) { + itemIds[i] = i; + if (collectionType != CollectionType.ERC1155) { + amounts[i] = 1; + } else { + amounts[i] = 1 + i; + } + } + } +} diff --git a/contracts/test/foundry/marketplace/utils/ProtocolHelpers.sol b/contracts/test/foundry/marketplace/utils/ProtocolHelpers.sol new file mode 100644 index 00000000..a8c092b6 --- /dev/null +++ b/contracts/test/foundry/marketplace/utils/ProtocolHelpers.sol @@ -0,0 +1,107 @@ +/// SPDX-License-Identifier: MIT +pragma solidity 0.8.17; + +// Dependencies +import {BatchOrderTypehashRegistry} from "@hypercerts/marketplace/BatchOrderTypehashRegistry.sol"; + +// Libraries +import {OrderStructs} from "@hypercerts/marketplace/libraries/OrderStructs.sol"; + +// Other tests +import {TestHelpers} from "./TestHelpers.sol"; +import {TestParameters} from "./TestParameters.sol"; + +// Enums +import {CollectionType} from "@hypercerts/marketplace/enums/CollectionType.sol"; +import {QuoteType} from "@hypercerts/marketplace/enums/QuoteType.sol"; + +contract ProtocolHelpers is TestHelpers, TestParameters { + using OrderStructs for OrderStructs.Maker; + + bytes32 internal _domainSeparator; + + receive() external payable {} + + function _createSingleItemMakerOrder( + QuoteType quoteType, + uint256 globalNonce, + uint256 subsetNonce, + uint256 strategyId, + CollectionType collectionType, + uint256 orderNonce, + address collection, + address currency, + address signer, + uint256 price, + uint256 itemId + ) internal view returns (OrderStructs.Maker memory makerOrder) { + uint256[] memory itemIds = new uint256[](1); + itemIds[0] = itemId; + uint256[] memory amounts = new uint256[](1); + amounts[0] = 1; + + makerOrder = OrderStructs.Maker({ + quoteType: quoteType, + globalNonce: globalNonce, + subsetNonce: subsetNonce, + orderNonce: orderNonce, + strategyId: strategyId, + collectionType: collectionType, + collection: collection, + currency: currency, + signer: signer, + startTime: block.timestamp, + endTime: block.timestamp + 1, + price: price, + itemIds: itemIds, + amounts: amounts, + additionalParameters: abi.encode() + }); + } + + function _createMultiItemMakerOrder( + QuoteType quoteType, + uint256 globalNonce, + uint256 subsetNonce, + uint256 strategyId, + CollectionType collectionType, + uint256 orderNonce, + address collection, + address currency, + address signer, + uint256 price, + uint256[] memory itemIds, + uint256[] memory amounts + ) internal view returns (OrderStructs.Maker memory newMakerBid) { + newMakerBid = OrderStructs.Maker({ + quoteType: quoteType, + globalNonce: globalNonce, + subsetNonce: subsetNonce, + orderNonce: orderNonce, + strategyId: strategyId, + collectionType: collectionType, + collection: collection, + currency: currency, + signer: signer, + startTime: block.timestamp, + endTime: block.timestamp + 1, + price: price, + itemIds: itemIds, + amounts: amounts, + additionalParameters: abi.encode() + }); + } + + function _signMakerOrder(OrderStructs.Maker memory maker, uint256 signerKey) internal view returns (bytes memory) { + bytes32 orderHash = _computeOrderHash(maker); + + (uint8 v, bytes32 r, bytes32 s) = + vm.sign(signerKey, keccak256(abi.encodePacked("\x19\x01", _domainSeparator, orderHash))); + + return abi.encodePacked(r, s, v); + } + + function _computeOrderHash(OrderStructs.Maker memory maker) internal pure returns (bytes32) { + return maker.hash(); + } +} diff --git a/contracts/test/foundry/marketplace/utils/StrategyTestMultiFillCollectionOrder.sol b/contracts/test/foundry/marketplace/utils/StrategyTestMultiFillCollectionOrder.sol new file mode 100644 index 00000000..80323455 --- /dev/null +++ b/contracts/test/foundry/marketplace/utils/StrategyTestMultiFillCollectionOrder.sol @@ -0,0 +1,77 @@ +/// SPDX-License-Identifier: MIT +pragma solidity 0.8.17; + +// Libraries +import {OrderStructs} from "@hypercerts/marketplace/libraries/OrderStructs.sol"; + +// Custom errors +import {OrderInvalid} from "@hypercerts/marketplace/errors/SharedErrors.sol"; + +// Base strategy contracts +import {BaseStrategy, IStrategy} from "@hypercerts/marketplace/executionStrategies/BaseStrategy.sol"; + +// Enums +import {CollectionType} from "@hypercerts/marketplace/enums/CollectionType.sol"; + +contract StrategyTestMultiFillCollectionOrder is BaseStrategy { + using OrderStructs for OrderStructs.Maker; + + // Address of the protocol + address public immutable LOOKSRARE_PROTOCOL; + + // Tracks historical fills + mapping(bytes32 => uint256) internal countItemsFilledForOrderHash; + + /** + * @notice Constructor + * @param _looksRareProtocol Address of the LooksRare protocol + */ + constructor(address _looksRareProtocol) { + LOOKSRARE_PROTOCOL = _looksRareProtocol; + } + + /** + * @notice Execute collection strategy with taker ask order + * @param takerAsk Taker ask struct (taker ask-specific parameters for the execution) + * @param makerBid Maker bid struct (maker bid-specific parameters for the execution) + */ + function executeStrategyWithTakerAsk(OrderStructs.Taker calldata takerAsk, OrderStructs.Maker calldata makerBid) + external + returns (uint256 price, uint256[] memory itemIds, uint256[] memory amounts, bool isNonceInvalidated) + { + if (msg.sender != LOOKSRARE_PROTOCOL) revert OrderInvalid(); + // Only available for ERC721 + if (makerBid.collectionType != CollectionType.ERC721) revert OrderInvalid(); + + bytes32 orderHash = makerBid.hash(); + uint256 countItemsFilled = countItemsFilledForOrderHash[orderHash]; + uint256 countItemsFillable = makerBid.amounts[0]; + + price = makerBid.price; + (itemIds, amounts) = abi.decode(takerAsk.additionalParameters, (uint256[], uint256[])); + uint256 countItemsToFill = amounts.length; + + if ( + countItemsToFill == 0 || makerBid.amounts.length != 1 || itemIds.length != countItemsToFill + || countItemsFillable < countItemsToFill + countItemsFilled + ) revert OrderInvalid(); + + price *= countItemsToFill; + + if (countItemsToFill + countItemsFilled == countItemsFillable) { + delete countItemsFilledForOrderHash[orderHash]; + isNonceInvalidated = true; + } else { + countItemsFilledForOrderHash[orderHash] += countItemsToFill; + } + } + + function isMakerOrderValid(OrderStructs.Maker calldata, bytes4) + external + view + override + returns (bool isValid, bytes4 errorSelector) + { + // + } +} diff --git a/contracts/test/foundry/marketplace/utils/TestHelpers.sol b/contracts/test/foundry/marketplace/utils/TestHelpers.sol new file mode 100644 index 00000000..66270688 --- /dev/null +++ b/contracts/test/foundry/marketplace/utils/TestHelpers.sol @@ -0,0 +1,26 @@ +// SPDX-License-Identifier: MIT +pragma solidity 0.8.17; + +import {Test} from "forge-std/Test.sol"; +import {BytesLib} from "./BytesLib.sol"; + +abstract contract TestHelpers is Test { + using BytesLib for bytes; + + modifier asPrankedUser(address user) { + vm.startPrank(user); + _; + vm.stopPrank(); + } + + /** + * @dev Transforms a standard signature into an EIP2098 compliant signature + * @param signature The secp256k1 65-bytes signature + * @return eip2098Signature The 64-bytes EIP2098 compliant signature + */ + function _eip2098Signature(bytes memory signature) internal pure returns (bytes memory eip2098Signature) { + eip2098Signature = signature.slice(0, 64); + uint8 parityBit = uint8(eip2098Signature[32]) | ((uint8(signature[64]) % 27) << 7); + eip2098Signature[32] = bytes1(parityBit); + } +} diff --git a/contracts/test/foundry/marketplace/utils/TestParameters.sol b/contracts/test/foundry/marketplace/utils/TestParameters.sol new file mode 100644 index 00000000..44d29cf9 --- /dev/null +++ b/contracts/test/foundry/marketplace/utils/TestParameters.sol @@ -0,0 +1,55 @@ +// SPDX-License-Identifier: MIT +pragma solidity 0.8.17; + +import {Test} from "forge-std/Test.sol"; +import {OrderStructs} from "@hypercerts/marketplace/libraries/OrderStructs.sol"; + +abstract contract TestParameters is Test { + // Empty constants + OrderStructs.MerkleTree internal _EMPTY_MERKLE_TREE; + bytes4 internal constant _EMPTY_BYTES4 = bytes4(0); + bytes32 public constant MAGIC_VALUE_ORDER_NONCE_EXECUTED = keccak256("ORDER_NONCE_EXECUTED"); + + // Addresses + address internal constant _owner = address(42); + address internal constant _sender = address(88); + address internal constant _recipient = address(90); + address internal constant _transferrer = address(100); + address internal constant _royaltyRecipient = address(22); + + // Currencies + address internal constant ETH = address(0); + address internal constant WETH_MAINNET = 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2; + + // Generic fee parameters + uint16 internal constant _standardProtocolFeeBp = uint16(50); + uint16 internal constant _minTotalFeeBp = uint16(50); + uint16 internal constant _maxProtocolFeeBp = uint16(200); + uint16 internal constant _standardRoyaltyFee = uint16(0); + + uint256 internal constant _sellerProceedBpWithStandardProtocolFeeBp = 9950; + + // Public/Private keys for maker/taker user + uint256 internal constant makerUserPK = 1; + uint256 internal constant takerUserPK = 2; + // it is equal to vm.addr(makerUserPK) + address internal constant makerUser = 0x7E5F4552091A69125d5DfCb7b8C2659029395Bdf; + // it is equal to vm.addr(takerUserPK) + address internal constant takerUser = 0x2B5AD5c4795c026514f8317c7a215E218DcCD6cF; + + // Initial balances + // @dev The balances are on purpose different across users to make sure the tests are properly checking the + // assertion + uint256 internal constant _initialETHBalanceUser = 100 ether; + uint256 internal constant _initialWETHBalanceUser = 10 ether; + uint256 internal constant _initialETHBalanceRoyaltyRecipient = 10 ether; + uint256 internal constant _initialWETHBalanceRoyaltyRecipient = 25 ether; + uint256 internal constant _initialETHBalanceOwner = 50 ether; + uint256 internal constant _initialWETHBalanceOwner = 15 ether; + + // Chainlink ETH/USD price feed (Ethereum mainnet) + address internal constant CHAINLINK_ETH_USD_PRICE_FEED = 0x5f4eC3Df9cbd43714FE2740f5E3616155c5b8419; + + // Strategy id + uint256 internal constant STANDARD_SALE_FOR_FIXED_PRICE_STRATEGY = 0; +} diff --git a/contracts/test/foundry/AllowlistMinter.t.sol b/contracts/test/foundry/protocol/AllowlistMinter.t.sol similarity index 90% rename from contracts/test/foundry/AllowlistMinter.t.sol rename to contracts/test/foundry/protocol/AllowlistMinter.t.sol index 7ccb3aa9..a16c343c 100644 --- a/contracts/test/foundry/AllowlistMinter.t.sol +++ b/contracts/test/foundry/protocol/AllowlistMinter.t.sol @@ -1,20 +1,21 @@ // SPDX-License-Identifier: UNLICENSED pragma solidity ^0.8.16; -import { PRBTest } from "prb-test/PRBTest.sol"; -import { StdCheats } from "forge-std/StdCheats.sol"; -import { StdUtils } from "forge-std/StdUtils.sol"; +import {PRBTest} from "prb-test/PRBTest.sol"; +import {StdCheats} from "forge-std/StdCheats.sol"; +import {StdUtils} from "forge-std/StdUtils.sol"; -import { AllowlistMinter } from "../../src/AllowlistMinter.sol"; -import { Errors } from "../../src/libs/Errors.sol"; +import {AllowlistMinter} from "@hypercerts/protocol/AllowlistMinter.sol"; +import {Errors} from "@hypercerts/protocol/libs/Errors.sol"; -import { Merkle } from "murky/Merkle.sol"; +import {Merkle} from "murky/Merkle.sol"; contract MerkleHelper is AllowlistMinter, Merkle { - function generateCustomData( - address[] calldata addresses, - uint256[] calldata units - ) public pure returns (bytes32[] memory data) { + function generateCustomData(address[] calldata addresses, uint256[] calldata units) + public + pure + returns (bytes32[] memory data) + { data = new bytes32[](addresses.length); for (uint256 i = 0; i < addresses.length; i++) { data[i] = _calculateLeaf(addresses[i], units[i]); @@ -39,7 +40,7 @@ contract MerkleHelper is AllowlistMinter, Merkle { function _getSum(uint256[] memory array) public pure returns (uint256 sum) { uint256 len = array.length; - for (uint256 i; i < len; ) { + for (uint256 i; i < len;) { sum += array[i]; unchecked { ++i; @@ -159,7 +160,7 @@ contract AllowlistTest is PRBTest, StdCheats, StdUtils { } function testBasicAllowlistFuzz(uint256 size) public { - size = bound(size, 4, 5_000); + size = bound(size, 4, 5000); uint256 units = 10_000; bytes32[] memory data = merkle.generateData(size, 10_000); bytes32 root = merkle.getRoot(data); @@ -173,7 +174,7 @@ contract AllowlistTest is PRBTest, StdCheats, StdUtils { } function testProcessClaimFuzz(uint256 size) public { - size = bound(size, 4, 5_000); + size = bound(size, 4, 5000); uint256 value = 10_000; bytes32[] memory data = merkle.generateData(size, value); bytes32 root = merkle.getRoot(data); diff --git a/contracts/test/foundry/Bitshifting.t.sol b/contracts/test/foundry/protocol/Bitshifting.t.sol similarity index 86% rename from contracts/test/foundry/Bitshifting.t.sol rename to contracts/test/foundry/protocol/Bitshifting.t.sol index 68bc2cc8..6c4d9fe2 100644 --- a/contracts/test/foundry/Bitshifting.t.sol +++ b/contracts/test/foundry/protocol/Bitshifting.t.sol @@ -1,9 +1,9 @@ // SPDX-License-Identifier: UNLICENSED pragma solidity ^0.8.16; -import { PRBTest } from "prb-test/PRBTest.sol"; -import { StdCheats } from "forge-std/StdCheats.sol"; -import { StdUtils } from "forge-std/StdUtils.sol"; +import {PRBTest} from "prb-test/PRBTest.sol"; +import {StdCheats} from "forge-std/StdCheats.sol"; +import {StdUtils} from "forge-std/StdUtils.sol"; contract Bitshifter { /// @dev Bitmask used to expose only upper 128 bits of uint256 @@ -47,21 +47,24 @@ contract BitshiftingTest is PRBTest, StdCheats, StdUtils, Bitshifter { function testTypeMask() public { // 128 1s, 128 0s - assertEq(TYPE_MASK, 115792089237316195423570985008687907852929702298719625575994209400481361428480); + assertEq( + TYPE_MASK, + 115_792_089_237_316_195_423_570_985_008_687_907_852_929_702_298_719_625_575_994_209_400_481_361_428_480 + ); // 128 0s, 128 1s - assertEq(NF_INDEX_MASK, 340282366920938463463374607431768211455); + assertEq(NF_INDEX_MASK, 340_282_366_920_938_463_463_374_607_431_768_211_455); } function testBaseType() public { uint256 baseID = 1 << 128; uint256 baseType = getBaseType(baseID); assertEq(baseID, baseType); - assertEq(baseID, 340282366920938463463374607431768211456); + assertEq(baseID, 340_282_366_920_938_463_463_374_607_431_768_211_456); assertTrue(isBaseType(baseID)); assertEq(getItemIndex(baseID), 0); - assertEq(getBaseType(baseID), 340282366920938463463374607431768211456); + assertEq(getBaseType(baseID), 340_282_366_920_938_463_463_374_607_431_768_211_456); assertFalse(isTypedItem(baseID)); } diff --git a/contracts/test/foundry/HypercertMinter.batchminting.t.sol b/contracts/test/foundry/protocol/HypercertMinter.batchminting.t.sol similarity index 86% rename from contracts/test/foundry/HypercertMinter.batchminting.t.sol rename to contracts/test/foundry/protocol/HypercertMinter.batchminting.t.sol index b5349919..3f8502d6 100644 --- a/contracts/test/foundry/HypercertMinter.batchminting.t.sol +++ b/contracts/test/foundry/protocol/HypercertMinter.batchminting.t.sol @@ -1,14 +1,15 @@ // SPDX-License-Identifier: UNLICENSED pragma solidity ^0.8.16; -import { PRBTest } from "prb-test/PRBTest.sol"; -import { StdCheats } from "forge-std/StdCheats.sol"; -import { StdUtils } from "forge-std/StdUtils.sol"; -import { HypercertMinter } from "../../src/HypercertMinter.sol"; +import {PRBTest} from "prb-test/PRBTest.sol"; +import {StdCheats} from "forge-std/StdCheats.sol"; +import {StdUtils} from "forge-std/StdUtils.sol"; +import {HypercertMinter} from "@hypercerts/protocol/HypercertMinter.sol"; //solhint-disable-next-line max-line-length -import { ERC1155HolderUpgradeable } from "openzeppelin-contracts-upgradeable/contracts/token/ERC1155/utils/ERC1155HolderUpgradeable.sol"; -import { Merkle } from "murky/Merkle.sol"; -import { IHypercertToken } from "../../src/interfaces/IHypercertToken.sol"; +import {ERC1155HolderUpgradeable} from + "openzeppelin-contracts-upgradeable/contracts/token/ERC1155/utils/ERC1155HolderUpgradeable.sol"; +import {Merkle} from "murky/Merkle.sol"; +import {IHypercertToken} from "@hypercerts/protocol/interfaces/IHypercertToken.sol"; contract BatchMintingHelper is Merkle, ERC1155HolderUpgradeable { event BatchValueTransfer(uint256[] claimIDs, uint256[] fromTokenIDs, uint256[] toTokenIDs, uint256[] values); @@ -20,10 +21,11 @@ contract BatchMintingHelper is Merkle, ERC1155HolderUpgradeable { bytes32 root; } - function generateCustomData( - address[] memory addresses, - uint256[] memory units - ) public pure returns (bytes32[] memory data) { + function generateCustomData(address[] memory addresses, uint256[] memory units) + public + pure + returns (bytes32[] memory data) + { data = new bytes32[](addresses.length); for (uint256 i = 0; i < addresses.length; i++) { data[i] = _calculateLeaf(addresses[i], units[i]); @@ -62,7 +64,7 @@ contract BatchMintingHelper is Merkle, ERC1155HolderUpgradeable { function _getSum(uint256[] memory array) public pure returns (uint256 sum) { uint256 len = array.length; - for (uint256 i; i < len; ) { + for (uint256 i; i < len;) { sum += array[i]; unchecked { ++i; @@ -107,7 +109,7 @@ contract HypercertBatchMintingTest is PRBTest, StdCheats, StdUtils, BatchMinting proofs[i] = getProof(dataset.data, index); ids[i] = (i + 1) << 128; units[i] = dataset.units[index]; - minter.createAllowlist(user, 10000, dataset.root, _uri, IHypercertToken.TransferRestrictions.AllowAll); + minter.createAllowlist(user, 10_000, dataset.root, _uri, IHypercertToken.TransferRestrictions.AllowAll); } units[3] = 0; @@ -151,8 +153,8 @@ contract HypercertBatchMintingTest is PRBTest, StdCheats, StdUtils, BatchMinting uint256[] memory zeroes = new uint256[](2); - minter.createAllowlist(user, 10000, one.root, _uri, IHypercertToken.TransferRestrictions.AllowAll); - minter.createAllowlist(user, 10000, two.root, _uri, IHypercertToken.TransferRestrictions.AllowAll); + minter.createAllowlist(user, 10_000, one.root, _uri, IHypercertToken.TransferRestrictions.AllowAll); + minter.createAllowlist(user, 10_000, two.root, _uri, IHypercertToken.TransferRestrictions.AllowAll); startHoax(user, 10 ether); @@ -179,7 +181,7 @@ contract HypercertBatchMintingTest is PRBTest, StdCheats, StdUtils, BatchMinting ids[i] = (i + 1) << 128; tokenIDs[i] = ids[i] + 1; units[i] = dataset.units[index]; - minter.createAllowlist(user, 10000, dataset.root, _uri, IHypercertToken.TransferRestrictions.AllowAll); + minter.createAllowlist(user, 10_000, dataset.root, _uri, IHypercertToken.TransferRestrictions.AllowAll); } startHoax(user, 10 ether); @@ -215,11 +217,7 @@ contract HypercertBatchMintingTest is PRBTest, StdCheats, StdUtils, BatchMinting tokenIDs[i] = ids[i] + 1; units[i] = dataset.units[index]; minter.createAllowlist( - user, - _getSum(units), - dataset.root, - _uri, - IHypercertToken.TransferRestrictions.AllowAll + user, _getSum(units), dataset.root, _uri, IHypercertToken.TransferRestrictions.AllowAll ); } @@ -254,7 +252,7 @@ contract HypercertBatchMintingTest is PRBTest, StdCheats, StdUtils, BatchMinting ids[i] = (i + 1) << 128; tokenIDs[i] = ids[i] + 1; units[i] = dataset.units[index]; - minter.createAllowlist(user, 10000, dataset.root, _uri, IHypercertToken.TransferRestrictions.DisallowAll); + minter.createAllowlist(user, 10_000, dataset.root, _uri, IHypercertToken.TransferRestrictions.DisallowAll); } startHoax(user, 10 ether); @@ -289,11 +287,7 @@ contract HypercertBatchMintingTest is PRBTest, StdCheats, StdUtils, BatchMinting tokenIDs[i] = ids[i] + 1; units[i] = dataset.units[index]; minter.createAllowlist( - user, - 10000, - dataset.root, - _uri, - IHypercertToken.TransferRestrictions.FromCreatorOnly + user, 10_000, dataset.root, _uri, IHypercertToken.TransferRestrictions.FromCreatorOnly ); } diff --git a/contracts/test/foundry/HypercertMinter.pausable.t.sol b/contracts/test/foundry/protocol/HypercertMinter.pausable.t.sol similarity index 88% rename from contracts/test/foundry/HypercertMinter.pausable.t.sol rename to contracts/test/foundry/protocol/HypercertMinter.pausable.t.sol index 716c8c5f..a4b63061 100644 --- a/contracts/test/foundry/HypercertMinter.pausable.t.sol +++ b/contracts/test/foundry/protocol/HypercertMinter.pausable.t.sol @@ -1,11 +1,11 @@ // SPDX-License-Identifier: UNLICENSED pragma solidity ^0.8.16; -import { StdCheats } from "forge-std/StdCheats.sol"; -import { StdUtils } from "forge-std/StdUtils.sol"; -import { PRBTest } from "prb-test/PRBTest.sol"; -import { HypercertMinter } from "../../src/HypercertMinter.sol"; -import { IHypercertToken } from "../../src/interfaces/IHypercertToken.sol"; +import {StdCheats} from "forge-std/StdCheats.sol"; +import {StdUtils} from "forge-std/StdUtils.sol"; +import {PRBTest} from "prb-test/PRBTest.sol"; +import {HypercertMinter} from "@hypercerts/protocol/HypercertMinter.sol"; +import {IHypercertToken} from "@hypercerts/protocol/interfaces/IHypercertToken.sol"; contract PausableTestHelper { /** @@ -86,13 +86,7 @@ contract HypercertMinterPausableTest is PRBTest, StdCheats, StdUtils, PausableTe hypercertMinter.mintClaim(owner, 1, _uri, IHypercertToken.TransferRestrictions.AllowAll); vm.expectRevert("Pausable: paused"); - hypercertMinter.mintClaimWithFractions( - owner, - 1, - fractions, - _uri, - IHypercertToken.TransferRestrictions.AllowAll - ); + hypercertMinter.mintClaimWithFractions(owner, 1, fractions, _uri, IHypercertToken.TransferRestrictions.AllowAll); vm.expectRevert("Pausable: paused"); hypercertMinter.mintClaimFromAllowlist(owner, proofs, 2, 1000); diff --git a/contracts/test/foundry/HypercertMinter.t.sol b/contracts/test/foundry/protocol/HypercertMinter.t.sol similarity index 78% rename from contracts/test/foundry/HypercertMinter.t.sol rename to contracts/test/foundry/protocol/HypercertMinter.t.sol index ad15aada..86bbe1d5 100644 --- a/contracts/test/foundry/HypercertMinter.t.sol +++ b/contracts/test/foundry/protocol/HypercertMinter.t.sol @@ -1,12 +1,12 @@ // SPDX-License-Identifier: UNLICENSED pragma solidity ^0.8.16; -import { StdCheats } from "forge-std/StdCheats.sol"; -import { StdUtils } from "forge-std/StdUtils.sol"; -import { Merkle } from "murky/Merkle.sol"; -import { PRBTest } from "prb-test/PRBTest.sol"; -import { HypercertMinter } from "../../src/HypercertMinter.sol"; -import { IHypercertToken } from "../../src/interfaces/IHypercertToken.sol"; +import {StdCheats} from "forge-std/StdCheats.sol"; +import {StdUtils} from "forge-std/StdUtils.sol"; +import {Merkle} from "murky/Merkle.sol"; +import {PRBTest} from "prb-test/PRBTest.sol"; +import {HypercertMinter} from "@hypercerts/protocol/HypercertMinter.sol"; +import {IHypercertToken} from "@hypercerts/protocol/interfaces/IHypercertToken.sol"; contract MinterTestHelper { event ClaimStored(uint256 indexed claimID, string uri, uint256 totalUnits); @@ -38,7 +38,9 @@ contract MinterTestHelper { return 0; } sum = 0; - for (uint256 i = 0; i < array.length; i++) sum += array[i]; + for (uint256 i = 0; i < array.length; i++) { + sum += array[i]; + } } function buildFractions(uint256 size) public pure returns (uint256[] memory) { @@ -76,7 +78,7 @@ contract HypercertMinterTest is PRBTest, StdCheats, StdUtils, MinterTestHelper { } function testClaimSingleFraction() public { - uint256 units = 10000; + uint256 units = 10_000; vm.expectEmit(true, true, true, true); emit ClaimStored(1 << 128, _uri, units); @@ -89,11 +91,7 @@ contract HypercertMinterTest is PRBTest, StdCheats, StdUtils, MinterTestHelper { vm.expectEmit(true, true, true, true); emit ClaimStored(1 << 128, _uri, totalUnits); hypercertMinter.mintClaimWithFractions( - alice, - totalUnits, - fractions, - _uri, - IHypercertToken.TransferRestrictions.AllowAll + alice, totalUnits, fractions, _uri, IHypercertToken.TransferRestrictions.AllowAll ); } @@ -104,11 +102,7 @@ contract HypercertMinterTest is PRBTest, StdCheats, StdUtils, MinterTestHelper { vm.expectEmit(true, true, true, true); emit ClaimStored(1 << 128, _uri, totalUnits); hypercertMinter.mintClaimWithFractions( - alice, - totalUnits, - fractions, - _uri, - IHypercertToken.TransferRestrictions.AllowAll + alice, totalUnits, fractions, _uri, IHypercertToken.TransferRestrictions.AllowAll ); } @@ -118,11 +112,7 @@ contract HypercertMinterTest is PRBTest, StdCheats, StdUtils, MinterTestHelper { vm.expectEmit(true, true, true, true); emit ClaimStored(1 << 128, _uri, totalUnits); hypercertMinter.mintClaimWithFractions( - alice, - totalUnits, - fractions, - _uri, - IHypercertToken.TransferRestrictions.DisallowAll + alice, totalUnits, fractions, _uri, IHypercertToken.TransferRestrictions.DisallowAll ); } @@ -132,11 +122,7 @@ contract HypercertMinterTest is PRBTest, StdCheats, StdUtils, MinterTestHelper { vm.expectEmit(true, true, true, true); emit ClaimStored(1 << 128, _uri, totalUnits); hypercertMinter.mintClaimWithFractions( - alice, - totalUnits, - fractions, - _uri, - IHypercertToken.TransferRestrictions.FromCreatorOnly + alice, totalUnits, fractions, _uri, IHypercertToken.TransferRestrictions.FromCreatorOnly ); } } diff --git a/contracts/test/foundry/HypercertMinter.transfers.t.sol b/contracts/test/foundry/protocol/HypercertMinter.transfers.t.sol similarity index 92% rename from contracts/test/foundry/HypercertMinter.transfers.t.sol rename to contracts/test/foundry/protocol/HypercertMinter.transfers.t.sol index 7c74edb1..cd2f1773 100644 --- a/contracts/test/foundry/HypercertMinter.transfers.t.sol +++ b/contracts/test/foundry/protocol/HypercertMinter.transfers.t.sol @@ -1,12 +1,12 @@ // SPDX-License-Identifier: UNLICENSED pragma solidity ^0.8.16; -import { StdCheats } from "forge-std/StdCheats.sol"; -import { StdUtils } from "forge-std/StdUtils.sol"; -import { PRBTest } from "prb-test/PRBTest.sol"; -import { Errors } from "../../src/libs/Errors.sol"; -import { HypercertMinter } from "../../src/HypercertMinter.sol"; -import { IHypercertToken } from "../../src/interfaces/IHypercertToken.sol"; +import {StdCheats} from "forge-std/StdCheats.sol"; +import {StdUtils} from "forge-std/StdUtils.sol"; +import {PRBTest} from "prb-test/PRBTest.sol"; +import {Errors} from "@hypercerts/protocol/libs/Errors.sol"; +import {HypercertMinter} from "@hypercerts/protocol/HypercertMinter.sol"; +import {IHypercertToken} from "@hypercerts/protocol/interfaces/IHypercertToken.sol"; /// @dev Testing transfer restrictions on hypercerts contract HypercertMinterTransferTest is PRBTest, StdCheats, StdUtils { @@ -22,7 +22,7 @@ contract HypercertMinterTransferTest is PRBTest, StdCheats, StdUtils { function setUp() public { hypercertMinter = new HypercertMinter(); _uri = "ipfs://bafybeigdyrzt5sfp7udm7hu76uh7y26nf3efuylqabf3oclgtqy55fbzdi"; - _units = 10000; + _units = 10_000; baseID = 1 << 128; tokenIndex = 1; tokenID = baseID + tokenIndex; diff --git a/contracts/test/foundry/PerformanceTesting.t.sol b/contracts/test/foundry/protocol/PerformanceTesting.t.sol similarity index 82% rename from contracts/test/foundry/PerformanceTesting.t.sol rename to contracts/test/foundry/protocol/PerformanceTesting.t.sol index 7ed5b2df..956fd3bb 100644 --- a/contracts/test/foundry/PerformanceTesting.t.sol +++ b/contracts/test/foundry/protocol/PerformanceTesting.t.sol @@ -1,12 +1,12 @@ // SPDX-License-Identifier: UNLICENSED pragma solidity ^0.8.16; -import { PRBTest } from "prb-test/PRBTest.sol"; -import { StdCheats } from "forge-std/StdCheats.sol"; -import { StdUtils } from "forge-std/StdUtils.sol"; -import { HypercertMinter } from "../../src/HypercertMinter.sol"; -import { Merkle } from "murky/Merkle.sol"; -import { IHypercertToken } from "../../src/interfaces/IHypercertToken.sol"; +import {PRBTest} from "prb-test/PRBTest.sol"; +import {StdCheats} from "forge-std/StdCheats.sol"; +import {StdUtils} from "forge-std/StdUtils.sol"; +import {HypercertMinter} from "@hypercerts/protocol/HypercertMinter.sol"; +import {Merkle} from "murky/Merkle.sol"; +import {IHypercertToken} from "@hypercerts/protocol/interfaces/IHypercertToken.sol"; // forge test -vv --match-path test/foundry/PerformanceTesting.t.sol @@ -78,10 +78,11 @@ contract PerformanceTestHelper is Merkle { leaf = keccak256(bytes.concat(keccak256(abi.encode(account, amount)))); } - function generateCustomData( - address[] memory addresses, - uint256[] memory units - ) public pure returns (bytes32[] memory data) { + function generateCustomData(address[] memory addresses, uint256[] memory units) + public + pure + returns (bytes32[] memory data) + { data = new bytes32[](addresses.length); for (uint256 i = 0; i < addresses.length; i++) { data[i] = _calculateLeaf(addresses[i], units[i]); @@ -129,7 +130,7 @@ contract PerformanceTesting is PRBTest, StdCheats, StdUtils, PerformanceTestHelp function setUp() public { alice = address(1); hypercertMinter = new HypercertMinter(); - bytes32[] memory data = generateData(12, 10000); + bytes32[] memory data = generateData(12, 10_000); rootHash = getRoot(data); proof = getProof(data, 6); @@ -149,11 +150,7 @@ contract PerformanceTesting is PRBTest, StdCheats, StdUtils, PerformanceTestHelp ids[i] = (i + 1) << 128; units[i] = dataset.units[index]; hypercertMinter.createAllowlist( - alice, - dataset.units[index], - dataset.root, - _uri, - IHypercertToken.TransferRestrictions.AllowAll + alice, dataset.units[index], dataset.root, _uri, IHypercertToken.TransferRestrictions.AllowAll ); } } @@ -170,7 +167,7 @@ contract PerformanceTesting is PRBTest, StdCheats, StdUtils, PerformanceTestHelp // Mint Hypercert with 1 fraction function testClaimSingleFraction() public { - hypercertMinter.mintClaim(alice, 10000, _uri, IHypercertToken.TransferRestrictions.AllowAll); + hypercertMinter.mintClaim(alice, 10_000, _uri, IHypercertToken.TransferRestrictions.AllowAll); } function testClaimSingleFractionFuzz(address account, uint256 value) public { @@ -188,11 +185,7 @@ contract PerformanceTesting is PRBTest, StdCheats, StdUtils, PerformanceTestHelp uint256 totalUnits = getSum(fractions); hypercertMinter.mintClaimWithFractions( - alice, - totalUnits, - fractions, - _uri, - IHypercertToken.TransferRestrictions.AllowAll + alice, totalUnits, fractions, _uri, IHypercertToken.TransferRestrictions.AllowAll ); } @@ -201,11 +194,7 @@ contract PerformanceTesting is PRBTest, StdCheats, StdUtils, PerformanceTestHelp uint256 totalUnits = getSum(fractions); hypercertMinter.mintClaimWithFractions( - alice, - totalUnits, - fractions, - _uri, - IHypercertToken.TransferRestrictions.AllowAll + alice, totalUnits, fractions, _uri, IHypercertToken.TransferRestrictions.AllowAll ); } @@ -215,11 +204,7 @@ contract PerformanceTesting is PRBTest, StdCheats, StdUtils, PerformanceTestHelp uint256 totalUnits = getSum(fractions); hypercertMinter.mintClaimWithFractions( - alice, - totalUnits, - fractions, - "https://example.com/ipfsHash", - IHypercertToken.TransferRestrictions.AllowAll + alice, totalUnits, fractions, "https://example.com/ipfsHash", IHypercertToken.TransferRestrictions.AllowAll ); } diff --git a/contracts/test/foundry/SemiFungible1155.allowances.t.sol b/contracts/test/foundry/protocol/SemiFungible1155.allowances.t.sol similarity index 94% rename from contracts/test/foundry/SemiFungible1155.allowances.t.sol rename to contracts/test/foundry/protocol/SemiFungible1155.allowances.t.sol index 438b1893..efe78bef 100644 --- a/contracts/test/foundry/SemiFungible1155.allowances.t.sol +++ b/contracts/test/foundry/protocol/SemiFungible1155.allowances.t.sol @@ -1,10 +1,10 @@ // SPDX-License-Identifier: UNLICENSED pragma solidity ^0.8.16; -import { PRBTest } from "prb-test/PRBTest.sol"; -import { StdCheats } from "forge-std/StdCheats.sol"; -import { StdUtils } from "forge-std/StdUtils.sol"; -import { SemiFungible1155Helper } from "./SemiFungibleHelper.sol"; +import {PRBTest} from "prb-test/PRBTest.sol"; +import {StdCheats} from "forge-std/StdCheats.sol"; +import {StdUtils} from "forge-std/StdUtils.sol"; +import {SemiFungible1155Helper} from "./SemiFungibleHelper.sol"; /// @dev See the "Writing Tests" section in the Foundry Book if this is your first time with Forge. /// https://book.getfoundry.sh/forge/writing-tests diff --git a/contracts/test/foundry/protocol/SemiFungible1155.burning.t.sol b/contracts/test/foundry/protocol/SemiFungible1155.burning.t.sol new file mode 100644 index 00000000..1e3c21a4 --- /dev/null +++ b/contracts/test/foundry/protocol/SemiFungible1155.burning.t.sol @@ -0,0 +1,121 @@ +// SPDX-License-Identifier: UNLICENSED +pragma solidity >=0.8.16; + +import {PRBTest} from "prb-test/PRBTest.sol"; +import {StdCheats} from "forge-std/StdCheats.sol"; +import {StdUtils} from "forge-std/StdUtils.sol"; +import {SemiFungible1155Helper} from "./SemiFungibleHelper.sol"; + +/// @dev See the "Writing Tests" section in the Foundry Book if this is your first time with Forge. +/// https://book.getfoundry.sh/forge/writing-tests +contract SemiFungible1155BurnTest is PRBTest, StdCheats, StdUtils, SemiFungible1155Helper { + SemiFungible1155Helper internal semiFungible; + string internal _uri; + address internal alice; + address internal bob; + + function setUp() public { + semiFungible = new SemiFungible1155Helper(); + _uri = "ipfs://bafybeigdyrzt5sfp7udm7hu76uh7y26nf3efuylqabf3oclgtqy55fbzdi"; + alice = address(1); + bob = address(2); + } + + function testBurnFraction() public { + uint256 baseID = 1 << 128; + + uint256 size = 20; + uint256 value = 2000; + uint256[] memory values = semiFungible.buildValues(size, value); + uint256[] memory tokenIDs = semiFungible.buildIDs(baseID, size); + + startHoax(alice, 100 ether); + + semiFungible.mintValue(alice, values, _uri); + semiFungible.validateOwnerBalanceUnits(tokenIDs[1], alice, 1, values[1]); + + changePrank(bob); + vm.expectRevert(NotApprovedOrOwner.selector); + semiFungible.burnValue(alice, tokenIDs[1]); + + changePrank(alice); + vm.expectEmit(true, true, true, true); + emit TransferSingle(alice, alice, address(0), tokenIDs[1], 1); + semiFungible.burnValue(alice, tokenIDs[1]); + + semiFungible.validateNotOwnerNoBalanceNoUnits(tokenIDs[1], alice); + } + + function testBatchBurnFractions() public { + uint256 baseID = 1 << 128; + + uint256 size = 20; + uint256 value = 2000; + uint256[] memory values = semiFungible.buildValues(size, value); + uint256[] memory tokenIDs = semiFungible.buildIDs(baseID, size); + + uint256[] memory valueToBurn = new uint256[](2); + valueToBurn[0] = 1; + valueToBurn[1] = 1; + uint256[] memory idsToBurn = new uint256[](2); + idsToBurn[0] = tokenIDs[1]; + idsToBurn[1] = tokenIDs[7]; + uint256[] memory toTokens = new uint256[](2); + toTokens[0] = 0; + toTokens[1] = 0; + + startHoax(alice, 100 ether); + + semiFungible.mintValue(alice, values, _uri); + semiFungible.validateOwnerBalanceUnits(tokenIDs[1], alice, 1, values[1]); + + assertEq(semiFungible.unitsOf(tokenIDs[7]), 2000); + assertEq(semiFungible.unitsOf(baseID), size * value); + + changePrank(bob); + vm.expectRevert(NotApprovedOrOwner.selector); + semiFungible.batchBurnValues(alice, idsToBurn); + + changePrank(alice); + vm.expectEmit(true, true, true, true); + emit TransferBatch(alice, alice, address(0), idsToBurn, valueToBurn); + semiFungible.batchBurnValues(alice, idsToBurn); + + semiFungible.validateNotOwnerNoBalanceNoUnits(tokenIDs[1], alice); + assertEq(semiFungible.unitsOf(tokenIDs[1]), 0); + + semiFungible.validateNotOwnerNoBalanceNoUnits(tokenIDs[7], alice); + assertEq(semiFungible.unitsOf(tokenIDs[7]), 0); + + assertEq(semiFungible.unitsOf(baseID), size * value); + } + + function testCannotBurnClaim() public { + uint256 size = 20; + uint256 value = 2000; + uint256[] memory values = semiFungible.buildValues(size, value); + + startHoax(alice, 100 ether); + + uint256 baseID = semiFungible.mintValue(alice, values, _uri); + + vm.expectRevert("ERC1155: burn amount exceeds balance"); + semiFungible.burnValue(alice, baseID); + } + + function testCannotBatchBurnClaim() public { + uint256 size = 20; + uint256 value = 2000; + uint256[] memory values = semiFungible.buildValues(size, value); + + startHoax(alice, 100 ether); + + uint256 baseID = semiFungible.mintValue(alice, values, _uri); + + uint256[] memory idsToBurn = new uint256[](1); + idsToBurn[0] = baseID; + + vm.expectRevert("ERC1155: burn amount exceeds balance"); + semiFungible.batchBurnValues(alice, idsToBurn); + } +} diff --git a/contracts/test/foundry/SemiFungible1155.minting.t.sol b/contracts/test/foundry/protocol/SemiFungible1155.minting.t.sol similarity index 88% rename from contracts/test/foundry/SemiFungible1155.minting.t.sol rename to contracts/test/foundry/protocol/SemiFungible1155.minting.t.sol index ae7f78d6..9458a8cc 100644 --- a/contracts/test/foundry/SemiFungible1155.minting.t.sol +++ b/contracts/test/foundry/protocol/SemiFungible1155.minting.t.sol @@ -1,11 +1,11 @@ // SPDX-License-Identifier: UNLICENSED pragma solidity ^0.8.16; -import { PRBTest } from "prb-test/PRBTest.sol"; -import { stdError } from "forge-std/StdError.sol"; -import { StdCheats } from "forge-std/StdCheats.sol"; -import { StdUtils } from "forge-std/StdUtils.sol"; -import { SemiFungible1155Helper } from "./SemiFungibleHelper.sol"; +import {PRBTest} from "prb-test/PRBTest.sol"; +import {stdError} from "forge-std/StdError.sol"; +import {StdCheats} from "forge-std/StdCheats.sol"; +import {StdUtils} from "forge-std/StdUtils.sol"; +import {SemiFungible1155Helper} from "./SemiFungibleHelper.sol"; /// @dev See the "Writing Tests" section in the Foundry Book if this is your first time with Forge. /// https://book.getfoundry.sh/forge/writing-tests @@ -64,7 +64,7 @@ contract SemiFungible1155MintingTest is PRBTest, StdCheats, StdUtils, SemiFungib semiFungible.setMaxType(); vm.expectRevert(stdError.arithmeticError); - semiFungible.mintValue(alice, 10000, _uri); + semiFungible.mintValue(alice, 10_000, _uri); } // HAPPY MINTING @@ -81,17 +81,17 @@ contract SemiFungible1155MintingTest is PRBTest, StdCheats, StdUtils, SemiFungib // uint256 value vm.expectEmit(true, true, true, true); emit TransferSingle(alice, address(0), address(0), _baseID, 0); - uint256 baseID = semiFungible.mintValue(alice, 10000, _uri); + uint256 baseID = semiFungible.mintValue(alice, 10_000, _uri); assertEq(baseID, _baseID); assertEq(semiFungible.ownerOf(baseID), address(0)); assertEq(semiFungible.creator(baseID), alice); - assertEq(semiFungible.unitsOf(baseID), 10000); + assertEq(semiFungible.unitsOf(baseID), 10_000); - semiFungible.validateOwnerBalanceUnits(baseID + 1, alice, 1, 10000); + semiFungible.validateOwnerBalanceUnits(baseID + 1, alice, 1, 10_000); - assertEq(semiFungible.tokenValue(baseID), 10000); - assertEq(semiFungible.tokenValue(baseID + 1), 10000); + assertEq(semiFungible.tokenValue(baseID), 10_000); + assertEq(semiFungible.tokenValue(baseID + 1), 10_000); assertEq(semiFungible.tokenValue(baseID + 2), 0); } @@ -123,7 +123,7 @@ contract SemiFungible1155MintingTest is PRBTest, StdCheats, StdUtils, SemiFungib values[2] = 5000; uint256 baseID = semiFungible.mintValue(alice, values, _uri); - assertEq(semiFungible.unitsOf(baseID), 15000); + assertEq(semiFungible.unitsOf(baseID), 15_000); assertEq(semiFungible.ownerOf(baseID), address(0)); // Swap because of splitting logic diff --git a/contracts/test/foundry/SemiFungible1155.t.sol b/contracts/test/foundry/protocol/SemiFungible1155.t.sol similarity index 91% rename from contracts/test/foundry/SemiFungible1155.t.sol rename to contracts/test/foundry/protocol/SemiFungible1155.t.sol index 09918e69..ea5746c1 100644 --- a/contracts/test/foundry/SemiFungible1155.t.sol +++ b/contracts/test/foundry/protocol/SemiFungible1155.t.sol @@ -1,10 +1,10 @@ // SPDX-License-Identifier: UNLICENSED pragma solidity ^0.8.16; -import { PRBTest } from "prb-test/PRBTest.sol"; -import { StdCheats } from "forge-std/StdCheats.sol"; -import { StdUtils } from "forge-std/StdUtils.sol"; -import { SemiFungible1155Helper } from "./SemiFungibleHelper.sol"; +import {PRBTest} from "prb-test/PRBTest.sol"; +import {StdCheats} from "forge-std/StdCheats.sol"; +import {StdUtils} from "forge-std/StdUtils.sol"; +import {SemiFungible1155Helper} from "./SemiFungibleHelper.sol"; /// @dev See the "Writing Tests" section in the Foundry Book if this is your first time with Forge. /// https://book.getfoundry.sh/forge/writing-tests @@ -35,16 +35,16 @@ contract SemiFungible1155DefaultTest is PRBTest, StdCheats, StdUtils, SemiFungib startHoax(alice, 100 ether); - semiFungible.mintValue(alice, 10000, _uri); + semiFungible.mintValue(alice, 10_000, _uri); semiFungible.splitValue(alice, tokenID, values); - assertEq(semiFungible.unitsOf(baseID), 10000); + assertEq(semiFungible.unitsOf(baseID), 10_000); semiFungible.validateOwnerBalanceUnits(tokenID, alice, 1, values[0]); semiFungible.validateOwnerBalanceUnits(tokenID + 1, alice, 1, values[1]); // Units - assertEq(semiFungible.unitsOf(baseID), 10000); + assertEq(semiFungible.unitsOf(baseID), 10_000); assertEq(semiFungible.unitsOf(tokenID), 7000); assertEq(semiFungible.unitsOf(tokenID + 1), 3000); } diff --git a/contracts/test/foundry/SemiFungible1155.transfers.t.sol b/contracts/test/foundry/protocol/SemiFungible1155.transfers.t.sol similarity index 94% rename from contracts/test/foundry/SemiFungible1155.transfers.t.sol rename to contracts/test/foundry/protocol/SemiFungible1155.transfers.t.sol index 5a910740..bcad3900 100644 --- a/contracts/test/foundry/SemiFungible1155.transfers.t.sol +++ b/contracts/test/foundry/protocol/SemiFungible1155.transfers.t.sol @@ -1,10 +1,10 @@ // SPDX-License-Identifier: UNLICENSED pragma solidity ^0.8.16; -import { StdCheats } from "forge-std/StdCheats.sol"; -import { StdUtils } from "forge-std/StdUtils.sol"; -import { PRBTest } from "prb-test/PRBTest.sol"; -import { SemiFungible1155Helper } from "./SemiFungibleHelper.sol"; +import {StdCheats} from "forge-std/StdCheats.sol"; +import {StdUtils} from "forge-std/StdUtils.sol"; +import {PRBTest} from "prb-test/PRBTest.sol"; +import {SemiFungible1155Helper} from "./SemiFungibleHelper.sol"; /// @dev See the "Writing Tests" section in the Foundry Book if this is your first time with Forge. /// https://book.getfoundry.sh/forge/writing-tests @@ -24,14 +24,14 @@ contract SemiFungible1155TransferTest is PRBTest, StdCheats, StdUtils { // UNHAPPY PATHS function testFailTransferTypeIDToken() public { - semiFungible.mintValue(alice, 10000, _uri); + semiFungible.mintValue(alice, 10_000, _uri); //NotApprovedOrOWner, since no owner semiFungible.safeTransferFrom(alice, bob, 1 << 128, 1, ""); } function testFailTransferNonExistingFractionToken() public { - semiFungible.mintValue(alice, 10000, _uri); + semiFungible.mintValue(alice, 10_000, _uri); //NotApprovedOrOWner, since no owner semiFungible.safeTransferFrom(alice, bob, 1 << (128 + 2), 1, ""); @@ -59,10 +59,10 @@ contract SemiFungible1155TransferTest is PRBTest, StdCheats, StdUtils { uint256 baseID = 1 << 128; uint128 tokenID = 1; - semiFungible.mintValue(alice, 10000, _uri); + semiFungible.mintValue(alice, 10_000, _uri); assertEq(semiFungible.balanceOf(alice, baseID), 0); - semiFungible.validateOwnerBalanceUnits(baseID + tokenID, alice, 1, 10000); + semiFungible.validateOwnerBalanceUnits(baseID + tokenID, alice, 1, 10_000); assertEq(semiFungible.balanceOf(bob, baseID), 0); semiFungible.validateNotOwnerNoBalanceNoUnits(baseID + tokenID, bob); @@ -78,7 +78,7 @@ contract SemiFungible1155TransferTest is PRBTest, StdCheats, StdUtils { semiFungible.validateNotOwnerNoBalanceNoUnits(baseID + tokenID, alice); // Updates token ownership - semiFungible.validateOwnerBalanceUnits(baseID + tokenID, bob, 1, 10000); + semiFungible.validateOwnerBalanceUnits(baseID + tokenID, bob, 1, 10_000); } function testFuzzTransferFullToken(address from, address to, uint256 units) public { diff --git a/contracts/test/foundry/SemiFungible1155.units.sol b/contracts/test/foundry/protocol/SemiFungible1155.units.sol similarity index 89% rename from contracts/test/foundry/SemiFungible1155.units.sol rename to contracts/test/foundry/protocol/SemiFungible1155.units.sol index 654c1dbb..384bcdfb 100644 --- a/contracts/test/foundry/SemiFungible1155.units.sol +++ b/contracts/test/foundry/protocol/SemiFungible1155.units.sol @@ -1,10 +1,10 @@ // SPDX-License-Identifier: UNLICENSED pragma solidity ^0.8.16; -import { PRBTest } from "prb-test/PRBTest.sol"; -import { StdCheats } from "forge-std/StdCheats.sol"; -import { StdUtils } from "forge-std/StdUtils.sol"; -import { SemiFungible1155Helper } from "./SemiFungibleHelper.sol"; +import {PRBTest} from "prb-test/PRBTest.sol"; +import {StdCheats} from "forge-std/StdCheats.sol"; +import {StdUtils} from "forge-std/StdUtils.sol"; +import {SemiFungible1155Helper} from "./SemiFungibleHelper.sol"; /// @dev See the "Writing Tests" section in the Foundry Book if this is your first time with Forge. /// https://book.getfoundry.sh/forge/writing-tests @@ -28,11 +28,11 @@ contract SemiFungible1155UnitsTest is PRBTest, StdCheats, StdUtils { uint256 baseID = 1 << 128; uint128 tokenID = 1; - semiFungible.mintValue(alice, 10000, _uri); + semiFungible.mintValue(alice, 10_000, _uri); assertEq(semiFungible.unitsOf(baseID), 10_000); - semiFungible.validateOwnerBalanceUnits(baseID + tokenID, alice, 1, 10000); + semiFungible.validateOwnerBalanceUnits(baseID + tokenID, alice, 1, 10_000); semiFungible.validateNotOwnerNoBalanceNoUnits(baseID + tokenID, bob); @@ -51,7 +51,7 @@ contract SemiFungible1155UnitsTest is PRBTest, StdCheats, StdUtils { semiFungible.validateNotOwnerNoBalanceNoUnits(baseID + tokenID, alice); assertEq(semiFungible.balanceOf(bob, baseID), 0); - semiFungible.validateOwnerBalanceUnits(baseID + tokenID, bob, 1, 10000); + semiFungible.validateOwnerBalanceUnits(baseID + tokenID, bob, 1, 10_000); } function testUnitsMultipleFractions() public { diff --git a/contracts/test/foundry/SemiFungibleHelper.sol b/contracts/test/foundry/protocol/SemiFungibleHelper.sol similarity index 87% rename from contracts/test/foundry/SemiFungibleHelper.sol rename to contracts/test/foundry/protocol/SemiFungibleHelper.sol index 4d43a810..82a1c264 100644 --- a/contracts/test/foundry/SemiFungibleHelper.sol +++ b/contracts/test/foundry/protocol/SemiFungibleHelper.sol @@ -1,9 +1,10 @@ // SPDX-License-Identifier: UNLICENSED pragma solidity ^0.8.16; -import { SemiFungible1155 } from "../../src/SemiFungible1155.sol"; -import { PRBTest } from "prb-test/PRBTest.sol"; -import { StdCheats } from "forge-std/StdCheats.sol"; -import { StdUtils } from "forge-std/StdUtils.sol"; + +import {SemiFungible1155} from "@hypercerts/protocol/SemiFungible1155.sol"; +import {PRBTest} from "prb-test/PRBTest.sol"; +import {StdCheats} from "forge-std/StdCheats.sol"; +import {StdUtils} from "forge-std/StdUtils.sol"; contract SemiFungible1155Helper is SemiFungible1155, PRBTest, StdCheats, StdUtils { error FractionalBurn(); @@ -51,6 +52,10 @@ contract SemiFungible1155Helper is SemiFungible1155, PRBTest, StdCheats, StdUtil _burnToken(account, tokenID); } + function batchBurnValues(address account, uint256[] memory tokenIDs) public { + _batchBurnToken(account, tokenIDs); + } + function unitsOf(uint256 tokenID) public view returns (uint256) { return _unitsOf(tokenID); } @@ -86,18 +91,24 @@ contract SemiFungible1155Helper is SemiFungible1155, PRBTest, StdCheats, StdUtil return 0; } sum = 0; - for (uint256 i = 0; i < array.length; i++) sum += array[i]; + for (uint256 i = 0; i < array.length; i++) { + sum += array[i]; + } } function buildValues(uint256 size, uint256 base) public pure returns (uint256[] memory) { uint256[] memory _values = new uint256[](size); - for (uint256 i = 0; i < size; i++) _values[i] = base; + for (uint256 i = 0; i < size; i++) { + _values[i] = base; + } return _values; } function buildIDs(uint256 baseID, uint256 size) public pure returns (uint256[] memory) { uint256[] memory _values = new uint256[](size); - for (uint256 i = 0; i < size; i++) _values[i] = baseID + i + 1; + for (uint256 i = 0; i < size; i++) { + _values[i] = baseID + i + 1; + } return _values; } diff --git a/contracts/test/mock/MockChainlinkAggregator.sol b/contracts/test/mock/MockChainlinkAggregator.sol new file mode 100644 index 00000000..a102b079 --- /dev/null +++ b/contracts/test/mock/MockChainlinkAggregator.sol @@ -0,0 +1,31 @@ +// SPDX-License-Identifier: MIT +pragma solidity >=0.8.17; + +contract MockChainlinkAggregator { + int256 private _answer; + uint8 private _decimals = 18; + + function setDecimals(uint8 newDecimals) external { + _decimals = newDecimals; + } + + function decimals() external view returns (uint8) { + return _decimals; + } + + function setAnswer(int256 answer) external { + _answer = answer; + } + + function latestRoundData() + external + view + returns (uint80 roundId, int256 answer, uint256 startedAt, uint256 updatedAt, uint80 answeredInRound) + { + roundId = 1; + answer = _answer; + startedAt = block.timestamp; + updatedAt = block.timestamp; + answeredInRound = 1; + } +} diff --git a/contracts/test/mock/MockERC1155.sol b/contracts/test/mock/MockERC1155.sol new file mode 100644 index 00000000..4bbfdccd --- /dev/null +++ b/contracts/test/mock/MockERC1155.sol @@ -0,0 +1,29 @@ +// SPDX-License-Identifier: MIT +pragma solidity >=0.8.7; + +import {ERC1155} from "solmate/src/tokens/ERC1155.sol"; + +// LooksRare unopinionated libraries +import {IERC2981} from "@looksrare/contracts-libs/contracts/interfaces/generic/IERC2981.sol"; + +contract MockERC1155 is ERC1155 { + function batchMint(address to, uint256[] memory tokenIds, uint256[] memory amounts) public { + _batchMint(to, tokenIds, amounts, ""); + } + + function mint(address to, uint256 tokenId, uint256 amount) public { + _mint(to, tokenId, amount, ""); + } + + function uri(uint256) public pure override returns (string memory) { + return "uri"; + } + + function royaltyInfo(uint256, uint256) external pure returns (address, uint256) { + return (address(0), 0); + } + + function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { + return interfaceId == type(IERC2981).interfaceId || super.supportsInterface(interfaceId); + } +} diff --git a/contracts/test/mock/MockERC1155SupportsNoInterface.sol b/contracts/test/mock/MockERC1155SupportsNoInterface.sol new file mode 100644 index 00000000..34b9da89 --- /dev/null +++ b/contracts/test/mock/MockERC1155SupportsNoInterface.sol @@ -0,0 +1,10 @@ +// SPDX-License-Identifier: MIT +pragma solidity >=0.8.7; + +import {MockERC1155} from "./MockERC1155.sol"; + +contract MockERC1155SupportsNoInterface is MockERC1155 { + function supportsInterface(bytes4) public view virtual override returns (bool) { + return false; + } +} diff --git a/contracts/test/mock/MockERC1155WithoutAnyBalanceOf.sol b/contracts/test/mock/MockERC1155WithoutAnyBalanceOf.sol new file mode 100644 index 00000000..4474f875 --- /dev/null +++ b/contracts/test/mock/MockERC1155WithoutAnyBalanceOf.sol @@ -0,0 +1,21 @@ +// SPDX-License-Identifier: MIT +pragma solidity >=0.8.7; + +import {ERC1155} from "@openzeppelin/contracts/token/ERC1155/ERC1155.sol"; + +/** + * @dev This contract has to inherit from OZ instead of Solmate because + * Solmate's implementation defines balanceOf as a public mapping + * and it cannot be overridden. + */ +contract MockERC1155WithoutAnyBalanceOf is ERC1155 { + constructor() ERC1155("https://example.com") {} + + function balanceOf(address, uint256) public view virtual override returns (uint256) { + revert("Not implemented"); + } + + function balanceOfBatch(address[] memory, uint256[] memory) public pure override returns (uint256[] memory) { + revert("Not implemented"); + } +} diff --git a/contracts/test/mock/MockERC1155WithoutBalanceOfBatch.sol b/contracts/test/mock/MockERC1155WithoutBalanceOfBatch.sol new file mode 100644 index 00000000..1c010cae --- /dev/null +++ b/contracts/test/mock/MockERC1155WithoutBalanceOfBatch.sol @@ -0,0 +1,10 @@ +// SPDX-License-Identifier: MIT +pragma solidity >=0.8.7; + +import {MockERC1155} from "./MockERC1155.sol"; + +contract MockERC1155WithoutBalanceOfBatch is MockERC1155 { + function balanceOfBatch(address[] calldata, uint256[] calldata) public pure override returns (uint256[] memory) { + revert("Not implemented"); + } +} diff --git a/contracts/test/mock/MockERC1155WithoutIsApprovedForAll.sol b/contracts/test/mock/MockERC1155WithoutIsApprovedForAll.sol new file mode 100644 index 00000000..c02c4192 --- /dev/null +++ b/contracts/test/mock/MockERC1155WithoutIsApprovedForAll.sol @@ -0,0 +1,21 @@ +// SPDX-License-Identifier: MIT +pragma solidity >=0.8.7; + +import {ERC1155} from "@openzeppelin/contracts/token/ERC1155/ERC1155.sol"; + +/** + * @dev This contract has to inherit from OZ instead of Solmate because + * Solmate's implementation defines isApprovedForAll as a public mapping + * and it cannot be overridden. + */ +contract MockERC1155WithoutIsApprovedForAll is ERC1155 { + constructor() ERC1155("https://example.com") {} + + function mint(address to, uint256 tokenId, uint256 amount) public { + _mint(to, tokenId, amount, ""); + } + + function isApprovedForAll(address, address) public view virtual override returns (bool) { + revert("Not implemented"); + } +} diff --git a/contracts/test/mock/MockERC20.sol b/contracts/test/mock/MockERC20.sol new file mode 100644 index 00000000..019bed0e --- /dev/null +++ b/contracts/test/mock/MockERC20.sol @@ -0,0 +1,10 @@ +// SPDX-License-Identifier: MIT +pragma solidity >=0.8.7; + +import {ERC20} from "solmate/src/tokens/ERC20.sol"; + +contract MockERC20 is ERC20("MockERC20", "MockERC20", 18) { + function mint(address to, uint256 amount) public { + _mint(to, amount); + } +} diff --git a/contracts/test/mock/MockERC721.sol b/contracts/test/mock/MockERC721.sol new file mode 100644 index 00000000..4db2eed7 --- /dev/null +++ b/contracts/test/mock/MockERC721.sol @@ -0,0 +1,31 @@ +// SPDX-License-Identifier: MIT +pragma solidity >=0.8.7; + +import {ERC721} from "solmate/src/tokens/ERC721.sol"; +import {IERC165} from "@looksrare/contracts-libs/contracts/interfaces/generic/IERC165.sol"; + +contract MockERC721 is ERC721("MockERC721", "MockERC721") { + function mint(address to, uint256 tokenId) public { + _mint(to, tokenId); + } + + function batchMint(address to, uint256 amount) external { + for (uint256 i; i < amount; i++) { + _mint(to, i); + } + } + + function batchMint(address to, uint256[] memory tokenIds) public { + for (uint256 i; i < tokenIds.length; i++) { + _mint(to, tokenIds[i]); + } + } + + function tokenURI(uint256) public pure override returns (string memory) { + return "tokenURI"; + } + + function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { + return super.supportsInterface(interfaceId); + } +} diff --git a/contracts/test/mock/MockERC721SupportsNoInterface.sol b/contracts/test/mock/MockERC721SupportsNoInterface.sol new file mode 100644 index 00000000..e5a6c5e3 --- /dev/null +++ b/contracts/test/mock/MockERC721SupportsNoInterface.sol @@ -0,0 +1,10 @@ +// SPDX-License-Identifier: MIT +pragma solidity >=0.8.7; + +import {MockERC721} from "./MockERC721.sol"; + +contract MockERC721SupportsNoInterface is MockERC721 { + function supportsInterface(bytes4) public view virtual override returns (bool) { + return false; + } +} diff --git a/contracts/test/mock/MockERC721WithRoyalties.sol b/contracts/test/mock/MockERC721WithRoyalties.sol new file mode 100644 index 00000000..071e2432 --- /dev/null +++ b/contracts/test/mock/MockERC721WithRoyalties.sol @@ -0,0 +1,53 @@ +// SPDX-License-Identifier: MIT +pragma solidity 0.8.17; + +import {IERC165, IERC2981} from "@looksrare/contracts-libs/contracts/interfaces/generic/IERC2981.sol"; +import {MockERC721} from "./MockERC721.sol"; + +// Constants +import {ONE_HUNDRED_PERCENT_IN_BP} from "@hypercerts/marketplace/constants/NumericConstants.sol"; + +/** + * @dev This contract allows adding a royalty basis points higher than 10,000, which + * reverts during the royaltyInfo call. The purpose is to create a scenario where + * royaltyInfo returns the correct response for some token IDs and reverts for some + * other token IDs. This can potentially happen in a bundle transaction. + */ +contract MockERC721WithRoyalties is MockERC721, IERC2981 { + address public immutable DEFAULT_ROYALTY_RECIPIENT; + uint256 public immutable DEFAULT_ROYALTY_FEE; + + mapping(uint256 => uint256) internal _royaltyFeeForTokenId; + mapping(uint256 => address) internal _royaltyRecipientForTokenId; + + constructor(address _royaltyFeeRecipient, uint256 _royaltyFee) { + DEFAULT_ROYALTY_RECIPIENT = _royaltyFeeRecipient; + DEFAULT_ROYALTY_FEE = _royaltyFee; + } + + function addCustomRoyaltyInformationForTokenId(uint256 tokenId, address royaltyRecipient, uint256 royaltyFee) + external + { + _royaltyRecipientForTokenId[tokenId] = royaltyRecipient; + _royaltyFeeForTokenId[tokenId] = royaltyFee; + } + + function royaltyInfo(uint256 tokenId, uint256 salePrice) + external + view + override + returns (address royaltyRecipient, uint256 royaltyAmount) + { + royaltyRecipient = _royaltyRecipientForTokenId[tokenId] == address(0) + ? DEFAULT_ROYALTY_RECIPIENT + : _royaltyRecipientForTokenId[tokenId]; + uint256 _royaltyFee = _royaltyFeeForTokenId[tokenId]; + uint256 royaltyFee = _royaltyFee == 0 ? DEFAULT_ROYALTY_FEE : _royaltyFee; + require(royaltyFee <= ONE_HUNDRED_PERCENT_IN_BP, "Royalty too high"); + royaltyAmount = (royaltyFee * salePrice) / ONE_HUNDRED_PERCENT_IN_BP; + } + + function supportsInterface(bytes4 interfaceId) public view override(MockERC721, IERC165) returns (bool) { + return interfaceId == 0x2a55205a || super.supportsInterface(interfaceId); + } +} diff --git a/contracts/test/mock/MockRoyaltyFeeRegistry.sol b/contracts/test/mock/MockRoyaltyFeeRegistry.sol new file mode 100644 index 00000000..d9700825 --- /dev/null +++ b/contracts/test/mock/MockRoyaltyFeeRegistry.sol @@ -0,0 +1,95 @@ +// SPDX-License-Identifier: MIT +pragma solidity 0.8.17; + +// LooksRare unopinionated libraries +import {OwnableTwoSteps} from "@looksrare/contracts-libs/contracts/OwnableTwoSteps.sol"; + +// Royalty Fee Registry interface +import {IRoyaltyFeeRegistry} from "@hypercerts/marketplace/interfaces/IRoyaltyFeeRegistry.sol"; + +// Constants +import {ONE_HUNDRED_PERCENT_IN_BP} from "@hypercerts/marketplace/constants/NumericConstants.sol"; + +/** + * @title MockRoyaltyFeeRegistry + * @notice It is a royalty fee registry for the LooksRare exchange. + * @dev The original one used the standard Ownable library from OpenZeppelin. + */ +contract MockRoyaltyFeeRegistry is IRoyaltyFeeRegistry, OwnableTwoSteps { + struct FeeInfo { + address setter; + address receiver; + uint256 fee; + } + + // Limit (if enforced for fee royalty in basis point (10,000 = 100%) + uint256 public royaltyFeeLimit; + + mapping(address => FeeInfo) private _royaltyFeeInfoCollection; + + event NewRoyaltyFeeLimit(uint256 royaltyFeeLimit); + event RoyaltyFeeUpdate(address indexed collection, address indexed setter, address indexed receiver, uint256 fee); + + /** + * @notice Constructor + * @param _owner Owner address + * @param _royaltyFeeLimit new royalty fee limit (500 = 5%, 1,000 = 10%) + */ + constructor(address _owner, uint256 _royaltyFeeLimit) OwnableTwoSteps(_owner) { + require(_royaltyFeeLimit <= 9500, "Owner: Royalty fee limit too high"); + royaltyFeeLimit = _royaltyFeeLimit; + } + + /** + * @notice Update royalty info for collection + * @param _royaltyFeeLimit new royalty fee limit (500 = 5%, 1,000 = 10%) + */ + function updateRoyaltyFeeLimit(uint256 _royaltyFeeLimit) external onlyOwner { + require(_royaltyFeeLimit <= 9500, "Owner: Royalty fee limit too high"); + royaltyFeeLimit = _royaltyFeeLimit; + + emit NewRoyaltyFeeLimit(_royaltyFeeLimit); + } + + /** + * @notice Update royalty info for collection + * @param collection address of the NFT contract + * @param setter address that sets the receiver + * @param receiver receiver for the royalty fee + * @param fee fee (500 = 5%, 1,000 = 10%) + */ + function updateRoyaltyInfoForCollection(address collection, address setter, address receiver, uint256 fee) + external + onlyOwner + { + require(fee <= royaltyFeeLimit, "Registry: Royalty fee too high"); + _royaltyFeeInfoCollection[collection] = FeeInfo({setter: setter, receiver: receiver, fee: fee}); + + emit RoyaltyFeeUpdate(collection, setter, receiver, fee); + } + + /** + * @notice Calculate royalty info for a collection address and a sale gross amount + * @param collection collection address + * @param amount amount + * @return receiver address and amount received by royalty recipient + */ + function royaltyInfo(address collection, uint256 amount) external view returns (address, uint256) { + return ( + _royaltyFeeInfoCollection[collection].receiver, + (amount * _royaltyFeeInfoCollection[collection].fee) / ONE_HUNDRED_PERCENT_IN_BP + ); + } + + /** + * @notice View royalty info for a collection address + * @param collection collection address + */ + function royaltyFeeInfoCollection(address collection) external view returns (address, address, uint256) { + return ( + _royaltyFeeInfoCollection[collection].setter, + _royaltyFeeInfoCollection[collection].receiver, + _royaltyFeeInfoCollection[collection].fee + ); + } +} diff --git a/contracts/test/mock/MockSmartWallet.sol b/contracts/test/mock/MockSmartWallet.sol new file mode 100644 index 00000000..77d02b61 --- /dev/null +++ b/contracts/test/mock/MockSmartWallet.sol @@ -0,0 +1,65 @@ +// SPDX-License-Identifier: MIT +pragma solidity >=0.8.17; + +contract MockSmartWallet { + address public owner; + + bytes4 internal constant MAGICVALUE = bytes4(keccak256("isValidSignature(bytes32,bytes)")); + + modifier onlyOwner() { + if (msg.sender != owner) { + revert("Unauthorized"); + } + _; + } + + constructor() { + owner = msg.sender; + } + + receive() external payable {} + + function transferOwnership(address _newOwner) external onlyOwner { + owner = _newOwner; + } + + function executeBatch(address[] calldata dest, bytes[] calldata calldata_) external onlyOwner { + if (dest.length != calldata_.length) { + revert("Invalid array length"); + } + for (uint256 i = 0; i < dest.length; ++i) { + execute(dest[i], 0, calldata_[i]); + } + } + + function isValidSignature(bytes32 _hash, bytes memory _signature) external view returns (bytes4 magicValue) { + bytes32 r; + bytes32 s; + uint8 v; + + assembly { + r := mload(add(_signature, 0x20)) + s := mload(add(_signature, 0x40)) + v := byte(0, mload(add(_signature, 0x60))) + } + address recovered = ecrecover(_hash, v, r, s); + if (recovered == address(0)) { + revert("Invalid signature"); + } + if (owner != recovered) { + revert("Invalid signer"); + } + + return MAGICVALUE; + } + + function execute(address dest, uint256 value, bytes calldata calldata_) public onlyOwner { + (bool success, bytes memory result) = dest.call{value: value}(calldata_); + + if (!success) { + assembly { + revert(add(result, 32), mload(result)) + } + } + } +} diff --git a/contracts/tsconfig.build.json b/contracts/tsconfig.build.json index d2a57421..e9929279 100644 --- a/contracts/tsconfig.build.json +++ b/contracts/tsconfig.build.json @@ -22,11 +22,17 @@ }, "include": ["./src"], "files": [ - "src/abi/HypercertMinter.json", - "src/types/src/AllowlistMinter.ts", - "src/types/src/HypercertMinter.ts", - "src/types/src/interfaces/IAllowlist.ts", - "src/types/src/interfaces/IHypercertToken.ts", - "src/types/src/libs/Errors.ts" + "types/src/marketplace/CurrencyManager.ts", + "types/src/marketplace/ExecutionManager.ts", + "types/src/marketplace/LooksRareProtocol.ts", + "types/src/marketplace/NonceManager.ts", + "types/src/marketplace/helpers/OrderValidatorV2A.ts", + "types/src/marketplace/StrategyManager.ts", + "types/src/marketplace/TransferManager.ts", + "types/src/protocol/AllowlistMinter.ts", + "types/src/protocol/HypercertMinter.ts", + "types/src/protocol/interfaces/IAllowlist.ts", + "types/src/protocol/interfaces/IHypercertToken.ts", + "types/src/protocol/libs/Errors.ts" ] } diff --git a/contracts/tsconfig.json b/contracts/tsconfig.json index 8d0a6cfc..a3e3d8dc 100644 --- a/contracts/tsconfig.json +++ b/contracts/tsconfig.json @@ -20,14 +20,19 @@ "target": "ESNext", "outDir": "dist" }, - "include": ["./tasks", "./test", "./types", "./src"], + "include": ["./tasks", "./test", "./src"], "files": [ - "hardhat.config.ts", - "src/abi/HypercertMinter.json", - "src/types/src/AllowlistMinter.ts", - "src/types/src/HypercertMinter.ts", - "src/types/src/interfaces/IAllowlist.ts", - "src/types/src/interfaces/IHypercertToken.ts", - "src/types/src/libs/Errors.ts" + "types/src/marketplace/CurrencyManager.ts", + "types/src/marketplace/ExecutionManager.ts", + "types/src/marketplace/LooksRareProtocol.ts", + "types/src/marketplace/NonceManager.ts", + "types/src/marketplace/helpers/OrderValidatorV2A.ts", + "types/src/marketplace/StrategyManager.ts", + "types/src/marketplace/TransferManager.ts", + "types/src/protocol/AllowlistMinter.ts", + "types/src/protocol/HypercertMinter.ts", + "types/src/protocol/interfaces/IAllowlist.ts", + "types/src/protocol/interfaces/IHypercertToken.ts", + "types/src/protocol/libs/Errors.ts" ] } diff --git a/cors-proxy/src/index.ts b/cors-proxy/src/index.ts index e88e6e3d..aaa9a400 100644 --- a/cors-proxy/src/index.ts +++ b/cors-proxy/src/index.ts @@ -69,6 +69,9 @@ export default { // Rewrite request to point to API URL. This also makes the request mutable // so you can add the correct Origin header to make the API server think // that this request is not cross-site. + // TODO: Never use ts ignore + // eslint-disable-next-line @typescript-eslint/ban-ts-comment + // @ts-ignore request = new Request(apiUrl, request); request.headers.set("Origin", new URL(apiUrl).origin); let response = await fetch(request); diff --git a/defender/.eslintrc.yml b/defender/.eslintrc.yml index fb4528bd..07ab4df0 100644 --- a/defender/.eslintrc.yml +++ b/defender/.eslintrc.yml @@ -9,7 +9,7 @@ parserOptions: plugins: - "@typescript-eslint" root: true -ignorePatterns: ["rollup.config.js", "jest.config.ts", "build/"] +ignorePatterns: ["build/"] rules: "@typescript-eslint/semi": - warn diff --git a/defender/package.json b/defender/package.json index f2da4c70..2d8a57f4 100644 --- a/defender/package.json +++ b/defender/package.json @@ -14,10 +14,10 @@ }, "dependencies": { "@hypercerts-org/contracts": "0.8.11", - "@openzeppelin/defender-autotask-client": "^1.48.0", - "@openzeppelin/defender-autotask-utils": "^1.48.0", - "@openzeppelin/defender-base-client": "^1.48.0", - "@openzeppelin/defender-sentinel-client": "^1.48.0", + "@openzeppelin/defender-autotask-client": "1.50.0", + "@openzeppelin/defender-autotask-utils": "1.50.0", + "@openzeppelin/defender-base-client": "1.49.0", + "@openzeppelin/defender-sentinel-client": "1.49.0", "@openzeppelin/merkle-tree": "^1.0.2", "@supabase/supabase-js": "^2.4.1", "axios": "^1.2.6", diff --git a/defender/src/auto-tasks/batch-mint-claims-from-allowlists.ts b/defender/src/auto-tasks/batch-mint-claims-from-allowlists.ts index 558983f6..578f6aa8 100644 --- a/defender/src/auto-tasks/batch-mint-claims-from-allowlists.ts +++ b/defender/src/auto-tasks/batch-mint-claims-from-allowlists.ts @@ -13,14 +13,6 @@ import { BigNumber, ethers } from "ethers"; import fetch from "node-fetch"; export async function handler(event: AutotaskEvent) { - console.log( - "Event: ", - JSON.stringify( - { ...event, secrets: "HIDDEN", credentials: "HIDDEN" }, - null, - 2, - ), - ); const network = getNetworkConfigFromName(event.autotaskName); const { SUPABASE_URL, SUPABASE_SECRET_API_KEY } = event.secrets; const ALCHEMY_KEY = event.secrets[network.alchemyKeyEnvName]; diff --git a/defender/src/networks.ts b/defender/src/networks.ts index ffbc1fba..80aa187b 100644 --- a/defender/src/networks.ts +++ b/defender/src/networks.ts @@ -30,7 +30,6 @@ export const NETWORKS: SupportedNetworks = { { networkKey: "sepolia", contractAddress: "0xa16DFb32Eb140a6f3F2AC68f41dAd8c7e83C4941", - alchemyKeyEnvName: "ALCHEMY_SEPOLIA_KEY", chainId: 11155111, rpc: "https://rpc.sepolia.org", }, diff --git a/defender/src/update.ts b/defender/src/update.ts index 874b2d00..f7fbf463 100644 --- a/defender/src/update.ts +++ b/defender/src/update.ts @@ -27,8 +27,9 @@ export const updateAutotask = async (networks: NetworkConfig[]) => { autotaskClient .updateCodeFromFolder(autoTask.autotaskId, `./build/relay/${name}`) - .then((_) => { + .then((res) => { console.log(`Updated ${autoTask.autotaskId}`); + console.log(res); }) .catch((err) => { console.error(`Failed to update ${autoTask.autotaskId}`); @@ -67,8 +68,9 @@ export const updateSentinel = async (networks: NetworkConfig[]) => { addresses: [network.contractAddress], abi, }) - .then((_) => { + .then((res) => { console.log(`Updated: ", ${sentinel.subscriberId}`); + console.log(res); }) .catch((err) => { console.error(`Failed to update ${sentinel.subscriberId}`); diff --git a/docs/.eslintrc.yml b/docs/.eslintrc.yml new file mode 100644 index 00000000..c1258f9f --- /dev/null +++ b/docs/.eslintrc.yml @@ -0,0 +1,27 @@ +extends: + - "eslint:recommended" + - "plugin:@typescript-eslint/eslint-recommended" + - "plugin:@typescript-eslint/recommended" + - "prettier" +parser: "@typescript-eslint/parser" +parserOptions: + project: "./docs/tsconfig.json" +plugins: + - "@docusaurus" + - "@typescript-eslint" +root: true +ignorePatterns: ["build/"] +rules: + "@typescript-eslint/semi": + - warn + "@typescript-eslint/switch-exhaustiveness-check": + - warn + "@typescript-eslint/no-floating-promises": + - error + - ignoreIIFE: true + ignoreVoid: true + "@typescript-eslint/no-inferrable-types": "off" + "@typescript-eslint/no-unused-vars": + - error + - argsIgnorePattern: "_" + varsIgnorePattern: "_" diff --git a/docs/docs/developer/api/contracts/HypercertMinter.md b/docs/docs/developer/api/contracts/HypercertMinter.md index 785dd5cf..518efa42 100644 --- a/docs/docs/developer/api/contracts/HypercertMinter.md +++ b/docs/docs/developer/api/contracts/HypercertMinter.md @@ -60,6 +60,23 @@ _See {IERC1155-balanceOfBatch}. Requirements: - `accounts` and `ids` must have t | ---- | --------- | ----------- | | \_0 | uint256[] | undefined | +### batchBurnFraction + +```solidity +function batchBurnFraction(address _account, uint256[] _tokenIDs) external nonpayable +``` + +Burn a claimtoken + +_see {IHypercertToken}_ + +#### Parameters + +| Name | Type | Description | +| ---------- | --------- | ----------- | +| \_account | address | undefined | +| \_tokenIDs | uint256[] | undefined | + ### batchMintClaimsFromAllowlists ```solidity @@ -82,30 +99,38 @@ _Calls AllowlistMinter to verify `proofs`.Mints the `amount` of units for the hy ### burn ```solidity -function burn(address account, uint256 id, uint256 value) external nonpayable +function burn(address account, uint256 id, uint256) external nonpayable ``` +Burn a claimtoken; override is needed to update units/values + +_see {ERC1155Burnable}_ + #### Parameters | Name | Type | Description | | ------- | ------- | ----------- | | account | address | undefined | | id | uint256 | undefined | -| value | uint256 | undefined | +| \_2 | uint256 | undefined | ### burnBatch ```solidity -function burnBatch(address account, uint256[] ids, uint256[] values) external nonpayable +function burnBatch(address account, uint256[] ids, uint256[]) external nonpayable ``` +Batch burn claimtokens; override is needed to update units/values + +_see {ERC1155Burnable}_ + #### Parameters | Name | Type | Description | | ------- | --------- | ----------- | | account | address | undefined | | ids | uint256[] | undefined | -| values | uint256[] | undefined | +| \_2 | uint256[] | undefined | ### burnFraction @@ -319,19 +344,19 @@ _Returns the address of the current owner._ function ownerOf(uint256 tokenID) external view returns (address _owner) ``` -READ +_Returns the owner of a given token ID._ #### Parameters -| Name | Type | Description | -| ------- | ------- | ----------- | -| tokenID | uint256 | undefined | +| Name | Type | Description | +| ------- | ------- | ----------------------------- | +| tokenID | uint256 | The ID of the token to query. | #### Returns -| Name | Type | Description | -| ------- | ------- | ----------- | -| \_owner | address | undefined | +| Name | Type | Description | +| ------- | ------- | -------------------------------------- | +| \_owner | address | The address of the owner of the token. | ### pause diff --git a/docs/docs/developer/api/contracts/HypercertTrader.md b/docs/docs/developer/api/contracts/HypercertTrader.md new file mode 100644 index 00000000..e31e8840 --- /dev/null +++ b/docs/docs/developer/api/contracts/HypercertTrader.md @@ -0,0 +1,434 @@ +# HypercertTrader + +_bitbeckers_ + +> Contract for managing hypercert trades + +Implementation of the HypercertTrader Interface + +## Methods + +### batchBuyUnits + +```solidity +function batchBuyUnits(address recipient, uint256[] offerIDs, uint256[] unitAmounts, address[] buyTokens, uint256[] tokenAmountsPerUnit) external payable +``` + +This function allows a user to buy Hypercert tokens from multiple existing offers in a single transaction. The function takes in several arrays of parameters, including the IDs of the offers to buy from, the number of units to buy for each offer, the tokens used for payment for each offer, and the amounts of tokens to pay per unit for each offer. The function then executes the trades and transfers the Hypercert tokens to the specified recipient. + +_Buys Hypercert tokens from multiple existing offers in a single transaction._ + +#### Parameters + +| Name | Type | Description | +| ------------------- | --------- | -------------------------------------------------------------------- | +| recipient | address | The address that will receive the Hypercert tokens. | +| offerIDs | uint256[] | The list of IDs of the offers to buy from. | +| unitAmounts | uint256[] | The list of numbers of units to buy for each offer. | +| buyTokens | address[] | The list of addresses of the tokens used for payment for each offer. | +| tokenAmountsPerUnit | uint256[] | The list of amounts of tokens to pay per unit for each offer. | + +### buyUnits + +```solidity +function buyUnits(address recipient, uint256 offerID, uint256 unitAmount, address buyToken, uint256 tokenAmountPerUnit) external payable +``` + +This function buys Hypercert tokens from an existing offer. The function verifies that the offer is valid and that the buyer has provided enough payment in the specified token. If the offer is for a fraction of a Hypercert token, the function splits the fraction and transfers the appropriate number of units to the buyer. If the offer is for a fixed number of units, the function transfers the units to the buyer. The function also transfers the payment to the offerer and emits a `Trade` event. + +_Buys Hypercert tokens from an existing offer._ + +#### Parameters + +| Name | Type | Description | +| ------------------ | ------- | --------------------------------------------------- | +| recipient | address | The address that will receive the Hypercert tokens. | +| offerID | uint256 | The ID of the offer to buy from. | +| unitAmount | uint256 | The number of units to buy. | +| buyToken | address | The address of the token used for payment. | +| tokenAmountPerUnit | uint256 | The amount of tokens to pay per unit. | + +### cancelOffer + +```solidity +function cancelOffer(uint256 offerID) external nonpayable +``` + +This function cancels an existing offer. The function verifies that the offer exists and that the caller is the offerer. The function sets the offer status to `Cancelled` and emits an `OfferCancelled` event. + +_Cancels an existing offer._ + +#### Parameters + +| Name | Type | Description | +| ------- | ------- | ------------------------------ | +| offerID | uint256 | The ID of the offer to cancel. | + +### createOffer + +```solidity +function createOffer(address hypercertContract, uint256 fractionID, uint256 unitsForSale, uint256 minUnitsPerTrade, uint256 maxUnitsPerTrade, IHypercertTrader.AcceptedToken[] acceptedTokens) external payable returns (uint256 offerID) +``` + +#### Parameters + +| Name | Type | Description | +| ----------------- | -------------------------------- | ----------- | +| hypercertContract | address | undefined | +| fractionID | uint256 | undefined | +| unitsForSale | uint256 | undefined | +| minUnitsPerTrade | uint256 | undefined | +| maxUnitsPerTrade | uint256 | undefined | +| acceptedTokens | IHypercertTrader.AcceptedToken[] | undefined | + +#### Returns + +| Name | Type | Description | +| ------- | ------- | ----------- | +| offerID | uint256 | undefined | + +### getOffer + +```solidity +function getOffer(uint256 offerID) external view returns (struct IHypercertTrader.Offer) +``` + +#### Parameters + +| Name | Type | Description | +| ------- | ------- | ----------- | +| offerID | uint256 | undefined | + +#### Returns + +| Name | Type | Description | +| ---- | ---------------------- | ----------- | +| \_0 | IHypercertTrader.Offer | undefined | + +### initialize + +```solidity +function initialize() external nonpayable +``` + +_see { openzeppelin-contracts-upgradeable/contracts/proxy/utils/Initializable.sol }_ + +### offers + +```solidity +function offers(uint256) external view returns (address offerer, address hypercertContract, uint256 fractionID, uint256 unitsAvailable, uint256 minUnitsPerTrade, uint256 maxUnitsPerTrade, enum IHypercertTrader.OfferType offerType, enum IHypercertTrader.OfferStatus status) +``` + +#### Parameters + +| Name | Type | Description | +| ---- | ------- | ----------- | +| \_0 | uint256 | undefined | + +#### Returns + +| Name | Type | Description | +| ----------------- | --------------------------------- | ----------- | +| offerer | address | undefined | +| hypercertContract | address | undefined | +| fractionID | uint256 | undefined | +| unitsAvailable | uint256 | undefined | +| minUnitsPerTrade | uint256 | undefined | +| maxUnitsPerTrade | uint256 | undefined | +| offerType | enum IHypercertTrader.OfferType | undefined | +| status | enum IHypercertTrader.OfferStatus | undefined | + +### owner + +```solidity +function owner() external view returns (address) +``` + +_Returns the address of the current owner._ + +#### Returns + +| Name | Type | Description | +| ---- | ------- | ----------- | +| \_0 | address | undefined | + +### pause + +```solidity +function pause() external nonpayable +``` + +PAUSABLE + +### paused + +```solidity +function paused() external view returns (bool) +``` + +_Returns true if the contract is paused, and false otherwise._ + +#### Returns + +| Name | Type | Description | +| ---- | ---- | ----------- | +| \_0 | bool | undefined | + +### proxiableUUID + +```solidity +function proxiableUUID() external view returns (bytes32) +``` + +_Implementation of the ERC1822 {proxiableUUID} function. This returns the storage slot used by the implementation. It is used to validate the implementation's compatibility when performing an upgrade. IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this function revert if invoked through a proxy. This is guaranteed by the `notDelegated` modifier._ + +#### Returns + +| Name | Type | Description | +| ---- | ------- | ----------- | +| \_0 | bytes32 | undefined | + +### renounceOwnership + +```solidity +function renounceOwnership() external nonpayable +``` + +_Leaves the contract without owner. It will not be possible to call `onlyOwner` functions anymore. Can only be called by the current owner. NOTE: Renouncing ownership will leave the contract without an owner, thereby removing any functionality that is only available to the owner._ + +### totalUnitsForSale + +```solidity +function totalUnitsForSale(address, uint256) external view returns (uint256) +``` + +#### Parameters + +| Name | Type | Description | +| ---- | ------- | ----------- | +| \_0 | address | undefined | +| \_1 | uint256 | undefined | + +#### Returns + +| Name | Type | Description | +| ---- | ------- | ----------- | +| \_0 | uint256 | undefined | + +### transferOwnership + +```solidity +function transferOwnership(address newOwner) external nonpayable +``` + +_Transfers ownership of the contract to a new account (`newOwner`). Can only be called by the current owner._ + +#### Parameters + +| Name | Type | Description | +| -------- | ------- | ----------- | +| newOwner | address | undefined | + +### unpause + +```solidity +function unpause() external nonpayable +``` + +### upgradeTo + +```solidity +function upgradeTo(address newImplementation) external nonpayable +``` + +_Upgrade the implementation of the proxy to `newImplementation`. Calls {\_authorizeUpgrade}. Emits an {Upgraded} event._ + +#### Parameters + +| Name | Type | Description | +| ----------------- | ------- | ----------- | +| newImplementation | address | undefined | + +### upgradeToAndCall + +```solidity +function upgradeToAndCall(address newImplementation, bytes data) external payable +``` + +_Upgrade the implementation of the proxy to `newImplementation`, and subsequently execute the function call encoded in `data`. Calls {\_authorizeUpgrade}. Emits an {Upgraded} event._ + +#### Parameters + +| Name | Type | Description | +| ----------------- | ------- | ----------- | +| newImplementation | address | undefined | +| data | bytes | undefined | + +## Events + +### AdminChanged + +```solidity +event AdminChanged(address previousAdmin, address newAdmin) +``` + +#### Parameters + +| Name | Type | Description | +| ------------- | ------- | ----------- | +| previousAdmin | address | undefined | +| newAdmin | address | undefined | + +### BeaconUpgraded + +```solidity +event BeaconUpgraded(address indexed beacon) +``` + +#### Parameters + +| Name | Type | Description | +| ---------------- | ------- | ----------- | +| beacon `indexed` | address | undefined | + +### Initialized + +```solidity +event Initialized(uint8 version) +``` + +#### Parameters + +| Name | Type | Description | +| ------- | ----- | ----------- | +| version | uint8 | undefined | + +### OfferCancelled + +```solidity +event OfferCancelled(address indexed creator, address indexed hypercertContract, uint256 indexed fractionID, uint256 offerID) +``` + +#### Parameters + +| Name | Type | Description | +| --------------------------- | ------- | ----------- | +| creator `indexed` | address | undefined | +| hypercertContract `indexed` | address | undefined | +| fractionID `indexed` | uint256 | undefined | +| offerID | uint256 | undefined | + +### OfferCreated + +```solidity +event OfferCreated(address indexed offerer, address indexed hypercertContract, uint256 indexed fractionID, uint256 offerID) +``` + +#### Parameters + +| Name | Type | Description | +| --------------------------- | ------- | ----------- | +| offerer `indexed` | address | undefined | +| hypercertContract `indexed` | address | undefined | +| fractionID `indexed` | uint256 | undefined | +| offerID | uint256 | undefined | + +### OwnershipTransferred + +```solidity +event OwnershipTransferred(address indexed previousOwner, address indexed newOwner) +``` + +#### Parameters + +| Name | Type | Description | +| ----------------------- | ------- | ----------- | +| previousOwner `indexed` | address | undefined | +| newOwner `indexed` | address | undefined | + +### Paused + +```solidity +event Paused(address account) +``` + +#### Parameters + +| Name | Type | Description | +| ------- | ------- | ----------- | +| account | address | undefined | + +### Trade + +```solidity +event Trade(address indexed seller, address indexed buyer, address indexed hypercertContract, uint256 fractionID, uint256 unitsBought, address buyToken, uint256 tokenAmountPerUnit, uint256 offerID) +``` + +#### Parameters + +| Name | Type | Description | +| --------------------------- | ------- | ----------- | +| seller `indexed` | address | undefined | +| buyer `indexed` | address | undefined | +| hypercertContract `indexed` | address | undefined | +| fractionID | uint256 | undefined | +| unitsBought | uint256 | undefined | +| buyToken | address | undefined | +| tokenAmountPerUnit | uint256 | undefined | +| offerID | uint256 | undefined | + +### Unpaused + +```solidity +event Unpaused(address account) +``` + +#### Parameters + +| Name | Type | Description | +| ------- | ------- | ----------- | +| account | address | undefined | + +### Upgraded + +```solidity +event Upgraded(address indexed implementation) +``` + +#### Parameters + +| Name | Type | Description | +| ------------------------ | ------- | ----------- | +| implementation `indexed` | address | undefined | + +## Errors + +### InvalidBuy + +```solidity +error InvalidBuy(string) +``` + +#### Parameters + +| Name | Type | Description | +| ---- | ------ | ----------- | +| \_0 | string | undefined | + +### InvalidOffer + +```solidity +error InvalidOffer(string) +``` + +#### Parameters + +| Name | Type | Description | +| ---- | ------ | ----------- | +| \_0 | string | undefined | + +### NotAllowed + +```solidity +error NotAllowed() +``` diff --git a/docs/docs/developer/api/contracts/IHypercertMinter.md b/docs/docs/developer/api/contracts/IHypercertMinter.md new file mode 100644 index 00000000..13a84632 --- /dev/null +++ b/docs/docs/developer/api/contracts/IHypercertMinter.md @@ -0,0 +1,39 @@ +# IHypercertMinter + +## Methods + +### ownerOf + +```solidity +function ownerOf(uint256 id) external view returns (address) +``` + +#### Parameters + +| Name | Type | Description | +| ---- | ------- | ----------- | +| id | uint256 | undefined | + +#### Returns + +| Name | Type | Description | +| ---- | ------- | ----------- | +| \_0 | address | undefined | + +### unitsOf + +```solidity +function unitsOf(uint256 id) external view returns (uint256) +``` + +#### Parameters + +| Name | Type | Description | +| ---- | ------- | ----------- | +| id | uint256 | undefined | + +#### Returns + +| Name | Type | Description | +| ---- | ------- | ----------- | +| \_0 | uint256 | undefined | diff --git a/docs/docs/developer/api/contracts/SemiFungible1155.md b/docs/docs/developer/api/contracts/SemiFungible1155.md index 444dfe22..a4086e37 100644 --- a/docs/docs/developer/api/contracts/SemiFungible1155.md +++ b/docs/docs/developer/api/contracts/SemiFungible1155.md @@ -129,19 +129,19 @@ _Returns the address of the current owner._ function ownerOf(uint256 tokenID) external view returns (address _owner) ``` -READ +_Returns the owner of a given token ID._ #### Parameters -| Name | Type | Description | -| ------- | ------- | ----------- | -| tokenID | uint256 | undefined | +| Name | Type | Description | +| ------- | ------- | ----------------------------- | +| tokenID | uint256 | The ID of the token to query. | #### Returns -| Name | Type | Description | -| ------- | ------- | ----------- | -| \_owner | address | undefined | +| Name | Type | Description | +| ------- | ------- | -------------------------------------- | +| \_owner | address | The address of the owner of the token. | ### proxiableUUID @@ -285,19 +285,19 @@ _Upgrade the implementation of the proxy to `newImplementation`, and subsequentl function uri(uint256 tokenID) external view returns (string _uri) ``` -_see { openzeppelin-contracts-upgradeable/token/ERC1155/extensions/ERC1155URIStorageUpgradeable.sol }Always returns the URI for the basetype so that it's managed in one place._ +_Returns the metadata URI for a given token ID.This function retrieves the metadata URI for the specified token ID by calling the `uri` function of the `ERC1155URIStorageUpgradeable` contract.The metadata URI is a string that points to a JSON file containing information about the token, such as its name, symbol, and image.This function always returns the URI for the basetype so that it's managed in one place._ #### Parameters -| Name | Type | Description | -| ------- | ------- | ----------- | -| tokenID | uint256 | undefined | +| Name | Type | Description | +| ------- | ------- | ----------------------------------------------------- | +| tokenID | uint256 | The ID of the token to retrieve the metadata URI for. | #### Returns -| Name | Type | Description | -| ----- | ------ | ----------- | -| \_uri | string | undefined | +| Name | Type | Description | +| ----- | ------ | -------------------------------------------- | +| \_uri | string | The metadata URI for the specified token ID. | ## Events diff --git a/docs/docs/developer/api/contracts/ainlink/contracts/src/v0.8/interfaces/AggregatorV3Interface.md b/docs/docs/developer/api/contracts/ainlink/contracts/src/v0.8/interfaces/AggregatorV3Interface.md new file mode 100644 index 00000000..6be07157 --- /dev/null +++ b/docs/docs/developer/api/contracts/ainlink/contracts/src/v0.8/interfaces/AggregatorV3Interface.md @@ -0,0 +1,77 @@ +# AggregatorV3Interface + +## Methods + +### decimals + +```solidity +function decimals() external view returns (uint8) +``` + +#### Returns + +| Name | Type | Description | +| ---- | ----- | ----------- | +| \_0 | uint8 | undefined | + +### description + +```solidity +function description() external view returns (string) +``` + +#### Returns + +| Name | Type | Description | +| ---- | ------ | ----------- | +| \_0 | string | undefined | + +### getRoundData + +```solidity +function getRoundData(uint80 _roundId) external view returns (uint80 roundId, int256 answer, uint256 startedAt, uint256 updatedAt, uint80 answeredInRound) +``` + +#### Parameters + +| Name | Type | Description | +| --------- | ------ | ----------- | +| \_roundId | uint80 | undefined | + +#### Returns + +| Name | Type | Description | +| --------------- | ------- | ----------- | +| roundId | uint80 | undefined | +| answer | int256 | undefined | +| startedAt | uint256 | undefined | +| updatedAt | uint256 | undefined | +| answeredInRound | uint80 | undefined | + +### latestRoundData + +```solidity +function latestRoundData() external view returns (uint80 roundId, int256 answer, uint256 startedAt, uint256 updatedAt, uint80 answeredInRound) +``` + +#### Returns + +| Name | Type | Description | +| --------------- | ------- | ----------- | +| roundId | uint80 | undefined | +| answer | int256 | undefined | +| startedAt | uint256 | undefined | +| updatedAt | uint256 | undefined | +| answeredInRound | uint80 | undefined | + +### version + +```solidity +function version() external view returns (uint256) +``` + +#### Returns + +| Name | Type | Description | +| ---- | ------- | ----------- | +| \_0 | uint256 | undefined | diff --git a/docs/docs/developer/api/contracts/interfaces/IHypercertToken.md b/docs/docs/developer/api/contracts/interfaces/IHypercertToken.md index 6bd5a931..30ed6f95 100644 --- a/docs/docs/developer/api/contracts/interfaces/IHypercertToken.md +++ b/docs/docs/developer/api/contracts/interfaces/IHypercertToken.md @@ -8,6 +8,23 @@ This interface declares the required functionality for a hypercert tokenThis int ## Methods +### batchBurnFraction + +```solidity +function batchBurnFraction(address account, uint256[] tokenIDs) external nonpayable +``` + +Operator must be allowed by `creator` and the tokens must represent the total amount of available units. + +_Function to burn the tokens at `tokenIDs` for `account`_ + +#### Parameters + +| Name | Type | Description | +| -------- | --------- | ----------- | +| account | address | undefined | +| tokenIDs | uint256[] | undefined | + ### burnFraction ```solidity diff --git a/docs/docs/developer/api/contracts/interfaces/IHypercertTrader.md b/docs/docs/developer/api/contracts/interfaces/IHypercertTrader.md new file mode 100644 index 00000000..06fb700c --- /dev/null +++ b/docs/docs/developer/api/contracts/interfaces/IHypercertTrader.md @@ -0,0 +1,133 @@ +# IHypercertTrader + +_bitbeckers_ + +> Interface for hypercert token trading + +This interface declares the required functionality to interact with the hypercert marketplace + +## Methods + +### batchBuyUnits + +```solidity +function batchBuyUnits(address recipient, uint256[] offerIDs, uint256[] unitAmounts, address[] buyTokens, uint256[] tokenAmountsPerUnit) external payable +``` + +_Buys Hypercert tokens from multiple existing offers in a single transaction._ + +#### Parameters + +| Name | Type | Description | +| ------------------- | --------- | -------------------------------------------------------------------- | +| recipient | address | The address that will receive the Hypercert tokens. | +| offerIDs | uint256[] | The list of IDs of the offers to buy from. | +| unitAmounts | uint256[] | The list of numbers of units to buy for each offer. | +| buyTokens | address[] | The list of addresses of the tokens used for payment for each offer. | +| tokenAmountsPerUnit | uint256[] | The list of amounts of tokens to pay per unit for each offer. | + +### buyUnits + +```solidity +function buyUnits(address recipient, uint256 offerID, uint256 unitAmount, address buyToken, uint256 tokenAmountPerUnit) external payable +``` + +_Buys Hypercert tokens from an existing offer._ + +#### Parameters + +| Name | Type | Description | +| ------------------ | ------- | --------------------------------------------------- | +| recipient | address | The address that will receive the Hypercert tokens. | +| offerID | uint256 | The ID of the offer to buy from. | +| unitAmount | uint256 | The number of units to buy. | +| buyToken | address | The address of the token used for payment. | +| tokenAmountPerUnit | uint256 | The amount of tokens to pay per unit. | + +### cancelOffer + +```solidity +function cancelOffer(uint256 offerID) external nonpayable +``` + +_Cancels an existing offer._ + +#### Parameters + +| Name | Type | Description | +| ------- | ------- | ------------------------------ | +| offerID | uint256 | The ID of the offer to cancel. | + +### createOffer + +```solidity +function createOffer(address hypercertContract, uint256 fractionID, uint256 units, uint256 minUnitsPerTrade, uint256 maxUnitsPerTrade, IHypercertTrader.AcceptedToken[] acceptedTokens) external payable returns (uint256 offerID) +``` + +#### Parameters + +| Name | Type | Description | +| ----------------- | -------------------------------- | ----------- | +| hypercertContract | address | undefined | +| fractionID | uint256 | undefined | +| units | uint256 | undefined | +| minUnitsPerTrade | uint256 | undefined | +| maxUnitsPerTrade | uint256 | undefined | +| acceptedTokens | IHypercertTrader.AcceptedToken[] | undefined | + +#### Returns + +| Name | Type | Description | +| ------- | ------- | ----------- | +| offerID | uint256 | undefined | + +## Events + +### OfferCancelled + +```solidity +event OfferCancelled(address indexed creator, address indexed hypercertContract, uint256 indexed fractionID, uint256 offerID) +``` + +#### Parameters + +| Name | Type | Description | +| --------------------------- | ------- | ----------- | +| creator `indexed` | address | undefined | +| hypercertContract `indexed` | address | undefined | +| fractionID `indexed` | uint256 | undefined | +| offerID | uint256 | undefined | + +### OfferCreated + +```solidity +event OfferCreated(address indexed offerer, address indexed hypercertContract, uint256 indexed fractionID, uint256 offerID) +``` + +#### Parameters + +| Name | Type | Description | +| --------------------------- | ------- | ----------- | +| offerer `indexed` | address | undefined | +| hypercertContract `indexed` | address | undefined | +| fractionID `indexed` | uint256 | undefined | +| offerID | uint256 | undefined | + +### Trade + +```solidity +event Trade(address indexed seller, address indexed buyer, address indexed hypercertContract, uint256 fractionID, uint256 unitsBought, address buyToken, uint256 tokenAmountPerUnit, uint256 offerID) +``` + +#### Parameters + +| Name | Type | Description | +| --------------------------- | ------- | ----------- | +| seller `indexed` | address | undefined | +| buyer `indexed` | address | undefined | +| hypercertContract `indexed` | address | undefined | +| fractionID | uint256 | undefined | +| unitsBought | uint256 | undefined | +| buyToken | address | undefined | +| tokenAmountPerUnit | uint256 | undefined | +| offerID | uint256 | undefined | diff --git a/docs/docs/developer/api/contracts/marketplace/BatchOrderTypehashRegistry.md b/docs/docs/developer/api/contracts/marketplace/BatchOrderTypehashRegistry.md new file mode 100644 index 00000000..4cb96bfc --- /dev/null +++ b/docs/docs/developer/api/contracts/marketplace/BatchOrderTypehashRegistry.md @@ -0,0 +1,46 @@ +# BatchOrderTypehashRegistry + +_LooksRare protocol team (👀,💎)_ + +> BatchOrderTypehashRegistry + +The contract generates the batch order hash that is used to compute the digest for signature verification. + +## Methods + +### hashBatchOrder + +```solidity +function hashBatchOrder(bytes32 root, uint256 proofLength) external pure returns (bytes32 batchOrderHash) +``` + +This function returns the hash of the concatenation of batch order type hash and merkle root. + +#### Parameters + +| Name | Type | Description | +| ----------- | ------- | ------------------- | +| root | bytes32 | Merkle root | +| proofLength | uint256 | Merkle proof length | + +#### Returns + +| Name | Type | Description | +| -------------- | ------- | -------------------- | +| batchOrderHash | bytes32 | The batch order hash | + +## Errors + +### MerkleProofTooLarge + +```solidity +error MerkleProofTooLarge(uint256 length) +``` + +It is returned if the length of the merkle proof provided is greater than tolerated. + +#### Parameters + +| Name | Type | Description | +| ------ | ------- | ------------ | +| length | uint256 | Proof length | diff --git a/docs/docs/developer/api/contracts/marketplace/CreatorFeeManagerWithRebates.md b/docs/docs/developer/api/contracts/marketplace/CreatorFeeManagerWithRebates.md new file mode 100644 index 00000000..a32aef65 --- /dev/null +++ b/docs/docs/developer/api/contracts/marketplace/CreatorFeeManagerWithRebates.md @@ -0,0 +1,76 @@ +# CreatorFeeManagerWithRebates + +_LooksRare protocol team (👀,💎)_ + +> CreatorFeeManagerWithRebates + +This contract returns the creator fee address and the creator rebate amount. + +## Methods + +### STANDARD_ROYALTY_FEE_BP + +```solidity +function STANDARD_ROYALTY_FEE_BP() external view returns (uint256) +``` + +Standard royalty fee (in basis point). + +#### Returns + +| Name | Type | Description | +| ---- | ------- | ----------- | +| \_0 | uint256 | undefined | + +### royaltyFeeRegistry + +```solidity +function royaltyFeeRegistry() external view returns (contract IRoyaltyFeeRegistry) +``` + +Royalty fee registry interface. + +#### Returns + +| Name | Type | Description | +| ---- | ---------------------------- | ----------- | +| \_0 | contract IRoyaltyFeeRegistry | undefined | + +### viewCreatorFeeInfo + +```solidity +function viewCreatorFeeInfo(address collection, uint256 price, uint256[] itemIds) external view returns (address creator, uint256 creatorFeeAmount) +``` + +This function returns the creator address and calculates the creator fee amount. + +#### Parameters + +| Name | Type | Description | +| ---------- | --------- | ------------------ | +| collection | address | Collection address | +| price | uint256 | Transaction price | +| itemIds | uint256[] | Array of item ids | + +#### Returns + +| Name | Type | Description | +| ---------------- | ------- | ------------------ | +| creator | address | Creator address | +| creatorFeeAmount | uint256 | Creator fee amount | + +## Errors + +### BundleEIP2981NotAllowed + +```solidity +error BundleEIP2981NotAllowed(address collection) +``` + +It is returned if the bundle contains multiple itemIds with different creator fee structure. + +#### Parameters + +| Name | Type | Description | +| ---------- | ------- | ----------- | +| collection | address | undefined | diff --git a/docs/docs/developer/api/contracts/marketplace/CreatorFeeManagerWithRoyalties.md b/docs/docs/developer/api/contracts/marketplace/CreatorFeeManagerWithRoyalties.md new file mode 100644 index 00000000..41cab900 --- /dev/null +++ b/docs/docs/developer/api/contracts/marketplace/CreatorFeeManagerWithRoyalties.md @@ -0,0 +1,64 @@ +# CreatorFeeManagerWithRoyalties + +_LooksRare protocol team (👀,💎)_ + +> CreatorFeeManagerWithRoyalties + +This contract returns the creator fee address and the creator fee amount. + +## Methods + +### royaltyFeeRegistry + +```solidity +function royaltyFeeRegistry() external view returns (contract IRoyaltyFeeRegistry) +``` + +Royalty fee registry interface. + +#### Returns + +| Name | Type | Description | +| ---- | ---------------------------- | ----------- | +| \_0 | contract IRoyaltyFeeRegistry | undefined | + +### viewCreatorFeeInfo + +```solidity +function viewCreatorFeeInfo(address collection, uint256 price, uint256[] itemIds) external view returns (address creator, uint256 creatorFeeAmount) +``` + +This function returns the creator address and calculates the creator fee amount. + +_There are two on-chain sources for the royalty fee to distribute. 1. RoyaltyFeeRegistry: It is an on-chain registry where creator fee is defined for all items of a collection. 2. ERC2981: The NFT Royalty Standard where royalty fee is defined at a itemId level in a collection. The on-chain logic looks up the registry first. If it does not find anything, it checks if a collection is ERC2981. If so, it fetches the proper royalty information for the itemId. For a bundle that contains multiple itemIds (for a collection using ERC2981), if the royalty fee/recipient differ among the itemIds part of the bundle, the trade reverts. This contract DOES NOT enforce any restriction for extremely high creator fee, nor verifies the creator fee fetched is inferior to the total price. If any contract relies on it to build an on-chain royalty logic, it should implement protection against: (1) high royalties (2) potential unexpected royalty changes that can occur after the creation of the order._ + +#### Parameters + +| Name | Type | Description | +| ---------- | --------- | ------------------ | +| collection | address | Collection address | +| price | uint256 | Transaction price | +| itemIds | uint256[] | Array of item ids | + +#### Returns + +| Name | Type | Description | +| ---------------- | ------- | ------------------ | +| creator | address | Creator address | +| creatorFeeAmount | uint256 | Creator fee amount | + +## Errors + +### BundleEIP2981NotAllowed + +```solidity +error BundleEIP2981NotAllowed(address collection) +``` + +It is returned if the bundle contains multiple itemIds with different creator fee structure. + +#### Parameters + +| Name | Type | Description | +| ---------- | ------- | ----------- | +| collection | address | undefined | diff --git a/docs/docs/developer/api/contracts/marketplace/CurrencyManager.md b/docs/docs/developer/api/contracts/marketplace/CurrencyManager.md new file mode 100644 index 00000000..9ff1c0fc --- /dev/null +++ b/docs/docs/developer/api/contracts/marketplace/CurrencyManager.md @@ -0,0 +1,250 @@ +# CurrencyManager + +_LooksRare protocol team (👀,💎)_ + +> CurrencyManager + +This contract manages the list of valid fungible currencies. + +## Methods + +### cancelOwnershipTransfer + +```solidity +function cancelOwnershipTransfer() external nonpayable +``` + +This function is used to cancel the ownership transfer. + +_This function can be used for both cancelling a transfer to a new owner and cancelling the renouncement of the ownership._ + +### confirmOwnershipRenouncement + +```solidity +function confirmOwnershipRenouncement() external nonpayable +``` + +This function is used to confirm the ownership renouncement. + +### confirmOwnershipTransfer + +```solidity +function confirmOwnershipTransfer() external nonpayable +``` + +This function is used to confirm the ownership transfer. + +_This function can only be called by the current potential owner._ + +### initiateOwnershipRenouncement + +```solidity +function initiateOwnershipRenouncement() external nonpayable +``` + +This function is used to initiate the ownership renouncement. + +### initiateOwnershipTransfer + +```solidity +function initiateOwnershipTransfer(address newPotentialOwner) external nonpayable +``` + +This function is used to initiate the transfer of ownership to a new owner. + +#### Parameters + +| Name | Type | Description | +| ----------------- | ------- | --------------------------- | +| newPotentialOwner | address | New potential owner address | + +### isCurrencyAllowed + +```solidity +function isCurrencyAllowed(address) external view returns (bool) +``` + +It checks whether the currency is allowed for transacting. + +#### Parameters + +| Name | Type | Description | +| ---- | ------- | ----------- | +| \_0 | address | undefined | + +#### Returns + +| Name | Type | Description | +| ---- | ---- | ----------- | +| \_0 | bool | undefined | + +### owner + +```solidity +function owner() external view returns (address) +``` + +Address of the current owner. + +#### Returns + +| Name | Type | Description | +| ---- | ------- | ----------- | +| \_0 | address | undefined | + +### ownershipStatus + +```solidity +function ownershipStatus() external view returns (enum IOwnableTwoSteps.Status) +``` + +Ownership status. + +#### Returns + +| Name | Type | Description | +| ---- | ---------------------------- | ----------- | +| \_0 | enum IOwnableTwoSteps.Status | undefined | + +### potentialOwner + +```solidity +function potentialOwner() external view returns (address) +``` + +Address of the potential owner. + +#### Returns + +| Name | Type | Description | +| ---- | ------- | ----------- | +| \_0 | address | undefined | + +### updateCurrencyStatus + +```solidity +function updateCurrencyStatus(address currency, bool isAllowed) external nonpayable +``` + +This function allows the owner to update the status of a currency. + +_Only callable by owner._ + +#### Parameters + +| Name | Type | Description | +| --------- | ------- | -------------------------------------------------- | +| currency | address | Currency address (address(0) for ETH) | +| isAllowed | bool | Whether the currency should be allowed for trading | + +## Events + +### CancelOwnershipTransfer + +```solidity +event CancelOwnershipTransfer() +``` + +This is emitted if the ownership transfer is cancelled. + +### CurrencyStatusUpdated + +```solidity +event CurrencyStatusUpdated(address currency, bool isAllowed) +``` + +It is emitted if the currency status in the allowlist is updated. + +#### Parameters + +| Name | Type | Description | +| --------- | ------- | ----------- | +| currency | address | undefined | +| isAllowed | bool | undefined | + +### InitiateOwnershipRenouncement + +```solidity +event InitiateOwnershipRenouncement() +``` + +This is emitted if the ownership renouncement is initiated. + +### InitiateOwnershipTransfer + +```solidity +event InitiateOwnershipTransfer(address previousOwner, address potentialOwner) +``` + +This is emitted if the ownership transfer is initiated. + +#### Parameters + +| Name | Type | Description | +| -------------- | ------- | ----------- | +| previousOwner | address | undefined | +| potentialOwner | address | undefined | + +### NewOwner + +```solidity +event NewOwner(address newOwner) +``` + +This is emitted when there is a new owner. + +#### Parameters + +| Name | Type | Description | +| -------- | ------- | ----------- | +| newOwner | address | undefined | + +## Errors + +### NoOngoingTransferInProgress + +```solidity +error NoOngoingTransferInProgress() +``` + +This is returned when there is no transfer of ownership in progress. + +### NotOwner + +```solidity +error NotOwner() +``` + +This is returned when the caller is not the owner. + +### RenouncementNotInProgress + +```solidity +error RenouncementNotInProgress() +``` + +This is returned when there is no renouncement in progress but the owner tries to validate the ownership renouncement. + +### TransferAlreadyInProgress + +```solidity +error TransferAlreadyInProgress() +``` + +This is returned when the transfer is already in progress but the owner tries initiate a new ownership transfer. + +### TransferNotInProgress + +```solidity +error TransferNotInProgress() +``` + +This is returned when there is no ownership transfer in progress but the ownership change tries to be approved. + +### WrongPotentialOwner + +```solidity +error WrongPotentialOwner() +``` + +This is returned when the ownership transfer is attempted to be validated by the a caller that is not the potential owner. diff --git a/docs/docs/developer/api/contracts/marketplace/ExecutionManager.md b/docs/docs/developer/api/contracts/marketplace/ExecutionManager.md new file mode 100644 index 00000000..981cb3a7 --- /dev/null +++ b/docs/docs/developer/api/contracts/marketplace/ExecutionManager.md @@ -0,0 +1,751 @@ +# ExecutionManager + +_LooksRare protocol team (👀,💎)_ + +> ExecutionManager + +This contract handles the execution and resolution of transactions. A transaction is executed on-chain when an off-chain maker order is matched by on-chain taker order of a different kind. For instance, a taker ask is executed against a maker bid (or a taker bid against a maker ask). + +## Methods + +### MAGIC_VALUE_ORDER_NONCE_EXECUTED + +```solidity +function MAGIC_VALUE_ORDER_NONCE_EXECUTED() external view returns (bytes32) +``` + +Magic value nonce returned if executed (or cancelled). + +#### Returns + +| Name | Type | Description | +| ---- | ------- | ----------- | +| \_0 | bytes32 | undefined | + +### addStrategy + +```solidity +function addStrategy(uint16 standardProtocolFeeBp, uint16 minTotalFeeBp, uint16 maxProtocolFeeBp, bytes4 selector, bool isMakerBid, address implementation) external nonpayable +``` + +This function allows the owner to add a new execution strategy to the protocol. + +_Strategies have an id that is incremental. Only callable by owner._ + +#### Parameters + +| Name | Type | Description | +| --------------------- | ------- | ---------------------------------------------- | +| standardProtocolFeeBp | uint16 | Standard protocol fee (in basis point) | +| minTotalFeeBp | uint16 | Minimum total fee (in basis point) | +| maxProtocolFeeBp | uint16 | Maximum protocol fee (in basis point) | +| selector | bytes4 | Function selector for the strategy | +| isMakerBid | bool | Whether the function selector is for maker bid | +| implementation | address | Implementation address | + +### cancelOrderNonces + +```solidity +function cancelOrderNonces(uint256[] orderNonces) external nonpayable +``` + +This function allows a user to cancel an array of order nonces. + +_It does not check the status of the nonces to save gas and to prevent revertion if one of the orders is filled in the same block._ + +#### Parameters + +| Name | Type | Description | +| ----------- | --------- | --------------------- | +| orderNonces | uint256[] | Array of order nonces | + +### cancelOwnershipTransfer + +```solidity +function cancelOwnershipTransfer() external nonpayable +``` + +This function is used to cancel the ownership transfer. + +_This function can be used for both cancelling a transfer to a new owner and cancelling the renouncement of the ownership._ + +### cancelSubsetNonces + +```solidity +function cancelSubsetNonces(uint256[] subsetNonces) external nonpayable +``` + +This function allows a user to cancel an array of subset nonces. + +_It does not check the status of the nonces to save gas._ + +#### Parameters + +| Name | Type | Description | +| ------------ | --------- | ---------------------- | +| subsetNonces | uint256[] | Array of subset nonces | + +### confirmOwnershipRenouncement + +```solidity +function confirmOwnershipRenouncement() external nonpayable +``` + +This function is used to confirm the ownership renouncement. + +### confirmOwnershipTransfer + +```solidity +function confirmOwnershipTransfer() external nonpayable +``` + +This function is used to confirm the ownership transfer. + +_This function can only be called by the current potential owner._ + +### creatorFeeManager + +```solidity +function creatorFeeManager() external view returns (contract ICreatorFeeManager) +``` + +Creator fee manager. + +#### Returns + +| Name | Type | Description | +| ---- | --------------------------- | ----------- | +| \_0 | contract ICreatorFeeManager | undefined | + +### incrementBidAskNonces + +```solidity +function incrementBidAskNonces(bool bid, bool ask) external nonpayable +``` + +This function increments a user's bid/ask nonces. + +_The logic for computing the quasi-random number is inspired by Seaport v1.2. The pseudo-randomness allows non-deterministic computation of the next ask/bid nonce. A deterministic increment would make the cancel-all process non-effective in certain cases (orders signed with a greater ask/bid nonce). The same quasi-random number is used for incrementing both the bid and ask nonces if both values are incremented in the same transaction. If this function is used twice in the same block, it will return the same quasiRandomNumber but this will not impact the overall business logic._ + +#### Parameters + +| Name | Type | Description | +| ---- | ---- | --------------------------------------- | +| bid | bool | Whether to increment the user bid nonce | +| ask | bool | Whether to increment the user ask nonce | + +### initiateOwnershipRenouncement + +```solidity +function initiateOwnershipRenouncement() external nonpayable +``` + +This function is used to initiate the ownership renouncement. + +### initiateOwnershipTransfer + +```solidity +function initiateOwnershipTransfer(address newPotentialOwner) external nonpayable +``` + +This function is used to initiate the transfer of ownership to a new owner. + +#### Parameters + +| Name | Type | Description | +| ----------------- | ------- | --------------------------- | +| newPotentialOwner | address | New potential owner address | + +### isCurrencyAllowed + +```solidity +function isCurrencyAllowed(address) external view returns (bool) +``` + +It checks whether the currency is allowed for transacting. + +#### Parameters + +| Name | Type | Description | +| ---- | ------- | ----------- | +| \_0 | address | undefined | + +#### Returns + +| Name | Type | Description | +| ---- | ---- | ----------- | +| \_0 | bool | undefined | + +### maxCreatorFeeBp + +```solidity +function maxCreatorFeeBp() external view returns (uint16) +``` + +Maximum creator fee (in basis point). + +#### Returns + +| Name | Type | Description | +| ---- | ------ | ----------- | +| \_0 | uint16 | undefined | + +### owner + +```solidity +function owner() external view returns (address) +``` + +Address of the current owner. + +#### Returns + +| Name | Type | Description | +| ---- | ------- | ----------- | +| \_0 | address | undefined | + +### ownershipStatus + +```solidity +function ownershipStatus() external view returns (enum IOwnableTwoSteps.Status) +``` + +Ownership status. + +#### Returns + +| Name | Type | Description | +| ---- | ---------------------------- | ----------- | +| \_0 | enum IOwnableTwoSteps.Status | undefined | + +### potentialOwner + +```solidity +function potentialOwner() external view returns (address) +``` + +Address of the potential owner. + +#### Returns + +| Name | Type | Description | +| ---- | ------- | ----------- | +| \_0 | address | undefined | + +### protocolFeeRecipient + +```solidity +function protocolFeeRecipient() external view returns (address) +``` + +Protocol fee recipient. + +#### Returns + +| Name | Type | Description | +| ---- | ------- | ----------- | +| \_0 | address | undefined | + +### strategyInfo + +```solidity +function strategyInfo(uint256) external view returns (bool isActive, uint16 standardProtocolFeeBp, uint16 minTotalFeeBp, uint16 maxProtocolFeeBp, bytes4 selector, bool isMakerBid, address implementation) +``` + +This returns the strategy information for a strategy id. + +#### Parameters + +| Name | Type | Description | +| ---- | ------- | ----------- | +| \_0 | uint256 | undefined | + +#### Returns + +| Name | Type | Description | +| --------------------- | ------- | ----------- | +| isActive | bool | undefined | +| standardProtocolFeeBp | uint16 | undefined | +| minTotalFeeBp | uint16 | undefined | +| maxProtocolFeeBp | uint16 | undefined | +| selector | bytes4 | undefined | +| isMakerBid | bool | undefined | +| implementation | address | undefined | + +### updateCreatorFeeManager + +```solidity +function updateCreatorFeeManager(address newCreatorFeeManager) external nonpayable +``` + +This function allows the owner to update the creator fee manager address. + +_Only callable by owner._ + +#### Parameters + +| Name | Type | Description | +| -------------------- | ------- | ---------------------------------- | +| newCreatorFeeManager | address | Address of the creator fee manager | + +### updateCurrencyStatus + +```solidity +function updateCurrencyStatus(address currency, bool isAllowed) external nonpayable +``` + +This function allows the owner to update the status of a currency. + +_Only callable by owner._ + +#### Parameters + +| Name | Type | Description | +| --------- | ------- | -------------------------------------------------- | +| currency | address | Currency address (address(0) for ETH) | +| isAllowed | bool | Whether the currency should be allowed for trading | + +### updateMaxCreatorFeeBp + +```solidity +function updateMaxCreatorFeeBp(uint16 newMaxCreatorFeeBp) external nonpayable +``` + +This function allows the owner to update the maximum creator fee (in basis point). + +_The maximum value that can be set is 25%. Only callable by owner._ + +#### Parameters + +| Name | Type | Description | +| ------------------ | ------ | ---------------------------------------- | +| newMaxCreatorFeeBp | uint16 | New maximum creator fee (in basis point) | + +### updateProtocolFeeRecipient + +```solidity +function updateProtocolFeeRecipient(address newProtocolFeeRecipient) external nonpayable +``` + +This function allows the owner to update the protocol fee recipient. + +_Only callable by owner._ + +#### Parameters + +| Name | Type | Description | +| ----------------------- | ------- | ---------------------------------- | +| newProtocolFeeRecipient | address | New protocol fee recipient address | + +### updateStrategy + +```solidity +function updateStrategy(uint256 strategyId, bool isActive, uint16 newStandardProtocolFee, uint16 newMinTotalFee) external nonpayable +``` + +This function allows the owner to update parameters for an existing execution strategy. + +_Only callable by owner._ + +#### Parameters + +| Name | Type | Description | +| ---------------------- | ------- | ------------------------------------------ | +| strategyId | uint256 | Strategy id | +| isActive | bool | Whether the strategy must be active | +| newStandardProtocolFee | uint16 | New standard protocol fee (in basis point) | +| newMinTotalFee | uint16 | New minimum total fee (in basis point) | + +### userBidAskNonces + +```solidity +function userBidAskNonces(address) external view returns (uint256 bidNonce, uint256 askNonce) +``` + +This tracks the bid and ask nonces for a user address. + +#### Parameters + +| Name | Type | Description | +| ---- | ------- | ----------- | +| \_0 | address | undefined | + +#### Returns + +| Name | Type | Description | +| -------- | ------- | ----------- | +| bidNonce | uint256 | undefined | +| askNonce | uint256 | undefined | + +### userOrderNonce + +```solidity +function userOrderNonce(address, uint256) external view returns (bytes32) +``` + +This checks whether the order nonce for a user was executed or cancelled. + +#### Parameters + +| Name | Type | Description | +| ---- | ------- | ----------- | +| \_0 | address | undefined | +| \_1 | uint256 | undefined | + +#### Returns + +| Name | Type | Description | +| ---- | ------- | ----------- | +| \_0 | bytes32 | undefined | + +### userSubsetNonce + +```solidity +function userSubsetNonce(address, uint256) external view returns (bool) +``` + +This checks whether the subset nonce for a user was cancelled. + +#### Parameters + +| Name | Type | Description | +| ---- | ------- | ----------- | +| \_0 | address | undefined | +| \_1 | uint256 | undefined | + +#### Returns + +| Name | Type | Description | +| ---- | ---- | ----------- | +| \_0 | bool | undefined | + +## Events + +### CancelOwnershipTransfer + +```solidity +event CancelOwnershipTransfer() +``` + +This is emitted if the ownership transfer is cancelled. + +### CurrencyStatusUpdated + +```solidity +event CurrencyStatusUpdated(address currency, bool isAllowed) +``` + +It is emitted if the currency status in the allowlist is updated. + +#### Parameters + +| Name | Type | Description | +| --------- | ------- | ----------- | +| currency | address | undefined | +| isAllowed | bool | undefined | + +### InitiateOwnershipRenouncement + +```solidity +event InitiateOwnershipRenouncement() +``` + +This is emitted if the ownership renouncement is initiated. + +### InitiateOwnershipTransfer + +```solidity +event InitiateOwnershipTransfer(address previousOwner, address potentialOwner) +``` + +This is emitted if the ownership transfer is initiated. + +#### Parameters + +| Name | Type | Description | +| -------------- | ------- | ----------- | +| previousOwner | address | undefined | +| potentialOwner | address | undefined | + +### NewBidAskNonces + +```solidity +event NewBidAskNonces(address user, uint256 bidNonce, uint256 askNonce) +``` + +It is emitted when there is an update of the global bid/ask nonces for a user. + +#### Parameters + +| Name | Type | Description | +| -------- | ------- | ----------- | +| user | address | undefined | +| bidNonce | uint256 | undefined | +| askNonce | uint256 | undefined | + +### NewCreatorFeeManager + +```solidity +event NewCreatorFeeManager(address creatorFeeManager) +``` + +It is issued when there is a new creator fee manager. + +#### Parameters + +| Name | Type | Description | +| ----------------- | ------- | ----------- | +| creatorFeeManager | address | undefined | + +### NewMaxCreatorFeeBp + +```solidity +event NewMaxCreatorFeeBp(uint256 maxCreatorFeeBp) +``` + +It is issued when there is a new maximum creator fee (in basis point). + +#### Parameters + +| Name | Type | Description | +| --------------- | ------- | ----------- | +| maxCreatorFeeBp | uint256 | undefined | + +### NewOwner + +```solidity +event NewOwner(address newOwner) +``` + +This is emitted when there is a new owner. + +#### Parameters + +| Name | Type | Description | +| -------- | ------- | ----------- | +| newOwner | address | undefined | + +### NewProtocolFeeRecipient + +```solidity +event NewProtocolFeeRecipient(address protocolFeeRecipient) +``` + +It is issued when there is a new protocol fee recipient address. + +#### Parameters + +| Name | Type | Description | +| -------------------- | ------- | ----------- | +| protocolFeeRecipient | address | undefined | + +### NewStrategy + +```solidity +event NewStrategy(uint256 strategyId, uint16 standardProtocolFeeBp, uint16 minTotalFeeBp, uint16 maxProtocolFeeBp, bytes4 selector, bool isMakerBid, address implementation) +``` + +It is emitted when a new strategy is added. + +#### Parameters + +| Name | Type | Description | +| --------------------- | ------- | ----------- | +| strategyId | uint256 | undefined | +| standardProtocolFeeBp | uint16 | undefined | +| minTotalFeeBp | uint16 | undefined | +| maxProtocolFeeBp | uint16 | undefined | +| selector | bytes4 | undefined | +| isMakerBid | bool | undefined | +| implementation | address | undefined | + +### OrderNoncesCancelled + +```solidity +event OrderNoncesCancelled(address user, uint256[] orderNonces) +``` + +It is emitted when order nonces are cancelled for a user. + +#### Parameters + +| Name | Type | Description | +| ----------- | --------- | ----------- | +| user | address | undefined | +| orderNonces | uint256[] | undefined | + +### StrategyUpdated + +```solidity +event StrategyUpdated(uint256 strategyId, bool isActive, uint16 standardProtocolFeeBp, uint16 minTotalFeeBp) +``` + +It is emitted when an existing strategy is updated. + +#### Parameters + +| Name | Type | Description | +| --------------------- | ------- | ----------- | +| strategyId | uint256 | undefined | +| isActive | bool | undefined | +| standardProtocolFeeBp | uint16 | undefined | +| minTotalFeeBp | uint16 | undefined | + +### SubsetNoncesCancelled + +```solidity +event SubsetNoncesCancelled(address user, uint256[] subsetNonces) +``` + +It is emitted when subset nonces are cancelled for a user. + +#### Parameters + +| Name | Type | Description | +| ------------ | --------- | ----------- | +| user | address | undefined | +| subsetNonces | uint256[] | undefined | + +## Errors + +### CreatorFeeBpTooHigh + +```solidity +error CreatorFeeBpTooHigh() +``` + +It is returned if the creator fee (in basis point) is too high. + +### LengthsInvalid + +```solidity +error LengthsInvalid() +``` + +It is returned if there is either a mismatch or an error in the length of the array(s). + +### NewProtocolFeeRecipientCannotBeNullAddress + +```solidity +error NewProtocolFeeRecipientCannotBeNullAddress() +``` + +It is returned if the new protocol fee recipient is set to address(0). + +### NoOngoingTransferInProgress + +```solidity +error NoOngoingTransferInProgress() +``` + +This is returned when there is no transfer of ownership in progress. + +### NoSelectorForStrategy + +```solidity +error NoSelectorForStrategy() +``` + +It is returned if there is no selector for maker ask/bid for a given strategyId, depending on the quote type. + +### NotOwner + +```solidity +error NotOwner() +``` + +This is returned when the caller is not the owner. + +### NotV2Strategy + +```solidity +error NotV2Strategy() +``` + +If the strategy has not set properly its implementation contract. + +_It can only be returned for owner operations._ + +### OutsideOfTimeRange + +```solidity +error OutsideOfTimeRange() +``` + +It is returned if the current block timestamp is not between start and end times in the maker order. + +### RenouncementNotInProgress + +```solidity +error RenouncementNotInProgress() +``` + +This is returned when there is no renouncement in progress but the owner tries to validate the ownership renouncement. + +### StrategyHasNoSelector + +```solidity +error StrategyHasNoSelector() +``` + +It is returned if the strategy has no selector. + +_It can only be returned for owner operations._ + +### StrategyNotAvailable + +```solidity +error StrategyNotAvailable(uint256 strategyId) +``` + +It is returned if the strategy id has no implementation. + +_It is returned if there is no implementation address and the strategyId is strictly greater than 0._ + +#### Parameters + +| Name | Type | Description | +| ---------- | ------- | ----------- | +| strategyId | uint256 | undefined | + +### StrategyNotUsed + +```solidity +error StrategyNotUsed() +``` + +It is returned if the strategyId is invalid. + +### StrategyProtocolFeeTooHigh + +```solidity +error StrategyProtocolFeeTooHigh() +``` + +It is returned if the strategy's protocol fee is too high. + +_It can only be returned for owner operations._ + +### TransferAlreadyInProgress + +```solidity +error TransferAlreadyInProgress() +``` + +This is returned when the transfer is already in progress but the owner tries initiate a new ownership transfer. + +### TransferNotInProgress + +```solidity +error TransferNotInProgress() +``` + +This is returned when there is no ownership transfer in progress but the ownership change tries to be approved. + +### WrongPotentialOwner + +```solidity +error WrongPotentialOwner() +``` + +This is returned when the ownership transfer is attempted to be validated by the a caller that is not the potential owner. diff --git a/docs/docs/developer/api/contracts/marketplace/InheritedStrategy.md b/docs/docs/developer/api/contracts/marketplace/InheritedStrategy.md new file mode 100644 index 00000000..022cce57 --- /dev/null +++ b/docs/docs/developer/api/contracts/marketplace/InheritedStrategy.md @@ -0,0 +1,9 @@ +# InheritedStrategy + +_LooksRare protocol team (👀,💎)_ + +> InheritedStrategy + +This contract handles the verification of parameters for standard transactions. It does not verify the taker struct's itemIds and amounts array as well as minPrice (taker ask) / maxPrice (taker bid) because before the taker executes the transaction and the maker itemIds/amounts/price should have already been confirmed off-chain. + +_A standard transaction (bid or ask) is mapped to strategyId = 0._ diff --git a/docs/docs/developer/api/contracts/marketplace/LooksRareProtocol.md b/docs/docs/developer/api/contracts/marketplace/LooksRareProtocol.md new file mode 100644 index 00000000..fca005d6 --- /dev/null +++ b/docs/docs/developer/api/contracts/marketplace/LooksRareProtocol.md @@ -0,0 +1,1157 @@ +# LooksRareProtocol + +_LooksRare protocol team (👀,💎)_ + +> LooksRareProtocol + +This contract is the core smart contract of the LooksRare protocol ("v2"). It is the main entry point for users to initiate transactions with taker orders and manage the cancellation of maker orders, which exist off-chain. ~~~~~~ ~~~~ ~~~~ ~~~ ~~~ ~~~ ~~~ ~~~ ~~~ ~~~~~~~~~ ~~~ ~~~ ~~~~~~~~~ ~~~ ~~~~~~~~~ ~~~~ ~~~~ ~~~~~~~~~ ~~~ ~~~ ~~~~~~~ ~~~~~~~ ~~~ ~~~- ~~~~~~~~ ~~~~ ~~~ ~~~~ ~~~~ ~~~ ~~~ ~~~~~~~~~~~~ ~~~~~~~~~~~~ ~~~ ~~~ ~~~~~~~~~~~ ~~~~~~~~~~~ ~~~ ~~~ ~~~ ~~~ ~~~ ~~~ ~~~ ~~~~~~~~~~ ~~~ ~~~ ~~~~~ ~~~ ~~~~~~ ~~~~~~ ~~~ ~~~~~ ~~~~~~~ ~~~ ~~~ ~~~ ~~~ ~~~~~~~ ~~~~~~ ~~~~ ~~~ ~~~ ~~~~ ~~~~~~ ~~~~ ~~~ ~~~ ~~~ ~~~ ~~~~ ~~~ ~~~ ~~~ ~~~ ~~~ ~~~ ~~~~ ~~~ ~~~ ~~~ ~~~ ~~~~ ~~~~~~ ~~~~ ~~~ ~~~ ~~~~~ ~~~~~~ ~~~~~~~ ~~~ ~~~ ~~~ ~~~ ~~~~~~~ ~~~~~ ~~~ ~~~~~~ ~~~~~~ ~~~ ~~~~~ ~~~ ~~~ ~~~~~~~~~~ ~~~ ~~~ ~~ ~~~ ~~~ ~~~ ~~~ ~~~~~~~~~~~ ~~~~~~~~~~~ ~~~ ~~~ ~~~~~~~~~~~~ ~~~~~~~~~~~~ ~~~ ~~~ ~~~~ ~~~~ ~~~ ~~~~ ~~~~~~~~ ~~~~ ~~~ ~~~~~~~ ~~~~~~~ ~~~ ~~~ ~~~~~~~~ ~~~~ ~~~~ ~~~~~~~~ ~~~ ~~~~~~~~~ ~~~ ~~~ ~~~~~~~~~ ~~~ ~~~ ~~~ ~~~ ~~~ ~~~ ~~~~ ~~~~ ~~~~~~ + +## Methods + +### MAGIC_VALUE_ORDER_NONCE_EXECUTED + +```solidity +function MAGIC_VALUE_ORDER_NONCE_EXECUTED() external view returns (bytes32) +``` + +Magic value nonce returned if executed (or cancelled). + +#### Returns + +| Name | Type | Description | +| ---- | ------- | ----------- | +| \_0 | bytes32 | undefined | + +### WETH + +```solidity +function WETH() external view returns (address) +``` + +Wrapped ETH. + +#### Returns + +| Name | Type | Description | +| ---- | ------- | ----------- | +| \_0 | address | undefined | + +### addStrategy + +```solidity +function addStrategy(uint16 standardProtocolFeeBp, uint16 minTotalFeeBp, uint16 maxProtocolFeeBp, bytes4 selector, bool isMakerBid, address implementation) external nonpayable +``` + +This function allows the owner to add a new execution strategy to the protocol. + +_Strategies have an id that is incremental. Only callable by owner._ + +#### Parameters + +| Name | Type | Description | +| --------------------- | ------- | ---------------------------------------------- | +| standardProtocolFeeBp | uint16 | Standard protocol fee (in basis point) | +| minTotalFeeBp | uint16 | Minimum total fee (in basis point) | +| maxProtocolFeeBp | uint16 | Maximum protocol fee (in basis point) | +| selector | bytes4 | Function selector for the strategy | +| isMakerBid | bool | Whether the function selector is for maker bid | +| implementation | address | Implementation address | + +### cancelOrderNonces + +```solidity +function cancelOrderNonces(uint256[] orderNonces) external nonpayable +``` + +This function allows a user to cancel an array of order nonces. + +_It does not check the status of the nonces to save gas and to prevent revertion if one of the orders is filled in the same block._ + +#### Parameters + +| Name | Type | Description | +| ----------- | --------- | --------------------- | +| orderNonces | uint256[] | Array of order nonces | + +### cancelOwnershipTransfer + +```solidity +function cancelOwnershipTransfer() external nonpayable +``` + +This function is used to cancel the ownership transfer. + +_This function can be used for both cancelling a transfer to a new owner and cancelling the renouncement of the ownership._ + +### cancelSubsetNonces + +```solidity +function cancelSubsetNonces(uint256[] subsetNonces) external nonpayable +``` + +This function allows a user to cancel an array of subset nonces. + +_It does not check the status of the nonces to save gas._ + +#### Parameters + +| Name | Type | Description | +| ------------ | --------- | ---------------------- | +| subsetNonces | uint256[] | Array of subset nonces | + +### chainId + +```solidity +function chainId() external view returns (uint256) +``` + +Current chainId. + +#### Returns + +| Name | Type | Description | +| ---- | ------- | ----------- | +| \_0 | uint256 | undefined | + +### confirmOwnershipRenouncement + +```solidity +function confirmOwnershipRenouncement() external nonpayable +``` + +This function is used to confirm the ownership renouncement. + +### confirmOwnershipTransfer + +```solidity +function confirmOwnershipTransfer() external nonpayable +``` + +This function is used to confirm the ownership transfer. + +_This function can only be called by the current potential owner._ + +### creatorFeeManager + +```solidity +function creatorFeeManager() external view returns (contract ICreatorFeeManager) +``` + +Creator fee manager. + +#### Returns + +| Name | Type | Description | +| ---- | --------------------------- | ----------- | +| \_0 | contract ICreatorFeeManager | undefined | + +### domainSeparator + +```solidity +function domainSeparator() external view returns (bytes32) +``` + +Current domain separator. + +#### Returns + +| Name | Type | Description | +| ---- | ------- | ----------- | +| \_0 | bytes32 | undefined | + +### executeMultipleTakerBids + +```solidity +function executeMultipleTakerBids(OrderStructs.Taker[] takerBids, OrderStructs.Maker[] makerAsks, bytes[] makerSignatures, OrderStructs.MerkleTree[] merkleTrees, bool isAtomic) external payable +``` + +#### Parameters + +| Name | Type | Description | +| --------------- | ------------------------- | ----------- | +| takerBids | OrderStructs.Taker[] | undefined | +| makerAsks | OrderStructs.Maker[] | undefined | +| makerSignatures | bytes[] | undefined | +| merkleTrees | OrderStructs.MerkleTree[] | undefined | +| isAtomic | bool | undefined | + +### executeTakerAsk + +```solidity +function executeTakerAsk(OrderStructs.Taker takerAsk, OrderStructs.Maker makerBid, bytes makerSignature, OrderStructs.MerkleTree merkleTree) external nonpayable +``` + +#### Parameters + +| Name | Type | Description | +| -------------- | ----------------------- | ----------- | +| takerAsk | OrderStructs.Taker | undefined | +| makerBid | OrderStructs.Maker | undefined | +| makerSignature | bytes | undefined | +| merkleTree | OrderStructs.MerkleTree | undefined | + +### executeTakerBid + +```solidity +function executeTakerBid(OrderStructs.Taker takerBid, OrderStructs.Maker makerAsk, bytes makerSignature, OrderStructs.MerkleTree merkleTree) external payable +``` + +#### Parameters + +| Name | Type | Description | +| -------------- | ----------------------- | ----------- | +| takerBid | OrderStructs.Taker | undefined | +| makerAsk | OrderStructs.Maker | undefined | +| makerSignature | bytes | undefined | +| merkleTree | OrderStructs.MerkleTree | undefined | + +### hashBatchOrder + +```solidity +function hashBatchOrder(bytes32 root, uint256 proofLength) external pure returns (bytes32 batchOrderHash) +``` + +This function returns the hash of the concatenation of batch order type hash and merkle root. + +#### Parameters + +| Name | Type | Description | +| ----------- | ------- | ------------------- | +| root | bytes32 | Merkle root | +| proofLength | uint256 | Merkle proof length | + +#### Returns + +| Name | Type | Description | +| -------------- | ------- | -------------------- | +| batchOrderHash | bytes32 | The batch order hash | + +### incrementBidAskNonces + +```solidity +function incrementBidAskNonces(bool bid, bool ask) external nonpayable +``` + +This function increments a user's bid/ask nonces. + +_The logic for computing the quasi-random number is inspired by Seaport v1.2. The pseudo-randomness allows non-deterministic computation of the next ask/bid nonce. A deterministic increment would make the cancel-all process non-effective in certain cases (orders signed with a greater ask/bid nonce). The same quasi-random number is used for incrementing both the bid and ask nonces if both values are incremented in the same transaction. If this function is used twice in the same block, it will return the same quasiRandomNumber but this will not impact the overall business logic._ + +#### Parameters + +| Name | Type | Description | +| ---- | ---- | --------------------------------------- | +| bid | bool | Whether to increment the user bid nonce | +| ask | bool | Whether to increment the user ask nonce | + +### initiateOwnershipRenouncement + +```solidity +function initiateOwnershipRenouncement() external nonpayable +``` + +This function is used to initiate the ownership renouncement. + +### initiateOwnershipTransfer + +```solidity +function initiateOwnershipTransfer(address newPotentialOwner) external nonpayable +``` + +This function is used to initiate the transfer of ownership to a new owner. + +#### Parameters + +| Name | Type | Description | +| ----------------- | ------- | --------------------------- | +| newPotentialOwner | address | New potential owner address | + +### isCurrencyAllowed + +```solidity +function isCurrencyAllowed(address) external view returns (bool) +``` + +It checks whether the currency is allowed for transacting. + +#### Parameters + +| Name | Type | Description | +| ---- | ------- | ----------- | +| \_0 | address | undefined | + +#### Returns + +| Name | Type | Description | +| ---- | ---- | ----------- | +| \_0 | bool | undefined | + +### maxCreatorFeeBp + +```solidity +function maxCreatorFeeBp() external view returns (uint16) +``` + +Maximum creator fee (in basis point). + +#### Returns + +| Name | Type | Description | +| ---- | ------ | ----------- | +| \_0 | uint16 | undefined | + +### owner + +```solidity +function owner() external view returns (address) +``` + +Address of the current owner. + +#### Returns + +| Name | Type | Description | +| ---- | ------- | ----------- | +| \_0 | address | undefined | + +### ownershipStatus + +```solidity +function ownershipStatus() external view returns (enum IOwnableTwoSteps.Status) +``` + +Ownership status. + +#### Returns + +| Name | Type | Description | +| ---- | ---------------------------- | ----------- | +| \_0 | enum IOwnableTwoSteps.Status | undefined | + +### potentialOwner + +```solidity +function potentialOwner() external view returns (address) +``` + +Address of the potential owner. + +#### Returns + +| Name | Type | Description | +| ---- | ------- | ----------- | +| \_0 | address | undefined | + +### protocolFeeRecipient + +```solidity +function protocolFeeRecipient() external view returns (address) +``` + +Protocol fee recipient. + +#### Returns + +| Name | Type | Description | +| ---- | ------- | ----------- | +| \_0 | address | undefined | + +### restrictedExecuteTakerBid + +```solidity +function restrictedExecuteTakerBid(OrderStructs.Taker takerBid, OrderStructs.Maker makerAsk, address sender, bytes32 orderHash) external nonpayable returns (uint256 protocolFeeAmount) +``` + +#### Parameters + +| Name | Type | Description | +| --------- | ------------------ | ----------- | +| takerBid | OrderStructs.Taker | undefined | +| makerAsk | OrderStructs.Maker | undefined | +| sender | address | undefined | +| orderHash | bytes32 | undefined | + +#### Returns + +| Name | Type | Description | +| ----------------- | ------- | ----------- | +| protocolFeeAmount | uint256 | undefined | + +### strategyInfo + +```solidity +function strategyInfo(uint256) external view returns (bool isActive, uint16 standardProtocolFeeBp, uint16 minTotalFeeBp, uint16 maxProtocolFeeBp, bytes4 selector, bool isMakerBid, address implementation) +``` + +This returns the strategy information for a strategy id. + +#### Parameters + +| Name | Type | Description | +| ---- | ------- | ----------- | +| \_0 | uint256 | undefined | + +#### Returns + +| Name | Type | Description | +| --------------------- | ------- | ----------- | +| isActive | bool | undefined | +| standardProtocolFeeBp | uint16 | undefined | +| minTotalFeeBp | uint16 | undefined | +| maxProtocolFeeBp | uint16 | undefined | +| selector | bytes4 | undefined | +| isMakerBid | bool | undefined | +| implementation | address | undefined | + +### transferManager + +```solidity +function transferManager() external view returns (contract TransferManager) +``` + +Transfer manager for ERC721 and ERC1155. + +#### Returns + +| Name | Type | Description | +| ---- | ------------------------ | ----------- | +| \_0 | contract TransferManager | undefined | + +### updateCreatorFeeManager + +```solidity +function updateCreatorFeeManager(address newCreatorFeeManager) external nonpayable +``` + +This function allows the owner to update the creator fee manager address. + +_Only callable by owner._ + +#### Parameters + +| Name | Type | Description | +| -------------------- | ------- | ---------------------------------- | +| newCreatorFeeManager | address | Address of the creator fee manager | + +### updateCurrencyStatus + +```solidity +function updateCurrencyStatus(address currency, bool isAllowed) external nonpayable +``` + +This function allows the owner to update the status of a currency. + +_Only callable by owner._ + +#### Parameters + +| Name | Type | Description | +| --------- | ------- | -------------------------------------------------- | +| currency | address | Currency address (address(0) for ETH) | +| isAllowed | bool | Whether the currency should be allowed for trading | + +### updateDomainSeparator + +```solidity +function updateDomainSeparator() external nonpayable +``` + +This function allows the owner to update the domain separator (if possible). + +_Only callable by owner. If there is a fork of the network with a new chainId, it allows the owner to reset the domain separator for the new chain id._ + +### updateETHGasLimitForTransfer + +```solidity +function updateETHGasLimitForTransfer(uint256 newGasLimitETHTransfer) external nonpayable +``` + +This function allows the owner to update the maximum ETH gas limit for a standard transfer. + +_Only callable by owner._ + +#### Parameters + +| Name | Type | Description | +| ---------------------- | ------- | ------------------------------ | +| newGasLimitETHTransfer | uint256 | New gas limit for ETH transfer | + +### updateMaxCreatorFeeBp + +```solidity +function updateMaxCreatorFeeBp(uint16 newMaxCreatorFeeBp) external nonpayable +``` + +This function allows the owner to update the maximum creator fee (in basis point). + +_The maximum value that can be set is 25%. Only callable by owner._ + +#### Parameters + +| Name | Type | Description | +| ------------------ | ------ | ---------------------------------------- | +| newMaxCreatorFeeBp | uint16 | New maximum creator fee (in basis point) | + +### updateProtocolFeeRecipient + +```solidity +function updateProtocolFeeRecipient(address newProtocolFeeRecipient) external nonpayable +``` + +This function allows the owner to update the protocol fee recipient. + +_Only callable by owner._ + +#### Parameters + +| Name | Type | Description | +| ----------------------- | ------- | ---------------------------------- | +| newProtocolFeeRecipient | address | New protocol fee recipient address | + +### updateStrategy + +```solidity +function updateStrategy(uint256 strategyId, bool isActive, uint16 newStandardProtocolFee, uint16 newMinTotalFee) external nonpayable +``` + +This function allows the owner to update parameters for an existing execution strategy. + +_Only callable by owner._ + +#### Parameters + +| Name | Type | Description | +| ---------------------- | ------- | ------------------------------------------ | +| strategyId | uint256 | Strategy id | +| isActive | bool | Whether the strategy must be active | +| newStandardProtocolFee | uint16 | New standard protocol fee (in basis point) | +| newMinTotalFee | uint16 | New minimum total fee (in basis point) | + +### userBidAskNonces + +```solidity +function userBidAskNonces(address) external view returns (uint256 bidNonce, uint256 askNonce) +``` + +This tracks the bid and ask nonces for a user address. + +#### Parameters + +| Name | Type | Description | +| ---- | ------- | ----------- | +| \_0 | address | undefined | + +#### Returns + +| Name | Type | Description | +| -------- | ------- | ----------- | +| bidNonce | uint256 | undefined | +| askNonce | uint256 | undefined | + +### userOrderNonce + +```solidity +function userOrderNonce(address, uint256) external view returns (bytes32) +``` + +This checks whether the order nonce for a user was executed or cancelled. + +#### Parameters + +| Name | Type | Description | +| ---- | ------- | ----------- | +| \_0 | address | undefined | +| \_1 | uint256 | undefined | + +#### Returns + +| Name | Type | Description | +| ---- | ------- | ----------- | +| \_0 | bytes32 | undefined | + +### userSubsetNonce + +```solidity +function userSubsetNonce(address, uint256) external view returns (bool) +``` + +This checks whether the subset nonce for a user was cancelled. + +#### Parameters + +| Name | Type | Description | +| ---- | ------- | ----------- | +| \_0 | address | undefined | +| \_1 | uint256 | undefined | + +#### Returns + +| Name | Type | Description | +| ---- | ---- | ----------- | +| \_0 | bool | undefined | + +## Events + +### CancelOwnershipTransfer + +```solidity +event CancelOwnershipTransfer() +``` + +This is emitted if the ownership transfer is cancelled. + +### CurrencyStatusUpdated + +```solidity +event CurrencyStatusUpdated(address currency, bool isAllowed) +``` + +It is emitted if the currency status in the allowlist is updated. + +#### Parameters + +| Name | Type | Description | +| --------- | ------- | ----------- | +| currency | address | undefined | +| isAllowed | bool | undefined | + +### InitiateOwnershipRenouncement + +```solidity +event InitiateOwnershipRenouncement() +``` + +This is emitted if the ownership renouncement is initiated. + +### InitiateOwnershipTransfer + +```solidity +event InitiateOwnershipTransfer(address previousOwner, address potentialOwner) +``` + +This is emitted if the ownership transfer is initiated. + +#### Parameters + +| Name | Type | Description | +| -------------- | ------- | ----------- | +| previousOwner | address | undefined | +| potentialOwner | address | undefined | + +### NewBidAskNonces + +```solidity +event NewBidAskNonces(address user, uint256 bidNonce, uint256 askNonce) +``` + +It is emitted when there is an update of the global bid/ask nonces for a user. + +#### Parameters + +| Name | Type | Description | +| -------- | ------- | ----------- | +| user | address | undefined | +| bidNonce | uint256 | undefined | +| askNonce | uint256 | undefined | + +### NewCreatorFeeManager + +```solidity +event NewCreatorFeeManager(address creatorFeeManager) +``` + +It is issued when there is a new creator fee manager. + +#### Parameters + +| Name | Type | Description | +| ----------------- | ------- | ----------- | +| creatorFeeManager | address | undefined | + +### NewDomainSeparator + +```solidity +event NewDomainSeparator() +``` + +It is emitted if there is a change in the domain separator. + +### NewGasLimitETHTransfer + +```solidity +event NewGasLimitETHTransfer(uint256 gasLimitETHTransfer) +``` + +It is emitted when there is a new gas limit for a ETH transfer (before it is wrapped to WETH). + +#### Parameters + +| Name | Type | Description | +| ------------------- | ------- | ----------- | +| gasLimitETHTransfer | uint256 | undefined | + +### NewMaxCreatorFeeBp + +```solidity +event NewMaxCreatorFeeBp(uint256 maxCreatorFeeBp) +``` + +It is issued when there is a new maximum creator fee (in basis point). + +#### Parameters + +| Name | Type | Description | +| --------------- | ------- | ----------- | +| maxCreatorFeeBp | uint256 | undefined | + +### NewOwner + +```solidity +event NewOwner(address newOwner) +``` + +This is emitted when there is a new owner. + +#### Parameters + +| Name | Type | Description | +| -------- | ------- | ----------- | +| newOwner | address | undefined | + +### NewProtocolFeeRecipient + +```solidity +event NewProtocolFeeRecipient(address protocolFeeRecipient) +``` + +It is issued when there is a new protocol fee recipient address. + +#### Parameters + +| Name | Type | Description | +| -------------------- | ------- | ----------- | +| protocolFeeRecipient | address | undefined | + +### NewStrategy + +```solidity +event NewStrategy(uint256 strategyId, uint16 standardProtocolFeeBp, uint16 minTotalFeeBp, uint16 maxProtocolFeeBp, bytes4 selector, bool isMakerBid, address implementation) +``` + +It is emitted when a new strategy is added. + +#### Parameters + +| Name | Type | Description | +| --------------------- | ------- | ----------- | +| strategyId | uint256 | undefined | +| standardProtocolFeeBp | uint16 | undefined | +| minTotalFeeBp | uint16 | undefined | +| maxProtocolFeeBp | uint16 | undefined | +| selector | bytes4 | undefined | +| isMakerBid | bool | undefined | +| implementation | address | undefined | + +### OrderNoncesCancelled + +```solidity +event OrderNoncesCancelled(address user, uint256[] orderNonces) +``` + +It is emitted when order nonces are cancelled for a user. + +#### Parameters + +| Name | Type | Description | +| ----------- | --------- | ----------- | +| user | address | undefined | +| orderNonces | uint256[] | undefined | + +### StrategyUpdated + +```solidity +event StrategyUpdated(uint256 strategyId, bool isActive, uint16 standardProtocolFeeBp, uint16 minTotalFeeBp) +``` + +It is emitted when an existing strategy is updated. + +#### Parameters + +| Name | Type | Description | +| --------------------- | ------- | ----------- | +| strategyId | uint256 | undefined | +| isActive | bool | undefined | +| standardProtocolFeeBp | uint16 | undefined | +| minTotalFeeBp | uint16 | undefined | + +### SubsetNoncesCancelled + +```solidity +event SubsetNoncesCancelled(address user, uint256[] subsetNonces) +``` + +It is emitted when subset nonces are cancelled for a user. + +#### Parameters + +| Name | Type | Description | +| ------------ | --------- | ----------- | +| user | address | undefined | +| subsetNonces | uint256[] | undefined | + +### TakerAsk + +```solidity +event TakerAsk(ILooksRareProtocol.NonceInvalidationParameters nonceInvalidationParameters, address askUser, address bidUser, uint256 strategyId, address currency, address collection, uint256[] itemIds, uint256[] amounts, address[2] feeRecipients, uint256[3] feeAmounts) +``` + +It is emitted when a taker ask transaction is completed. + +#### Parameters + +| Name | Type | Description | +| --------------------------- | ---------------------------------------------- | ----------- | +| nonceInvalidationParameters | ILooksRareProtocol.NonceInvalidationParameters | undefined | +| askUser | address | undefined | +| bidUser | address | undefined | +| strategyId | uint256 | undefined | +| currency | address | undefined | +| collection | address | undefined | +| itemIds | uint256[] | undefined | +| amounts | uint256[] | undefined | +| feeRecipients | address[2] | undefined | +| feeAmounts | uint256[3] | undefined | + +### TakerBid + +```solidity +event TakerBid(ILooksRareProtocol.NonceInvalidationParameters nonceInvalidationParameters, address bidUser, address bidRecipient, uint256 strategyId, address currency, address collection, uint256[] itemIds, uint256[] amounts, address[2] feeRecipients, uint256[3] feeAmounts) +``` + +It is emitted when a taker bid transaction is completed. + +#### Parameters + +| Name | Type | Description | +| --------------------------- | ---------------------------------------------- | ----------- | +| nonceInvalidationParameters | ILooksRareProtocol.NonceInvalidationParameters | undefined | +| bidUser | address | undefined | +| bidRecipient | address | undefined | +| strategyId | uint256 | undefined | +| currency | address | undefined | +| collection | address | undefined | +| itemIds | uint256[] | undefined | +| amounts | uint256[] | undefined | +| feeRecipients | address[2] | undefined | +| feeAmounts | uint256[3] | undefined | + +## Errors + +### CallerInvalid + +```solidity +error CallerInvalid() +``` + +It is returned if the function cannot be called by the sender. + +### ChainIdInvalid + +```solidity +error ChainIdInvalid() +``` + +It is returned if the domain separator should change. + +### CreatorFeeBpTooHigh + +```solidity +error CreatorFeeBpTooHigh() +``` + +It is returned if the creator fee (in basis point) is too high. + +### CurrencyInvalid + +```solidity +error CurrencyInvalid() +``` + +It is returned if the currency is invalid. + +### ERC20TransferFromFail + +```solidity +error ERC20TransferFromFail() +``` + +It is emitted if the ERC20 transferFrom fails. + +### LengthsInvalid + +```solidity +error LengthsInvalid() +``` + +It is returned if there is either a mismatch or an error in the length of the array(s). + +### MerkleProofInvalid + +```solidity +error MerkleProofInvalid() +``` + +It is returned if the merkle proof provided is invalid. + +### MerkleProofTooLarge + +```solidity +error MerkleProofTooLarge(uint256 length) +``` + +It is returned if the length of the merkle proof provided is greater than tolerated. + +#### Parameters + +| Name | Type | Description | +| ------ | ------- | ------------ | +| length | uint256 | Proof length | + +### NewGasLimitETHTransferTooLow + +```solidity +error NewGasLimitETHTransferTooLow() +``` + +It is returned if the gas limit for a standard ETH transfer is too low. + +### NewProtocolFeeRecipientCannotBeNullAddress + +```solidity +error NewProtocolFeeRecipientCannotBeNullAddress() +``` + +It is returned if the new protocol fee recipient is set to address(0). + +### NoOngoingTransferInProgress + +```solidity +error NoOngoingTransferInProgress() +``` + +This is returned when there is no transfer of ownership in progress. + +### NoSelectorForStrategy + +```solidity +error NoSelectorForStrategy() +``` + +It is returned if there is no selector for maker ask/bid for a given strategyId, depending on the quote type. + +### NoncesInvalid + +```solidity +error NoncesInvalid() +``` + +It is returned if the nonces are invalid. + +### NotAContract + +```solidity +error NotAContract() +``` + +It is emitted if the call recipient is not a contract. + +### NotOwner + +```solidity +error NotOwner() +``` + +This is returned when the caller is not the owner. + +### NotV2Strategy + +```solidity +error NotV2Strategy() +``` + +If the strategy has not set properly its implementation contract. + +_It can only be returned for owner operations._ + +### NullSignerAddress + +```solidity +error NullSignerAddress() +``` + +It is emitted if the signer is null. + +### OutsideOfTimeRange + +```solidity +error OutsideOfTimeRange() +``` + +It is returned if the current block timestamp is not between start and end times in the maker order. + +### QuoteTypeInvalid + +```solidity +error QuoteTypeInvalid() +``` + +It is returned if the maker quote type is invalid. + +### ReentrancyFail + +```solidity +error ReentrancyFail() +``` + +This is returned when there is a reentrant call. + +### RenouncementNotInProgress + +```solidity +error RenouncementNotInProgress() +``` + +This is returned when there is no renouncement in progress but the owner tries to validate the ownership renouncement. + +### SameDomainSeparator + +```solidity +error SameDomainSeparator() +``` + +It is returned if the domain separator cannot be updated (i.e. the chainId is the same). + +### SignatureEOAInvalid + +```solidity +error SignatureEOAInvalid() +``` + +It is emitted if the signature is invalid for an EOA (the address recovered is not the expected one). + +### SignatureERC1271Invalid + +```solidity +error SignatureERC1271Invalid() +``` + +It is emitted if the signature is invalid for a ERC1271 contract signer. + +### SignatureLengthInvalid + +```solidity +error SignatureLengthInvalid(uint256 length) +``` + +It is emitted if the signature's length is neither 64 nor 65 bytes. + +#### Parameters + +| Name | Type | Description | +| ------ | ------- | ----------- | +| length | uint256 | undefined | + +### SignatureParameterSInvalid + +```solidity +error SignatureParameterSInvalid() +``` + +It is emitted if the signature is invalid due to S parameter. + +### SignatureParameterVInvalid + +```solidity +error SignatureParameterVInvalid(uint8 v) +``` + +It is emitted if the signature is invalid due to V parameter. + +#### Parameters + +| Name | Type | Description | +| ---- | ----- | ----------- | +| v | uint8 | undefined | + +### StrategyHasNoSelector + +```solidity +error StrategyHasNoSelector() +``` + +It is returned if the strategy has no selector. + +_It can only be returned for owner operations._ + +### StrategyNotAvailable + +```solidity +error StrategyNotAvailable(uint256 strategyId) +``` + +It is returned if the strategy id has no implementation. + +_It is returned if there is no implementation address and the strategyId is strictly greater than 0._ + +#### Parameters + +| Name | Type | Description | +| ---------- | ------- | ----------- | +| strategyId | uint256 | undefined | + +### StrategyNotUsed + +```solidity +error StrategyNotUsed() +``` + +It is returned if the strategyId is invalid. + +### StrategyProtocolFeeTooHigh + +```solidity +error StrategyProtocolFeeTooHigh() +``` + +It is returned if the strategy's protocol fee is too high. + +_It can only be returned for owner operations._ + +### TransferAlreadyInProgress + +```solidity +error TransferAlreadyInProgress() +``` + +This is returned when the transfer is already in progress but the owner tries initiate a new ownership transfer. + +### TransferNotInProgress + +```solidity +error TransferNotInProgress() +``` + +This is returned when there is no ownership transfer in progress but the ownership change tries to be approved. + +### UnsupportedCollectionType + +```solidity +error UnsupportedCollectionType() +``` + +### WrongPotentialOwner + +```solidity +error WrongPotentialOwner() +``` + +This is returned when the ownership transfer is attempted to be validated by the a caller that is not the potential owner. diff --git a/docs/docs/developer/api/contracts/marketplace/NonceManager.md b/docs/docs/developer/api/contracts/marketplace/NonceManager.md new file mode 100644 index 00000000..fea95495 --- /dev/null +++ b/docs/docs/developer/api/contracts/marketplace/NonceManager.md @@ -0,0 +1,193 @@ +# NonceManager + +_LooksRare protocol team (👀,💎)_ + +> NonceManager + +This contract handles the nonce logic that is used for invalidating maker orders that exist off-chain. The nonce logic revolves around three parts at the user level: - order nonce (orders sharing an order nonce are conditional, OCO-like) - subset (orders can be grouped under a same subset) - bid/ask (all orders can be executed only if the bid/ask nonce matches the user's one on-chain) Only the order nonce is invalidated at the time of the execution of a maker order that contains it. + +## Methods + +### MAGIC_VALUE_ORDER_NONCE_EXECUTED + +```solidity +function MAGIC_VALUE_ORDER_NONCE_EXECUTED() external view returns (bytes32) +``` + +Magic value nonce returned if executed (or cancelled). + +#### Returns + +| Name | Type | Description | +| ---- | ------- | ----------- | +| \_0 | bytes32 | undefined | + +### cancelOrderNonces + +```solidity +function cancelOrderNonces(uint256[] orderNonces) external nonpayable +``` + +This function allows a user to cancel an array of order nonces. + +_It does not check the status of the nonces to save gas and to prevent revertion if one of the orders is filled in the same block._ + +#### Parameters + +| Name | Type | Description | +| ----------- | --------- | --------------------- | +| orderNonces | uint256[] | Array of order nonces | + +### cancelSubsetNonces + +```solidity +function cancelSubsetNonces(uint256[] subsetNonces) external nonpayable +``` + +This function allows a user to cancel an array of subset nonces. + +_It does not check the status of the nonces to save gas._ + +#### Parameters + +| Name | Type | Description | +| ------------ | --------- | ---------------------- | +| subsetNonces | uint256[] | Array of subset nonces | + +### incrementBidAskNonces + +```solidity +function incrementBidAskNonces(bool bid, bool ask) external nonpayable +``` + +This function increments a user's bid/ask nonces. + +_The logic for computing the quasi-random number is inspired by Seaport v1.2. The pseudo-randomness allows non-deterministic computation of the next ask/bid nonce. A deterministic increment would make the cancel-all process non-effective in certain cases (orders signed with a greater ask/bid nonce). The same quasi-random number is used for incrementing both the bid and ask nonces if both values are incremented in the same transaction. If this function is used twice in the same block, it will return the same quasiRandomNumber but this will not impact the overall business logic._ + +#### Parameters + +| Name | Type | Description | +| ---- | ---- | --------------------------------------- | +| bid | bool | Whether to increment the user bid nonce | +| ask | bool | Whether to increment the user ask nonce | + +### userBidAskNonces + +```solidity +function userBidAskNonces(address) external view returns (uint256 bidNonce, uint256 askNonce) +``` + +This tracks the bid and ask nonces for a user address. + +#### Parameters + +| Name | Type | Description | +| ---- | ------- | ----------- | +| \_0 | address | undefined | + +#### Returns + +| Name | Type | Description | +| -------- | ------- | ----------- | +| bidNonce | uint256 | undefined | +| askNonce | uint256 | undefined | + +### userOrderNonce + +```solidity +function userOrderNonce(address, uint256) external view returns (bytes32) +``` + +This checks whether the order nonce for a user was executed or cancelled. + +#### Parameters + +| Name | Type | Description | +| ---- | ------- | ----------- | +| \_0 | address | undefined | +| \_1 | uint256 | undefined | + +#### Returns + +| Name | Type | Description | +| ---- | ------- | ----------- | +| \_0 | bytes32 | undefined | + +### userSubsetNonce + +```solidity +function userSubsetNonce(address, uint256) external view returns (bool) +``` + +This checks whether the subset nonce for a user was cancelled. + +#### Parameters + +| Name | Type | Description | +| ---- | ------- | ----------- | +| \_0 | address | undefined | +| \_1 | uint256 | undefined | + +#### Returns + +| Name | Type | Description | +| ---- | ---- | ----------- | +| \_0 | bool | undefined | + +## Events + +### NewBidAskNonces + +```solidity +event NewBidAskNonces(address user, uint256 bidNonce, uint256 askNonce) +``` + +It is emitted when there is an update of the global bid/ask nonces for a user. + +#### Parameters + +| Name | Type | Description | +| -------- | ------- | ----------- | +| user | address | undefined | +| bidNonce | uint256 | undefined | +| askNonce | uint256 | undefined | + +### OrderNoncesCancelled + +```solidity +event OrderNoncesCancelled(address user, uint256[] orderNonces) +``` + +It is emitted when order nonces are cancelled for a user. + +#### Parameters + +| Name | Type | Description | +| ----------- | --------- | ----------- | +| user | address | undefined | +| orderNonces | uint256[] | undefined | + +### SubsetNoncesCancelled + +```solidity +event SubsetNoncesCancelled(address user, uint256[] subsetNonces) +``` + +It is emitted when subset nonces are cancelled for a user. + +#### Parameters + +| Name | Type | Description | +| ------------ | --------- | ----------- | +| user | address | undefined | +| subsetNonces | uint256[] | undefined | + +## Errors + +### LengthsInvalid + +```solidity +error LengthsInvalid() +``` + +It is returned if there is either a mismatch or an error in the length of the array(s). diff --git a/docs/docs/developer/api/contracts/marketplace/ProtocolFeeRecipient.md b/docs/docs/developer/api/contracts/marketplace/ProtocolFeeRecipient.md new file mode 100644 index 00000000..36f6a35c --- /dev/null +++ b/docs/docs/developer/api/contracts/marketplace/ProtocolFeeRecipient.md @@ -0,0 +1,75 @@ +# ProtocolFeeRecipient + +_LooksRare protocol team (👀,💎)_ + +> ProtocolFeeRecipient + +This contract is used to receive protocol fees and transfer them to the fee sharing setter. Fee sharing setter cannot receive ETH directly, so we need to use this contract as a middleman to convert ETH into WETH before sending it. + +## Methods + +### FEE_SHARING_SETTER + +```solidity +function FEE_SHARING_SETTER() external view returns (address) +``` + +#### Returns + +| Name | Type | Description | +| ---- | ------- | ----------- | +| \_0 | address | undefined | + +### WETH + +```solidity +function WETH() external view returns (contract IWETH) +``` + +#### Returns + +| Name | Type | Description | +| ---- | -------------- | ----------- | +| \_0 | contract IWETH | undefined | + +### transferERC20 + +```solidity +function transferERC20(address currency) external nonpayable +``` + +#### Parameters + +| Name | Type | Description | +| -------- | ------- | ---------------------- | +| currency | address | ERC20 currency address | + +### transferETH + +```solidity +function transferETH() external nonpayable +``` + +## Errors + +### ERC20TransferFail + +```solidity +error ERC20TransferFail() +``` + +It is emitted if the ERC20 transfer fails. + +### NotAContract + +```solidity +error NotAContract() +``` + +It is emitted if the call recipient is not a contract. + +### NothingToTransfer + +```solidity +error NothingToTransfer() +``` diff --git a/docs/docs/developer/api/contracts/marketplace/StrategyManager.md b/docs/docs/developer/api/contracts/marketplace/StrategyManager.md new file mode 100644 index 00000000..a55f3985 --- /dev/null +++ b/docs/docs/developer/api/contracts/marketplace/StrategyManager.md @@ -0,0 +1,391 @@ +# StrategyManager + +_LooksRare protocol team (👀,💎)_ + +> StrategyManager + +This contract handles the addition and the update of execution strategies. + +## Methods + +### addStrategy + +```solidity +function addStrategy(uint16 standardProtocolFeeBp, uint16 minTotalFeeBp, uint16 maxProtocolFeeBp, bytes4 selector, bool isMakerBid, address implementation) external nonpayable +``` + +This function allows the owner to add a new execution strategy to the protocol. + +_Strategies have an id that is incremental. Only callable by owner._ + +#### Parameters + +| Name | Type | Description | +| --------------------- | ------- | ---------------------------------------------- | +| standardProtocolFeeBp | uint16 | Standard protocol fee (in basis point) | +| minTotalFeeBp | uint16 | Minimum total fee (in basis point) | +| maxProtocolFeeBp | uint16 | Maximum protocol fee (in basis point) | +| selector | bytes4 | Function selector for the strategy | +| isMakerBid | bool | Whether the function selector is for maker bid | +| implementation | address | Implementation address | + +### cancelOwnershipTransfer + +```solidity +function cancelOwnershipTransfer() external nonpayable +``` + +This function is used to cancel the ownership transfer. + +_This function can be used for both cancelling a transfer to a new owner and cancelling the renouncement of the ownership._ + +### confirmOwnershipRenouncement + +```solidity +function confirmOwnershipRenouncement() external nonpayable +``` + +This function is used to confirm the ownership renouncement. + +### confirmOwnershipTransfer + +```solidity +function confirmOwnershipTransfer() external nonpayable +``` + +This function is used to confirm the ownership transfer. + +_This function can only be called by the current potential owner._ + +### initiateOwnershipRenouncement + +```solidity +function initiateOwnershipRenouncement() external nonpayable +``` + +This function is used to initiate the ownership renouncement. + +### initiateOwnershipTransfer + +```solidity +function initiateOwnershipTransfer(address newPotentialOwner) external nonpayable +``` + +This function is used to initiate the transfer of ownership to a new owner. + +#### Parameters + +| Name | Type | Description | +| ----------------- | ------- | --------------------------- | +| newPotentialOwner | address | New potential owner address | + +### isCurrencyAllowed + +```solidity +function isCurrencyAllowed(address) external view returns (bool) +``` + +It checks whether the currency is allowed for transacting. + +#### Parameters + +| Name | Type | Description | +| ---- | ------- | ----------- | +| \_0 | address | undefined | + +#### Returns + +| Name | Type | Description | +| ---- | ---- | ----------- | +| \_0 | bool | undefined | + +### owner + +```solidity +function owner() external view returns (address) +``` + +Address of the current owner. + +#### Returns + +| Name | Type | Description | +| ---- | ------- | ----------- | +| \_0 | address | undefined | + +### ownershipStatus + +```solidity +function ownershipStatus() external view returns (enum IOwnableTwoSteps.Status) +``` + +Ownership status. + +#### Returns + +| Name | Type | Description | +| ---- | ---------------------------- | ----------- | +| \_0 | enum IOwnableTwoSteps.Status | undefined | + +### potentialOwner + +```solidity +function potentialOwner() external view returns (address) +``` + +Address of the potential owner. + +#### Returns + +| Name | Type | Description | +| ---- | ------- | ----------- | +| \_0 | address | undefined | + +### strategyInfo + +```solidity +function strategyInfo(uint256) external view returns (bool isActive, uint16 standardProtocolFeeBp, uint16 minTotalFeeBp, uint16 maxProtocolFeeBp, bytes4 selector, bool isMakerBid, address implementation) +``` + +This returns the strategy information for a strategy id. + +#### Parameters + +| Name | Type | Description | +| ---- | ------- | ----------- | +| \_0 | uint256 | undefined | + +#### Returns + +| Name | Type | Description | +| --------------------- | ------- | ----------- | +| isActive | bool | undefined | +| standardProtocolFeeBp | uint16 | undefined | +| minTotalFeeBp | uint16 | undefined | +| maxProtocolFeeBp | uint16 | undefined | +| selector | bytes4 | undefined | +| isMakerBid | bool | undefined | +| implementation | address | undefined | + +### updateCurrencyStatus + +```solidity +function updateCurrencyStatus(address currency, bool isAllowed) external nonpayable +``` + +This function allows the owner to update the status of a currency. + +_Only callable by owner._ + +#### Parameters + +| Name | Type | Description | +| --------- | ------- | -------------------------------------------------- | +| currency | address | Currency address (address(0) for ETH) | +| isAllowed | bool | Whether the currency should be allowed for trading | + +### updateStrategy + +```solidity +function updateStrategy(uint256 strategyId, bool isActive, uint16 newStandardProtocolFee, uint16 newMinTotalFee) external nonpayable +``` + +This function allows the owner to update parameters for an existing execution strategy. + +_Only callable by owner._ + +#### Parameters + +| Name | Type | Description | +| ---------------------- | ------- | ------------------------------------------ | +| strategyId | uint256 | Strategy id | +| isActive | bool | Whether the strategy must be active | +| newStandardProtocolFee | uint16 | New standard protocol fee (in basis point) | +| newMinTotalFee | uint16 | New minimum total fee (in basis point) | + +## Events + +### CancelOwnershipTransfer + +```solidity +event CancelOwnershipTransfer() +``` + +This is emitted if the ownership transfer is cancelled. + +### CurrencyStatusUpdated + +```solidity +event CurrencyStatusUpdated(address currency, bool isAllowed) +``` + +It is emitted if the currency status in the allowlist is updated. + +#### Parameters + +| Name | Type | Description | +| --------- | ------- | ----------- | +| currency | address | undefined | +| isAllowed | bool | undefined | + +### InitiateOwnershipRenouncement + +```solidity +event InitiateOwnershipRenouncement() +``` + +This is emitted if the ownership renouncement is initiated. + +### InitiateOwnershipTransfer + +```solidity +event InitiateOwnershipTransfer(address previousOwner, address potentialOwner) +``` + +This is emitted if the ownership transfer is initiated. + +#### Parameters + +| Name | Type | Description | +| -------------- | ------- | ----------- | +| previousOwner | address | undefined | +| potentialOwner | address | undefined | + +### NewOwner + +```solidity +event NewOwner(address newOwner) +``` + +This is emitted when there is a new owner. + +#### Parameters + +| Name | Type | Description | +| -------- | ------- | ----------- | +| newOwner | address | undefined | + +### NewStrategy + +```solidity +event NewStrategy(uint256 strategyId, uint16 standardProtocolFeeBp, uint16 minTotalFeeBp, uint16 maxProtocolFeeBp, bytes4 selector, bool isMakerBid, address implementation) +``` + +It is emitted when a new strategy is added. + +#### Parameters + +| Name | Type | Description | +| --------------------- | ------- | ----------- | +| strategyId | uint256 | undefined | +| standardProtocolFeeBp | uint16 | undefined | +| minTotalFeeBp | uint16 | undefined | +| maxProtocolFeeBp | uint16 | undefined | +| selector | bytes4 | undefined | +| isMakerBid | bool | undefined | +| implementation | address | undefined | + +### StrategyUpdated + +```solidity +event StrategyUpdated(uint256 strategyId, bool isActive, uint16 standardProtocolFeeBp, uint16 minTotalFeeBp) +``` + +It is emitted when an existing strategy is updated. + +#### Parameters + +| Name | Type | Description | +| --------------------- | ------- | ----------- | +| strategyId | uint256 | undefined | +| isActive | bool | undefined | +| standardProtocolFeeBp | uint16 | undefined | +| minTotalFeeBp | uint16 | undefined | + +## Errors + +### NoOngoingTransferInProgress + +```solidity +error NoOngoingTransferInProgress() +``` + +This is returned when there is no transfer of ownership in progress. + +### NotOwner + +```solidity +error NotOwner() +``` + +This is returned when the caller is not the owner. + +### NotV2Strategy + +```solidity +error NotV2Strategy() +``` + +If the strategy has not set properly its implementation contract. + +_It can only be returned for owner operations._ + +### RenouncementNotInProgress + +```solidity +error RenouncementNotInProgress() +``` + +This is returned when there is no renouncement in progress but the owner tries to validate the ownership renouncement. + +### StrategyHasNoSelector + +```solidity +error StrategyHasNoSelector() +``` + +It is returned if the strategy has no selector. + +_It can only be returned for owner operations._ + +### StrategyNotUsed + +```solidity +error StrategyNotUsed() +``` + +It is returned if the strategyId is invalid. + +### StrategyProtocolFeeTooHigh + +```solidity +error StrategyProtocolFeeTooHigh() +``` + +It is returned if the strategy's protocol fee is too high. + +_It can only be returned for owner operations._ + +### TransferAlreadyInProgress + +```solidity +error TransferAlreadyInProgress() +``` + +This is returned when the transfer is already in progress but the owner tries initiate a new ownership transfer. + +### TransferNotInProgress + +```solidity +error TransferNotInProgress() +``` + +This is returned when there is no ownership transfer in progress but the ownership change tries to be approved. + +### WrongPotentialOwner + +```solidity +error WrongPotentialOwner() +``` + +This is returned when the ownership transfer is attempted to be validated by the a caller that is not the potential owner. diff --git a/docs/docs/developer/api/contracts/marketplace/TransferManager.md b/docs/docs/developer/api/contracts/marketplace/TransferManager.md new file mode 100644 index 00000000..6091a918 --- /dev/null +++ b/docs/docs/developer/api/contracts/marketplace/TransferManager.md @@ -0,0 +1,547 @@ +# TransferManager + +_LooksRare protocol team (👀,💎)_ + +> TransferManager + +This contract provides the transfer functions for ERC721/ERC1155/Hypercert/Hyperboard for contracts that require them. Collection type "0" refers to ERC721 transfer functions. Collection type "1" refers to ERC1155 transfer functions. Collection type "2" refers to Hypercert transfer functions. Collection type "3" refers to Hyperboard transfer functions. + +_"Safe" transfer functions for ERC721 are not implemented since they come with added gas costs to verify if the recipient is a contract as it requires verifying the receiver interface is valid._ + +## Methods + +### allowOperator + +```solidity +function allowOperator(address operator) external nonpayable +``` + +This function allows an operator to be added for the shared transfer system. Once the operator is allowed, users can grant NFT approvals to this operator. + +_Only callable by owner._ + +#### Parameters + +| Name | Type | Description | +| -------- | ------- | ------------------------- | +| operator | address | Operator address to allow | + +### cancelOwnershipTransfer + +```solidity +function cancelOwnershipTransfer() external nonpayable +``` + +This function is used to cancel the ownership transfer. + +_This function can be used for both cancelling a transfer to a new owner and cancelling the renouncement of the ownership._ + +### confirmOwnershipRenouncement + +```solidity +function confirmOwnershipRenouncement() external nonpayable +``` + +This function is used to confirm the ownership renouncement. + +### confirmOwnershipTransfer + +```solidity +function confirmOwnershipTransfer() external nonpayable +``` + +This function is used to confirm the ownership transfer. + +_This function can only be called by the current potential owner._ + +### grantApprovals + +```solidity +function grantApprovals(address[] operators) external nonpayable +``` + +This function allows a user to grant approvals for an array of operators. Users cannot grant approvals if the operator is not allowed by this contract's owner. + +_Each operator address must be globally allowed to be approved._ + +#### Parameters + +| Name | Type | Description | +| --------- | --------- | --------------------------- | +| operators | address[] | Array of operator addresses | + +### hasUserApprovedOperator + +```solidity +function hasUserApprovedOperator(address, address) external view returns (bool) +``` + +This returns whether the user has approved the operator address. The first address is the user and the second address is the operator (e.g. LooksRareProtocol). + +#### Parameters + +| Name | Type | Description | +| ---- | ------- | ----------- | +| \_0 | address | undefined | +| \_1 | address | undefined | + +#### Returns + +| Name | Type | Description | +| ---- | ---- | ----------- | +| \_0 | bool | undefined | + +### initiateOwnershipRenouncement + +```solidity +function initiateOwnershipRenouncement() external nonpayable +``` + +This function is used to initiate the ownership renouncement. + +### initiateOwnershipTransfer + +```solidity +function initiateOwnershipTransfer(address newPotentialOwner) external nonpayable +``` + +This function is used to initiate the transfer of ownership to a new owner. + +#### Parameters + +| Name | Type | Description | +| ----------------- | ------- | --------------------------- | +| newPotentialOwner | address | New potential owner address | + +### isOperatorAllowed + +```solidity +function isOperatorAllowed(address) external view returns (bool) +``` + +This returns whether the operator address is allowed by this contract's owner. + +#### Parameters + +| Name | Type | Description | +| ---- | ------- | ----------- | +| \_0 | address | undefined | + +#### Returns + +| Name | Type | Description | +| ---- | ---- | ----------- | +| \_0 | bool | undefined | + +### owner + +```solidity +function owner() external view returns (address) +``` + +Address of the current owner. + +#### Returns + +| Name | Type | Description | +| ---- | ------- | ----------- | +| \_0 | address | undefined | + +### ownershipStatus + +```solidity +function ownershipStatus() external view returns (enum IOwnableTwoSteps.Status) +``` + +Ownership status. + +#### Returns + +| Name | Type | Description | +| ---- | ---------------------------- | ----------- | +| \_0 | enum IOwnableTwoSteps.Status | undefined | + +### potentialOwner + +```solidity +function potentialOwner() external view returns (address) +``` + +Address of the potential owner. + +#### Returns + +| Name | Type | Description | +| ---- | ------- | ----------- | +| \_0 | address | undefined | + +### removeOperator + +```solidity +function removeOperator(address operator) external nonpayable +``` + +This function allows the user to remove an operator for the shared transfer system. + +_Only callable by owner._ + +#### Parameters + +| Name | Type | Description | +| -------- | ------- | -------------------------- | +| operator | address | Operator address to remove | + +### revokeApprovals + +```solidity +function revokeApprovals(address[] operators) external nonpayable +``` + +This function allows a user to revoke existing approvals for an array of operators. + +_Each operator address must be approved at the user level to be revoked._ + +#### Parameters + +| Name | Type | Description | +| --------- | --------- | --------------------------- | +| operators | address[] | Array of operator addresses | + +### transferBatchItemsAcrossCollections + +```solidity +function transferBatchItemsAcrossCollections(ITransferManager.BatchTransferItem[] items, address from, address to) external nonpayable +``` + +#### Parameters + +| Name | Type | Description | +| ----- | ------------------------------------ | ----------- | +| items | ITransferManager.BatchTransferItem[] | undefined | +| from | address | undefined | +| to | address | undefined | + +### transferItemsERC1155 + +```solidity +function transferItemsERC1155(address collection, address from, address to, uint256[] itemIds, uint256[] amounts) external nonpayable +``` + +This function transfers items for a single ERC1155 collection. + +_It does not allow batch transferring if from = msg.sender since native function should be used._ + +#### Parameters + +| Name | Type | Description | +| ---------- | --------- | ------------------ | +| collection | address | Collection address | +| from | address | Sender address | +| to | address | Recipient address | +| itemIds | uint256[] | Array of itemIds | +| amounts | uint256[] | Array of amounts | + +### transferItemsERC721 + +```solidity +function transferItemsERC721(address collection, address from, address to, uint256[] itemIds, uint256[] amounts) external nonpayable +``` + +This function transfers items for a single ERC721 collection. + +#### Parameters + +| Name | Type | Description | +| ---------- | --------- | ------------------ | +| collection | address | Collection address | +| from | address | Sender address | +| to | address | Recipient address | +| itemIds | uint256[] | Array of itemIds | +| amounts | uint256[] | Array of amounts | + +### transferItemsHyperboard + +```solidity +function transferItemsHyperboard(address collection, address from, address to, uint256[] itemIds, uint256[] amounts) external nonpayable +``` + +This function transfers items for a single Hyperboard. + +_It does not allow batch transferring if from = msg.sender since native function should be used._ + +#### Parameters + +| Name | Type | Description | +| ---------- | --------- | ------------------ | +| collection | address | Collection address | +| from | address | Sender address | +| to | address | Recipient address | +| itemIds | uint256[] | Array of itemIds | +| amounts | uint256[] | Array of amounts | + +### transferItemsHypercert + +```solidity +function transferItemsHypercert(address collection, address from, address to, uint256[] itemIds, uint256[] amounts) external nonpayable +``` + +This function transfers items for a single Hypercert. + +_It does not allow batch transferring if from = msg.sender since native function should be used._ + +#### Parameters + +| Name | Type | Description | +| ---------- | --------- | ------------------ | +| collection | address | Collection address | +| from | address | Sender address | +| to | address | Recipient address | +| itemIds | uint256[] | Array of itemIds | +| amounts | uint256[] | Array of amounts | + +## Events + +### ApprovalsGranted + +```solidity +event ApprovalsGranted(address user, address[] operators) +``` + +It is emitted if operators' approvals to transfer NFTs are granted by a user. + +#### Parameters + +| Name | Type | Description | +| --------- | --------- | ----------- | +| user | address | undefined | +| operators | address[] | undefined | + +### ApprovalsRemoved + +```solidity +event ApprovalsRemoved(address user, address[] operators) +``` + +It is emitted if operators' approvals to transfer NFTs are revoked by a user. + +#### Parameters + +| Name | Type | Description | +| --------- | --------- | ----------- | +| user | address | undefined | +| operators | address[] | undefined | + +### CancelOwnershipTransfer + +```solidity +event CancelOwnershipTransfer() +``` + +This is emitted if the ownership transfer is cancelled. + +### InitiateOwnershipRenouncement + +```solidity +event InitiateOwnershipRenouncement() +``` + +This is emitted if the ownership renouncement is initiated. + +### InitiateOwnershipTransfer + +```solidity +event InitiateOwnershipTransfer(address previousOwner, address potentialOwner) +``` + +This is emitted if the ownership transfer is initiated. + +#### Parameters + +| Name | Type | Description | +| -------------- | ------- | ----------- | +| previousOwner | address | undefined | +| potentialOwner | address | undefined | + +### NewOwner + +```solidity +event NewOwner(address newOwner) +``` + +This is emitted when there is a new owner. + +#### Parameters + +| Name | Type | Description | +| -------- | ------- | ----------- | +| newOwner | address | undefined | + +### OperatorAllowed + +```solidity +event OperatorAllowed(address operator) +``` + +It is emitted if a new operator is added to the global allowlist. + +#### Parameters + +| Name | Type | Description | +| -------- | ------- | ----------- | +| operator | address | undefined | + +### OperatorRemoved + +```solidity +event OperatorRemoved(address operator) +``` + +It is emitted if an operator is removed from the global allowlist. + +#### Parameters + +| Name | Type | Description | +| -------- | ------- | ----------- | +| operator | address | undefined | + +## Errors + +### AmountInvalid + +```solidity +error AmountInvalid() +``` + +It is returned if the amount is invalid. For ERC721, any number that is not 1. For ERC1155, if amount is 0. + +### ERC1155SafeBatchTransferFromFail + +```solidity +error ERC1155SafeBatchTransferFromFail() +``` + +It is emitted if the ERC1155 safeBatchTransferFrom fails. + +### ERC1155SafeTransferFromFail + +```solidity +error ERC1155SafeTransferFromFail() +``` + +It is emitted if the ERC1155 safeTransferFrom fails. + +### ERC721TransferFromFail + +```solidity +error ERC721TransferFromFail() +``` + +It is emitted if the ERC721 transferFrom fails. + +### LengthsInvalid + +```solidity +error LengthsInvalid() +``` + +It is returned if there is either a mismatch or an error in the length of the array(s). + +### NoOngoingTransferInProgress + +```solidity +error NoOngoingTransferInProgress() +``` + +This is returned when there is no transfer of ownership in progress. + +### NotAContract + +```solidity +error NotAContract() +``` + +It is emitted if the call recipient is not a contract. + +### NotOwner + +```solidity +error NotOwner() +``` + +This is returned when the caller is not the owner. + +### OperatorAlreadyAllowed + +```solidity +error OperatorAlreadyAllowed() +``` + +It is returned if the transfer caller is already allowed by the owner. + +_This error can only be returned for owner operations._ + +### OperatorAlreadyApprovedByUser + +```solidity +error OperatorAlreadyApprovedByUser() +``` + +It is returned if the operator to approve has already been approved by the user. + +### OperatorNotAllowed + +```solidity +error OperatorNotAllowed() +``` + +It is returned if the operator to approve is not in the global allowlist defined by the owner. + +_This error can be returned if the user tries to grant approval to an operator address not in the allowlist or if the owner tries to remove the operator from the global allowlist._ + +### OperatorNotApprovedByUser + +```solidity +error OperatorNotApprovedByUser() +``` + +It is returned if the operator to revoke has not been previously approved by the user. + +### RenouncementNotInProgress + +```solidity +error RenouncementNotInProgress() +``` + +This is returned when there is no renouncement in progress but the owner tries to validate the ownership renouncement. + +### TransferAlreadyInProgress + +```solidity +error TransferAlreadyInProgress() +``` + +This is returned when the transfer is already in progress but the owner tries initiate a new ownership transfer. + +### TransferCallerInvalid + +```solidity +error TransferCallerInvalid() +``` + +It is returned if the transfer caller is invalid. For a transfer called to be valid, the operator must be in the global allowlist and approved by the 'from' user. + +### TransferNotInProgress + +```solidity +error TransferNotInProgress() +``` + +This is returned when there is no ownership transfer in progress but the ownership change tries to be approved. + +### WrongPotentialOwner + +```solidity +error WrongPotentialOwner() +``` + +This is returned when the ownership transfer is attempted to be validated by the a caller that is not the potential owner. diff --git a/docs/docs/developer/api/contracts/marketplace/TransferSelectorNFT.md b/docs/docs/developer/api/contracts/marketplace/TransferSelectorNFT.md new file mode 100644 index 00000000..2e428566 --- /dev/null +++ b/docs/docs/developer/api/contracts/marketplace/TransferSelectorNFT.md @@ -0,0 +1,779 @@ +# TransferSelectorNFT + +_LooksRare protocol team (👀,💎)_ + +> TransferSelectorNFT + +This contract handles the logic for transferring non-fungible items. + +## Methods + +### MAGIC_VALUE_ORDER_NONCE_EXECUTED + +```solidity +function MAGIC_VALUE_ORDER_NONCE_EXECUTED() external view returns (bytes32) +``` + +Magic value nonce returned if executed (or cancelled). + +#### Returns + +| Name | Type | Description | +| ---- | ------- | ----------- | +| \_0 | bytes32 | undefined | + +### addStrategy + +```solidity +function addStrategy(uint16 standardProtocolFeeBp, uint16 minTotalFeeBp, uint16 maxProtocolFeeBp, bytes4 selector, bool isMakerBid, address implementation) external nonpayable +``` + +This function allows the owner to add a new execution strategy to the protocol. + +_Strategies have an id that is incremental. Only callable by owner._ + +#### Parameters + +| Name | Type | Description | +| --------------------- | ------- | ---------------------------------------------- | +| standardProtocolFeeBp | uint16 | Standard protocol fee (in basis point) | +| minTotalFeeBp | uint16 | Minimum total fee (in basis point) | +| maxProtocolFeeBp | uint16 | Maximum protocol fee (in basis point) | +| selector | bytes4 | Function selector for the strategy | +| isMakerBid | bool | Whether the function selector is for maker bid | +| implementation | address | Implementation address | + +### cancelOrderNonces + +```solidity +function cancelOrderNonces(uint256[] orderNonces) external nonpayable +``` + +This function allows a user to cancel an array of order nonces. + +_It does not check the status of the nonces to save gas and to prevent revertion if one of the orders is filled in the same block._ + +#### Parameters + +| Name | Type | Description | +| ----------- | --------- | --------------------- | +| orderNonces | uint256[] | Array of order nonces | + +### cancelOwnershipTransfer + +```solidity +function cancelOwnershipTransfer() external nonpayable +``` + +This function is used to cancel the ownership transfer. + +_This function can be used for both cancelling a transfer to a new owner and cancelling the renouncement of the ownership._ + +### cancelSubsetNonces + +```solidity +function cancelSubsetNonces(uint256[] subsetNonces) external nonpayable +``` + +This function allows a user to cancel an array of subset nonces. + +_It does not check the status of the nonces to save gas._ + +#### Parameters + +| Name | Type | Description | +| ------------ | --------- | ---------------------- | +| subsetNonces | uint256[] | Array of subset nonces | + +### confirmOwnershipRenouncement + +```solidity +function confirmOwnershipRenouncement() external nonpayable +``` + +This function is used to confirm the ownership renouncement. + +### confirmOwnershipTransfer + +```solidity +function confirmOwnershipTransfer() external nonpayable +``` + +This function is used to confirm the ownership transfer. + +_This function can only be called by the current potential owner._ + +### creatorFeeManager + +```solidity +function creatorFeeManager() external view returns (contract ICreatorFeeManager) +``` + +Creator fee manager. + +#### Returns + +| Name | Type | Description | +| ---- | --------------------------- | ----------- | +| \_0 | contract ICreatorFeeManager | undefined | + +### incrementBidAskNonces + +```solidity +function incrementBidAskNonces(bool bid, bool ask) external nonpayable +``` + +This function increments a user's bid/ask nonces. + +_The logic for computing the quasi-random number is inspired by Seaport v1.2. The pseudo-randomness allows non-deterministic computation of the next ask/bid nonce. A deterministic increment would make the cancel-all process non-effective in certain cases (orders signed with a greater ask/bid nonce). The same quasi-random number is used for incrementing both the bid and ask nonces if both values are incremented in the same transaction. If this function is used twice in the same block, it will return the same quasiRandomNumber but this will not impact the overall business logic._ + +#### Parameters + +| Name | Type | Description | +| ---- | ---- | --------------------------------------- | +| bid | bool | Whether to increment the user bid nonce | +| ask | bool | Whether to increment the user ask nonce | + +### initiateOwnershipRenouncement + +```solidity +function initiateOwnershipRenouncement() external nonpayable +``` + +This function is used to initiate the ownership renouncement. + +### initiateOwnershipTransfer + +```solidity +function initiateOwnershipTransfer(address newPotentialOwner) external nonpayable +``` + +This function is used to initiate the transfer of ownership to a new owner. + +#### Parameters + +| Name | Type | Description | +| ----------------- | ------- | --------------------------- | +| newPotentialOwner | address | New potential owner address | + +### isCurrencyAllowed + +```solidity +function isCurrencyAllowed(address) external view returns (bool) +``` + +It checks whether the currency is allowed for transacting. + +#### Parameters + +| Name | Type | Description | +| ---- | ------- | ----------- | +| \_0 | address | undefined | + +#### Returns + +| Name | Type | Description | +| ---- | ---- | ----------- | +| \_0 | bool | undefined | + +### maxCreatorFeeBp + +```solidity +function maxCreatorFeeBp() external view returns (uint16) +``` + +Maximum creator fee (in basis point). + +#### Returns + +| Name | Type | Description | +| ---- | ------ | ----------- | +| \_0 | uint16 | undefined | + +### owner + +```solidity +function owner() external view returns (address) +``` + +Address of the current owner. + +#### Returns + +| Name | Type | Description | +| ---- | ------- | ----------- | +| \_0 | address | undefined | + +### ownershipStatus + +```solidity +function ownershipStatus() external view returns (enum IOwnableTwoSteps.Status) +``` + +Ownership status. + +#### Returns + +| Name | Type | Description | +| ---- | ---------------------------- | ----------- | +| \_0 | enum IOwnableTwoSteps.Status | undefined | + +### potentialOwner + +```solidity +function potentialOwner() external view returns (address) +``` + +Address of the potential owner. + +#### Returns + +| Name | Type | Description | +| ---- | ------- | ----------- | +| \_0 | address | undefined | + +### protocolFeeRecipient + +```solidity +function protocolFeeRecipient() external view returns (address) +``` + +Protocol fee recipient. + +#### Returns + +| Name | Type | Description | +| ---- | ------- | ----------- | +| \_0 | address | undefined | + +### strategyInfo + +```solidity +function strategyInfo(uint256) external view returns (bool isActive, uint16 standardProtocolFeeBp, uint16 minTotalFeeBp, uint16 maxProtocolFeeBp, bytes4 selector, bool isMakerBid, address implementation) +``` + +This returns the strategy information for a strategy id. + +#### Parameters + +| Name | Type | Description | +| ---- | ------- | ----------- | +| \_0 | uint256 | undefined | + +#### Returns + +| Name | Type | Description | +| --------------------- | ------- | ----------- | +| isActive | bool | undefined | +| standardProtocolFeeBp | uint16 | undefined | +| minTotalFeeBp | uint16 | undefined | +| maxProtocolFeeBp | uint16 | undefined | +| selector | bytes4 | undefined | +| isMakerBid | bool | undefined | +| implementation | address | undefined | + +### transferManager + +```solidity +function transferManager() external view returns (contract TransferManager) +``` + +Transfer manager for ERC721 and ERC1155. + +#### Returns + +| Name | Type | Description | +| ---- | ------------------------ | ----------- | +| \_0 | contract TransferManager | undefined | + +### updateCreatorFeeManager + +```solidity +function updateCreatorFeeManager(address newCreatorFeeManager) external nonpayable +``` + +This function allows the owner to update the creator fee manager address. + +_Only callable by owner._ + +#### Parameters + +| Name | Type | Description | +| -------------------- | ------- | ---------------------------------- | +| newCreatorFeeManager | address | Address of the creator fee manager | + +### updateCurrencyStatus + +```solidity +function updateCurrencyStatus(address currency, bool isAllowed) external nonpayable +``` + +This function allows the owner to update the status of a currency. + +_Only callable by owner._ + +#### Parameters + +| Name | Type | Description | +| --------- | ------- | -------------------------------------------------- | +| currency | address | Currency address (address(0) for ETH) | +| isAllowed | bool | Whether the currency should be allowed for trading | + +### updateMaxCreatorFeeBp + +```solidity +function updateMaxCreatorFeeBp(uint16 newMaxCreatorFeeBp) external nonpayable +``` + +This function allows the owner to update the maximum creator fee (in basis point). + +_The maximum value that can be set is 25%. Only callable by owner._ + +#### Parameters + +| Name | Type | Description | +| ------------------ | ------ | ---------------------------------------- | +| newMaxCreatorFeeBp | uint16 | New maximum creator fee (in basis point) | + +### updateProtocolFeeRecipient + +```solidity +function updateProtocolFeeRecipient(address newProtocolFeeRecipient) external nonpayable +``` + +This function allows the owner to update the protocol fee recipient. + +_Only callable by owner._ + +#### Parameters + +| Name | Type | Description | +| ----------------------- | ------- | ---------------------------------- | +| newProtocolFeeRecipient | address | New protocol fee recipient address | + +### updateStrategy + +```solidity +function updateStrategy(uint256 strategyId, bool isActive, uint16 newStandardProtocolFee, uint16 newMinTotalFee) external nonpayable +``` + +This function allows the owner to update parameters for an existing execution strategy. + +_Only callable by owner._ + +#### Parameters + +| Name | Type | Description | +| ---------------------- | ------- | ------------------------------------------ | +| strategyId | uint256 | Strategy id | +| isActive | bool | Whether the strategy must be active | +| newStandardProtocolFee | uint16 | New standard protocol fee (in basis point) | +| newMinTotalFee | uint16 | New minimum total fee (in basis point) | + +### userBidAskNonces + +```solidity +function userBidAskNonces(address) external view returns (uint256 bidNonce, uint256 askNonce) +``` + +This tracks the bid and ask nonces for a user address. + +#### Parameters + +| Name | Type | Description | +| ---- | ------- | ----------- | +| \_0 | address | undefined | + +#### Returns + +| Name | Type | Description | +| -------- | ------- | ----------- | +| bidNonce | uint256 | undefined | +| askNonce | uint256 | undefined | + +### userOrderNonce + +```solidity +function userOrderNonce(address, uint256) external view returns (bytes32) +``` + +This checks whether the order nonce for a user was executed or cancelled. + +#### Parameters + +| Name | Type | Description | +| ---- | ------- | ----------- | +| \_0 | address | undefined | +| \_1 | uint256 | undefined | + +#### Returns + +| Name | Type | Description | +| ---- | ------- | ----------- | +| \_0 | bytes32 | undefined | + +### userSubsetNonce + +```solidity +function userSubsetNonce(address, uint256) external view returns (bool) +``` + +This checks whether the subset nonce for a user was cancelled. + +#### Parameters + +| Name | Type | Description | +| ---- | ------- | ----------- | +| \_0 | address | undefined | +| \_1 | uint256 | undefined | + +#### Returns + +| Name | Type | Description | +| ---- | ---- | ----------- | +| \_0 | bool | undefined | + +## Events + +### CancelOwnershipTransfer + +```solidity +event CancelOwnershipTransfer() +``` + +This is emitted if the ownership transfer is cancelled. + +### CurrencyStatusUpdated + +```solidity +event CurrencyStatusUpdated(address currency, bool isAllowed) +``` + +It is emitted if the currency status in the allowlist is updated. + +#### Parameters + +| Name | Type | Description | +| --------- | ------- | ----------- | +| currency | address | undefined | +| isAllowed | bool | undefined | + +### InitiateOwnershipRenouncement + +```solidity +event InitiateOwnershipRenouncement() +``` + +This is emitted if the ownership renouncement is initiated. + +### InitiateOwnershipTransfer + +```solidity +event InitiateOwnershipTransfer(address previousOwner, address potentialOwner) +``` + +This is emitted if the ownership transfer is initiated. + +#### Parameters + +| Name | Type | Description | +| -------------- | ------- | ----------- | +| previousOwner | address | undefined | +| potentialOwner | address | undefined | + +### NewBidAskNonces + +```solidity +event NewBidAskNonces(address user, uint256 bidNonce, uint256 askNonce) +``` + +It is emitted when there is an update of the global bid/ask nonces for a user. + +#### Parameters + +| Name | Type | Description | +| -------- | ------- | ----------- | +| user | address | undefined | +| bidNonce | uint256 | undefined | +| askNonce | uint256 | undefined | + +### NewCreatorFeeManager + +```solidity +event NewCreatorFeeManager(address creatorFeeManager) +``` + +It is issued when there is a new creator fee manager. + +#### Parameters + +| Name | Type | Description | +| ----------------- | ------- | ----------- | +| creatorFeeManager | address | undefined | + +### NewMaxCreatorFeeBp + +```solidity +event NewMaxCreatorFeeBp(uint256 maxCreatorFeeBp) +``` + +It is issued when there is a new maximum creator fee (in basis point). + +#### Parameters + +| Name | Type | Description | +| --------------- | ------- | ----------- | +| maxCreatorFeeBp | uint256 | undefined | + +### NewOwner + +```solidity +event NewOwner(address newOwner) +``` + +This is emitted when there is a new owner. + +#### Parameters + +| Name | Type | Description | +| -------- | ------- | ----------- | +| newOwner | address | undefined | + +### NewProtocolFeeRecipient + +```solidity +event NewProtocolFeeRecipient(address protocolFeeRecipient) +``` + +It is issued when there is a new protocol fee recipient address. + +#### Parameters + +| Name | Type | Description | +| -------------------- | ------- | ----------- | +| protocolFeeRecipient | address | undefined | + +### NewStrategy + +```solidity +event NewStrategy(uint256 strategyId, uint16 standardProtocolFeeBp, uint16 minTotalFeeBp, uint16 maxProtocolFeeBp, bytes4 selector, bool isMakerBid, address implementation) +``` + +It is emitted when a new strategy is added. + +#### Parameters + +| Name | Type | Description | +| --------------------- | ------- | ----------- | +| strategyId | uint256 | undefined | +| standardProtocolFeeBp | uint16 | undefined | +| minTotalFeeBp | uint16 | undefined | +| maxProtocolFeeBp | uint16 | undefined | +| selector | bytes4 | undefined | +| isMakerBid | bool | undefined | +| implementation | address | undefined | + +### OrderNoncesCancelled + +```solidity +event OrderNoncesCancelled(address user, uint256[] orderNonces) +``` + +It is emitted when order nonces are cancelled for a user. + +#### Parameters + +| Name | Type | Description | +| ----------- | --------- | ----------- | +| user | address | undefined | +| orderNonces | uint256[] | undefined | + +### StrategyUpdated + +```solidity +event StrategyUpdated(uint256 strategyId, bool isActive, uint16 standardProtocolFeeBp, uint16 minTotalFeeBp) +``` + +It is emitted when an existing strategy is updated. + +#### Parameters + +| Name | Type | Description | +| --------------------- | ------- | ----------- | +| strategyId | uint256 | undefined | +| isActive | bool | undefined | +| standardProtocolFeeBp | uint16 | undefined | +| minTotalFeeBp | uint16 | undefined | + +### SubsetNoncesCancelled + +```solidity +event SubsetNoncesCancelled(address user, uint256[] subsetNonces) +``` + +It is emitted when subset nonces are cancelled for a user. + +#### Parameters + +| Name | Type | Description | +| ------------ | --------- | ----------- | +| user | address | undefined | +| subsetNonces | uint256[] | undefined | + +## Errors + +### CreatorFeeBpTooHigh + +```solidity +error CreatorFeeBpTooHigh() +``` + +It is returned if the creator fee (in basis point) is too high. + +### LengthsInvalid + +```solidity +error LengthsInvalid() +``` + +It is returned if there is either a mismatch or an error in the length of the array(s). + +### NewProtocolFeeRecipientCannotBeNullAddress + +```solidity +error NewProtocolFeeRecipientCannotBeNullAddress() +``` + +It is returned if the new protocol fee recipient is set to address(0). + +### NoOngoingTransferInProgress + +```solidity +error NoOngoingTransferInProgress() +``` + +This is returned when there is no transfer of ownership in progress. + +### NoSelectorForStrategy + +```solidity +error NoSelectorForStrategy() +``` + +It is returned if there is no selector for maker ask/bid for a given strategyId, depending on the quote type. + +### NotOwner + +```solidity +error NotOwner() +``` + +This is returned when the caller is not the owner. + +### NotV2Strategy + +```solidity +error NotV2Strategy() +``` + +If the strategy has not set properly its implementation contract. + +_It can only be returned for owner operations._ + +### OutsideOfTimeRange + +```solidity +error OutsideOfTimeRange() +``` + +It is returned if the current block timestamp is not between start and end times in the maker order. + +### ReentrancyFail + +```solidity +error ReentrancyFail() +``` + +This is returned when there is a reentrant call. + +### RenouncementNotInProgress + +```solidity +error RenouncementNotInProgress() +``` + +This is returned when there is no renouncement in progress but the owner tries to validate the ownership renouncement. + +### StrategyHasNoSelector + +```solidity +error StrategyHasNoSelector() +``` + +It is returned if the strategy has no selector. + +_It can only be returned for owner operations._ + +### StrategyNotAvailable + +```solidity +error StrategyNotAvailable(uint256 strategyId) +``` + +It is returned if the strategy id has no implementation. + +_It is returned if there is no implementation address and the strategyId is strictly greater than 0._ + +#### Parameters + +| Name | Type | Description | +| ---------- | ------- | ----------- | +| strategyId | uint256 | undefined | + +### StrategyNotUsed + +```solidity +error StrategyNotUsed() +``` + +It is returned if the strategyId is invalid. + +### StrategyProtocolFeeTooHigh + +```solidity +error StrategyProtocolFeeTooHigh() +``` + +It is returned if the strategy's protocol fee is too high. + +_It can only be returned for owner operations._ + +### TransferAlreadyInProgress + +```solidity +error TransferAlreadyInProgress() +``` + +This is returned when the transfer is already in progress but the owner tries initiate a new ownership transfer. + +### TransferNotInProgress + +```solidity +error TransferNotInProgress() +``` + +This is returned when there is no ownership transfer in progress but the ownership change tries to be approved. + +### UnsupportedCollectionType + +```solidity +error UnsupportedCollectionType() +``` + +### WrongPotentialOwner + +```solidity +error WrongPotentialOwner() +``` + +This is returned when the ownership transfer is attempted to be validated by the a caller that is not the potential owner. diff --git a/docs/docs/developer/api/contracts/marketplace/executionStrategies/BaseStrategy.md b/docs/docs/developer/api/contracts/marketplace/executionStrategies/BaseStrategy.md new file mode 100644 index 00000000..37866658 --- /dev/null +++ b/docs/docs/developer/api/contracts/marketplace/executionStrategies/BaseStrategy.md @@ -0,0 +1,41 @@ +# BaseStrategy + +_LooksRare protocol team (👀,💎)_ + +> BaseStrategy + +## Methods + +### isLooksRareV2Strategy + +```solidity +function isLooksRareV2Strategy() external pure returns (bool) +``` + +This function acts as a safety check for the protocol's owner when adding new execution strategies. + +#### Returns + +| Name | Type | Description | +| ---- | ---- | ---------------------------------------------- | +| \_0 | bool | Whether it is a LooksRare V2 protocol strategy | + +### isMakerOrderValid + +```solidity +function isMakerOrderValid(OrderStructs.Maker makerOrder, bytes4 functionSelector) external view returns (bool isValid, bytes4 errorSelector) +``` + +#### Parameters + +| Name | Type | Description | +| ---------------- | ------------------ | ----------- | +| makerOrder | OrderStructs.Maker | undefined | +| functionSelector | bytes4 | undefined | + +#### Returns + +| Name | Type | Description | +| ------------- | ------ | ----------- | +| isValid | bool | undefined | +| errorSelector | bytes4 | undefined | diff --git a/docs/docs/developer/api/contracts/marketplace/executionStrategies/Chainlink/BaseStrategyChainlinkPriceLatency.md b/docs/docs/developer/api/contracts/marketplace/executionStrategies/Chainlink/BaseStrategyChainlinkPriceLatency.md new file mode 100644 index 00000000..c9503939 --- /dev/null +++ b/docs/docs/developer/api/contracts/marketplace/executionStrategies/Chainlink/BaseStrategyChainlinkPriceLatency.md @@ -0,0 +1,212 @@ +# BaseStrategyChainlinkPriceLatency + +_LooksRare protocol team (👀,💎)_ + +> BaseStrategyChainlinkPriceLatency + +This contract allows the owner to define the maximum acceptable Chainlink price latency. + +## Methods + +### cancelOwnershipTransfer + +```solidity +function cancelOwnershipTransfer() external nonpayable +``` + +This function is used to cancel the ownership transfer. + +_This function can be used for both cancelling a transfer to a new owner and cancelling the renouncement of the ownership._ + +### confirmOwnershipRenouncement + +```solidity +function confirmOwnershipRenouncement() external nonpayable +``` + +This function is used to confirm the ownership renouncement. + +### confirmOwnershipTransfer + +```solidity +function confirmOwnershipTransfer() external nonpayable +``` + +This function is used to confirm the ownership transfer. + +_This function can only be called by the current potential owner._ + +### initiateOwnershipRenouncement + +```solidity +function initiateOwnershipRenouncement() external nonpayable +``` + +This function is used to initiate the ownership renouncement. + +### initiateOwnershipTransfer + +```solidity +function initiateOwnershipTransfer(address newPotentialOwner) external nonpayable +``` + +This function is used to initiate the transfer of ownership to a new owner. + +#### Parameters + +| Name | Type | Description | +| ----------------- | ------- | --------------------------- | +| newPotentialOwner | address | New potential owner address | + +### maxLatency + +```solidity +function maxLatency() external view returns (uint256) +``` + +Maximum latency accepted after which the execution strategy rejects the retrieved price. For ETH, it cannot be higher than 3,600 as Chainlink will at least update the price every 3,600 seconds, provided ETH's price does not deviate more than 0.5%. For NFTs, it cannot be higher than 86,400 as Chainlink will at least update the price every 86,400 seconds, provided ETH's price does not deviate more than 2%. + +#### Returns + +| Name | Type | Description | +| ---- | ------- | ----------- | +| \_0 | uint256 | undefined | + +### owner + +```solidity +function owner() external view returns (address) +``` + +Address of the current owner. + +#### Returns + +| Name | Type | Description | +| ---- | ------- | ----------- | +| \_0 | address | undefined | + +### ownershipStatus + +```solidity +function ownershipStatus() external view returns (enum IOwnableTwoSteps.Status) +``` + +Ownership status. + +#### Returns + +| Name | Type | Description | +| ---- | ---------------------------- | ----------- | +| \_0 | enum IOwnableTwoSteps.Status | undefined | + +### potentialOwner + +```solidity +function potentialOwner() external view returns (address) +``` + +Address of the potential owner. + +#### Returns + +| Name | Type | Description | +| ---- | ------- | ----------- | +| \_0 | address | undefined | + +## Events + +### CancelOwnershipTransfer + +```solidity +event CancelOwnershipTransfer() +``` + +This is emitted if the ownership transfer is cancelled. + +### InitiateOwnershipRenouncement + +```solidity +event InitiateOwnershipRenouncement() +``` + +This is emitted if the ownership renouncement is initiated. + +### InitiateOwnershipTransfer + +```solidity +event InitiateOwnershipTransfer(address previousOwner, address potentialOwner) +``` + +This is emitted if the ownership transfer is initiated. + +#### Parameters + +| Name | Type | Description | +| -------------- | ------- | ----------- | +| previousOwner | address | undefined | +| potentialOwner | address | undefined | + +### NewOwner + +```solidity +event NewOwner(address newOwner) +``` + +This is emitted when there is a new owner. + +#### Parameters + +| Name | Type | Description | +| -------- | ------- | ----------- | +| newOwner | address | undefined | + +## Errors + +### NoOngoingTransferInProgress + +```solidity +error NoOngoingTransferInProgress() +``` + +This is returned when there is no transfer of ownership in progress. + +### NotOwner + +```solidity +error NotOwner() +``` + +This is returned when the caller is not the owner. + +### RenouncementNotInProgress + +```solidity +error RenouncementNotInProgress() +``` + +This is returned when there is no renouncement in progress but the owner tries to validate the ownership renouncement. + +### TransferAlreadyInProgress + +```solidity +error TransferAlreadyInProgress() +``` + +This is returned when the transfer is already in progress but the owner tries initiate a new ownership transfer. + +### TransferNotInProgress + +```solidity +error TransferNotInProgress() +``` + +This is returned when there is no ownership transfer in progress but the ownership change tries to be approved. + +### WrongPotentialOwner + +```solidity +error WrongPotentialOwner() +``` + +This is returned when the ownership transfer is attempted to be validated by the a caller that is not the potential owner. diff --git a/docs/docs/developer/api/contracts/marketplace/executionStrategies/Chainlink/StrategyChainlinkUSDDynamicAsk.md b/docs/docs/developer/api/contracts/marketplace/executionStrategies/Chainlink/StrategyChainlinkUSDDynamicAsk.md new file mode 100644 index 00000000..e2d77dd3 --- /dev/null +++ b/docs/docs/developer/api/contracts/marketplace/executionStrategies/Chainlink/StrategyChainlinkUSDDynamicAsk.md @@ -0,0 +1,342 @@ +# StrategyChainlinkUSDDynamicAsk + +_LooksRare protocol team (👀,💎)_ + +> StrategyChainlinkUSDDynamicAsk + +This contract allows a seller to sell an NFT priced in USD and the receivable amount to be in ETH. + +## Methods + +### ETH_USD_PRICE_FEED_DECIMALS + +```solidity +function ETH_USD_PRICE_FEED_DECIMALS() external view returns (uint256) +``` + +_It is possible to call priceFeed.decimals() to get the decimals, but to save gas, it is hard coded instead._ + +#### Returns + +| Name | Type | Description | +| ---- | ------- | ----------- | +| \_0 | uint256 | undefined | + +### WETH + +```solidity +function WETH() external view returns (address) +``` + +Wrapped ether (WETH) address. + +#### Returns + +| Name | Type | Description | +| ---- | ------- | ----------- | +| \_0 | address | undefined | + +### cancelOwnershipTransfer + +```solidity +function cancelOwnershipTransfer() external nonpayable +``` + +This function is used to cancel the ownership transfer. + +_This function can be used for both cancelling a transfer to a new owner and cancelling the renouncement of the ownership._ + +### confirmOwnershipRenouncement + +```solidity +function confirmOwnershipRenouncement() external nonpayable +``` + +This function is used to confirm the ownership renouncement. + +### confirmOwnershipTransfer + +```solidity +function confirmOwnershipTransfer() external nonpayable +``` + +This function is used to confirm the ownership transfer. + +_This function can only be called by the current potential owner._ + +### executeStrategyWithTakerBid + +```solidity +function executeStrategyWithTakerBid(OrderStructs.Taker takerBid, OrderStructs.Maker makerAsk) external view returns (uint256 price, uint256[] itemIds, uint256[] amounts, bool isNonceInvalidated) +``` + +#### Parameters + +| Name | Type | Description | +| -------- | ------------------ | ----------- | +| takerBid | OrderStructs.Taker | undefined | +| makerAsk | OrderStructs.Maker | undefined | + +#### Returns + +| Name | Type | Description | +| ------------------ | --------- | ----------- | +| price | uint256 | undefined | +| itemIds | uint256[] | undefined | +| amounts | uint256[] | undefined | +| isNonceInvalidated | bool | undefined | + +### initiateOwnershipRenouncement + +```solidity +function initiateOwnershipRenouncement() external nonpayable +``` + +This function is used to initiate the ownership renouncement. + +### initiateOwnershipTransfer + +```solidity +function initiateOwnershipTransfer(address newPotentialOwner) external nonpayable +``` + +This function is used to initiate the transfer of ownership to a new owner. + +#### Parameters + +| Name | Type | Description | +| ----------------- | ------- | --------------------------- | +| newPotentialOwner | address | New potential owner address | + +### isLooksRareV2Strategy + +```solidity +function isLooksRareV2Strategy() external pure returns (bool) +``` + +This function acts as a safety check for the protocol's owner when adding new execution strategies. + +#### Returns + +| Name | Type | Description | +| ---- | ---- | ---------------------------------------------- | +| \_0 | bool | Whether it is a LooksRare V2 protocol strategy | + +### isMakerOrderValid + +```solidity +function isMakerOrderValid(OrderStructs.Maker makerAsk, bytes4 functionSelector) external view returns (bool isValid, bytes4 errorSelector) +``` + +#### Parameters + +| Name | Type | Description | +| ---------------- | ------------------ | ----------- | +| makerAsk | OrderStructs.Maker | undefined | +| functionSelector | bytes4 | undefined | + +#### Returns + +| Name | Type | Description | +| ------------- | ------ | ----------- | +| isValid | bool | undefined | +| errorSelector | bytes4 | undefined | + +### maxLatency + +```solidity +function maxLatency() external view returns (uint256) +``` + +Maximum latency accepted after which the execution strategy rejects the retrieved price. For ETH, it cannot be higher than 3,600 as Chainlink will at least update the price every 3,600 seconds, provided ETH's price does not deviate more than 0.5%. For NFTs, it cannot be higher than 86,400 as Chainlink will at least update the price every 86,400 seconds, provided ETH's price does not deviate more than 2%. + +#### Returns + +| Name | Type | Description | +| ---- | ------- | ----------- | +| \_0 | uint256 | undefined | + +### owner + +```solidity +function owner() external view returns (address) +``` + +Address of the current owner. + +#### Returns + +| Name | Type | Description | +| ---- | ------- | ----------- | +| \_0 | address | undefined | + +### ownershipStatus + +```solidity +function ownershipStatus() external view returns (enum IOwnableTwoSteps.Status) +``` + +Ownership status. + +#### Returns + +| Name | Type | Description | +| ---- | ---------------------------- | ----------- | +| \_0 | enum IOwnableTwoSteps.Status | undefined | + +### potentialOwner + +```solidity +function potentialOwner() external view returns (address) +``` + +Address of the potential owner. + +#### Returns + +| Name | Type | Description | +| ---- | ------- | ----------- | +| \_0 | address | undefined | + +### priceFeed + +```solidity +function priceFeed() external view returns (contract AggregatorV3Interface) +``` + +ETH/USD Chainlink price feed + +#### Returns + +| Name | Type | Description | +| ---- | ------------------------------ | ----------- | +| \_0 | contract AggregatorV3Interface | undefined | + +## Events + +### CancelOwnershipTransfer + +```solidity +event CancelOwnershipTransfer() +``` + +This is emitted if the ownership transfer is cancelled. + +### InitiateOwnershipRenouncement + +```solidity +event InitiateOwnershipRenouncement() +``` + +This is emitted if the ownership renouncement is initiated. + +### InitiateOwnershipTransfer + +```solidity +event InitiateOwnershipTransfer(address previousOwner, address potentialOwner) +``` + +This is emitted if the ownership transfer is initiated. + +#### Parameters + +| Name | Type | Description | +| -------------- | ------- | ----------- | +| previousOwner | address | undefined | +| potentialOwner | address | undefined | + +### NewOwner + +```solidity +event NewOwner(address newOwner) +``` + +This is emitted when there is a new owner. + +#### Parameters + +| Name | Type | Description | +| -------- | ------- | ----------- | +| newOwner | address | undefined | + +## Errors + +### BidTooLow + +```solidity +error BidTooLow() +``` + +It is returned if the bid price is too low for the ask user. + +### ChainlinkPriceInvalid + +```solidity +error ChainlinkPriceInvalid() +``` + +It is returned if the Chainlink price is invalid (e.g. negative). + +### NoOngoingTransferInProgress + +```solidity +error NoOngoingTransferInProgress() +``` + +This is returned when there is no transfer of ownership in progress. + +### NotOwner + +```solidity +error NotOwner() +``` + +This is returned when the caller is not the owner. + +### OrderInvalid + +```solidity +error OrderInvalid() +``` + +It is returned if the order is permanently invalid. There may be an issue with the order formatting. + +### PriceNotRecentEnough + +```solidity +error PriceNotRecentEnough() +``` + +It is returned if the current block time relative to the latest price's update time is greater than the latency tolerance. + +### RenouncementNotInProgress + +```solidity +error RenouncementNotInProgress() +``` + +This is returned when there is no renouncement in progress but the owner tries to validate the ownership renouncement. + +### TransferAlreadyInProgress + +```solidity +error TransferAlreadyInProgress() +``` + +This is returned when the transfer is already in progress but the owner tries initiate a new ownership transfer. + +### TransferNotInProgress + +```solidity +error TransferNotInProgress() +``` + +This is returned when there is no ownership transfer in progress but the ownership change tries to be approved. + +### WrongPotentialOwner + +```solidity +error WrongPotentialOwner() +``` + +This is returned when the ownership transfer is attempted to be validated by the a caller that is not the potential owner. diff --git a/docs/docs/developer/api/contracts/marketplace/executionStrategies/StrategyCollectionOffer.md b/docs/docs/developer/api/contracts/marketplace/executionStrategies/StrategyCollectionOffer.md new file mode 100644 index 00000000..600967db --- /dev/null +++ b/docs/docs/developer/api/contracts/marketplace/executionStrategies/StrategyCollectionOffer.md @@ -0,0 +1,107 @@ +# StrategyCollectionOffer + +_LooksRare protocol team (👀,💎)_ + +> StrategyCollectionOffer + +This contract offers execution strategies for users to create maker bid offers for items in a collection. There are two available functions: 1. executeCollectionStrategyWithTakerAsk --> it applies to all itemIds in a collection 2. executeCollectionStrategyWithTakerAskWithProof --> it allows adding merkle proof criteria.The bidder can only bid on 1 item id at a time. 1. If ERC721, the amount must be 1. 2. If ERC1155, the amount can be greater than 1. + +_Use cases can include trait-based offers or rarity score offers._ + +## Methods + +### executeCollectionStrategyWithTakerAsk + +```solidity +function executeCollectionStrategyWithTakerAsk(OrderStructs.Taker takerAsk, OrderStructs.Maker makerBid) external pure returns (uint256 price, uint256[] itemIds, uint256[] amounts, bool isNonceInvalidated) +``` + +#### Parameters + +| Name | Type | Description | +| -------- | ------------------ | ----------- | +| takerAsk | OrderStructs.Taker | undefined | +| makerBid | OrderStructs.Maker | undefined | + +#### Returns + +| Name | Type | Description | +| ------------------ | --------- | ----------- | +| price | uint256 | undefined | +| itemIds | uint256[] | undefined | +| amounts | uint256[] | undefined | +| isNonceInvalidated | bool | undefined | + +### executeCollectionStrategyWithTakerAskWithProof + +```solidity +function executeCollectionStrategyWithTakerAskWithProof(OrderStructs.Taker takerAsk, OrderStructs.Maker makerBid) external pure returns (uint256 price, uint256[] itemIds, uint256[] amounts, bool isNonceInvalidated) +``` + +#### Parameters + +| Name | Type | Description | +| -------- | ------------------ | ----------- | +| takerAsk | OrderStructs.Taker | undefined | +| makerBid | OrderStructs.Maker | undefined | + +#### Returns + +| Name | Type | Description | +| ------------------ | --------- | ----------- | +| price | uint256 | undefined | +| itemIds | uint256[] | undefined | +| amounts | uint256[] | undefined | +| isNonceInvalidated | bool | undefined | + +### isLooksRareV2Strategy + +```solidity +function isLooksRareV2Strategy() external pure returns (bool) +``` + +This function acts as a safety check for the protocol's owner when adding new execution strategies. + +#### Returns + +| Name | Type | Description | +| ---- | ---- | ---------------------------------------------- | +| \_0 | bool | Whether it is a LooksRare V2 protocol strategy | + +### isMakerOrderValid + +```solidity +function isMakerOrderValid(OrderStructs.Maker makerBid, bytes4 functionSelector) external pure returns (bool isValid, bytes4 errorSelector) +``` + +#### Parameters + +| Name | Type | Description | +| ---------------- | ------------------ | ----------- | +| makerBid | OrderStructs.Maker | undefined | +| functionSelector | bytes4 | undefined | + +#### Returns + +| Name | Type | Description | +| ------------- | ------ | ----------- | +| isValid | bool | undefined | +| errorSelector | bytes4 | undefined | + +## Errors + +### MerkleProofInvalid + +```solidity +error MerkleProofInvalid() +``` + +It is returned if the merkle proof provided is invalid. + +### OrderInvalid + +```solidity +error OrderInvalid() +``` + +It is returned if the order is permanently invalid. There may be an issue with the order formatting. diff --git a/docs/docs/developer/api/contracts/marketplace/executionStrategies/StrategyDutchAuction.md b/docs/docs/developer/api/contracts/marketplace/executionStrategies/StrategyDutchAuction.md new file mode 100644 index 00000000..1227878d --- /dev/null +++ b/docs/docs/developer/api/contracts/marketplace/executionStrategies/StrategyDutchAuction.md @@ -0,0 +1,83 @@ +# StrategyDutchAuction + +_LooksRare protocol team (👀,💎)_ + +> StrategyDutchAuction + +This contract offers a single execution strategy for users to create Dutch auctions. + +## Methods + +### executeStrategyWithTakerBid + +```solidity +function executeStrategyWithTakerBid(OrderStructs.Taker takerBid, OrderStructs.Maker makerAsk) external view returns (uint256 price, uint256[] itemIds, uint256[] amounts, bool isNonceInvalidated) +``` + +#### Parameters + +| Name | Type | Description | +| -------- | ------------------ | ----------- | +| takerBid | OrderStructs.Taker | undefined | +| makerAsk | OrderStructs.Maker | undefined | + +#### Returns + +| Name | Type | Description | +| ------------------ | --------- | ----------- | +| price | uint256 | undefined | +| itemIds | uint256[] | undefined | +| amounts | uint256[] | undefined | +| isNonceInvalidated | bool | undefined | + +### isLooksRareV2Strategy + +```solidity +function isLooksRareV2Strategy() external pure returns (bool) +``` + +This function acts as a safety check for the protocol's owner when adding new execution strategies. + +#### Returns + +| Name | Type | Description | +| ---- | ---- | ---------------------------------------------- | +| \_0 | bool | Whether it is a LooksRare V2 protocol strategy | + +### isMakerOrderValid + +```solidity +function isMakerOrderValid(OrderStructs.Maker makerAsk, bytes4 functionSelector) external pure returns (bool isValid, bytes4 errorSelector) +``` + +#### Parameters + +| Name | Type | Description | +| ---------------- | ------------------ | ----------- | +| makerAsk | OrderStructs.Maker | undefined | +| functionSelector | bytes4 | undefined | + +#### Returns + +| Name | Type | Description | +| ------------- | ------ | ----------- | +| isValid | bool | undefined | +| errorSelector | bytes4 | undefined | + +## Errors + +### BidTooLow + +```solidity +error BidTooLow() +``` + +It is returned if the bid price is too low for the ask user. + +### OrderInvalid + +```solidity +error OrderInvalid() +``` + +It is returned if the order is permanently invalid. There may be an issue with the order formatting. diff --git a/docs/docs/developer/api/contracts/marketplace/executionStrategies/StrategyItemIdsRange.md b/docs/docs/developer/api/contracts/marketplace/executionStrategies/StrategyItemIdsRange.md new file mode 100644 index 00000000..6a1f0cd5 --- /dev/null +++ b/docs/docs/developer/api/contracts/marketplace/executionStrategies/StrategyItemIdsRange.md @@ -0,0 +1,75 @@ +# StrategyItemIdsRange + +_LooksRare protocol team (👀,💎)_ + +> StrategyItemIdsRange + +This contract offers a single execution strategy for users to bid on a specific amount of items in a range bounded by 2 item ids. + +## Methods + +### executeStrategyWithTakerAsk + +```solidity +function executeStrategyWithTakerAsk(OrderStructs.Taker takerAsk, OrderStructs.Maker makerBid) external pure returns (uint256 price, uint256[] itemIds, uint256[] amounts, bool isNonceInvalidated) +``` + +#### Parameters + +| Name | Type | Description | +| -------- | ------------------ | ----------- | +| takerAsk | OrderStructs.Taker | undefined | +| makerBid | OrderStructs.Maker | undefined | + +#### Returns + +| Name | Type | Description | +| ------------------ | --------- | ----------- | +| price | uint256 | undefined | +| itemIds | uint256[] | undefined | +| amounts | uint256[] | undefined | +| isNonceInvalidated | bool | undefined | + +### isLooksRareV2Strategy + +```solidity +function isLooksRareV2Strategy() external pure returns (bool) +``` + +This function acts as a safety check for the protocol's owner when adding new execution strategies. + +#### Returns + +| Name | Type | Description | +| ---- | ---- | ---------------------------------------------- | +| \_0 | bool | Whether it is a LooksRare V2 protocol strategy | + +### isMakerOrderValid + +```solidity +function isMakerOrderValid(OrderStructs.Maker makerBid, bytes4 functionSelector) external pure returns (bool isValid, bytes4 errorSelector) +``` + +#### Parameters + +| Name | Type | Description | +| ---------------- | ------------------ | ----------- | +| makerBid | OrderStructs.Maker | undefined | +| functionSelector | bytes4 | undefined | + +#### Returns + +| Name | Type | Description | +| ------------- | ------ | ----------- | +| isValid | bool | undefined | +| errorSelector | bytes4 | undefined | + +## Errors + +### OrderInvalid + +```solidity +error OrderInvalid() +``` + +It is returned if the order is permanently invalid. There may be an issue with the order formatting. diff --git a/docs/docs/developer/api/contracts/marketplace/helpers/OrderValidatorV2A.md b/docs/docs/developer/api/contracts/marketplace/helpers/OrderValidatorV2A.md new file mode 100644 index 00000000..2d6342fd --- /dev/null +++ b/docs/docs/developer/api/contracts/marketplace/helpers/OrderValidatorV2A.md @@ -0,0 +1,201 @@ +# OrderValidatorV2A + +_LooksRare protocol team (👀,💎)_ + +> OrderValidatorV2A + +This contract is used to check the validity of maker ask/bid orders in the LooksRareProtocol (v2). It performs checks for: 1. Protocol allowlist issues (i.e. currency or strategy not allowed) 2. Maker order-specific issues (e.g., order invalid due to format or other-strategy specific issues) 3. Nonce related issues (e.g., nonce executed or cancelled) 4. Signature related issues and merkle tree parameters 5. Timestamp related issues (e.g., order expired) 6. Asset-related issues for ERC20/ERC721/ERC1155 (approvals and balances) 7. Collection-type suggestions 8. Transfer manager related issues 9. Creator fee related issues (e.g., creator fee too high, ERC2981 bundles) + +_This version does not handle strategies with partial fills._ + +## Methods + +### CRITERIA_GROUPS + +```solidity +function CRITERIA_GROUPS() external view returns (uint256) +``` + +Number of distinct criteria groups checked to evaluate the validity of an order. + +#### Returns + +| Name | Type | Description | +| ---- | ------- | ----------- | +| \_0 | uint256 | undefined | + +### ERC1155_INTERFACE_ID + +```solidity +function ERC1155_INTERFACE_ID() external view returns (bytes4) +``` + +ERC1155 interfaceId. + +#### Returns + +| Name | Type | Description | +| ---- | ------ | ----------- | +| \_0 | bytes4 | undefined | + +### ERC721_INTERFACE_ID_1 + +```solidity +function ERC721_INTERFACE_ID_1() external view returns (bytes4) +``` + +ERC721 potential interfaceId. + +#### Returns + +| Name | Type | Description | +| ---- | ------ | ----------- | +| \_0 | bytes4 | undefined | + +### ERC721_INTERFACE_ID_2 + +```solidity +function ERC721_INTERFACE_ID_2() external view returns (bytes4) +``` + +ERC721 potential interfaceId. + +#### Returns + +| Name | Type | Description | +| ---- | ------ | ----------- | +| \_0 | bytes4 | undefined | + +### MAGIC_VALUE_ORDER_NONCE_EXECUTED + +```solidity +function MAGIC_VALUE_ORDER_NONCE_EXECUTED() external view returns (bytes32) +``` + +Magic value nonce returned if executed (or cancelled). + +#### Returns + +| Name | Type | Description | +| ---- | ------- | ----------- | +| \_0 | bytes32 | undefined | + +### checkMakerOrderValidity + +```solidity +function checkMakerOrderValidity(OrderStructs.Maker makerOrder, bytes signature, OrderStructs.MerkleTree merkleTree) external view returns (uint256[9] validationCodes) +``` + +#### Parameters + +| Name | Type | Description | +| ---------- | ----------------------- | ----------- | +| makerOrder | OrderStructs.Maker | undefined | +| signature | bytes | undefined | +| merkleTree | OrderStructs.MerkleTree | undefined | + +#### Returns + +| Name | Type | Description | +| --------------- | ---------- | ----------- | +| validationCodes | uint256[9] | undefined | + +### checkMultipleMakerOrderValidities + +```solidity +function checkMultipleMakerOrderValidities(OrderStructs.Maker[] makerOrders, bytes[] signatures, OrderStructs.MerkleTree[] merkleTrees) external view returns (uint256[9][] validationCodes) +``` + +#### Parameters + +| Name | Type | Description | +| ----------- | ------------------------- | ----------- | +| makerOrders | OrderStructs.Maker[] | undefined | +| signatures | bytes[] | undefined | +| merkleTrees | OrderStructs.MerkleTree[] | undefined | + +#### Returns + +| Name | Type | Description | +| --------------- | ------------ | ----------- | +| validationCodes | uint256[9][] | undefined | + +### creatorFeeManager + +```solidity +function creatorFeeManager() external view returns (contract ICreatorFeeManager) +``` + +CreatorFeeManager. + +#### Returns + +| Name | Type | Description | +| ---- | --------------------------- | ----------- | +| \_0 | contract ICreatorFeeManager | undefined | + +### deriveProtocolParameters + +```solidity +function deriveProtocolParameters() external nonpayable +``` + +Derive protocol parameters. Anyone can call this function. + +_It allows adjusting if the domain separator or creator fee manager address were to change._ + +### domainSeparator + +```solidity +function domainSeparator() external view returns (bytes32) +``` + +LooksRareProtocol domain separator. + +#### Returns + +| Name | Type | Description | +| ---- | ------- | ----------- | +| \_0 | bytes32 | undefined | + +### looksRareProtocol + +```solidity +function looksRareProtocol() external view returns (contract LooksRareProtocol) +``` + +LooksRareProtocol. + +#### Returns + +| Name | Type | Description | +| ---- | -------------------------- | ----------- | +| \_0 | contract LooksRareProtocol | undefined | + +### maxCreatorFeeBp + +```solidity +function maxCreatorFeeBp() external view returns (uint256) +``` + +Maximum creator fee (in basis point). + +#### Returns + +| Name | Type | Description | +| ---- | ------- | ----------- | +| \_0 | uint256 | undefined | + +### transferManager + +```solidity +function transferManager() external view returns (contract TransferManager) +``` + +TransferManager + +#### Returns + +| Name | Type | Description | +| ---- | ------------------------ | ----------- | +| \_0 | contract TransferManager | undefined | diff --git a/docs/docs/developer/api/contracts/marketplace/helpers/ProtocolHelpers.md b/docs/docs/developer/api/contracts/marketplace/helpers/ProtocolHelpers.md new file mode 100644 index 00000000..91be29a9 --- /dev/null +++ b/docs/docs/developer/api/contracts/marketplace/helpers/ProtocolHelpers.md @@ -0,0 +1,159 @@ +# ProtocolHelpers + +_LooksRare protocol team (👀,💎)_ + +> ProtocolHelpers + +This contract contains helper view functions for order creation. + +## Methods + +### computeDigestMerkleTree + +```solidity +function computeDigestMerkleTree(OrderStructs.MerkleTree merkleTree) external view returns (bytes32 digest) +``` + +#### Parameters + +| Name | Type | Description | +| ---------- | ----------------------- | ----------- | +| merkleTree | OrderStructs.MerkleTree | undefined | + +#### Returns + +| Name | Type | Description | +| ------ | ------- | ----------- | +| digest | bytes32 | undefined | + +### computeMakerDigest + +```solidity +function computeMakerDigest(OrderStructs.Maker maker) external view returns (bytes32 digest) +``` + +#### Parameters + +| Name | Type | Description | +| ----- | ------------------ | ----------- | +| maker | OrderStructs.Maker | undefined | + +#### Returns + +| Name | Type | Description | +| ------ | ------- | ----------- | +| digest | bytes32 | undefined | + +### looksRareProtocol + +```solidity +function looksRareProtocol() external view returns (contract LooksRareProtocol) +``` + +#### Returns + +| Name | Type | Description | +| ---- | -------------------------- | ----------- | +| \_0 | contract LooksRareProtocol | undefined | + +### verifyMakerSignature + +```solidity +function verifyMakerSignature(OrderStructs.Maker maker, bytes makerSignature, address signer) external view returns (bool) +``` + +#### Parameters + +| Name | Type | Description | +| -------------- | ------------------ | ----------- | +| maker | OrderStructs.Maker | undefined | +| makerSignature | bytes | undefined | +| signer | address | undefined | + +#### Returns + +| Name | Type | Description | +| ---- | ---- | ----------- | +| \_0 | bool | undefined | + +### verifyMerkleTree + +```solidity +function verifyMerkleTree(OrderStructs.MerkleTree merkleTree, bytes makerSignature, address signer) external view returns (bool) +``` + +#### Parameters + +| Name | Type | Description | +| -------------- | ----------------------- | ----------- | +| merkleTree | OrderStructs.MerkleTree | undefined | +| makerSignature | bytes | undefined | +| signer | address | undefined | + +#### Returns + +| Name | Type | Description | +| ---- | ---- | ----------- | +| \_0 | bool | undefined | + +## Errors + +### NullSignerAddress + +```solidity +error NullSignerAddress() +``` + +It is emitted if the signer is null. + +### SignatureEOAInvalid + +```solidity +error SignatureEOAInvalid() +``` + +It is emitted if the signature is invalid for an EOA (the address recovered is not the expected one). + +### SignatureERC1271Invalid + +```solidity +error SignatureERC1271Invalid() +``` + +It is emitted if the signature is invalid for a ERC1271 contract signer. + +### SignatureLengthInvalid + +```solidity +error SignatureLengthInvalid(uint256 length) +``` + +It is emitted if the signature's length is neither 64 nor 65 bytes. + +#### Parameters + +| Name | Type | Description | +| ------ | ------- | ----------- | +| length | uint256 | undefined | + +### SignatureParameterSInvalid + +```solidity +error SignatureParameterSInvalid() +``` + +It is emitted if the signature is invalid due to S parameter. + +### SignatureParameterVInvalid + +```solidity +error SignatureParameterVInvalid(uint8 v) +``` + +It is emitted if the signature is invalid due to V parameter. + +#### Parameters + +| Name | Type | Description | +| ---- | ----- | ----------- | +| v | uint8 | undefined | diff --git a/docs/docs/developer/api/contracts/marketplace/interfaces/ICreatorFeeManager.md b/docs/docs/developer/api/contracts/marketplace/interfaces/ICreatorFeeManager.md new file mode 100644 index 00000000..b832744e --- /dev/null +++ b/docs/docs/developer/api/contracts/marketplace/interfaces/ICreatorFeeManager.md @@ -0,0 +1,60 @@ +# ICreatorFeeManager + +_LooksRare protocol team (👀,💎)_ + +> ICreatorFeeManager + +## Methods + +### royaltyFeeRegistry + +```solidity +function royaltyFeeRegistry() external view returns (contract IRoyaltyFeeRegistry royaltyFeeRegistry) +``` + +It returns the royalty fee registry address/interface. + +#### Returns + +| Name | Type | Description | +| ------------------ | ---------------------------- | ------------------------------------- | +| royaltyFeeRegistry | contract IRoyaltyFeeRegistry | Interface of the royalty fee registry | + +### viewCreatorFeeInfo + +```solidity +function viewCreatorFeeInfo(address collection, uint256 price, uint256[] itemIds) external view returns (address creator, uint256 creatorFeeAmount) +``` + +This function returns the creator address and calculates the creator fee amount. + +#### Parameters + +| Name | Type | Description | +| ---------- | --------- | ------------------ | +| collection | address | Collection address | +| price | uint256 | Transaction price | +| itemIds | uint256[] | Array of item ids | + +#### Returns + +| Name | Type | Description | +| ---------------- | ------- | ------------------ | +| creator | address | Creator address | +| creatorFeeAmount | uint256 | Creator fee amount | + +## Errors + +### BundleEIP2981NotAllowed + +```solidity +error BundleEIP2981NotAllowed(address collection) +``` + +It is returned if the bundle contains multiple itemIds with different creator fee structure. + +#### Parameters + +| Name | Type | Description | +| ---------- | ------- | ----------- | +| collection | address | undefined | diff --git a/docs/docs/developer/api/contracts/marketplace/interfaces/ICurrencyManager.md b/docs/docs/developer/api/contracts/marketplace/interfaces/ICurrencyManager.md new file mode 100644 index 00000000..da683d8c --- /dev/null +++ b/docs/docs/developer/api/contracts/marketplace/interfaces/ICurrencyManager.md @@ -0,0 +1,22 @@ +# ICurrencyManager + +_LooksRare protocol team (👀,💎)_ + +> ICurrencyManager + +## Events + +### CurrencyStatusUpdated + +```solidity +event CurrencyStatusUpdated(address currency, bool isAllowed) +``` + +It is emitted if the currency status in the allowlist is updated. + +#### Parameters + +| Name | Type | Description | +| --------- | ------- | ----------------------------------- | +| currency | address | Currency address (address(0) = ETH) | +| isAllowed | bool | Whether the currency is allowed | diff --git a/docs/docs/developer/api/contracts/marketplace/interfaces/IExecutionManager.md b/docs/docs/developer/api/contracts/marketplace/interfaces/IExecutionManager.md new file mode 100644 index 00000000..0e86c75b --- /dev/null +++ b/docs/docs/developer/api/contracts/marketplace/interfaces/IExecutionManager.md @@ -0,0 +1,99 @@ +# IExecutionManager + +_LooksRare protocol team (👀,💎)_ + +> IExecutionManager + +## Events + +### NewCreatorFeeManager + +```solidity +event NewCreatorFeeManager(address creatorFeeManager) +``` + +It is issued when there is a new creator fee manager. + +#### Parameters + +| Name | Type | Description | +| ----------------- | ------- | -------------------------------------- | +| creatorFeeManager | address | Address of the new creator fee manager | + +### NewMaxCreatorFeeBp + +```solidity +event NewMaxCreatorFeeBp(uint256 maxCreatorFeeBp) +``` + +It is issued when there is a new maximum creator fee (in basis point). + +#### Parameters + +| Name | Type | Description | +| --------------- | ------- | ---------------------------------------- | +| maxCreatorFeeBp | uint256 | New maximum creator fee (in basis point) | + +### NewProtocolFeeRecipient + +```solidity +event NewProtocolFeeRecipient(address protocolFeeRecipient) +``` + +It is issued when there is a new protocol fee recipient address. + +#### Parameters + +| Name | Type | Description | +| -------------------- | ------- | ----------------------------------------- | +| protocolFeeRecipient | address | Address of the new protocol fee recipient | + +## Errors + +### CreatorFeeBpTooHigh + +```solidity +error CreatorFeeBpTooHigh() +``` + +It is returned if the creator fee (in basis point) is too high. + +### NewProtocolFeeRecipientCannotBeNullAddress + +```solidity +error NewProtocolFeeRecipientCannotBeNullAddress() +``` + +It is returned if the new protocol fee recipient is set to address(0). + +### NoSelectorForStrategy + +```solidity +error NoSelectorForStrategy() +``` + +It is returned if there is no selector for maker ask/bid for a given strategyId, depending on the quote type. + +### OutsideOfTimeRange + +```solidity +error OutsideOfTimeRange() +``` + +It is returned if the current block timestamp is not between start and end times in the maker order. + +### StrategyNotAvailable + +```solidity +error StrategyNotAvailable(uint256 strategyId) +``` + +It is returned if the strategy id has no implementation. + +_It is returned if there is no implementation address and the strategyId is strictly greater than 0._ + +#### Parameters + +| Name | Type | Description | +| ---------- | ------- | ----------- | +| strategyId | uint256 | undefined | diff --git a/docs/docs/developer/api/contracts/marketplace/interfaces/IImmutableCreate2Factory.md b/docs/docs/developer/api/contracts/marketplace/interfaces/IImmutableCreate2Factory.md new file mode 100644 index 00000000..86e79020 --- /dev/null +++ b/docs/docs/developer/api/contracts/marketplace/interfaces/IImmutableCreate2Factory.md @@ -0,0 +1,22 @@ +# IImmutableCreate2Factory + +## Methods + +### safeCreate2 + +```solidity +function safeCreate2(bytes32 salt, bytes initializationCode) external payable returns (address deploymentAddress) +``` + +#### Parameters + +| Name | Type | Description | +| ------------------ | ------- | ----------- | +| salt | bytes32 | undefined | +| initializationCode | bytes | undefined | + +#### Returns + +| Name | Type | Description | +| ----------------- | ------- | ----------- | +| deploymentAddress | address | undefined | diff --git a/docs/docs/developer/api/contracts/marketplace/interfaces/ILooksRareProtocol.md b/docs/docs/developer/api/contracts/marketplace/interfaces/ILooksRareProtocol.md new file mode 100644 index 00000000..e7414f54 --- /dev/null +++ b/docs/docs/developer/api/contracts/marketplace/interfaces/ILooksRareProtocol.md @@ -0,0 +1,157 @@ +# ILooksRareProtocol + +_LooksRare protocol team (👀,💎)_ + +> ILooksRareProtocol + +## Methods + +### executeMultipleTakerBids + +```solidity +function executeMultipleTakerBids(OrderStructs.Taker[] takerBids, OrderStructs.Maker[] makerAsks, bytes[] makerSignatures, OrderStructs.MerkleTree[] merkleTrees, bool isAtomic) external payable +``` + +#### Parameters + +| Name | Type | Description | +| --------------- | ------------------------- | ----------- | +| takerBids | OrderStructs.Taker[] | undefined | +| makerAsks | OrderStructs.Maker[] | undefined | +| makerSignatures | bytes[] | undefined | +| merkleTrees | OrderStructs.MerkleTree[] | undefined | +| isAtomic | bool | undefined | + +### executeTakerAsk + +```solidity +function executeTakerAsk(OrderStructs.Taker takerAsk, OrderStructs.Maker makerBid, bytes makerSignature, OrderStructs.MerkleTree merkleTree) external nonpayable +``` + +#### Parameters + +| Name | Type | Description | +| -------------- | ----------------------- | ----------- | +| takerAsk | OrderStructs.Taker | undefined | +| makerBid | OrderStructs.Maker | undefined | +| makerSignature | bytes | undefined | +| merkleTree | OrderStructs.MerkleTree | undefined | + +### executeTakerBid + +```solidity +function executeTakerBid(OrderStructs.Taker takerBid, OrderStructs.Maker makerAsk, bytes makerSignature, OrderStructs.MerkleTree merkleTree) external payable +``` + +#### Parameters + +| Name | Type | Description | +| -------------- | ----------------------- | ----------- | +| takerBid | OrderStructs.Taker | undefined | +| makerAsk | OrderStructs.Maker | undefined | +| makerSignature | bytes | undefined | +| merkleTree | OrderStructs.MerkleTree | undefined | + +## Events + +### NewDomainSeparator + +```solidity +event NewDomainSeparator() +``` + +It is emitted if there is a change in the domain separator. + +### NewGasLimitETHTransfer + +```solidity +event NewGasLimitETHTransfer(uint256 gasLimitETHTransfer) +``` + +It is emitted when there is a new gas limit for a ETH transfer (before it is wrapped to WETH). + +#### Parameters + +| Name | Type | Description | +| ------------------- | ------- | ----------------------------- | +| gasLimitETHTransfer | uint256 | Gas limit for an ETH transfer | + +### TakerAsk + +```solidity +event TakerAsk(ILooksRareProtocol.NonceInvalidationParameters nonceInvalidationParameters, address askUser, address bidUser, uint256 strategyId, address currency, address collection, uint256[] itemIds, uint256[] amounts, address[2] feeRecipients, uint256[3] feeAmounts) +``` + +It is emitted when a taker ask transaction is completed. + +#### Parameters + +| Name | Type | Description | +| --------------------------- | ---------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| nonceInvalidationParameters | ILooksRareProtocol.NonceInvalidationParameters | Struct about nonce invalidation parameters | +| askUser | address | Address of the ask user | +| bidUser | address | Address of the bid user | +| strategyId | uint256 | Id of the strategy | +| currency | address | Address of the currency | +| collection | address | Address of the collection | +| itemIds | uint256[] | Array of item ids | +| amounts | uint256[] | Array of amounts (for item ids) | +| feeRecipients | address[2] | Array of fee recipients feeRecipients[0] User who receives the proceeds of the sale (it can be the taker ask user or different) feeRecipients[1] Creator fee recipient (if none, address(0)) | +| feeAmounts | uint256[3] | Array of fee amounts feeAmounts[0] Fee amount for the user receiving sale proceeds feeAmounts[1] Creator fee amount feeAmounts[2] Protocol fee amount prior to adjustment for a potential affiliate payment | + +### TakerBid + +```solidity +event TakerBid(ILooksRareProtocol.NonceInvalidationParameters nonceInvalidationParameters, address bidUser, address bidRecipient, uint256 strategyId, address currency, address collection, uint256[] itemIds, uint256[] amounts, address[2] feeRecipients, uint256[3] feeAmounts) +``` + +It is emitted when a taker bid transaction is completed. + +#### Parameters + +| Name | Type | Description | +| --------------------------- | ---------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| nonceInvalidationParameters | ILooksRareProtocol.NonceInvalidationParameters | Struct about nonce invalidation parameters | +| bidUser | address | Address of the bid user | +| bidRecipient | address | Address of the recipient of the bid | +| strategyId | uint256 | Id of the strategy | +| currency | address | Address of the currency | +| collection | address | Address of the collection | +| itemIds | uint256[] | Array of item ids | +| amounts | uint256[] | Array of amounts (for item ids) | +| feeRecipients | address[2] | Array of fee recipients feeRecipients[0] User who receives the proceeds of the sale (it is the maker ask user) feeRecipients[1] Creator fee recipient (if none, address(0)) | +| feeAmounts | uint256[3] | Array of fee amounts feeAmounts[0] Fee amount for the user receiving sale proceeds feeAmounts[1] Creator fee amount feeAmounts[2] Protocol fee amount prior to adjustment for a potential affiliate payment | + +## Errors + +### ChainIdInvalid + +```solidity +error ChainIdInvalid() +``` + +It is returned if the domain separator should change. + +### NewGasLimitETHTransferTooLow + +```solidity +error NewGasLimitETHTransferTooLow() +``` + +It is returned if the gas limit for a standard ETH transfer is too low. + +### NoncesInvalid + +```solidity +error NoncesInvalid() +``` + +It is returned if the nonces are invalid. + +### SameDomainSeparator + +```solidity +error SameDomainSeparator() +``` + +It is returned if the domain separator cannot be updated (i.e. the chainId is the same). diff --git a/docs/docs/developer/api/contracts/marketplace/interfaces/INonceManager.md b/docs/docs/developer/api/contracts/marketplace/interfaces/INonceManager.md new file mode 100644 index 00000000..eaa3f977 --- /dev/null +++ b/docs/docs/developer/api/contracts/marketplace/interfaces/INonceManager.md @@ -0,0 +1,53 @@ +# INonceManager + +_LooksRare protocol team (👀,💎)_ + +> INonceManager + +## Events + +### NewBidAskNonces + +```solidity +event NewBidAskNonces(address user, uint256 bidNonce, uint256 askNonce) +``` + +It is emitted when there is an update of the global bid/ask nonces for a user. + +#### Parameters + +| Name | Type | Description | +| -------- | ------- | ------------------- | +| user | address | Address of the user | +| bidNonce | uint256 | New bid nonce | +| askNonce | uint256 | New ask nonce | + +### OrderNoncesCancelled + +```solidity +event OrderNoncesCancelled(address user, uint256[] orderNonces) +``` + +It is emitted when order nonces are cancelled for a user. + +#### Parameters + +| Name | Type | Description | +| ----------- | --------- | ------------------------------- | +| user | address | Address of the user | +| orderNonces | uint256[] | Array of order nonces cancelled | + +### SubsetNoncesCancelled + +```solidity +event SubsetNoncesCancelled(address user, uint256[] subsetNonces) +``` + +It is emitted when subset nonces are cancelled for a user. + +#### Parameters + +| Name | Type | Description | +| ------------ | --------- | -------------------------------- | +| user | address | Address of the user | +| subsetNonces | uint256[] | Array of subset nonces cancelled | diff --git a/docs/docs/developer/api/contracts/marketplace/interfaces/IRoyaltyFeeRegistry.md b/docs/docs/developer/api/contracts/marketplace/interfaces/IRoyaltyFeeRegistry.md new file mode 100644 index 00000000..5ed0ef6c --- /dev/null +++ b/docs/docs/developer/api/contracts/marketplace/interfaces/IRoyaltyFeeRegistry.md @@ -0,0 +1,29 @@ +# IRoyaltyFeeRegistry + +_LooksRare protocol team (👀,💎)_ + +> IRoyaltyFeeRegistry + +## Methods + +### royaltyInfo + +```solidity +function royaltyInfo(address collection, uint256 price) external view returns (address receiver, uint256 royaltyFee) +``` + +This function returns the royalty information for a collection at a given transaction price. + +#### Parameters + +| Name | Type | Description | +| ---------- | ------- | ------------------ | +| collection | address | Collection address | +| price | uint256 | Transaction price | + +#### Returns + +| Name | Type | Description | +| ---------- | ------- | ------------------ | +| receiver | address | Receiver address | +| royaltyFee | uint256 | Royalty fee amount | diff --git a/docs/docs/developer/api/contracts/marketplace/interfaces/IStrategy.md b/docs/docs/developer/api/contracts/marketplace/interfaces/IStrategy.md new file mode 100644 index 00000000..2b4a45bc --- /dev/null +++ b/docs/docs/developer/api/contracts/marketplace/interfaces/IStrategy.md @@ -0,0 +1,41 @@ +# IStrategy + +_LooksRare protocol team (👀,💎)_ + +> IStrategy + +## Methods + +### isLooksRareV2Strategy + +```solidity +function isLooksRareV2Strategy() external pure returns (bool isStrategy) +``` + +This function acts as a safety check for the protocol's owner when adding new execution strategies. + +#### Returns + +| Name | Type | Description | +| ---------- | ---- | ---------------------------------------------- | +| isStrategy | bool | Whether it is a LooksRare V2 protocol strategy | + +### isMakerOrderValid + +```solidity +function isMakerOrderValid(OrderStructs.Maker makerOrder, bytes4 functionSelector) external view returns (bool isValid, bytes4 errorSelector) +``` + +#### Parameters + +| Name | Type | Description | +| ---------------- | ------------------ | ----------- | +| makerOrder | OrderStructs.Maker | undefined | +| functionSelector | bytes4 | undefined | + +#### Returns + +| Name | Type | Description | +| ------------- | ------ | ----------- | +| isValid | bool | undefined | +| errorSelector | bytes4 | undefined | diff --git a/docs/docs/developer/api/contracts/marketplace/interfaces/IStrategyManager.md b/docs/docs/developer/api/contracts/marketplace/interfaces/IStrategyManager.md new file mode 100644 index 00000000..ae6ea7b1 --- /dev/null +++ b/docs/docs/developer/api/contracts/marketplace/interfaces/IStrategyManager.md @@ -0,0 +1,84 @@ +# IStrategyManager + +_LooksRare protocol team (👀,💎)_ + +> IStrategyManager + +## Events + +### NewStrategy + +```solidity +event NewStrategy(uint256 strategyId, uint16 standardProtocolFeeBp, uint16 minTotalFeeBp, uint16 maxProtocolFeeBp, bytes4 selector, bool isMakerBid, address implementation) +``` + +It is emitted when a new strategy is added. + +#### Parameters + +| Name | Type | Description | +| --------------------- | ------- | ---------------------------------------------------- | +| strategyId | uint256 | Id of the new strategy | +| standardProtocolFeeBp | uint16 | Standard protocol fee (in basis point) | +| minTotalFeeBp | uint16 | Minimum total fee (in basis point) | +| maxProtocolFeeBp | uint16 | Maximum protocol fee (in basis point) | +| selector | bytes4 | Function selector for the transaction to be executed | +| isMakerBid | bool | Whether the strategyId is for maker bid | +| implementation | address | Address of the implementation of the strategy | + +### StrategyUpdated + +```solidity +event StrategyUpdated(uint256 strategyId, bool isActive, uint16 standardProtocolFeeBp, uint16 minTotalFeeBp) +``` + +It is emitted when an existing strategy is updated. + +#### Parameters + +| Name | Type | Description | +| --------------------- | ------- | -------------------------------------------------------- | +| strategyId | uint256 | Id of the strategy | +| isActive | bool | Whether the strategy is active (or not) after the update | +| standardProtocolFeeBp | uint16 | Standard protocol fee (in basis point) | +| minTotalFeeBp | uint16 | Minimum total fee (in basis point) | + +## Errors + +### NotV2Strategy + +```solidity +error NotV2Strategy() +``` + +If the strategy has not set properly its implementation contract. + +_It can only be returned for owner operations._ + +### StrategyHasNoSelector + +```solidity +error StrategyHasNoSelector() +``` + +It is returned if the strategy has no selector. + +_It can only be returned for owner operations._ + +### StrategyNotUsed + +```solidity +error StrategyNotUsed() +``` + +It is returned if the strategyId is invalid. + +### StrategyProtocolFeeTooHigh + +```solidity +error StrategyProtocolFeeTooHigh() +``` + +It is returned if the strategy's protocol fee is too high. + +_It can only be returned for owner operations._ diff --git a/docs/docs/developer/api/contracts/marketplace/interfaces/ITransferManager.md b/docs/docs/developer/api/contracts/marketplace/interfaces/ITransferManager.md new file mode 100644 index 00000000..3ba8ca81 --- /dev/null +++ b/docs/docs/developer/api/contracts/marketplace/interfaces/ITransferManager.md @@ -0,0 +1,111 @@ +# ITransferManager + +_LooksRare protocol team (👀,💎)_ + +> ITransferManager + +## Events + +### ApprovalsGranted + +```solidity +event ApprovalsGranted(address user, address[] operators) +``` + +It is emitted if operators' approvals to transfer NFTs are granted by a user. + +#### Parameters + +| Name | Type | Description | +| --------- | --------- | --------------------------- | +| user | address | Address of the user | +| operators | address[] | Array of operator addresses | + +### ApprovalsRemoved + +```solidity +event ApprovalsRemoved(address user, address[] operators) +``` + +It is emitted if operators' approvals to transfer NFTs are revoked by a user. + +#### Parameters + +| Name | Type | Description | +| --------- | --------- | --------------------------- | +| user | address | Address of the user | +| operators | address[] | Array of operator addresses | + +### OperatorAllowed + +```solidity +event OperatorAllowed(address operator) +``` + +It is emitted if a new operator is added to the global allowlist. + +#### Parameters + +| Name | Type | Description | +| -------- | ------- | ---------------- | +| operator | address | Operator address | + +### OperatorRemoved + +```solidity +event OperatorRemoved(address operator) +``` + +It is emitted if an operator is removed from the global allowlist. + +#### Parameters + +| Name | Type | Description | +| -------- | ------- | ---------------- | +| operator | address | Operator address | + +## Errors + +### OperatorAlreadyAllowed + +```solidity +error OperatorAlreadyAllowed() +``` + +It is returned if the transfer caller is already allowed by the owner. + +_This error can only be returned for owner operations._ + +### OperatorAlreadyApprovedByUser + +```solidity +error OperatorAlreadyApprovedByUser() +``` + +It is returned if the operator to approve has already been approved by the user. + +### OperatorNotAllowed + +```solidity +error OperatorNotAllowed() +``` + +It is returned if the operator to approve is not in the global allowlist defined by the owner. + +_This error can be returned if the user tries to grant approval to an operator address not in the allowlist or if the owner tries to remove the operator from the global allowlist._ + +### OperatorNotApprovedByUser + +```solidity +error OperatorNotApprovedByUser() +``` + +It is returned if the operator to revoke has not been previously approved by the user. + +### TransferCallerInvalid + +```solidity +error TransferCallerInvalid() +``` + +It is returned if the transfer caller is invalid. For a transfer called to be valid, the operator must be in the global allowlist and approved by the 'from' user. diff --git a/docs/docs/developer/api/contracts/marketplace/libraries/CurrencyValidator.md b/docs/docs/developer/api/contracts/marketplace/libraries/CurrencyValidator.md new file mode 100644 index 00000000..1b1f41a2 --- /dev/null +++ b/docs/docs/developer/api/contracts/marketplace/libraries/CurrencyValidator.md @@ -0,0 +1,7 @@ +# CurrencyValidator + +_LooksRare protocol team (👀,💎)_ + +> CurrencyValidator + +This library validates the order currency to be the chain's native currency or the specified ERC20 token. diff --git a/docs/docs/developer/api/contracts/marketplace/libraries/OpenZeppelin/MerkleProofCalldataWithNodes.md b/docs/docs/developer/api/contracts/marketplace/libraries/OpenZeppelin/MerkleProofCalldataWithNodes.md new file mode 100644 index 00000000..943a54cd --- /dev/null +++ b/docs/docs/developer/api/contracts/marketplace/libraries/OpenZeppelin/MerkleProofCalldataWithNodes.md @@ -0,0 +1,7 @@ +# MerkleProofCalldataWithNodes + +_OpenZeppelin (adjusted by LooksRare)_ + +> MerkleProofCalldataWithNodes + +This library is adjusted from the work of OpenZeppelin. It is based on the 4.7.0 (utils/cryptography/MerkleProof.sol). diff --git a/docs/docs/developer/api/contracts/marketplace/libraries/OpenZeppelin/MerkleProofMemory.md b/docs/docs/developer/api/contracts/marketplace/libraries/OpenZeppelin/MerkleProofMemory.md new file mode 100644 index 00000000..37529181 --- /dev/null +++ b/docs/docs/developer/api/contracts/marketplace/libraries/OpenZeppelin/MerkleProofMemory.md @@ -0,0 +1,7 @@ +# MerkleProofMemory + +_OpenZeppelin (adjusted by LooksRare)_ + +> MerkleProofMemory + +This library is adjusted from the work of OpenZeppelin. It is based on the 4.7.0 (utils/cryptography/MerkleProof.sol). diff --git a/docs/docs/developer/api/contracts/marketplace/libraries/OrderStructs.md b/docs/docs/developer/api/contracts/marketplace/libraries/OrderStructs.md new file mode 100644 index 00000000..3c166bb7 --- /dev/null +++ b/docs/docs/developer/api/contracts/marketplace/libraries/OrderStructs.md @@ -0,0 +1,7 @@ +# OrderStructs + +_LooksRare protocol team (👀,💎)_ + +> OrderStructs + +This library contains all order struct types for the LooksRare protocol (v2). diff --git a/docs/docs/developer/api/contracts/protocol/AllowlistMinter.md b/docs/docs/developer/api/contracts/protocol/AllowlistMinter.md new file mode 100644 index 00000000..4684053c --- /dev/null +++ b/docs/docs/developer/api/contracts/protocol/AllowlistMinter.md @@ -0,0 +1,84 @@ +# AllowlistMinter + +_bitbeckers_ + +> Interface for hypercert token interactions + +This interface declares the required functionality for a hypercert tokenThis interface does not specify the underlying token type (e.g. 721 or 1155) + +## Methods + +### hasBeenClaimed + +```solidity +function hasBeenClaimed(uint256, bytes32) external view returns (bool) +``` + +#### Parameters + +| Name | Type | Description | +| ---- | ------- | ----------- | +| \_0 | uint256 | undefined | +| \_1 | bytes32 | undefined | + +#### Returns + +| Name | Type | Description | +| ---- | ---- | ----------- | +| \_0 | bool | undefined | + +### isAllowedToClaim + +```solidity +function isAllowedToClaim(bytes32[] proof, uint256 claimID, bytes32 leaf) external view returns (bool isAllowed) +``` + +#### Parameters + +| Name | Type | Description | +| ------- | --------- | ----------- | +| proof | bytes32[] | undefined | +| claimID | uint256 | undefined | +| leaf | bytes32 | undefined | + +#### Returns + +| Name | Type | Description | +| --------- | ---- | ----------- | +| isAllowed | bool | undefined | + +## Events + +### AllowlistCreated + +```solidity +event AllowlistCreated(uint256 tokenID, bytes32 root) +``` + +#### Parameters + +| Name | Type | Description | +| ------- | ------- | ----------- | +| tokenID | uint256 | undefined | +| root | bytes32 | undefined | + +### LeafClaimed + +```solidity +event LeafClaimed(uint256 tokenID, bytes32 leaf) +``` + +#### Parameters + +| Name | Type | Description | +| ------- | ------- | ----------- | +| tokenID | uint256 | undefined | +| leaf | bytes32 | undefined | + +## Errors + +### DoesNotExist + +```solidity +error DoesNotExist() +``` diff --git a/docs/docs/developer/api/contracts/protocol/HypercertMinter.md b/docs/docs/developer/api/contracts/protocol/HypercertMinter.md new file mode 100644 index 00000000..518efa42 --- /dev/null +++ b/docs/docs/developer/api/contracts/protocol/HypercertMinter.md @@ -0,0 +1,895 @@ +# HypercertMinter + +_bitbeckers_ + +> Contract for managing hypercert claims and whitelists + +Implementation of the HypercertTokenInterface using { SemiFungible1155 } as underlying token.This contract supports whitelisted minting via { AllowlistMinter }. + +_Wrapper contract to expose and chain functions._ + +## Methods + +### \_\_SemiFungible1155_init + +```solidity +function __SemiFungible1155_init() external nonpayable +``` + +_see { openzeppelin-contracts-upgradeable/contracts/proxy/utils/Initializable.sol }_ + +### balanceOf + +```solidity +function balanceOf(address account, uint256 id) external view returns (uint256) +``` + +_See {IERC1155-balanceOf}. Requirements: - `account` cannot be the zero address._ + +#### Parameters + +| Name | Type | Description | +| ------- | ------- | ----------- | +| account | address | undefined | +| id | uint256 | undefined | + +#### Returns + +| Name | Type | Description | +| ---- | ------- | ----------- | +| \_0 | uint256 | undefined | + +### balanceOfBatch + +```solidity +function balanceOfBatch(address[] accounts, uint256[] ids) external view returns (uint256[]) +``` + +_See {IERC1155-balanceOfBatch}. Requirements: - `accounts` and `ids` must have the same length._ + +#### Parameters + +| Name | Type | Description | +| -------- | --------- | ----------- | +| accounts | address[] | undefined | +| ids | uint256[] | undefined | + +#### Returns + +| Name | Type | Description | +| ---- | --------- | ----------- | +| \_0 | uint256[] | undefined | + +### batchBurnFraction + +```solidity +function batchBurnFraction(address _account, uint256[] _tokenIDs) external nonpayable +``` + +Burn a claimtoken + +_see {IHypercertToken}_ + +#### Parameters + +| Name | Type | Description | +| ---------- | --------- | ----------- | +| \_account | address | undefined | +| \_tokenIDs | uint256[] | undefined | + +### batchMintClaimsFromAllowlists + +```solidity +function batchMintClaimsFromAllowlists(address account, bytes32[][] proofs, uint256[] claimIDs, uint256[] units) external nonpayable +``` + +Mint semi-fungible tokens representing a fraction of the claims in `claimIDs` + +_Calls AllowlistMinter to verify `proofs`.Mints the `amount` of units for the hypercert stored under `claimIDs`_ + +#### Parameters + +| Name | Type | Description | +| -------- | ----------- | ----------- | +| account | address | undefined | +| proofs | bytes32[][] | undefined | +| claimIDs | uint256[] | undefined | +| units | uint256[] | undefined | + +### burn + +```solidity +function burn(address account, uint256 id, uint256) external nonpayable +``` + +Burn a claimtoken; override is needed to update units/values + +_see {ERC1155Burnable}_ + +#### Parameters + +| Name | Type | Description | +| ------- | ------- | ----------- | +| account | address | undefined | +| id | uint256 | undefined | +| \_2 | uint256 | undefined | + +### burnBatch + +```solidity +function burnBatch(address account, uint256[] ids, uint256[]) external nonpayable +``` + +Batch burn claimtokens; override is needed to update units/values + +_see {ERC1155Burnable}_ + +#### Parameters + +| Name | Type | Description | +| ------- | --------- | ----------- | +| account | address | undefined | +| ids | uint256[] | undefined | +| \_2 | uint256[] | undefined | + +### burnFraction + +```solidity +function burnFraction(address _account, uint256 _tokenID) external nonpayable +``` + +Burn a claimtoken + +_see {IHypercertToken}_ + +#### Parameters + +| Name | Type | Description | +| --------- | ------- | ----------- | +| \_account | address | undefined | +| \_tokenID | uint256 | undefined | + +### createAllowlist + +```solidity +function createAllowlist(address account, uint256 units, bytes32 merkleRoot, string _uri, enum IHypercertToken.TransferRestrictions restrictions) external nonpayable +``` + +Register a claim and the whitelist for minting token(s) belonging to that claim + +_Calls SemiFungible1155 to store the claim referenced in `uri` with amount of `units`Calls AllowlistMinter to store the `merkleRoot` as proof to authorize claims_ + +#### Parameters + +| Name | Type | Description | +| ------------ | ----------------------------------------- | ----------- | +| account | address | undefined | +| units | uint256 | undefined | +| merkleRoot | bytes32 | undefined | +| \_uri | string | undefined | +| restrictions | enum IHypercertToken.TransferRestrictions | undefined | + +### hasBeenClaimed + +```solidity +function hasBeenClaimed(uint256, bytes32) external view returns (bool) +``` + +#### Parameters + +| Name | Type | Description | +| ---- | ------- | ----------- | +| \_0 | uint256 | undefined | +| \_1 | bytes32 | undefined | + +#### Returns + +| Name | Type | Description | +| ---- | ---- | ----------- | +| \_0 | bool | undefined | + +### initialize + +```solidity +function initialize() external nonpayable +``` + +_see { openzeppelin-contracts-upgradeable/contracts/proxy/utils/Initializable.sol }_ + +### isAllowedToClaim + +```solidity +function isAllowedToClaim(bytes32[] proof, uint256 claimID, bytes32 leaf) external view returns (bool isAllowed) +``` + +#### Parameters + +| Name | Type | Description | +| ------- | --------- | ----------- | +| proof | bytes32[] | undefined | +| claimID | uint256 | undefined | +| leaf | bytes32 | undefined | + +#### Returns + +| Name | Type | Description | +| --------- | ---- | ----------- | +| isAllowed | bool | undefined | + +### isApprovedForAll + +```solidity +function isApprovedForAll(address account, address operator) external view returns (bool) +``` + +_See {IERC1155-isApprovedForAll}._ + +#### Parameters + +| Name | Type | Description | +| -------- | ------- | ----------- | +| account | address | undefined | +| operator | address | undefined | + +#### Returns + +| Name | Type | Description | +| ---- | ---- | ----------- | +| \_0 | bool | undefined | + +### mergeFractions + +```solidity +function mergeFractions(address _account, uint256[] _fractionIDs) external nonpayable +``` + +Merge the value of tokens belonging to the same claim + +_see {IHypercertToken}_ + +#### Parameters + +| Name | Type | Description | +| ------------- | --------- | ----------- | +| \_account | address | undefined | +| \_fractionIDs | uint256[] | undefined | + +### mintClaim + +```solidity +function mintClaim(address account, uint256 units, string _uri, enum IHypercertToken.TransferRestrictions restrictions) external nonpayable +``` + +Mint a semi-fungible token for the impact claim referenced via `uri` + +_see {IHypercertToken}_ + +#### Parameters + +| Name | Type | Description | +| ------------ | ----------------------------------------- | ----------- | +| account | address | undefined | +| units | uint256 | undefined | +| \_uri | string | undefined | +| restrictions | enum IHypercertToken.TransferRestrictions | undefined | + +### mintClaimFromAllowlist + +```solidity +function mintClaimFromAllowlist(address account, bytes32[] proof, uint256 claimID, uint256 units) external nonpayable +``` + +Mint a semi-fungible token representing a fraction of the claim + +_Calls AllowlistMinter to verify `proof`.Mints the `amount` of units for the hypercert stored under `claimID`_ + +#### Parameters + +| Name | Type | Description | +| ------- | --------- | ----------- | +| account | address | undefined | +| proof | bytes32[] | undefined | +| claimID | uint256 | undefined | +| units | uint256 | undefined | + +### mintClaimWithFractions + +```solidity +function mintClaimWithFractions(address account, uint256 units, uint256[] fractions, string _uri, enum IHypercertToken.TransferRestrictions restrictions) external nonpayable +``` + +Mint semi-fungible tokens for the impact claim referenced via `uri` + +_see {IHypercertToken}_ + +#### Parameters + +| Name | Type | Description | +| ------------ | ----------------------------------------- | ----------- | +| account | address | undefined | +| units | uint256 | undefined | +| fractions | uint256[] | undefined | +| \_uri | string | undefined | +| restrictions | enum IHypercertToken.TransferRestrictions | undefined | + +### name + +```solidity +function name() external view returns (string) +``` + +#### Returns + +| Name | Type | Description | +| ---- | ------ | ----------- | +| \_0 | string | undefined | + +### owner + +```solidity +function owner() external view returns (address) +``` + +_Returns the address of the current owner._ + +#### Returns + +| Name | Type | Description | +| ---- | ------- | ----------- | +| \_0 | address | undefined | + +### ownerOf + +```solidity +function ownerOf(uint256 tokenID) external view returns (address _owner) +``` + +_Returns the owner of a given token ID._ + +#### Parameters + +| Name | Type | Description | +| ------- | ------- | ----------------------------- | +| tokenID | uint256 | The ID of the token to query. | + +#### Returns + +| Name | Type | Description | +| ------- | ------- | -------------------------------------- | +| \_owner | address | The address of the owner of the token. | + +### pause + +```solidity +function pause() external nonpayable +``` + +PAUSABLE + +### paused + +```solidity +function paused() external view returns (bool) +``` + +_Returns true if the contract is paused, and false otherwise._ + +#### Returns + +| Name | Type | Description | +| ---- | ---- | ----------- | +| \_0 | bool | undefined | + +### proxiableUUID + +```solidity +function proxiableUUID() external view returns (bytes32) +``` + +_Implementation of the ERC1822 {proxiableUUID} function. This returns the storage slot used by the implementation. It is used to validate the implementation's compatibility when performing an upgrade. IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this function revert if invoked through a proxy. This is guaranteed by the `notDelegated` modifier._ + +#### Returns + +| Name | Type | Description | +| ---- | ------- | ----------- | +| \_0 | bytes32 | undefined | + +### readTransferRestriction + +```solidity +function readTransferRestriction(uint256 tokenID) external view returns (string) +``` + +TRANSFER RESTRICTIONS + +#### Parameters + +| Name | Type | Description | +| ------- | ------- | ----------- | +| tokenID | uint256 | undefined | + +#### Returns + +| Name | Type | Description | +| ---- | ------ | ----------- | +| \_0 | string | undefined | + +### renounceOwnership + +```solidity +function renounceOwnership() external nonpayable +``` + +_Leaves the contract without owner. It will not be possible to call `onlyOwner` functions anymore. Can only be called by the current owner. NOTE: Renouncing ownership will leave the contract without an owner, thereby removing any functionality that is only available to the owner._ + +### safeBatchTransferFrom + +```solidity +function safeBatchTransferFrom(address from, address to, uint256[] ids, uint256[] amounts, bytes data) external nonpayable +``` + +_See {IERC1155-safeBatchTransferFrom}._ + +#### Parameters + +| Name | Type | Description | +| ------- | --------- | ----------- | +| from | address | undefined | +| to | address | undefined | +| ids | uint256[] | undefined | +| amounts | uint256[] | undefined | +| data | bytes | undefined | + +### safeTransferFrom + +```solidity +function safeTransferFrom(address from, address to, uint256 id, uint256 amount, bytes data) external nonpayable +``` + +_See {IERC1155-safeTransferFrom}._ + +#### Parameters + +| Name | Type | Description | +| ------ | ------- | ----------- | +| from | address | undefined | +| to | address | undefined | +| id | uint256 | undefined | +| amount | uint256 | undefined | +| data | bytes | undefined | + +### setApprovalForAll + +```solidity +function setApprovalForAll(address operator, bool approved) external nonpayable +``` + +_See {IERC1155-setApprovalForAll}._ + +#### Parameters + +| Name | Type | Description | +| -------- | ------- | ----------- | +| operator | address | undefined | +| approved | bool | undefined | + +### splitFraction + +```solidity +function splitFraction(address _account, uint256 _tokenID, uint256[] _newFractions) external nonpayable +``` + +Split a claimtokens value into parts with summed value equal to the original + +_see {IHypercertToken}_ + +#### Parameters + +| Name | Type | Description | +| -------------- | --------- | ----------- | +| \_account | address | undefined | +| \_tokenID | uint256 | undefined | +| \_newFractions | uint256[] | undefined | + +### supportsInterface + +```solidity +function supportsInterface(bytes4 interfaceId) external view returns (bool) +``` + +_See {IERC165-supportsInterface}._ + +#### Parameters + +| Name | Type | Description | +| ----------- | ------ | ----------- | +| interfaceId | bytes4 | undefined | + +#### Returns + +| Name | Type | Description | +| ---- | ---- | ----------- | +| \_0 | bool | undefined | + +### transferOwnership + +```solidity +function transferOwnership(address newOwner) external nonpayable +``` + +_Transfers ownership of the contract to a new account (`newOwner`). Can only be called by the current owner._ + +#### Parameters + +| Name | Type | Description | +| -------- | ------- | ----------- | +| newOwner | address | undefined | + +### unitsOf + +```solidity +function unitsOf(address account, uint256 tokenID) external view returns (uint256 units) +``` + +_see {IHypercertToken}_ + +#### Parameters + +| Name | Type | Description | +| ------- | ------- | ----------- | +| account | address | undefined | +| tokenID | uint256 | undefined | + +#### Returns + +| Name | Type | Description | +| ----- | ------- | ----------- | +| units | uint256 | undefined | + +### unitsOf + +```solidity +function unitsOf(uint256 tokenID) external view returns (uint256 units) +``` + +_see {IHypercertToken}_ + +#### Parameters + +| Name | Type | Description | +| ------- | ------- | ----------- | +| tokenID | uint256 | undefined | + +#### Returns + +| Name | Type | Description | +| ----- | ------- | ----------- | +| units | uint256 | undefined | + +### unpause + +```solidity +function unpause() external nonpayable +``` + +### upgradeTo + +```solidity +function upgradeTo(address newImplementation) external nonpayable +``` + +_Upgrade the implementation of the proxy to `newImplementation`. Calls {\_authorizeUpgrade}. Emits an {Upgraded} event._ + +#### Parameters + +| Name | Type | Description | +| ----------------- | ------- | ----------- | +| newImplementation | address | undefined | + +### upgradeToAndCall + +```solidity +function upgradeToAndCall(address newImplementation, bytes data) external payable +``` + +_Upgrade the implementation of the proxy to `newImplementation`, and subsequently execute the function call encoded in `data`. Calls {\_authorizeUpgrade}. Emits an {Upgraded} event._ + +#### Parameters + +| Name | Type | Description | +| ----------------- | ------- | ----------- | +| newImplementation | address | undefined | +| data | bytes | undefined | + +### uri + +```solidity +function uri(uint256 tokenID) external view returns (string _uri) +``` + +_see { IHypercertMetadata}_ + +#### Parameters + +| Name | Type | Description | +| ------- | ------- | ----------- | +| tokenID | uint256 | undefined | + +#### Returns + +| Name | Type | Description | +| ----- | ------ | ----------- | +| \_uri | string | undefined | + +## Events + +### AdminChanged + +```solidity +event AdminChanged(address previousAdmin, address newAdmin) +``` + +#### Parameters + +| Name | Type | Description | +| ------------- | ------- | ----------- | +| previousAdmin | address | undefined | +| newAdmin | address | undefined | + +### AllowlistCreated + +```solidity +event AllowlistCreated(uint256 tokenID, bytes32 root) +``` + +#### Parameters + +| Name | Type | Description | +| ------- | ------- | ----------- | +| tokenID | uint256 | undefined | +| root | bytes32 | undefined | + +### ApprovalForAll + +```solidity +event ApprovalForAll(address indexed account, address indexed operator, bool approved) +``` + +#### Parameters + +| Name | Type | Description | +| ------------------ | ------- | ----------- | +| account `indexed` | address | undefined | +| operator `indexed` | address | undefined | +| approved | bool | undefined | + +### BatchValueTransfer + +```solidity +event BatchValueTransfer(uint256[] claimIDs, uint256[] fromTokenIDs, uint256[] toTokenIDs, uint256[] values) +``` + +#### Parameters + +| Name | Type | Description | +| ------------ | --------- | ----------- | +| claimIDs | uint256[] | undefined | +| fromTokenIDs | uint256[] | undefined | +| toTokenIDs | uint256[] | undefined | +| values | uint256[] | undefined | + +### BeaconUpgraded + +```solidity +event BeaconUpgraded(address indexed beacon) +``` + +#### Parameters + +| Name | Type | Description | +| ---------------- | ------- | ----------- | +| beacon `indexed` | address | undefined | + +### ClaimStored + +```solidity +event ClaimStored(uint256 indexed claimID, string uri, uint256 totalUnits) +``` + +#### Parameters + +| Name | Type | Description | +| ----------------- | ------- | ----------- | +| claimID `indexed` | uint256 | undefined | +| uri | string | undefined | +| totalUnits | uint256 | undefined | + +### Initialized + +```solidity +event Initialized(uint8 version) +``` + +#### Parameters + +| Name | Type | Description | +| ------- | ----- | ----------- | +| version | uint8 | undefined | + +### LeafClaimed + +```solidity +event LeafClaimed(uint256 tokenID, bytes32 leaf) +``` + +#### Parameters + +| Name | Type | Description | +| ------- | ------- | ----------- | +| tokenID | uint256 | undefined | +| leaf | bytes32 | undefined | + +### OwnershipTransferred + +```solidity +event OwnershipTransferred(address indexed previousOwner, address indexed newOwner) +``` + +#### Parameters + +| Name | Type | Description | +| ----------------------- | ------- | ----------- | +| previousOwner `indexed` | address | undefined | +| newOwner `indexed` | address | undefined | + +### Paused + +```solidity +event Paused(address account) +``` + +#### Parameters + +| Name | Type | Description | +| ------- | ------- | ----------- | +| account | address | undefined | + +### TransferBatch + +```solidity +event TransferBatch(address indexed operator, address indexed from, address indexed to, uint256[] ids, uint256[] values) +``` + +#### Parameters + +| Name | Type | Description | +| ------------------ | --------- | ----------- | +| operator `indexed` | address | undefined | +| from `indexed` | address | undefined | +| to `indexed` | address | undefined | +| ids | uint256[] | undefined | +| values | uint256[] | undefined | + +### TransferSingle + +```solidity +event TransferSingle(address indexed operator, address indexed from, address indexed to, uint256 id, uint256 value) +``` + +#### Parameters + +| Name | Type | Description | +| ------------------ | ------- | ----------- | +| operator `indexed` | address | undefined | +| from `indexed` | address | undefined | +| to `indexed` | address | undefined | +| id | uint256 | undefined | +| value | uint256 | undefined | + +### URI + +```solidity +event URI(string value, uint256 indexed id) +``` + +#### Parameters + +| Name | Type | Description | +| ------------ | ------- | ----------- | +| value | string | undefined | +| id `indexed` | uint256 | undefined | + +### Unpaused + +```solidity +event Unpaused(address account) +``` + +#### Parameters + +| Name | Type | Description | +| ------- | ------- | ----------- | +| account | address | undefined | + +### Upgraded + +```solidity +event Upgraded(address indexed implementation) +``` + +#### Parameters + +| Name | Type | Description | +| ------------------------ | ------- | ----------- | +| implementation `indexed` | address | undefined | + +### ValueTransfer + +```solidity +event ValueTransfer(uint256 claimID, uint256 fromTokenID, uint256 toTokenID, uint256 value) +``` + +#### Parameters + +| Name | Type | Description | +| ----------- | ------- | ----------- | +| claimID | uint256 | undefined | +| fromTokenID | uint256 | undefined | +| toTokenID | uint256 | undefined | +| value | uint256 | undefined | + +## Errors + +### AlreadyClaimed + +```solidity +error AlreadyClaimed() +``` + +### ArraySize + +```solidity +error ArraySize() +``` + +### DoesNotExist + +```solidity +error DoesNotExist() +``` + +### DuplicateEntry + +```solidity +error DuplicateEntry() +``` + +### Invalid + +```solidity +error Invalid() +``` + +### NotAllowed + +```solidity +error NotAllowed() +``` + +### NotApprovedOrOwner + +```solidity +error NotApprovedOrOwner() +``` + +### TransfersNotAllowed + +```solidity +error TransfersNotAllowed() +``` + +### TypeMismatch + +```solidity +error TypeMismatch() +``` diff --git a/docs/docs/developer/api/contracts/protocol/SemiFungible1155.md b/docs/docs/developer/api/contracts/protocol/SemiFungible1155.md new file mode 100644 index 00000000..a4086e37 --- /dev/null +++ b/docs/docs/developer/api/contracts/protocol/SemiFungible1155.md @@ -0,0 +1,457 @@ +# SemiFungible1155 + +_bitbeckers_ + +> Contract for minting semi-fungible EIP1155 tokens + +Extends { Upgradeable1155 } token with semi-fungible properties and the concept of `units` + +_Adds split bit strategy as described in [EIP-1155](https://eips.ethereum.org/EIPS/eip-1155#non-fungible-tokens)_ + +## Methods + +### \_\_SemiFungible1155_init + +```solidity +function __SemiFungible1155_init() external nonpayable +``` + +_see { openzeppelin-contracts-upgradeable/contracts/proxy/utils/Initializable.sol }_ + +### balanceOf + +```solidity +function balanceOf(address account, uint256 id) external view returns (uint256) +``` + +_See {IERC1155-balanceOf}. Requirements: - `account` cannot be the zero address._ + +#### Parameters + +| Name | Type | Description | +| ------- | ------- | ----------- | +| account | address | undefined | +| id | uint256 | undefined | + +#### Returns + +| Name | Type | Description | +| ---- | ------- | ----------- | +| \_0 | uint256 | undefined | + +### balanceOfBatch + +```solidity +function balanceOfBatch(address[] accounts, uint256[] ids) external view returns (uint256[]) +``` + +_See {IERC1155-balanceOfBatch}. Requirements: - `accounts` and `ids` must have the same length._ + +#### Parameters + +| Name | Type | Description | +| -------- | --------- | ----------- | +| accounts | address[] | undefined | +| ids | uint256[] | undefined | + +#### Returns + +| Name | Type | Description | +| ---- | --------- | ----------- | +| \_0 | uint256[] | undefined | + +### burn + +```solidity +function burn(address account, uint256 id, uint256 value) external nonpayable +``` + +#### Parameters + +| Name | Type | Description | +| ------- | ------- | ----------- | +| account | address | undefined | +| id | uint256 | undefined | +| value | uint256 | undefined | + +### burnBatch + +```solidity +function burnBatch(address account, uint256[] ids, uint256[] values) external nonpayable +``` + +#### Parameters + +| Name | Type | Description | +| ------- | --------- | ----------- | +| account | address | undefined | +| ids | uint256[] | undefined | +| values | uint256[] | undefined | + +### isApprovedForAll + +```solidity +function isApprovedForAll(address account, address operator) external view returns (bool) +``` + +_See {IERC1155-isApprovedForAll}._ + +#### Parameters + +| Name | Type | Description | +| -------- | ------- | ----------- | +| account | address | undefined | +| operator | address | undefined | + +#### Returns + +| Name | Type | Description | +| ---- | ---- | ----------- | +| \_0 | bool | undefined | + +### owner + +```solidity +function owner() external view returns (address) +``` + +_Returns the address of the current owner._ + +#### Returns + +| Name | Type | Description | +| ---- | ------- | ----------- | +| \_0 | address | undefined | + +### ownerOf + +```solidity +function ownerOf(uint256 tokenID) external view returns (address _owner) +``` + +_Returns the owner of a given token ID._ + +#### Parameters + +| Name | Type | Description | +| ------- | ------- | ----------------------------- | +| tokenID | uint256 | The ID of the token to query. | + +#### Returns + +| Name | Type | Description | +| ------- | ------- | -------------------------------------- | +| \_owner | address | The address of the owner of the token. | + +### proxiableUUID + +```solidity +function proxiableUUID() external view returns (bytes32) +``` + +_Implementation of the ERC1822 {proxiableUUID} function. This returns the storage slot used by the implementation. It is used to validate the implementation's compatibility when performing an upgrade. IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this function revert if invoked through a proxy. This is guaranteed by the `notDelegated` modifier._ + +#### Returns + +| Name | Type | Description | +| ---- | ------- | ----------- | +| \_0 | bytes32 | undefined | + +### renounceOwnership + +```solidity +function renounceOwnership() external nonpayable +``` + +_Leaves the contract without owner. It will not be possible to call `onlyOwner` functions anymore. Can only be called by the current owner. NOTE: Renouncing ownership will leave the contract without an owner, thereby removing any functionality that is only available to the owner._ + +### safeBatchTransferFrom + +```solidity +function safeBatchTransferFrom(address from, address to, uint256[] ids, uint256[] amounts, bytes data) external nonpayable +``` + +_See {IERC1155-safeBatchTransferFrom}._ + +#### Parameters + +| Name | Type | Description | +| ------- | --------- | ----------- | +| from | address | undefined | +| to | address | undefined | +| ids | uint256[] | undefined | +| amounts | uint256[] | undefined | +| data | bytes | undefined | + +### safeTransferFrom + +```solidity +function safeTransferFrom(address from, address to, uint256 id, uint256 amount, bytes data) external nonpayable +``` + +_See {IERC1155-safeTransferFrom}._ + +#### Parameters + +| Name | Type | Description | +| ------ | ------- | ----------- | +| from | address | undefined | +| to | address | undefined | +| id | uint256 | undefined | +| amount | uint256 | undefined | +| data | bytes | undefined | + +### setApprovalForAll + +```solidity +function setApprovalForAll(address operator, bool approved) external nonpayable +``` + +_See {IERC1155-setApprovalForAll}._ + +#### Parameters + +| Name | Type | Description | +| -------- | ------- | ----------- | +| operator | address | undefined | +| approved | bool | undefined | + +### supportsInterface + +```solidity +function supportsInterface(bytes4 interfaceId) external view returns (bool) +``` + +_See {IERC165-supportsInterface}._ + +#### Parameters + +| Name | Type | Description | +| ----------- | ------ | ----------- | +| interfaceId | bytes4 | undefined | + +#### Returns + +| Name | Type | Description | +| ---- | ---- | ----------- | +| \_0 | bool | undefined | + +### transferOwnership + +```solidity +function transferOwnership(address newOwner) external nonpayable +``` + +_Transfers ownership of the contract to a new account (`newOwner`). Can only be called by the current owner._ + +#### Parameters + +| Name | Type | Description | +| -------- | ------- | ----------- | +| newOwner | address | undefined | + +### upgradeTo + +```solidity +function upgradeTo(address newImplementation) external nonpayable +``` + +_Upgrade the implementation of the proxy to `newImplementation`. Calls {\_authorizeUpgrade}. Emits an {Upgraded} event._ + +#### Parameters + +| Name | Type | Description | +| ----------------- | ------- | ----------- | +| newImplementation | address | undefined | + +### upgradeToAndCall + +```solidity +function upgradeToAndCall(address newImplementation, bytes data) external payable +``` + +_Upgrade the implementation of the proxy to `newImplementation`, and subsequently execute the function call encoded in `data`. Calls {\_authorizeUpgrade}. Emits an {Upgraded} event._ + +#### Parameters + +| Name | Type | Description | +| ----------------- | ------- | ----------- | +| newImplementation | address | undefined | +| data | bytes | undefined | + +### uri + +```solidity +function uri(uint256 tokenID) external view returns (string _uri) +``` + +_Returns the metadata URI for a given token ID.This function retrieves the metadata URI for the specified token ID by calling the `uri` function of the `ERC1155URIStorageUpgradeable` contract.The metadata URI is a string that points to a JSON file containing information about the token, such as its name, symbol, and image.This function always returns the URI for the basetype so that it's managed in one place._ + +#### Parameters + +| Name | Type | Description | +| ------- | ------- | ----------------------------------------------------- | +| tokenID | uint256 | The ID of the token to retrieve the metadata URI for. | + +#### Returns + +| Name | Type | Description | +| ----- | ------ | -------------------------------------------- | +| \_uri | string | The metadata URI for the specified token ID. | + +## Events + +### AdminChanged + +```solidity +event AdminChanged(address previousAdmin, address newAdmin) +``` + +#### Parameters + +| Name | Type | Description | +| ------------- | ------- | ----------- | +| previousAdmin | address | undefined | +| newAdmin | address | undefined | + +### ApprovalForAll + +```solidity +event ApprovalForAll(address indexed account, address indexed operator, bool approved) +``` + +#### Parameters + +| Name | Type | Description | +| ------------------ | ------- | ----------- | +| account `indexed` | address | undefined | +| operator `indexed` | address | undefined | +| approved | bool | undefined | + +### BatchValueTransfer + +```solidity +event BatchValueTransfer(uint256[] claimIDs, uint256[] fromTokenIDs, uint256[] toTokenIDs, uint256[] values) +``` + +_Emitted on transfer of `values` between `fromTokenIDs` to `toTokenIDs` of `claimIDs`_ + +#### Parameters + +| Name | Type | Description | +| ------------ | --------- | ----------- | +| claimIDs | uint256[] | undefined | +| fromTokenIDs | uint256[] | undefined | +| toTokenIDs | uint256[] | undefined | +| values | uint256[] | undefined | + +### BeaconUpgraded + +```solidity +event BeaconUpgraded(address indexed beacon) +``` + +#### Parameters + +| Name | Type | Description | +| ---------------- | ------- | ----------- | +| beacon `indexed` | address | undefined | + +### Initialized + +```solidity +event Initialized(uint8 version) +``` + +#### Parameters + +| Name | Type | Description | +| ------- | ----- | ----------- | +| version | uint8 | undefined | + +### OwnershipTransferred + +```solidity +event OwnershipTransferred(address indexed previousOwner, address indexed newOwner) +``` + +#### Parameters + +| Name | Type | Description | +| ----------------------- | ------- | ----------- | +| previousOwner `indexed` | address | undefined | +| newOwner `indexed` | address | undefined | + +### TransferBatch + +```solidity +event TransferBatch(address indexed operator, address indexed from, address indexed to, uint256[] ids, uint256[] values) +``` + +#### Parameters + +| Name | Type | Description | +| ------------------ | --------- | ----------- | +| operator `indexed` | address | undefined | +| from `indexed` | address | undefined | +| to `indexed` | address | undefined | +| ids | uint256[] | undefined | +| values | uint256[] | undefined | + +### TransferSingle + +```solidity +event TransferSingle(address indexed operator, address indexed from, address indexed to, uint256 id, uint256 value) +``` + +#### Parameters + +| Name | Type | Description | +| ------------------ | ------- | ----------- | +| operator `indexed` | address | undefined | +| from `indexed` | address | undefined | +| to `indexed` | address | undefined | +| id | uint256 | undefined | +| value | uint256 | undefined | + +### URI + +```solidity +event URI(string value, uint256 indexed id) +``` + +#### Parameters + +| Name | Type | Description | +| ------------ | ------- | ----------- | +| value | string | undefined | +| id `indexed` | uint256 | undefined | + +### Upgraded + +```solidity +event Upgraded(address indexed implementation) +``` + +#### Parameters + +| Name | Type | Description | +| ------------------------ | ------- | ----------- | +| implementation `indexed` | address | undefined | + +### ValueTransfer + +```solidity +event ValueTransfer(uint256 claimID, uint256 fromTokenID, uint256 toTokenID, uint256 value) +``` + +_Emitted on transfer of `value` between `fromTokenID` to `toTokenID` of the same `claimID`_ + +#### Parameters + +| Name | Type | Description | +| ----------- | ------- | ----------- | +| claimID | uint256 | undefined | +| fromTokenID | uint256 | undefined | +| toTokenID | uint256 | undefined | +| value | uint256 | undefined | diff --git a/docs/docs/developer/api/contracts/protocol/interfaces/IAllowlist.md b/docs/docs/developer/api/contracts/protocol/interfaces/IAllowlist.md new file mode 100644 index 00000000..72455b43 --- /dev/null +++ b/docs/docs/developer/api/contracts/protocol/interfaces/IAllowlist.md @@ -0,0 +1,29 @@ +# IAllowlist + +_bitbeckers_ + +> Interface for allowlist + +This interface declares the required functionality for a hypercert tokenThis interface does not specify the underlying token type (e.g. 721 or 1155) + +## Methods + +### isAllowedToClaim + +```solidity +function isAllowedToClaim(bytes32[] proof, uint256 tokenID, bytes32 leaf) external view returns (bool isAllowed) +``` + +#### Parameters + +| Name | Type | Description | +| ------- | --------- | ----------- | +| proof | bytes32[] | undefined | +| tokenID | uint256 | undefined | +| leaf | bytes32 | undefined | + +#### Returns + +| Name | Type | Description | +| --------- | ---- | ----------- | +| isAllowed | bool | undefined | diff --git a/docs/docs/developer/api/contracts/protocol/interfaces/IHypercertToken.md b/docs/docs/developer/api/contracts/protocol/interfaces/IHypercertToken.md new file mode 100644 index 00000000..6bd5a931 --- /dev/null +++ b/docs/docs/developer/api/contracts/protocol/interfaces/IHypercertToken.md @@ -0,0 +1,175 @@ +# IHypercertToken + +_bitbeckers_ + +> Interface for hypercert token interactions + +This interface declares the required functionality for a hypercert tokenThis interface does not specify the underlying token type (e.g. 721 or 1155) + +## Methods + +### burnFraction + +```solidity +function burnFraction(address account, uint256 tokenID) external nonpayable +``` + +Operator must be allowed by `creator` and the token must represent the total amount of available units. + +_Function to burn the token at `tokenID` for `account`_ + +#### Parameters + +| Name | Type | Description | +| ------- | ------- | ----------- | +| account | address | undefined | +| tokenID | uint256 | undefined | + +### mergeFractions + +```solidity +function mergeFractions(address account, uint256[] tokenIDs) external nonpayable +``` + +Tokens that have been merged are burned. + +_Function called to merge tokens within `tokenIDs`._ + +#### Parameters + +| Name | Type | Description | +| -------- | --------- | ----------- | +| account | address | undefined | +| tokenIDs | uint256[] | undefined | + +### mintClaim + +```solidity +function mintClaim(address account, uint256 units, string uri, enum IHypercertToken.TransferRestrictions restrictions) external nonpayable +``` + +_Function called to store a claim referenced via `uri` with a maximum number of fractions `units`._ + +#### Parameters + +| Name | Type | Description | +| ------------ | ----------------------------------------- | ----------- | +| account | address | undefined | +| units | uint256 | undefined | +| uri | string | undefined | +| restrictions | enum IHypercertToken.TransferRestrictions | undefined | + +### mintClaimWithFractions + +```solidity +function mintClaimWithFractions(address account, uint256 units, uint256[] fractions, string uri, enum IHypercertToken.TransferRestrictions restrictions) external nonpayable +``` + +_Function called to store a claim referenced via `uri` with a set of `fractions`.Fractions are internally summed to total units._ + +#### Parameters + +| Name | Type | Description | +| ------------ | ----------------------------------------- | ----------- | +| account | address | undefined | +| units | uint256 | undefined | +| fractions | uint256[] | undefined | +| uri | string | undefined | +| restrictions | enum IHypercertToken.TransferRestrictions | undefined | + +### splitFraction + +```solidity +function splitFraction(address account, uint256 tokenID, uint256[] _values) external nonpayable +``` + +The sum of `values` must equal the current value of `_tokenID`. + +_Function called to split `tokenID` owned by `account` into units declared in `values`._ + +#### Parameters + +| Name | Type | Description | +| -------- | --------- | ----------- | +| account | address | undefined | +| tokenID | uint256 | undefined | +| \_values | uint256[] | undefined | + +### unitsOf + +```solidity +function unitsOf(address account, uint256 tokenID) external view returns (uint256 units) +``` + +_Returns the `units` held by `account` of a (fractional) token at `claimID`If `tokenID` is a base type, the total amount of `units` held by `account` for the claim is returned.If `tokenID` is a fractional token, the `units` held by `account` the token is returned_ + +#### Parameters + +| Name | Type | Description | +| ------- | ------- | ----------- | +| account | address | undefined | +| tokenID | uint256 | undefined | + +#### Returns + +| Name | Type | Description | +| ----- | ------- | ----------- | +| units | uint256 | undefined | + +### unitsOf + +```solidity +function unitsOf(uint256 tokenID) external view returns (uint256 units) +``` + +_Returns the `units` held by a (fractional) token at `claimID`If `tokenID` is a base type, the total amount of `units` for the claim is returned.If `tokenID` is a fractional token, the `units` held by the token is returned_ + +#### Parameters + +| Name | Type | Description | +| ------- | ------- | ----------- | +| tokenID | uint256 | undefined | + +#### Returns + +| Name | Type | Description | +| ----- | ------- | ----------- | +| units | uint256 | undefined | + +### uri + +```solidity +function uri(uint256 tokenID) external view returns (string metadata) +``` + +_Returns the `uri` for metadata of the claim represented by `tokenID`Metadata must conform to { Hypercert Metadata } spec (based on ERC1155 Metadata)_ + +#### Parameters + +| Name | Type | Description | +| ------- | ------- | ----------- | +| tokenID | uint256 | undefined | + +#### Returns + +| Name | Type | Description | +| -------- | ------ | ----------- | +| metadata | string | undefined | + +## Events + +### ClaimStored + +```solidity +event ClaimStored(uint256 indexed claimID, string uri, uint256 totalUnits) +``` + +_Emitted when token with tokenID `claimID` is stored, with external data reference via `uri`._ + +#### Parameters + +| Name | Type | Description | +| ----------------- | ------- | ----------- | +| claimID `indexed` | uint256 | undefined | +| uri | string | undefined | +| totalUnits | uint256 | undefined | diff --git a/docs/docs/developer/api/contracts/protocol/libs/Errors.md b/docs/docs/developer/api/contracts/protocol/libs/Errors.md new file mode 100644 index 00000000..93fe0124 --- /dev/null +++ b/docs/docs/developer/api/contracts/protocol/libs/Errors.md @@ -0,0 +1,59 @@ +# Errors + +_bitbeckers_ + +## Errors + +### AlreadyClaimed + +```solidity +error AlreadyClaimed() +``` + +### ArraySize + +```solidity +error ArraySize() +``` + +### DoesNotExist + +```solidity +error DoesNotExist() +``` + +### DuplicateEntry + +```solidity +error DuplicateEntry() +``` + +### Invalid + +```solidity +error Invalid() +``` + +### NotAllowed + +```solidity +error NotAllowed() +``` + +### NotApprovedOrOwner + +```solidity +error NotApprovedOrOwner() +``` + +### TransfersNotAllowed + +```solidity +error TransfersNotAllowed() +``` + +### TypeMismatch + +```solidity +error TypeMismatch() +``` diff --git a/docs/package.json b/docs/package.json index 7225bde0..674a836e 100644 --- a/docs/package.json +++ b/docs/package.json @@ -30,6 +30,7 @@ "react-dom": "^18.2.0" }, "devDependencies": { + "@docusaurus/eslint-plugin": "^2.4.1", "@docusaurus/module-type-aliases": "^2.4.1", "@tsconfig/docusaurus": "^1.0.6", "typescript": "^4.9.4" diff --git a/frontend/.eslintrc.json b/frontend/.eslintrc.json index d99797cb..fdcf77c2 100644 --- a/frontend/.eslintrc.json +++ b/frontend/.eslintrc.json @@ -16,11 +16,6 @@ "prettier", "next" ], - "ignorePatterns": [ - "**/graph/generated/*", - "**/vendor/*.js", - "vendor/**/*.js" - ], "parser": "@typescript-eslint/parser", "parserOptions": { "ecmaFeatures": { diff --git a/frontend/components/blueprint-create.tsx b/frontend/components/blueprint-create.tsx deleted file mode 100644 index 876b6a6c..00000000 --- a/frontend/components/blueprint-create.tsx +++ /dev/null @@ -1,487 +0,0 @@ -import { useAccountLowerCase } from "../hooks/account"; -import { useMintBlueprintToRegistry } from "../hooks/createBlueprintInRegistry"; -import { useListRegistries } from "../hooks/list-registries"; -import { parseListFromString } from "../lib/parsing"; -import { useConfetti } from "./confetti"; -import { useContractModal } from "./contract-interaction-dialog-context"; -import { DATE_INDEFINITE, DateIndefinite, FormContext } from "./forms"; -import { formatHypercertData } from "@hypercerts-org/sdk"; -import { DataProvider } from "@plasmicapp/loader-nextjs"; -import dayjs from "dayjs"; -import { Formik, FormikProps } from "formik"; -import html2canvas from "html2canvas"; -import _ from "lodash"; -import { useRouter } from "next/router"; -import qs from "qs"; -import React, { ReactNode } from "react"; -import { toast } from "react-toastify"; -import * as Yup from "yup"; - -/** - * Constants - */ -const FORM_SELECTOR = "currentForm"; -const IMAGE_SELECTOR = "hypercertimage"; -export const NAME_MIN_LENGTH = 2; -export const NAME_MAX_LENGTH = 50; - -export const DESCRIPTION_MIN_LENGTH = 20; -export const DESCRIPTION_MAX_LENGTH = 1500; - -export const DEFAULT_NUM_FRACTIONS = 10000; -export const DEFAULT_HYPERCERT_VERSION = "0.0.1"; - -//const DEFAULT_TIME = dayjs().format("YYYY-MM-DD"); -const DEFAULT_TIME = dayjs(); -const DEFAULT_FORM_DATA: BlueprintCreateFormData = { - registryId: "", - minterAddress: "", - name: "", - description: "", - externalLink: "", - logoUrl: "", - //logoImage: null, - bannerUrl: "", - //bannerImage: null, - impactScopes: ["all"] as string[], - //impactTimeStart: DEFAULT_TIME.format("YYYY-MM-DD"), - impactTimeEnd: DEFAULT_TIME.format("YYYY-MM-DD"), - workScopes: "", - workTimeStart: DEFAULT_TIME.format("YYYY-MM-DD"), - workTimeEnd: DEFAULT_TIME.format("YYYY-MM-DD"), - rights: ["Public Display"] as string[], - contributors: "", - agreeContributorsConsent: false, - agreeTermsConditions: false, - // Hidden - backgroundColor: "", - backgroundVectorArt: "", - metadataProperties: "", -}; - -interface BlueprintCreateFormData { - registryId: string; - minterAddress: string; - name: string; - description: string; - externalLink: string; - logoUrl: string; - //logoImage: File | null; - bannerUrl: string; - //bannerImage: File | null; - impactScopes: string[]; - //impactTimeStart?: string; - impactTimeEnd?: string | DateIndefinite; - workScopes: string; - workTimeStart?: string; - workTimeEnd?: string; - rights: string[]; - contributors: string; - agreeContributorsConsent: boolean; - agreeTermsConditions: boolean; - // Hidden - backgroundColor: string; - backgroundVectorArt: string; - metadataProperties: string; -} - -/** - * Generic utility function to check for valid URLs - * - We should probably move this to common.ts or util.ts - * @param value - * @param opts - * @returns - */ -const isValidUrl = ( - value: any, - opts: { - emptyAllowed?: boolean; - ipfsAllowed?: boolean; - }, -) => { - // Check empty, null, or undefined - if (opts.emptyAllowed && !value) { - return true; - } else if (!value) { - return false; - } - - // Check IPFS - const isIpfsUrl = value.match(/^(ipfs):\/\//); - if (opts.ipfsAllowed && isIpfsUrl) { - return true; - } - - try { - const urlSchema = Yup.string().url(); - urlSchema.validateSync(value); - return true; - } catch (e) { - return false; - } -}; - -/** - * Converts raw form data to a query string - * @param values - * @returns - */ -const formDataToQueryString = (values: Record) => { - // We will serialize our Dayjs objects - const formatDate = (key: string) => { - if (values[key] === DATE_INDEFINITE) { - values[key] = DATE_INDEFINITE; - } else if (values[key] && values[key].format) { - values[key] = values[key].format("YYYY-MM-DD"); - } - }; - ["impactTimeStart", "impactTimeEnd", "workTimeStart", "workTimeEnd"].forEach( - formatDate, - ); - const filteredValues = _.chain(values).pickBy().value(); - return qs.stringify(filteredValues); -}; - -/** - * Converts a query string into raw form data - * @param query - * @returns - */ -const queryStringToFormData = (query?: string) => { - const rawValues = qs.parse(query ?? ""); - const parseValue = (v: any) => { - return v === DATE_INDEFINITE ? DATE_INDEFINITE : dayjs(v as string); - }; - const values = { - ...rawValues, - // we need to parse dates to match the expected types - //impactTimeStart: parseValue(rawValues["impactTimeStart"]), - impactTimeEnd: parseValue(rawValues["impactTimeEnd"]), - workTimeStart: parseValue(rawValues["workTimeStart"]), - workTimeEnd: parseValue(rawValues["workTimeEnd"]), - }; - return values as any; -}; - -/** - * Form validation rules - */ -const ValidationSchema = Yup.object().shape({ - registryId: Yup.string().required("Required"), - minterAddress: Yup.string().required("Required"), - name: Yup.string() - .min(NAME_MIN_LENGTH, `Name must be at least ${NAME_MIN_LENGTH} characters`) - .max(NAME_MAX_LENGTH, `Name must be at most ${NAME_MAX_LENGTH} characters`) - .required("Required"), - description: Yup.string() - .min( - DESCRIPTION_MIN_LENGTH, - `Description must be at least ${DESCRIPTION_MIN_LENGTH} characters`, - ) - .max( - DESCRIPTION_MAX_LENGTH, - `Description must be at most ${DESCRIPTION_MAX_LENGTH} characters`, - ) - .required("Required"), - externalLink: Yup.string().test( - "valid uri", - "Please enter a valid URL", - (value) => - isValidUrl(value, { - emptyAllowed: true, - ipfsAllowed: true, - }), - ), - logoUrl: Yup.string().test("valid uri", "Please enter a valid URL", (value) => - isValidUrl(value, { - emptyAllowed: true, - ipfsAllowed: false, - }), - ), - bannerUrl: Yup.string().test( - "valid uri", - "Please enter a valid URL", - (value) => - isValidUrl(value, { - emptyAllowed: true, - ipfsAllowed: false, - }), - ), - impactScopes: Yup.array().min(1, "Please choose at least 1 item"), - impactTimeEnd: Yup.lazy((val: any) => { - switch (typeof val) { - case "string": - return Yup.string(); - default: - return Yup.date().when("workTimeStart", (workTimeStart) => { - return Yup.date().min( - workTimeStart, - "End date must be after start date", - ); - }); - } - }), - workScopes: Yup.string() - .required("Required") - .min( - NAME_MIN_LENGTH, - `Work scopes must be at least ${NAME_MIN_LENGTH} characters`, - ) - .test("no duplicates", "Please remove duplicate items", (value) => { - if (!value) { - return true; - } - const items = parseListFromString(value, { lowercase: "all" }); - const dedup = parseListFromString(value, { - lowercase: "all", - deduplicate: true, - }); - return _.isEqual(items, dedup); - }), - workTimeEnd: Yup.date().when("workTimeStart", (workTimeStart) => { - return Yup.date().min(workTimeStart, "End date must be after start date"); - }), - rights: Yup.array().min(1), - contributors: Yup.string() - .required("Required") - .test("no duplicates", "Please remove duplicate items", (value) => { - if (!value) { - return true; - } - const items = parseListFromString(value, { lowercase: "all" }); - const dedup = parseListFromString(value, { - lowercase: "all", - deduplicate: true, - }); - return _.isEqual(items, dedup); - }), - agreeContributorsConsent: Yup.boolean().oneOf( - [true], - "You must get the consent of contributors before creating", - ), - agreeTermsConditions: Yup.boolean().oneOf( - [true], - "You must agree to the terms and conditions", - ), -}); - -/** - * Hypercert creation form logic using Formik - * - For the actual layout of form elements, - * we assume it's passed in via the `children` prop. - * - Use the form elements defined in `./forms.tsx` - * - Make sure that there is a form element with a `fieldName` - * for each field in HypercertCreateFormData - */ -export interface HypercertCreateFormProps { - className?: string; // Plasmic CSS class - children?: ReactNode; // Form elements -} - -export function BlueprintCreateForm(props: HypercertCreateFormProps) { - const { data: registries = [] } = useListRegistries(); - const registryOptions = registries.map((r: any) => `${r.name} - ${r.id}`); - const { className, children } = props; - const { address } = useAccountLowerCase(); - const { push } = useRouter(); - const { hideModal } = useContractModal(); - const confetti = useConfetti(); - - // Query string - const [initialQuery, setInitialQuery] = React.useState( - undefined, - ); - // Load the querystring into React state only once on initial page load - React.useEffect(() => { - if (!initialQuery) { - window.location.hash.startsWith("#") - ? setInitialQuery(window.location.hash.slice(1)) - : setInitialQuery(window.location.hash); - } - }, [initialQuery]); - - const onComplete = async () => { - hideModal(); - confetti && - (await confetti.addConfetti({ - emojis: ["🌈", "⚡️", "💥", "✨", "💫", "🌸"], - })); - push("/app/dashboard"); - }; - - const { mutate: createBlueprint, isLoading: createBlueprintPending } = - useMintBlueprintToRegistry({ - onComplete, - }); - - return ( -
- { - // console.log(values); - if (typeof initialQuery !== "undefined") { - // The useEffect has run already, so it's safe to just update the query string directly - //const querystring = formDataToQueryString(values); - //const path = `${window.location.pathname}#${querystring}`; - //window.history.pushState(null, "", path); - } - }} - initialValues={{ - ...DEFAULT_FORM_DATA, - ...queryStringToFormData(initialQuery), - }} - enableReinitialize - onSubmit={async (values, { setSubmitting }) => { - const image = await exportAsImage(IMAGE_SELECTOR); - const metaData = formatValuesToMetaData( - values, - // eslint-disable-next-line @typescript-eslint/no-non-null-assertion - address!, - image, - ); - console.log(`Metadata(valid=${metaData.valid}): `, metaData.data); - if (metaData.data) { - const registryId = values.registryId.split(" - ")[1]; - //return; // Used for testing - - if (!registryId) { - toast("Error creating blueprint. Please contact the team.", { - type: "error", - }); - console.error("Registry ID not found"); - return; - } - createBlueprint({ - registryId, - value: formDataToQueryString(values), - minterAddress: values.minterAddress, - }); - } else { - toast("Error creating hypercert. Please contact the team.", { - type: "error", - }); - console.error("SDK formatting errors: ", metaData.errors); - } - - if (!createBlueprintPending) { - setSubmitting(false); - } - }} - > - {(formikProps: FormikProps) => ( - - -
{ - e.preventDefault(); - console.log("Submitting form..."); - console.log("Form values: ", formikProps.values); - console.log("Form errors: ", formikProps.errors); - formikProps.handleSubmit(); - }} - > - {children} -
-
-
- )} -
-
- ); -} - -const formatValuesToMetaData = ( - val: BlueprintCreateFormData, - address: string, - image?: string, -) => { - // Split contributor names and addresses. - // - make sure addresses are always lower case - const contributorNamesAndAddresses = parseListFromString(val.contributors, { - lowercase: "addresses", - }); - // Split the work scopes - const workScopes = parseListFromString(val.workScopes); - - // Mint certificate using contract - // NOTE: we set the times to be UNIX time (seconds since the epoch) - // but Date.getTime() returns milliseconds since the epoch - // NOTE: we are fixing the impactTimeStart to be the same as workTimeStart - const impactTimeframeStart = val.workTimeStart - ? new Date(val.workTimeStart).getTime() / 1000 - : 0; - /** - const impactTimeframeStart = val.impactTimeStart - ? new Date(val.impactTimeStart).getTime() / 1000 - : 0; - */ - const impactTimeframeEnd = - val.impactTimeEnd !== "indefinite" && val.impactTimeEnd !== undefined - ? new Date(val.impactTimeEnd).getTime() / 1000 - : 0; - const workTimeframeStart = val.workTimeStart - ? new Date(val.workTimeStart).getTime() / 1000 - : 0; - const workTimeframeEnd = val.workTimeEnd - ? new Date(val.workTimeEnd).getTime() / 1000 - : 0; - - let properties = []; - if (val.metadataProperties) { - try { - properties = JSON.parse(val.metadataProperties); - } catch (e) { - console.warn( - `Unable to parse metadataProperties: ${val.metadataProperties}`, - ); - } - } - - return formatHypercertData({ - name: val.name, - description: val.description, - external_url: val.externalLink, - image: image ?? "", - contributors: contributorNamesAndAddresses, - workTimeframeStart, - workTimeframeEnd, - impactTimeframeStart, - impactTimeframeEnd, - workScope: workScopes, - impactScope: val.impactScopes, - rights: val.rights, - version: DEFAULT_HYPERCERT_VERSION, - properties: properties, - excludedImpactScope: [], - excludedRights: [], - excludedWorkScope: [], - }); -}; - -const exportAsImage = async (id: string) => { - const el = document.getElementById(id); - if (!el) { - return; - } - const canvas = await html2canvas(el, { - logging: true, - backgroundColor: null, - //useCORS: true, - proxy: "https://cors-proxy.hypercerts.workers.dev/", - imageTimeout: 0, - }); - const image = canvas.toDataURL("image/png", 1.0); - return image; -}; diff --git a/frontend/components/config.tsx b/frontend/components/config.tsx index 5cad0317..dc799b63 100644 --- a/frontend/components/config.tsx +++ b/frontend/components/config.tsx @@ -7,8 +7,8 @@ const PLASMIC_DATA_KEY = "Config"; interface ConfigData { domain: string; - chainId: number; - graphUrl: string; + chainId?: number; + graphUrl?: string; supabaseTable: string; } @@ -20,10 +20,17 @@ export interface ConfigProps { export function Config(props: ConfigProps) { const { className, children } = props; const { client: hypercertClient } = useHypercertClient(); + const chainId = hypercertClient.config.chain?.id + ? Number(hypercertClient.config.chain.id) + : undefined; + + console.log(chainId); + console.log("Config: ", hypercertClient.config); + const data: ConfigData = { domain: DOMAIN, - chainId: hypercertClient._config.chainId, - graphUrl: hypercertClient._config.graphUrl, + chainId: chainId, + graphUrl: hypercertClient?.config.graphUrl, supabaseTable: SUPABASE_TABLE, }; return ( diff --git a/frontend/components/contribution-blueprint-create.tsx b/frontend/components/contribution-blueprint-create.tsx deleted file mode 100644 index 8ca28c1a..00000000 --- a/frontend/components/contribution-blueprint-create.tsx +++ /dev/null @@ -1,28 +0,0 @@ -import { useListRegistries } from "../hooks/list-registries"; -import { Button, Divider } from "@mui/material"; -import { useState } from "react"; -import { AddRegistryDialog } from "./add-registry-dialog"; - -export const ContributionBlueprintCreate = () => { - const { data } = useListRegistries(); - const [showAddRegistryDialog, setShowAddRegistryDialog] = useState(false); - return ( -
- - {data?.map((registry: any) => ( -
-

{registry.name}

-

{registry.description}

-

{registry.owner_address}

- -
- ))} - setShowAddRegistryDialog(false)} - /> -
- ); -}; diff --git a/frontend/components/dapp-state.tsx b/frontend/components/dapp-state.tsx index 56e1947e..6b4e661a 100644 --- a/frontend/components/dapp-state.tsx +++ b/frontend/components/dapp-state.tsx @@ -1,6 +1,5 @@ import { useAccountLowerCase } from "../hooks/account"; import useCheckWriteable from "../hooks/checkWriteable"; -import { DEFAULT_CHAIN_ID } from "../lib/config"; import { claimedRecently } from "./claim-all-fractions-button"; import { PlasmicCanvasContext } from "@plasmicapp/loader-nextjs"; import { DataProvider } from "@plasmicapp/loader-nextjs"; @@ -15,7 +14,6 @@ const ALL_CHAINS = [optimism, goerli, hardhat, sepolia]; export interface DappStateData { myAddress?: string; - defaultChainId?: number; chain?: Chain; chains?: Chain[]; waitToClaim?: boolean; @@ -25,7 +23,6 @@ export interface DappStateData { //TODO revert to testnet data. Needed to override for local dev of WC-wagmi-safe integration export const DEFAULT_TEST_DATA: DappStateData = { myAddress: "0x22E4b9b003Cc7B7149CF2135dfCe2BaddC7a534f".toLowerCase(), - defaultChainId: 10, chain: optimism, chains: ALL_CHAINS, waitToClaim: false, @@ -63,7 +60,6 @@ export function DappState(props: DappStateProps) { myAddress: address, chain, chains, - defaultChainId: DEFAULT_CHAIN_ID, waitToClaim, writeable, }; diff --git a/frontend/components/hypercert-fetcher.tsx b/frontend/components/hypercert-fetcher.tsx index fd3076b5..db0c5f3f 100644 --- a/frontend/components/hypercert-fetcher.tsx +++ b/frontend/components/hypercert-fetcher.tsx @@ -79,7 +79,7 @@ export function HypercertFetcher(props: HypercertFetcherProps) { }, [useQueryString, byClaimId, byMetadataUri]); // Show when loading - if (!ignoreLoading && !!loading && !data) { + if (!client && !ignoreLoading && !!loading && !data) { return
{loading}
; } diff --git a/frontend/hooks/burnFraction.ts b/frontend/hooks/burnFraction.ts index 2c28bf11..3bff9e33 100644 --- a/frontend/hooks/burnFraction.ts +++ b/frontend/hooks/burnFraction.ts @@ -13,6 +13,7 @@ export const useBurnFraction = ({ const [txPending, setTxPending] = useState(false); const { client, isLoading } = useHypercertClient(); + const publicClient = client.config.publicClient; const stepDescriptions = { preparing: "Preparing to burn fraction", @@ -31,19 +32,22 @@ export const useBurnFraction = ({ setStep("burning"); - const tx = await client.burnClaimFraction(claimId); + const hash = await client.burnClaimFraction(claimId); - setStep("waiting"); + const receipt = await publicClient?.waitForTransactionReceipt({ + confirmations: 3, + hash: hash, + }); - const receipt = await tx.wait(5); + setStep("waiting"); - if (receipt.status === 0) { + if (receipt?.status === "reverted") { toast("Burning failed", { type: "error", }); console.error(receipt); } - if (receipt.status === 1) { + if (receipt?.status === "success") { toast(burnInteractionLabels.toastSuccess(receipt.transactionHash), { type: "success", }); diff --git a/frontend/hooks/hypercerts-client.ts b/frontend/hooks/hypercerts-client.ts index f616ab5c..e26c39ae 100644 --- a/frontend/hooks/hypercerts-client.ts +++ b/frontend/hooks/hypercerts-client.ts @@ -1,82 +1,44 @@ -import React, { useEffect, useMemo } from "react"; +import React, { useEffect } from "react"; import { - DEFAULT_CHAIN_ID, NFT_STORAGE_TOKEN, WEB3_STORAGE_TOKEN, - OVERRIDE_CHAIN_NAME, - OVERRIDE_GRAPH_URL, - CONTRACT_ADDRESS, - UNSAFE_FORCE_OVERRIDE_CONFIG, + NEXT_PUBLIC_DEFAULT_CHAIN_ID, } from "../lib/config"; import { HypercertClient, HypercertClientConfig } from "@hypercerts-org/sdk"; -import { providers } from "ethers"; -import { type WalletClient, useWalletClient, useNetwork } from "wagmi"; +import { useWalletClient, useNetwork } from "wagmi"; const clientConfig: Partial = { - chainId: DEFAULT_CHAIN_ID, + chain: { id: Number(NEXT_PUBLIC_DEFAULT_CHAIN_ID) }, nftStorageToken: NFT_STORAGE_TOKEN, web3StorageToken: WEB3_STORAGE_TOKEN, }; -function loadOverridingConfig(clientConfig: Partial) { - if (OVERRIDE_CHAIN_NAME) { - clientConfig.chainName = OVERRIDE_CHAIN_NAME; - } - - if (OVERRIDE_GRAPH_URL) { - clientConfig.graphUrl = OVERRIDE_GRAPH_URL; - } - - if (CONTRACT_ADDRESS) { - clientConfig.contractAddress = CONTRACT_ADDRESS; - } - - if (UNSAFE_FORCE_OVERRIDE_CONFIG) { - clientConfig.unsafeForceOverrideConfig = UNSAFE_FORCE_OVERRIDE_CONFIG; - } -} -loadOverridingConfig(clientConfig); - const defaultClient = new HypercertClient(clientConfig); -const walletClientToSigner = (walletClient: WalletClient) => { - const { account, chain, transport } = walletClient; - const network = { - chainId: chain.id, - name: chain.name, - ensAddress: chain.contracts?.ensRegistry?.address, - }; - const provider = new providers.Web3Provider(transport, network); - const signer = provider.getSigner(account.address); - return signer; -}; - -const useEthersSigner = ({ chainId }: { chainId?: number } = {}) => { - const { data: walletClient } = useWalletClient({ chainId }); - return useMemo( - () => (walletClient ? walletClientToSigner(walletClient) : undefined), - [walletClient], - ); -}; - export const useHypercertClient = () => { const { chain } = useNetwork(); - const signer = useEthersSigner({ chainId: chain?.id }); const [client, setClient] = React.useState(defaultClient); const [isLoading, setIsLoading] = React.useState(false); + const { + data: walletClient, + isError, + isLoading: walletClientLoading, + } = useWalletClient(); + useEffect(() => { - if (chain?.id && signer) { + if (chain?.id && !walletClientLoading && !isError && walletClient) { setIsLoading(true); - const config = { - chainId: chain.id, - operator: signer, - }; - loadOverridingConfig(config); try { + const config: Partial = { + ...clientConfig, + chain: { id: chain.id }, + walletClient, + }; + const client = new HypercertClient(config); setClient(client); } catch (e) { @@ -85,7 +47,7 @@ export const useHypercertClient = () => { } setIsLoading(false); - }, [chain?.id, signer]); + }, [chain?.id, walletClient, walletClientLoading]); return { client, isLoading }; }; diff --git a/frontend/hooks/mergeFractionUnits.ts b/frontend/hooks/mergeFractionUnits.ts index 2ebf4b8a..e984961f 100644 --- a/frontend/hooks/mergeFractionUnits.ts +++ b/frontend/hooks/mergeFractionUnits.ts @@ -13,6 +13,7 @@ export const useMergeFractionUnits = ({ const [txPending, setTxPending] = useState(false); const { client, isLoading } = useHypercertClient(); + const publicClient = client.config.publicClient; const stepDescriptions = { preparing: "Preparing to merge fraction values", @@ -29,17 +30,21 @@ export const useMergeFractionUnits = ({ try { setTxPending(true); - const tx = await client.mergeClaimUnits(ids); + const hash = await client.mergeFractionUnits(ids); + + const receipt = await publicClient?.waitForTransactionReceipt({ + confirmations: 3, + hash: hash, + }); setStep("waiting"); - const receipt = await tx.wait(5); - if (receipt.status === 0) { + if (receipt?.status === "reverted") { toast("Merging failed", { type: "error", }); console.error(receipt); } - if (receipt.status === 1) { + if (receipt?.status === "success") { toast(mintInteractionLabels.toastSuccess, { type: "success" }); setStep("complete"); diff --git a/frontend/hooks/mintClaim.ts b/frontend/hooks/mintClaim.ts index 4b152f5d..55abc6a1 100644 --- a/frontend/hooks/mintClaim.ts +++ b/frontend/hooks/mintClaim.ts @@ -10,6 +10,7 @@ export const useMintClaim = ({ onComplete }: { onComplete?: () => void }) => { const [txPending, setTxPending] = useState(false); const { client, isLoading } = useHypercertClient(); + const publicClient = client.config.publicClient; const stepDescriptions = { preparing: "Preparing to mint hypercert", @@ -29,21 +30,26 @@ export const useMintClaim = ({ onComplete }: { onComplete?: () => void }) => { try { setTxPending(true); - const tx = await client.mintClaim( + const hash = await client.mintClaim( metaData, - units, + BigInt(units), TransferRestrictions.FromCreatorOnly, ); + + const receipt = await publicClient?.waitForTransactionReceipt({ + confirmations: 3, + hash: hash, + }); + setStep("waiting"); - const receipt = await tx.wait(5); - if (receipt.status === 0) { + if (receipt?.status === "reverted") { toast("Minting failed", { type: "error", }); console.error(receipt); } - if (receipt.status === 1) { + if (receipt?.status === "success") { toast(mintInteractionLabels.toastSuccess, { type: "success" }); setStep("complete"); diff --git a/frontend/hooks/mintClaimAllowlist.ts b/frontend/hooks/mintClaimAllowlist.ts index 45debc0b..18273244 100644 --- a/frontend/hooks/mintClaimAllowlist.ts +++ b/frontend/hooks/mintClaimAllowlist.ts @@ -23,6 +23,7 @@ export const useMintClaimAllowlist = ({ const [txPending, setTxPending] = useState(false); const { client, isLoading } = useHypercertClient(); + const publicClient = client.config.publicClient; const stepDescriptions = { validateAllowlist: "Validating allowlist", @@ -121,22 +122,27 @@ export const useMintClaimAllowlist = ({ setStep("preparing"); setTxPending(true); - const tx = await client.createAllowlist( + const hash = await client.createAllowlist( _allowlist, metaData, _totalSupply, TransferRestrictions.FromCreatorOnly, ); + + const receipt = await publicClient?.waitForTransactionReceipt({ + confirmations: 3, + hash: hash, + }); + setStep("writing"); - const receipt = await tx.wait(5); - if (receipt.status === 0) { + if (receipt?.status === "reverted") { toast("Minting failed", { type: "error", }); console.error(receipt); } - if (receipt.status === 1) { + if (receipt?.status === "success") { toast(mintInteractionLabels.toastSuccess, { type: "success" }); setStep("complete"); diff --git a/frontend/hooks/mintFractionAllowlist.ts b/frontend/hooks/mintFractionAllowlist.ts index 09cd0ff5..822cba42 100644 --- a/frontend/hooks/mintFractionAllowlist.ts +++ b/frontend/hooks/mintFractionAllowlist.ts @@ -15,6 +15,8 @@ export const useMintFractionAllowlist = ({ const [txPending, setTxPending] = useState(false); const { client, isLoading } = useHypercertClient(); + const publicClient = client.config.publicClient; + const { setStep, showModal, hideModal } = useContractModal(); const stepDescriptions = { @@ -29,27 +31,32 @@ export const useMintFractionAllowlist = ({ const initializeWrite = async ( claimID: bigint, units: bigint, - proof: string[], + proof: `0x${string}`[], ) => { setStep("minting"); try { setTxPending(true); - const tx = await client.mintClaimFractionFromAllowlist( + const hash = await client.mintClaimFractionFromAllowlist( claimID, units, proof, ); + + const receipt = await publicClient?.waitForTransactionReceipt({ + confirmations: 3, + hash: hash, + }); + setStep("waiting"); - const receipt = await tx.wait(5); - if (receipt.status === 0) { + if (receipt?.status === "reverted") { toast("Minting failed", { type: "error", }); console.error(receipt); } - if (receipt.status === 1) { + if (receipt?.status === "success") { toast(mintInteractionLabels.toastSuccess, { type: "success" }); setStep("complete"); @@ -67,7 +74,7 @@ export const useMintFractionAllowlist = ({ }; return { - write: async (proof: string[], claimId: bigint, units: bigint) => { + write: async (proof: `0x${string}`[], claimId: bigint, units: bigint) => { showModal({ stepDescriptions }); setStep("initial"); await initializeWrite(claimId, units, proof); diff --git a/frontend/hooks/mintFractionAllowlistBatch.ts b/frontend/hooks/mintFractionAllowlistBatch.ts index e1c65c71..97c5b6f3 100644 --- a/frontend/hooks/mintFractionAllowlistBatch.ts +++ b/frontend/hooks/mintFractionAllowlistBatch.ts @@ -27,6 +27,8 @@ export const useMintFractionAllowlistBatch = ({ const { data: claimIds } = useGetAllEligibility(address ?? "", chain?.id); const parseError = useParseBlockchainError(); + const publicClient = client.config.publicClient; + const stepDescriptions = { initial: "Initializing interaction", proofs: "Getting and verifying proofs", @@ -56,7 +58,9 @@ export const useMintFractionAllowlistBatch = ({ const verified: ClaimProof[] = results.flat().filter((x) => x); const unique = _.uniqWith(verified, _.isEqual); - const claimIDs = unique.map((claimProof) => claimProof.claimIDContract); + const claimIDs = unique.map((claimProof) => + BigInt(claimProof.claimIDContract), + ); const units = unique.map((claimProof) => BigInt(claimProof.units)); const proofs = unique.map((claimProof) => claimProof.proof as HexString[]); @@ -69,21 +73,25 @@ export const useMintFractionAllowlistBatch = ({ try { setTxPending(true); - const tx = await client.batchMintClaimFractionsFromAllowlists( + const hash = await client.batchMintClaimFractionsFromAllowlists( claimIDs, units, proofs, ); + + const receipt = await publicClient?.waitForTransactionReceipt({ + confirmations: 3, + hash: hash, + }); setStep("waiting"); - const receipt = await tx.wait(5); - if (receipt.status === 0) { + if (receipt?.status === "reverted") { toast("Minting failed", { type: "error", }); console.error(receipt); } - if (receipt.status === 1) { + if (receipt?.status === "success") { toast(mintInteractionLabels.toastSuccess, { type: "success" }); setStep("complete"); diff --git a/frontend/hooks/splitClaimUnits.ts b/frontend/hooks/splitClaimUnits.ts index 47cd4859..640ad196 100644 --- a/frontend/hooks/splitClaimUnits.ts +++ b/frontend/hooks/splitClaimUnits.ts @@ -24,22 +24,29 @@ export const useSplitFractionUnits = ({ const { setStep, showModal, hideModal } = useContractModal(); const parseError = useParseBlockchainError(); + const publicClient = client.config.publicClient; + const initializeWrite = async (id: bigint, fractions: bigint[]) => { setStep("splitting"); try { setTxPending(true); - const tx = await client.splitClaimUnits(id, fractions); + const hash = await client.splitFractionUnits(id, fractions); + + const receipt = await publicClient?.waitForTransactionReceipt({ + confirmations: 3, + hash: hash, + }); + setStep("waiting"); - const receipt = await tx.wait(5); - if (receipt.status === 0) { + if (receipt?.status === "reverted") { toast("Splitting failed", { type: "error", }); console.error(receipt); } - if (receipt.status === 1) { + if (receipt?.status === "success") { toast(mintInteractionLabels.toastSuccess, { type: "success" }); setStep("complete"); diff --git a/frontend/lib/config.ts b/frontend/lib/config.ts index a30134c6..6ebe8eed 100644 --- a/frontend/lib/config.ts +++ b/frontend/lib/config.ts @@ -12,15 +12,11 @@ export const DOMAIN = requireEnv( export const isProduction = DOMAIN === "hypercerts.org"; -export const DEFAULT_CHAIN_ID = parseInt( - requireEnv( - process.env.NEXT_PUBLIC_DEFAULT_CHAIN_ID, - "NEXT_PUBLIC_DEFAULT_CHAIN_ID", - ), +export const NEXT_PUBLIC_DEFAULT_CHAIN_ID = requireEnv( + process.env.NEXT_PUBLIC_DEFAULT_CHAIN_ID, + "NEXT_PUBLIC_DEFAULT_CHAIN_ID", ); -export const CONTRACT_ADDRESS = process.env.NEXT_PUBLIC_CONTRACT_ADDRESS; - export const NFT_STORAGE_TOKEN = requireEnv( process.env.NEXT_PUBLIC_NFT_STORAGE_TOKEN, "NEXT_PUBLIC_NFT_STORAGE_TOKEN", @@ -53,7 +49,3 @@ export const SUPABASE_TABLE = requireEnv( export const UNSAFE_FORCE_OVERRIDE_CONFIG = process.env.NEXT_PUBLIC_UNSAFE_FORCE_OVERRIDE_CONFIG == "1"; - -export const OVERRIDE_CHAIN_NAME = process.env.NEXT_PUBLIC_CHAIN_NAME; - -export const OVERRIDE_GRAPH_URL = process.env.NEXT_PUBLIC_GRAPH_URL; diff --git a/frontend/lib/hypercert.test.ts b/frontend/lib/hypercert.test.ts index 7920637b..a2d4c549 100644 --- a/frontend/lib/hypercert.test.ts +++ b/frontend/lib/hypercert.test.ts @@ -23,7 +23,7 @@ function genClaimTokens( id: id, tokenID: tokenID, owner: owner, - chainName: options?.chainName ?? "test", + graphName: options?.chainName ?? "test", units: options?.units ?? "100", }); } @@ -37,7 +37,7 @@ function genClaim(totalUnits: string): Claim { contract: randomAddress(), tokenID: randomTokenID(), totalUnits: totalUnits, - chainName: "test", + graphName: "test", }; } diff --git a/frontend/lib/parse-blockchain-error.ts b/frontend/lib/parse-blockchain-error.ts index 1f28a411..8c169066 100644 --- a/frontend/lib/parse-blockchain-error.ts +++ b/frontend/lib/parse-blockchain-error.ts @@ -1,19 +1,20 @@ import { errorMessages } from "../content/readable-errors"; -import { useHypercertClient } from "../hooks/hypercerts-client"; +import { decodeErrorResult } from "viem"; +import { HypercertMinterAbi } from "@hypercerts-org/contracts"; export const useParseBlockchainError = () => { - const { - client: { contract }, - } = useHypercertClient(); return (e: any, fallbackMessage: string) => { const unparsedErrorData = e?.error?.data?.originalError?.data; if (unparsedErrorData) { - const errorData = contract?.interface?.parseError(unparsedErrorData); + const errorData = decodeErrorResult({ + abi: HypercertMinterAbi, + data: unparsedErrorData, + }); if (errorData) { console.log("Blockchain error", errorData); - const errorName = errorData.errorFragment.name; + const errorName = errorData.errorName; return errorMessages[errorName] || errorName; } } diff --git a/frontend/lib/parsing.test.ts b/frontend/lib/parsing.test.ts index 2b14fe6f..f98ec4d1 100644 --- a/frontend/lib/parsing.test.ts +++ b/frontend/lib/parsing.test.ts @@ -11,9 +11,9 @@ describe("allowlist", () => { true, ); expect(resultDeduped).toEqual([ - { address: "0x20326e144532f17f76aca759e61e19af20a58ef3", units: 100 }, - { address: "0x15c7281842a45465b4cbb8f89111d99e36e5bab8", units: 50 }, - { address: "0x1cca19b823afa773b09708d94d2ee6ff96c60057", units: 40 }, + { address: "0x20326e144532f17f76aca759e61e19af20a58ef3", units: 100n }, + { address: "0x15c7281842a45465b4cbb8f89111d99e36e5bab8", units: 50n }, + { address: "0x1cca19b823afa773b09708d94d2ee6ff96c60057", units: 40n }, ]); const resultNotDeduped = parseAllowlistCsv( @@ -25,9 +25,9 @@ describe("allowlist", () => { false, ); expect(resultNotDeduped).toEqual([ - { address: "0x20326e144532f17f76aca759e61e19af20a58ef3", units: 100 }, - { address: "0x15c7281842a45465b4cbb8f89111d99e36e5bab8", units: 50 }, - { address: "0x1cca19b823afa773b09708d94d2ee6ff96c60057", units: 40 }, + { address: "0x20326e144532f17f76aca759e61e19af20a58ef3", units: 100n }, + { address: "0x15c7281842a45465b4cbb8f89111d99e36e5bab8", units: 50n }, + { address: "0x1cca19b823afa773b09708d94d2ee6ff96c60057", units: 40n }, ]); }); @@ -43,9 +43,9 @@ describe("allowlist", () => { true, ); expect(result).toEqual([ - { address: "0x20326e144532f17f76aca759e61e19af20a58ef3", units: 200 }, - { address: "0x15c7281842a45465b4cbb8f89111d99e36e5bab8", units: 50 }, - { address: "0x1cca19b823afa773b09708d94d2ee6ff96c60057", units: 80 }, + { address: "0x20326e144532f17f76aca759e61e19af20a58ef3", units: 200n }, + { address: "0x15c7281842a45465b4cbb8f89111d99e36e5bab8", units: 50n }, + { address: "0x1cca19b823afa773b09708d94d2ee6ff96c60057", units: 80n }, ]); }); @@ -61,11 +61,11 @@ describe("allowlist", () => { false, ); expect(result).toEqual([ - { address: "0x20326e144532f17f76aca759e61e19af20a58ef3", units: 100 }, - { address: "0x15c7281842a45465b4cbb8f89111d99e36e5bab8", units: 50 }, - { address: "0x1cca19b823afa773b09708d94d2ee6ff96c60057", units: 40 }, - { address: "0x20326e144532f17f76aca759e61e19af20a58ef3", units: 100 }, - { address: "0x1cca19b823afa773b09708d94d2ee6ff96c60057", units: 40 }, + { address: "0x20326e144532f17f76aca759e61e19af20a58ef3", units: 100n }, + { address: "0x15c7281842a45465b4cbb8f89111d99e36e5bab8", units: 50n }, + { address: "0x1cca19b823afa773b09708d94d2ee6ff96c60057", units: 40n }, + { address: "0x20326e144532f17f76aca759e61e19af20a58ef3", units: 100n }, + { address: "0x1cca19b823afa773b09708d94d2ee6ff96c60057", units: 40n }, ]); }); @@ -85,10 +85,10 @@ describe("allowlist", () => { ], ); expect(result).toEqual([ - { address: "0x20326e144532f17f76aca759e61e19af20a58ef3", units: 100 }, - { address: "0x15c7281842a45465b4cbb8f89111d99e36e5bab8", units: 50 }, - { address: "0x1cca19b823afa773b09708d94d2ee6ff96c60057", units: 40 }, - { address: "0x22e4b9b003cc7b7149cf2135dfce2baddc7a534f", units: 570 }, + { address: "0x20326e144532f17f76aca759e61e19af20a58ef3", units: 100n }, + { address: "0x15c7281842a45465b4cbb8f89111d99e36e5bab8", units: 50n }, + { address: "0x1cca19b823afa773b09708d94d2ee6ff96c60057", units: 40n }, + { address: "0x22e4b9b003cc7b7149cf2135dfce2baddc7a534f", units: 570n }, ]); }); @@ -112,10 +112,10 @@ describe("allowlist", () => { ], ); expect(result).toEqual([ - { address: "0x20326e144532f17f76aca759e61e19af20a58ef3", units: 290 }, - { address: "0x15c7281842a45465b4cbb8f89111d99e36e5bab8", units: 50 }, - { address: "0x1cca19b823afa773b09708d94d2ee6ff96c60057", units: 40 }, - { address: "0x22e4b9b003cc7b7149cf2135dfce2baddc7a534f", units: 380 }, + { address: "0x20326e144532f17f76aca759e61e19af20a58ef3", units: 290n }, + { address: "0x15c7281842a45465b4cbb8f89111d99e36e5bab8", units: 50n }, + { address: "0x1cca19b823afa773b09708d94d2ee6ff96c60057", units: 40n }, + { address: "0x22e4b9b003cc7b7149cf2135dfce2baddc7a534f", units: 380n }, ]); }); diff --git a/frontend/lib/parsing.ts b/frontend/lib/parsing.ts index e7444a9c..8315f860 100644 --- a/frontend/lib/parsing.ts +++ b/frontend/lib/parsing.ts @@ -27,12 +27,17 @@ export function parseAllowlistCsv( console.error("Errors parsing allowlist:", errors); throw new InvalidDataError("Errors parsing allowlist"); } + + console.log(rawData); // Get the addresses and units from the CSV const csvData = rawData.map((row: any) => ({ address: row["address"].trim().toLowerCase(), - units: parseInt(row["fractions"].trim(), 10), + units: BigInt(row["fractions"].trim()), })); - const csvTotalSupply = csvData.reduce((accum, curr) => accum + curr.units, 0); + const csvTotalSupply = csvData.reduce( + (accum, curr) => accum + curr.units, + 0n, + ); if (csvTotalSupply <= 0) { throw new InvalidDataError("Did not find any valid rows"); } @@ -52,12 +57,23 @@ export function parseAllowlistCsv( } } // Combine CSV data with manually added addresses + // 0.75 const csvTotalPercentage = 1.0 - addTotalPercentage; - const totalSupply = csvTotalSupply / csvTotalPercentage; + + // 75 + const csvTotalPercentageBigInt = BigInt(Math.floor(csvTotalPercentage * 100)); // convert percentage to BigInt + const addTotalPercentageBigInt = BigInt(Math.floor(addTotalPercentage * 100)); // convert percentage to BigInt + const creatorSupply = + (((csvTotalSupply * 100n) / csvTotalPercentageBigInt) * + addTotalPercentageBigInt) / + 100n; + const totalSupply = csvTotalSupply + creatorSupply; // calculate total supply + + // TODO risk over overflow on units - casting bigint to number const data = csvData.concat( add.map((x) => ({ address: x.address.trim().toLowerCase(), - units: Math.floor(totalSupply * x.percentage), + units: (totalSupply * BigInt(Math.floor(x.percentage * 100))) / 100n, })), ); @@ -69,7 +85,7 @@ export function parseAllowlistCsv( // Deduplicate const groups = _.groupBy(data, (x) => x.address); const addressToUnits = _.mapValues(groups, (x) => - x.reduce((accum, curr) => accum + curr.units, 0), + x.reduce((accum, curr) => accum + curr.units, 0n), ); const result = _.toPairs(addressToUnits).map(([address, units]) => ({ diff --git a/frontend/next.config.mjs b/frontend/next.config.mjs index beb093bd..c8d52715 100644 --- a/frontend/next.config.mjs +++ b/frontend/next.config.mjs @@ -15,6 +15,7 @@ const nextConfig = { config.resolve.fallback = { fs: false, net: false, tls: false }; return config; }, + transpilePackages: ["@hypercerts-org/sdk"], }; export default withSentryConfig( diff --git a/frontend/package.json b/frontend/package.json index c9d96480..7c9186ee 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -23,9 +23,9 @@ "@emotion/react": "^11.10.5", "@emotion/styled": "^11.10.5", "@graphprotocol/client-cli": "^2.2.16", - "@hypercerts-org/contracts": "0.8.11", + "@hypercerts-org/contracts": "0.9.0", "@hypercerts-org/observabletreemap": "workspace: *", - "@hypercerts-org/sdk": "0.8.16", + "@hypercerts-org/sdk": "1.0.0-alpha.6", "@mui/icons-material": "^5.11.9", "@mui/material": "^5.11.2", "@mui/x-date-pickers": "^5.0.12", @@ -34,7 +34,7 @@ "@openzeppelin/merkle-tree": "^1.0.2", "@plasmicapp/host": "^1.0.171", "@plasmicapp/loader-nextjs": "^1.0.284", - "@rainbow-me/rainbowkit": "1.0.8", + "@rainbow-me/rainbowkit": "1.2.0", "@sentry/nextjs": "^7.73.0", "@sentry/utils": "^7.73.0", "@supabase/supabase-js": "^2.1.2", @@ -66,8 +66,8 @@ "react-toastify": "^9.1.1", "react-use": "^17.4.0", "serve": "^14.0.1", - "viem": "1.5.3", - "wagmi": "1.3.9", + "viem": "1.18.4", + "wagmi": "1.4.5", "yup": "^0.32.11" }, "devDependencies": { diff --git a/frontend/plasmic-init.ts b/frontend/plasmic-init.ts index c722eca3..42c167c4 100644 --- a/frontend/plasmic-init.ts +++ b/frontend/plasmic-init.ts @@ -1,9 +1,7 @@ -import { BlueprintCreateForm } from "./components/blueprint-create"; import { BurnFractionButton } from "./components/burn-fraction-button"; import ClaimAllFractionsButton from "./components/claim-all-fractions-button"; import { ClientGrid } from "./components/client-grid"; import { Config } from "./components/config"; -import { ContributionBlueprintCreate } from "./components/contribution-blueprint-create"; import { DEFAULT_TEST_DATA } from "./components/dapp-state"; import { FormField, @@ -240,29 +238,6 @@ PLASMIC.registerComponent(HypercertCreateForm, { importPath: "./components/hypercert-create", }); -PLASMIC.registerComponent(BlueprintCreateForm, { - name: "BlueprintCreateForm", - description: "Create a blueprint", - props: { - children: { - type: "slot", - defaultValue: { - type: "text", - value: "Placeholder", - }, - }, - }, - providesData: true, - importPath: "./components/blueprint-create", -}); - -PLASMIC.registerComponent(ContributionBlueprintCreate, { - name: "ContributionBlueprintCreate", - description: "Create a contribution blueprint", - importPath: "./components/contribution-blueprint-create", - props: {}, -}); - PLASMIC.registerComponent(FormError, { name: "FormError", description: "Displays the error associated with fieldName", diff --git a/graph/.eslintrc.yml b/graph/.eslintrc.yml new file mode 100644 index 00000000..2c49e547 --- /dev/null +++ b/graph/.eslintrc.yml @@ -0,0 +1,11 @@ +root: false +ignorePatterns: ["tests/", "generated/"] +parser: "@typescript-eslint/parser" +plugins: + - "@typescript-eslint" +extends: + - "eslint:recommended" + - "plugin:@typescript-eslint/recommended" +rules: + "@typescript-eslint/ban-types": + - "warn" diff --git a/graph/abis/HypercertMinter.json b/graph/abis/HypercertMinter.json index a0bb3aee..feb7ccb2 100644 --- a/graph/abis/HypercertMinter.json +++ b/graph/abis/HypercertMinter.json @@ -1,1065 +1,1130 @@ [ - { - "inputs": [], - "stateMutability": "nonpayable", - "type": "constructor" - }, - { - "inputs": [], - "name": "ArraySize", - "type": "error" - }, - { - "inputs": [], - "name": "DoesNotExist", - "type": "error" - }, - { - "inputs": [], - "name": "DuplicateEntry", - "type": "error" - }, - { - "inputs": [], - "name": "FractionalBurn", - "type": "error" - }, - { - "inputs": [], - "name": "Invalid", - "type": "error" - }, - { - "inputs": [], - "name": "NotAllowed", - "type": "error" - }, - { - "inputs": [], - "name": "TransfersNotAllowed", - "type": "error" - }, - { - "inputs": [], - "name": "TypeMismatch", - "type": "error" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "address", - "name": "previousAdmin", - "type": "address" - }, - { - "indexed": false, - "internalType": "address", - "name": "newAdmin", - "type": "address" - } - ], - "name": "AdminChanged", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "uint256", - "name": "tokenID", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "bytes32", - "name": "root", - "type": "bytes32" - } - ], - "name": "AllowlistCreated", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "account", - "type": "address" - }, - { - "indexed": true, - "internalType": "address", - "name": "operator", - "type": "address" - }, - { - "indexed": false, - "internalType": "bool", - "name": "approved", - "type": "bool" - } - ], - "name": "ApprovalForAll", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "uint256[]", - "name": "claimIDs", - "type": "uint256[]" - }, - { - "indexed": false, - "internalType": "uint256[]", - "name": "fromTokenIDs", - "type": "uint256[]" - }, - { - "indexed": false, - "internalType": "uint256[]", - "name": "toTokenIDs", - "type": "uint256[]" - }, - { - "indexed": false, - "internalType": "uint256[]", - "name": "values", - "type": "uint256[]" - } - ], - "name": "BatchValueTransfer", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "beacon", - "type": "address" - } - ], - "name": "BeaconUpgraded", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "uint256", - "name": "claimID", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "string", - "name": "uri", - "type": "string" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "totalUnits", - "type": "uint256" - } - ], - "name": "ClaimStored", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "uint8", - "name": "version", - "type": "uint8" - } - ], - "name": "Initialized", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "uint256", - "name": "tokenID", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "bytes32", - "name": "leaf", - "type": "bytes32" - } - ], - "name": "LeafClaimed", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "previousOwner", - "type": "address" - }, - { - "indexed": true, - "internalType": "address", - "name": "newOwner", - "type": "address" - } - ], - "name": "OwnershipTransferred", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "address", - "name": "account", - "type": "address" - } - ], - "name": "Paused", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "operator", - "type": "address" - }, - { - "indexed": true, - "internalType": "address", - "name": "from", - "type": "address" - }, - { - "indexed": true, - "internalType": "address", - "name": "to", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256[]", - "name": "ids", - "type": "uint256[]" - }, - { - "indexed": false, - "internalType": "uint256[]", - "name": "values", - "type": "uint256[]" - } - ], - "name": "TransferBatch", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "operator", - "type": "address" - }, - { - "indexed": true, - "internalType": "address", - "name": "from", - "type": "address" - }, - { - "indexed": true, - "internalType": "address", - "name": "to", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "id", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "value", - "type": "uint256" - } - ], - "name": "TransferSingle", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "string", - "name": "value", - "type": "string" - }, - { - "indexed": true, - "internalType": "uint256", - "name": "id", - "type": "uint256" - } - ], - "name": "URI", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "address", - "name": "account", - "type": "address" - } - ], - "name": "Unpaused", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "implementation", - "type": "address" - } - ], - "name": "Upgraded", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "uint256", - "name": "claimID", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "fromTokenID", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "toTokenID", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "value", - "type": "uint256" - } - ], - "name": "ValueTransfer", - "type": "event" - }, - { - "inputs": [], - "name": "__SemiFungible1155_init", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [], - "name": "__Upgradeable1155_init", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "account", - "type": "address" - }, - { - "internalType": "uint256", - "name": "id", - "type": "uint256" - } - ], - "name": "balanceOf", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address[]", - "name": "accounts", - "type": "address[]" - }, - { - "internalType": "uint256[]", - "name": "ids", - "type": "uint256[]" - } - ], - "name": "balanceOfBatch", - "outputs": [ - { - "internalType": "uint256[]", - "name": "", - "type": "uint256[]" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "bytes32[][]", - "name": "proofs", - "type": "bytes32[][]" - }, - { - "internalType": "uint256[]", - "name": "claimIDs", - "type": "uint256[]" - }, - { - "internalType": "uint256[]", - "name": "units", - "type": "uint256[]" - } - ], - "name": "batchMintClaimsFromAllowlists", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "account", - "type": "address" - }, - { - "internalType": "uint256", - "name": "id", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "value", - "type": "uint256" - } - ], - "name": "burn", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "account", - "type": "address" - }, - { - "internalType": "uint256[]", - "name": "ids", - "type": "uint256[]" - }, - { - "internalType": "uint256[]", - "name": "values", - "type": "uint256[]" - } - ], - "name": "burnBatch", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "_account", - "type": "address" - }, - { - "internalType": "uint256", - "name": "_tokenID", - "type": "uint256" - } - ], - "name": "burnValue", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "units", - "type": "uint256" - }, - { - "internalType": "bytes32", - "name": "merkleRoot", - "type": "bytes32" - }, - { - "internalType": "string", - "name": "_uri", - "type": "string" - }, - { - "internalType": "enum IHypercertToken.TransferRestrictions", - "name": "restrictions", - "type": "uint8" - } - ], - "name": "createAllowlist", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - }, - { - "internalType": "bytes32", - "name": "", - "type": "bytes32" - } - ], - "name": "hasBeenClaimed", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "initialize", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "bytes32[]", - "name": "proof", - "type": "bytes32[]" - }, - { - "internalType": "uint256", - "name": "claimID", - "type": "uint256" - }, - { - "internalType": "bytes32", - "name": "leaf", - "type": "bytes32" - } - ], - "name": "isAllowedToClaim", - "outputs": [ - { - "internalType": "bool", - "name": "isAllowed", - "type": "bool" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "account", - "type": "address" - }, - { - "internalType": "address", - "name": "operator", - "type": "address" - } - ], - "name": "isApprovedForAll", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256[]", - "name": "_fractionIDs", - "type": "uint256[]" - } - ], - "name": "mergeValue", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "units", - "type": "uint256" - }, - { - "internalType": "string", - "name": "_uri", - "type": "string" - }, - { - "internalType": "enum IHypercertToken.TransferRestrictions", - "name": "restrictions", - "type": "uint8" - } - ], - "name": "mintClaim", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "bytes32[]", - "name": "proof", - "type": "bytes32[]" - }, - { - "internalType": "uint256", - "name": "claimID", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "units", - "type": "uint256" - } - ], - "name": "mintClaimFromAllowlist", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "units", - "type": "uint256" - }, - { - "internalType": "uint256[]", - "name": "fractions", - "type": "uint256[]" - }, - { - "internalType": "string", - "name": "_uri", - "type": "string" - }, - { - "internalType": "enum IHypercertToken.TransferRestrictions", - "name": "restrictions", - "type": "uint8" - } - ], - "name": "mintClaimWithFractions", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [], - "name": "name", - "outputs": [ - { - "internalType": "string", - "name": "", - "type": "string" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "owner", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "tokenID", - "type": "uint256" - } - ], - "name": "ownerOf", - "outputs": [ - { - "internalType": "address", - "name": "_owner", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "pause", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [], - "name": "paused", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "proxiableUUID", - "outputs": [ - { - "internalType": "bytes32", - "name": "", - "type": "bytes32" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "renounceOwnership", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "from", - "type": "address" - }, - { - "internalType": "address", - "name": "to", - "type": "address" - }, - { - "internalType": "uint256[]", - "name": "ids", - "type": "uint256[]" - }, - { - "internalType": "uint256[]", - "name": "amounts", - "type": "uint256[]" - }, - { - "internalType": "bytes", - "name": "data", - "type": "bytes" - } - ], - "name": "safeBatchTransferFrom", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "from", - "type": "address" - }, - { - "internalType": "address", - "name": "to", - "type": "address" - }, - { - "internalType": "uint256", - "name": "id", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "amount", - "type": "uint256" - }, - { - "internalType": "bytes", - "name": "data", - "type": "bytes" - } - ], - "name": "safeTransferFrom", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "operator", - "type": "address" - }, - { - "internalType": "bool", - "name": "approved", - "type": "bool" - } - ], - "name": "setApprovalForAll", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "_account", - "type": "address" - }, - { - "internalType": "uint256", - "name": "_tokenID", - "type": "uint256" - }, - { - "internalType": "uint256[]", - "name": "_values", - "type": "uint256[]" - } - ], - "name": "splitValue", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "bytes4", - "name": "interfaceId", - "type": "bytes4" - } - ], - "name": "supportsInterface", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "newOwner", - "type": "address" - } - ], - "name": "transferOwnership", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "account", - "type": "address" - }, - { - "internalType": "uint256", - "name": "tokenID", - "type": "uint256" - } - ], - "name": "unitsOf", - "outputs": [ - { - "internalType": "uint256", - "name": "units", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "tokenID", - "type": "uint256" - } - ], - "name": "unitsOf", - "outputs": [ - { - "internalType": "uint256", - "name": "units", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "unpause", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "newImplementation", - "type": "address" - } - ], - "name": "upgradeTo", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "newImplementation", - "type": "address" - }, - { - "internalType": "bytes", - "name": "data", - "type": "bytes" - } - ], - "name": "upgradeToAndCall", - "outputs": [], - "stateMutability": "payable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "tokenID", - "type": "uint256" - } - ], + { + "inputs": [], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "inputs": [], + "name": "AlreadyClaimed", + "type": "error" + }, + { + "inputs": [], + "name": "ArraySize", + "type": "error" + }, + { + "inputs": [], + "name": "DoesNotExist", + "type": "error" + }, + { + "inputs": [], + "name": "DuplicateEntry", + "type": "error" + }, + { + "inputs": [], + "name": "Invalid", + "type": "error" + }, + { + "inputs": [], + "name": "NotAllowed", + "type": "error" + }, + { + "inputs": [], + "name": "NotApprovedOrOwner", + "type": "error" + }, + { + "inputs": [], + "name": "TransfersNotAllowed", + "type": "error" + }, + { + "inputs": [], + "name": "TypeMismatch", + "type": "error" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "previousAdmin", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "newAdmin", + "type": "address" + } + ], + "name": "AdminChanged", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "tokenID", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "bytes32", + "name": "root", + "type": "bytes32" + } + ], + "name": "AllowlistCreated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "account", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "operator", + "type": "address" + }, + { + "indexed": false, + "internalType": "bool", + "name": "approved", + "type": "bool" + } + ], + "name": "ApprovalForAll", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256[]", + "name": "claimIDs", + "type": "uint256[]" + }, + { + "indexed": false, + "internalType": "uint256[]", + "name": "fromTokenIDs", + "type": "uint256[]" + }, + { + "indexed": false, + "internalType": "uint256[]", + "name": "toTokenIDs", + "type": "uint256[]" + }, + { + "indexed": false, + "internalType": "uint256[]", + "name": "values", + "type": "uint256[]" + } + ], + "name": "BatchValueTransfer", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "beacon", + "type": "address" + } + ], + "name": "BeaconUpgraded", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "uint256", + "name": "claimID", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "string", "name": "uri", - "outputs": [ - { - "internalType": "string", - "name": "_uri", - "type": "string" - } - ], - "stateMutability": "view", - "type": "function" - } + "type": "string" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "totalUnits", + "type": "uint256" + } + ], + "name": "ClaimStored", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint8", + "name": "version", + "type": "uint8" + } + ], + "name": "Initialized", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "tokenID", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "bytes32", + "name": "leaf", + "type": "bytes32" + } + ], + "name": "LeafClaimed", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "previousOwner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "OwnershipTransferred", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "Paused", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "operator", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "from", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256[]", + "name": "ids", + "type": "uint256[]" + }, + { + "indexed": false, + "internalType": "uint256[]", + "name": "values", + "type": "uint256[]" + } + ], + "name": "TransferBatch", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "operator", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "from", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "id", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "value", + "type": "uint256" + } + ], + "name": "TransferSingle", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "string", + "name": "value", + "type": "string" + }, + { + "indexed": true, + "internalType": "uint256", + "name": "id", + "type": "uint256" + } + ], + "name": "URI", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "Unpaused", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "implementation", + "type": "address" + } + ], + "name": "Upgraded", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "claimID", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "fromTokenID", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "toTokenID", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "value", + "type": "uint256" + } + ], + "name": "ValueTransfer", + "type": "event" + }, + { + "inputs": [], + "name": "__SemiFungible1155_init", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + }, + { + "internalType": "uint256", + "name": "id", + "type": "uint256" + } + ], + "name": "balanceOf", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address[]", + "name": "accounts", + "type": "address[]" + }, + { + "internalType": "uint256[]", + "name": "ids", + "type": "uint256[]" + } + ], + "name": "balanceOfBatch", + "outputs": [ + { + "internalType": "uint256[]", + "name": "", + "type": "uint256[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_account", + "type": "address" + }, + { + "internalType": "uint256[]", + "name": "_tokenIDs", + "type": "uint256[]" + } + ], + "name": "batchBurnFraction", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + }, + { + "internalType": "bytes32[][]", + "name": "proofs", + "type": "bytes32[][]" + }, + { + "internalType": "uint256[]", + "name": "claimIDs", + "type": "uint256[]" + }, + { + "internalType": "uint256[]", + "name": "units", + "type": "uint256[]" + } + ], + "name": "batchMintClaimsFromAllowlists", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + }, + { + "internalType": "uint256", + "name": "id", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "value", + "type": "uint256" + } + ], + "name": "burn", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + }, + { + "internalType": "uint256[]", + "name": "ids", + "type": "uint256[]" + }, + { + "internalType": "uint256[]", + "name": "values", + "type": "uint256[]" + } + ], + "name": "burnBatch", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_account", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_tokenID", + "type": "uint256" + } + ], + "name": "burnFraction", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + }, + { + "internalType": "uint256", + "name": "units", + "type": "uint256" + }, + { + "internalType": "bytes32", + "name": "merkleRoot", + "type": "bytes32" + }, + { + "internalType": "string", + "name": "_uri", + "type": "string" + }, + { + "internalType": "enum IHypercertToken.TransferRestrictions", + "name": "restrictions", + "type": "uint8" + } + ], + "name": "createAllowlist", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + }, + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "name": "hasBeenClaimed", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "initialize", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32[]", + "name": "proof", + "type": "bytes32[]" + }, + { + "internalType": "uint256", + "name": "claimID", + "type": "uint256" + }, + { + "internalType": "bytes32", + "name": "leaf", + "type": "bytes32" + } + ], + "name": "isAllowedToClaim", + "outputs": [ + { + "internalType": "bool", + "name": "isAllowed", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + }, + { + "internalType": "address", + "name": "operator", + "type": "address" + } + ], + "name": "isApprovedForAll", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_account", + "type": "address" + }, + { + "internalType": "uint256[]", + "name": "_fractionIDs", + "type": "uint256[]" + } + ], + "name": "mergeFractions", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + }, + { + "internalType": "uint256", + "name": "units", + "type": "uint256" + }, + { + "internalType": "string", + "name": "_uri", + "type": "string" + }, + { + "internalType": "enum IHypercertToken.TransferRestrictions", + "name": "restrictions", + "type": "uint8" + } + ], + "name": "mintClaim", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + }, + { + "internalType": "bytes32[]", + "name": "proof", + "type": "bytes32[]" + }, + { + "internalType": "uint256", + "name": "claimID", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "units", + "type": "uint256" + } + ], + "name": "mintClaimFromAllowlist", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + }, + { + "internalType": "uint256", + "name": "units", + "type": "uint256" + }, + { + "internalType": "uint256[]", + "name": "fractions", + "type": "uint256[]" + }, + { + "internalType": "string", + "name": "_uri", + "type": "string" + }, + { + "internalType": "enum IHypercertToken.TransferRestrictions", + "name": "restrictions", + "type": "uint8" + } + ], + "name": "mintClaimWithFractions", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "name", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "owner", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "tokenID", + "type": "uint256" + } + ], + "name": "ownerOf", + "outputs": [ + { + "internalType": "address", + "name": "_owner", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "pause", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "paused", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "proxiableUUID", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "tokenID", + "type": "uint256" + } + ], + "name": "readTransferRestriction", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "renounceOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "from", + "type": "address" + }, + { + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "internalType": "uint256[]", + "name": "ids", + "type": "uint256[]" + }, + { + "internalType": "uint256[]", + "name": "amounts", + "type": "uint256[]" + }, + { + "internalType": "bytes", + "name": "data", + "type": "bytes" + } + ], + "name": "safeBatchTransferFrom", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "from", + "type": "address" + }, + { + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "internalType": "uint256", + "name": "id", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "internalType": "bytes", + "name": "data", + "type": "bytes" + } + ], + "name": "safeTransferFrom", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "operator", + "type": "address" + }, + { + "internalType": "bool", + "name": "approved", + "type": "bool" + } + ], + "name": "setApprovalForAll", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_account", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_tokenID", + "type": "uint256" + }, + { + "internalType": "uint256[]", + "name": "_newFractions", + "type": "uint256[]" + } + ], + "name": "splitFraction", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes4", + "name": "interfaceId", + "type": "bytes4" + } + ], + "name": "supportsInterface", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "transferOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + }, + { + "internalType": "uint256", + "name": "tokenID", + "type": "uint256" + } + ], + "name": "unitsOf", + "outputs": [ + { + "internalType": "uint256", + "name": "units", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "tokenID", + "type": "uint256" + } + ], + "name": "unitsOf", + "outputs": [ + { + "internalType": "uint256", + "name": "units", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "unpause", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newImplementation", + "type": "address" + } + ], + "name": "upgradeTo", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newImplementation", + "type": "address" + }, + { + "internalType": "bytes", + "name": "data", + "type": "bytes" + } + ], + "name": "upgradeToAndCall", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "tokenID", + "type": "uint256" + } + ], + "name": "uri", + "outputs": [ + { + "internalType": "string", + "name": "_uri", + "type": "string" + } + ], + "stateMutability": "view", + "type": "function" + } ] diff --git a/graph/generated/HypercertMinter/HypercertMinter.ts b/graph/generated/HypercertMinter/HypercertMinter.ts index 41fdeb8c..988629ae 100644 --- a/graph/generated/HypercertMinter/HypercertMinter.ts +++ b/graph/generated/HypercertMinter/HypercertMinter.ts @@ -7,7 +7,7 @@ import { Entity, Bytes, Address, - BigInt + BigInt, } from "@graphprotocol/graph-ts"; export class AdminChanged extends ethereum.Event { @@ -401,8 +401,8 @@ export class HypercertMinter extends ethereum.SmartContract { "balanceOf(address,uint256):(uint256)", [ ethereum.Value.fromAddress(account), - ethereum.Value.fromUnsignedBigInt(id) - ] + ethereum.Value.fromUnsignedBigInt(id), + ], ); return result[0].toBigInt(); @@ -414,8 +414,8 @@ export class HypercertMinter extends ethereum.SmartContract { "balanceOf(address,uint256):(uint256)", [ ethereum.Value.fromAddress(account), - ethereum.Value.fromUnsignedBigInt(id) - ] + ethereum.Value.fromUnsignedBigInt(id), + ], ); if (result.reverted) { return new ethereum.CallResult(); @@ -430,8 +430,8 @@ export class HypercertMinter extends ethereum.SmartContract { "balanceOfBatch(address[],uint256[]):(uint256[])", [ ethereum.Value.fromAddressArray(accounts), - ethereum.Value.fromUnsignedBigIntArray(ids) - ] + ethereum.Value.fromUnsignedBigIntArray(ids), + ], ); return result[0].toBigIntArray(); @@ -439,15 +439,15 @@ export class HypercertMinter extends ethereum.SmartContract { try_balanceOfBatch( accounts: Array
, - ids: Array + ids: Array, ): ethereum.CallResult> { let result = super.tryCall( "balanceOfBatch", "balanceOfBatch(address[],uint256[]):(uint256[])", [ ethereum.Value.fromAddressArray(accounts), - ethereum.Value.fromUnsignedBigIntArray(ids) - ] + ethereum.Value.fromUnsignedBigIntArray(ids), + ], ); if (result.reverted) { return new ethereum.CallResult(); @@ -462,8 +462,8 @@ export class HypercertMinter extends ethereum.SmartContract { "hasBeenClaimed(uint256,bytes32):(bool)", [ ethereum.Value.fromUnsignedBigInt(param0), - ethereum.Value.fromFixedBytes(param1) - ] + ethereum.Value.fromFixedBytes(param1), + ], ); return result[0].toBoolean(); @@ -471,15 +471,15 @@ export class HypercertMinter extends ethereum.SmartContract { try_hasBeenClaimed( param0: BigInt, - param1: Bytes + param1: Bytes, ): ethereum.CallResult { let result = super.tryCall( "hasBeenClaimed", "hasBeenClaimed(uint256,bytes32):(bool)", [ ethereum.Value.fromUnsignedBigInt(param0), - ethereum.Value.fromFixedBytes(param1) - ] + ethereum.Value.fromFixedBytes(param1), + ], ); if (result.reverted) { return new ethereum.CallResult(); @@ -495,8 +495,8 @@ export class HypercertMinter extends ethereum.SmartContract { [ ethereum.Value.fromFixedBytesArray(proof), ethereum.Value.fromUnsignedBigInt(claimID), - ethereum.Value.fromFixedBytes(leaf) - ] + ethereum.Value.fromFixedBytes(leaf), + ], ); return result[0].toBoolean(); @@ -505,7 +505,7 @@ export class HypercertMinter extends ethereum.SmartContract { try_isAllowedToClaim( proof: Array, claimID: BigInt, - leaf: Bytes + leaf: Bytes, ): ethereum.CallResult { let result = super.tryCall( "isAllowedToClaim", @@ -513,8 +513,8 @@ export class HypercertMinter extends ethereum.SmartContract { [ ethereum.Value.fromFixedBytesArray(proof), ethereum.Value.fromUnsignedBigInt(claimID), - ethereum.Value.fromFixedBytes(leaf) - ] + ethereum.Value.fromFixedBytes(leaf), + ], ); if (result.reverted) { return new ethereum.CallResult(); @@ -529,8 +529,8 @@ export class HypercertMinter extends ethereum.SmartContract { "isApprovedForAll(address,address):(bool)", [ ethereum.Value.fromAddress(account), - ethereum.Value.fromAddress(operator) - ] + ethereum.Value.fromAddress(operator), + ], ); return result[0].toBoolean(); @@ -538,15 +538,15 @@ export class HypercertMinter extends ethereum.SmartContract { try_isApprovedForAll( account: Address, - operator: Address + operator: Address, ): ethereum.CallResult { let result = super.tryCall( "isApprovedForAll", "isApprovedForAll(address,address):(bool)", [ ethereum.Value.fromAddress(account), - ethereum.Value.fromAddress(operator) - ] + ethereum.Value.fromAddress(operator), + ], ); if (result.reverted) { return new ethereum.CallResult(); @@ -587,7 +587,7 @@ export class HypercertMinter extends ethereum.SmartContract { ownerOf(tokenID: BigInt): Address { let result = super.call("ownerOf", "ownerOf(uint256):(address)", [ - ethereum.Value.fromUnsignedBigInt(tokenID) + ethereum.Value.fromUnsignedBigInt(tokenID), ]); return result[0].toAddress(); @@ -595,7 +595,7 @@ export class HypercertMinter extends ethereum.SmartContract { try_ownerOf(tokenID: BigInt): ethereum.CallResult
{ let result = super.tryCall("ownerOf", "ownerOf(uint256):(address)", [ - ethereum.Value.fromUnsignedBigInt(tokenID) + ethereum.Value.fromUnsignedBigInt(tokenID), ]); if (result.reverted) { return new ethereum.CallResult(); @@ -629,7 +629,7 @@ export class HypercertMinter extends ethereum.SmartContract { let result = super.tryCall( "proxiableUUID", "proxiableUUID():(bytes32)", - [] + [], ); if (result.reverted) { return new ethereum.CallResult(); @@ -638,11 +638,34 @@ export class HypercertMinter extends ethereum.SmartContract { return ethereum.CallResult.fromValue(value[0].toBytes()); } + readTransferRestriction(tokenID: BigInt): string { + let result = super.call( + "readTransferRestriction", + "readTransferRestriction(uint256):(string)", + [ethereum.Value.fromUnsignedBigInt(tokenID)], + ); + + return result[0].toString(); + } + + try_readTransferRestriction(tokenID: BigInt): ethereum.CallResult { + let result = super.tryCall( + "readTransferRestriction", + "readTransferRestriction(uint256):(string)", + [ethereum.Value.fromUnsignedBigInt(tokenID)], + ); + if (result.reverted) { + return new ethereum.CallResult(); + } + let value = result.value; + return ethereum.CallResult.fromValue(value[0].toString()); + } + supportsInterface(interfaceId: Bytes): boolean { let result = super.call( "supportsInterface", "supportsInterface(bytes4):(bool)", - [ethereum.Value.fromFixedBytes(interfaceId)] + [ethereum.Value.fromFixedBytes(interfaceId)], ); return result[0].toBoolean(); @@ -652,7 +675,7 @@ export class HypercertMinter extends ethereum.SmartContract { let result = super.tryCall( "supportsInterface", "supportsInterface(bytes4):(bool)", - [ethereum.Value.fromFixedBytes(interfaceId)] + [ethereum.Value.fromFixedBytes(interfaceId)], ); if (result.reverted) { return new ethereum.CallResult(); @@ -664,7 +687,7 @@ export class HypercertMinter extends ethereum.SmartContract { unitsOf(account: Address, tokenID: BigInt): BigInt { let result = super.call("unitsOf", "unitsOf(address,uint256):(uint256)", [ ethereum.Value.fromAddress(account), - ethereum.Value.fromUnsignedBigInt(tokenID) + ethereum.Value.fromUnsignedBigInt(tokenID), ]); return result[0].toBigInt(); @@ -676,8 +699,8 @@ export class HypercertMinter extends ethereum.SmartContract { "unitsOf(address,uint256):(uint256)", [ ethereum.Value.fromAddress(account), - ethereum.Value.fromUnsignedBigInt(tokenID) - ] + ethereum.Value.fromUnsignedBigInt(tokenID), + ], ); if (result.reverted) { return new ethereum.CallResult(); @@ -688,7 +711,7 @@ export class HypercertMinter extends ethereum.SmartContract { unitsOf1(tokenID: BigInt): BigInt { let result = super.call("unitsOf", "unitsOf(uint256):(uint256)", [ - ethereum.Value.fromUnsignedBigInt(tokenID) + ethereum.Value.fromUnsignedBigInt(tokenID), ]); return result[0].toBigInt(); @@ -696,7 +719,7 @@ export class HypercertMinter extends ethereum.SmartContract { try_unitsOf1(tokenID: BigInt): ethereum.CallResult { let result = super.tryCall("unitsOf", "unitsOf(uint256):(uint256)", [ - ethereum.Value.fromUnsignedBigInt(tokenID) + ethereum.Value.fromUnsignedBigInt(tokenID), ]); if (result.reverted) { return new ethereum.CallResult(); @@ -707,7 +730,7 @@ export class HypercertMinter extends ethereum.SmartContract { uri(tokenID: BigInt): string { let result = super.call("uri", "uri(uint256):(string)", [ - ethereum.Value.fromUnsignedBigInt(tokenID) + ethereum.Value.fromUnsignedBigInt(tokenID), ]); return result[0].toString(); @@ -715,7 +738,7 @@ export class HypercertMinter extends ethereum.SmartContract { try_uri(tokenID: BigInt): ethereum.CallResult { let result = super.tryCall("uri", "uri(uint256):(string)", [ - ethereum.Value.fromUnsignedBigInt(tokenID) + ethereum.Value.fromUnsignedBigInt(tokenID), ]); if (result.reverted) { return new ethereum.CallResult(); @@ -777,28 +800,36 @@ export class __SemiFungible1155_initCall__Outputs { } } -export class __Upgradeable1155_initCall extends ethereum.Call { - get inputs(): __Upgradeable1155_initCall__Inputs { - return new __Upgradeable1155_initCall__Inputs(this); +export class BatchBurnFractionCall extends ethereum.Call { + get inputs(): BatchBurnFractionCall__Inputs { + return new BatchBurnFractionCall__Inputs(this); } - get outputs(): __Upgradeable1155_initCall__Outputs { - return new __Upgradeable1155_initCall__Outputs(this); + get outputs(): BatchBurnFractionCall__Outputs { + return new BatchBurnFractionCall__Outputs(this); } } -export class __Upgradeable1155_initCall__Inputs { - _call: __Upgradeable1155_initCall; +export class BatchBurnFractionCall__Inputs { + _call: BatchBurnFractionCall; - constructor(call: __Upgradeable1155_initCall) { + constructor(call: BatchBurnFractionCall) { this._call = call; } + + get _account(): Address { + return this._call.inputValues[0].value.toAddress(); + } + + get _tokenIDs(): Array { + return this._call.inputValues[1].value.toBigIntArray(); + } } -export class __Upgradeable1155_initCall__Outputs { - _call: __Upgradeable1155_initCall; +export class BatchBurnFractionCall__Outputs { + _call: BatchBurnFractionCall; - constructor(call: __Upgradeable1155_initCall) { + constructor(call: BatchBurnFractionCall) { this._call = call; } } @@ -820,16 +851,20 @@ export class BatchMintClaimsFromAllowlistsCall__Inputs { this._call = call; } + get account(): Address { + return this._call.inputValues[0].value.toAddress(); + } + get proofs(): Array> { - return this._call.inputValues[0].value.toBytesMatrix(); + return this._call.inputValues[1].value.toBytesMatrix(); } get claimIDs(): Array { - return this._call.inputValues[1].value.toBigIntArray(); + return this._call.inputValues[2].value.toBigIntArray(); } get units(): Array { - return this._call.inputValues[2].value.toBigIntArray(); + return this._call.inputValues[3].value.toBigIntArray(); } } @@ -917,20 +952,20 @@ export class BurnBatchCall__Outputs { } } -export class BurnValueCall extends ethereum.Call { - get inputs(): BurnValueCall__Inputs { - return new BurnValueCall__Inputs(this); +export class BurnFractionCall extends ethereum.Call { + get inputs(): BurnFractionCall__Inputs { + return new BurnFractionCall__Inputs(this); } - get outputs(): BurnValueCall__Outputs { - return new BurnValueCall__Outputs(this); + get outputs(): BurnFractionCall__Outputs { + return new BurnFractionCall__Outputs(this); } } -export class BurnValueCall__Inputs { - _call: BurnValueCall; +export class BurnFractionCall__Inputs { + _call: BurnFractionCall; - constructor(call: BurnValueCall) { + constructor(call: BurnFractionCall) { this._call = call; } @@ -943,10 +978,10 @@ export class BurnValueCall__Inputs { } } -export class BurnValueCall__Outputs { - _call: BurnValueCall; +export class BurnFractionCall__Outputs { + _call: BurnFractionCall; - constructor(call: BurnValueCall) { + constructor(call: BurnFractionCall) { this._call = call; } } @@ -968,20 +1003,24 @@ export class CreateAllowlistCall__Inputs { this._call = call; } + get account(): Address { + return this._call.inputValues[0].value.toAddress(); + } + get units(): BigInt { - return this._call.inputValues[0].value.toBigInt(); + return this._call.inputValues[1].value.toBigInt(); } get merkleRoot(): Bytes { - return this._call.inputValues[1].value.toBytes(); + return this._call.inputValues[2].value.toBytes(); } get _uri(): string { - return this._call.inputValues[2].value.toString(); + return this._call.inputValues[3].value.toString(); } get restrictions(): i32 { - return this._call.inputValues[3].value.toI32(); + return this._call.inputValues[4].value.toI32(); } } @@ -1019,32 +1058,36 @@ export class InitializeCall__Outputs { } } -export class MergeValueCall extends ethereum.Call { - get inputs(): MergeValueCall__Inputs { - return new MergeValueCall__Inputs(this); +export class MergeFractionsCall extends ethereum.Call { + get inputs(): MergeFractionsCall__Inputs { + return new MergeFractionsCall__Inputs(this); } - get outputs(): MergeValueCall__Outputs { - return new MergeValueCall__Outputs(this); + get outputs(): MergeFractionsCall__Outputs { + return new MergeFractionsCall__Outputs(this); } } -export class MergeValueCall__Inputs { - _call: MergeValueCall; +export class MergeFractionsCall__Inputs { + _call: MergeFractionsCall; - constructor(call: MergeValueCall) { + constructor(call: MergeFractionsCall) { this._call = call; } + get _account(): Address { + return this._call.inputValues[0].value.toAddress(); + } + get _fractionIDs(): Array { - return this._call.inputValues[0].value.toBigIntArray(); + return this._call.inputValues[1].value.toBigIntArray(); } } -export class MergeValueCall__Outputs { - _call: MergeValueCall; +export class MergeFractionsCall__Outputs { + _call: MergeFractionsCall; - constructor(call: MergeValueCall) { + constructor(call: MergeFractionsCall) { this._call = call; } } @@ -1066,16 +1109,20 @@ export class MintClaimCall__Inputs { this._call = call; } + get account(): Address { + return this._call.inputValues[0].value.toAddress(); + } + get units(): BigInt { - return this._call.inputValues[0].value.toBigInt(); + return this._call.inputValues[1].value.toBigInt(); } get _uri(): string { - return this._call.inputValues[1].value.toString(); + return this._call.inputValues[2].value.toString(); } get restrictions(): i32 { - return this._call.inputValues[2].value.toI32(); + return this._call.inputValues[3].value.toI32(); } } @@ -1104,16 +1151,20 @@ export class MintClaimFromAllowlistCall__Inputs { this._call = call; } + get account(): Address { + return this._call.inputValues[0].value.toAddress(); + } + get proof(): Array { - return this._call.inputValues[0].value.toBytesArray(); + return this._call.inputValues[1].value.toBytesArray(); } get claimID(): BigInt { - return this._call.inputValues[1].value.toBigInt(); + return this._call.inputValues[2].value.toBigInt(); } get units(): BigInt { - return this._call.inputValues[2].value.toBigInt(); + return this._call.inputValues[3].value.toBigInt(); } } @@ -1142,20 +1193,24 @@ export class MintClaimWithFractionsCall__Inputs { this._call = call; } + get account(): Address { + return this._call.inputValues[0].value.toAddress(); + } + get units(): BigInt { - return this._call.inputValues[0].value.toBigInt(); + return this._call.inputValues[1].value.toBigInt(); } get fractions(): Array { - return this._call.inputValues[1].value.toBigIntArray(); + return this._call.inputValues[2].value.toBigIntArray(); } get _uri(): string { - return this._call.inputValues[2].value.toString(); + return this._call.inputValues[3].value.toString(); } get restrictions(): i32 { - return this._call.inputValues[3].value.toI32(); + return this._call.inputValues[4].value.toI32(); } } @@ -1345,20 +1400,20 @@ export class SetApprovalForAllCall__Outputs { } } -export class SplitValueCall extends ethereum.Call { - get inputs(): SplitValueCall__Inputs { - return new SplitValueCall__Inputs(this); +export class SplitFractionCall extends ethereum.Call { + get inputs(): SplitFractionCall__Inputs { + return new SplitFractionCall__Inputs(this); } - get outputs(): SplitValueCall__Outputs { - return new SplitValueCall__Outputs(this); + get outputs(): SplitFractionCall__Outputs { + return new SplitFractionCall__Outputs(this); } } -export class SplitValueCall__Inputs { - _call: SplitValueCall; +export class SplitFractionCall__Inputs { + _call: SplitFractionCall; - constructor(call: SplitValueCall) { + constructor(call: SplitFractionCall) { this._call = call; } @@ -1370,15 +1425,15 @@ export class SplitValueCall__Inputs { return this._call.inputValues[1].value.toBigInt(); } - get _values(): Array { + get _newFractions(): Array { return this._call.inputValues[2].value.toBigIntArray(); } } -export class SplitValueCall__Outputs { - _call: SplitValueCall; +export class SplitFractionCall__Outputs { + _call: SplitFractionCall; - constructor(call: SplitValueCall) { + constructor(call: SplitFractionCall) { this._call = call; } } diff --git a/graph/generated/schema.ts b/graph/generated/schema.ts index 7834b274..cf492abf 100644 --- a/graph/generated/schema.ts +++ b/graph/generated/schema.ts @@ -222,6 +222,23 @@ export class Claim extends Entity { this.set("totalUnits", Value.fromBigInt(value)); } } + + get allowlist(): string | null { + let value = this.get("allowlist"); + if (!value || value.kind == ValueKind.NULL) { + return null; + } else { + return value.toString(); + } + } + + set allowlist(value: string | null) { + if (!value) { + this.unset("allowlist"); + } else { + this.set("allowlist", Value.fromString(value)); + } + } } export class ClaimToken extends Entity { @@ -314,4 +331,417 @@ export class ClaimToken extends Entity { set units(value: BigInt) { this.set("units", Value.fromBigInt(value)); } + + get offers(): OfferLoader { + return new OfferLoader("ClaimToken", this.get("id")!.toString(), "offers"); + } +} + +export class Token extends Entity { + constructor(id: string) { + super(); + this.set("id", Value.fromString(id)); + } + + save(): void { + let id = this.get("id"); + assert(id != null, "Cannot save Token entity without an ID"); + if (id) { + assert( + id.kind == ValueKind.STRING, + `Entities of type Token must have an ID of type String but the id '${id.displayData()}' is of type ${id.displayKind()}`, + ); + store.set("Token", id.toString(), this); + } + } + + static loadInBlock(id: string): Token | null { + return changetype(store.get_in_block("Token", id)); + } + + static load(id: string): Token | null { + return changetype(store.get("Token", id)); + } + + get id(): string { + let value = this.get("id"); + if (!value || value.kind == ValueKind.NULL) { + throw new Error("Cannot return null for a required field."); + } else { + return value.toString(); + } + } + + set id(value: string) { + this.set("id", Value.fromString(value)); + } + + get name(): string { + let value = this.get("name"); + if (!value || value.kind == ValueKind.NULL) { + throw new Error("Cannot return null for a required field."); + } else { + return value.toString(); + } + } + + set name(value: string) { + this.set("name", Value.fromString(value)); + } + + get symbol(): string | null { + let value = this.get("symbol"); + if (!value || value.kind == ValueKind.NULL) { + return null; + } else { + return value.toString(); + } + } + + set symbol(value: string | null) { + if (!value) { + this.unset("symbol"); + } else { + this.set("symbol", Value.fromString(value)); + } + } + + get decimals(): BigInt | null { + let value = this.get("decimals"); + if (!value || value.kind == ValueKind.NULL) { + return null; + } else { + return value.toBigInt(); + } + } + + set decimals(value: BigInt | null) { + if (!value) { + this.unset("decimals"); + } else { + this.set("decimals", Value.fromBigInt(value)); + } + } +} + +export class AcceptedToken extends Entity { + constructor(id: string) { + super(); + this.set("id", Value.fromString(id)); + } + + save(): void { + let id = this.get("id"); + assert(id != null, "Cannot save AcceptedToken entity without an ID"); + if (id) { + assert( + id.kind == ValueKind.STRING, + `Entities of type AcceptedToken must have an ID of type String but the id '${id.displayData()}' is of type ${id.displayKind()}`, + ); + store.set("AcceptedToken", id.toString(), this); + } + } + + static loadInBlock(id: string): AcceptedToken | null { + return changetype( + store.get_in_block("AcceptedToken", id), + ); + } + + static load(id: string): AcceptedToken | null { + return changetype(store.get("AcceptedToken", id)); + } + + get id(): string { + let value = this.get("id"); + if (!value || value.kind == ValueKind.NULL) { + throw new Error("Cannot return null for a required field."); + } else { + return value.toString(); + } + } + + set id(value: string) { + this.set("id", Value.fromString(value)); + } + + get token(): string { + let value = this.get("token"); + if (!value || value.kind == ValueKind.NULL) { + throw new Error("Cannot return null for a required field."); + } else { + return value.toString(); + } + } + + set token(value: string) { + this.set("token", Value.fromString(value)); + } + + get minimumAmountPerUnit(): BigInt { + let value = this.get("minimumAmountPerUnit"); + if (!value || value.kind == ValueKind.NULL) { + throw new Error("Cannot return null for a required field."); + } else { + return value.toBigInt(); + } + } + + set minimumAmountPerUnit(value: BigInt) { + this.set("minimumAmountPerUnit", Value.fromBigInt(value)); + } + + get accepted(): boolean { + let value = this.get("accepted"); + if (!value || value.kind == ValueKind.NULL) { + return false; + } else { + return value.toBoolean(); + } + } + + set accepted(value: boolean) { + this.set("accepted", Value.fromBoolean(value)); + } +} + +export class Offer extends Entity { + constructor(id: string) { + super(); + this.set("id", Value.fromString(id)); + } + + save(): void { + let id = this.get("id"); + assert(id != null, "Cannot save Offer entity without an ID"); + if (id) { + assert( + id.kind == ValueKind.STRING, + `Entities of type Offer must have an ID of type String but the id '${id.displayData()}' is of type ${id.displayKind()}`, + ); + store.set("Offer", id.toString(), this); + } + } + + static loadInBlock(id: string): Offer | null { + return changetype(store.get_in_block("Offer", id)); + } + + static load(id: string): Offer | null { + return changetype(store.get("Offer", id)); + } + + get id(): string { + let value = this.get("id"); + if (!value || value.kind == ValueKind.NULL) { + throw new Error("Cannot return null for a required field."); + } else { + return value.toString(); + } + } + + set id(value: string) { + this.set("id", Value.fromString(value)); + } + + get fractionID(): string { + let value = this.get("fractionID"); + if (!value || value.kind == ValueKind.NULL) { + throw new Error("Cannot return null for a required field."); + } else { + return value.toString(); + } + } + + set fractionID(value: string) { + this.set("fractionID", Value.fromString(value)); + } + + get unitsAvailable(): BigInt { + let value = this.get("unitsAvailable"); + if (!value || value.kind == ValueKind.NULL) { + throw new Error("Cannot return null for a required field."); + } else { + return value.toBigInt(); + } + } + + set unitsAvailable(value: BigInt) { + this.set("unitsAvailable", Value.fromBigInt(value)); + } + + get minUnitsPerTrade(): BigInt { + let value = this.get("minUnitsPerTrade"); + if (!value || value.kind == ValueKind.NULL) { + throw new Error("Cannot return null for a required field."); + } else { + return value.toBigInt(); + } + } + + set minUnitsPerTrade(value: BigInt) { + this.set("minUnitsPerTrade", Value.fromBigInt(value)); + } + + get maxUnitsPerTrade(): BigInt { + let value = this.get("maxUnitsPerTrade"); + if (!value || value.kind == ValueKind.NULL) { + throw new Error("Cannot return null for a required field."); + } else { + return value.toBigInt(); + } + } + + set maxUnitsPerTrade(value: BigInt) { + this.set("maxUnitsPerTrade", Value.fromBigInt(value)); + } + + get status(): string { + let value = this.get("status"); + if (!value || value.kind == ValueKind.NULL) { + throw new Error("Cannot return null for a required field."); + } else { + return value.toString(); + } + } + + set status(value: string) { + this.set("status", Value.fromString(value)); + } + + get acceptedTokens(): Array { + let value = this.get("acceptedTokens"); + if (!value || value.kind == ValueKind.NULL) { + throw new Error("Cannot return null for a required field."); + } else { + return value.toStringArray(); + } + } + + set acceptedTokens(value: Array) { + this.set("acceptedTokens", Value.fromStringArray(value)); + } +} + +export class Trade extends Entity { + constructor(id: string) { + super(); + this.set("id", Value.fromString(id)); + } + + save(): void { + let id = this.get("id"); + assert(id != null, "Cannot save Trade entity without an ID"); + if (id) { + assert( + id.kind == ValueKind.STRING, + `Entities of type Trade must have an ID of type String but the id '${id.displayData()}' is of type ${id.displayKind()}`, + ); + store.set("Trade", id.toString(), this); + } + } + + static loadInBlock(id: string): Trade | null { + return changetype(store.get_in_block("Trade", id)); + } + + static load(id: string): Trade | null { + return changetype(store.get("Trade", id)); + } + + get id(): string { + let value = this.get("id"); + if (!value || value.kind == ValueKind.NULL) { + throw new Error("Cannot return null for a required field."); + } else { + return value.toString(); + } + } + + set id(value: string) { + this.set("id", Value.fromString(value)); + } + + get buyer(): Bytes { + let value = this.get("buyer"); + if (!value || value.kind == ValueKind.NULL) { + throw new Error("Cannot return null for a required field."); + } else { + return value.toBytes(); + } + } + + set buyer(value: Bytes) { + this.set("buyer", Value.fromBytes(value)); + } + + get offerID(): string { + let value = this.get("offerID"); + if (!value || value.kind == ValueKind.NULL) { + throw new Error("Cannot return null for a required field."); + } else { + return value.toString(); + } + } + + set offerID(value: string) { + this.set("offerID", Value.fromString(value)); + } + + get unitsSold(): BigInt { + let value = this.get("unitsSold"); + if (!value || value.kind == ValueKind.NULL) { + throw new Error("Cannot return null for a required field."); + } else { + return value.toBigInt(); + } + } + + set unitsSold(value: BigInt) { + this.set("unitsSold", Value.fromBigInt(value)); + } + + get token(): string { + let value = this.get("token"); + if (!value || value.kind == ValueKind.NULL) { + throw new Error("Cannot return null for a required field."); + } else { + return value.toString(); + } + } + + set token(value: string) { + this.set("token", Value.fromString(value)); + } + + get amountPerUnit(): BigInt { + let value = this.get("amountPerUnit"); + if (!value || value.kind == ValueKind.NULL) { + throw new Error("Cannot return null for a required field."); + } else { + return value.toBigInt(); + } + } + + set amountPerUnit(value: BigInt) { + this.set("amountPerUnit", Value.fromBigInt(value)); + } +} + +export class OfferLoader extends Entity { + _entity: string; + _field: string; + _id: string; + + constructor(entity: string, id: string, field: string) { + super(); + this._entity = entity; + this._id = id; + this._field = field; + } + + load(): Offer[] { + let value = store.loadRelated(this._entity, this._id, this._field); + return changetype(value); + } } diff --git a/graph/schema.graphql b/graph/schema.graphql index 85e54ed2..d6ec32ef 100644 --- a/graph/schema.graphql +++ b/graph/schema.graphql @@ -13,6 +13,7 @@ type Claim @entity { creator: Bytes owner: Bytes totalUnits: BigInt + allowlist: Allowlist } type ClaimToken @entity { @@ -21,4 +22,44 @@ type ClaimToken @entity { claim: Claim! owner: Bytes! units: BigInt! + offers: [Offer!] @derivedFrom(field: "fractionID") +} + +type Token @entity { + id: String! + name: String! + symbol: String + decimals: BigInt +} + +type AcceptedToken @entity { + id: String! + token: Token! + minimumAmountPerUnit: BigInt! + accepted: Boolean! +} + +enum OfferStatus { + Open + Fulfilled + Cancelled +} + +type Offer @entity { + id: String! + fractionID: ClaimToken! + unitsAvailable: BigInt! + minUnitsPerTrade: BigInt! + maxUnitsPerTrade: BigInt! + status: OfferStatus! + acceptedTokens: [AcceptedToken!]! +} + +type Trade @entity { + id: String! + buyer: Bytes! + offerID: Offer! + unitsSold: BigInt! + token: Token! + amountPerUnit: BigInt! } diff --git a/graph/src/hypercert-minter.ts b/graph/src/hypercert-minter.ts index d88fbacf..fbee62a8 100644 --- a/graph/src/hypercert-minter.ts +++ b/graph/src/hypercert-minter.ts @@ -12,6 +12,7 @@ import { ValueTransfer as ValueTransferEvent, } from "../generated/HypercertMinter/HypercertMinter"; import { + ZERO_ADDRESS, getID, getOrCreateAllowlist, getOrCreateClaim, @@ -21,7 +22,7 @@ import { log } from "@graphprotocol/graph-ts"; import { ClaimToken } from "../generated/schema"; export function handleAllowlistCreated(event: AllowlistCreatedEvent): void { - let allowlist = getOrCreateAllowlist( + const allowlist = getOrCreateAllowlist( event.params.tokenID, event.params.root, event.address, @@ -30,10 +31,11 @@ export function handleAllowlistCreated(event: AllowlistCreatedEvent): void { allowlist.save(); } -export function handleApprovalForAll(event: ApprovalForAllEvent): void {} +// eslint-disable-next-line @typescript-eslint/no-empty-function +export function handleApprovalForAll(_event: ApprovalForAllEvent): void {} export function handleClaimStored(event: ClaimStoredEvent): void { - let claim = getOrCreateClaim( + const claim = getOrCreateClaim( event.params.claimID, event.address, event.block.timestamp, @@ -47,21 +49,24 @@ export function handleClaimStored(event: ClaimStoredEvent): void { claim.save(); } -export function handleInitialized(event: InitializedEvent): void {} +// eslint-disable-next-line @typescript-eslint/no-empty-function +export function handleInitialized(_: InitializedEvent): void {} -export function handleLeafClaimed(event: LeafClaimedEvent): void {} +// eslint-disable-next-line @typescript-eslint/no-empty-function +export function handleLeafClaimed(_: LeafClaimedEvent): void {} export function handleOwnershipTransferred( - event: OwnershipTransferredEvent, + _event: OwnershipTransferredEvent, + // eslint-disable-next-line @typescript-eslint/no-empty-function, ): void {} export function handleTransferBatch(event: TransferBatchEvent): void { - let ids = event.params.ids; - let size = ids.length; + const ids = event.params.ids; + const size = ids.length; for (let i = 0; i < size; i++) { - let id = getID(ids[i], event.address); - let token = ClaimToken.load(id); + const id = getID(ids[i], event.address); + const token = ClaimToken.load(id); if (!token) { log.debug("Transfered ClaimToken does not exist: {}", [id]); @@ -75,8 +80,8 @@ export function handleTransferBatch(event: TransferBatchEvent): void { } export function handleTransferSingle(event: TransferSingleEvent): void { - let id = getID(event.params.id, event.address); - let token = ClaimToken.load(id); + const id = getID(event.params.id, event.address); + const token = ClaimToken.load(id); if (!token) { log.debug("Transfered ClaimToken does not exist: {}", [id]); @@ -87,7 +92,8 @@ export function handleTransferSingle(event: TransferSingleEvent): void { token.save(); } -export function handleURI(event: URIEvent): void {} +// eslint-disable-next-line @typescript-eslint/no-empty-function +export function handleURI(_event: URIEvent): void {} export function handleValueTransfer(event: ValueTransferEvent): void { log.debug("Received ValueTransferEvent claimID: {}", [ @@ -104,18 +110,18 @@ export function handleValueTransfer(event: ValueTransferEvent): void { event.params.value.toString(), ]); - let from = getOrCreateClaimToken( + const from = getOrCreateClaimToken( event.params.claimID, event.params.fromTokenID, event.address, ); - let to = getOrCreateClaimToken( + const to = getOrCreateClaimToken( event.params.claimID, event.params.toTokenID, event.address, ); - let value = event.params.value; + const value = event.params.value; log.debug("Got from: {}", [from.id]); log.debug("Got to: {}", [to.id]); @@ -135,6 +141,7 @@ export function handleValueTransfer(event: ValueTransferEvent): void { // Burn value if (!from.tokenID.isZero() && to.tokenID.isZero()) { from.units = from.units.minus(value); + from.owner = ZERO_ADDRESS; } log.debug("Saving from: {}", [from.id]); @@ -146,18 +153,23 @@ export function handleValueTransfer(event: ValueTransferEvent): void { //TODO cleanup to nicer state handling export function handleBatchValueTransfer(event: BatchValueTransfer): void { - let claimIDs = event.params.claimIDs; - let fromIDs = event.params.fromTokenIDs; - let toIDs = event.params.toTokenIDs; - let values = event.params.values; + const claimIDs = event.params.claimIDs; + const fromIDs = event.params.fromTokenIDs; + const toIDs = event.params.toTokenIDs; + const values = event.params.values; + const contractAddress = event.address; - let size = claimIDs.length; + const size = claimIDs.length; for (let i = 0; i < size; i++) { - let from = getOrCreateClaimToken(claimIDs[i], fromIDs[i], event.address); - let to = getOrCreateClaimToken(claimIDs[i], toIDs[i], event.address); + const from = getOrCreateClaimToken( + claimIDs[i], + fromIDs[i], + contractAddress, + ); + const to = getOrCreateClaimToken(claimIDs[i], toIDs[i], contractAddress); - let value = values[i]; + const value = values[i]; log.debug("Got from: {}", [from.id]); log.debug("Got to: {}", [to.id]); @@ -176,6 +188,7 @@ export function handleBatchValueTransfer(event: BatchValueTransfer): void { // Burn value if (!from.tokenID.isZero() && to.tokenID.isZero()) { from.units = from.units.minus(value); + from.owner = ZERO_ADDRESS; } log.debug("Saving from: {}", [from.id]); diff --git a/graph/src/utils.ts b/graph/src/utils.ts index a401c245..2828cc15 100644 --- a/graph/src/utils.ts +++ b/graph/src/utils.ts @@ -1,6 +1,17 @@ -import { Address, BigInt, Bytes, log } from "@graphprotocol/graph-ts"; -import { Allowlist, Claim, ClaimToken } from "../generated/schema"; import { HypercertMinter } from "../generated/HypercertMinter/HypercertMinter"; +import { + AcceptedToken, + Allowlist, + Claim, + ClaimToken, + Offer, + Token, +} from "../generated/schema"; +import { Address, BigInt, Bytes, log } from "@graphprotocol/graph-ts"; + +export const ZERO_ADDRESS = Address.fromString( + "0x0000000000000000000000000000000000000000", +); export function getID(tokenID: BigInt, contract: Address): string { return contract.toHexString().concat("-".concat(tokenID.toString())); @@ -9,9 +20,9 @@ export function getID(tokenID: BigInt, contract: Address): string { export function getOrCreateAllowlist( claimID: BigInt, root: Bytes, - contract: Address + contract: Address, ): Allowlist { - let id = getID(claimID, contract); + const id = getID(claimID, contract); let list = Allowlist.load(id); log.debug("Created allowlistID: {}", [id]); @@ -29,18 +40,24 @@ export function getOrCreateAllowlist( export function getOrCreateClaim( claimID: BigInt, contract: Address, - timestamp: BigInt + timestamp: BigInt, ): Claim { - let id = getID(claimID, contract); + const id = getID(claimID, contract); let claim = Claim.load(id); log.debug("Created claimID: {}", [id]); if (claim == null) { claim = new Claim(id); + const list = Allowlist.load(id); + if (timestamp) { claim.creation = timestamp; } + + if (list) { + claim.allowlist = list.id; + } claim.tokenID = claimID; claim.contract = contract.toHexString(); claim.save(); @@ -52,17 +69,17 @@ export function getOrCreateClaim( export function getOrCreateClaimToken( claimID: BigInt, tokenID: BigInt, - contract: Address + contract: Address, ): ClaimToken { - let minterContract = HypercertMinter.bind(contract); + const minterContract = HypercertMinter.bind(contract); - let id = getID(tokenID, contract); + const id = getID(tokenID, contract); let fraction = ClaimToken.load(id); if (fraction == null) { log.debug("Creating claimToken: {}", [id]); - let owner = minterContract.ownerOf(tokenID); + const owner = minterContract.ownerOf(tokenID); fraction = new ClaimToken(id); fraction.owner = owner; @@ -74,3 +91,108 @@ export function getOrCreateClaimToken( return fraction; } + +export function getOrCreateToken(token: Address): Token { + const _tokenID = token.toHexString(); + let _token = Token.load(_tokenID); + + if (_token == null) { + _token = new Token(_tokenID); + log.debug("Created Token: {}", [_tokenID]); + _token.name = "Native"; + _token.save(); + } + + log.debug("Returning Token: {}", [_tokenID]); + + return _token; +} + +export function getOrCreateAcceptedToken( + offerID: BigInt, + token: Address, + minimumAmountPerUnit: BigInt, +): AcceptedToken { + const _acceptedTokenID = offerID + .toHexString() + .concat("-".concat(token.toHexString())); + let acceptedToken = AcceptedToken.load(_acceptedTokenID); + + if (acceptedToken == null) { + acceptedToken = new AcceptedToken(_acceptedTokenID); + log.debug("Created acceptedToken: {}", [_acceptedTokenID]); + + acceptedToken.token = getOrCreateToken(token).id; + acceptedToken.minimumAmountPerUnit = minimumAmountPerUnit; + acceptedToken.accepted = true; + acceptedToken.save(); + } + + log.debug("Returning acceptedToken: {}", [_acceptedTokenID]); + return acceptedToken; +} + +export function getOrCreateOffer( + hypercertContract: Address, + traderContract: Address, + fractionID: BigInt, + offerID: BigInt, +): Offer { + const _traderContract = HypercertTrader.bind(traderContract); + + const _fractionID = getID(fractionID, hypercertContract); + const _offerID = fractionID + .toHexString() + .concat("-".concat(offerID.toString())); + let offer = Offer.load(_offerID); + + if (offer == null) { + const offerOnChain = _traderContract.getOffer(offerID); + offer = new Offer(_offerID); + log.debug("Created offer: {}", [_offerID]); + + offer.fractionID = _fractionID; + offer.unitsAvailable = offerOnChain.unitsAvailable; + offer.minUnitsPerTrade = offerOnChain.minUnitsPerTrade; + offer.maxUnitsPerTrade = offerOnChain.maxUnitsPerTrade; + offer.acceptedTokens = []; + offer.status = "Open"; + + for (let i = 0; i < offerOnChain.acceptedTokens.length; i++) { + const _acceptedToken = offerOnChain.acceptedTokens[i]; + const parsedToken = getOrCreateAcceptedToken( + offerID, + _acceptedToken.token, + _acceptedToken.minimumAmountPerUnit, + ); + offer.acceptedTokens.push(parsedToken.id.toString()); + log.debug("Added accepted token to offer {} at place {}", [ + _offerID, + _acceptedToken.length.toString(), + ]); + } + + log.debug("Created offerID: {}", [_offerID]); + offer.save(); + } + + log.debug("Returning offer: {}", [_offerID]); + + return offer; +} + +export function getOrCreateOfferByID( + hypercertContract: Address, + fractionID: BigInt, + offerID: BigInt, +): Offer | null { + const _fractionID = getID(fractionID, hypercertContract); + const _offerID = _fractionID.concat("-".concat(offerID.toString())); + const offer = Offer.load(_offerID); + + if (offer == null) { + log.error("Offer with ID {} does not exist", [_offerID]); + } + + return offer; +} diff --git a/graph/subgraph.yaml b/graph/subgraph.yaml index ada9aab5..6b664dde 100644 --- a/graph/subgraph.yaml +++ b/graph/subgraph.yaml @@ -33,11 +33,9 @@ dataSources: handler: handleLeafClaimed - event: OwnershipTransferred(indexed address,indexed address) handler: handleOwnershipTransferred - - event: TransferBatch(indexed address,indexed address,indexed - address,uint256[],uint256[]) + - event: TransferBatch(indexed address,indexed address,indexed address,uint256[],uint256[]) handler: handleTransferBatch - - event: TransferSingle(indexed address,indexed address,indexed - address,uint256,uint256) + - event: TransferSingle(indexed address,indexed address,indexed address,uint256,uint256) handler: handleTransferSingle - event: URI(string,indexed uint256) handler: handleURI diff --git a/graph/tests/.latest.json b/graph/tests/.latest.json index ff6bf392..9bf8a349 100644 --- a/graph/tests/.latest.json +++ b/graph/tests/.latest.json @@ -1,4 +1,4 @@ { "version": "0.6.0", - "timestamp": 1698760525590 + "timestamp": 1699280746839 } diff --git a/graph/tests/hypercert-minter-burn.test.ts b/graph/tests/hypercert-minter-burn.test.ts new file mode 100644 index 00000000..09d35de4 --- /dev/null +++ b/graph/tests/hypercert-minter-burn.test.ts @@ -0,0 +1,189 @@ +import { + handleTransferSingle, + handleValueTransfer, + handleBatchValueTransfer, + handleTransferBatch, +} from "../src/hypercert-minter"; +import { + createBatchValueTransferEvent, + createTransferBatchEvent, + createTransferSingleEvent, + createValueTransferEvent, + getDefaultContractAddress, + ZERO_ADDRESS, + ZERO_TOKEN, +} from "./hypercert-minter-utils"; +import { Address, BigInt, ethereum } from "@graphprotocol/graph-ts"; +import { + assert, + describe, + test, + clearStore, + beforeAll, + createMockedFunction, + afterEach, +} from "matchstick-as/assembly/index"; + +export { handleTransferSingle, handleValueTransfer, handleBatchValueTransfer }; + +describe("Describe entity assertions", () => { + beforeAll(() => {}); + + afterEach(() => { + clearStore(); + }); + + test("TransferSingle and TransferValue for an existing token to zero address burns the fraction", () => { + let from = Address.fromString("0x0000000000000000000000000000000000000001"); + + let claimID = BigInt.fromI64(1); + let fromID = BigInt.fromI64(0); + let toID = BigInt.fromI64(1); + let units = BigInt.fromI64(10000); + + // Create fraction token + let valueTransferEvent = createValueTransferEvent( + claimID, + fromID, + toID, + units, + ); + + createMockedFunction( + getDefaultContractAddress(), + "ownerOf", + "ownerOf(uint256):(address)", + ) + .withArgs([ethereum.Value.fromUnsignedBigInt(toID)]) + .returns([ethereum.Value.fromAddress(from)]); + + createMockedFunction( + getDefaultContractAddress(), + "ownerOf", + "ownerOf(uint256):(address)", + ) + .withArgs([ethereum.Value.fromUnsignedBigInt(fromID)]) + .returns([ethereum.Value.fromAddress(from)]); + + handleValueTransfer(valueTransferEvent); + + let fractionId = getDefaultContractAddress().toHexString().concat("-1"); + + assert.fieldEquals("ClaimToken", fractionId, "owner", from.toHexString()); + assert.fieldEquals("ClaimToken", fractionId, "units", "10000"); + + // Handle 1155 transfer to zero address + let transferSingleEvent = createTransferSingleEvent( + from, + from, + ZERO_ADDRESS, + BigInt.fromI64(1), + BigInt.fromI64(1), + ); + + handleTransferSingle(transferSingleEvent); + + assert.fieldEquals( + "ClaimToken", + fractionId, + "owner", + ZERO_ADDRESS.toHexString(), + ); + assert.fieldEquals("ClaimToken", fractionId, "units", "10000"); + + // Handle hypercert units transfer + let valueTransferEvent2 = createValueTransferEvent( + claimID, + toID, + ZERO_TOKEN, + units, + ); + + handleValueTransfer(valueTransferEvent2); + + assert.fieldEquals( + "ClaimToken", + fractionId, + "owner", + ZERO_ADDRESS.toHexString(), + ); + assert.fieldEquals("ClaimToken", fractionId, "units", "0"); + }); + + test("TransferBatch and BatchTransferValue for an existing token to zero address burns the fraction", () => { + let from = Address.fromString("0x0000000000000000000000000000000000000001"); + + let claimID = BigInt.fromI64(1); + let fromID = BigInt.fromI64(0); + let toID = BigInt.fromI64(1); + let units = BigInt.fromI64(10000); + + // Create fraction token + let valueTransferEvent = createBatchValueTransferEvent( + [claimID], + [fromID], + [toID], + [units], + ); + + createMockedFunction( + getDefaultContractAddress(), + "ownerOf", + "ownerOf(uint256):(address)", + ) + .withArgs([ethereum.Value.fromUnsignedBigInt(toID)]) + .returns([ethereum.Value.fromAddress(from)]); + + createMockedFunction( + getDefaultContractAddress(), + "ownerOf", + "ownerOf(uint256):(address)", + ) + .withArgs([ethereum.Value.fromUnsignedBigInt(fromID)]) + .returns([ethereum.Value.fromAddress(from)]); + + handleBatchValueTransfer(valueTransferEvent); + + let fractionId = getDefaultContractAddress().toHexString().concat("-1"); + + assert.fieldEquals("ClaimToken", fractionId, "owner", from.toHexString()); + assert.fieldEquals("ClaimToken", fractionId, "units", "10000"); + + // Handle 1155 transfer to zero address + let transferBatchEvent = createTransferBatchEvent( + from, + from, + ZERO_ADDRESS, + [BigInt.fromI64(1)], + [BigInt.fromI64(1)], + ); + + handleTransferBatch(transferBatchEvent); + + assert.fieldEquals( + "ClaimToken", + fractionId, + "owner", + ZERO_ADDRESS.toHexString(), + ); + assert.fieldEquals("ClaimToken", fractionId, "units", "10000"); + + // Handle hypercert units transfer + let valueTransferEvent2 = createBatchValueTransferEvent( + [claimID], + [toID], + [ZERO_TOKEN], + [units], + ); + + handleBatchValueTransfer(valueTransferEvent2); + + assert.fieldEquals( + "ClaimToken", + fractionId, + "owner", + ZERO_ADDRESS.toHexString(), + ); + assert.fieldEquals("ClaimToken", fractionId, "units", "0"); + }); +}); diff --git a/graph/tests/hypercert-minter-claim.test.ts b/graph/tests/hypercert-minter-claim.test.ts index 38c403c0..b7a6e45a 100644 --- a/graph/tests/hypercert-minter-claim.test.ts +++ b/graph/tests/hypercert-minter-claim.test.ts @@ -20,7 +20,7 @@ describe("Describe entity assertions", () => { let claimStoredEvent = createClaimStoredEvent( BigInt.fromI64(1), "ipfs://exampleshash", - BigInt.fromI64(10000) + BigInt.fromI64(10000), ); handleClaimStored(claimStoredEvent); }); @@ -43,13 +43,13 @@ describe("Describe entity assertions", () => { "Claim", claimId, "creator", - "0xa16081f360e3847006db660bae1c6d1b2e17ec2a" + "0xa16081f360e3847006db660bae1c6d1b2e17ec2a", ); assert.fieldEquals( "Claim", claimId, "owner", - "0xa16081f360e3847006db660bae1c6d1b2e17ec2a" + "0xa16081f360e3847006db660bae1c6d1b2e17ec2a", ); assert.fieldEquals("Claim", claimId, "totalUnits", "10000"); }); diff --git a/graph/tests/hypercert-minter-utils.ts b/graph/tests/hypercert-minter-utils.ts index 53a64853..e1694735 100644 --- a/graph/tests/hypercert-minter-utils.ts +++ b/graph/tests/hypercert-minter-utils.ts @@ -1,5 +1,3 @@ -import { newMockEvent } from "matchstick-as"; -import { ethereum, Address, BigInt, Bytes } from "@graphprotocol/graph-ts"; import { AllowlistCreated, BatchValueTransfer, @@ -10,6 +8,13 @@ import { URI, ValueTransfer, } from "../generated/HypercertMinter/HypercertMinter"; +import { ethereum, Address, BigInt, Bytes } from "@graphprotocol/graph-ts"; +import { newMockEvent } from "matchstick-as"; + +export const ZERO_ADDRESS = Address.fromString( + "0x0000000000000000000000000000000000000000", +); +export const ZERO_TOKEN = BigInt.fromI32(0); export function getDefaultContractAddress(): Address { return Address.fromString("0x89205A3A3b2A69De6Dbf7f01ED13B2108B2c43e7"); @@ -28,7 +33,7 @@ export function buildZeroes(size: BigInt): BigInt[] { export function buildIDs( size: BigInt, - start: BigInt = BigInt.zero() + start: BigInt = BigInt.zero(), ): BigInt[] { let array: BigInt[] = []; for (let i = 0; i < size.toI32(); i++) { @@ -54,7 +59,7 @@ export function buildValues(size: BigInt): BigInt[] { export function createAllowlistCreatedEvent( tokenID: BigInt, - root: Bytes + root: Bytes, ): AllowlistCreated { let mockEvent = newMockEvent(); let parameters: ethereum.EventParam[] = new Array(); @@ -64,11 +69,11 @@ export function createAllowlistCreatedEvent( parameters.push( new ethereum.EventParam( "tokenID", - ethereum.Value.fromUnsignedBigInt(tokenID) - ) + ethereum.Value.fromUnsignedBigInt(tokenID), + ), ); parameters.push( - new ethereum.EventParam("root", ethereum.Value.fromFixedBytes(root)) + new ethereum.EventParam("root", ethereum.Value.fromFixedBytes(root)), ); let allowlistCreatedEvent = new AllowlistCreated( @@ -79,7 +84,7 @@ export function createAllowlistCreatedEvent( mockEvent.block, mockEvent.transaction, parameters, - mockEvent.receipt + mockEvent.receipt, ); return allowlistCreatedEvent; @@ -88,7 +93,7 @@ export function createAllowlistCreatedEvent( export function createClaimStoredEvent( claimID: BigInt, uri: string, - totalUnits: BigInt + totalUnits: BigInt, ): ClaimStored { let mockEvent = newMockEvent(); let parameters: ethereum.EventParam[] = new Array(); @@ -96,18 +101,18 @@ export function createClaimStoredEvent( parameters.push( new ethereum.EventParam( "claimID", - ethereum.Value.fromUnsignedBigInt(claimID) - ) + ethereum.Value.fromUnsignedBigInt(claimID), + ), ); parameters.push( - new ethereum.EventParam("uri", ethereum.Value.fromString(uri)) + new ethereum.EventParam("uri", ethereum.Value.fromString(uri)), ); parameters.push( new ethereum.EventParam( "totalUnits", - ethereum.Value.fromUnsignedBigInt(totalUnits) - ) + ethereum.Value.fromUnsignedBigInt(totalUnits), + ), ); let claimStoredEvent = new ClaimStored( @@ -118,7 +123,7 @@ export function createClaimStoredEvent( mockEvent.block, mockEvent.transaction, parameters, - mockEvent.receipt + mockEvent.receipt, ); return claimStoredEvent; @@ -126,7 +131,7 @@ export function createClaimStoredEvent( export function createLeafClaimedEvent( tokenID: BigInt, - leaf: Bytes + leaf: Bytes, ): LeafClaimed { let leafClaimedEvent = changetype(newMockEvent()); @@ -135,11 +140,11 @@ export function createLeafClaimedEvent( leafClaimedEvent.parameters.push( new ethereum.EventParam( "tokenID", - ethereum.Value.fromUnsignedBigInt(tokenID) - ) + ethereum.Value.fromUnsignedBigInt(tokenID), + ), ); leafClaimedEvent.parameters.push( - new ethereum.EventParam("leaf", ethereum.Value.fromFixedBytes(leaf)) + new ethereum.EventParam("leaf", ethereum.Value.fromFixedBytes(leaf)), ); return leafClaimedEvent; @@ -150,29 +155,39 @@ export function createTransferBatchEvent( from: Address, to: Address, ids: Array, - values: Array + values: Array, ): TransferBatch { - let transferBatchEvent = changetype(newMockEvent()); - - transferBatchEvent.parameters = new Array(); + let mockEvent = newMockEvent(); + let parameters: ethereum.EventParam[] = new Array(); - transferBatchEvent.parameters.push( - new ethereum.EventParam("operator", ethereum.Value.fromAddress(operator)) + parameters.push( + new ethereum.EventParam("operator", ethereum.Value.fromAddress(operator)), ); - transferBatchEvent.parameters.push( - new ethereum.EventParam("from", ethereum.Value.fromAddress(from)) + parameters.push( + new ethereum.EventParam("from", ethereum.Value.fromAddress(from)), ); - transferBatchEvent.parameters.push( - new ethereum.EventParam("to", ethereum.Value.fromAddress(to)) + parameters.push( + new ethereum.EventParam("to", ethereum.Value.fromAddress(to)), ); - transferBatchEvent.parameters.push( - new ethereum.EventParam("ids", ethereum.Value.fromUnsignedBigIntArray(ids)) + parameters.push( + new ethereum.EventParam("ids", ethereum.Value.fromUnsignedBigIntArray(ids)), ); - transferBatchEvent.parameters.push( + parameters.push( new ethereum.EventParam( "values", - ethereum.Value.fromUnsignedBigIntArray(values) - ) + ethereum.Value.fromUnsignedBigIntArray(values), + ), + ); + + let transferBatchEvent = new TransferBatch( + getDefaultContractAddress(), + mockEvent.logIndex, + mockEvent.transactionLogIndex, + mockEvent.logType, + mockEvent.block, + mockEvent.transaction, + parameters, + mockEvent.receipt, ); return transferBatchEvent; @@ -183,25 +198,25 @@ export function createTransferSingleEvent( from: Address, to: Address, id: BigInt, - value: BigInt + value: BigInt, ): TransferSingle { let mockEvent = newMockEvent(); let parameters: ethereum.EventParam[] = new Array(); parameters.push( - new ethereum.EventParam("operator", ethereum.Value.fromAddress(operator)) + new ethereum.EventParam("operator", ethereum.Value.fromAddress(operator)), ); parameters.push( - new ethereum.EventParam("from", ethereum.Value.fromAddress(from)) + new ethereum.EventParam("from", ethereum.Value.fromAddress(from)), ); parameters.push( - new ethereum.EventParam("to", ethereum.Value.fromAddress(to)) + new ethereum.EventParam("to", ethereum.Value.fromAddress(to)), ); parameters.push( - new ethereum.EventParam("id", ethereum.Value.fromUnsignedBigInt(id)) + new ethereum.EventParam("id", ethereum.Value.fromUnsignedBigInt(id)), ); parameters.push( - new ethereum.EventParam("value", ethereum.Value.fromUnsignedBigInt(value)) + new ethereum.EventParam("value", ethereum.Value.fromUnsignedBigInt(value)), ); let transferSingleEvent = new TransferSingle( @@ -212,7 +227,7 @@ export function createTransferSingleEvent( mockEvent.block, mockEvent.transaction, parameters, - mockEvent.receipt + mockEvent.receipt, ); return transferSingleEvent; @@ -224,20 +239,20 @@ export function createURIEvent(value: string, id: BigInt): URI { uriEvent.parameters = new Array(); uriEvent.parameters.push( - new ethereum.EventParam("value", ethereum.Value.fromString(value)) + new ethereum.EventParam("value", ethereum.Value.fromString(value)), ); uriEvent.parameters.push( - new ethereum.EventParam("id", ethereum.Value.fromUnsignedBigInt(id)) + new ethereum.EventParam("id", ethereum.Value.fromUnsignedBigInt(id)), ); return uriEvent; } export function createHypercertMinterUpgradedEvent( - implementation: Address + implementation: Address, ): HypercertMinterUpgraded { let hypercertMinterUpgradedEvent = changetype( - newMockEvent() + newMockEvent(), ); hypercertMinterUpgradedEvent.parameters = new Array(); @@ -245,8 +260,8 @@ export function createHypercertMinterUpgradedEvent( hypercertMinterUpgradedEvent.parameters.push( new ethereum.EventParam( "implementation", - ethereum.Value.fromAddress(implementation) - ) + ethereum.Value.fromAddress(implementation), + ), ); return hypercertMinterUpgradedEvent; @@ -256,7 +271,7 @@ export function createValueTransferEvent( claimID: BigInt, fromTokenID: BigInt, toTokenID: BigInt, - value: BigInt + value: BigInt, ): ValueTransfer { let mockEvent = newMockEvent(); let parameters: ethereum.EventParam[] = new Array(); @@ -264,24 +279,24 @@ export function createValueTransferEvent( parameters.push( new ethereum.EventParam( "claimID", - ethereum.Value.fromUnsignedBigInt(claimID) - ) + ethereum.Value.fromUnsignedBigInt(claimID), + ), ); parameters.push( new ethereum.EventParam( "fromTokenID", - ethereum.Value.fromUnsignedBigInt(fromTokenID) - ) + ethereum.Value.fromUnsignedBigInt(fromTokenID), + ), ); parameters.push( new ethereum.EventParam( "toTokenID", - ethereum.Value.fromUnsignedBigInt(toTokenID) - ) + ethereum.Value.fromUnsignedBigInt(toTokenID), + ), ); parameters.push( - new ethereum.EventParam("value", ethereum.Value.fromUnsignedBigInt(value)) + new ethereum.EventParam("value", ethereum.Value.fromUnsignedBigInt(value)), ); let valueTransferEvent = new ValueTransfer( @@ -292,7 +307,7 @@ export function createValueTransferEvent( mockEvent.block, mockEvent.transaction, parameters, - mockEvent.receipt + mockEvent.receipt, ); return valueTransferEvent; @@ -302,7 +317,7 @@ export function createBatchValueTransferEvent( claimIDs: BigInt[], fromTokenIDs: BigInt[], toTokenIDs: BigInt[], - values: BigInt[] + values: BigInt[], ): BatchValueTransfer { let mockEvent = newMockEvent(); let parameters: ethereum.EventParam[] = new Array(); @@ -310,26 +325,26 @@ export function createBatchValueTransferEvent( parameters.push( new ethereum.EventParam( "claimIDs", - ethereum.Value.fromUnsignedBigIntArray(claimIDs) - ) + ethereum.Value.fromUnsignedBigIntArray(claimIDs), + ), ); parameters.push( new ethereum.EventParam( "fromTokenIDs", - ethereum.Value.fromUnsignedBigIntArray(fromTokenIDs) - ) + ethereum.Value.fromUnsignedBigIntArray(fromTokenIDs), + ), ); parameters.push( new ethereum.EventParam( "toTokenIDs", - ethereum.Value.fromUnsignedBigIntArray(toTokenIDs) - ) + ethereum.Value.fromUnsignedBigIntArray(toTokenIDs), + ), ); parameters.push( new ethereum.EventParam( "values", - ethereum.Value.fromUnsignedBigIntArray(values) - ) + ethereum.Value.fromUnsignedBigIntArray(values), + ), ); let batchValueTransferEvent = new BatchValueTransfer( @@ -340,7 +355,7 @@ export function createBatchValueTransferEvent( mockEvent.block, mockEvent.transaction, parameters, - mockEvent.receipt + mockEvent.receipt, ); return batchValueTransferEvent; diff --git a/package.json b/package.json index 38706568..19c7c402 100644 --- a/package.json +++ b/package.json @@ -46,8 +46,13 @@ "type": "git", "url": "git+https://github.com/hypercerts-org/hypercerts.git" }, - "resolutions": { + "overrides": { "graphql": "^16.6.0", - "ethers": "^5.7.2" + "@hypercerts/contracts": { + "ethers": "6.8.0" + }, + "@hypercerts/frontend": { + "ethers": "5.7.2" + } } } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 531025b1..203d74fe 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -4,10 +4,6 @@ settings: autoInstallPeers: true excludeLinksFromLockfile: false -overrides: - graphql: ^16.6.0 - ethers: ^5.7.2 - importers: .: @@ -32,7 +28,14 @@ importers: version: 1.10.16 contracts: + dependencies: + hardhat: + specifier: ^2.18.3 + version: 2.18.3(ts-node@10.9.1)(typescript@4.9.5) devDependencies: + '@chainlink/contracts': + specifier: ^0.8.0 + version: 0.8.0(ethers@6.8.0) '@commitlint/cli': specifier: ^17.1.2 version: 17.8.1 @@ -41,40 +44,22 @@ importers: version: 17.8.1 '@dlsl/hardhat-markup': specifier: ^1.0.0-rc.7 - version: 1.0.0-rc.14(hardhat@2.13.1)(prettier@2.8.8) - '@ethersproject/abi': - specifier: ^5.7.0 - version: 5.7.0 - '@ethersproject/bytes': - specifier: ^5.7.0 - version: 5.7.0 - '@ethersproject/providers': - specifier: ^5.7.2 - version: 5.7.2 - '@nomicfoundation/hardhat-chai-matchers': - specifier: ^1.0.5 - version: 1.0.6(@nomiclabs/hardhat-ethers@2.2.3)(chai@4.3.10)(ethers@5.7.2)(hardhat@2.13.1) - '@nomicfoundation/hardhat-network-helpers': - specifier: ^1.0.7 - version: 1.0.9(hardhat@2.13.1) + version: 1.0.0-rc.14(hardhat@2.18.3)(prettier@2.8.8) + '@looksrare/contracts-libs': + specifier: ^3.4.0 + version: 3.4.0 '@nomicfoundation/hardhat-toolbox': - specifier: ^2.0.0 - version: 2.0.2(@ethersproject/abi@5.7.0)(@ethersproject/providers@5.7.2)(@nomicfoundation/hardhat-chai-matchers@1.0.6)(@nomicfoundation/hardhat-network-helpers@1.0.9)(@nomiclabs/hardhat-ethers@2.2.3)(@nomiclabs/hardhat-etherscan@3.1.7)(@typechain/ethers-v5@11.1.2)(@typechain/hardhat@9.1.0)(@types/chai@4.3.9)(@types/mocha@9.1.0)(@types/node@18.18.6)(chai@4.3.10)(ethers@5.7.2)(hardhat-gas-reporter@1.0.9)(hardhat@2.13.1)(solidity-coverage@0.8.5)(ts-node@10.9.1)(typechain@8.3.2)(typescript@4.9.5) - '@nomiclabs/hardhat-ethers': - specifier: ^2.2.1 - version: 2.2.3(ethers@5.7.2)(hardhat@2.13.1) - '@nomiclabs/hardhat-etherscan': - specifier: ^3.1.3 - version: 3.1.7(hardhat@2.13.1) - '@openzeppelin/hardhat-defender': - specifier: ^1.8.2 - version: 1.9.0(@nomiclabs/hardhat-ethers@2.2.3)(@nomiclabs/hardhat-etherscan@3.1.7)(ethers@5.7.2)(hardhat@2.13.1) + specifier: ^3.0.0 + version: 3.0.0(@nomicfoundation/hardhat-chai-matchers@2.0.2)(@nomicfoundation/hardhat-ethers@3.0.4)(@nomicfoundation/hardhat-network-helpers@1.0.9)(@nomicfoundation/hardhat-verify@1.1.1)(@typechain/ethers-v6@0.4.3)(@typechain/hardhat@8.0.3)(@types/chai@4.3.9)(@types/mocha@9.1.0)(@types/node@18.18.7)(chai@4.3.10)(ethers@6.8.0)(hardhat-gas-reporter@1.0.9)(hardhat@2.18.3)(solidity-coverage@0.8.5)(ts-node@10.9.1)(typechain@8.3.2)(typescript@4.9.5) + '@openzeppelin/contracts': + specifier: <5.0.0 + version: 4.9.3 '@openzeppelin/hardhat-upgrades': - specifier: ^1.28 - version: 1.28.0(@nomiclabs/hardhat-ethers@2.2.3)(@nomiclabs/hardhat-etherscan@3.1.7)(ethers@5.7.2)(hardhat@2.13.1) + specifier: 2.3.3 + version: 2.3.3(@nomicfoundation/hardhat-ethers@3.0.4)(@nomicfoundation/hardhat-verify@1.1.1)(ethers@6.8.0)(hardhat@2.18.3) '@primitivefi/hardhat-dodoc': specifier: ^0.2.3 - version: 0.2.3(hardhat@2.13.1)(squirrelly@8.0.8) + version: 0.2.3(hardhat@2.18.3)(squirrelly@8.0.8) '@rollup/plugin-commonjs': specifier: ^24.0.1 version: 24.1.0(rollup@4.1.4) @@ -87,42 +72,24 @@ importers: '@trivago/prettier-plugin-sort-imports': specifier: ^3.3.0 version: 3.4.0(prettier@2.8.8) - '@typechain/ethers-v5': - specifier: ^11.1.1 - version: 11.1.2(@ethersproject/abi@5.7.0)(@ethersproject/providers@5.7.2)(ethers@5.7.2)(typechain@8.3.2)(typescript@4.9.5) - '@typechain/hardhat': - specifier: ^9.0.0 - version: 9.1.0(@typechain/ethers-v6@0.5.1)(ethers@5.7.2)(hardhat@2.13.1)(typechain@8.3.2) - '@types/chai': - specifier: ^4.3.4 - version: 4.3.9 - '@types/mocha': - specifier: 9.1.0 - version: 9.1.0 '@types/node': specifier: ^18.11.11 - version: 18.18.6 + version: 18.18.7 '@typescript-eslint/eslint-plugin': specifier: ^5.38.0 version: 5.62.0(@typescript-eslint/parser@5.62.0)(eslint@8.52.0)(typescript@4.9.5) '@typescript-eslint/parser': specifier: ^5.38.0 version: 5.62.0(eslint@8.52.0)(typescript@4.9.5) - chai: - specifier: ^4.3.7 - version: 4.3.10 commitizen: specifier: ^4.2.5 - version: 4.3.0 - copyfiles: - specifier: ^2.4.1 - version: 2.4.1 + version: 4.3.0(typescript@4.9.5) cross-env: specifier: ^7.0.3 version: 7.0.3 cz-conventional-changelog: specifier: ^3.3.0 - version: 3.3.0 + version: 3.3.0(typescript@4.9.5) dotenv: specifier: ^16.0.2 version: 16.3.1 @@ -133,20 +100,14 @@ importers: specifier: ^8.5.0 version: 8.10.0(eslint@8.52.0) ethers: - specifier: ^5.7.2 - version: 5.7.2 - hardhat: - specifier: 2.13.1 - version: 2.13.1(ts-node@10.9.1)(typescript@4.9.5) + specifier: ^6.8.0 + version: 6.8.0 hardhat-abi-exporter: specifier: ^2.10.1 - version: 2.10.1(hardhat@2.13.1) - hardhat-gas-reporter: - specifier: ^1.0.9 - version: 1.0.9(hardhat@2.13.1) + version: 2.10.1(hardhat@2.18.3) hardhat-preprocessor: specifier: ^0.1.5 - version: 0.1.5(hardhat@2.13.1) + version: 0.1.5(hardhat@2.18.3) husky: specifier: ^8.0.1 version: 8.0.3 @@ -186,12 +147,12 @@ importers: solhint-plugin-prettier: specifier: ^0.0.5 version: 0.0.5(prettier-plugin-solidity@1.1.3)(prettier@2.8.8) - solidity-coverage: - specifier: ^0.8.2 - version: 0.8.5(hardhat@2.13.1) + solmate: + specifier: ^6.2.0 + version: 6.2.0 ts-node: specifier: ^10.9.1 - version: 10.9.1(@types/node@18.18.6)(typescript@4.9.5) + version: 10.9.1(@types/node@18.18.7)(typescript@4.9.5) typechain: specifier: ^8.3.1 version: 8.3.2(typescript@4.9.5) @@ -203,7 +164,7 @@ importers: devDependencies: '@cloudflare/workers-types': specifier: ^4.20230115.0 - version: 4.20231016.0 + version: 4.20231025.0 typescript: specifier: ^4.9.5 version: 4.9.5 @@ -220,23 +181,23 @@ importers: specifier: 0.8.11 version: 0.8.11 '@openzeppelin/defender-autotask-client': - specifier: ^1.48.0 - version: 1.49.0 + specifier: 1.50.0 + version: 1.50.0 '@openzeppelin/defender-autotask-utils': - specifier: ^1.48.0 - version: 1.49.0 + specifier: 1.50.0 + version: 1.50.0 '@openzeppelin/defender-base-client': - specifier: ^1.48.0 + specifier: 1.49.0 version: 1.49.0(debug@4.3.4) '@openzeppelin/defender-sentinel-client': - specifier: ^1.48.0 + specifier: 1.49.0 version: 1.49.0 '@openzeppelin/merkle-tree': specifier: ^1.0.2 version: 1.0.5 '@supabase/supabase-js': specifier: ^2.4.1 - version: 2.38.2 + version: 2.38.3 axios: specifier: ^1.2.6 version: 1.5.1(debug@4.3.4) @@ -244,7 +205,7 @@ importers: specifier: ^16.0.3 version: 16.3.1 ethers: - specifier: ^5.7.2 + specifier: 5.7.2 version: 5.7.2 node-fetch: specifier: ^3.3.0 @@ -252,7 +213,7 @@ importers: devDependencies: '@types/node': specifier: ^18.11.18 - version: 18.18.6 + version: 18.18.7 rimraf: specifier: ^5.0.5 version: 5.0.5 @@ -264,7 +225,7 @@ importers: version: 9.5.0(typescript@4.9.5)(webpack@5.89.0) ts-node: specifier: ^10.9.1 - version: 10.9.1(@types/node@18.18.6)(typescript@4.9.5) + version: 10.9.1(@types/node@18.18.7)(typescript@4.9.5) tsx: specifier: ^3.14.0 version: 3.14.0 @@ -282,13 +243,13 @@ importers: dependencies: '@docusaurus/core': specifier: ^2.4.1 - version: 2.4.3(@docusaurus/types@2.4.3)(react-dom@18.2.0)(react@18.2.0)(typescript@4.9.5) + version: 2.4.3(@docusaurus/types@2.4.3)(eslint@8.52.0)(react-dom@18.2.0)(react@18.2.0)(typescript@4.9.5) '@docusaurus/preset-classic': specifier: ^2.4.1 - version: 2.4.3(@algolia/client-search@4.20.0)(react-dom@18.2.0)(react@18.2.0)(search-insights@2.9.0)(typescript@4.9.5) + version: 2.4.3(@algolia/client-search@4.20.0)(eslint@8.52.0)(react-dom@18.2.0)(react@18.2.0)(search-insights@2.9.0)(typescript@4.9.5) '@docusaurus/theme-mermaid': specifier: ^2.4.1 - version: 2.4.3(react-dom@18.2.0)(react@18.2.0)(typescript@4.9.5) + version: 2.4.3(eslint@8.52.0)(react-dom@18.2.0)(react@18.2.0)(typescript@4.9.5) '@mdx-js/react': specifier: ^1.6.22 version: 1.6.22(react@18.2.0) @@ -314,6 +275,9 @@ importers: specifier: ^18.2.0 version: 18.2.0(react@18.2.0) devDependencies: + '@docusaurus/eslint-plugin': + specifier: ^2.4.1 + version: 2.4.3(eslint@8.52.0)(typescript@4.9.5) '@docusaurus/module-type-aliases': specifier: ^2.4.1 version: 2.4.3(react-dom@18.2.0)(react@18.2.0) @@ -331,34 +295,34 @@ importers: version: 3.8.6(graphql@16.8.1)(react-dom@18.2.0)(react@18.2.0) '@celo/rainbowkit-celo': specifier: ^1.1.0 - version: 1.1.0(@rainbow-me/rainbowkit@1.0.8)(react@18.2.0)(typescript@5.1.6)(viem@1.5.3)(wagmi@1.3.9)(zod@3.22.4) + version: 1.1.0(@rainbow-me/rainbowkit@1.2.0)(react@18.2.0)(typescript@5.1.6)(viem@1.18.4)(wagmi@1.4.5)(zod@3.22.4) '@emotion/react': specifier: ^11.10.5 - version: 11.11.1(@types/react@18.2.31)(react@18.2.0) + version: 11.11.1(@types/react@18.2.33)(react@18.2.0) '@emotion/styled': specifier: ^11.10.5 - version: 11.11.0(@emotion/react@11.11.1)(@types/react@18.2.31)(react@18.2.0) + version: 11.11.0(@emotion/react@11.11.1)(@types/react@18.2.33)(react@18.2.0) '@graphprotocol/client-cli': specifier: ^2.2.16 - version: 2.2.22(@babel/core@7.23.2)(@envelop/core@3.0.6)(@graphql-mesh/cross-helpers@0.3.4)(@graphql-mesh/store@0.93.1)(@graphql-mesh/types@0.93.2)(@graphql-mesh/utils@0.93.2)(@graphql-tools/delegate@9.0.35)(@graphql-tools/merge@8.4.2)(@graphql-tools/utils@9.2.1)(@graphql-tools/wrap@9.4.2)(@types/node@18.18.6)(graphql-tag@2.12.6)(graphql@16.8.1)(react-native@0.72.6) + version: 2.2.22(@babel/core@7.23.2)(@envelop/core@3.0.6)(@graphql-mesh/cross-helpers@0.3.4)(@graphql-mesh/store@0.93.1)(@graphql-mesh/types@0.93.2)(@graphql-mesh/utils@0.93.2)(@graphql-tools/delegate@9.0.35)(@graphql-tools/merge@8.4.2)(@graphql-tools/utils@9.2.1)(@graphql-tools/wrap@9.4.2)(@types/node@18.18.7)(graphql-tag@2.12.6)(graphql@16.8.1)(react-native@0.72.6) '@hypercerts-org/contracts': - specifier: 0.8.11 - version: 0.8.11 + specifier: 0.9.0 + version: 0.9.0(typescript@5.1.6) '@hypercerts-org/observabletreemap': specifier: 'workspace: *' version: link:../vendor/observabletreemap '@hypercerts-org/sdk': - specifier: 0.8.16 - version: 0.8.16(@envelop/core@3.0.6)(@ethersproject/abi@5.7.0)(@ethersproject/providers@5.7.2)(@graphql-tools/delegate@9.0.35)(@graphql-tools/merge@8.4.2)(@graphql-tools/utils@9.2.1)(@graphql-tools/wrap@9.4.2)(@types/node@18.18.6)(node-fetch@3.3.2)(react-dom@18.2.0)(react@18.2.0)(tslib@2.6.2)(typescript@5.1.6)(uint8arraylist@2.4.3) + specifier: 1.0.0-alpha.6 + version: 1.0.0-alpha.6(@envelop/core@3.0.6)(@graphql-tools/delegate@9.0.35)(@graphql-tools/merge@8.4.2)(@graphql-tools/utils@9.2.1)(@graphql-tools/wrap@9.4.2)(@types/node@18.18.7)(node-fetch@3.3.2)(react-dom@18.2.0)(react@18.2.0)(tslib@2.6.2)(typescript@5.1.6)(uint8arraylist@2.4.3)(zod@3.22.4) '@mui/icons-material': specifier: ^5.11.9 - version: 5.14.14(@mui/material@5.14.14)(@types/react@18.2.31)(react@18.2.0) + version: 5.14.15(@mui/material@5.14.15)(@types/react@18.2.33)(react@18.2.0) '@mui/material': specifier: ^5.11.2 - version: 5.14.14(@emotion/react@11.11.1)(@emotion/styled@11.11.0)(@types/react@18.2.31)(react-dom@18.2.0)(react@18.2.0) + version: 5.14.15(@emotion/react@11.11.1)(@emotion/styled@11.11.0)(@types/react@18.2.33)(react-dom@18.2.0)(react@18.2.0) '@mui/x-date-pickers': specifier: ^5.0.12 - version: 5.0.20(@emotion/react@11.11.1)(@emotion/styled@11.11.0)(@mui/material@5.14.14)(@mui/system@5.14.14)(@types/react@18.2.31)(dayjs@1.11.10)(react-dom@18.2.0)(react@18.2.0) + version: 5.0.20(@emotion/react@11.11.1)(@emotion/styled@11.11.0)(@mui/material@5.14.15)(@mui/system@5.14.15)(@types/react@18.2.33)(dayjs@1.11.10)(react-dom@18.2.0)(react@18.2.0) '@next/eslint-plugin-next': specifier: ^13.4.12 version: 13.5.6 @@ -375,17 +339,17 @@ importers: specifier: ^1.0.284 version: 1.0.333(next@13.5.6)(react-dom@18.2.0)(react@18.2.0) '@rainbow-me/rainbowkit': - specifier: 1.0.8 - version: 1.0.8(@types/react@18.2.31)(react-dom@18.2.0)(react@18.2.0)(viem@1.5.3)(wagmi@1.3.9) + specifier: 1.2.0 + version: 1.2.0(@types/react@18.2.33)(react-dom@18.2.0)(react@18.2.0)(viem@1.18.4)(wagmi@1.4.5) '@sentry/nextjs': specifier: ^7.73.0 - version: 7.74.1(next@13.5.6)(react@18.2.0)(webpack@5.89.0) + version: 7.75.1(next@13.5.6)(react@18.2.0)(webpack@5.89.0) '@sentry/utils': specifier: ^7.73.0 - version: 7.74.1 + version: 7.75.1 '@supabase/supabase-js': specifier: ^2.1.2 - version: 2.38.2 + version: 2.38.3 '@tanstack/react-query': specifier: ^4.36.1 version: 4.36.1(react-dom@18.2.0)(react-native@0.72.6)(react@18.2.0) @@ -411,17 +375,17 @@ importers: specifier: ^16.0.3 version: 16.3.1 ethers: - specifier: ^5.7.2 + specifier: 5.7.2 version: 5.7.2 formik: specifier: ^2.2.9 version: 2.4.5(react@18.2.0) formik-mui: specifier: ^5.0.0-alpha.0 - version: 5.0.0-alpha.0(@emotion/react@11.11.1)(@emotion/styled@11.11.0)(@mui/material@5.14.14)(formik@2.4.5)(react@18.2.0)(tiny-warning@1.0.3) + version: 5.0.0-alpha.0(@emotion/react@11.11.1)(@emotion/styled@11.11.0)(@mui/material@5.14.15)(formik@2.4.5)(react@18.2.0)(tiny-warning@1.0.3) formik-mui-x-date-pickers: specifier: ^0.0.1 - version: 0.0.1(@emotion/react@11.11.1)(@emotion/styled@11.11.0)(@mui/material@5.14.14)(@mui/system@5.14.14)(@mui/x-date-pickers@5.0.20)(formik@2.4.5)(react@18.2.0)(tiny-warning@1.0.3) + version: 0.0.1(@emotion/react@11.11.1)(@emotion/styled@11.11.0)(@mui/material@5.14.15)(@mui/system@5.14.15)(@mui/x-date-pickers@5.0.20)(formik@2.4.5)(react@18.2.0)(tiny-warning@1.0.3) graphql: specifier: ^16.6.0 version: 16.8.1 @@ -442,7 +406,7 @@ importers: version: 5.4.1 primereact: specifier: ^9.6.0 - version: 9.6.3(@types/react@18.2.31)(react-dom@18.2.0)(react@18.2.0) + version: 9.6.3(@types/react@18.2.33)(react-dom@18.2.0)(react@18.2.0) qs: specifier: ^6.11.0 version: 6.11.2 @@ -460,7 +424,7 @@ importers: version: 14.2.3(react@18.2.0) react-markdown: specifier: ^8.0.7 - version: 8.0.7(@types/react@18.2.31)(react@18.2.0) + version: 8.0.7(@types/react@18.2.33)(react@18.2.0) react-toastify: specifier: ^9.1.1 version: 9.1.3(react-dom@18.2.0)(react@18.2.0) @@ -471,11 +435,11 @@ importers: specifier: ^14.0.1 version: 14.2.1 viem: - specifier: 1.5.3 - version: 1.5.3(typescript@5.1.6)(zod@3.22.4) + specifier: 1.18.4 + version: 1.18.4(typescript@5.1.6)(zod@3.22.4) wagmi: - specifier: 1.3.9 - version: 1.3.9(@types/react@18.2.31)(react-dom@18.2.0)(react-native@0.72.6)(react@18.2.0)(typescript@5.1.6)(viem@1.5.3)(zod@3.22.4) + specifier: 1.4.5 + version: 1.4.5(@types/react@18.2.33)(react-dom@18.2.0)(react-native@0.72.6)(react@18.2.0)(typescript@5.1.6)(viem@1.18.4)(zod@3.22.4) yup: specifier: ^0.32.11 version: 0.32.11 @@ -494,7 +458,7 @@ importers: version: 14.5.1(@testing-library/dom@9.3.3) '@types/node': specifier: ^18.0.0 - version: 18.18.6 + version: 18.18.7 '@types/papaparse': specifier: ^5.3.7 version: 5.3.10 @@ -503,7 +467,7 @@ importers: version: 6.9.9 '@types/react': specifier: ^18.0.14 - version: 18.2.31 + version: 18.2.33 '@types/react-dom': specifier: ^18.0.5 version: 18.2.14 @@ -530,7 +494,7 @@ importers: version: 1.1.7 jest: specifier: ^29.5.0 - version: 29.7.0(@types/node@18.18.6)(ts-node@10.9.1) + version: 29.7.0(@types/node@18.18.7)(ts-node@10.9.1) jest-environment-jsdom: specifier: ^29.5.0 version: 29.7.0 @@ -542,7 +506,7 @@ importers: devDependencies: '@graphprotocol/graph-cli': specifier: 0.60.0 - version: 0.60.0(@types/node@18.18.6)(node-fetch@3.3.2)(typescript@4.9.5) + version: 0.60.0(@types/node@18.18.7)(node-fetch@3.3.2)(typescript@4.9.5) '@graphprotocol/graph-ts': specifier: 0.31.0 version: 0.31.0 @@ -556,44 +520,44 @@ importers: sdk: dependencies: '@ethereum-attestation-service/eas-sdk': - specifier: ^0.28.3 - version: 0.28.3(@ethersproject/abi@5.7.0)(@ethersproject/providers@5.7.2)(ts-node@10.9.1)(typescript@4.9.5) + specifier: 1.2.2-beta.0 + version: 1.2.2-beta.0(ts-node@10.9.1)(typescript@5.1.6) '@ethersproject/abstract-signer': specifier: ^5.7.0 version: 5.7.0 '@graphprotocol/client-add-source-name': specifier: ^1.0.16 - version: 1.0.20(@graphql-mesh/types@0.95.7)(@graphql-tools/delegate@9.0.35)(@graphql-tools/utils@9.2.1)(@graphql-tools/wrap@9.4.2)(graphql@16.8.1) + version: 1.0.20(@graphql-mesh/types@0.95.8)(@graphql-tools/delegate@9.0.35)(@graphql-tools/utils@9.2.1)(@graphql-tools/wrap@9.4.2)(graphql@16.8.1) '@graphprotocol/client-polling-live': specifier: ^2.0.0 version: 2.0.0(@envelop/core@3.0.6)(@graphql-tools/merge@9.0.0)(graphql@16.8.1) '@graphql-mesh/cache-localforage': specifier: ^0.95.7 - version: 0.95.7(@graphql-mesh/types@0.95.7)(@graphql-mesh/utils@0.95.7)(graphql@16.8.1)(tslib@2.6.2) + version: 0.95.8(@graphql-mesh/types@0.95.8)(@graphql-mesh/utils@0.95.8)(graphql@16.8.1)(tslib@2.6.2) '@graphql-mesh/cross-helpers': specifier: ^0.4.1 version: 0.4.1(@graphql-tools/utils@9.2.1)(graphql@16.8.1) '@graphql-mesh/graphql': specifier: ^0.95.7 - version: 0.95.7(@graphql-mesh/cross-helpers@0.4.1)(@graphql-mesh/store@0.95.7)(@graphql-mesh/types@0.95.7)(@graphql-mesh/utils@0.95.7)(@graphql-tools/utils@9.2.1)(@types/node@18.18.6)(graphql@16.8.1)(react-dom@18.2.0)(react@18.2.0)(tslib@2.6.2) + version: 0.95.8(@graphql-mesh/cross-helpers@0.4.1)(@graphql-mesh/store@0.95.8)(@graphql-mesh/types@0.95.8)(@graphql-mesh/utils@0.95.8)(@graphql-tools/utils@9.2.1)(@types/node@18.18.7)(graphql@16.8.1)(react-dom@18.2.0)(react@18.2.0)(tslib@2.6.2) '@graphql-mesh/http': specifier: ^0.96.13 - version: 0.96.13(@graphql-mesh/cross-helpers@0.4.1)(@graphql-mesh/runtime@0.96.12)(@graphql-mesh/types@0.95.7)(@graphql-mesh/utils@0.95.7)(graphql@16.8.1)(tslib@2.6.2) + version: 0.96.14(@graphql-mesh/cross-helpers@0.4.1)(@graphql-mesh/runtime@0.96.13)(@graphql-mesh/types@0.95.8)(@graphql-mesh/utils@0.95.8)(graphql@16.8.1)(tslib@2.6.2) '@graphql-mesh/merger-bare': specifier: ^0.95.7 - version: 0.95.7(@graphql-mesh/store@0.95.7)(@graphql-mesh/types@0.95.7)(@graphql-mesh/utils@0.95.7)(@graphql-tools/utils@9.2.1)(graphql@16.8.1)(tslib@2.6.2) + version: 0.95.8(@graphql-mesh/store@0.95.8)(@graphql-mesh/types@0.95.8)(@graphql-mesh/utils@0.95.8)(@graphql-tools/utils@9.2.1)(graphql@16.8.1)(tslib@2.6.2) '@graphql-mesh/runtime': specifier: ^0.96.12 - version: 0.96.12(@graphql-mesh/cross-helpers@0.4.1)(@graphql-mesh/types@0.95.7)(@graphql-mesh/utils@0.95.7)(@graphql-tools/utils@9.2.1)(graphql@16.8.1)(tslib@2.6.2) + version: 0.96.13(@graphql-mesh/cross-helpers@0.4.1)(@graphql-mesh/types@0.95.8)(@graphql-mesh/utils@0.95.8)(@graphql-tools/utils@9.2.1)(graphql@16.8.1)(tslib@2.6.2) '@graphql-mesh/store': specifier: ^0.95.7 - version: 0.95.7(@graphql-mesh/cross-helpers@0.4.1)(@graphql-mesh/types@0.95.7)(@graphql-mesh/utils@0.95.7)(@graphql-tools/utils@9.2.1)(graphql@16.8.1)(tslib@2.6.2) + version: 0.95.8(@graphql-mesh/cross-helpers@0.4.1)(@graphql-mesh/types@0.95.8)(@graphql-mesh/utils@0.95.8)(@graphql-tools/utils@9.2.1)(graphql@16.8.1)(tslib@2.6.2) '@graphql-mesh/types': specifier: ^0.95.7 - version: 0.95.7(@graphql-mesh/store@0.95.7)(@graphql-tools/utils@9.2.1)(graphql@16.8.1)(tslib@2.6.2) + version: 0.95.8(@graphql-mesh/store@0.95.8)(@graphql-tools/utils@9.2.1)(graphql@16.8.1)(tslib@2.6.2) '@graphql-mesh/utils': specifier: ^0.95.7 - version: 0.95.7(@graphql-mesh/cross-helpers@0.4.1)(@graphql-mesh/types@0.95.7)(@graphql-tools/utils@9.2.1)(graphql@16.8.1)(tslib@2.6.2) + version: 0.95.8(@graphql-mesh/cross-helpers@0.4.1)(@graphql-mesh/types@0.95.8)(@graphql-tools/utils@9.2.1)(graphql@16.8.1)(tslib@2.6.2) '@graphql-typed-document-node/core': specifier: ^3.2.0 version: 3.2.0(graphql@16.8.1) @@ -605,7 +569,7 @@ importers: version: 1.0.5 '@whatwg-node/fetch': specifier: ^0.9.13 - version: 0.9.13 + version: 0.9.14 ajv: specifier: ^8.11.2 version: 8.12.0 @@ -616,7 +580,7 @@ importers: specifier: ^16.0.3 version: 16.3.1 ethers: - specifier: ^5.7.2 + specifier: 5.7.2 version: 5.7.2 graphql: specifier: ^16.6.0 @@ -624,9 +588,6 @@ importers: ipfs-core: specifier: ^0.17.0 version: 0.17.0(uint8arraylist@2.4.3) - jest: - specifier: ^29.3.1 - version: 29.7.0(@types/node@18.18.6)(ts-node@10.9.1) loglevel: specifier: ^1.8.1 version: 1.8.1 @@ -636,6 +597,9 @@ importers: nft.storage: specifier: ^7.1.1 version: 7.1.1(node-fetch@3.3.2) + viem: + specifier: ^1.18.4 + version: 1.18.4(typescript@5.1.6)(zod@3.22.4) web3.storage: specifier: ^4.5.5 version: 4.5.5(node-fetch@3.3.2) @@ -654,7 +618,7 @@ importers: version: 8.2.0 '@graphprotocol/client-cli': specifier: ^3.0.0 - version: 3.0.0(@babel/core@7.23.2)(@envelop/core@3.0.6)(@graphql-mesh/cross-helpers@0.4.1)(@graphql-mesh/store@0.95.7)(@graphql-mesh/types@0.95.7)(@graphql-mesh/utils@0.95.7)(@graphql-tools/delegate@9.0.35)(@graphql-tools/merge@9.0.0)(@graphql-tools/utils@9.2.1)(@graphql-tools/wrap@9.4.2)(@types/node@18.18.6)(graphql-tag@2.12.6)(graphql@16.8.1)(react-native@0.72.6) + version: 3.0.0(@babel/core@7.23.2)(@envelop/core@3.0.6)(@graphql-mesh/cross-helpers@0.4.1)(@graphql-mesh/store@0.95.8)(@graphql-mesh/types@0.95.8)(@graphql-mesh/utils@0.95.8)(@graphql-tools/delegate@9.0.35)(@graphql-tools/merge@9.0.0)(@graphql-tools/utils@9.2.1)(@graphql-tools/wrap@9.4.2)(@types/node@18.18.7)(graphql-tag@2.12.6)(graphql@16.8.1)(react-native@0.72.6) '@jest/globals': specifier: ^29.7.0 version: 29.7.0 @@ -676,12 +640,21 @@ importers: '@types/jest': specifier: ^29.2.5 version: 29.5.6 + '@types/mocha': + specifier: 9.1.0 + version: 9.1.0 '@types/node': specifier: ^18.11.17 - version: 18.18.6 + version: 18.18.7 '@types/sinon': specifier: ^10.0.15 version: 10.0.20 + '@viem/anvil': + specifier: ^0.0.6 + version: 0.0.6 + abitype: + specifier: ^0.10.2 + version: 0.10.2(typescript@5.1.6)(zod@3.22.4) babel-jest: specifier: ^29.7.0 version: 29.7.0(@babel/core@7.23.2) @@ -699,19 +672,22 @@ importers: version: 0.17.19 ethereum-waffle: specifier: ^4.0.10 - version: 4.0.10(@ensdomains/ens@0.4.5)(@ensdomains/resolver@0.2.4)(@ethersproject/abi@5.7.0)(@ethersproject/providers@5.7.2)(ethers@5.7.2)(typescript@4.9.5) + version: 4.0.10(@ensdomains/ens@0.4.5)(@ensdomains/resolver@0.2.4)(@ethersproject/abi@5.7.0)(@ethersproject/providers@5.7.2)(ethers@5.7.2)(typescript@5.1.6) it-all: specifier: ^2.0.0 version: 2.0.1 + jest: + specifier: ^29.3.1 + version: 29.7.0(@types/node@18.18.7)(ts-node@10.9.1) jest-extended: specifier: ^4.0.0 version: 4.0.2(jest@29.7.0) + jest-fetch-mock: + specifier: ^3.0.3 + version: 3.0.3 json-schema-to-typescript: specifier: ^12.0.0 version: 12.0.0 - msw: - specifier: ^1.2.1 - version: 1.3.2(typescript@4.9.5) nyc: specifier: ^15.1.0 version: 15.1.0 @@ -723,7 +699,7 @@ importers: version: 2.0.0(rollup@3.29.4) rollup-plugin-dts: specifier: ^5.2.0 - version: 5.3.1(rollup@3.29.4)(typescript@4.9.5) + version: 5.3.1(rollup@3.29.4)(typescript@5.1.6) rollup-plugin-esbuild: specifier: ^5.0.0 version: 5.0.0(esbuild@0.17.19)(rollup@3.29.4) @@ -738,7 +714,7 @@ importers: version: 15.2.0 ts-jest: specifier: ^29.0.3 - version: 29.1.1(@babel/core@7.23.2)(babel-jest@29.7.0)(esbuild@0.17.19)(jest@29.7.0)(typescript@4.9.5) + version: 29.1.1(@babel/core@7.23.2)(babel-jest@29.7.0)(esbuild@0.17.19)(jest@29.7.0)(typescript@5.1.6) ts-jest-resolver: specifier: ^2.0.0 version: 2.0.1 @@ -747,7 +723,7 @@ importers: version: 10.0.0(mocha@10.2.0) ts-node: specifier: ^10.9.1 - version: 10.9.1(@types/node@18.18.6)(typescript@4.9.5) + version: 10.9.1(@types/node@18.18.7)(typescript@5.1.6) tslib: specifier: ^2.5.0 version: 2.6.2 @@ -756,16 +732,16 @@ importers: version: 3.14.0 typedoc: specifier: ^0.23.25 - version: 0.23.28(typescript@4.9.5) + version: 0.23.28(typescript@5.1.6) typedoc-plugin-markdown: specifier: ^3.14.0 - version: 3.16.0(typedoc@0.23.28) + version: 3.17.0(typedoc@0.23.28) typedoc-plugin-missing-exports: specifier: ^2.0.0 version: 2.1.0(typedoc@0.23.28) typescript: - specifier: ^4.9.0 - version: 4.9.5 + specifier: 5.1.6 + version: 5.1.6 vendor/observabletreemap: dependencies: @@ -778,7 +754,6 @@ packages: /@aashutoshrathi/word-wrap@1.2.6: resolution: {integrity: sha512-1Yjs2SvM8TflER/OD3cOjhWWOZb58A2t7wpE2S9XfBYTiIl+XFhQG2bjy4Pu1I+EAlCNUzRDYDdFwFYUKvXcIA==} engines: {node: '>=0.10.0'} - dev: true /@achingbrain/ip-address@8.1.0: resolution: {integrity: sha512-Zus4vMKVRDm+R1o0QJNhD0PD/8qRGO3Zx8YPsFG5lANt5utVtGg3iHVGBSAF80TfQmhi8rP+Kg/OigdxY0BXHw==} @@ -792,7 +767,7 @@ packages: resolution: {integrity: sha512-rU4G75TEOTIPlkeDnPEVwx/VmMMFta42kY2SMmVobRkrtNLnxtU08Yhriu6tSBc9oO0wXdfNNeuLnNnEnL7w/A==} dependencies: '@achingbrain/ssdp': 4.0.6 - '@libp2p/logger': 3.0.3 + '@libp2p/logger': 3.0.4 default-gateway: 7.2.2 err-code: 3.0.1 it-first: 3.0.3 @@ -816,8 +791,16 @@ packages: resolution: {integrity: sha512-/62yikz7NLScCGAAST5SHdnjaDJQBDq0M2muyRTpf2VQhw6StBg2ALiu73zSJQ4fMVLA+0uBhBHAle7Wg+2kSg==} dev: true + /@adraffy/ens-normalize@1.10.0: + resolution: {integrity: sha512-nA9XHtlAkYfJxY7bce8DcN7eKxWWCWkU+1GR9d+U6MbNpfwQp8TI7vqOsBsMcHoT4mBu2kypKoSKnghEzOOq5Q==} + /@adraffy/ens-normalize@1.9.0: resolution: {integrity: sha512-iowxq3U30sghZotgl4s/oJRci6WPBfNO5YYgk2cIOMCHr3LeGPcsZjCEr+33Q4N+oV3OABDAtA+pyvWjbvBifQ==} + dev: true + + /@adraffy/ens-normalize@1.9.4: + resolution: {integrity: sha512-UK0bHA7hh9cR39V+4gl2/NnBBjoXIxkuWAPCaY4X7fbH4L/azIi7ilWOCjMUYfpJgraLUAqkRi2BqrjME8Rynw==} + dev: false /@algolia/autocomplete-core@1.9.3(@algolia/client-search@4.20.0)(algoliasearch@4.20.0)(search-insights@2.9.0): resolution: {integrity: sha512-009HdfugtGCdC4JdXUbVJClA0q0zh24yyePn+KUGk3rP7j8FEe/m5Yo/z65gn6nP/cM39PxpzqKrL7A6fP6PPw==} @@ -967,7 +950,7 @@ packages: /@apollo/client@3.8.6(graphql@16.8.1)(react-dom@18.2.0)(react@18.2.0): resolution: {integrity: sha512-FnHg3vhQP8tQzgBs6oTJCFFIbovelDGYujj6MK7CJneiHf62TJstCIO0Ot4A1h7XrgFEtgl8a/OgajQWqrTuYw==} peerDependencies: - graphql: ^16.6.0 + graphql: ^14.0.0 || ^15.0.0 || ^16.0.0 graphql-ws: ^5.5.5 react: ^16.8.0 || ^17.0.0 || ^18.0.0 react-dom: ^16.8.0 || ^17.0.0 || ^18.0.0 @@ -983,8 +966,8 @@ packages: optional: true dependencies: '@graphql-typed-document-node/core': 3.2.0(graphql@16.8.1) - '@wry/context': 0.7.3 - '@wry/equality': 0.5.6 + '@wry/context': 0.7.4 + '@wry/equality': 0.5.7 '@wry/trie': 0.4.3 graphql: 16.8.1 graphql-tag: 2.12.6(graphql@16.8.1) @@ -1016,7 +999,7 @@ packages: resolution: {integrity: sha512-9anThAaj1dQr6IGmzBMcfzOQKTa5artjuPmw8NYK/fiGEMjADbSguBY2FMDykt+QhilR3wc9VA/3yVju7JHg7Q==} hasBin: true peerDependencies: - graphql: ^16.6.0 + graphql: '*' dependencies: '@babel/core': 7.23.2 '@babel/generator': 7.23.0 @@ -1500,7 +1483,7 @@ packages: '@babel/core': ^7.0.0-0 dependencies: '@babel/core': 7.12.9 - '@babel/helper-plugin-utils': 7.10.4 + '@babel/helper-plugin-utils': 7.22.5 '@babel/plugin-syntax-object-rest-spread': 7.8.3(@babel/core@7.12.9) '@babel/plugin-transform-parameters': 7.22.15(@babel/core@7.12.9) dev: false @@ -1565,6 +1548,7 @@ packages: dependencies: '@babel/core': 7.23.2 '@babel/helper-plugin-utils': 7.22.5 + dev: true /@babel/plugin-syntax-class-properties@7.12.13(@babel/core@7.23.2): resolution: {integrity: sha512-fm4idjKla0YahUNgFNLCB0qySdsoPiZP3iQE3rky0mBUtMZ23yDJ9SJdg6dXTSDnulOVqiF3Hgr9nbXvXTQZYA==} @@ -2605,12 +2589,13 @@ packages: /@bcoe/v8-coverage@0.2.3: resolution: {integrity: sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw==} + dev: true /@braintree/sanitize-url@6.0.4: resolution: {integrity: sha512-s3jaWicZd0pkP0jf5ysyHUI/RE7MHos6qlToFcGWXVp+ykHOy77OUMrfbgJ9it2C5bow7OIQwYYaHjk9XlBQ2A==} dev: false - /@celo/rainbowkit-celo@1.1.0(@rainbow-me/rainbowkit@1.0.8)(react@18.2.0)(typescript@5.1.6)(viem@1.5.3)(wagmi@1.3.9)(zod@3.22.4): + /@celo/rainbowkit-celo@1.1.0(@rainbow-me/rainbowkit@1.2.0)(react@18.2.0)(typescript@5.1.6)(viem@1.18.4)(wagmi@1.4.5)(zod@3.22.4): resolution: {integrity: sha512-/G4HFhJNwUk6uU1yqGfQ/LIoNg9UAA4BUcEvFdd0M3DImnKlhodNLUdCmzqv96sjc/I7tMJqBeTnmbhwXdlsjQ==} peerDependencies: '@rainbow-me/rainbowkit': '>=1.0.2 && <=2.0.0' @@ -2618,10 +2603,10 @@ packages: wagmi: '>=1.0.0 && <=2.0.0' dependencies: '@metamask/providers': 11.1.2 - '@rainbow-me/rainbowkit': 1.0.8(@types/react@18.2.31)(react-dom@18.2.0)(react@18.2.0)(viem@1.5.3)(wagmi@1.3.9) - '@wagmi/connectors': 2.6.6(@wagmi/chains@1.6.0)(react@18.2.0)(typescript@5.1.6)(viem@1.5.3)(zod@3.22.4) - viem: 1.5.3(typescript@5.1.6)(zod@3.22.4) - wagmi: 1.3.9(@types/react@18.2.31)(react-dom@18.2.0)(react-native@0.72.6)(react@18.2.0)(typescript@5.1.6)(viem@1.5.3)(zod@3.22.4) + '@rainbow-me/rainbowkit': 1.2.0(@types/react@18.2.33)(react-dom@18.2.0)(react@18.2.0)(viem@1.18.4)(wagmi@1.4.5) + '@wagmi/connectors': 2.7.0(react@18.2.0)(typescript@5.1.6)(viem@1.18.4)(zod@3.22.4) + viem: 1.18.4(typescript@5.1.6)(zod@3.22.4) + wagmi: 1.4.5(@types/react@18.2.33)(react-dom@18.2.0)(react-native@0.72.6)(react@18.2.0)(typescript@5.1.6)(viem@1.18.4)(zod@3.22.4) transitivePeerDependencies: - '@react-native-async-storage/async-storage' - '@wagmi/chains' @@ -2635,6 +2620,19 @@ packages: - zod dev: false + /@chainlink/contracts@0.8.0(ethers@6.8.0): + resolution: {integrity: sha512-nUv1Uxw5Mn92wgLs2bgPYmo8hpdQ3s9jB/lcbdU0LmNOVu0hbfmouVnqwRLa28Ll50q6GczUA+eO0ikNIKLZsA==} + dependencies: + '@eth-optimism/contracts': 0.5.40(ethers@6.8.0) + '@openzeppelin/contracts': 4.3.3 + '@openzeppelin/contracts-upgradeable-4.7.3': /@openzeppelin/contracts-upgradeable@4.7.3 + '@openzeppelin/contracts-v0.7': /@openzeppelin/contracts@3.4.2 + transitivePeerDependencies: + - bufferutil + - ethers + - utf-8-validate + dev: true + /@chainsafe/as-sha256@0.3.1: resolution: {integrity: sha512-hldFFYuf49ed7DAakWVXSJODuq3pzJEguD8tQ7h+sGkM18vja+OFoJI9krnGmgzyuZC2ETX0NOIcCTy31v2Mtg==} @@ -2735,8 +2733,8 @@ packages: mime: 3.0.0 dev: true - /@cloudflare/workers-types@4.20231016.0: - resolution: {integrity: sha512-eGB0cRVyoJpeyGJx2re5sbd9R316a61sY73xwnqm4cwGpb+OxCK2gc651RxGiN7H4w6LY1RpysUgeGLmj5B3+g==} + /@cloudflare/workers-types@4.20231025.0: + resolution: {integrity: sha512-TkcZkntUTOcvJ4vgmwpNfLTclpMbmbClZCe62B25/VTukmyv91joRa4eKzSjzCZUXTbFHNmVdOpmGaaJU2U3+A==} dev: true /@coinbase/wallet-sdk@3.7.2: @@ -2808,12 +2806,12 @@ packages: ajv: 8.12.0 dev: true - /@commitlint/config-validator@18.0.0: - resolution: {integrity: sha512-PlXy5QZzQeMgQM7jb0odIhxsI6GWcbGgfy+Hkz5ap31KES/oJgtEvgD8pjg0Z9Ri296bT6zK3ts6brS0MAcMgg==} + /@commitlint/config-validator@18.1.0: + resolution: {integrity: sha512-kbHkIuItXn93o2NmTdwi5Mk1ujyuSIysRE/XHtrcps/27GuUKEIqBJp6TdJ4Sq+ze59RlzYSHMKuDKZbfg9+uQ==} engines: {node: '>=v18'} requiresBuild: true dependencies: - '@commitlint/types': 18.0.0 + '@commitlint/types': 18.1.0 ajv: 8.12.0 dev: true optional: true @@ -2835,8 +2833,8 @@ packages: engines: {node: '>=v14'} dev: true - /@commitlint/execute-rule@18.0.0: - resolution: {integrity: sha512-eNUSaHajb+g3sgZeIrfc6cXNnKIkYN2SXtDVXuiE+hOa055T0bLdZK29gSd945JCztxPVwdOkPLDeLg3NfDubg==} + /@commitlint/execute-rule@18.1.0: + resolution: {integrity: sha512-w3Vt4K+O7+nSr9/gFSEfZ1exKUOPSlJaRpnk7Y+XowEhvwT7AIk1HNANH+gETf0zGZ020+hfiMW/Ome+SNCUsg==} engines: {node: '>=v18'} requiresBuild: true dev: true @@ -2891,28 +2889,25 @@ packages: - '@swc/wasm' dev: true - /@commitlint/load@18.0.0: - resolution: {integrity: sha512-ocvMSkzNZCJ4yV673xjd4Y7sFVG/mg7S6yvL5ioM0OIG2XTbcCdzpmq+BeJcIwsRYU9g/b688yh7RDzGlbai6w==} + /@commitlint/load@18.2.0(typescript@4.9.5): + resolution: {integrity: sha512-xjX3d3CRlOALwImhOsmLYZh14/+gW/KxsY7+bPKrzmGuFailf9K7ckhB071oYZVJdACnpY4hDYiosFyOC+MpAA==} engines: {node: '>=v18'} requiresBuild: true dependencies: - '@commitlint/config-validator': 18.0.0 - '@commitlint/execute-rule': 18.0.0 - '@commitlint/resolve-extends': 18.0.0 - '@commitlint/types': 18.0.0 - '@types/node': 18.18.6 + '@commitlint/config-validator': 18.1.0 + '@commitlint/execute-rule': 18.1.0 + '@commitlint/resolve-extends': 18.1.0 + '@commitlint/types': 18.1.0 + '@types/node': 18.18.7 chalk: 4.1.2 - cosmiconfig: 8.3.6(typescript@5.2.2) - cosmiconfig-typescript-loader: 4.4.0(@types/node@18.18.6)(cosmiconfig@8.3.6)(ts-node@10.9.1)(typescript@5.2.2) + cosmiconfig: 8.3.6(typescript@4.9.5) + cosmiconfig-typescript-loader: 5.0.0(@types/node@18.18.7)(cosmiconfig@8.3.6)(typescript@4.9.5) lodash.isplainobject: 4.0.6 lodash.merge: 4.6.2 lodash.uniq: 4.5.0 resolve-from: 5.0.0 - ts-node: 10.9.1(@types/node@18.18.6)(typescript@5.2.2) - typescript: 5.2.2 transitivePeerDependencies: - - '@swc/core' - - '@swc/wasm' + - typescript dev: true optional: true @@ -2953,13 +2948,13 @@ packages: resolve-global: 1.0.0 dev: true - /@commitlint/resolve-extends@18.0.0: - resolution: {integrity: sha512-MD9+6GSiWvqgdJtfos+1gqz+zmy2vV7TbUVz2ETZzpfECgmUZSZSYzyivivBAQK6feS71KxmMLL8+YFF9+FFRQ==} + /@commitlint/resolve-extends@18.1.0: + resolution: {integrity: sha512-3mZpzOEJkELt7BbaZp6+bofJyxViyObebagFn0A7IHaLARhPkWTivXdjvZHS12nAORftv88Yhbh8eCPKfSvB7g==} engines: {node: '>=v18'} requiresBuild: true dependencies: - '@commitlint/config-validator': 18.0.0 - '@commitlint/types': 18.0.0 + '@commitlint/config-validator': 18.1.0 + '@commitlint/types': 18.1.0 import-fresh: 3.3.0 lodash.mergewith: 4.6.2 resolve-from: 5.0.0 @@ -2997,8 +2992,8 @@ packages: chalk: 4.1.2 dev: true - /@commitlint/types@18.0.0: - resolution: {integrity: sha512-FDzAdSm7kIir0NW0bZLENdrEgf/9Ihs1AAqE9DK9R+dRFby4ookkxPMaz7elZmG+e5rBl7hGrWJzJINqG9cDDg==} + /@commitlint/types@18.1.0: + resolution: {integrity: sha512-65vGxZmbs+2OVwEItxhp3Ul7X2m2LyLfifYI/NdPwRqblmuES2w2aIRhIjb7cwUIBHHSTT8WXj4ixVHQibmvLQ==} engines: {node: '>=v18'} requiresBuild: true dependencies: @@ -3012,8 +3007,8 @@ packages: dependencies: '@jridgewell/trace-mapping': 0.3.9 - /@cypress/code-coverage@3.12.5(@babel/core@7.23.2)(@babel/preset-env@7.23.2)(babel-loader@9.1.3)(cypress@12.17.4)(webpack@5.89.0): - resolution: {integrity: sha512-0hczq2kgzkh/fBLm74rHcDRX//W3bhJJw/aPWu57/pPaRp5c+LcatWuv8ZtIWNXit2kBClueOrVj0I20Arh80A==} + /@cypress/code-coverage@3.12.6(@babel/core@7.23.2)(@babel/preset-env@7.23.2)(babel-loader@9.1.3)(cypress@12.17.4)(webpack@5.89.0): + resolution: {integrity: sha512-QeOB54dkxee8LKdbK9NqMinlMtzy60K2DexSvx4XZdrU52gut9Ukc7sUvRe44gK1yJFYno977Kx9miNIeYWVtA==} peerDependencies: '@babel/core': ^7.0.1 '@babel/preset-env': ^7.0.0 @@ -3166,13 +3161,13 @@ packages: resolution: {integrity: sha512-dBVuXR082gk3jsFp7Rd/JI4kytwGHecnCoTtXFb7DB6CNHp4rg5k1bhg0nWdLGLnOV71lmDzGQaLMy8iPLY0pw==} engines: {node: '>=10.0.0'} - /@dlsl/hardhat-markup@1.0.0-rc.14(hardhat@2.13.1)(prettier@2.8.8): + /@dlsl/hardhat-markup@1.0.0-rc.14(hardhat@2.18.3)(prettier@2.8.8): resolution: {integrity: sha512-fhkjuHjM6sDzjY6xiNHiENTdNRQGDEZ8RTkFnmvGVSYP2G7VKjVvay0ZWxILIXb+WvK+JdkcVtpvR00eo8wuWg==} deprecated: Package no longer supported. Contact Support at https://www.npmjs.com/support for more info. peerDependencies: hardhat: ^2.10.0 dependencies: - hardhat: 2.13.1(ts-node@10.9.1)(typescript@4.9.5) + hardhat: 2.18.3(ts-node@10.9.1)(typescript@4.9.5) json2md: 2.0.0 prettier-plugin-solidity: 1.1.3(prettier@2.8.8) solidity-ast: 0.4.52 @@ -3212,7 +3207,7 @@ packages: - '@algolia/client-search' dev: false - /@docusaurus/core@2.4.3(@docusaurus/types@2.4.3)(react-dom@18.2.0)(react@18.2.0)(typescript@4.9.5): + /@docusaurus/core@2.4.3(@docusaurus/types@2.4.3)(eslint@8.52.0)(react-dom@18.2.0)(react@18.2.0)(typescript@4.9.5): resolution: {integrity: sha512-dWH5P7cgeNSIg9ufReX6gaCl/TmrGKD38Orbwuz05WPhAQtFXHd5B8Qym1TiXfvUNvwoYKkAJOJuGe8ou0Z7PA==} engines: {node: '>=16.14'} hasBin: true @@ -3271,7 +3266,7 @@ packages: postcss-loader: 7.3.3(postcss@8.4.31)(typescript@4.9.5)(webpack@5.89.0) prompts: 2.4.2 react: 18.2.0 - react-dev-utils: 12.0.1(typescript@4.9.5)(webpack@5.89.0) + react-dev-utils: 12.0.1(eslint@8.52.0)(typescript@4.9.5)(webpack@5.89.0) react-dom: 18.2.0(react@18.2.0) react-helmet-async: 1.3.0(react-dom@18.2.0)(react@18.2.0) react-loadable: /@docusaurus/react-loadable@5.5.2(react@18.2.0) @@ -3279,7 +3274,7 @@ packages: react-router: 5.3.4(react@18.2.0) react-router-config: 5.1.1(react-router@5.3.4)(react@18.2.0) react-router-dom: 5.3.4(react@18.2.0) - rtl-detect: 1.0.4 + rtl-detect: 1.1.2 semver: 7.5.4 serve-handler: 6.1.5 shelljs: 0.8.5 @@ -3322,6 +3317,20 @@ packages: tslib: 2.6.2 dev: false + /@docusaurus/eslint-plugin@2.4.3(eslint@8.52.0)(typescript@4.9.5): + resolution: {integrity: sha512-CckN1JCU7biEP4JMDCNGJf6VcmaCqqIruYrvSU91pKYrFuYi0gblfkljagkHc9+mw1ZX2jtoTm4XfoZ/Q9WDCA==} + engines: {node: '>=16.14'} + peerDependencies: + eslint: '>=6' + dependencies: + '@typescript-eslint/utils': 5.62.0(eslint@8.52.0)(typescript@4.9.5) + eslint: 8.52.0 + tslib: 2.6.2 + transitivePeerDependencies: + - supports-color + - typescript + dev: true + /@docusaurus/logger@2.4.3: resolution: {integrity: sha512-Zxws7r3yLufk9xM1zq9ged0YHs65mlRmtsobnFkdZTxWXdTYlWWLWdKyNKAsVC+D7zg+pv2fGbyabdOnyZOM3w==} engines: {node: '>=16.14'} @@ -3374,7 +3383,7 @@ packages: '@docusaurus/react-loadable': 5.5.2(react@18.2.0) '@docusaurus/types': 2.4.3(react-dom@18.2.0)(react@18.2.0) '@types/history': 4.7.11 - '@types/react': 18.2.31 + '@types/react': 18.2.33 '@types/react-router-config': 5.0.9 '@types/react-router-dom': 5.3.3 react: 18.2.0 @@ -3387,14 +3396,14 @@ packages: - uglify-js - webpack-cli - /@docusaurus/plugin-content-blog@2.4.3(react-dom@18.2.0)(react@18.2.0)(typescript@4.9.5): + /@docusaurus/plugin-content-blog@2.4.3(eslint@8.52.0)(react-dom@18.2.0)(react@18.2.0)(typescript@4.9.5): resolution: {integrity: sha512-PVhypqaA0t98zVDpOeTqWUTvRqCEjJubtfFUQ7zJNYdbYTbS/E/ytq6zbLVsN/dImvemtO/5JQgjLxsh8XLo8Q==} engines: {node: '>=16.14'} peerDependencies: react: ^16.8.4 || ^17.0.0 react-dom: ^16.8.4 || ^17.0.0 dependencies: - '@docusaurus/core': 2.4.3(@docusaurus/types@2.4.3)(react-dom@18.2.0)(react@18.2.0)(typescript@4.9.5) + '@docusaurus/core': 2.4.3(@docusaurus/types@2.4.3)(eslint@8.52.0)(react-dom@18.2.0)(react@18.2.0)(typescript@4.9.5) '@docusaurus/logger': 2.4.3 '@docusaurus/mdx-loader': 2.4.3(@docusaurus/types@2.4.3)(react-dom@18.2.0)(react@18.2.0) '@docusaurus/types': 2.4.3(react-dom@18.2.0)(react@18.2.0) @@ -3430,14 +3439,14 @@ packages: - webpack-cli dev: false - /@docusaurus/plugin-content-docs@2.4.3(react-dom@18.2.0)(react@18.2.0)(typescript@4.9.5): + /@docusaurus/plugin-content-docs@2.4.3(eslint@8.52.0)(react-dom@18.2.0)(react@18.2.0)(typescript@4.9.5): resolution: {integrity: sha512-N7Po2LSH6UejQhzTCsvuX5NOzlC+HiXOVvofnEPj0WhMu1etpLEXE6a4aTxrtg95lQ5kf0xUIdjX9sh3d3G76A==} engines: {node: '>=16.14'} peerDependencies: react: ^16.8.4 || ^17.0.0 react-dom: ^16.8.4 || ^17.0.0 dependencies: - '@docusaurus/core': 2.4.3(@docusaurus/types@2.4.3)(react-dom@18.2.0)(react@18.2.0)(typescript@4.9.5) + '@docusaurus/core': 2.4.3(@docusaurus/types@2.4.3)(eslint@8.52.0)(react-dom@18.2.0)(react@18.2.0)(typescript@4.9.5) '@docusaurus/logger': 2.4.3 '@docusaurus/mdx-loader': 2.4.3(@docusaurus/types@2.4.3)(react-dom@18.2.0)(react@18.2.0) '@docusaurus/module-type-aliases': 2.4.3(react-dom@18.2.0)(react@18.2.0) @@ -3473,14 +3482,14 @@ packages: - webpack-cli dev: false - /@docusaurus/plugin-content-pages@2.4.3(react-dom@18.2.0)(react@18.2.0)(typescript@4.9.5): + /@docusaurus/plugin-content-pages@2.4.3(eslint@8.52.0)(react-dom@18.2.0)(react@18.2.0)(typescript@4.9.5): resolution: {integrity: sha512-txtDVz7y3zGk67q0HjG0gRttVPodkHqE0bpJ+7dOaTH40CQFLSh7+aBeGnPOTl+oCPG+hxkim4SndqPqXjQ8Bg==} engines: {node: '>=16.14'} peerDependencies: react: ^16.8.4 || ^17.0.0 react-dom: ^16.8.4 || ^17.0.0 dependencies: - '@docusaurus/core': 2.4.3(@docusaurus/types@2.4.3)(react-dom@18.2.0)(react@18.2.0)(typescript@4.9.5) + '@docusaurus/core': 2.4.3(@docusaurus/types@2.4.3)(eslint@8.52.0)(react-dom@18.2.0)(react@18.2.0)(typescript@4.9.5) '@docusaurus/mdx-loader': 2.4.3(@docusaurus/types@2.4.3)(react-dom@18.2.0)(react@18.2.0) '@docusaurus/types': 2.4.3(react-dom@18.2.0)(react@18.2.0) '@docusaurus/utils': 2.4.3(@docusaurus/types@2.4.3) @@ -3508,14 +3517,14 @@ packages: - webpack-cli dev: false - /@docusaurus/plugin-debug@2.4.3(react-dom@18.2.0)(react@18.2.0)(typescript@4.9.5): + /@docusaurus/plugin-debug@2.4.3(eslint@8.52.0)(react-dom@18.2.0)(react@18.2.0)(typescript@4.9.5): resolution: {integrity: sha512-LkUbuq3zCmINlFb+gAd4ZvYr+bPAzMC0hwND4F7V9bZ852dCX8YoWyovVUBKq4er1XsOwSQaHmNGtObtn8Av8Q==} engines: {node: '>=16.14'} peerDependencies: react: ^16.8.4 || ^17.0.0 react-dom: ^16.8.4 || ^17.0.0 dependencies: - '@docusaurus/core': 2.4.3(@docusaurus/types@2.4.3)(react-dom@18.2.0)(react@18.2.0)(typescript@4.9.5) + '@docusaurus/core': 2.4.3(@docusaurus/types@2.4.3)(eslint@8.52.0)(react-dom@18.2.0)(react@18.2.0)(typescript@4.9.5) '@docusaurus/types': 2.4.3(react-dom@18.2.0)(react@18.2.0) '@docusaurus/utils': 2.4.3(@docusaurus/types@2.4.3) fs-extra: 10.1.0 @@ -3543,14 +3552,14 @@ packages: - webpack-cli dev: false - /@docusaurus/plugin-google-analytics@2.4.3(react-dom@18.2.0)(react@18.2.0)(typescript@4.9.5): + /@docusaurus/plugin-google-analytics@2.4.3(eslint@8.52.0)(react-dom@18.2.0)(react@18.2.0)(typescript@4.9.5): resolution: {integrity: sha512-KzBV3k8lDkWOhg/oYGxlK5o9bOwX7KpPc/FTWoB+SfKhlHfhq7qcQdMi1elAaVEIop8tgK6gD1E58Q+XC6otSQ==} engines: {node: '>=16.14'} peerDependencies: react: ^16.8.4 || ^17.0.0 react-dom: ^16.8.4 || ^17.0.0 dependencies: - '@docusaurus/core': 2.4.3(@docusaurus/types@2.4.3)(react-dom@18.2.0)(react@18.2.0)(typescript@4.9.5) + '@docusaurus/core': 2.4.3(@docusaurus/types@2.4.3)(eslint@8.52.0)(react-dom@18.2.0)(react@18.2.0)(typescript@4.9.5) '@docusaurus/types': 2.4.3(react-dom@18.2.0)(react@18.2.0) '@docusaurus/utils-validation': 2.4.3(@docusaurus/types@2.4.3) react: 18.2.0 @@ -3574,14 +3583,14 @@ packages: - webpack-cli dev: false - /@docusaurus/plugin-google-gtag@2.4.3(react-dom@18.2.0)(react@18.2.0)(typescript@4.9.5): + /@docusaurus/plugin-google-gtag@2.4.3(eslint@8.52.0)(react-dom@18.2.0)(react@18.2.0)(typescript@4.9.5): resolution: {integrity: sha512-5FMg0rT7sDy4i9AGsvJC71MQrqQZwgLNdDetLEGDHLfSHLvJhQbTCUGbGXknUgWXQJckcV/AILYeJy+HhxeIFA==} engines: {node: '>=16.14'} peerDependencies: react: ^16.8.4 || ^17.0.0 react-dom: ^16.8.4 || ^17.0.0 dependencies: - '@docusaurus/core': 2.4.3(@docusaurus/types@2.4.3)(react-dom@18.2.0)(react@18.2.0)(typescript@4.9.5) + '@docusaurus/core': 2.4.3(@docusaurus/types@2.4.3)(eslint@8.52.0)(react-dom@18.2.0)(react@18.2.0)(typescript@4.9.5) '@docusaurus/types': 2.4.3(react-dom@18.2.0)(react@18.2.0) '@docusaurus/utils-validation': 2.4.3(@docusaurus/types@2.4.3) react: 18.2.0 @@ -3605,14 +3614,14 @@ packages: - webpack-cli dev: false - /@docusaurus/plugin-google-tag-manager@2.4.3(react-dom@18.2.0)(react@18.2.0)(typescript@4.9.5): + /@docusaurus/plugin-google-tag-manager@2.4.3(eslint@8.52.0)(react-dom@18.2.0)(react@18.2.0)(typescript@4.9.5): resolution: {integrity: sha512-1jTzp71yDGuQiX9Bi0pVp3alArV0LSnHXempvQTxwCGAEzUWWaBg4d8pocAlTpbP9aULQQqhgzrs8hgTRPOM0A==} engines: {node: '>=16.14'} peerDependencies: react: ^16.8.4 || ^17.0.0 react-dom: ^16.8.4 || ^17.0.0 dependencies: - '@docusaurus/core': 2.4.3(@docusaurus/types@2.4.3)(react-dom@18.2.0)(react@18.2.0)(typescript@4.9.5) + '@docusaurus/core': 2.4.3(@docusaurus/types@2.4.3)(eslint@8.52.0)(react-dom@18.2.0)(react@18.2.0)(typescript@4.9.5) '@docusaurus/types': 2.4.3(react-dom@18.2.0)(react@18.2.0) '@docusaurus/utils-validation': 2.4.3(@docusaurus/types@2.4.3) react: 18.2.0 @@ -3636,14 +3645,14 @@ packages: - webpack-cli dev: false - /@docusaurus/plugin-sitemap@2.4.3(react-dom@18.2.0)(react@18.2.0)(typescript@4.9.5): + /@docusaurus/plugin-sitemap@2.4.3(eslint@8.52.0)(react-dom@18.2.0)(react@18.2.0)(typescript@4.9.5): resolution: {integrity: sha512-LRQYrK1oH1rNfr4YvWBmRzTL0LN9UAPxBbghgeFRBm5yloF6P+zv1tm2pe2hQTX/QP5bSKdnajCvfnScgKXMZQ==} engines: {node: '>=16.14'} peerDependencies: react: ^16.8.4 || ^17.0.0 react-dom: ^16.8.4 || ^17.0.0 dependencies: - '@docusaurus/core': 2.4.3(@docusaurus/types@2.4.3)(react-dom@18.2.0)(react@18.2.0)(typescript@4.9.5) + '@docusaurus/core': 2.4.3(@docusaurus/types@2.4.3)(eslint@8.52.0)(react-dom@18.2.0)(react@18.2.0)(typescript@4.9.5) '@docusaurus/logger': 2.4.3 '@docusaurus/types': 2.4.3(react-dom@18.2.0)(react@18.2.0) '@docusaurus/utils': 2.4.3(@docusaurus/types@2.4.3) @@ -3672,25 +3681,25 @@ packages: - webpack-cli dev: false - /@docusaurus/preset-classic@2.4.3(@algolia/client-search@4.20.0)(react-dom@18.2.0)(react@18.2.0)(search-insights@2.9.0)(typescript@4.9.5): + /@docusaurus/preset-classic@2.4.3(@algolia/client-search@4.20.0)(eslint@8.52.0)(react-dom@18.2.0)(react@18.2.0)(search-insights@2.9.0)(typescript@4.9.5): resolution: {integrity: sha512-tRyMliepY11Ym6hB1rAFSNGwQDpmszvWYJvlK1E+md4SW8i6ylNHtpZjaYFff9Mdk3i/Pg8ItQq9P0daOJAvQw==} engines: {node: '>=16.14'} peerDependencies: react: ^16.8.4 || ^17.0.0 react-dom: ^16.8.4 || ^17.0.0 dependencies: - '@docusaurus/core': 2.4.3(@docusaurus/types@2.4.3)(react-dom@18.2.0)(react@18.2.0)(typescript@4.9.5) - '@docusaurus/plugin-content-blog': 2.4.3(react-dom@18.2.0)(react@18.2.0)(typescript@4.9.5) - '@docusaurus/plugin-content-docs': 2.4.3(react-dom@18.2.0)(react@18.2.0)(typescript@4.9.5) - '@docusaurus/plugin-content-pages': 2.4.3(react-dom@18.2.0)(react@18.2.0)(typescript@4.9.5) - '@docusaurus/plugin-debug': 2.4.3(react-dom@18.2.0)(react@18.2.0)(typescript@4.9.5) - '@docusaurus/plugin-google-analytics': 2.4.3(react-dom@18.2.0)(react@18.2.0)(typescript@4.9.5) - '@docusaurus/plugin-google-gtag': 2.4.3(react-dom@18.2.0)(react@18.2.0)(typescript@4.9.5) - '@docusaurus/plugin-google-tag-manager': 2.4.3(react-dom@18.2.0)(react@18.2.0)(typescript@4.9.5) - '@docusaurus/plugin-sitemap': 2.4.3(react-dom@18.2.0)(react@18.2.0)(typescript@4.9.5) - '@docusaurus/theme-classic': 2.4.3(react-dom@18.2.0)(react@18.2.0)(typescript@4.9.5) - '@docusaurus/theme-common': 2.4.3(@docusaurus/types@2.4.3)(react-dom@18.2.0)(react@18.2.0)(typescript@4.9.5) - '@docusaurus/theme-search-algolia': 2.4.3(@algolia/client-search@4.20.0)(@docusaurus/types@2.4.3)(react-dom@18.2.0)(react@18.2.0)(search-insights@2.9.0)(typescript@4.9.5) + '@docusaurus/core': 2.4.3(@docusaurus/types@2.4.3)(eslint@8.52.0)(react-dom@18.2.0)(react@18.2.0)(typescript@4.9.5) + '@docusaurus/plugin-content-blog': 2.4.3(eslint@8.52.0)(react-dom@18.2.0)(react@18.2.0)(typescript@4.9.5) + '@docusaurus/plugin-content-docs': 2.4.3(eslint@8.52.0)(react-dom@18.2.0)(react@18.2.0)(typescript@4.9.5) + '@docusaurus/plugin-content-pages': 2.4.3(eslint@8.52.0)(react-dom@18.2.0)(react@18.2.0)(typescript@4.9.5) + '@docusaurus/plugin-debug': 2.4.3(eslint@8.52.0)(react-dom@18.2.0)(react@18.2.0)(typescript@4.9.5) + '@docusaurus/plugin-google-analytics': 2.4.3(eslint@8.52.0)(react-dom@18.2.0)(react@18.2.0)(typescript@4.9.5) + '@docusaurus/plugin-google-gtag': 2.4.3(eslint@8.52.0)(react-dom@18.2.0)(react@18.2.0)(typescript@4.9.5) + '@docusaurus/plugin-google-tag-manager': 2.4.3(eslint@8.52.0)(react-dom@18.2.0)(react@18.2.0)(typescript@4.9.5) + '@docusaurus/plugin-sitemap': 2.4.3(eslint@8.52.0)(react-dom@18.2.0)(react@18.2.0)(typescript@4.9.5) + '@docusaurus/theme-classic': 2.4.3(eslint@8.52.0)(react-dom@18.2.0)(react@18.2.0)(typescript@4.9.5) + '@docusaurus/theme-common': 2.4.3(@docusaurus/types@2.4.3)(eslint@8.52.0)(react-dom@18.2.0)(react@18.2.0)(typescript@4.9.5) + '@docusaurus/theme-search-algolia': 2.4.3(@algolia/client-search@4.20.0)(@docusaurus/types@2.4.3)(eslint@8.52.0)(react-dom@18.2.0)(react@18.2.0)(search-insights@2.9.0)(typescript@4.9.5) '@docusaurus/types': 2.4.3(react-dom@18.2.0)(react@18.2.0) react: 18.2.0 react-dom: 18.2.0(react@18.2.0) @@ -3721,24 +3730,24 @@ packages: peerDependencies: react: '*' dependencies: - '@types/react': 18.2.31 + '@types/react': 18.2.33 prop-types: 15.8.1 react: 18.2.0 - /@docusaurus/theme-classic@2.4.3(react-dom@18.2.0)(react@18.2.0)(typescript@4.9.5): + /@docusaurus/theme-classic@2.4.3(eslint@8.52.0)(react-dom@18.2.0)(react@18.2.0)(typescript@4.9.5): resolution: {integrity: sha512-QKRAJPSGPfDY2yCiPMIVyr+MqwZCIV2lxNzqbyUW0YkrlmdzzP3WuQJPMGLCjWgQp/5c9kpWMvMxjhpZx1R32Q==} engines: {node: '>=16.14'} peerDependencies: react: ^16.8.4 || ^17.0.0 react-dom: ^16.8.4 || ^17.0.0 dependencies: - '@docusaurus/core': 2.4.3(@docusaurus/types@2.4.3)(react-dom@18.2.0)(react@18.2.0)(typescript@4.9.5) + '@docusaurus/core': 2.4.3(@docusaurus/types@2.4.3)(eslint@8.52.0)(react-dom@18.2.0)(react@18.2.0)(typescript@4.9.5) '@docusaurus/mdx-loader': 2.4.3(@docusaurus/types@2.4.3)(react-dom@18.2.0)(react@18.2.0) '@docusaurus/module-type-aliases': 2.4.3(react-dom@18.2.0)(react@18.2.0) - '@docusaurus/plugin-content-blog': 2.4.3(react-dom@18.2.0)(react@18.2.0)(typescript@4.9.5) - '@docusaurus/plugin-content-docs': 2.4.3(react-dom@18.2.0)(react@18.2.0)(typescript@4.9.5) - '@docusaurus/plugin-content-pages': 2.4.3(react-dom@18.2.0)(react@18.2.0)(typescript@4.9.5) - '@docusaurus/theme-common': 2.4.3(@docusaurus/types@2.4.3)(react-dom@18.2.0)(react@18.2.0)(typescript@4.9.5) + '@docusaurus/plugin-content-blog': 2.4.3(eslint@8.52.0)(react-dom@18.2.0)(react@18.2.0)(typescript@4.9.5) + '@docusaurus/plugin-content-docs': 2.4.3(eslint@8.52.0)(react-dom@18.2.0)(react@18.2.0)(typescript@4.9.5) + '@docusaurus/plugin-content-pages': 2.4.3(eslint@8.52.0)(react-dom@18.2.0)(react@18.2.0)(typescript@4.9.5) + '@docusaurus/theme-common': 2.4.3(@docusaurus/types@2.4.3)(eslint@8.52.0)(react-dom@18.2.0)(react@18.2.0)(typescript@4.9.5) '@docusaurus/theme-translations': 2.4.3 '@docusaurus/types': 2.4.3(react-dom@18.2.0)(react@18.2.0) '@docusaurus/utils': 2.4.3(@docusaurus/types@2.4.3) @@ -3777,7 +3786,7 @@ packages: - webpack-cli dev: false - /@docusaurus/theme-common@2.4.3(@docusaurus/types@2.4.3)(react-dom@18.2.0)(react@18.2.0)(typescript@4.9.5): + /@docusaurus/theme-common@2.4.3(@docusaurus/types@2.4.3)(eslint@8.52.0)(react-dom@18.2.0)(react@18.2.0)(typescript@4.9.5): resolution: {integrity: sha512-7KaDJBXKBVGXw5WOVt84FtN8czGWhM0lbyWEZXGp8AFfL6sZQfRTluFp4QriR97qwzSyOfQb+nzcDZZU4tezUw==} engines: {node: '>=16.14'} peerDependencies: @@ -3786,13 +3795,13 @@ packages: dependencies: '@docusaurus/mdx-loader': 2.4.3(@docusaurus/types@2.4.3)(react-dom@18.2.0)(react@18.2.0) '@docusaurus/module-type-aliases': 2.4.3(react-dom@18.2.0)(react@18.2.0) - '@docusaurus/plugin-content-blog': 2.4.3(react-dom@18.2.0)(react@18.2.0)(typescript@4.9.5) - '@docusaurus/plugin-content-docs': 2.4.3(react-dom@18.2.0)(react@18.2.0)(typescript@4.9.5) - '@docusaurus/plugin-content-pages': 2.4.3(react-dom@18.2.0)(react@18.2.0)(typescript@4.9.5) + '@docusaurus/plugin-content-blog': 2.4.3(eslint@8.52.0)(react-dom@18.2.0)(react@18.2.0)(typescript@4.9.5) + '@docusaurus/plugin-content-docs': 2.4.3(eslint@8.52.0)(react-dom@18.2.0)(react@18.2.0)(typescript@4.9.5) + '@docusaurus/plugin-content-pages': 2.4.3(eslint@8.52.0)(react-dom@18.2.0)(react@18.2.0)(typescript@4.9.5) '@docusaurus/utils': 2.4.3(@docusaurus/types@2.4.3) '@docusaurus/utils-common': 2.4.3(@docusaurus/types@2.4.3) '@types/history': 4.7.11 - '@types/react': 18.2.31 + '@types/react': 18.2.33 '@types/react-router-config': 5.0.9 clsx: 1.2.1 parse-numeric-range: 1.3.0 @@ -3821,16 +3830,16 @@ packages: - webpack-cli dev: false - /@docusaurus/theme-mermaid@2.4.3(react-dom@18.2.0)(react@18.2.0)(typescript@4.9.5): + /@docusaurus/theme-mermaid@2.4.3(eslint@8.52.0)(react-dom@18.2.0)(react@18.2.0)(typescript@4.9.5): resolution: {integrity: sha512-S1tZ3xpowtFiTrpTKmvVbRHUYGOlEG5CnPzWlO4huJT1sAwLR+pD6f9DYUlPv2+9NezF3EfUrUyW9xLH0UP58w==} engines: {node: '>=16.14'} peerDependencies: react: ^16.8.4 || ^17.0.0 react-dom: ^16.8.4 || ^17.0.0 dependencies: - '@docusaurus/core': 2.4.3(@docusaurus/types@2.4.3)(react-dom@18.2.0)(react@18.2.0)(typescript@4.9.5) + '@docusaurus/core': 2.4.3(@docusaurus/types@2.4.3)(eslint@8.52.0)(react-dom@18.2.0)(react@18.2.0)(typescript@4.9.5) '@docusaurus/module-type-aliases': 2.4.3(react-dom@18.2.0)(react@18.2.0) - '@docusaurus/theme-common': 2.4.3(@docusaurus/types@2.4.3)(react-dom@18.2.0)(react@18.2.0)(typescript@4.9.5) + '@docusaurus/theme-common': 2.4.3(@docusaurus/types@2.4.3)(eslint@8.52.0)(react-dom@18.2.0)(react@18.2.0)(typescript@4.9.5) '@docusaurus/types': 2.4.3(react-dom@18.2.0)(react@18.2.0) '@docusaurus/utils-validation': 2.4.3(@docusaurus/types@2.4.3) '@mdx-js/react': 1.6.22(react@18.2.0) @@ -3856,7 +3865,7 @@ packages: - webpack-cli dev: false - /@docusaurus/theme-search-algolia@2.4.3(@algolia/client-search@4.20.0)(@docusaurus/types@2.4.3)(react-dom@18.2.0)(react@18.2.0)(search-insights@2.9.0)(typescript@4.9.5): + /@docusaurus/theme-search-algolia@2.4.3(@algolia/client-search@4.20.0)(@docusaurus/types@2.4.3)(eslint@8.52.0)(react-dom@18.2.0)(react@18.2.0)(search-insights@2.9.0)(typescript@4.9.5): resolution: {integrity: sha512-jziq4f6YVUB5hZOB85ELATwnxBz/RmSLD3ksGQOLDPKVzat4pmI8tddNWtriPpxR04BNT+ZfpPUMFkNFetSW1Q==} engines: {node: '>=16.14'} peerDependencies: @@ -3864,15 +3873,15 @@ packages: react-dom: ^16.8.4 || ^17.0.0 dependencies: '@docsearch/react': 3.5.2(@algolia/client-search@4.20.0)(react-dom@18.2.0)(react@18.2.0)(search-insights@2.9.0) - '@docusaurus/core': 2.4.3(@docusaurus/types@2.4.3)(react-dom@18.2.0)(react@18.2.0)(typescript@4.9.5) + '@docusaurus/core': 2.4.3(@docusaurus/types@2.4.3)(eslint@8.52.0)(react-dom@18.2.0)(react@18.2.0)(typescript@4.9.5) '@docusaurus/logger': 2.4.3 - '@docusaurus/plugin-content-docs': 2.4.3(react-dom@18.2.0)(react@18.2.0)(typescript@4.9.5) - '@docusaurus/theme-common': 2.4.3(@docusaurus/types@2.4.3)(react-dom@18.2.0)(react@18.2.0)(typescript@4.9.5) + '@docusaurus/plugin-content-docs': 2.4.3(eslint@8.52.0)(react-dom@18.2.0)(react@18.2.0)(typescript@4.9.5) + '@docusaurus/theme-common': 2.4.3(@docusaurus/types@2.4.3)(eslint@8.52.0)(react-dom@18.2.0)(react@18.2.0)(typescript@4.9.5) '@docusaurus/theme-translations': 2.4.3 '@docusaurus/utils': 2.4.3(@docusaurus/types@2.4.3) '@docusaurus/utils-validation': 2.4.3(@docusaurus/types@2.4.3) algoliasearch: 4.20.0 - algoliasearch-helper: 3.14.2(algoliasearch@4.20.0) + algoliasearch-helper: 3.15.0(algoliasearch@4.20.0) clsx: 1.2.1 eta: 2.2.0 fs-extra: 10.1.0 @@ -3918,7 +3927,7 @@ packages: react-dom: ^16.8.4 || ^17.0.0 dependencies: '@types/history': 4.7.11 - '@types/react': 18.2.31 + '@types/react': 18.2.33 commander: 5.1.0 joi: 17.11.0 react: 18.2.0 @@ -4049,7 +4058,7 @@ packages: resolution: {integrity: sha512-W2P2c/VRW1/1tLox0mVUalvnWXxavmv/Oum2aPsRcoDJuob75FC3Y8FbpfLwUegRcxINtGUMPq0tFCvYNTBXNA==} dev: false - /@emotion/react@11.11.1(@types/react@18.2.31)(react@18.2.0): + /@emotion/react@11.11.1(@types/react@18.2.33)(react@18.2.0): resolution: {integrity: sha512-5mlW1DquU5HaxjLkfkGN1GA/fvVGdyHURRiX/0FHl2cfIfRxSOfmxEH5YS43edp0OldZrZ+dkBKbngxcNCdZvA==} peerDependencies: '@types/react': '*' @@ -4065,7 +4074,7 @@ packages: '@emotion/use-insertion-effect-with-fallbacks': 1.0.1(react@18.2.0) '@emotion/utils': 1.2.1 '@emotion/weak-memoize': 0.3.1 - '@types/react': 18.2.31 + '@types/react': 18.2.33 hoist-non-react-statics: 3.3.2 react: 18.2.0 dev: false @@ -4084,7 +4093,7 @@ packages: resolution: {integrity: sha512-0QBtGvaqtWi+nx6doRwDdBIzhNdZrXUppvTM4dtZZWEGTXL/XE/yJxLMGlDT1Gt+UHH5IX1n+jkXyytE/av7OA==} dev: false - /@emotion/styled@11.11.0(@emotion/react@11.11.1)(@types/react@18.2.31)(react@18.2.0): + /@emotion/styled@11.11.0(@emotion/react@11.11.1)(@types/react@18.2.33)(react@18.2.0): resolution: {integrity: sha512-hM5Nnvu9P3midq5aaXj4I+lnSfNi7Pmd4EWk1fOZ3pxookaQTNew6bp4JaCBYM4HVFZF9g7UjJmsUmC2JlxOng==} peerDependencies: '@emotion/react': ^11.0.0-rc.0 @@ -4097,11 +4106,11 @@ packages: '@babel/runtime': 7.23.2 '@emotion/babel-plugin': 11.11.0 '@emotion/is-prop-valid': 1.2.1 - '@emotion/react': 11.11.1(@types/react@18.2.31)(react@18.2.0) + '@emotion/react': 11.11.1(@types/react@18.2.33)(react@18.2.0) '@emotion/serialize': 1.1.2 '@emotion/use-insertion-effect-with-fallbacks': 1.0.1(react@18.2.0) '@emotion/utils': 1.2.1 - '@types/react': 18.2.31 + '@types/react': 18.2.33 react: 18.2.0 dev: false @@ -4159,7 +4168,7 @@ packages: resolution: {integrity: sha512-aXAf1bg5Z71YfEKLCZ8OMUZAOYPGHV/a+7avd5TIMFNDxl5wJTmIonep3T+kdMpwRInDphfNPGFD0GcGdGxpHg==} peerDependencies: '@envelop/core': ^3.0.6 - graphql: ^16.6.0 + graphql: ^14.0.0 || ^15.0.0 || ^16.0.0 dependencies: '@envelop/core': 3.0.6 '@graphql-tools/utils': 8.13.1(graphql@16.8.1) @@ -4171,7 +4180,7 @@ packages: engines: {node: '>=18.0.0'} peerDependencies: '@envelop/core': ^5.0.0 - graphql: ^16.6.0 + graphql: ^14.0.0 || ^15.0.0 || ^16.0.0 dependencies: '@envelop/core': 5.0.0 '@graphql-tools/utils': 10.0.7(graphql@16.8.1) @@ -4184,7 +4193,7 @@ packages: engines: {node: '>=18.0.0'} peerDependencies: '@envelop/core': ^5.0.0 - graphql: ^16.6.0 + graphql: ^14.0.0 || ^15.0.0 || ^16.0.0 dependencies: '@envelop/core': 5.0.0 graphql: 16.8.1 @@ -4209,7 +4218,7 @@ packages: resolution: {integrity: sha512-MkzcScQHJJQ/9YCAPdWShEi3xZv4F4neTs+NszzSrZOdlU8z/THuRt7gZ0sO0y2be+sx+SKjHQP8Gq3VXXcTTg==} peerDependencies: '@envelop/core': ^3.0.6 - graphql: ^16.6.0 + graphql: ^14.0.0 || ^15.0.0 || ^16.0.0 dependencies: '@envelop/core': 3.0.6 graphql: 16.8.1 @@ -5045,12 +5054,10 @@ packages: dependencies: eslint: 8.52.0 eslint-visitor-keys: 3.4.3 - dev: true - /@eslint-community/regexpp@4.9.1: - resolution: {integrity: sha512-Y27x+MBLjXa+0JWDhykM3+JE+il3kHKAEqabfEWq3SDhZjLYb6/BHL/JKFnH3fe207JaXkyDo685Oc2Glt6ifA==} + /@eslint-community/regexpp@4.10.0: + resolution: {integrity: sha512-Cu96Sd2By9mCNTx2iyKOmq10v22jUVQv0lQnlGNy16oE9589yE+QADPbrMGCkA51cKZSg3Pu/aTJVTGfL/qjUA==} engines: {node: ^12.0.0 || ^14.0.0 || >=16.0.0} - dev: true /@eslint/eslintrc@1.4.1: resolution: {integrity: sha512-XXrH9Uarn0stsyldqDYq8r++mROmWRI1xKMXa640Bb//SY1+ECYX6VzT6Lcx5frD0V30XieqJ0oX9I2Xj5aoMA==} @@ -5084,58 +5091,54 @@ packages: strip-json-comments: 3.1.1 transitivePeerDependencies: - supports-color - dev: true /@eslint/js@8.52.0: resolution: {integrity: sha512-mjZVbpaeMZludF2fsWLD0Z9gCref1Tk4i9+wddjRvpUNqqcndPkBD09N/Mapey0b3jaXbLm2kICwFv2E64QinA==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} - dev: true - /@ethereum-attestation-service/eas-contracts@0.27.1(@ethersproject/abi@5.7.0)(@ethersproject/providers@5.7.2)(ethers@5.7.2)(ts-node@10.9.1)(typescript@4.9.5): - resolution: {integrity: sha512-ly1N/jLbXJjACDL7dnMSkzViBxxuVc+aMZ3EB1kpFxeMWrXkb7nN6w9gxGTH+m3gJztaKvyMsyr/13pA0OYq6Q==} + /@eth-optimism/contracts@0.5.40(ethers@6.8.0): + resolution: {integrity: sha512-MrzV0nvsymfO/fursTB7m/KunkPsCndltVgfdHaT1Aj5Vi6R/doKIGGkOofHX+8B6VMZpuZosKCMQ5lQuqjt8w==} + peerDependencies: + ethers: ^5 dependencies: - '@typechain/ethers-v5': 10.2.1(@ethersproject/abi@5.7.0)(@ethersproject/providers@5.7.2)(ethers@5.7.2)(typechain@8.3.2)(typescript@4.9.5) - '@typechain/hardhat': 6.1.6(@ethersproject/abi@5.7.0)(@ethersproject/providers@5.7.2)(@typechain/ethers-v5@10.2.1)(ethers@5.7.2)(hardhat@2.13.1)(typechain@8.3.2) - hardhat: 2.13.1(ts-node@10.9.1)(typescript@4.9.5) - typechain: 8.3.2(typescript@4.9.5) + '@eth-optimism/core-utils': 0.12.0 + '@ethersproject/abstract-provider': 5.7.0 + '@ethersproject/abstract-signer': 5.7.0 + ethers: 6.8.0 transitivePeerDependencies: - - '@ethersproject/abi' - - '@ethersproject/providers' - bufferutil - - ethers - - supports-color - - ts-node - - typescript - utf-8-validate - dev: false + dev: true - /@ethereum-attestation-service/eas-contracts@0.27.1(@ethersproject/abi@5.7.0)(@ethersproject/providers@5.7.2)(ethers@5.7.2)(typescript@5.1.6): - resolution: {integrity: sha512-ly1N/jLbXJjACDL7dnMSkzViBxxuVc+aMZ3EB1kpFxeMWrXkb7nN6w9gxGTH+m3gJztaKvyMsyr/13pA0OYq6Q==} + /@eth-optimism/core-utils@0.12.0: + resolution: {integrity: sha512-qW+7LZYCz7i8dRa7SRlUKIo1VBU8lvN0HeXCxJR+z+xtMzMQpPds20XJNCMclszxYQHkXY00fOT6GvFw9ZL6nw==} dependencies: - '@typechain/ethers-v5': 10.2.1(@ethersproject/abi@5.7.0)(@ethersproject/providers@5.7.2)(ethers@5.7.2)(typechain@8.3.2)(typescript@5.1.6) - '@typechain/hardhat': 6.1.6(@ethersproject/abi@5.7.0)(@ethersproject/providers@5.7.2)(@typechain/ethers-v5@10.2.1)(ethers@5.7.2)(hardhat@2.13.1)(typechain@8.3.2) - hardhat: 2.13.1(typescript@5.1.6) - typechain: 8.3.2(typescript@5.1.6) + '@ethersproject/abi': 5.7.0 + '@ethersproject/abstract-provider': 5.7.0 + '@ethersproject/address': 5.7.0 + '@ethersproject/bignumber': 5.7.0 + '@ethersproject/bytes': 5.7.0 + '@ethersproject/constants': 5.7.0 + '@ethersproject/contracts': 5.7.0 + '@ethersproject/hash': 5.7.0 + '@ethersproject/keccak256': 5.7.0 + '@ethersproject/properties': 5.7.0 + '@ethersproject/providers': 5.7.2 + '@ethersproject/rlp': 5.7.0 + '@ethersproject/transactions': 5.7.0 + '@ethersproject/web': 5.7.1 + bufio: 1.2.1 + chai: 4.3.10 transitivePeerDependencies: - - '@ethersproject/abi' - - '@ethersproject/providers' - bufferutil - - ethers - - supports-color - - ts-node - - typescript - utf-8-validate - dev: false + dev: true - /@ethereum-attestation-service/eas-sdk@0.28.3(@ethersproject/abi@5.7.0)(@ethersproject/providers@5.7.2)(ts-node@10.9.1)(typescript@4.9.5): - resolution: {integrity: sha512-Z197jE5oi8Eh9SmjldTnkPKKhOId2NA9OyEFvbXDMafoHtfC6V117r0GHj9IlsOGtaK8Y0fiZYX1EKMKcJb6UQ==} + /@ethereum-attestation-service/eas-contracts@1.2.0-beta.1(ts-node@10.9.1)(typescript@5.1.6): + resolution: {integrity: sha512-NOicVFjm3UOY6HHmMPIpFTZJ7ieuETl7GRJyceW/CPPXxMMBBu9tf9eDVbVrDn6D7fYX3NMDIR39RoK5BhpWYA==} dependencies: - '@ethereum-attestation-service/eas-contracts': 0.27.1(@ethersproject/abi@5.7.0)(@ethersproject/providers@5.7.2)(ethers@5.7.2)(ts-node@10.9.1)(typescript@4.9.5) - ethers: 5.7.2 - multiformats: 9.9.0 + hardhat: 2.18.2(ts-node@10.9.1)(typescript@5.1.6) transitivePeerDependencies: - - '@ethersproject/abi' - - '@ethersproject/providers' - bufferutil - supports-color - ts-node @@ -5143,15 +5146,17 @@ packages: - utf-8-validate dev: false - /@ethereum-attestation-service/eas-sdk@0.28.3(@ethersproject/abi@5.7.0)(@ethersproject/providers@5.7.2)(typescript@5.1.6): - resolution: {integrity: sha512-Z197jE5oi8Eh9SmjldTnkPKKhOId2NA9OyEFvbXDMafoHtfC6V117r0GHj9IlsOGtaK8Y0fiZYX1EKMKcJb6UQ==} + /@ethereum-attestation-service/eas-sdk@1.2.2-beta.0(ts-node@10.9.1)(typescript@5.1.6): + resolution: {integrity: sha512-penkXiCKvHY8jN9UVV3B9IX001YnwWCNjbrBNE5e8Wy1rAzcPv7tqTBuvqXzjqmHfcASv7UFOIbfPEc5hd9mpA==} dependencies: - '@ethereum-attestation-service/eas-contracts': 0.27.1(@ethersproject/abi@5.7.0)(@ethersproject/providers@5.7.2)(ethers@5.7.2)(typescript@5.1.6) - ethers: 5.7.2 + '@ethereum-attestation-service/eas-contracts': 1.2.0-beta.1(ts-node@10.9.1)(typescript@5.1.6) + ethers: 6.8.0 + js-base64: 3.7.5 + lodash: 4.17.21 multiformats: 9.9.0 + pako: 2.1.0 + semver: 7.5.4 transitivePeerDependencies: - - '@ethersproject/abi' - - '@ethersproject/providers' - bufferutil - supports-color - ts-node @@ -5163,7 +5168,7 @@ packages: resolution: {integrity: sha512-X5RepE7Dn8KQLFO7HHAAe+KeGaX/by14hn90wePGBhzL54tq4Y8JscZFu+/LCwCl6TnkAAy5ebiMoqJ37sFtWw==} engines: {node: '>=10.0'} peerDependencies: - ethers: ^5.7.2 + ethers: '*' dependencies: '@ethereum-waffle/provider': 4.0.5(@ensdomains/ens@0.4.5)(@ensdomains/resolver@0.2.4)(ethers@5.7.2) debug: 4.3.4(supports-color@8.1.1) @@ -5175,24 +5180,24 @@ packages: - supports-color dev: true - /@ethereum-waffle/compiler@4.0.3(@ethersproject/abi@5.7.0)(@ethersproject/providers@5.7.2)(ethers@5.7.2)(solc@0.8.15)(typechain@8.3.2)(typescript@4.9.5): + /@ethereum-waffle/compiler@4.0.3(@ethersproject/abi@5.7.0)(@ethersproject/providers@5.7.2)(ethers@5.7.2)(solc@0.8.15)(typechain@8.3.2)(typescript@5.1.6): resolution: {integrity: sha512-5x5U52tSvEVJS6dpCeXXKvRKyf8GICDwiTwUvGD3/WD+DpvgvaoHOL82XqpTSUHgV3bBq6ma5/8gKUJUIAnJCw==} engines: {node: '>=10.0'} peerDependencies: - ethers: ^5.7.2 + ethers: '*' solc: '*' typechain: ^8.0.0 dependencies: '@resolver-engine/imports': 0.3.3 '@resolver-engine/imports-fs': 0.3.3 - '@typechain/ethers-v5': 10.2.1(@ethersproject/abi@5.7.0)(@ethersproject/providers@5.7.2)(ethers@5.7.2)(typechain@8.3.2)(typescript@4.9.5) + '@typechain/ethers-v5': 10.2.1(@ethersproject/abi@5.7.0)(@ethersproject/providers@5.7.2)(ethers@5.7.2)(typechain@8.3.2)(typescript@5.1.6) '@types/mkdirp': 0.5.2 - '@types/node-fetch': 2.6.7 + '@types/node-fetch': 2.6.8 ethers: 5.7.2 mkdirp: 0.5.6 node-fetch: 2.7.0 solc: 0.8.15 - typechain: 8.3.2(typescript@4.9.5) + typechain: 8.3.2(typescript@5.1.6) transitivePeerDependencies: - '@ethersproject/abi' - '@ethersproject/providers' @@ -5207,7 +5212,7 @@ packages: peerDependencies: '@ensdomains/ens': ^0.4.4 '@ensdomains/resolver': ^0.2.4 - ethers: ^5.7.2 + ethers: '*' dependencies: '@ensdomains/ens': 0.4.5 '@ensdomains/resolver': 0.2.4 @@ -5218,7 +5223,7 @@ packages: resolution: {integrity: sha512-LwEj5SIuEe9/gnrXgtqIkWbk2g15imM/qcJcxpLyAkOj981tQxXmtV4XmQMZsdedEsZ/D/rbUAOtZbgwqgUwQA==} engines: {node: '>=10.0'} peerDependencies: - ethers: ^5.7.2 + ethers: '*' dependencies: ethers: 5.7.2 dev: true @@ -5227,7 +5232,7 @@ packages: resolution: {integrity: sha512-40uzfyzcrPh+Gbdzv89JJTMBlZwzya1YLDyim8mVbEqYLP5VRYWoGp0JMyaizgV3hMoUFRqJKVmIUw4v7r3hYw==} engines: {node: '>=10.0'} peerDependencies: - ethers: ^5.7.2 + ethers: '*' dependencies: '@ethereum-waffle/ens': 4.0.3(@ensdomains/ens@0.4.5)(@ensdomains/resolver@0.2.4)(ethers@5.7.2) '@ganache/ethereum-options': 0.1.4 @@ -5268,7 +5273,7 @@ packages: resolution: {integrity: sha512-Cq2qS0FTu6O2VU1sgg+WyU9Ps0M6j/BEMHN+hRaECXCV/r0aI78u4N6p52QW/BDVhwWZpCdrvG8X7NJdzlpNUA==} dependencies: crc-32: 1.2.2 - ethereumjs-util: 7.1.3 + ethereumjs-util: 7.1.5 dev: true /@ethereumjs/common@2.6.5: @@ -5298,7 +5303,7 @@ packages: resolution: {integrity: sha512-WWUwg1PdjHKZZxPPo274ZuPsJCWV3SqATrEKQP1n2DrVYVP1aZIYpo/mFaA0BDoE0tIQmBeimRCEA0Lgil+yYw==} dependencies: '@ethereumjs/common': 2.6.0 - ethereumjs-util: 7.1.3 + ethereumjs-util: 7.1.5 dev: true /@ethereumjs/tx@3.5.2: @@ -5327,7 +5332,7 @@ packages: async-eventemitter: 0.2.4 core-js-pure: 3.33.1 debug: 2.6.9 - ethereumjs-util: 7.1.3 + ethereumjs-util: 7.1.5 functional-red-black-tree: 1.0.1 mcl-wasm: 0.7.9 merkle-patricia-tree: 4.2.4 @@ -5759,7 +5764,7 @@ packages: '@graphql-tools/delegate': ^9.0.32 '@graphql-tools/utils': ^9.2.1 '@graphql-tools/wrap': ^9.4.2 - graphql: ^16.6.0 + graphql: ^15.2.0 || ^16.0.0 dependencies: '@graphql-mesh/types': 0.93.2(@graphql-mesh/store@0.93.1)(@graphql-tools/utils@9.2.1)(graphql@16.8.1)(tslib@2.6.2) '@graphql-tools/delegate': 9.0.35(graphql@16.8.1) @@ -5770,16 +5775,16 @@ packages: tslib: 2.6.2 dev: false - /@graphprotocol/client-add-source-name@1.0.20(@graphql-mesh/types@0.95.7)(@graphql-tools/delegate@9.0.35)(@graphql-tools/utils@9.2.1)(@graphql-tools/wrap@9.4.2)(graphql@16.8.1): + /@graphprotocol/client-add-source-name@1.0.20(@graphql-mesh/types@0.95.8)(@graphql-tools/delegate@9.0.35)(@graphql-tools/utils@9.2.1)(@graphql-tools/wrap@9.4.2)(graphql@16.8.1): resolution: {integrity: sha512-JJ++BVg4fhNCbLej105uHpabZesLsCSo9p43ZKSTT1VUdbuZtarzyIHC3uUmbvCfWQMVTCJEBZGx4l41oooOiw==} peerDependencies: '@graphql-mesh/types': ^0.78.0 || ^0.79.0 || ^0.80.0 || ^0.81.0 || ^0.82.0 || ^0.83.0 || ^0.84.0 || ^0.85.0 || ^0.89.0 || ^0.90.0 || ^0.91.0 || ^0.93.0 '@graphql-tools/delegate': ^9.0.32 '@graphql-tools/utils': ^9.2.1 '@graphql-tools/wrap': ^9.4.2 - graphql: ^16.6.0 + graphql: ^15.2.0 || ^16.0.0 dependencies: - '@graphql-mesh/types': 0.95.7(@graphql-mesh/store@0.95.7)(@graphql-tools/utils@9.2.1)(graphql@16.8.1)(tslib@2.6.2) + '@graphql-mesh/types': 0.95.8(@graphql-mesh/store@0.95.8)(@graphql-tools/utils@9.2.1)(graphql@16.8.1)(tslib@2.6.2) '@graphql-tools/delegate': 9.0.35(graphql@16.8.1) '@graphql-tools/utils': 9.2.1(graphql@16.8.1) '@graphql-tools/wrap': 9.4.2(graphql@16.8.1) @@ -5788,7 +5793,7 @@ packages: tslib: 2.6.2 dev: false - /@graphprotocol/client-add-source-name@2.0.0(@graphql-mesh/types@0.95.7)(@graphql-tools/delegate@9.0.35)(@graphql-tools/utils@9.2.1)(@graphql-tools/wrap@9.4.2)(graphql@16.8.1): + /@graphprotocol/client-add-source-name@2.0.0(@graphql-mesh/types@0.95.8)(@graphql-tools/delegate@9.0.35)(@graphql-tools/utils@9.2.1)(@graphql-tools/wrap@9.4.2)(graphql@16.8.1): resolution: {integrity: sha512-3vX8mVPIEJFwAoRhjTPd9IjQrBuE+Gv+JB7IEf8/9222qiU9EzHVFUekKxVtcxQXD40CfageS41CxOreWQ1enA==} engines: {node: '>=16.0.0'} peerDependencies: @@ -5796,9 +5801,9 @@ packages: '@graphql-tools/delegate': ^9.0.32 || ^10.0.0 '@graphql-tools/utils': ^9.2.1 || ^10.0.0 '@graphql-tools/wrap': ^9.4.2 || ^10.0.0 - graphql: ^16.6.0 + graphql: ^15.2.0 || ^16.0.0 dependencies: - '@graphql-mesh/types': 0.95.7(@graphql-mesh/store@0.95.7)(@graphql-tools/utils@9.2.1)(graphql@16.8.1)(tslib@2.6.2) + '@graphql-mesh/types': 0.95.8(@graphql-mesh/store@0.95.8)(@graphql-tools/utils@9.2.1)(graphql@16.8.1)(tslib@2.6.2) '@graphql-tools/delegate': 9.0.35(graphql@16.8.1) '@graphql-tools/utils': 9.2.1(graphql@16.8.1) '@graphql-tools/wrap': 9.4.2(graphql@16.8.1) @@ -5814,7 +5819,7 @@ packages: '@graphql-tools/delegate': ^9.0.32 '@graphql-tools/utils': ^9.2.1 '@graphql-tools/wrap': ^9.4.2 - graphql: ^16.6.0 + graphql: ^15.2.0 || ^16.0.0 dependencies: '@graphql-mesh/types': 0.93.2(@graphql-mesh/store@0.93.1)(@graphql-tools/utils@9.2.1)(graphql@16.8.1)(tslib@2.6.2) '@graphql-tools/delegate': 9.0.35(graphql@16.8.1) @@ -5825,7 +5830,7 @@ packages: tslib: 2.6.2 dev: false - /@graphprotocol/client-auto-pagination@2.0.0(@graphql-mesh/types@0.95.7)(@graphql-tools/delegate@9.0.35)(@graphql-tools/utils@9.2.1)(@graphql-tools/wrap@9.4.2)(graphql@16.8.1): + /@graphprotocol/client-auto-pagination@2.0.0(@graphql-mesh/types@0.95.8)(@graphql-tools/delegate@9.0.35)(@graphql-tools/utils@9.2.1)(@graphql-tools/wrap@9.4.2)(graphql@16.8.1): resolution: {integrity: sha512-TouHgs6rQLpZSgnMoPdes8/ZTtMMEoxWeUUCkfho/xfSi49prb5DcsI83pykln0OEAUnNPnaX0MhP+xA5LtFSg==} engines: {node: '>=16.0.0'} peerDependencies: @@ -5833,9 +5838,9 @@ packages: '@graphql-tools/delegate': ^9.0.32 || ^10.0.0 '@graphql-tools/utils': ^9.2.1 || ^10.0.0 '@graphql-tools/wrap': ^9.4.2 || ^10.0.0 - graphql: ^16.6.0 + graphql: ^15.2.0 || ^16.0.0 dependencies: - '@graphql-mesh/types': 0.95.7(@graphql-mesh/store@0.95.7)(@graphql-tools/utils@9.2.1)(graphql@16.8.1)(tslib@2.6.2) + '@graphql-mesh/types': 0.95.8(@graphql-mesh/store@0.95.8)(@graphql-tools/utils@9.2.1)(graphql@16.8.1)(tslib@2.6.2) '@graphql-tools/delegate': 9.0.35(graphql@16.8.1) '@graphql-tools/utils': 9.2.1(graphql@16.8.1) '@graphql-tools/wrap': 9.4.2(graphql@16.8.1) @@ -5849,7 +5854,7 @@ packages: peerDependencies: '@graphql-mesh/types': ^0.78.0 || ^0.79.0 || ^0.80.0 || ^0.81.0 || ^0.82.0 || ^0.83.0 || ^0.84.0 || ^0.85.0 || ^0.89.0 || ^0.90.0 || ^0.91.0 || ^0.93.0 '@graphql-tools/delegate': ^9.0.32 - graphql: ^16.6.0 + graphql: ^15.2.0 || ^16.0.0 dependencies: '@graphql-mesh/transform-type-merging': 0.93.1(@graphql-mesh/types@0.93.2)(@graphql-mesh/utils@0.93.2)(graphql@16.8.1)(tslib@2.6.2) '@graphql-mesh/types': 0.93.2(@graphql-mesh/store@0.93.1)(@graphql-tools/utils@9.2.1)(graphql@16.8.1)(tslib@2.6.2) @@ -5860,16 +5865,16 @@ packages: - '@graphql-mesh/utils' dev: false - /@graphprotocol/client-auto-type-merging@2.0.0(@graphql-mesh/types@0.95.7)(@graphql-mesh/utils@0.95.7)(@graphql-tools/delegate@9.0.35)(graphql@16.8.1): + /@graphprotocol/client-auto-type-merging@2.0.0(@graphql-mesh/types@0.95.8)(@graphql-mesh/utils@0.95.8)(@graphql-tools/delegate@9.0.35)(graphql@16.8.1): resolution: {integrity: sha512-mxqXKHK2lO+k4r02Q44n3qhd5dufo+SSDduD8zGUDBsYcRQAtQD9PwmXRHyUoB9nw4A+NC+CtVh+76fueXCG1w==} engines: {node: '>=16.0.0'} peerDependencies: '@graphql-mesh/types': ^0.78.0 || ^0.79.0 || ^0.80.0 || ^0.81.0 || ^0.82.0 || ^0.83.0 || ^0.84.0 || ^0.85.0 || ^0.89.0 || ^0.90.0 || ^0.91.0 || ^0.93.0 '@graphql-tools/delegate': ^9.0.32 || ^10.0.0 - graphql: ^16.6.0 + graphql: ^15.2.0 || ^16.0.0 dependencies: - '@graphql-mesh/transform-type-merging': 0.93.1(@graphql-mesh/types@0.95.7)(@graphql-mesh/utils@0.95.7)(graphql@16.8.1)(tslib@2.6.2) - '@graphql-mesh/types': 0.95.7(@graphql-mesh/store@0.95.7)(@graphql-tools/utils@9.2.1)(graphql@16.8.1)(tslib@2.6.2) + '@graphql-mesh/transform-type-merging': 0.93.1(@graphql-mesh/types@0.95.8)(@graphql-mesh/utils@0.95.8)(graphql@16.8.1)(tslib@2.6.2) + '@graphql-mesh/types': 0.95.8(@graphql-mesh/store@0.95.8)(@graphql-tools/utils@9.2.1)(graphql@16.8.1)(tslib@2.6.2) '@graphql-tools/delegate': 9.0.35(graphql@16.8.1) graphql: 16.8.1 tslib: 2.6.2 @@ -5881,7 +5886,7 @@ packages: resolution: {integrity: sha512-Eim0fZ0AgukHt5770j/UYDxfrqJroOhDe8FfNKKN7mDVRoMBoCsNknH47i03fh4A/kE8R+J6Job/zEJZPTtKnQ==} peerDependencies: '@graphql-tools/delegate': ^9.0.32 - graphql: ^16.6.0 + graphql: ^15.2.0 || ^16.0.0 dependencies: '@graphql-tools/delegate': 9.0.35(graphql@16.8.1) '@graphql-tools/utils': 9.2.1(graphql@16.8.1) @@ -5894,7 +5899,7 @@ packages: engines: {node: '>=16.0.0'} peerDependencies: '@graphql-tools/delegate': ^9.0.32 || ^10.0.0 - graphql: ^16.6.0 + graphql: ^15.2.0 || ^16.0.0 dependencies: '@graphql-tools/delegate': 9.0.35(graphql@16.8.1) '@graphql-tools/utils': 10.0.7(graphql@16.8.1) @@ -5902,19 +5907,19 @@ packages: tslib: 2.6.2 dev: true - /@graphprotocol/client-cli@2.2.22(@babel/core@7.23.2)(@envelop/core@3.0.6)(@graphql-mesh/cross-helpers@0.3.4)(@graphql-mesh/store@0.93.1)(@graphql-mesh/types@0.93.2)(@graphql-mesh/utils@0.93.2)(@graphql-tools/delegate@9.0.35)(@graphql-tools/merge@8.4.2)(@graphql-tools/utils@9.2.1)(@graphql-tools/wrap@9.4.2)(@types/node@18.18.6)(graphql-tag@2.12.6)(graphql@16.8.1)(react-native@0.72.6): + /@graphprotocol/client-cli@2.2.22(@babel/core@7.23.2)(@envelop/core@3.0.6)(@graphql-mesh/cross-helpers@0.3.4)(@graphql-mesh/store@0.93.1)(@graphql-mesh/types@0.93.2)(@graphql-mesh/utils@0.93.2)(@graphql-tools/delegate@9.0.35)(@graphql-tools/merge@8.4.2)(@graphql-tools/utils@9.2.1)(@graphql-tools/wrap@9.4.2)(@types/node@18.18.7)(graphql-tag@2.12.6)(graphql@16.8.1)(react-native@0.72.6): resolution: {integrity: sha512-PIi8rFibYZVup+0jb08399RmbGF1ZrqUe6RXzLtKZBT57OWIMWwsFvdJyUAdr8Y8f0rrMn6A+Oy4nP1lf3hc1g==} hasBin: true peerDependencies: - graphql: ^16.6.0 + graphql: ^15.2.0 || ^16.0.0 dependencies: '@graphprotocol/client-add-source-name': 1.0.20(@graphql-mesh/types@0.93.2)(@graphql-tools/delegate@9.0.35)(@graphql-tools/utils@9.2.1)(@graphql-tools/wrap@9.4.2)(graphql@16.8.1) '@graphprotocol/client-auto-pagination': 1.1.18(@graphql-mesh/types@0.93.2)(@graphql-tools/delegate@9.0.35)(@graphql-tools/utils@9.2.1)(@graphql-tools/wrap@9.4.2)(graphql@16.8.1) '@graphprotocol/client-auto-type-merging': 1.0.25(@graphql-mesh/types@0.93.2)(@graphql-mesh/utils@0.93.2)(@graphql-tools/delegate@9.0.35)(graphql@16.8.1) '@graphprotocol/client-block-tracking': 1.0.14(@graphql-tools/delegate@9.0.35)(graphql@16.8.1) '@graphprotocol/client-polling-live': 1.1.1(@envelop/core@3.0.6)(@graphql-tools/merge@8.4.2)(graphql@16.8.1) - '@graphql-mesh/cli': 0.82.35(@babel/core@7.23.2)(@types/node@18.18.6)(graphql-tag@2.12.6)(graphql@16.8.1)(react-native@0.72.6) - '@graphql-mesh/graphql': 0.93.1(@graphql-mesh/cross-helpers@0.3.4)(@graphql-mesh/store@0.93.1)(@graphql-mesh/types@0.93.2)(@graphql-mesh/utils@0.93.2)(@graphql-tools/utils@9.2.1)(@types/node@18.18.6)(graphql@16.8.1)(tslib@2.6.2) + '@graphql-mesh/cli': 0.82.35(@babel/core@7.23.2)(@types/node@18.18.7)(graphql-tag@2.12.6)(graphql@16.8.1)(react-native@0.72.6) + '@graphql-mesh/graphql': 0.93.1(@graphql-mesh/cross-helpers@0.3.4)(@graphql-mesh/store@0.93.1)(@graphql-mesh/types@0.93.2)(@graphql-mesh/utils@0.93.2)(@graphql-tools/utils@9.2.1)(@types/node@18.18.7)(graphql@16.8.1)(tslib@2.6.2) graphql: 16.8.1 tslib: 2.6.2 transitivePeerDependencies: @@ -5940,20 +5945,20 @@ packages: - utf-8-validate dev: false - /@graphprotocol/client-cli@3.0.0(@babel/core@7.23.2)(@envelop/core@3.0.6)(@graphql-mesh/cross-helpers@0.4.1)(@graphql-mesh/store@0.95.7)(@graphql-mesh/types@0.95.7)(@graphql-mesh/utils@0.95.7)(@graphql-tools/delegate@9.0.35)(@graphql-tools/merge@9.0.0)(@graphql-tools/utils@9.2.1)(@graphql-tools/wrap@9.4.2)(@types/node@18.18.6)(graphql-tag@2.12.6)(graphql@16.8.1)(react-native@0.72.6): + /@graphprotocol/client-cli@3.0.0(@babel/core@7.23.2)(@envelop/core@3.0.6)(@graphql-mesh/cross-helpers@0.4.1)(@graphql-mesh/store@0.95.8)(@graphql-mesh/types@0.95.8)(@graphql-mesh/utils@0.95.8)(@graphql-tools/delegate@9.0.35)(@graphql-tools/merge@9.0.0)(@graphql-tools/utils@9.2.1)(@graphql-tools/wrap@9.4.2)(@types/node@18.18.7)(graphql-tag@2.12.6)(graphql@16.8.1)(react-native@0.72.6): resolution: {integrity: sha512-hTISbOzKavlDifBNsR6JqQMfdYwY7++hflPy+c3WHRrZ4OMoxFmW7ZuvaP6LvgKdJV77O8w9dnT/uxeHs6a90g==} engines: {node: '>=16.0.0'} hasBin: true peerDependencies: - graphql: ^16.6.0 + graphql: ^15.2.0 || ^16.0.0 dependencies: - '@graphprotocol/client-add-source-name': 2.0.0(@graphql-mesh/types@0.95.7)(@graphql-tools/delegate@9.0.35)(@graphql-tools/utils@9.2.1)(@graphql-tools/wrap@9.4.2)(graphql@16.8.1) - '@graphprotocol/client-auto-pagination': 2.0.0(@graphql-mesh/types@0.95.7)(@graphql-tools/delegate@9.0.35)(@graphql-tools/utils@9.2.1)(@graphql-tools/wrap@9.4.2)(graphql@16.8.1) - '@graphprotocol/client-auto-type-merging': 2.0.0(@graphql-mesh/types@0.95.7)(@graphql-mesh/utils@0.95.7)(@graphql-tools/delegate@9.0.35)(graphql@16.8.1) + '@graphprotocol/client-add-source-name': 2.0.0(@graphql-mesh/types@0.95.8)(@graphql-tools/delegate@9.0.35)(@graphql-tools/utils@9.2.1)(@graphql-tools/wrap@9.4.2)(graphql@16.8.1) + '@graphprotocol/client-auto-pagination': 2.0.0(@graphql-mesh/types@0.95.8)(@graphql-tools/delegate@9.0.35)(@graphql-tools/utils@9.2.1)(@graphql-tools/wrap@9.4.2)(graphql@16.8.1) + '@graphprotocol/client-auto-type-merging': 2.0.0(@graphql-mesh/types@0.95.8)(@graphql-mesh/utils@0.95.8)(@graphql-tools/delegate@9.0.35)(graphql@16.8.1) '@graphprotocol/client-block-tracking': 2.0.0(@graphql-tools/delegate@9.0.35)(graphql@16.8.1) '@graphprotocol/client-polling-live': 2.0.0(@envelop/core@3.0.6)(@graphql-tools/merge@9.0.0)(graphql@16.8.1) - '@graphql-mesh/cli': 0.82.35(@babel/core@7.23.2)(@types/node@18.18.6)(graphql-tag@2.12.6)(graphql@16.8.1)(react-native@0.72.6) - '@graphql-mesh/graphql': 0.93.1(@graphql-mesh/cross-helpers@0.4.1)(@graphql-mesh/store@0.95.7)(@graphql-mesh/types@0.95.7)(@graphql-mesh/utils@0.95.7)(@graphql-tools/utils@9.2.1)(@types/node@18.18.6)(graphql@16.8.1)(tslib@2.6.2) + '@graphql-mesh/cli': 0.82.35(@babel/core@7.23.2)(@types/node@18.18.7)(graphql-tag@2.12.6)(graphql@16.8.1)(react-native@0.72.6) + '@graphql-mesh/graphql': 0.93.1(@graphql-mesh/cross-helpers@0.4.1)(@graphql-mesh/store@0.95.8)(@graphql-mesh/types@0.95.8)(@graphql-mesh/utils@0.95.8)(@graphql-tools/utils@9.2.1)(@types/node@18.18.7)(graphql@16.8.1)(tslib@2.6.2) graphql: 16.8.1 tslib: 2.6.2 transitivePeerDependencies: @@ -5984,7 +5989,7 @@ packages: peerDependencies: '@envelop/core': ^2.4.2 || ^3.0.0 '@graphql-tools/merge': ^8.3.14 - graphql: ^16.6.0 + graphql: ^15.2.0 || ^16.0.0 dependencies: '@envelop/core': 3.0.6 '@graphql-tools/merge': 8.4.2(graphql@16.8.1) @@ -5999,7 +6004,7 @@ packages: peerDependencies: '@envelop/core': ^2.4.2 || ^3.0.0 || ^4.0.0 '@graphql-tools/merge': ^8.3.14 || ^9.0.0 - graphql: ^16.6.0 + graphql: ^15.2.0 || ^16.0.0 dependencies: '@envelop/core': 3.0.6 '@graphql-tools/merge': 8.4.2(graphql@16.8.1) @@ -6014,7 +6019,7 @@ packages: peerDependencies: '@envelop/core': ^2.4.2 || ^3.0.0 || ^4.0.0 '@graphql-tools/merge': ^8.3.14 || ^9.0.0 - graphql: ^16.6.0 + graphql: ^15.2.0 || ^16.0.0 dependencies: '@envelop/core': 3.0.6 '@graphql-tools/merge': 9.0.0(graphql@16.8.1) @@ -6022,15 +6027,15 @@ packages: graphql: 16.8.1 tslib: 2.6.2 - /@graphprotocol/graph-cli@0.60.0(@types/node@18.18.6)(node-fetch@3.3.2)(typescript@4.9.5): + /@graphprotocol/graph-cli@0.60.0(@types/node@18.18.7)(node-fetch@3.3.2)(typescript@4.9.5): resolution: {integrity: sha512-8tGaQJ0EzAPtkDXCAijFGoVdJXM+pKFlGxjiU31TdG5bS4cIUoSB6yWojVsFFod0yETAwf+giel/0/8sudYsDw==} engines: {node: '>=14'} hasBin: true dependencies: '@float-capital/float-subgraph-uncrashable': 0.0.0-internal-testing.5 - '@oclif/core': 2.8.6(@types/node@18.18.6)(typescript@4.9.5) - '@oclif/plugin-autocomplete': 2.3.10(@types/node@18.18.6)(typescript@4.9.5) - '@oclif/plugin-not-found': 2.4.3(@types/node@18.18.6)(typescript@4.9.5) + '@oclif/core': 2.8.6(@types/node@18.18.7)(typescript@4.9.5) + '@oclif/plugin-autocomplete': 2.3.10(@types/node@18.18.7)(typescript@4.9.5) + '@oclif/plugin-not-found': 2.4.3(@types/node@18.18.7)(typescript@4.9.5) '@whatwg-node/fetch': 0.8.8 assemblyscript: 0.19.23 binary-install-raw: 0.0.13(debug@4.3.4) @@ -6042,7 +6047,7 @@ packages: fs-extra: 9.1.0 glob: 9.3.5 gluegun: 5.1.2(debug@4.3.4) - graphql: 16.8.1 + graphql: 15.5.0 immutable: 4.2.1 ipfs-http-client: 55.0.0(node-fetch@3.3.2) jayson: 4.0.0 @@ -6076,7 +6081,7 @@ packages: /@graphql-codegen/core@3.1.0(graphql@16.8.1): resolution: {integrity: sha512-DH1/yaR7oJE6/B+c6ZF2Tbdh7LixF1K8L+8BoSubjNyQ8pNwR4a70mvc1sv6H7qgp6y1bPQ9tKE+aazRRshysw==} peerDependencies: - graphql: ^16.6.0 + graphql: ^0.8.0 || ^0.9.0 || ^0.10.0 || ^0.11.0 || ^0.12.0 || ^0.13.0 || ^14.0.0 || ^15.0.0 || ^16.0.0 dependencies: '@graphql-codegen/plugin-helpers': 4.2.0(graphql@16.8.1) '@graphql-tools/schema': 9.0.19(graphql@16.8.1) @@ -6087,7 +6092,7 @@ packages: /@graphql-codegen/plugin-helpers@2.7.2(graphql@16.8.1): resolution: {integrity: sha512-kln2AZ12uii6U59OQXdjLk5nOlh1pHis1R98cDZGFnfaiAbX9V3fxcZ1MMJkB7qFUymTALzyjZoXXdyVmPMfRg==} peerDependencies: - graphql: ^16.6.0 + graphql: ^0.8.0 || ^0.9.0 || ^0.10.0 || ^0.11.0 || ^0.12.0 || ^0.13.0 || ^14.0.0 || ^15.0.0 || ^16.0.0 dependencies: '@graphql-tools/utils': 8.13.1(graphql@16.8.1) change-case-all: 1.0.14 @@ -6100,7 +6105,7 @@ packages: /@graphql-codegen/plugin-helpers@3.1.2(graphql@16.8.1): resolution: {integrity: sha512-emOQiHyIliVOIjKVKdsI5MXj312zmRDwmHpyUTZMjfpvxq/UVAHUJIVdVf+lnjjrI+LXBTgMlTWTgHQfmICxjg==} peerDependencies: - graphql: ^16.6.0 + graphql: ^0.8.0 || ^0.9.0 || ^0.10.0 || ^0.11.0 || ^0.12.0 || ^0.13.0 || ^14.0.0 || ^15.0.0 || ^16.0.0 dependencies: '@graphql-tools/utils': 9.2.1(graphql@16.8.1) change-case-all: 1.0.15 @@ -6113,7 +6118,7 @@ packages: /@graphql-codegen/plugin-helpers@4.2.0(graphql@16.8.1): resolution: {integrity: sha512-THFTCfg+46PXlXobYJ/OoCX6pzjI+9woQqCjdyKtgoI0tn3Xq2HUUCiidndxUpEYVrXb5pRiRXb7b/ZbMQqD0A==} peerDependencies: - graphql: ^16.6.0 + graphql: ^0.8.0 || ^0.9.0 || ^0.10.0 || ^0.11.0 || ^0.12.0 || ^0.13.0 || ^14.0.0 || ^15.0.0 || ^16.0.0 dependencies: '@graphql-tools/utils': 9.2.1(graphql@16.8.1) change-case-all: 1.0.15 @@ -6126,7 +6131,7 @@ packages: /@graphql-codegen/schema-ast@3.0.1(graphql@16.8.1): resolution: {integrity: sha512-rTKTi4XiW4QFZnrEqetpiYEWVsOFNoiR/v3rY9mFSttXFbIwNXPme32EspTiGWmEEdHY8UuTDtZN3vEcs/31zw==} peerDependencies: - graphql: ^16.6.0 + graphql: ^0.8.0 || ^0.9.0 || ^0.10.0 || ^0.11.0 || ^0.12.0 || ^0.13.0 || ^14.0.0 || ^15.0.0 || ^16.0.0 dependencies: '@graphql-codegen/plugin-helpers': 4.2.0(graphql@16.8.1) '@graphql-tools/utils': 9.2.1(graphql@16.8.1) @@ -6136,7 +6141,7 @@ packages: /@graphql-codegen/typed-document-node@4.0.1(graphql@16.8.1): resolution: {integrity: sha512-mQNYCd12JsFSaK6xLry4olY9TdYG7GxQPexU6qU4Om++eKhseGwk2eGmQDRG4Qp8jEDFLMXuHMVUKqMQ1M+F/A==} peerDependencies: - graphql: ^16.6.0 + graphql: ^0.8.0 || ^0.9.0 || ^0.10.0 || ^0.11.0 || ^0.12.0 || ^0.13.0 || ^14.0.0 || ^15.0.0 || ^16.0.0 dependencies: '@graphql-codegen/plugin-helpers': 4.2.0(graphql@16.8.1) '@graphql-codegen/visitor-plugin-common': 3.1.1(graphql@16.8.1) @@ -6151,7 +6156,7 @@ packages: /@graphql-codegen/typescript-generic-sdk@3.1.0(graphql-tag@2.12.6)(graphql@16.8.1): resolution: {integrity: sha512-nQZi/YGRI1+qCZZsh0V5nz6+hCHSN4OU9tKyOTDsEPyDFnGEukDuRdCH2IZasGn22a3Iu5TUDkgp5w9wEQwGmg==} peerDependencies: - graphql: ^16.6.0 + graphql: ^0.8.0 || ^0.9.0 || ^0.10.0 || ^0.11.0 || ^0.12.0 || ^0.13.0 || ^14.0.0 || ^15.0.0 || ^16.0.0 graphql-tag: ^2.0.0 dependencies: '@graphql-codegen/plugin-helpers': 3.1.2(graphql@16.8.1) @@ -6167,7 +6172,7 @@ packages: /@graphql-codegen/typescript-operations@3.0.4(graphql@16.8.1): resolution: {integrity: sha512-6yE2OL2+WJ1vd5MwFEGXpaxsFGzjAGUytPVHDML3Bi3TwP1F3lnQlIko4untwvHW0JhZEGQ7Ck30H9HjcxpdKA==} peerDependencies: - graphql: ^16.6.0 + graphql: ^0.8.0 || ^0.9.0 || ^0.10.0 || ^0.11.0 || ^0.12.0 || ^0.13.0 || ^14.0.0 || ^15.0.0 || ^16.0.0 dependencies: '@graphql-codegen/plugin-helpers': 4.2.0(graphql@16.8.1) '@graphql-codegen/typescript': 3.0.4(graphql@16.8.1) @@ -6182,7 +6187,7 @@ packages: /@graphql-codegen/typescript-resolvers@3.2.1(graphql@16.8.1): resolution: {integrity: sha512-2ZIHk5J6HTuylse5ZIxw+aega54prHxvj7vM8hiKJ6vejZ94kvVPAq4aWmSFOkZ5lqU3YnM/ZyWfnhT5CUDj1g==} peerDependencies: - graphql: ^16.6.0 + graphql: ^0.8.0 || ^0.9.0 || ^0.10.0 || ^0.11.0 || ^0.12.0 || ^0.13.0 || ^14.0.0 || ^15.0.0 || ^16.0.0 dependencies: '@graphql-codegen/plugin-helpers': 4.2.0(graphql@16.8.1) '@graphql-codegen/typescript': 3.0.4(graphql@16.8.1) @@ -6198,7 +6203,7 @@ packages: /@graphql-codegen/typescript@3.0.4(graphql@16.8.1): resolution: {integrity: sha512-x4O47447DZrWNtE/l5CU9QzzW4m1RbmCEdijlA3s2flG/y1Ckqdemob4CWfilSm5/tZ3w1junVDY616RDTSvZw==} peerDependencies: - graphql: ^16.6.0 + graphql: ^0.12.0 || ^0.13.0 || ^14.0.0 || ^15.0.0 || ^16.0.0 dependencies: '@graphql-codegen/plugin-helpers': 4.2.0(graphql@16.8.1) '@graphql-codegen/schema-ast': 3.0.1(graphql@16.8.1) @@ -6213,7 +6218,7 @@ packages: /@graphql-codegen/visitor-plugin-common@2.13.1(graphql@16.8.1): resolution: {integrity: sha512-mD9ufZhDGhyrSaWQGrU1Q1c5f01TeWtSWy/cDwXYjJcHIj1Y/DG2x0tOflEfCvh5WcnmHNIw4lzDsg1W7iFJEg==} peerDependencies: - graphql: ^16.6.0 + graphql: ^0.8.0 || ^0.9.0 || ^0.10.0 || ^0.11.0 || ^0.12.0 || ^0.13.0 || ^14.0.0 || ^15.0.0 || ^16.0.0 dependencies: '@graphql-codegen/plugin-helpers': 2.7.2(graphql@16.8.1) '@graphql-tools/optimize': 1.4.0(graphql@16.8.1) @@ -6233,7 +6238,7 @@ packages: /@graphql-codegen/visitor-plugin-common@3.1.1(graphql@16.8.1): resolution: {integrity: sha512-uAfp+zu/009R3HUAuTK2AamR1bxIltM6rrYYI6EXSmkM3rFtFsLTuJhjUDj98HcUCszJZrADppz8KKLGRUVlNg==} peerDependencies: - graphql: ^16.6.0 + graphql: ^0.8.0 || ^0.9.0 || ^0.10.0 || ^0.11.0 || ^0.12.0 || ^0.13.0 || ^14.0.0 || ^15.0.0 || ^16.0.0 dependencies: '@graphql-codegen/plugin-helpers': 4.2.0(graphql@16.8.1) '@graphql-tools/optimize': 1.4.0(graphql@16.8.1) @@ -6253,7 +6258,7 @@ packages: /@graphql-inspector/core@3.3.0(graphql@16.8.1): resolution: {integrity: sha512-LRtk9sHgj9qqVPIkkThAVq3iZ7QxgHCx6elEwd0eesZBCmaIYQxD/BFu+VT8jr10YfOURBZuAnVdyGu64vYpBg==} peerDependencies: - graphql: ^16.6.0 + graphql: ^0.13.0 || ^14.0.0 || ^15.0.0 || ^16.0.0 dependencies: dependency-graph: 0.11.0 graphql: 16.8.1 @@ -6264,7 +6269,7 @@ packages: resolution: {integrity: sha512-1CWfFYucnRdULGiN1NDSinlNlpucBT+0x4i4AIthKe5n5jD9RIVyJtkA8zBbujUFrP++YE3l+TQifwbN1yTQsw==} engines: {node: '>=16.0.0'} peerDependencies: - graphql: ^16.6.0 + graphql: ^14.0.0 || ^15.0.0 || ^16.0.0 dependencies: dependency-graph: 0.11.0 graphql: 16.8.1 @@ -6276,7 +6281,7 @@ packages: peerDependencies: '@graphql-mesh/types': ^0.93.1 '@graphql-mesh/utils': ^0.93.1 - graphql: ^16.6.0 + graphql: '*' tslib: ^2.4.0 dependencies: '@graphql-mesh/types': 0.93.2(@graphql-mesh/store@0.93.1)(@graphql-tools/utils@9.2.1)(graphql@16.8.1)(tslib@2.6.2) @@ -6285,27 +6290,27 @@ packages: localforage: 1.10.0 tslib: 2.6.2 - /@graphql-mesh/cache-localforage@0.95.7(@graphql-mesh/types@0.95.7)(@graphql-mesh/utils@0.95.7)(graphql@16.8.1)(tslib@2.6.2): - resolution: {integrity: sha512-/e9sFn0kgSxGE6O/GWfdGnFMOIfk1Y+IZwRqPIofHmIPdyC5cZ/gnkN6oRQv7nnx+c9hzQQ5OnxiOGdOKwb1cg==} + /@graphql-mesh/cache-localforage@0.95.8(@graphql-mesh/types@0.95.8)(@graphql-mesh/utils@0.95.8)(graphql@16.8.1)(tslib@2.6.2): + resolution: {integrity: sha512-PgCTHh1dLwjmusWEWAMQkglL7gR8VyyT9pzTcYBVFhGYNXysepCrl85QtaqtEMnR/YijgpCWaKGIYK+bosQZsg==} engines: {node: '>=16.0.0'} peerDependencies: - '@graphql-mesh/types': ^0.95.7 - '@graphql-mesh/utils': ^0.95.7 - graphql: ^16.6.0 + '@graphql-mesh/types': ^0.95.8 + '@graphql-mesh/utils': ^0.95.8 + graphql: '*' tslib: ^2.4.0 dependencies: - '@graphql-mesh/types': 0.95.7(@graphql-mesh/store@0.95.7)(@graphql-tools/utils@9.2.1)(graphql@16.8.1)(tslib@2.6.2) - '@graphql-mesh/utils': 0.95.7(@graphql-mesh/cross-helpers@0.4.1)(@graphql-mesh/types@0.95.7)(@graphql-tools/utils@9.2.1)(graphql@16.8.1)(tslib@2.6.2) + '@graphql-mesh/types': 0.95.8(@graphql-mesh/store@0.95.8)(@graphql-tools/utils@9.2.1)(graphql@16.8.1)(tslib@2.6.2) + '@graphql-mesh/utils': 0.95.8(@graphql-mesh/cross-helpers@0.4.1)(@graphql-mesh/types@0.95.8)(@graphql-tools/utils@9.2.1)(graphql@16.8.1)(tslib@2.6.2) graphql: 16.8.1 localforage: 1.10.0 tslib: 2.6.2 dev: false - /@graphql-mesh/cli@0.82.35(@babel/core@7.23.2)(@types/node@18.18.6)(graphql-tag@2.12.6)(graphql@16.8.1)(react-native@0.72.6): + /@graphql-mesh/cli@0.82.35(@babel/core@7.23.2)(@types/node@18.18.7)(graphql-tag@2.12.6)(graphql@16.8.1)(react-native@0.72.6): resolution: {integrity: sha512-5IuXpk+Zpg05u6qNPX19VzC5/HCiLdDRF6EPZ3ze57FIRgGA3YsB1CUGga6Ky3inalURYwx0kWqmdjbdKZYx1w==} hasBin: true peerDependencies: - graphql: ^16.6.0 + graphql: '*' dependencies: '@graphql-codegen/core': 3.1.0(graphql@16.8.1) '@graphql-codegen/typed-document-node': 4.0.1(graphql@16.8.1) @@ -6335,7 +6340,7 @@ packages: open: 7.4.2 pascal-case: 3.1.2 rimraf: 5.0.5 - ts-node: 10.9.1(@types/node@18.18.6)(typescript@5.1.6) + ts-node: 10.9.1(@types/node@18.18.7)(typescript@5.1.6) tsconfig-paths: 4.2.0 tslib: 2.6.2 typescript: 5.1.6 @@ -6363,7 +6368,7 @@ packages: '@graphql-mesh/types': ^0.93.1 '@graphql-mesh/utils': ^0.93.1 '@graphql-tools/utils': ^9.2.1 - graphql: ^16.6.0 + graphql: '*' tslib: ^2.4.0 dependencies: '@envelop/core': 3.0.6 @@ -6393,7 +6398,7 @@ packages: resolution: {integrity: sha512-jseNppSNEwNWjcjDDwsxmRBK+ub8tz2qc/ca2ZfCTebuCk/+D3dI3LJ95ceNFOIhInK0g2HVq8BO8lMMX1pQtg==} peerDependencies: '@graphql-tools/utils': ^9.2.1 - graphql: ^16.6.0 + graphql: '*' dependencies: '@graphql-tools/utils': 9.2.1(graphql@16.8.1) graphql: 16.8.1 @@ -6409,13 +6414,13 @@ packages: engines: {node: '>=16.0.0'} peerDependencies: '@graphql-tools/utils': ^9.2.1 || ^10.0.0 - graphql: ^16.6.0 + graphql: '*' dependencies: '@graphql-tools/utils': 9.2.1(graphql@16.8.1) graphql: 16.8.1 path-browserify: 1.0.1 - /@graphql-mesh/graphql@0.93.1(@graphql-mesh/cross-helpers@0.3.4)(@graphql-mesh/store@0.93.1)(@graphql-mesh/types@0.93.2)(@graphql-mesh/utils@0.93.2)(@graphql-tools/utils@9.2.1)(@types/node@18.18.6)(graphql@16.8.1)(tslib@2.6.2): + /@graphql-mesh/graphql@0.93.1(@graphql-mesh/cross-helpers@0.3.4)(@graphql-mesh/store@0.93.1)(@graphql-mesh/types@0.93.2)(@graphql-mesh/utils@0.93.2)(@graphql-tools/utils@9.2.1)(@types/node@18.18.7)(graphql@16.8.1)(tslib@2.6.2): resolution: {integrity: sha512-1G2/1jkl1VPWhsZsUBwFQI5d9OxxEc+CMxy5ef0qI2WEXqIocOxMhEY53cc+tCSbuXR99rxos+KD/8Z6ZasaOQ==} peerDependencies: '@graphql-mesh/cross-helpers': ^0.3.4 @@ -6423,7 +6428,7 @@ packages: '@graphql-mesh/types': ^0.93.1 '@graphql-mesh/utils': ^0.93.1 '@graphql-tools/utils': ^9.2.1 - graphql: ^16.6.0 + graphql: '*' tslib: ^2.4.0 dependencies: '@graphql-mesh/cross-helpers': 0.3.4(@graphql-tools/utils@9.2.1)(graphql@16.8.1)(react-native@0.72.6) @@ -6432,7 +6437,7 @@ packages: '@graphql-mesh/types': 0.93.2(@graphql-mesh/store@0.93.1)(@graphql-tools/utils@9.2.1)(graphql@16.8.1)(tslib@2.6.2) '@graphql-mesh/utils': 0.93.2(@graphql-mesh/cross-helpers@0.3.4)(@graphql-mesh/types@0.93.2)(@graphql-tools/utils@9.2.1)(graphql@16.8.1)(tslib@2.6.2) '@graphql-tools/delegate': 9.0.35(graphql@16.8.1) - '@graphql-tools/url-loader': 7.17.18(@types/node@18.18.6)(graphql@16.8.1) + '@graphql-tools/url-loader': 7.17.18(@types/node@18.18.7)(graphql@16.8.1) '@graphql-tools/utils': 9.2.1(graphql@16.8.1) '@graphql-tools/wrap': 9.4.2(graphql@16.8.1) graphql: 16.8.1 @@ -6445,7 +6450,7 @@ packages: - utf-8-validate dev: false - /@graphql-mesh/graphql@0.93.1(@graphql-mesh/cross-helpers@0.4.1)(@graphql-mesh/store@0.95.7)(@graphql-mesh/types@0.95.7)(@graphql-mesh/utils@0.95.7)(@graphql-tools/utils@9.2.1)(@types/node@18.18.6)(graphql@16.8.1)(tslib@2.6.2): + /@graphql-mesh/graphql@0.93.1(@graphql-mesh/cross-helpers@0.4.1)(@graphql-mesh/store@0.95.8)(@graphql-mesh/types@0.95.8)(@graphql-mesh/utils@0.95.8)(@graphql-tools/utils@9.2.1)(@types/node@18.18.7)(graphql@16.8.1)(tslib@2.6.2): resolution: {integrity: sha512-1G2/1jkl1VPWhsZsUBwFQI5d9OxxEc+CMxy5ef0qI2WEXqIocOxMhEY53cc+tCSbuXR99rxos+KD/8Z6ZasaOQ==} peerDependencies: '@graphql-mesh/cross-helpers': ^0.3.4 @@ -6453,16 +6458,16 @@ packages: '@graphql-mesh/types': ^0.93.1 '@graphql-mesh/utils': ^0.93.1 '@graphql-tools/utils': ^9.2.1 - graphql: ^16.6.0 + graphql: '*' tslib: ^2.4.0 dependencies: '@graphql-mesh/cross-helpers': 0.4.1(@graphql-tools/utils@9.2.1)(graphql@16.8.1) - '@graphql-mesh/store': 0.95.7(@graphql-mesh/cross-helpers@0.4.1)(@graphql-mesh/types@0.95.7)(@graphql-mesh/utils@0.95.7)(@graphql-tools/utils@9.2.1)(graphql@16.8.1)(tslib@2.6.2) + '@graphql-mesh/store': 0.95.8(@graphql-mesh/cross-helpers@0.4.1)(@graphql-mesh/types@0.95.8)(@graphql-mesh/utils@0.95.8)(@graphql-tools/utils@9.2.1)(graphql@16.8.1)(tslib@2.6.2) '@graphql-mesh/string-interpolation': 0.4.4(graphql@16.8.1)(tslib@2.6.2) - '@graphql-mesh/types': 0.95.7(@graphql-mesh/store@0.95.7)(@graphql-tools/utils@9.2.1)(graphql@16.8.1)(tslib@2.6.2) - '@graphql-mesh/utils': 0.95.7(@graphql-mesh/cross-helpers@0.4.1)(@graphql-mesh/types@0.95.7)(@graphql-tools/utils@9.2.1)(graphql@16.8.1)(tslib@2.6.2) + '@graphql-mesh/types': 0.95.8(@graphql-mesh/store@0.95.8)(@graphql-tools/utils@9.2.1)(graphql@16.8.1)(tslib@2.6.2) + '@graphql-mesh/utils': 0.95.8(@graphql-mesh/cross-helpers@0.4.1)(@graphql-mesh/types@0.95.8)(@graphql-tools/utils@9.2.1)(graphql@16.8.1)(tslib@2.6.2) '@graphql-tools/delegate': 9.0.35(graphql@16.8.1) - '@graphql-tools/url-loader': 7.17.18(@types/node@18.18.6)(graphql@16.8.1) + '@graphql-tools/url-loader': 7.17.18(@types/node@18.18.7)(graphql@16.8.1) '@graphql-tools/utils': 9.2.1(graphql@16.8.1) '@graphql-tools/wrap': 9.4.2(graphql@16.8.1) graphql: 16.8.1 @@ -6475,26 +6480,26 @@ packages: - utf-8-validate dev: true - /@graphql-mesh/graphql@0.95.7(@graphql-mesh/cross-helpers@0.4.1)(@graphql-mesh/store@0.95.7)(@graphql-mesh/types@0.95.7)(@graphql-mesh/utils@0.95.7)(@graphql-tools/utils@9.2.1)(@types/node@18.18.6)(graphql@16.8.1)(react-dom@18.2.0)(react@18.2.0)(tslib@2.6.2): - resolution: {integrity: sha512-Fjf1Ti2HYOEP+dFLVnVxafD/Z4Ev+sR6BUbx3E7Mw8r/XGY28KmCA/QftBOB6BRNKMLe5w7RsgjCrO+Qp0klNg==} + /@graphql-mesh/graphql@0.95.8(@graphql-mesh/cross-helpers@0.4.1)(@graphql-mesh/store@0.95.8)(@graphql-mesh/types@0.95.8)(@graphql-mesh/utils@0.95.8)(@graphql-tools/utils@9.2.1)(@types/node@18.18.7)(graphql@16.8.1)(react-dom@18.2.0)(react@18.2.0)(tslib@2.6.2): + resolution: {integrity: sha512-mEbz2XYSgRTdNidUBWB7FT3QzLliJwxJIoqipSbZNputJqSbUZZ6QD/oI1IrdPXqVl/ELE2CuLiogkOSO24C1Q==} engines: {node: '>=16.0.0'} peerDependencies: '@graphql-mesh/cross-helpers': ^0.4.1 - '@graphql-mesh/store': ^0.95.7 - '@graphql-mesh/types': ^0.95.7 - '@graphql-mesh/utils': ^0.95.7 + '@graphql-mesh/store': ^0.95.8 + '@graphql-mesh/types': ^0.95.8 + '@graphql-mesh/utils': ^0.95.8 '@graphql-tools/utils': ^9.2.1 || ^10.0.0 - graphql: ^16.6.0 + graphql: '*' tslib: ^2.4.0 dependencies: '@graphql-mesh/cross-helpers': 0.4.1(@graphql-tools/utils@9.2.1)(graphql@16.8.1) - '@graphql-mesh/store': 0.95.7(@graphql-mesh/cross-helpers@0.4.1)(@graphql-mesh/types@0.95.7)(@graphql-mesh/utils@0.95.7)(@graphql-tools/utils@9.2.1)(graphql@16.8.1)(tslib@2.6.2) - '@graphql-mesh/string-interpolation': 0.5.2(graphql@16.8.1)(tslib@2.6.2) - '@graphql-mesh/types': 0.95.7(@graphql-mesh/store@0.95.7)(@graphql-tools/utils@9.2.1)(graphql@16.8.1)(tslib@2.6.2) - '@graphql-mesh/utils': 0.95.7(@graphql-mesh/cross-helpers@0.4.1)(@graphql-mesh/types@0.95.7)(@graphql-tools/utils@9.2.1)(graphql@16.8.1)(tslib@2.6.2) + '@graphql-mesh/store': 0.95.8(@graphql-mesh/cross-helpers@0.4.1)(@graphql-mesh/types@0.95.8)(@graphql-mesh/utils@0.95.8)(@graphql-tools/utils@9.2.1)(graphql@16.8.1)(tslib@2.6.2) + '@graphql-mesh/string-interpolation': 0.5.3(graphql@16.8.1)(tslib@2.6.2) + '@graphql-mesh/types': 0.95.8(@graphql-mesh/store@0.95.8)(@graphql-tools/utils@9.2.1)(graphql@16.8.1)(tslib@2.6.2) + '@graphql-mesh/utils': 0.95.8(@graphql-mesh/cross-helpers@0.4.1)(@graphql-mesh/types@0.95.8)(@graphql-tools/utils@9.2.1)(graphql@16.8.1)(tslib@2.6.2) '@graphql-tools/delegate': 10.0.3(graphql@16.8.1) - '@graphql-tools/federation': 1.1.10(@types/node@18.18.6)(graphql@16.8.1)(react-dom@18.2.0)(react@18.2.0) - '@graphql-tools/url-loader': 8.0.0(@types/node@18.18.6)(graphql@16.8.1) + '@graphql-tools/federation': 1.1.10(@types/node@18.18.7)(graphql@16.8.1)(react-dom@18.2.0)(react@18.2.0) + '@graphql-tools/url-loader': 8.0.0(@types/node@18.18.7)(graphql@16.8.1) '@graphql-tools/utils': 9.2.1(graphql@16.8.1) graphql: 16.8.1 lodash.get: 4.4.2 @@ -6517,7 +6522,7 @@ packages: '@graphql-mesh/runtime': ^0.93.2 '@graphql-mesh/types': ^0.93.1 '@graphql-mesh/utils': ^0.93.1 - graphql: ^16.6.0 + graphql: '*' tslib: ^2.4.0 dependencies: '@graphql-mesh/cross-helpers': 0.3.4(@graphql-tools/utils@9.2.1)(graphql@16.8.1)(react-native@0.72.6) @@ -6529,22 +6534,22 @@ packages: graphql-yoga: 3.9.1(graphql@16.8.1) tslib: 2.6.2 - /@graphql-mesh/http@0.96.13(@graphql-mesh/cross-helpers@0.4.1)(@graphql-mesh/runtime@0.96.12)(@graphql-mesh/types@0.95.7)(@graphql-mesh/utils@0.95.7)(graphql@16.8.1)(tslib@2.6.2): - resolution: {integrity: sha512-WNiOJkwuRKoVCv/+9bp8/PFdclyTN0COIwSXjzIf36QICPtUXhokPLkXKhR7Xdtk175aIIpUHYRRwlgQw3BC1w==} + /@graphql-mesh/http@0.96.14(@graphql-mesh/cross-helpers@0.4.1)(@graphql-mesh/runtime@0.96.13)(@graphql-mesh/types@0.95.8)(@graphql-mesh/utils@0.95.8)(graphql@16.8.1)(tslib@2.6.2): + resolution: {integrity: sha512-38Mxw2K2RABBBO0IiXKZDu2o+jlM4vcUSEg+9h2Dz67oOJZHpKeId6z1PFb7uYMzAs29yoMcqXIEnews+HVhrQ==} engines: {node: '>=16.0.0'} peerDependencies: '@graphql-mesh/cross-helpers': ^0.4.1 - '@graphql-mesh/runtime': ^0.96.12 - '@graphql-mesh/types': ^0.95.7 - '@graphql-mesh/utils': ^0.95.7 - graphql: ^16.6.0 + '@graphql-mesh/runtime': ^0.96.13 + '@graphql-mesh/types': ^0.95.8 + '@graphql-mesh/utils': ^0.95.8 + graphql: '*' tslib: ^2.4.0 dependencies: '@graphql-mesh/cross-helpers': 0.4.1(@graphql-tools/utils@9.2.1)(graphql@16.8.1) - '@graphql-mesh/runtime': 0.96.12(@graphql-mesh/cross-helpers@0.4.1)(@graphql-mesh/types@0.95.7)(@graphql-mesh/utils@0.95.7)(@graphql-tools/utils@9.2.1)(graphql@16.8.1)(tslib@2.6.2) - '@graphql-mesh/types': 0.95.7(@graphql-mesh/store@0.95.7)(@graphql-tools/utils@9.2.1)(graphql@16.8.1)(tslib@2.6.2) - '@graphql-mesh/utils': 0.95.7(@graphql-mesh/cross-helpers@0.4.1)(@graphql-mesh/types@0.95.7)(@graphql-tools/utils@9.2.1)(graphql@16.8.1)(tslib@2.6.2) - '@whatwg-node/server': 0.9.15 + '@graphql-mesh/runtime': 0.96.13(@graphql-mesh/cross-helpers@0.4.1)(@graphql-mesh/types@0.95.8)(@graphql-mesh/utils@0.95.8)(@graphql-tools/utils@9.2.1)(graphql@16.8.1)(tslib@2.6.2) + '@graphql-mesh/types': 0.95.8(@graphql-mesh/store@0.95.8)(@graphql-tools/utils@9.2.1)(graphql@16.8.1)(tslib@2.6.2) + '@graphql-mesh/utils': 0.95.8(@graphql-mesh/cross-helpers@0.4.1)(@graphql-mesh/types@0.95.8)(@graphql-tools/utils@9.2.1)(graphql@16.8.1)(tslib@2.6.2) + '@whatwg-node/server': 0.9.16 graphql: 16.8.1 graphql-yoga: 5.0.0(graphql@16.8.1) tslib: 2.6.2 @@ -6556,7 +6561,7 @@ packages: '@graphql-mesh/types': ^0.93.1 '@graphql-mesh/utils': ^0.93.1 '@graphql-tools/utils': ^9.2.1 - graphql: ^16.6.0 + graphql: '*' tslib: ^2.4.0 dependencies: '@graphql-mesh/merger-stitching': 0.93.1(@graphql-mesh/store@0.93.1)(@graphql-mesh/types@0.93.2)(@graphql-mesh/utils@0.93.2)(@graphql-tools/utils@9.2.1)(graphql@16.8.1)(tslib@2.6.2) @@ -6569,19 +6574,19 @@ packages: transitivePeerDependencies: - '@graphql-mesh/store' - /@graphql-mesh/merger-bare@0.95.7(@graphql-mesh/store@0.95.7)(@graphql-mesh/types@0.95.7)(@graphql-mesh/utils@0.95.7)(@graphql-tools/utils@9.2.1)(graphql@16.8.1)(tslib@2.6.2): - resolution: {integrity: sha512-QNLm5otrzcpClR8Puks4Md7Mh6AON+EWK+l3NBKvEkiOINFcnDRFv4FrSEXSfrAv/vHrSBbxAEXGUWHjjbQ8Kw==} + /@graphql-mesh/merger-bare@0.95.8(@graphql-mesh/store@0.95.8)(@graphql-mesh/types@0.95.8)(@graphql-mesh/utils@0.95.8)(@graphql-tools/utils@9.2.1)(graphql@16.8.1)(tslib@2.6.2): + resolution: {integrity: sha512-E5R8Sv5Dkp+eswYKEDHgu8puwSeolPX1j9IHwBVe1npRRCXc3CjMsQJ9+kcTln453vbSBcM1a3fQspIaKA1Tcg==} engines: {node: '>=16.0.0'} peerDependencies: - '@graphql-mesh/types': ^0.95.7 - '@graphql-mesh/utils': ^0.95.7 + '@graphql-mesh/types': ^0.95.8 + '@graphql-mesh/utils': ^0.95.8 '@graphql-tools/utils': ^9.2.1 || ^10.0.0 - graphql: ^16.6.0 + graphql: '*' tslib: ^2.4.0 dependencies: - '@graphql-mesh/merger-stitching': 0.95.7(@graphql-mesh/store@0.95.7)(@graphql-mesh/types@0.95.7)(@graphql-mesh/utils@0.95.7)(@graphql-tools/utils@9.2.1)(graphql@16.8.1)(tslib@2.6.2) - '@graphql-mesh/types': 0.95.7(@graphql-mesh/store@0.95.7)(@graphql-tools/utils@9.2.1)(graphql@16.8.1)(tslib@2.6.2) - '@graphql-mesh/utils': 0.95.7(@graphql-mesh/cross-helpers@0.4.1)(@graphql-mesh/types@0.95.7)(@graphql-tools/utils@9.2.1)(graphql@16.8.1)(tslib@2.6.2) + '@graphql-mesh/merger-stitching': 0.95.8(@graphql-mesh/store@0.95.8)(@graphql-mesh/types@0.95.8)(@graphql-mesh/utils@0.95.8)(@graphql-tools/utils@9.2.1)(graphql@16.8.1)(tslib@2.6.2) + '@graphql-mesh/types': 0.95.8(@graphql-mesh/store@0.95.8)(@graphql-tools/utils@9.2.1)(graphql@16.8.1)(tslib@2.6.2) + '@graphql-mesh/utils': 0.95.8(@graphql-mesh/cross-helpers@0.4.1)(@graphql-mesh/types@0.95.8)(@graphql-tools/utils@9.2.1)(graphql@16.8.1)(tslib@2.6.2) '@graphql-tools/schema': 10.0.0(graphql@16.8.1) '@graphql-tools/utils': 9.2.1(graphql@16.8.1) graphql: 16.8.1 @@ -6597,7 +6602,7 @@ packages: '@graphql-mesh/types': ^0.93.1 '@graphql-mesh/utils': ^0.93.1 '@graphql-tools/utils': ^9.2.1 - graphql: ^16.6.0 + graphql: '*' tslib: ^2.4.0 dependencies: '@graphql-mesh/store': 0.93.1(@graphql-mesh/cross-helpers@0.3.4)(@graphql-mesh/types@0.93.2)(@graphql-mesh/utils@0.93.2)(@graphql-tools/utils@9.2.1)(graphql@16.8.1)(tslib@2.6.2) @@ -6611,20 +6616,20 @@ packages: graphql: 16.8.1 tslib: 2.6.2 - /@graphql-mesh/merger-stitching@0.95.7(@graphql-mesh/store@0.95.7)(@graphql-mesh/types@0.95.7)(@graphql-mesh/utils@0.95.7)(@graphql-tools/utils@9.2.1)(graphql@16.8.1)(tslib@2.6.2): - resolution: {integrity: sha512-0fooZHNseNrrVIm+OPfy7NdN1f/Cq6yhpW7d9lXjB8kPWjRGaX6gBUxpfCsRqSrfBDP1VwusZ6Z9EmW+84AtCQ==} + /@graphql-mesh/merger-stitching@0.95.8(@graphql-mesh/store@0.95.8)(@graphql-mesh/types@0.95.8)(@graphql-mesh/utils@0.95.8)(@graphql-tools/utils@9.2.1)(graphql@16.8.1)(tslib@2.6.2): + resolution: {integrity: sha512-eAukU8AsjK8jIT3vFhalGoERh98xZgzKkTCQL7w2wPpFXveSDMn+9fVvCJ1EBKTsLa7SkNXqzAFkfYp21hW0ng==} engines: {node: '>=16.0.0'} peerDependencies: - '@graphql-mesh/store': ^0.95.7 - '@graphql-mesh/types': ^0.95.7 - '@graphql-mesh/utils': ^0.95.7 + '@graphql-mesh/store': ^0.95.8 + '@graphql-mesh/types': ^0.95.8 + '@graphql-mesh/utils': ^0.95.8 '@graphql-tools/utils': ^9.2.1 || ^10.0.0 - graphql: ^16.6.0 + graphql: '*' tslib: ^2.4.0 dependencies: - '@graphql-mesh/store': 0.95.7(@graphql-mesh/cross-helpers@0.4.1)(@graphql-mesh/types@0.95.7)(@graphql-mesh/utils@0.95.7)(@graphql-tools/utils@9.2.1)(graphql@16.8.1)(tslib@2.6.2) - '@graphql-mesh/types': 0.95.7(@graphql-mesh/store@0.95.7)(@graphql-tools/utils@9.2.1)(graphql@16.8.1)(tslib@2.6.2) - '@graphql-mesh/utils': 0.95.7(@graphql-mesh/cross-helpers@0.4.1)(@graphql-mesh/types@0.95.7)(@graphql-tools/utils@9.2.1)(graphql@16.8.1)(tslib@2.6.2) + '@graphql-mesh/store': 0.95.8(@graphql-mesh/cross-helpers@0.4.1)(@graphql-mesh/types@0.95.8)(@graphql-mesh/utils@0.95.8)(@graphql-tools/utils@9.2.1)(graphql@16.8.1)(tslib@2.6.2) + '@graphql-mesh/types': 0.95.8(@graphql-mesh/store@0.95.8)(@graphql-tools/utils@9.2.1)(graphql@16.8.1)(tslib@2.6.2) + '@graphql-mesh/utils': 0.95.8(@graphql-mesh/cross-helpers@0.4.1)(@graphql-mesh/types@0.95.8)(@graphql-tools/utils@9.2.1)(graphql@16.8.1)(tslib@2.6.2) '@graphql-tools/delegate': 10.0.3(graphql@16.8.1) '@graphql-tools/schema': 10.0.0(graphql@16.8.1) '@graphql-tools/stitch': 9.0.3(graphql@16.8.1) @@ -6640,7 +6645,7 @@ packages: '@graphql-mesh/types': ^0.93.1 '@graphql-mesh/utils': ^0.93.1 '@graphql-tools/utils': ^9.2.1 - graphql: ^16.6.0 + graphql: '*' tslib: ^2.4.0 dependencies: '@envelop/core': 3.0.6 @@ -6658,22 +6663,22 @@ packages: graphql: 16.8.1 tslib: 2.6.2 - /@graphql-mesh/runtime@0.96.12(@graphql-mesh/cross-helpers@0.3.4)(@graphql-mesh/types@0.93.2)(@graphql-mesh/utils@0.93.2)(@graphql-tools/utils@9.2.1)(graphql@16.8.1)(tslib@2.6.2): - resolution: {integrity: sha512-b3a/XjbTtS8gF30wu35M4pA2KyUYkYcWlnYNGXWOObtdEtEXjj+GkX//yO2XzTGI/sGWKElAAKIv4asPsye4jA==} + /@graphql-mesh/runtime@0.96.13(@graphql-mesh/cross-helpers@0.3.4)(@graphql-mesh/types@0.93.2)(@graphql-mesh/utils@0.93.2)(@graphql-tools/utils@9.2.1)(graphql@16.8.1)(tslib@2.6.2): + resolution: {integrity: sha512-eZIW/gdEVLvCLEEae8e3lny7d89CFfDyu0Z0xu4yVEdYeVpG9Ki2mDYFHztusIIkZikecvdsoM9MZX6LYcPOkg==} engines: {node: '>=16.0.0'} peerDependencies: '@graphql-mesh/cross-helpers': ^0.4.1 - '@graphql-mesh/types': ^0.95.7 - '@graphql-mesh/utils': ^0.95.7 + '@graphql-mesh/types': ^0.95.8 + '@graphql-mesh/utils': ^0.95.8 '@graphql-tools/utils': ^9.2.1 || ^10.0.0 - graphql: ^16.6.0 + graphql: '*' tslib: ^2.4.0 dependencies: '@envelop/core': 5.0.0 '@envelop/extended-validation': 4.0.0(@envelop/core@5.0.0)(graphql@16.8.1) '@envelop/graphql-jit': 8.0.1(@envelop/core@5.0.0)(graphql@16.8.1) '@graphql-mesh/cross-helpers': 0.3.4(@graphql-tools/utils@9.2.1)(graphql@16.8.1)(react-native@0.72.6) - '@graphql-mesh/string-interpolation': 0.5.2(graphql@16.8.1)(tslib@2.6.2) + '@graphql-mesh/string-interpolation': 0.5.3(graphql@16.8.1)(tslib@2.6.2) '@graphql-mesh/types': 0.93.2(@graphql-mesh/store@0.93.1)(@graphql-tools/utils@9.2.1)(graphql@16.8.1)(tslib@2.6.2) '@graphql-mesh/utils': 0.93.2(@graphql-mesh/cross-helpers@0.3.4)(@graphql-mesh/types@0.93.2)(@graphql-tools/utils@9.2.1)(graphql@16.8.1)(tslib@2.6.2) '@graphql-tools/batch-delegate': 9.0.0(graphql@16.8.1) @@ -6681,36 +6686,36 @@ packages: '@graphql-tools/executor': 1.2.0(graphql@16.8.1) '@graphql-tools/utils': 9.2.1(graphql@16.8.1) '@graphql-tools/wrap': 10.0.1(graphql@16.8.1) - '@whatwg-node/fetch': 0.9.13 + '@whatwg-node/fetch': 0.9.14 graphql: 16.8.1 graphql-jit: 0.8.2(graphql@16.8.1) tslib: 2.6.2 dev: false - /@graphql-mesh/runtime@0.96.12(@graphql-mesh/cross-helpers@0.4.1)(@graphql-mesh/types@0.95.7)(@graphql-mesh/utils@0.95.7)(@graphql-tools/utils@9.2.1)(graphql@16.8.1)(tslib@2.6.2): - resolution: {integrity: sha512-b3a/XjbTtS8gF30wu35M4pA2KyUYkYcWlnYNGXWOObtdEtEXjj+GkX//yO2XzTGI/sGWKElAAKIv4asPsye4jA==} + /@graphql-mesh/runtime@0.96.13(@graphql-mesh/cross-helpers@0.4.1)(@graphql-mesh/types@0.95.8)(@graphql-mesh/utils@0.95.8)(@graphql-tools/utils@9.2.1)(graphql@16.8.1)(tslib@2.6.2): + resolution: {integrity: sha512-eZIW/gdEVLvCLEEae8e3lny7d89CFfDyu0Z0xu4yVEdYeVpG9Ki2mDYFHztusIIkZikecvdsoM9MZX6LYcPOkg==} engines: {node: '>=16.0.0'} peerDependencies: '@graphql-mesh/cross-helpers': ^0.4.1 - '@graphql-mesh/types': ^0.95.7 - '@graphql-mesh/utils': ^0.95.7 + '@graphql-mesh/types': ^0.95.8 + '@graphql-mesh/utils': ^0.95.8 '@graphql-tools/utils': ^9.2.1 || ^10.0.0 - graphql: ^16.6.0 + graphql: '*' tslib: ^2.4.0 dependencies: '@envelop/core': 5.0.0 '@envelop/extended-validation': 4.0.0(@envelop/core@5.0.0)(graphql@16.8.1) '@envelop/graphql-jit': 8.0.1(@envelop/core@5.0.0)(graphql@16.8.1) '@graphql-mesh/cross-helpers': 0.4.1(@graphql-tools/utils@9.2.1)(graphql@16.8.1) - '@graphql-mesh/string-interpolation': 0.5.2(graphql@16.8.1)(tslib@2.6.2) - '@graphql-mesh/types': 0.95.7(@graphql-mesh/store@0.95.7)(@graphql-tools/utils@9.2.1)(graphql@16.8.1)(tslib@2.6.2) - '@graphql-mesh/utils': 0.95.7(@graphql-mesh/cross-helpers@0.4.1)(@graphql-mesh/types@0.95.7)(@graphql-tools/utils@9.2.1)(graphql@16.8.1)(tslib@2.6.2) + '@graphql-mesh/string-interpolation': 0.5.3(graphql@16.8.1)(tslib@2.6.2) + '@graphql-mesh/types': 0.95.8(@graphql-mesh/store@0.95.8)(@graphql-tools/utils@9.2.1)(graphql@16.8.1)(tslib@2.6.2) + '@graphql-mesh/utils': 0.95.8(@graphql-mesh/cross-helpers@0.4.1)(@graphql-mesh/types@0.95.8)(@graphql-tools/utils@9.2.1)(graphql@16.8.1)(tslib@2.6.2) '@graphql-tools/batch-delegate': 9.0.0(graphql@16.8.1) '@graphql-tools/delegate': 10.0.3(graphql@16.8.1) '@graphql-tools/executor': 1.2.0(graphql@16.8.1) '@graphql-tools/utils': 9.2.1(graphql@16.8.1) '@graphql-tools/wrap': 10.0.1(graphql@16.8.1) - '@whatwg-node/fetch': 0.9.13 + '@whatwg-node/fetch': 0.9.14 graphql: 16.8.1 graphql-jit: 0.8.2(graphql@16.8.1) tslib: 2.6.2 @@ -6723,7 +6728,7 @@ packages: '@graphql-mesh/types': ^0.93.1 '@graphql-mesh/utils': ^0.93.1 '@graphql-tools/utils': ^9.2.1 - graphql: ^16.6.0 + graphql: '*' tslib: ^2.4.0 dependencies: '@graphql-inspector/core': 3.3.0(graphql@16.8.1) @@ -6734,21 +6739,21 @@ packages: graphql: 16.8.1 tslib: 2.6.2 - /@graphql-mesh/store@0.95.7(@graphql-mesh/cross-helpers@0.4.1)(@graphql-mesh/types@0.95.7)(@graphql-mesh/utils@0.95.7)(@graphql-tools/utils@9.2.1)(graphql@16.8.1)(tslib@2.6.2): - resolution: {integrity: sha512-4T5MnkdV70gPzM3Hj+Er2Qg4FTzePzbzGdHdWRSbW++4K+05Hbe1gKPix2f3s3BGkAO4Et5XkkdILL5QynhQFw==} + /@graphql-mesh/store@0.95.8(@graphql-mesh/cross-helpers@0.4.1)(@graphql-mesh/types@0.95.8)(@graphql-mesh/utils@0.95.8)(@graphql-tools/utils@9.2.1)(graphql@16.8.1)(tslib@2.6.2): + resolution: {integrity: sha512-29lpMcvqS1DM9alUOCyj6he2V7ZzG/DZxkerRefT8Mo5FexwJZI3LeI0YHNSY9Cq0x8KzRoH1TWcTTN/1PDRRw==} engines: {node: '>=16.0.0'} peerDependencies: '@graphql-mesh/cross-helpers': ^0.4.1 - '@graphql-mesh/types': ^0.95.7 - '@graphql-mesh/utils': ^0.95.7 + '@graphql-mesh/types': ^0.95.8 + '@graphql-mesh/utils': ^0.95.8 '@graphql-tools/utils': ^9.2.1 || ^10.0.0 - graphql: ^16.6.0 + graphql: '*' tslib: ^2.4.0 dependencies: '@graphql-inspector/core': 5.0.1(graphql@16.8.1) '@graphql-mesh/cross-helpers': 0.4.1(@graphql-tools/utils@9.2.1)(graphql@16.8.1) - '@graphql-mesh/types': 0.95.7(@graphql-mesh/store@0.95.7)(@graphql-tools/utils@9.2.1)(graphql@16.8.1)(tslib@2.6.2) - '@graphql-mesh/utils': 0.95.7(@graphql-mesh/cross-helpers@0.4.1)(@graphql-mesh/types@0.95.7)(@graphql-tools/utils@9.2.1)(graphql@16.8.1)(tslib@2.6.2) + '@graphql-mesh/types': 0.95.8(@graphql-mesh/store@0.95.8)(@graphql-tools/utils@9.2.1)(graphql@16.8.1)(tslib@2.6.2) + '@graphql-mesh/utils': 0.95.8(@graphql-mesh/cross-helpers@0.4.1)(@graphql-mesh/types@0.95.8)(@graphql-tools/utils@9.2.1)(graphql@16.8.1)(tslib@2.6.2) '@graphql-tools/utils': 9.2.1(graphql@16.8.1) graphql: 16.8.1 tslib: 2.6.2 @@ -6756,7 +6761,7 @@ packages: /@graphql-mesh/string-interpolation@0.4.4(graphql@16.8.1)(tslib@2.6.2): resolution: {integrity: sha512-IotswBYZRaPswOebcr2wuOFuzD3dHIJxVEkPiiQubqjUIR8HhQI22XHJv0WNiQZ65z8NR9+GYWwEDIc2JRCNfQ==} peerDependencies: - graphql: ^16.6.0 + graphql: '*' tslib: ^2.4.0 dependencies: dayjs: 1.11.7 @@ -6765,11 +6770,11 @@ packages: lodash.get: 4.4.2 tslib: 2.6.2 - /@graphql-mesh/string-interpolation@0.5.2(graphql@16.8.1)(tslib@2.6.2): - resolution: {integrity: sha512-TkSAJ9pj1zesQyDlHrEUevVGOc1s/z9IQC0AONcpMHAunb8uYGO4Yryl8JIRIvDl5DlexHt3z8kLDNCInRGWNQ==} + /@graphql-mesh/string-interpolation@0.5.3(graphql@16.8.1)(tslib@2.6.2): + resolution: {integrity: sha512-/R4kj3M1uqUie/7RZ58zgRrT8RBrDsCCR6ii00s62DbLsl+jZYOZFyTqHGsFbP7L7aHnl0fo1dwhEJIs+rjCLg==} engines: {node: '>=16.0.0'} peerDependencies: - graphql: ^16.6.0 + graphql: '*' tslib: ^2.4.0 dependencies: dayjs: 1.11.10 @@ -6783,7 +6788,7 @@ packages: peerDependencies: '@graphql-mesh/types': ^0.93.1 '@graphql-mesh/utils': ^0.93.1 - graphql: ^16.6.0 + graphql: '*' tslib: ^2.4.0 dependencies: '@graphql-mesh/types': 0.93.2(@graphql-mesh/store@0.93.1)(@graphql-tools/utils@9.2.1)(graphql@16.8.1)(tslib@2.6.2) @@ -6794,16 +6799,16 @@ packages: tslib: 2.6.2 dev: false - /@graphql-mesh/transform-type-merging@0.93.1(@graphql-mesh/types@0.95.7)(@graphql-mesh/utils@0.95.7)(graphql@16.8.1)(tslib@2.6.2): + /@graphql-mesh/transform-type-merging@0.93.1(@graphql-mesh/types@0.95.8)(@graphql-mesh/utils@0.95.8)(graphql@16.8.1)(tslib@2.6.2): resolution: {integrity: sha512-CUrqCMaEqO1LDusv59UPqmQju3f+LpEGxFu7CydMiIvbfKDDDrf8+dF3OVU7d/ZOMRxB6hR80JsQF0SVeXPCOQ==} peerDependencies: '@graphql-mesh/types': ^0.93.1 '@graphql-mesh/utils': ^0.93.1 - graphql: ^16.6.0 + graphql: '*' tslib: ^2.4.0 dependencies: - '@graphql-mesh/types': 0.95.7(@graphql-mesh/store@0.95.7)(@graphql-tools/utils@9.2.1)(graphql@16.8.1)(tslib@2.6.2) - '@graphql-mesh/utils': 0.95.7(@graphql-mesh/cross-helpers@0.4.1)(@graphql-mesh/types@0.95.7)(@graphql-tools/utils@9.2.1)(graphql@16.8.1)(tslib@2.6.2) + '@graphql-mesh/types': 0.95.8(@graphql-mesh/store@0.95.8)(@graphql-tools/utils@9.2.1)(graphql@16.8.1)(tslib@2.6.2) + '@graphql-mesh/utils': 0.95.8(@graphql-mesh/cross-helpers@0.4.1)(@graphql-mesh/types@0.95.8)(@graphql-tools/utils@9.2.1)(graphql@16.8.1)(tslib@2.6.2) '@graphql-tools/delegate': 9.0.35(graphql@16.8.1) '@graphql-tools/stitching-directives': 2.3.34(graphql@16.8.1) graphql: 16.8.1 @@ -6815,7 +6820,7 @@ packages: peerDependencies: '@graphql-mesh/store': ^0.93.1 '@graphql-tools/utils': ^9.2.1 - graphql: ^16.6.0 + graphql: '*' tslib: ^2.4.0 dependencies: '@graphql-mesh/store': 0.93.1(@graphql-mesh/cross-helpers@0.3.4)(@graphql-mesh/types@0.93.2)(@graphql-mesh/utils@0.93.2)(@graphql-tools/utils@9.2.1)(graphql@16.8.1)(tslib@2.6.2) @@ -6826,16 +6831,16 @@ packages: graphql: 16.8.1 tslib: 2.6.2 - /@graphql-mesh/types@0.95.7(@graphql-mesh/store@0.95.7)(@graphql-tools/utils@9.2.1)(graphql@16.8.1)(tslib@2.6.2): - resolution: {integrity: sha512-afM2uuGR//lBoDrQvyfDmCcPwObpouRauahKVrXGyxkWe9LuIBG+scBZcynSbKotO1SgFcbJtToafMAIk5CefQ==} + /@graphql-mesh/types@0.95.8(@graphql-mesh/store@0.95.8)(@graphql-tools/utils@9.2.1)(graphql@16.8.1)(tslib@2.6.2): + resolution: {integrity: sha512-H2xh5KGc3+Ly3VdAPnRdKTibZpW9zEFgUzsozL9MQhCs6WLX+/kOADb0uIDqYFKX5c/2axmcy87BFNOausXYig==} engines: {node: '>=16.0.0'} peerDependencies: - '@graphql-mesh/store': ^0.95.7 + '@graphql-mesh/store': ^0.95.8 '@graphql-tools/utils': ^9.2.1 || ^10.0.0 - graphql: ^16.6.0 + graphql: '*' tslib: ^2.4.0 dependencies: - '@graphql-mesh/store': 0.95.7(@graphql-mesh/cross-helpers@0.4.1)(@graphql-mesh/types@0.95.7)(@graphql-mesh/utils@0.95.7)(@graphql-tools/utils@9.2.1)(graphql@16.8.1)(tslib@2.6.2) + '@graphql-mesh/store': 0.95.8(@graphql-mesh/cross-helpers@0.4.1)(@graphql-mesh/types@0.95.8)(@graphql-mesh/utils@0.95.8)(@graphql-tools/utils@9.2.1)(graphql@16.8.1)(tslib@2.6.2) '@graphql-tools/batch-delegate': 9.0.0(graphql@16.8.1) '@graphql-tools/delegate': 10.0.3(graphql@16.8.1) '@graphql-tools/utils': 9.2.1(graphql@16.8.1) @@ -6849,7 +6854,7 @@ packages: '@graphql-mesh/cross-helpers': ^0.3.4 '@graphql-mesh/types': ^0.93.2 '@graphql-tools/utils': ^9.2.1 - graphql: ^16.6.0 + graphql: '*' tslib: ^2.4.0 dependencies: '@graphql-mesh/cross-helpers': 0.3.4(@graphql-tools/utils@9.2.1)(graphql@16.8.1)(react-native@0.72.6) @@ -6857,7 +6862,7 @@ packages: '@graphql-mesh/types': 0.93.2(@graphql-mesh/store@0.93.1)(@graphql-tools/utils@9.2.1)(graphql@16.8.1)(tslib@2.6.2) '@graphql-tools/delegate': 9.0.35(graphql@16.8.1) '@graphql-tools/utils': 9.2.1(graphql@16.8.1) - dset: 3.1.2 + dset: 3.1.3 graphql: 16.8.1 js-yaml: 4.1.0 lodash.get: 4.4.2 @@ -6865,23 +6870,23 @@ packages: tiny-lru: 8.0.2 tslib: 2.6.2 - /@graphql-mesh/utils@0.95.7(@graphql-mesh/cross-helpers@0.4.1)(@graphql-mesh/types@0.95.7)(@graphql-tools/utils@9.2.1)(graphql@16.8.1)(tslib@2.6.2): - resolution: {integrity: sha512-6YQTMTrLt6m/cAdesrBgbGVSrLd+68xTo1dRIhxUFHSgucSAqA47Q8E71Lc9cLHh80HQT+/pauKHHG40csy1Ng==} + /@graphql-mesh/utils@0.95.8(@graphql-mesh/cross-helpers@0.4.1)(@graphql-mesh/types@0.95.8)(@graphql-tools/utils@9.2.1)(graphql@16.8.1)(tslib@2.6.2): + resolution: {integrity: sha512-gH2/kXvxMHVWMX8DppIIZpFfSUaoKDJ6eQHFoAAsdabGE+vLtVk0OEYqMGVGtD/8ZDFa/P6CmwXc6hBzoLY6Kg==} engines: {node: '>=16.0.0'} peerDependencies: '@graphql-mesh/cross-helpers': ^0.4.1 - '@graphql-mesh/types': ^0.95.7 + '@graphql-mesh/types': ^0.95.8 '@graphql-tools/utils': ^9.2.1 || ^10.0.0 - graphql: ^16.6.0 + graphql: '*' tslib: ^2.4.0 dependencies: '@graphql-mesh/cross-helpers': 0.4.1(@graphql-tools/utils@9.2.1)(graphql@16.8.1) - '@graphql-mesh/string-interpolation': 0.5.2(graphql@16.8.1)(tslib@2.6.2) - '@graphql-mesh/types': 0.95.7(@graphql-mesh/store@0.95.7)(@graphql-tools/utils@9.2.1)(graphql@16.8.1)(tslib@2.6.2) + '@graphql-mesh/string-interpolation': 0.5.3(graphql@16.8.1)(tslib@2.6.2) + '@graphql-mesh/types': 0.95.8(@graphql-mesh/store@0.95.8)(@graphql-tools/utils@9.2.1)(graphql@16.8.1)(tslib@2.6.2) '@graphql-tools/delegate': 10.0.3(graphql@16.8.1) '@graphql-tools/utils': 9.2.1(graphql@16.8.1) - '@whatwg-node/fetch': 0.9.13 - dset: 3.1.2 + '@whatwg-node/fetch': 0.9.14 + dset: 3.1.3 graphql: 16.8.1 js-yaml: 4.1.0 lodash.get: 4.4.2 @@ -6892,7 +6897,7 @@ packages: /@graphql-tools/batch-delegate@8.4.27(graphql@16.8.1): resolution: {integrity: sha512-efgDDJhljma9d3Ky/LswIu1xm/if2oS27XA1sOcxcShW+Ze+Qxi0hZZ6iyI4eQxVDX5Lyy/n+NvQEZAK1riqnQ==} peerDependencies: - graphql: ^16.6.0 + graphql: ^14.0.0 || ^15.0.0 || ^16.0.0 || ^17.0.0 dependencies: '@graphql-tools/delegate': 9.0.35(graphql@16.8.1) '@graphql-tools/utils': 9.2.1(graphql@16.8.1) @@ -6905,7 +6910,7 @@ packages: resolution: {integrity: sha512-23NmxcHQeKcfhMQyrRPTZfW4/+bSpAyR/qAhRjx+/hikDIa1Uv2XVgV9jIitSgM0OEk/KGPB4VQv+LCOWvAYiw==} engines: {node: '>=16.0.0'} peerDependencies: - graphql: ^16.6.0 + graphql: ^14.0.0 || ^15.0.0 || ^16.0.0 || ^17.0.0 dependencies: '@graphql-tools/delegate': 10.0.3(graphql@16.8.1) '@graphql-tools/utils': 10.0.7(graphql@16.8.1) @@ -6917,7 +6922,7 @@ packages: /@graphql-tools/batch-execute@8.5.22(graphql@16.8.1): resolution: {integrity: sha512-hcV1JaY6NJQFQEwCKrYhpfLK8frSXDbtNMoTur98u10Cmecy1zrqNKSqhEyGetpgHxaJRqszGzKeI3RuroDN6A==} peerDependencies: - graphql: ^16.6.0 + graphql: ^14.0.0 || ^15.0.0 || ^16.0.0 || ^17.0.0 dependencies: '@graphql-tools/utils': 9.2.1(graphql@16.8.1) dataloader: 2.2.2 @@ -6929,7 +6934,7 @@ packages: resolution: {integrity: sha512-Y2uwdZI6ZnatopD/SYfZ1eGuQFI7OU2KGZ2/B/7G9ISmgMl5K+ZZWz/PfIEXeiHirIDhyk54s4uka5rj2xwKqQ==} engines: {node: '>=16.0.0'} peerDependencies: - graphql: ^16.6.0 + graphql: ^14.0.0 || ^15.0.0 || ^16.0.0 || ^17.0.0 dependencies: '@graphql-tools/utils': 10.0.7(graphql@16.8.1) dataloader: 2.2.2 @@ -6940,7 +6945,7 @@ packages: /@graphql-tools/code-file-loader@7.3.23(@babel/core@7.23.2)(graphql@16.8.1): resolution: {integrity: sha512-8Wt1rTtyTEs0p47uzsPJ1vAtfAx0jmxPifiNdmo9EOCuUPyQGEbMaik/YkqZ7QUFIEYEQu+Vgfo8tElwOPtx5Q==} peerDependencies: - graphql: ^16.6.0 + graphql: ^14.0.0 || ^15.0.0 || ^16.0.0 || ^17.0.0 dependencies: '@graphql-tools/graphql-tag-pluck': 7.5.2(@babel/core@7.23.2)(graphql@16.8.1) '@graphql-tools/utils': 9.2.1(graphql@16.8.1) @@ -6956,7 +6961,7 @@ packages: resolution: {integrity: sha512-Jor9oazZ07zuWkykD3OOhT/2XD74Zm6Ar0ENZMk75MDD51wB2UWUIMljtHxbJhV5A6UBC2v8x6iY0xdCGiIlyw==} engines: {node: '>=16.0.0'} peerDependencies: - graphql: ^16.6.0 + graphql: ^14.0.0 || ^15.0.0 || ^16.0.0 || ^17.0.0 dependencies: '@graphql-tools/batch-execute': 9.0.2(graphql@16.8.1) '@graphql-tools/executor': 1.2.0(graphql@16.8.1) @@ -6969,7 +6974,7 @@ packages: /@graphql-tools/delegate@9.0.35(graphql@16.8.1): resolution: {integrity: sha512-jwPu8NJbzRRMqi4Vp/5QX1vIUeUPpWmlQpOkXQD2r1X45YsVceyUUBnktCrlJlDB4jPRVy7JQGwmYo3KFiOBMA==} peerDependencies: - graphql: ^16.6.0 + graphql: ^14.0.0 || ^15.0.0 || ^16.0.0 || ^17.0.0 dependencies: '@graphql-tools/batch-execute': 8.5.22(graphql@16.8.1) '@graphql-tools/executor': 0.0.20(graphql@16.8.1) @@ -6983,7 +6988,7 @@ packages: /@graphql-tools/executor-graphql-ws@0.0.14(graphql@16.8.1): resolution: {integrity: sha512-P2nlkAsPZKLIXImFhj0YTtny5NQVGSsKnhi7PzXiaHSXc6KkzqbWZHKvikD4PObanqg+7IO58rKFpGXP7eeO+w==} peerDependencies: - graphql: ^16.6.0 + graphql: ^14.0.0 || ^15.0.0 || ^16.0.0 || ^17.0.0 dependencies: '@graphql-tools/utils': 9.2.1(graphql@16.8.1) '@repeaterjs/repeater': 3.0.4 @@ -7001,7 +7006,7 @@ packages: resolution: {integrity: sha512-yM67SzwE8rYRpm4z4AuGtABlOp9mXXVy6sxXnTJRoYIdZrmDbKVfIY+CpZUJCqS0FX3xf2+GoHlsj7Qswaxgcg==} engines: {node: '>=16.0.0'} peerDependencies: - graphql: ^16.6.0 + graphql: ^14.0.0 || ^15.0.0 || ^16.0.0 || ^17.0.0 dependencies: '@graphql-tools/utils': 10.0.7(graphql@16.8.1) '@types/ws': 8.5.8 @@ -7015,35 +7020,35 @@ packages: - utf-8-validate dev: false - /@graphql-tools/executor-http@0.1.10(@types/node@18.18.6)(graphql@16.8.1): + /@graphql-tools/executor-http@0.1.10(@types/node@18.18.7)(graphql@16.8.1): resolution: {integrity: sha512-hnAfbKv0/lb9s31LhWzawQ5hghBfHS+gYWtqxME6Rl0Aufq9GltiiLBcl7OVVOnkLF0KhwgbYP1mB5VKmgTGpg==} peerDependencies: - graphql: ^16.6.0 + graphql: ^14.0.0 || ^15.0.0 || ^16.0.0 || ^17.0.0 dependencies: '@graphql-tools/utils': 9.2.1(graphql@16.8.1) '@repeaterjs/repeater': 3.0.4 '@whatwg-node/fetch': 0.8.8 - dset: 3.1.2 + dset: 3.1.3 extract-files: 11.0.0 graphql: 16.8.1 - meros: 1.3.0(@types/node@18.18.6) + meros: 1.3.0(@types/node@18.18.7) tslib: 2.6.2 value-or-promise: 1.0.12 transitivePeerDependencies: - '@types/node' - /@graphql-tools/executor-http@1.0.3(@types/node@18.18.6)(graphql@16.8.1): + /@graphql-tools/executor-http@1.0.3(@types/node@18.18.7)(graphql@16.8.1): resolution: {integrity: sha512-5WZIMBevRaxMabZ8U2Ty0dTUPy/PpeYSlMNEmC/YJjKKykgSfc/AwSejx2sE4FFKZ0I2kxRKRenyoWMHRAV49Q==} engines: {node: '>=16.0.0'} peerDependencies: - graphql: ^16.6.0 + graphql: ^14.0.0 || ^15.0.0 || ^16.0.0 || ^17.0.0 dependencies: '@graphql-tools/utils': 10.0.7(graphql@16.8.1) '@repeaterjs/repeater': 3.0.4 - '@whatwg-node/fetch': 0.9.13 + '@whatwg-node/fetch': 0.9.14 extract-files: 11.0.0 graphql: 16.8.1 - meros: 1.3.0(@types/node@18.18.6) + meros: 1.3.0(@types/node@18.18.7) tslib: 2.6.2 value-or-promise: 1.0.12 transitivePeerDependencies: @@ -7053,7 +7058,7 @@ packages: /@graphql-tools/executor-legacy-ws@0.0.11(graphql@16.8.1): resolution: {integrity: sha512-4ai+NnxlNfvIQ4c70hWFvOZlSUN8lt7yc+ZsrwtNFbFPH/EroIzFMapAxM9zwyv9bH38AdO3TQxZ5zNxgBdvUw==} peerDependencies: - graphql: ^16.6.0 + graphql: ^14.0.0 || ^15.0.0 || ^16.0.0 || ^17.0.0 dependencies: '@graphql-tools/utils': 9.2.1(graphql@16.8.1) '@types/ws': 8.5.8 @@ -7069,7 +7074,7 @@ packages: resolution: {integrity: sha512-b7aGuRekZDS+m3af3BIvMKxu15bmVPMt5eGQVuP2v5pxmbaPTh+iv5mx9b3Plt32z5Ke5tycBnNm5urSFtW8ng==} engines: {node: '>=16.0.0'} peerDependencies: - graphql: ^16.6.0 + graphql: ^14.0.0 || ^15.0.0 || ^16.0.0 || ^17.0.0 dependencies: '@graphql-tools/utils': 10.0.7(graphql@16.8.1) '@types/ws': 8.5.8 @@ -7085,7 +7090,7 @@ packages: /@graphql-tools/executor@0.0.18(graphql@16.8.1): resolution: {integrity: sha512-xZC0C+/npXoSHBB5bsJdwxDLgtl1Gu4fL9J2TPQmXoZC3L2N506KJoppf9LgWdHU/xK04luJrhP6WjhfkIN0pQ==} peerDependencies: - graphql: ^16.6.0 + graphql: ^14.0.0 || ^15.0.0 || ^16.0.0 || ^17.0.0 dependencies: '@graphql-tools/utils': 9.2.1(graphql@16.8.1) '@graphql-typed-document-node/core': 3.2.0(graphql@16.8.1) @@ -7097,7 +7102,7 @@ packages: /@graphql-tools/executor@0.0.20(graphql@16.8.1): resolution: {integrity: sha512-GdvNc4vszmfeGvUqlcaH1FjBoguvMYzxAfT6tDd4/LgwymepHhinqLNA5otqwVLW+JETcDaK7xGENzFomuE6TA==} peerDependencies: - graphql: ^16.6.0 + graphql: ^14.0.0 || ^15.0.0 || ^16.0.0 || ^17.0.0 dependencies: '@graphql-tools/utils': 9.2.1(graphql@16.8.1) '@graphql-typed-document-node/core': 3.2.0(graphql@16.8.1) @@ -7110,7 +7115,7 @@ packages: resolution: {integrity: sha512-SKlIcMA71Dha5JnEWlw4XxcaJ+YupuXg0QCZgl2TOLFz4SkGCwU/geAsJvUJFwK2RbVLpQv/UMq67lOaBuwDtg==} engines: {node: '>=16.0.0'} peerDependencies: - graphql: ^16.6.0 + graphql: ^14.0.0 || ^15.0.0 || ^16.0.0 || ^17.0.0 dependencies: '@graphql-tools/utils': 10.0.7(graphql@16.8.1) '@graphql-typed-document-node/core': 3.2.0(graphql@16.8.1) @@ -7119,14 +7124,14 @@ packages: tslib: 2.6.2 value-or-promise: 1.0.12 - /@graphql-tools/federation@1.1.10(@types/node@18.18.6)(graphql@16.8.1)(react-dom@18.2.0)(react@18.2.0): + /@graphql-tools/federation@1.1.10(@types/node@18.18.7)(graphql@16.8.1)(react-dom@18.2.0)(react@18.2.0): resolution: {integrity: sha512-H51qTYwbtfIYBO1uHXlImRWzo9tknSoIGBgJckDh+hdxJx43sZaMjJiLHc2DjRc/A8d2Bf0bi0HbH++HqOos/w==} engines: {node: '>=16.0.0'} peerDependencies: - graphql: ^16.6.0 + graphql: ^14.0.0 || ^15.0.0 || ^16.0.0 || ^17.0.0 dependencies: '@graphql-tools/delegate': 10.0.3(graphql@16.8.1) - '@graphql-tools/executor-http': 1.0.3(@types/node@18.18.6)(graphql@16.8.1) + '@graphql-tools/executor-http': 1.0.3(@types/node@18.18.7)(graphql@16.8.1) '@graphql-tools/merge': 9.0.0(graphql@16.8.1) '@graphql-tools/schema': 10.0.0(graphql@16.8.1) '@graphql-tools/stitch': 9.0.3(graphql@16.8.1) @@ -7148,7 +7153,7 @@ packages: /@graphql-tools/graphql-file-loader@7.5.17(graphql@16.8.1): resolution: {integrity: sha512-hVwwxPf41zOYgm4gdaZILCYnKB9Zap7Ys9OhY1hbwuAuC4MMNY9GpUjoTU3CQc3zUiPoYStyRtUGkHSJZ3HxBw==} peerDependencies: - graphql: ^16.6.0 + graphql: ^14.0.0 || ^15.0.0 || ^16.0.0 || ^17.0.0 dependencies: '@graphql-tools/import': 6.7.18(graphql@16.8.1) '@graphql-tools/utils': 9.2.1(graphql@16.8.1) @@ -7160,7 +7165,7 @@ packages: /@graphql-tools/graphql-tag-pluck@7.5.2(@babel/core@7.23.2)(graphql@16.8.1): resolution: {integrity: sha512-RW+H8FqOOLQw0BPXaahYepVSRjuOHw+7IL8Opaa5G5uYGOBxoXR7DceyQ7BcpMgktAOOmpDNQ2WtcboChOJSRA==} peerDependencies: - graphql: ^16.6.0 + graphql: ^14.0.0 || ^15.0.0 || ^16.0.0 || ^17.0.0 dependencies: '@babel/parser': 7.23.0 '@babel/plugin-syntax-import-assertions': 7.22.5(@babel/core@7.23.2) @@ -7176,7 +7181,7 @@ packages: /@graphql-tools/import@6.7.18(graphql@16.8.1): resolution: {integrity: sha512-XQDdyZTp+FYmT7as3xRWH/x8dx0QZA2WZqfMF5EWb36a0PiH7WwlRQYIdyYXj8YCLpiWkeBXgBRHmMnwEYR8iQ==} peerDependencies: - graphql: ^16.6.0 + graphql: ^14.0.0 || ^15.0.0 || ^16.0.0 || ^17.0.0 dependencies: '@graphql-tools/utils': 9.2.1(graphql@16.8.1) graphql: 16.8.1 @@ -7186,7 +7191,7 @@ packages: /@graphql-tools/load@7.8.14(graphql@16.8.1): resolution: {integrity: sha512-ASQvP+snHMYm+FhIaLxxFgVdRaM0vrN9wW2BKInQpktwWTXVyk+yP5nQUCEGmn0RTdlPKrffBaigxepkEAJPrg==} peerDependencies: - graphql: ^16.6.0 + graphql: ^14.0.0 || ^15.0.0 || ^16.0.0 || ^17.0.0 dependencies: '@graphql-tools/schema': 9.0.19(graphql@16.8.1) '@graphql-tools/utils': 9.2.1(graphql@16.8.1) @@ -7197,7 +7202,7 @@ packages: /@graphql-tools/merge@8.4.2(graphql@16.8.1): resolution: {integrity: sha512-XbrHAaj8yDuINph+sAfuq3QCZ/tKblrTLOpirK0+CAgNlZUCHs0Fa+xtMUURgwCVThLle1AF7svJCxFizygLsw==} peerDependencies: - graphql: ^16.6.0 + graphql: ^14.0.0 || ^15.0.0 || ^16.0.0 || ^17.0.0 dependencies: '@graphql-tools/utils': 9.2.1(graphql@16.8.1) graphql: 16.8.1 @@ -7207,7 +7212,7 @@ packages: resolution: {integrity: sha512-J7/xqjkGTTwOJmaJQJ2C+VDBDOWJL3lKrHJN4yMaRLAJH3PosB7GiPRaSDZdErs0+F77sH2MKs2haMMkywzx7Q==} engines: {node: '>=16.0.0'} peerDependencies: - graphql: ^16.6.0 + graphql: ^14.0.0 || ^15.0.0 || ^16.0.0 || ^17.0.0 dependencies: '@graphql-tools/utils': 10.0.7(graphql@16.8.1) graphql: 16.8.1 @@ -7216,7 +7221,7 @@ packages: /@graphql-tools/optimize@1.4.0(graphql@16.8.1): resolution: {integrity: sha512-dJs/2XvZp+wgHH8T5J2TqptT9/6uVzIYvA6uFACha+ufvdMBedkfR4b4GbT8jAKLRARiqRTxy3dctnwkTM2tdw==} peerDependencies: - graphql: ^16.6.0 + graphql: ^14.0.0 || ^15.0.0 || ^16.0.0 || ^17.0.0 dependencies: graphql: 16.8.1 tslib: 2.6.2 @@ -7224,7 +7229,7 @@ packages: /@graphql-tools/relay-operation-optimizer@6.5.18(graphql@16.8.1): resolution: {integrity: sha512-mc5VPyTeV+LwiM+DNvoDQfPqwQYhPV/cl5jOBjTgSniyaq8/86aODfMkrE2OduhQ5E00hqrkuL2Fdrgk0w1QJg==} peerDependencies: - graphql: ^16.6.0 + graphql: ^14.0.0 || ^15.0.0 || ^16.0.0 || ^17.0.0 dependencies: '@ardatan/relay-compiler': 12.0.0(graphql@16.8.1) '@graphql-tools/utils': 9.2.1(graphql@16.8.1) @@ -7238,7 +7243,7 @@ packages: resolution: {integrity: sha512-kf3qOXMFcMs2f/S8Y3A8fm/2w+GaHAkfr3Gnhh2LOug/JgpY/ywgFVxO3jOeSpSEdoYcDKLcXVjMigNbY4AdQg==} engines: {node: '>=16.0.0'} peerDependencies: - graphql: ^16.6.0 + graphql: ^14.0.0 || ^15.0.0 || ^16.0.0 || ^17.0.0 dependencies: '@graphql-tools/merge': 9.0.0(graphql@16.8.1) '@graphql-tools/utils': 10.0.7(graphql@16.8.1) @@ -7249,7 +7254,7 @@ packages: /@graphql-tools/schema@9.0.19(graphql@16.8.1): resolution: {integrity: sha512-oBRPoNBtCkk0zbUsyP4GaIzCt8C0aCI4ycIRUL67KK5pOHljKLBBtGT+Jr6hkzA74C8Gco8bpZPe7aWFjiaK2w==} peerDependencies: - graphql: ^16.6.0 + graphql: ^14.0.0 || ^15.0.0 || ^16.0.0 || ^17.0.0 dependencies: '@graphql-tools/merge': 8.4.2(graphql@16.8.1) '@graphql-tools/utils': 9.2.1(graphql@16.8.1) @@ -7260,7 +7265,7 @@ packages: /@graphql-tools/stitch@8.7.50(graphql@16.8.1): resolution: {integrity: sha512-VB1/uZyXjj1P5Wj0c4EKX3q8Q1Maj4dy6uNwodEPaO3EHMpaJU/DqyN0Bvnhxu0ol7RzdY3kgsvsdUjU2QMImw==} peerDependencies: - graphql: ^16.6.0 + graphql: ^14.0.0 || ^15.0.0 || ^16.0.0 || ^17.0.0 dependencies: '@graphql-tools/batch-delegate': 8.4.27(graphql@16.8.1) '@graphql-tools/delegate': 9.0.35(graphql@16.8.1) @@ -7277,7 +7282,7 @@ packages: resolution: {integrity: sha512-G03XahiHDu1pnaS8z2GNfsV/5BribMEUATT5dCHBAqj13Te5y1amZNQePrmw8DLtbf5qDbU6CO7kGHPxv0XO9A==} engines: {node: '>=16.0.0'} peerDependencies: - graphql: ^16.6.0 + graphql: ^14.0.0 || ^15.0.0 || ^16.0.0 || ^17.0.0 dependencies: '@graphql-tools/batch-delegate': 9.0.0(graphql@16.8.1) '@graphql-tools/delegate': 10.0.3(graphql@16.8.1) @@ -7294,22 +7299,22 @@ packages: /@graphql-tools/stitching-directives@2.3.34(graphql@16.8.1): resolution: {integrity: sha512-DVlo1/SW9jN6jN1IL279c7voEJiEHsLbYRD7tYsAW472zrHqn0rpB6jRzZDzLOlCpm7JRWPsegXVlkqf0qvqFQ==} peerDependencies: - graphql: ^16.6.0 + graphql: ^14.0.0 || ^15.0.0 || ^16.0.0 || ^17.0.0 dependencies: '@graphql-tools/delegate': 9.0.35(graphql@16.8.1) '@graphql-tools/utils': 9.2.1(graphql@16.8.1) graphql: 16.8.1 tslib: 2.6.2 - /@graphql-tools/url-loader@7.17.18(@types/node@18.18.6)(graphql@16.8.1): + /@graphql-tools/url-loader@7.17.18(@types/node@18.18.7)(graphql@16.8.1): resolution: {integrity: sha512-ear0CiyTj04jCVAxi7TvgbnGDIN2HgqzXzwsfcqiVg9cvjT40NcMlZ2P1lZDgqMkZ9oyLTV8Bw6j+SyG6A+xPw==} peerDependencies: - graphql: ^16.6.0 + graphql: ^14.0.0 || ^15.0.0 || ^16.0.0 || ^17.0.0 dependencies: '@ardatan/sync-fetch': 0.0.1 '@graphql-tools/delegate': 9.0.35(graphql@16.8.1) '@graphql-tools/executor-graphql-ws': 0.0.14(graphql@16.8.1) - '@graphql-tools/executor-http': 0.1.10(@types/node@18.18.6)(graphql@16.8.1) + '@graphql-tools/executor-http': 0.1.10(@types/node@18.18.7)(graphql@16.8.1) '@graphql-tools/executor-legacy-ws': 0.0.11(graphql@16.8.1) '@graphql-tools/utils': 9.2.1(graphql@16.8.1) '@graphql-tools/wrap': 9.4.2(graphql@16.8.1) @@ -7326,21 +7331,21 @@ packages: - encoding - utf-8-validate - /@graphql-tools/url-loader@8.0.0(@types/node@18.18.6)(graphql@16.8.1): + /@graphql-tools/url-loader@8.0.0(@types/node@18.18.7)(graphql@16.8.1): resolution: {integrity: sha512-rPc9oDzMnycvz+X+wrN3PLrhMBQkG4+sd8EzaFN6dypcssiefgWKToXtRKI8HHK68n2xEq1PyrOpkjHFJB+GwA==} engines: {node: '>=16.0.0'} peerDependencies: - graphql: ^16.6.0 + graphql: ^14.0.0 || ^15.0.0 || ^16.0.0 || ^17.0.0 dependencies: '@ardatan/sync-fetch': 0.0.1 '@graphql-tools/delegate': 10.0.3(graphql@16.8.1) '@graphql-tools/executor-graphql-ws': 1.1.0(graphql@16.8.1) - '@graphql-tools/executor-http': 1.0.3(@types/node@18.18.6)(graphql@16.8.1) + '@graphql-tools/executor-http': 1.0.3(@types/node@18.18.7)(graphql@16.8.1) '@graphql-tools/executor-legacy-ws': 1.0.4(graphql@16.8.1) '@graphql-tools/utils': 10.0.7(graphql@16.8.1) '@graphql-tools/wrap': 10.0.1(graphql@16.8.1) '@types/ws': 8.5.8 - '@whatwg-node/fetch': 0.9.13 + '@whatwg-node/fetch': 0.9.14 graphql: 16.8.1 isomorphic-ws: 5.0.0(ws@8.14.2) tslib: 2.6.2 @@ -7357,17 +7362,17 @@ packages: resolution: {integrity: sha512-KOdeMj6Hd/MENDaqPbws3YJl3wVy0DeYnL7PyUms5Skyf7uzI9INynDwPMhLXfSb0/ph6BXTwMd5zBtWbF8tBQ==} engines: {node: '>=16.0.0'} peerDependencies: - graphql: ^16.6.0 + graphql: ^14.0.0 || ^15.0.0 || ^16.0.0 || ^17.0.0 dependencies: '@graphql-typed-document-node/core': 3.2.0(graphql@16.8.1) - dset: 3.1.2 + dset: 3.1.3 graphql: 16.8.1 tslib: 2.6.2 /@graphql-tools/utils@8.13.1(graphql@16.8.1): resolution: {integrity: sha512-qIh9yYpdUFmctVqovwMdheVNJqFh+DQNWIhX87FJStfXYnmweBUDATok9fWPleKeFwxnW8IapKmY8m8toJEkAw==} peerDependencies: - graphql: ^16.6.0 + graphql: ^14.0.0 || ^15.0.0 || ^16.0.0 || ^17.0.0 dependencies: graphql: 16.8.1 tslib: 2.6.2 @@ -7375,7 +7380,7 @@ packages: /@graphql-tools/utils@9.2.1(graphql@16.8.1): resolution: {integrity: sha512-WUw506Ql6xzmOORlriNrD6Ugx+HjVgYxt9KCXD9mHAak+eaXSwuGGPyE60hy9xaDEoXKBsG7SkG69ybitaVl6A==} peerDependencies: - graphql: ^16.6.0 + graphql: ^14.0.0 || ^15.0.0 || ^16.0.0 || ^17.0.0 dependencies: '@graphql-typed-document-node/core': 3.2.0(graphql@16.8.1) graphql: 16.8.1 @@ -7385,7 +7390,7 @@ packages: resolution: {integrity: sha512-Cw6hVrKGM2OKBXeuAGltgy4tzuqQE0Nt7t/uAqnuokSXZhMHXJUb124Bnvxc2gPZn5chfJSDafDe4Cp8ZAVJgg==} engines: {node: '>=16.0.0'} peerDependencies: - graphql: ^16.6.0 + graphql: ^14.0.0 || ^15.0.0 || ^16.0.0 || ^17.0.0 dependencies: '@graphql-tools/delegate': 10.0.3(graphql@16.8.1) '@graphql-tools/schema': 10.0.0(graphql@16.8.1) @@ -7398,7 +7403,7 @@ packages: /@graphql-tools/wrap@9.4.2(graphql@16.8.1): resolution: {integrity: sha512-DFcd9r51lmcEKn0JW43CWkkI2D6T9XI1juW/Yo86i04v43O9w2/k4/nx2XTJv4Yv+iXwUw7Ok81PGltwGJSDSA==} peerDependencies: - graphql: ^16.6.0 + graphql: ^14.0.0 || ^15.0.0 || ^16.0.0 || ^17.0.0 dependencies: '@graphql-tools/delegate': 9.0.35(graphql@16.8.1) '@graphql-tools/schema': 9.0.19(graphql@16.8.1) @@ -7410,7 +7415,7 @@ packages: /@graphql-typed-document-node/core@3.2.0(graphql@16.8.1): resolution: {integrity: sha512-mB9oAsNCm9aM3/SOv4YtBMqZbYj10R7dkq8byBqxGY/ncFwhf2oQzMV+LCRlWoDSEBJ3COiR1yeDvMtsoOsuFQ==} peerDependencies: - graphql: ^16.6.0 + graphql: ^0.8.0 || ^0.9.0 || ^0.10.0 || ^0.11.0 || ^0.12.0 || ^0.13.0 || ^14.0.0 || ^15.0.0 || ^16.0.0 || ^17.0.0 dependencies: graphql: 16.8.1 @@ -7475,7 +7480,6 @@ packages: minimatch: 3.1.2 transitivePeerDependencies: - supports-color - dev: true /@humanwhocodes/config-array@0.9.5: resolution: {integrity: sha512-ObyMyWxZiCu/yTisA7uzx81s40xR2fD5Cg/2Kq7G02ajkNubJf6BopgDTmDyc3U7sXpNKM8cYOw7s7Tyr+DnCw==} @@ -7491,7 +7495,6 @@ packages: /@humanwhocodes/module-importer@1.0.1: resolution: {integrity: sha512-bxveV4V8v5Yb4ncFTT3rPSgZBOpCkjfK0y4oVVVJwIuDVBRMDXrPyXRL988i5ap9m9bnyEEjWfm5WkBmtffLfA==} engines: {node: '>=12.22'} - dev: true /@humanwhocodes/object-schema@1.2.1: resolution: {integrity: sha512-ZnQMnLV4e7hDlUvw8H+U8ASL02SS2Gn6+9Ac3wGGLIe7+je2AeAOxPY+izIPJDfFDb7eDjev0Us8MO1iFRN8hA==} @@ -7499,59 +7502,66 @@ packages: /@humanwhocodes/object-schema@2.0.1: resolution: {integrity: sha512-dvuCeX5fC9dXgJn9t+X5atfmgQAzUOWqS1254Gh0m6i8wKd10ebXkfNKiRK+1GWi/yTvvLDHpoxLr0xxxeslWw==} - dev: true /@hypercerts-org/contracts@0.8.11: resolution: {integrity: sha512-n6fwMsaoR50VITM2upR4OOi4EZJmZvU6vvXrHWCSakP9e1OeDuAOk+kHiK+egqDRYj6uKtg9VTUFKZBYvu3jRg==} dev: false - /@hypercerts-org/sdk@0.8.16(@envelop/core@3.0.6)(@ethersproject/abi@5.7.0)(@ethersproject/providers@5.7.2)(@graphql-tools/delegate@9.0.35)(@graphql-tools/merge@8.4.2)(@graphql-tools/utils@9.2.1)(@graphql-tools/wrap@9.4.2)(@types/node@18.18.6)(node-fetch@3.3.2)(react-dom@18.2.0)(react@18.2.0)(tslib@2.6.2)(typescript@5.1.6)(uint8arraylist@2.4.3): - resolution: {integrity: sha512-WkxYb5RYhv3QI7+N5y4xg5IL4azLqCq4ia1/bgFB55vWJLjnmoMj3VYbiybMxyfgnPfh5O8n2DU86u8ClLgyhg==} + /@hypercerts-org/contracts@0.9.0(typescript@5.1.6): + resolution: {integrity: sha512-enXkIzZxYMDaOchL9peq6ddIfo0uJeJb1o+nj3LMy5AzK5B+3ijNkJFDUx0N8RZPO2jVgqO3/4czAavndLfNww==} + dependencies: + hardhat: 2.18.3(typescript@5.1.6) + transitivePeerDependencies: + - bufferutil + - supports-color + - ts-node + - typescript + - utf-8-validate + dev: false + + /@hypercerts-org/sdk@1.0.0-alpha.6(@envelop/core@3.0.6)(@graphql-tools/delegate@9.0.35)(@graphql-tools/merge@8.4.2)(@graphql-tools/utils@9.2.1)(@graphql-tools/wrap@9.4.2)(@types/node@18.18.7)(node-fetch@3.3.2)(react-dom@18.2.0)(react@18.2.0)(tslib@2.6.2)(typescript@5.1.6)(uint8arraylist@2.4.3)(zod@3.22.4): + resolution: {integrity: sha512-WnZJfKGGqaQAPasvKjAuQ1eyWJT8kfY5Z445SjeFU8xWDelLRGuwaMT1w+B3e16YbZFQXBr/eB/dabMVb9ZPrQ==} dependencies: - '@ethereum-attestation-service/eas-sdk': 0.28.3(@ethersproject/abi@5.7.0)(@ethersproject/providers@5.7.2)(typescript@5.1.6) + '@ethereum-attestation-service/eas-sdk': 1.2.2-beta.0(ts-node@10.9.1)(typescript@5.1.6) '@ethersproject/abstract-signer': 5.7.0 - '@graphprotocol/client-add-source-name': 1.0.20(@graphql-mesh/types@0.95.7)(@graphql-tools/delegate@9.0.35)(@graphql-tools/utils@9.2.1)(@graphql-tools/wrap@9.4.2)(graphql@16.8.1) + '@graphprotocol/client-add-source-name': 1.0.20(@graphql-mesh/types@0.95.8)(@graphql-tools/delegate@9.0.35)(@graphql-tools/utils@9.2.1)(@graphql-tools/wrap@9.4.2)(graphql@16.8.1) '@graphprotocol/client-polling-live': 2.0.0(@envelop/core@3.0.6)(@graphql-tools/merge@8.4.2)(graphql@16.8.1) - '@graphql-mesh/cache-localforage': 0.95.7(@graphql-mesh/types@0.95.7)(@graphql-mesh/utils@0.95.7)(graphql@16.8.1)(tslib@2.6.2) + '@graphql-mesh/cache-localforage': 0.95.8(@graphql-mesh/types@0.95.8)(@graphql-mesh/utils@0.95.8)(graphql@16.8.1)(tslib@2.6.2) '@graphql-mesh/cross-helpers': 0.4.1(@graphql-tools/utils@9.2.1)(graphql@16.8.1) - '@graphql-mesh/graphql': 0.95.7(@graphql-mesh/cross-helpers@0.4.1)(@graphql-mesh/store@0.95.7)(@graphql-mesh/types@0.95.7)(@graphql-mesh/utils@0.95.7)(@graphql-tools/utils@9.2.1)(@types/node@18.18.6)(graphql@16.8.1)(react-dom@18.2.0)(react@18.2.0)(tslib@2.6.2) - '@graphql-mesh/http': 0.96.13(@graphql-mesh/cross-helpers@0.4.1)(@graphql-mesh/runtime@0.96.12)(@graphql-mesh/types@0.95.7)(@graphql-mesh/utils@0.95.7)(graphql@16.8.1)(tslib@2.6.2) - '@graphql-mesh/merger-bare': 0.95.7(@graphql-mesh/store@0.95.7)(@graphql-mesh/types@0.95.7)(@graphql-mesh/utils@0.95.7)(@graphql-tools/utils@9.2.1)(graphql@16.8.1)(tslib@2.6.2) - '@graphql-mesh/runtime': 0.96.12(@graphql-mesh/cross-helpers@0.3.4)(@graphql-mesh/types@0.93.2)(@graphql-mesh/utils@0.93.2)(@graphql-tools/utils@9.2.1)(graphql@16.8.1)(tslib@2.6.2) - '@graphql-mesh/store': 0.95.7(@graphql-mesh/cross-helpers@0.4.1)(@graphql-mesh/types@0.95.7)(@graphql-mesh/utils@0.95.7)(@graphql-tools/utils@9.2.1)(graphql@16.8.1)(tslib@2.6.2) - '@graphql-mesh/types': 0.95.7(@graphql-mesh/store@0.95.7)(@graphql-tools/utils@9.2.1)(graphql@16.8.1)(tslib@2.6.2) - '@graphql-mesh/utils': 0.95.7(@graphql-mesh/cross-helpers@0.4.1)(@graphql-mesh/types@0.95.7)(@graphql-tools/utils@9.2.1)(graphql@16.8.1)(tslib@2.6.2) + '@graphql-mesh/graphql': 0.95.8(@graphql-mesh/cross-helpers@0.4.1)(@graphql-mesh/store@0.95.8)(@graphql-mesh/types@0.95.8)(@graphql-mesh/utils@0.95.8)(@graphql-tools/utils@9.2.1)(@types/node@18.18.7)(graphql@16.8.1)(react-dom@18.2.0)(react@18.2.0)(tslib@2.6.2) + '@graphql-mesh/http': 0.96.14(@graphql-mesh/cross-helpers@0.4.1)(@graphql-mesh/runtime@0.96.13)(@graphql-mesh/types@0.95.8)(@graphql-mesh/utils@0.95.8)(graphql@16.8.1)(tslib@2.6.2) + '@graphql-mesh/merger-bare': 0.95.8(@graphql-mesh/store@0.95.8)(@graphql-mesh/types@0.95.8)(@graphql-mesh/utils@0.95.8)(@graphql-tools/utils@9.2.1)(graphql@16.8.1)(tslib@2.6.2) + '@graphql-mesh/runtime': 0.96.13(@graphql-mesh/cross-helpers@0.3.4)(@graphql-mesh/types@0.93.2)(@graphql-mesh/utils@0.93.2)(@graphql-tools/utils@9.2.1)(graphql@16.8.1)(tslib@2.6.2) + '@graphql-mesh/store': 0.95.8(@graphql-mesh/cross-helpers@0.4.1)(@graphql-mesh/types@0.95.8)(@graphql-mesh/utils@0.95.8)(@graphql-tools/utils@9.2.1)(graphql@16.8.1)(tslib@2.6.2) + '@graphql-mesh/types': 0.95.8(@graphql-mesh/store@0.95.8)(@graphql-tools/utils@9.2.1)(graphql@16.8.1)(tslib@2.6.2) + '@graphql-mesh/utils': 0.95.8(@graphql-mesh/cross-helpers@0.4.1)(@graphql-mesh/types@0.95.8)(@graphql-tools/utils@9.2.1)(graphql@16.8.1)(tslib@2.6.2) '@graphql-typed-document-node/core': 3.2.0(graphql@16.8.1) '@hypercerts-org/contracts': 0.8.11 '@openzeppelin/merkle-tree': 1.0.5 - '@whatwg-node/fetch': 0.9.13 + '@whatwg-node/fetch': 0.9.14 ajv: 8.12.0 axios: 1.5.1(debug@4.3.4) dotenv: 16.3.1 ethers: 5.7.2 graphql: 16.8.1 ipfs-core: 0.17.0(uint8arraylist@2.4.3) - jest: 29.7.0(@types/node@18.18.6)(ts-node@10.9.1) loglevel: 1.8.1 mime: 3.0.0 nft.storage: 7.1.1(node-fetch@3.3.2) + viem: 1.18.4(typescript@5.1.6)(zod@3.22.4) web3.storage: 4.5.5(node-fetch@3.3.2) transitivePeerDependencies: - '@envelop/core' - - '@ethersproject/abi' - - '@ethersproject/providers' - '@graphql-tools/delegate' - '@graphql-tools/merge' - '@graphql-tools/utils' - '@graphql-tools/wrap' - '@types/node' - - babel-plugin-macros - bufferutil - debug - encoding - graphql-ws - node-fetch - - node-notifier - react - react-dom - subscriptions-transport-ws @@ -7561,6 +7571,7 @@ packages: - typescript - uint8arraylist - utf-8-validate + - zod dev: false /@iarna/toml@2.2.5: @@ -7580,8 +7591,8 @@ packages: engines: {node: '>=16.0.0', npm: '>=7.0.0'} dependencies: '@ipld/dag-cbor': 9.0.6 - cborg: 4.0.4 - multiformats: 12.1.2 + cborg: 4.0.5 + multiformats: 12.1.3 varint: 6.0.0 dev: false @@ -7610,8 +7621,8 @@ packages: resolution: {integrity: sha512-3kNab5xMppgWw6DVYx2BzmFq8t7I56AGWfp5kaU1fIPkwHVpBRglJJTYsGtbVluCi/s/q97HZM3bC+aDW4sxbQ==} engines: {node: '>=16.0.0', npm: '>=7.0.0'} dependencies: - cborg: 4.0.4 - multiformats: 12.1.2 + cborg: 4.0.5 + multiformats: 12.1.3 dev: false /@ipld/dag-json@8.0.11: @@ -7661,21 +7672,24 @@ packages: get-package-type: 0.1.0 js-yaml: 3.14.1 resolve-from: 5.0.0 + dev: true /@istanbuljs/schema@0.1.3: resolution: {integrity: sha512-ZXRY4jNvVgSVQ8DL3LTcakaAtXwTVUxE81hslsyD2AtoXW/wVob10HkOJ1X/pAlcI7D+2YoZKg5do8G/w6RYgA==} engines: {node: '>=8'} + dev: true /@jest/console@29.7.0: resolution: {integrity: sha512-5Ni4CU7XHQi32IJ398EEP4RrB8eV09sXP2ROqD4bksHrnTree52PsxvX8tpL8LvTZ3pFzXyPbNQReSN41CAhOg==} engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} dependencies: '@jest/types': 29.6.3 - '@types/node': 18.18.6 + '@types/node': 18.18.7 chalk: 4.1.2 jest-message-util: 29.7.0 jest-util: 29.7.0 slash: 3.0.0 + dev: true /@jest/core@29.7.0(ts-node@10.9.1): resolution: {integrity: sha512-n7aeXWKMnGtDA48y8TLWJPJmLmmZ642Ceo78cYWEpiD7FzDgmNDV/GCVRorPABdXLJZ/9wzzgZAlHjXjxDHGsg==} @@ -7691,14 +7705,14 @@ packages: '@jest/test-result': 29.7.0 '@jest/transform': 29.7.0 '@jest/types': 29.6.3 - '@types/node': 18.18.6 + '@types/node': 18.18.7 ansi-escapes: 4.3.2 chalk: 4.1.2 ci-info: 3.9.0 exit: 0.1.2 graceful-fs: 4.2.11 jest-changed-files: 29.7.0 - jest-config: 29.7.0(@types/node@18.18.6)(ts-node@10.9.1) + jest-config: 29.7.0(@types/node@18.18.7)(ts-node@10.9.1) jest-haste-map: 29.7.0 jest-message-util: 29.7.0 jest-regex-util: 29.6.3 @@ -7718,6 +7732,7 @@ packages: - babel-plugin-macros - supports-color - ts-node + dev: true /@jest/create-cache-key-function@29.7.0: resolution: {integrity: sha512-4QqS3LY5PBmTRHj9sAg1HLoPzqAI0uOX6wI/TRqHIcOxlFidy6YEmCQJk6FSZjNLGCeubDMfmkWL+qaLKhSGQA==} @@ -7731,7 +7746,7 @@ packages: dependencies: '@jest/fake-timers': 29.7.0 '@jest/types': 29.6.3 - '@types/node': 18.18.6 + '@types/node': 18.18.7 jest-mock: 29.7.0 /@jest/expect-utils@29.7.0: @@ -7739,6 +7754,7 @@ packages: engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} dependencies: jest-get-type: 29.6.3 + dev: true /@jest/expect@29.7.0: resolution: {integrity: sha512-8uMeAMycttpva3P1lBHB8VciS9V0XAr3GymPpipdyQXbBcuhkLQOSe8E/p92RyAdToS6ZD1tFkX+CkhoECE0dQ==} @@ -7748,6 +7764,7 @@ packages: jest-snapshot: 29.7.0 transitivePeerDependencies: - supports-color + dev: true /@jest/fake-timers@29.7.0: resolution: {integrity: sha512-q4DH1Ha4TTFPdxLsqDXK1d3+ioSL7yL5oCMJZgDYm6i+6CygW5E5xVr/D1HdsGxjt1ZWSfUAs9OxSB/BNelWrQ==} @@ -7755,7 +7772,7 @@ packages: dependencies: '@jest/types': 29.6.3 '@sinonjs/fake-timers': 10.3.0 - '@types/node': 18.18.6 + '@types/node': 18.18.7 jest-message-util: 29.7.0 jest-mock: 29.7.0 jest-util: 29.7.0 @@ -7770,6 +7787,7 @@ packages: jest-mock: 29.7.0 transitivePeerDependencies: - supports-color + dev: true /@jest/reporters@29.7.0: resolution: {integrity: sha512-DApq0KJbJOEzAFYjHADNNxAE3KbhxQB1y5Kplb5Waqw6zVbuWatSnMjE5gs8FUgEPmNsnZA3NCWl9NG0ia04Pg==} @@ -7786,7 +7804,7 @@ packages: '@jest/transform': 29.7.0 '@jest/types': 29.6.3 '@jridgewell/trace-mapping': 0.3.20 - '@types/node': 18.18.6 + '@types/node': 18.18.7 chalk: 4.1.2 collect-v8-coverage: 1.0.2 exit: 0.1.2 @@ -7806,6 +7824,7 @@ packages: v8-to-istanbul: 9.1.3 transitivePeerDependencies: - supports-color + dev: true /@jest/schemas@29.6.3: resolution: {integrity: sha512-mo5j5X+jIZmJQveBKeS/clAueipV7KgiX1vMgCxam1RNYiqE1w62n0/tJJnHtjW8ZHcQco5gY85jA3mi0L+nSA==} @@ -7820,6 +7839,7 @@ packages: '@jridgewell/trace-mapping': 0.3.20 callsites: 3.1.0 graceful-fs: 4.2.11 + dev: true /@jest/test-result@29.7.0: resolution: {integrity: sha512-Fdx+tv6x1zlkJPcWXmMDAG2HBnaR9XPSd5aDWQVsfrZmLVT3lU1cwyxLgRmXR9yrq4NBoEm9BMsfgFzTQAbJYA==} @@ -7829,6 +7849,7 @@ packages: '@jest/types': 29.6.3 '@types/istanbul-lib-coverage': 2.0.5 collect-v8-coverage: 1.0.2 + dev: true /@jest/test-sequencer@29.7.0: resolution: {integrity: sha512-GQwJ5WZVrKnOJuiYiAF52UNUJXgTZx1NHjFSEB0qEMmSZKAkdMoIzw/Cj6x6NF4AvV23AUqDpFzQkN/eYCYTxw==} @@ -7838,6 +7859,7 @@ packages: graceful-fs: 4.2.11 jest-haste-map: 29.7.0 slash: 3.0.0 + dev: true /@jest/transform@29.7.0: resolution: {integrity: sha512-ok/BTPFzFKVMwO5eOHRrvnBVHdRy9IrsrW1GpMaQ9MCnilNLXQKmAX8s1YXDFaai9xJpac2ySzV0YeRRECr2Vw==} @@ -7860,6 +7882,7 @@ packages: write-file-atomic: 4.0.2 transitivePeerDependencies: - supports-color + dev: true /@jest/types@26.6.2: resolution: {integrity: sha512-fC6QCp7Sc5sX6g8Tvbmj4XUTbyrik0akgRy03yjXbQaBWWNWGE7SGtJk98m0N8nzegD/7SggrUlivxo5ax4KWQ==} @@ -7867,7 +7890,7 @@ packages: dependencies: '@types/istanbul-lib-coverage': 2.0.5 '@types/istanbul-reports': 3.0.3 - '@types/node': 18.18.6 + '@types/node': 18.18.7 '@types/yargs': 15.0.17 chalk: 4.1.2 @@ -7877,7 +7900,7 @@ packages: dependencies: '@types/istanbul-lib-coverage': 2.0.5 '@types/istanbul-reports': 3.0.3 - '@types/node': 18.18.6 + '@types/node': 18.18.7 '@types/yargs': 16.0.7 chalk: 4.1.2 @@ -7888,7 +7911,7 @@ packages: '@jest/schemas': 29.6.3 '@types/istanbul-lib-coverage': 2.0.5 '@types/istanbul-reports': 3.0.3 - '@types/node': 18.18.6 + '@types/node': 18.18.7 '@types/yargs': 17.0.29 chalk: 4.1.2 @@ -8342,14 +8365,14 @@ packages: - supports-color dev: false - /@libp2p/interface@0.1.3: - resolution: {integrity: sha512-C1O7Xqd2TGVWrIOEDx6kGJSk4YOysWGmYG5Oh3chnsCY0wjUSsLDpl9+wKrdiM/lJbAlHlV65ZOvSkIQ9cWPBQ==} + /@libp2p/interface@0.1.4: + resolution: {integrity: sha512-Pk8mzit/w7PbTh28n77RDLTU1CQBBzLygiNC07MvcEjaIwqXdNPN3Vuzr/5qiF6aDsbM9fA1W5dWoCif9xBdxg==} dependencies: '@multiformats/multiaddr': 12.1.7 abortable-iterator: 5.0.1 it-pushable: 3.2.1 it-stream-types: 2.0.1 - multiformats: 12.1.2 + multiformats: 12.1.3 p-defer: 4.0.0 race-signal: 1.0.1 uint8arraylist: 2.4.3 @@ -8428,14 +8451,14 @@ packages: - supports-color dev: false - /@libp2p/logger@3.0.3: - resolution: {integrity: sha512-85ioPX10QN4ZOZeurAZe5sQeRUCkIBT2DikKRbE/AIWKauIKHvvIrN4CSdCdzLw29XNA+xxNO2FVkf51HGgCeQ==} + /@libp2p/logger@3.0.4: + resolution: {integrity: sha512-MF42c7SOJIx5YmHhIsFaSYfaC266YYmMbAJHjjH8Zl5unFsqW82M+Xr7sGVj9/WXrWAd37ts8xJaQrkIXc3OZQ==} dependencies: - '@libp2p/interface': 0.1.3 + '@libp2p/interface': 0.1.4 '@multiformats/multiaddr': 12.1.7 debug: 4.3.4(supports-color@8.1.1) interface-datastore: 8.2.5 - multiformats: 12.1.2 + multiformats: 12.1.3 transitivePeerDependencies: - supports-color dev: false @@ -8812,6 +8835,11 @@ packages: '@lit-labs/ssr-dom-shim': 1.1.2 dev: false + /@looksrare/contracts-libs@3.4.0: + resolution: {integrity: sha512-tRFHcz9D4J0PLQg4ETWlvlRqrHpEoZhKsCTbyqATDXmekXvxbgk8+sRtaZK9Zo4gHpt6x+TcOgdUdARCg2elWg==} + engines: {node: '>=8.3.0'} + dev: true + /@mdx-js/mdx@1.6.22: resolution: {integrity: sha512-AMxuLxPz2j5/6TpF/XSdKpQP1NlG0z11dFOlq+2IP/lSgl11GY8ji6S/rgsViN/L0BDvHvUMruRb7ub+24LUYA==} dependencies: @@ -8860,8 +8888,8 @@ packages: tweetnacl: 1.0.3 tweetnacl-util: 0.15.1 - /@metamask/object-multiplex@1.2.0: - resolution: {integrity: sha512-hksV602d3NWE2Q30Mf2Np1WfVKaGqfJRy9vpHAmelbaD0OkDt06/0KQkRR6UVYdMbTbkuEu8xN5JDUU80inGwQ==} + /@metamask/object-multiplex@1.3.0: + resolution: {integrity: sha512-czcQeVYdSNtabd+NcYQnrM69MciiJyd1qvKH8WM2Id3C0ZiUUX5Xa/MK+/VUk633DBhVOwdNzAKIQ33lGyA+eQ==} engines: {node: '>=12.0.0'} dependencies: end-of-stream: 1.4.4 @@ -8873,10 +8901,10 @@ packages: resolution: {integrity: sha512-xjE4cKrGpKZjripkMKMStc0H4LXrWJPijfbaj1kKeDLVhRH2Yu3ZecV3iIhf1EIJePeA+Kx6Pcm7d0IVJ+ea7g==} engines: {node: '>=16.0.0'} dependencies: - '@metamask/object-multiplex': 1.2.0 + '@metamask/object-multiplex': 1.3.0 '@metamask/safe-event-emitter': 3.0.0 detect-browser: 5.3.0 - eth-rpc-errors: 4.0.2 + eth-rpc-errors: 4.0.3 extension-port-stream: 2.1.1 fast-deep-equal: 3.1.3 is-stream: 2.0.1 @@ -9139,32 +9167,8 @@ packages: tslib: 2.6.2 dev: false - /@mswjs/cookies@0.2.2: - resolution: {integrity: sha512-mlN83YSrcFgk7Dm1Mys40DLssI1KdJji2CMKN8eOlBqsTADYzj2+jWzsANsUTFbxDMWPD5e9bfA1RGqBpS3O1g==} - engines: {node: '>=14'} - dependencies: - '@types/set-cookie-parser': 2.4.5 - set-cookie-parser: 2.6.0 - dev: true - - /@mswjs/interceptors@0.17.10: - resolution: {integrity: sha512-N8x7eSLGcmUFNWZRxT1vsHvypzIRgQYdG0rJey/rZCy6zT/30qDt8Joj7FxzGNLSwXbeZqJOMqDurp7ra4hgbw==} - engines: {node: '>=14'} - dependencies: - '@open-draft/until': 1.0.3 - '@types/debug': 4.1.10 - '@xmldom/xmldom': 0.8.10 - debug: 4.3.4(supports-color@8.1.1) - headers-polyfill: 3.2.5 - outvariant: 1.4.0 - strict-event-emitter: 0.2.8 - web-encoding: 1.1.5 - transitivePeerDependencies: - - supports-color - dev: true - - /@mui/base@5.0.0-beta.20(@types/react@18.2.31)(react-dom@18.2.0)(react@18.2.0): - resolution: {integrity: sha512-CS2pUuqxST7ch9VNDCklRYDbJ3rru20Tx7na92QvVVKfu3RL4z/QLuVIc8jYGsdCnauMaeUSlFNLAJNb0yXe6w==} + /@mui/base@5.0.0-beta.21(@types/react@18.2.33)(react-dom@18.2.0)(react@18.2.0): + resolution: {integrity: sha512-eTKWx3WV/nwmRUK4z4K1MzlMyWCsi3WJ3RtV4DiXZeRh4qd4JCyp1Zzzi8Wv9xM4dEBmqQntFoei716PzwmFfA==} engines: {node: '>=12.0.0'} peerDependencies: '@types/react': ^17.0.0 || ^18.0.0 @@ -9176,22 +9180,22 @@ packages: dependencies: '@babel/runtime': 7.23.2 '@floating-ui/react-dom': 2.0.2(react-dom@18.2.0)(react@18.2.0) - '@mui/types': 7.2.6(@types/react@18.2.31) - '@mui/utils': 5.14.14(@types/react@18.2.31)(react@18.2.0) + '@mui/types': 7.2.7(@types/react@18.2.33) + '@mui/utils': 5.14.15(@types/react@18.2.33)(react@18.2.0) '@popperjs/core': 2.11.8 - '@types/react': 18.2.31 + '@types/react': 18.2.33 clsx: 2.0.0 prop-types: 15.8.1 react: 18.2.0 react-dom: 18.2.0(react@18.2.0) dev: false - /@mui/core-downloads-tracker@5.14.14: - resolution: {integrity: sha512-Rw/xKiTOUgXD8hdKqj60aC6QcGprMipG7ne2giK6Mz7b4PlhL/xog9xLeclY3BxsRLkZQ05egFnIEY1CSibTbw==} + /@mui/core-downloads-tracker@5.14.15: + resolution: {integrity: sha512-ZCDzBWtCKjAYAlKKM3PA/jG/3uVIDT9ZitOtVixIVmTCQyc5jSV1qhJX8+qIGz4RQZ9KLzPWO2tXd0O5hvzouQ==} dev: false - /@mui/icons-material@5.14.14(@mui/material@5.14.14)(@types/react@18.2.31)(react@18.2.0): - resolution: {integrity: sha512-vwuaMsKvI7AWTeYqR8wYbpXijuU8PzMAJWRAq2DDIuOZPxjKyHlr8WQ25+azZYkIXtJ7AqnVb1ZmHdEyB4/kug==} + /@mui/icons-material@5.14.15(@mui/material@5.14.15)(@types/react@18.2.33)(react@18.2.0): + resolution: {integrity: sha512-Dqu21vN/mVNzebJ+ofnKG+CeJYIhHuDs5+0fMEpdpzRt6UojelzdrEkNv+XkO0e1JMclzeXIRx404FirK/CFRw==} engines: {node: '>=12.0.0'} peerDependencies: '@mui/material': ^5.0.0 @@ -9202,13 +9206,13 @@ packages: optional: true dependencies: '@babel/runtime': 7.23.2 - '@mui/material': 5.14.14(@emotion/react@11.11.1)(@emotion/styled@11.11.0)(@types/react@18.2.31)(react-dom@18.2.0)(react@18.2.0) - '@types/react': 18.2.31 + '@mui/material': 5.14.15(@emotion/react@11.11.1)(@emotion/styled@11.11.0)(@types/react@18.2.33)(react-dom@18.2.0)(react@18.2.0) + '@types/react': 18.2.33 react: 18.2.0 dev: false - /@mui/material@5.14.14(@emotion/react@11.11.1)(@emotion/styled@11.11.0)(@types/react@18.2.31)(react-dom@18.2.0)(react@18.2.0): - resolution: {integrity: sha512-cAmCwAHFQXxb44kWbVFkhKATN8tACgMsFwrXo8ro6WzYW73U/qsR5AcCiJIhCyYYg+gcftfkmNcpRaV3JjhHCg==} + /@mui/material@5.14.15(@emotion/react@11.11.1)(@emotion/styled@11.11.0)(@types/react@18.2.33)(react-dom@18.2.0)(react@18.2.0): + resolution: {integrity: sha512-Gq65rHjvLzkxmhG8bvag851Oqsmru7qkUb/cCI2xu7dQzmY345f9xJRJi72sRGjhaqHXWeRKw/yIwp/7oQoeXg==} engines: {node: '>=12.0.0'} peerDependencies: '@emotion/react': ^11.5.0 @@ -9225,14 +9229,14 @@ packages: optional: true dependencies: '@babel/runtime': 7.23.2 - '@emotion/react': 11.11.1(@types/react@18.2.31)(react@18.2.0) - '@emotion/styled': 11.11.0(@emotion/react@11.11.1)(@types/react@18.2.31)(react@18.2.0) - '@mui/base': 5.0.0-beta.20(@types/react@18.2.31)(react-dom@18.2.0)(react@18.2.0) - '@mui/core-downloads-tracker': 5.14.14 - '@mui/system': 5.14.14(@emotion/react@11.11.1)(@emotion/styled@11.11.0)(@types/react@18.2.31)(react@18.2.0) - '@mui/types': 7.2.6(@types/react@18.2.31) - '@mui/utils': 5.14.14(@types/react@18.2.31)(react@18.2.0) - '@types/react': 18.2.31 + '@emotion/react': 11.11.1(@types/react@18.2.33)(react@18.2.0) + '@emotion/styled': 11.11.0(@emotion/react@11.11.1)(@types/react@18.2.33)(react@18.2.0) + '@mui/base': 5.0.0-beta.21(@types/react@18.2.33)(react-dom@18.2.0)(react@18.2.0) + '@mui/core-downloads-tracker': 5.14.15 + '@mui/system': 5.14.15(@emotion/react@11.11.1)(@emotion/styled@11.11.0)(@types/react@18.2.33)(react@18.2.0) + '@mui/types': 7.2.7(@types/react@18.2.33) + '@mui/utils': 5.14.15(@types/react@18.2.33)(react@18.2.0) + '@types/react': 18.2.33 '@types/react-transition-group': 4.4.8 clsx: 2.0.0 csstype: 3.1.2 @@ -9243,8 +9247,8 @@ packages: react-transition-group: 4.4.5(react-dom@18.2.0)(react@18.2.0) dev: false - /@mui/private-theming@5.14.14(@types/react@18.2.31)(react@18.2.0): - resolution: {integrity: sha512-n77au3CQj9uu16hak2Y+rvbGSBaJKxziG/gEbOLVGrAuqZ+ycVSkorCfN6Y/4XgYOpG/xvmuiY3JwhAEOzY3iA==} + /@mui/private-theming@5.14.15(@types/react@18.2.33)(react@18.2.0): + resolution: {integrity: sha512-V2Xh+Tu6A07NoSpup0P9m29GwvNMYl5DegsGWqlOTJyAV7cuuVjmVPqxgvL8xBng4R85xqIQJRMjtYYktoPNuQ==} engines: {node: '>=12.0.0'} peerDependencies: '@types/react': ^17.0.0 || ^18.0.0 @@ -9254,14 +9258,14 @@ packages: optional: true dependencies: '@babel/runtime': 7.23.2 - '@mui/utils': 5.14.14(@types/react@18.2.31)(react@18.2.0) - '@types/react': 18.2.31 + '@mui/utils': 5.14.15(@types/react@18.2.33)(react@18.2.0) + '@types/react': 18.2.33 prop-types: 15.8.1 react: 18.2.0 dev: false - /@mui/styled-engine@5.14.14(@emotion/react@11.11.1)(@emotion/styled@11.11.0)(react@18.2.0): - resolution: {integrity: sha512-sF3DS2PVG+cFWvkVHQQaGFpL1h6gSwOW3L91pdxPLQDHDZ5mZ/X0SlXU5XA+WjypoysG4urdAQC7CH/BRvUiqg==} + /@mui/styled-engine@5.14.15(@emotion/react@11.11.1)(@emotion/styled@11.11.0)(react@18.2.0): + resolution: {integrity: sha512-mbOjRf867BysNpexe5Z/P8s3bWzDPNowmKhi7gtNDP/LPEeqAfiDSuC4WPTXmtvse1dCl30Nl755OLUYuoi7Mw==} engines: {node: '>=12.0.0'} peerDependencies: '@emotion/react': ^11.4.1 @@ -9275,15 +9279,15 @@ packages: dependencies: '@babel/runtime': 7.23.2 '@emotion/cache': 11.11.0 - '@emotion/react': 11.11.1(@types/react@18.2.31)(react@18.2.0) - '@emotion/styled': 11.11.0(@emotion/react@11.11.1)(@types/react@18.2.31)(react@18.2.0) + '@emotion/react': 11.11.1(@types/react@18.2.33)(react@18.2.0) + '@emotion/styled': 11.11.0(@emotion/react@11.11.1)(@types/react@18.2.33)(react@18.2.0) csstype: 3.1.2 prop-types: 15.8.1 react: 18.2.0 dev: false - /@mui/system@5.14.14(@emotion/react@11.11.1)(@emotion/styled@11.11.0)(@types/react@18.2.31)(react@18.2.0): - resolution: {integrity: sha512-y4InFmCgGGWXnz+iK4jRTWVikY0HgYnABjz4wgiUgEa2W1H8M4ow+27BegExUWPkj4TWthQ2qG9FOGSMtI+PKA==} + /@mui/system@5.14.15(@emotion/react@11.11.1)(@emotion/styled@11.11.0)(@types/react@18.2.33)(react@18.2.0): + resolution: {integrity: sha512-zr0Gdk1RgKiEk+tCMB900LaOpEC8NaGvxtkmMdL/CXgkqQZSVZOt2PQsxJWaw7kE4YVkIe4VukFVc43qcq9u3w==} engines: {node: '>=12.0.0'} peerDependencies: '@emotion/react': ^11.5.0 @@ -9299,32 +9303,32 @@ packages: optional: true dependencies: '@babel/runtime': 7.23.2 - '@emotion/react': 11.11.1(@types/react@18.2.31)(react@18.2.0) - '@emotion/styled': 11.11.0(@emotion/react@11.11.1)(@types/react@18.2.31)(react@18.2.0) - '@mui/private-theming': 5.14.14(@types/react@18.2.31)(react@18.2.0) - '@mui/styled-engine': 5.14.14(@emotion/react@11.11.1)(@emotion/styled@11.11.0)(react@18.2.0) - '@mui/types': 7.2.6(@types/react@18.2.31) - '@mui/utils': 5.14.14(@types/react@18.2.31)(react@18.2.0) - '@types/react': 18.2.31 + '@emotion/react': 11.11.1(@types/react@18.2.33)(react@18.2.0) + '@emotion/styled': 11.11.0(@emotion/react@11.11.1)(@types/react@18.2.33)(react@18.2.0) + '@mui/private-theming': 5.14.15(@types/react@18.2.33)(react@18.2.0) + '@mui/styled-engine': 5.14.15(@emotion/react@11.11.1)(@emotion/styled@11.11.0)(react@18.2.0) + '@mui/types': 7.2.7(@types/react@18.2.33) + '@mui/utils': 5.14.15(@types/react@18.2.33)(react@18.2.0) + '@types/react': 18.2.33 clsx: 2.0.0 csstype: 3.1.2 prop-types: 15.8.1 react: 18.2.0 dev: false - /@mui/types@7.2.6(@types/react@18.2.31): - resolution: {integrity: sha512-7sjLQrUmBwufm/M7jw/quNiPK/oor2+pGUQP2CULRcFCArYTq78oJ3D5esTaL0UMkXKJvDqXn6Ike69yAOBQng==} + /@mui/types@7.2.7(@types/react@18.2.33): + resolution: {integrity: sha512-sofpWmcBqOlTzRbr1cLQuUDKaUYVZTw8ENQrtL39TECRNENEzwgnNPh6WMfqMZlMvf1Aj9DLg74XPjnLr0izUQ==} peerDependencies: '@types/react': ^17.0.0 || ^18.0.0 peerDependenciesMeta: '@types/react': optional: true dependencies: - '@types/react': 18.2.31 + '@types/react': 18.2.33 dev: false - /@mui/utils@5.14.14(@types/react@18.2.31)(react@18.2.0): - resolution: {integrity: sha512-3AKp8uksje5sRfVrtgG9Q/2TBsHWVBUtA0NaXliZqGcXo8J+A+Agp0qUW2rJ+ivgPWTCCubz9FZVT2IQZ3bGsw==} + /@mui/utils@5.14.15(@types/react@18.2.33)(react@18.2.0): + resolution: {integrity: sha512-QBfHovAvTa0J1jXuYDaXGk+Yyp7+Fm8GSqx6nK2JbezGqzCFfirNdop/+bL9Flh/OQ/64PeXcW4HGDdOge+n3A==} engines: {node: '>=12.0.0'} peerDependencies: '@types/react': ^17.0.0 || ^18.0.0 @@ -9335,13 +9339,13 @@ packages: dependencies: '@babel/runtime': 7.23.2 '@types/prop-types': 15.7.9 - '@types/react': 18.2.31 + '@types/react': 18.2.33 prop-types: 15.8.1 react: 18.2.0 react-is: 18.2.0 dev: false - /@mui/x-date-pickers@5.0.20(@emotion/react@11.11.1)(@emotion/styled@11.11.0)(@mui/material@5.14.14)(@mui/system@5.14.14)(@types/react@18.2.31)(dayjs@1.11.10)(react-dom@18.2.0)(react@18.2.0): + /@mui/x-date-pickers@5.0.20(@emotion/react@11.11.1)(@emotion/styled@11.11.0)(@mui/material@5.14.15)(@mui/system@5.14.15)(@types/react@18.2.33)(dayjs@1.11.10)(react-dom@18.2.0)(react@18.2.0): resolution: {integrity: sha512-ERukSeHIoNLbI1C2XRhF9wRhqfsr+Q4B1SAw2ZlU7CWgcG8UBOxgqRKDEOVAIoSWL+DWT6GRuQjOKvj6UXZceA==} engines: {node: '>=12.0.0'} peerDependencies: @@ -9375,11 +9379,11 @@ packages: '@date-io/dayjs': 2.17.0(dayjs@1.11.10) '@date-io/luxon': 2.17.0 '@date-io/moment': 2.17.0 - '@emotion/react': 11.11.1(@types/react@18.2.31)(react@18.2.0) - '@emotion/styled': 11.11.0(@emotion/react@11.11.1)(@types/react@18.2.31)(react@18.2.0) - '@mui/material': 5.14.14(@emotion/react@11.11.1)(@emotion/styled@11.11.0)(@types/react@18.2.31)(react-dom@18.2.0)(react@18.2.0) - '@mui/system': 5.14.14(@emotion/react@11.11.1)(@emotion/styled@11.11.0)(@types/react@18.2.31)(react@18.2.0) - '@mui/utils': 5.14.14(@types/react@18.2.31)(react@18.2.0) + '@emotion/react': 11.11.1(@types/react@18.2.33)(react@18.2.0) + '@emotion/styled': 11.11.0(@emotion/react@11.11.1)(@types/react@18.2.33)(react@18.2.0) + '@mui/material': 5.14.15(@emotion/react@11.11.1)(@emotion/styled@11.11.0)(@types/react@18.2.33)(react-dom@18.2.0)(react@18.2.0) + '@mui/system': 5.14.15(@emotion/react@11.11.1)(@emotion/styled@11.11.0)(@types/react@18.2.33)(react@18.2.0) + '@mui/utils': 5.14.15(@types/react@18.2.33)(react@18.2.0) '@types/react-transition-group': 4.4.8 clsx: 1.2.1 dayjs: 1.11.10 @@ -9438,9 +9442,9 @@ packages: dependencies: '@chainsafe/is-ip': 2.0.2 '@chainsafe/netmask': 2.0.0 - '@libp2p/interface': 0.1.3 + '@libp2p/interface': 0.1.4 dns-over-http-resolver: 2.1.2 - multiformats: 12.1.2 + multiformats: 12.1.3 uint8-varint: 2.0.1 uint8arrays: 4.0.6 transitivePeerDependencies: @@ -9458,7 +9462,7 @@ packages: resolution: {integrity: sha512-Yf0UpAaONjed+8PTt5NM/GG4Z4Ai4m1qfT7bqevjnkwRQ12K+0jxtRomirz+VJx4PokpA2St1ZSD1iMkZTqPRQ==} engines: {node: '>=16.0.0', npm: '>=7.0.0'} dependencies: - multiformats: 12.1.2 + multiformats: 12.1.3 murmurhash3js-revisited: 3.0.0 dev: false @@ -9563,6 +9567,7 @@ packages: resolution: {integrity: sha512-2upgEu0iLiDVDZkNLeFV2+ht0BAVgQnEmCk6JsOch9Rp8xfkMCbvbAZlA2pBHQc73dbl+vFOXfqkf4uemdn0bw==} dependencies: '@noble/hashes': 1.3.0 + dev: true /@noble/curves@1.1.0: resolution: {integrity: sha512-091oBExgENk/kGj3AZmtBDMpxQPDtxQABR2B9lb1JbVTs6ytdzZNwvhxQ4MWasRNEzlbEH8jCWFCwhF/Obj5AA==} @@ -9574,7 +9579,6 @@ packages: resolution: {integrity: sha512-oYclrNgRaM9SsBUBVbb8M6DTV7ZHRTKugureoYEncY5c65HOmRzvSiTE3y5CYaPYJA/GVkrhXEoF0M3Ya9PMnw==} dependencies: '@noble/hashes': 1.3.2 - dev: false /@noble/ed25519@1.7.3: resolution: {integrity: sha512-iR8GBkDt0Q3GyaVcIu7mSsVIqnFbkbRzGLWlvhwunacoLwt4J3swfKhfaM6rN6WY+TBGoYT1GtT1mIh2/jGbRQ==} @@ -9585,6 +9589,7 @@ packages: /@noble/hashes@1.3.0: resolution: {integrity: sha512-ilHEACi9DwqJB0pw7kv+Apvh50jiiSyR/cQ3y4W7lOR5mhvn/50FLUfsnfJz0BDZtl/RR16kXvptiv6q1msYZg==} + dev: true /@noble/hashes@1.3.1: resolution: {integrity: sha512-EbqwksQwz9xDRGfDST86whPBgM65E0OH/pCgqW0GBVzO22bNE+NuIbeTb714+IfSjU3aRk47EUvXIb5bTsenKA==} @@ -9594,7 +9599,6 @@ packages: /@noble/hashes@1.3.2: resolution: {integrity: sha512-MVC8EAQp7MvEcm30KWENFjgR+Mkmf+D189XJTkFIlwohU5hcBbn1ZkKq7KVTi2Hme3PMGF390DaL52beVrIihQ==} engines: {node: '>= 16'} - dev: false /@noble/secp256k1@1.7.1: resolution: {integrity: sha512-hOUk6AyBFmqVrv7k5WAw/LpszxVbj9gGN4JRkIX52fdFAj1UA61KXmZDvqVEm+pOyec3+fIeZB02LYa/pWOArw==} @@ -9617,32 +9621,32 @@ packages: '@nodelib/fs.scandir': 2.1.5 fastq: 1.15.0 - /@nomicfoundation/ethereumjs-block@5.0.0: - resolution: {integrity: sha512-DfhVbqM5DjriguuSv6r3TgOpyXC76oX8D/VEODsSwJQ1bZGqu4xLLfYPPTacpCAYOnewzJsZli+Ao9TBTAo2uw==} + /@nomicfoundation/ethereumjs-block@5.0.2: + resolution: {integrity: sha512-hSe6CuHI4SsSiWWjHDIzWhSiAVpzMUcDRpWYzN0T9l8/Rz7xNn3elwVOJ/tAyS0LqL6vitUD78Uk7lQDXZun7Q==} engines: {node: '>=14'} dependencies: - '@nomicfoundation/ethereumjs-common': 4.0.0 - '@nomicfoundation/ethereumjs-rlp': 5.0.0 - '@nomicfoundation/ethereumjs-trie': 6.0.0 - '@nomicfoundation/ethereumjs-tx': 5.0.0 - '@nomicfoundation/ethereumjs-util': 9.0.0 + '@nomicfoundation/ethereumjs-common': 4.0.2 + '@nomicfoundation/ethereumjs-rlp': 5.0.2 + '@nomicfoundation/ethereumjs-trie': 6.0.2 + '@nomicfoundation/ethereumjs-tx': 5.0.2 + '@nomicfoundation/ethereumjs-util': 9.0.2 ethereum-cryptography: 0.1.3 ethers: 5.7.2 transitivePeerDependencies: - bufferutil - utf-8-validate - /@nomicfoundation/ethereumjs-blockchain@7.0.0: - resolution: {integrity: sha512-cVRCrXZminZr0Mbx2hm0/109GZLn1v5bf0/k+SIbGn50yZm6YCdQt9CgGT0Gk56N2vy8NhXD4apo167m4LWk6Q==} + /@nomicfoundation/ethereumjs-blockchain@7.0.2: + resolution: {integrity: sha512-8UUsSXJs+MFfIIAKdh3cG16iNmWzWC/91P40sazNvrqhhdR/RtGDlFk2iFTGbBAZPs2+klZVzhRX8m2wvuvz3w==} engines: {node: '>=14'} dependencies: - '@nomicfoundation/ethereumjs-block': 5.0.0 - '@nomicfoundation/ethereumjs-common': 4.0.0 - '@nomicfoundation/ethereumjs-ethash': 3.0.0 - '@nomicfoundation/ethereumjs-rlp': 5.0.0 - '@nomicfoundation/ethereumjs-trie': 6.0.0 - '@nomicfoundation/ethereumjs-tx': 5.0.0 - '@nomicfoundation/ethereumjs-util': 9.0.0 + '@nomicfoundation/ethereumjs-block': 5.0.2 + '@nomicfoundation/ethereumjs-common': 4.0.2 + '@nomicfoundation/ethereumjs-ethash': 3.0.2 + '@nomicfoundation/ethereumjs-rlp': 5.0.2 + '@nomicfoundation/ethereumjs-trie': 6.0.2 + '@nomicfoundation/ethereumjs-tx': 5.0.2 + '@nomicfoundation/ethereumjs-util': 9.0.2 abstract-level: 1.0.3 debug: 4.3.4(supports-color@8.1.1) ethereum-cryptography: 0.1.3 @@ -9654,19 +9658,19 @@ packages: - supports-color - utf-8-validate - /@nomicfoundation/ethereumjs-common@4.0.0: - resolution: {integrity: sha512-UPpm5FAGAf2B6hQ8aVgO44Rdo0k73oMMCViqNJcKMlk1s9l3rxwuPTp1l20NiGvNO2Pzqk3chFL+BzmLL2g4wQ==} + /@nomicfoundation/ethereumjs-common@4.0.2: + resolution: {integrity: sha512-I2WGP3HMGsOoycSdOTSqIaES0ughQTueOsddJ36aYVpI3SN8YSusgRFLwzDJwRFVIYDKx/iJz0sQ5kBHVgdDwg==} dependencies: - '@nomicfoundation/ethereumjs-util': 9.0.0 + '@nomicfoundation/ethereumjs-util': 9.0.2 crc-32: 1.2.2 - /@nomicfoundation/ethereumjs-ethash@3.0.0: - resolution: {integrity: sha512-6zNv5Y3vNIsxjrsbKjMInVpo8cmR0c7yjZbBpy7NYuIMtm0JKhQoXsiFN56t/1sfn9V3v0wgrkAixo5v6bahpA==} + /@nomicfoundation/ethereumjs-ethash@3.0.2: + resolution: {integrity: sha512-8PfoOQCcIcO9Pylq0Buijuq/O73tmMVURK0OqdjhwqcGHYC2PwhbajDh7GZ55ekB0Px197ajK3PQhpKoiI/UPg==} engines: {node: '>=14'} dependencies: - '@nomicfoundation/ethereumjs-block': 5.0.0 - '@nomicfoundation/ethereumjs-rlp': 5.0.0 - '@nomicfoundation/ethereumjs-util': 9.0.0 + '@nomicfoundation/ethereumjs-block': 5.0.2 + '@nomicfoundation/ethereumjs-rlp': 5.0.2 + '@nomicfoundation/ethereumjs-util': 9.0.2 abstract-level: 1.0.3 bigint-crypto-utils: 3.3.0 ethereum-cryptography: 0.1.3 @@ -9674,14 +9678,14 @@ packages: - bufferutil - utf-8-validate - /@nomicfoundation/ethereumjs-evm@2.0.0: - resolution: {integrity: sha512-D+tr3M9sictopr3E20OVgme7YF/d0fU566WKh+ofXwmxapz/Dd8RSLSaVeKgfCI2BkzVA+XqXY08NNCV8w8fWA==} + /@nomicfoundation/ethereumjs-evm@2.0.2: + resolution: {integrity: sha512-rBLcUaUfANJxyOx9HIdMX6uXGin6lANCulIm/pjMgRqfiCRMZie3WKYxTSd8ZE/d+qT+zTedBF4+VHTdTSePmQ==} engines: {node: '>=14'} dependencies: '@ethersproject/providers': 5.7.2 - '@nomicfoundation/ethereumjs-common': 4.0.0 - '@nomicfoundation/ethereumjs-tx': 5.0.0 - '@nomicfoundation/ethereumjs-util': 9.0.0 + '@nomicfoundation/ethereumjs-common': 4.0.2 + '@nomicfoundation/ethereumjs-tx': 5.0.2 + '@nomicfoundation/ethereumjs-util': 9.0.2 debug: 4.3.4(supports-color@8.1.1) ethereum-cryptography: 0.1.3 mcl-wasm: 0.7.9 @@ -9691,16 +9695,16 @@ packages: - supports-color - utf-8-validate - /@nomicfoundation/ethereumjs-rlp@5.0.0: - resolution: {integrity: sha512-U1A0y330PtGb8Wft4yPVv0myWYJTesi89ItGoB0ICdqz7793KmUhpfQb2vJUXBi98wSdnxkIABO/GmsQvGKVDw==} + /@nomicfoundation/ethereumjs-rlp@5.0.2: + resolution: {integrity: sha512-QwmemBc+MMsHJ1P1QvPl8R8p2aPvvVcKBbvHnQOKBpBztEo0omN0eaob6FeZS/e3y9NSe+mfu3nNFBHszqkjTA==} engines: {node: '>=14'} hasBin: true - /@nomicfoundation/ethereumjs-statemanager@2.0.0: - resolution: {integrity: sha512-tgXtsx8yIDlxWMN+ThqPtGK0ITAuITrDy+GYIgGrnT6ZtelvXWM7SUYR0Mcv578lmGCoIwyHFtSBqOkOBYHLjw==} + /@nomicfoundation/ethereumjs-statemanager@2.0.2: + resolution: {integrity: sha512-dlKy5dIXLuDubx8Z74sipciZnJTRSV/uHG48RSijhgm1V7eXYFC567xgKtsKiVZB1ViTP9iFL4B6Je0xD6X2OA==} dependencies: - '@nomicfoundation/ethereumjs-common': 4.0.0 - '@nomicfoundation/ethereumjs-rlp': 5.0.0 + '@nomicfoundation/ethereumjs-common': 4.0.2 + '@nomicfoundation/ethereumjs-rlp': 5.0.2 debug: 4.3.4(supports-color@8.1.1) ethereum-cryptography: 0.1.3 ethers: 5.7.2 @@ -9710,51 +9714,51 @@ packages: - supports-color - utf-8-validate - /@nomicfoundation/ethereumjs-trie@6.0.0: - resolution: {integrity: sha512-YqPWiNxrZvL+Ef7KHqgru1IlaIGXhu78wd2fxNFOvi/NAQBF845dVfTKKXs1L9x0QBRRQRephgxHCKMuISGppw==} + /@nomicfoundation/ethereumjs-trie@6.0.2: + resolution: {integrity: sha512-yw8vg9hBeLYk4YNg5MrSJ5H55TLOv2FSWUTROtDtTMMmDGROsAu+0tBjiNGTnKRi400M6cEzoFfa89Fc5k8NTQ==} engines: {node: '>=14'} dependencies: - '@nomicfoundation/ethereumjs-rlp': 5.0.0 - '@nomicfoundation/ethereumjs-util': 9.0.0 + '@nomicfoundation/ethereumjs-rlp': 5.0.2 + '@nomicfoundation/ethereumjs-util': 9.0.2 '@types/readable-stream': 2.3.15 ethereum-cryptography: 0.1.3 readable-stream: 3.6.2 - /@nomicfoundation/ethereumjs-tx@5.0.0: - resolution: {integrity: sha512-LTyxI+zBJ+HuEBblUGbxvfKl1hg1uJlz2XhnszNagiBWQSgLb1vQCa1QaXV5Q8cUDYkr/Xe4NXWiUGEvH4e6lA==} + /@nomicfoundation/ethereumjs-tx@5.0.2: + resolution: {integrity: sha512-T+l4/MmTp7VhJeNloMkM+lPU3YMUaXdcXgTGCf8+ZFvV9NYZTRLFekRwlG6/JMmVfIfbrW+dRRJ9A6H5Q/Z64g==} engines: {node: '>=14'} dependencies: '@chainsafe/ssz': 0.9.4 '@ethersproject/providers': 5.7.2 - '@nomicfoundation/ethereumjs-common': 4.0.0 - '@nomicfoundation/ethereumjs-rlp': 5.0.0 - '@nomicfoundation/ethereumjs-util': 9.0.0 + '@nomicfoundation/ethereumjs-common': 4.0.2 + '@nomicfoundation/ethereumjs-rlp': 5.0.2 + '@nomicfoundation/ethereumjs-util': 9.0.2 ethereum-cryptography: 0.1.3 transitivePeerDependencies: - bufferutil - utf-8-validate - /@nomicfoundation/ethereumjs-util@9.0.0: - resolution: {integrity: sha512-9EG98CsEC9BnI7AY27F4QXZ8Vf0re8R9XoxQ0//KWF+B7quu6GQvgTq1RlNUjGh/XNCCJNf8E3LOY9ULR85wFQ==} + /@nomicfoundation/ethereumjs-util@9.0.2: + resolution: {integrity: sha512-4Wu9D3LykbSBWZo8nJCnzVIYGvGCuyiYLIJa9XXNVt1q1jUzHdB+sJvx95VGCpPkCT+IbLecW6yfzy3E1bQrwQ==} engines: {node: '>=14'} dependencies: '@chainsafe/ssz': 0.10.2 - '@nomicfoundation/ethereumjs-rlp': 5.0.0 + '@nomicfoundation/ethereumjs-rlp': 5.0.2 ethereum-cryptography: 0.1.3 - /@nomicfoundation/ethereumjs-vm@7.0.0: - resolution: {integrity: sha512-eHkEoe/4r4+g+fZyIIlQjBHEjCPFs8CHiIEEMvMfvFrV4hyHnuTg4LH7l92ok7TGZqpWxgMG2JOEUFkNsXrKuQ==} + /@nomicfoundation/ethereumjs-vm@7.0.2: + resolution: {integrity: sha512-Bj3KZT64j54Tcwr7Qm/0jkeZXJMfdcAtRBedou+Hx0dPOSIgqaIr0vvLwP65TpHbak2DmAq+KJbW2KNtIoFwvA==} engines: {node: '>=14'} dependencies: - '@nomicfoundation/ethereumjs-block': 5.0.0 - '@nomicfoundation/ethereumjs-blockchain': 7.0.0 - '@nomicfoundation/ethereumjs-common': 4.0.0 - '@nomicfoundation/ethereumjs-evm': 2.0.0 - '@nomicfoundation/ethereumjs-rlp': 5.0.0 - '@nomicfoundation/ethereumjs-statemanager': 2.0.0 - '@nomicfoundation/ethereumjs-trie': 6.0.0 - '@nomicfoundation/ethereumjs-tx': 5.0.0 - '@nomicfoundation/ethereumjs-util': 9.0.0 + '@nomicfoundation/ethereumjs-block': 5.0.2 + '@nomicfoundation/ethereumjs-blockchain': 7.0.2 + '@nomicfoundation/ethereumjs-common': 4.0.2 + '@nomicfoundation/ethereumjs-evm': 2.0.2 + '@nomicfoundation/ethereumjs-rlp': 5.0.2 + '@nomicfoundation/ethereumjs-statemanager': 2.0.2 + '@nomicfoundation/ethereumjs-trie': 6.0.2 + '@nomicfoundation/ethereumjs-tx': 5.0.2 + '@nomicfoundation/ethereumjs-util': 9.0.2 debug: 4.3.4(supports-color@8.1.1) ethereum-cryptography: 0.1.3 mcl-wasm: 0.7.9 @@ -9764,78 +9768,106 @@ packages: - supports-color - utf-8-validate - /@nomicfoundation/hardhat-chai-matchers@1.0.6(@nomiclabs/hardhat-ethers@2.2.3)(chai@4.3.10)(ethers@5.7.2)(hardhat@2.13.1): - resolution: {integrity: sha512-f5ZMNmabZeZegEfuxn/0kW+mm7+yV7VNDxLpMOMGXWFJ2l/Ct3QShujzDRF9cOkK9Ui/hbDeOWGZqyQALDXVCQ==} + /@nomicfoundation/hardhat-chai-matchers@2.0.2(@nomicfoundation/hardhat-ethers@3.0.4)(chai@4.3.10)(ethers@6.8.0)(hardhat@2.18.3): + resolution: {integrity: sha512-9Wu9mRtkj0U9ohgXYFbB/RQDa+PcEdyBm2suyEtsJf3PqzZEEjLUZgWnMjlFhATMk/fp3BjmnYVPrwl+gr8oEw==} peerDependencies: - '@nomiclabs/hardhat-ethers': ^2.0.0 + '@nomicfoundation/hardhat-ethers': ^3.0.0 chai: ^4.2.0 - ethers: ^5.7.2 + ethers: ^6.1.0 hardhat: ^2.9.4 dependencies: - '@ethersproject/abi': 5.7.0 - '@nomiclabs/hardhat-ethers': 2.2.3(ethers@5.7.2)(hardhat@2.13.1) + '@nomicfoundation/hardhat-ethers': 3.0.4(ethers@6.8.0)(hardhat@2.18.3) '@types/chai-as-promised': 7.1.7 chai: 4.3.10 chai-as-promised: 7.1.1(chai@4.3.10) deep-eql: 4.1.3 - ethers: 5.7.2 - hardhat: 2.13.1(ts-node@10.9.1)(typescript@4.9.5) + ethers: 6.8.0 + hardhat: 2.18.3(ts-node@10.9.1)(typescript@4.9.5) ordinal: 1.0.3 dev: true - /@nomicfoundation/hardhat-network-helpers@1.0.9(hardhat@2.13.1): + /@nomicfoundation/hardhat-ethers@3.0.4(ethers@6.8.0)(hardhat@2.18.3): + resolution: {integrity: sha512-k9qbLoY7qn6C6Y1LI0gk2kyHXil2Tauj4kGzQ8pgxYXIGw8lWn8tuuL72E11CrlKaXRUvOgF0EXrv/msPI2SbA==} + peerDependencies: + ethers: ^6.1.0 + hardhat: ^2.0.0 + dependencies: + debug: 4.3.4(supports-color@8.1.1) + ethers: 6.8.0 + hardhat: 2.18.3(ts-node@10.9.1)(typescript@4.9.5) + lodash.isequal: 4.5.0 + transitivePeerDependencies: + - supports-color + dev: true + + /@nomicfoundation/hardhat-network-helpers@1.0.9(hardhat@2.18.3): resolution: {integrity: sha512-OXWCv0cHpwLUO2u7bFxBna6dQtCC2Gg/aN/KtJLO7gmuuA28vgmVKYFRCDUqrbjujzgfwQ2aKyZ9Y3vSmDqS7Q==} peerDependencies: hardhat: ^2.9.5 dependencies: ethereumjs-util: 7.1.5 - hardhat: 2.13.1(ts-node@10.9.1)(typescript@4.9.5) + hardhat: 2.18.3(ts-node@10.9.1)(typescript@4.9.5) dev: true - /@nomicfoundation/hardhat-toolbox@2.0.2(@ethersproject/abi@5.7.0)(@ethersproject/providers@5.7.2)(@nomicfoundation/hardhat-chai-matchers@1.0.6)(@nomicfoundation/hardhat-network-helpers@1.0.9)(@nomiclabs/hardhat-ethers@2.2.3)(@nomiclabs/hardhat-etherscan@3.1.7)(@typechain/ethers-v5@11.1.2)(@typechain/hardhat@9.1.0)(@types/chai@4.3.9)(@types/mocha@9.1.0)(@types/node@18.18.6)(chai@4.3.10)(ethers@5.7.2)(hardhat-gas-reporter@1.0.9)(hardhat@2.13.1)(solidity-coverage@0.8.5)(ts-node@10.9.1)(typechain@8.3.2)(typescript@4.9.5): - resolution: {integrity: sha512-vnN1AzxbvpSx9pfdRHbUzTRIXpMLPXnUlkW855VaDk6N1pwRaQ2gNzEmFAABk4lWf11E00PKwFd/q27HuwYrYg==} + /@nomicfoundation/hardhat-toolbox@3.0.0(@nomicfoundation/hardhat-chai-matchers@2.0.2)(@nomicfoundation/hardhat-ethers@3.0.4)(@nomicfoundation/hardhat-network-helpers@1.0.9)(@nomicfoundation/hardhat-verify@1.1.1)(@typechain/ethers-v6@0.4.3)(@typechain/hardhat@8.0.3)(@types/chai@4.3.9)(@types/mocha@9.1.0)(@types/node@18.18.7)(chai@4.3.10)(ethers@6.8.0)(hardhat-gas-reporter@1.0.9)(hardhat@2.18.3)(solidity-coverage@0.8.5)(ts-node@10.9.1)(typechain@8.3.2)(typescript@4.9.5): + resolution: {integrity: sha512-MsteDXd0UagMksqm9KvcFG6gNKYNa3GGNCy73iQ6bEasEgg2v8Qjl6XA5hjs8o5UD5A3153B6W2BIVJ8SxYUtA==} peerDependencies: - '@ethersproject/abi': ^5.4.7 - '@ethersproject/providers': ^5.4.7 - '@nomicfoundation/hardhat-chai-matchers': ^1.0.0 + '@nomicfoundation/hardhat-chai-matchers': ^2.0.0 + '@nomicfoundation/hardhat-ethers': ^3.0.0 '@nomicfoundation/hardhat-network-helpers': ^1.0.0 - '@nomiclabs/hardhat-ethers': ^2.0.0 - '@nomiclabs/hardhat-etherscan': ^3.0.0 - '@typechain/ethers-v5': ^10.1.0 - '@typechain/hardhat': ^6.1.2 + '@nomicfoundation/hardhat-verify': ^1.0.0 + '@typechain/ethers-v6': ^0.4.0 + '@typechain/hardhat': ^8.0.0 '@types/chai': ^4.2.0 '@types/mocha': '>=9.1.0' '@types/node': '>=12.0.0' chai: ^4.2.0 - ethers: ^5.7.2 + ethers: ^6.4.0 hardhat: ^2.11.0 hardhat-gas-reporter: ^1.0.8 solidity-coverage: ^0.8.1 ts-node: '>=8.0.0' - typechain: ^8.1.0 + typechain: ^8.2.0 typescript: '>=4.5.0' dependencies: - '@ethersproject/abi': 5.7.0 - '@ethersproject/providers': 5.7.2 - '@nomicfoundation/hardhat-chai-matchers': 1.0.6(@nomiclabs/hardhat-ethers@2.2.3)(chai@4.3.10)(ethers@5.7.2)(hardhat@2.13.1) - '@nomicfoundation/hardhat-network-helpers': 1.0.9(hardhat@2.13.1) - '@nomiclabs/hardhat-ethers': 2.2.3(ethers@5.7.2)(hardhat@2.13.1) - '@nomiclabs/hardhat-etherscan': 3.1.7(hardhat@2.13.1) - '@typechain/ethers-v5': 11.1.2(@ethersproject/abi@5.7.0)(@ethersproject/providers@5.7.2)(ethers@5.7.2)(typechain@8.3.2)(typescript@4.9.5) - '@typechain/hardhat': 9.1.0(@typechain/ethers-v6@0.5.1)(ethers@5.7.2)(hardhat@2.13.1)(typechain@8.3.2) + '@nomicfoundation/hardhat-chai-matchers': 2.0.2(@nomicfoundation/hardhat-ethers@3.0.4)(chai@4.3.10)(ethers@6.8.0)(hardhat@2.18.3) + '@nomicfoundation/hardhat-ethers': 3.0.4(ethers@6.8.0)(hardhat@2.18.3) + '@nomicfoundation/hardhat-network-helpers': 1.0.9(hardhat@2.18.3) + '@nomicfoundation/hardhat-verify': 1.1.1(hardhat@2.18.3) + '@typechain/ethers-v6': 0.4.3(ethers@6.8.0)(typechain@8.3.2)(typescript@4.9.5) + '@typechain/hardhat': 8.0.3(@typechain/ethers-v6@0.4.3)(ethers@6.8.0)(hardhat@2.18.3)(typechain@8.3.2) '@types/chai': 4.3.9 '@types/mocha': 9.1.0 - '@types/node': 18.18.6 + '@types/node': 18.18.7 chai: 4.3.10 - ethers: 5.7.2 - hardhat: 2.13.1(ts-node@10.9.1)(typescript@4.9.5) - hardhat-gas-reporter: 1.0.9(hardhat@2.13.1) - solidity-coverage: 0.8.5(hardhat@2.13.1) - ts-node: 10.9.1(@types/node@18.18.6)(typescript@4.9.5) + ethers: 6.8.0 + hardhat: 2.18.3(ts-node@10.9.1)(typescript@4.9.5) + hardhat-gas-reporter: 1.0.9(hardhat@2.18.3) + solidity-coverage: 0.8.5(hardhat@2.18.3) + ts-node: 10.9.1(@types/node@18.18.7)(typescript@4.9.5) typechain: 8.3.2(typescript@4.9.5) typescript: 4.9.5 dev: true + /@nomicfoundation/hardhat-verify@1.1.1(hardhat@2.18.3): + resolution: {integrity: sha512-9QsTYD7pcZaQFEA3tBb/D/oCStYDiEVDN7Dxeo/4SCyHRSm86APypxxdOMEPlGmXsAvd+p1j/dTODcpxb8aztA==} + peerDependencies: + hardhat: ^2.0.4 + dependencies: + '@ethersproject/abi': 5.7.0 + '@ethersproject/address': 5.7.0 + cbor: 8.1.0 + chalk: 2.4.2 + debug: 4.3.4(supports-color@8.1.1) + hardhat: 2.18.3(ts-node@10.9.1)(typescript@4.9.5) + lodash.clonedeep: 4.5.0 + semver: 6.3.1 + table: 6.8.1 + undici: 5.26.5 + transitivePeerDependencies: + - supports-color + dev: true + /@nomicfoundation/solidity-analyzer-darwin-arm64@0.1.1: resolution: {integrity: sha512-KcTodaQw8ivDZyF+D76FokN/HdpgGpfjc/gFCImdLUyqB6eSWVaZPazMbeAjmfhx3R0zm/NYVzxwAokFKgrc0w==} engines: {node: '>= 10'} @@ -9931,36 +9963,6 @@ packages: '@nomicfoundation/solidity-analyzer-win32-ia32-msvc': 0.1.1 '@nomicfoundation/solidity-analyzer-win32-x64-msvc': 0.1.1 - /@nomiclabs/hardhat-ethers@2.2.3(ethers@5.7.2)(hardhat@2.13.1): - resolution: {integrity: sha512-YhzPdzb612X591FOe68q+qXVXGG2ANZRvDo0RRUtimev85rCrAlv/TLMEZw5c+kq9AbzocLTVX/h2jVIFPL9Xg==} - peerDependencies: - ethers: ^5.7.2 - hardhat: ^2.0.0 - dependencies: - ethers: 5.7.2 - hardhat: 2.13.1(ts-node@10.9.1)(typescript@4.9.5) - dev: true - - /@nomiclabs/hardhat-etherscan@3.1.7(hardhat@2.13.1): - resolution: {integrity: sha512-tZ3TvSgpvsQ6B6OGmo1/Au6u8BrAkvs1mIC/eURA3xgIfznUZBhmpne8hv7BXUzw9xNL3fXdpOYgOQlVMTcoHQ==} - peerDependencies: - hardhat: ^2.0.4 - dependencies: - '@ethersproject/abi': 5.7.0 - '@ethersproject/address': 5.7.0 - cbor: 8.1.0 - chalk: 2.4.2 - debug: 4.3.4(supports-color@8.1.1) - fs-extra: 7.0.1 - hardhat: 2.13.1(ts-node@10.9.1)(typescript@4.9.5) - lodash: 4.17.21 - semver: 6.3.1 - table: 6.8.1 - undici: 5.26.5 - transitivePeerDependencies: - - supports-color - dev: true - /@observablehq/inspector@5.0.0: resolution: {integrity: sha512-Vvg/TQdsZTUaeYbH0IKxYEz37FbRO6kdowoz2PrHLQif54NC1CjEihEjg+ZMSBn587GQxTFABu0CGkFZgtR1UQ==} dependencies: @@ -9983,7 +9985,7 @@ packages: d3-require: 1.3.0 dev: false - /@oclif/core@2.15.0(@types/node@18.18.6)(typescript@4.9.5): + /@oclif/core@2.15.0(@types/node@18.18.7)(typescript@4.9.5): resolution: {integrity: sha512-fNEMG5DzJHhYmI3MgpByTvltBOMyFcnRIUMxbiz2ai8rhaYgaTHMG3Q38HcosfIvtw9nCjxpcQtC8MN8QtVCcA==} engines: {node: '>=14.0.0'} dependencies: @@ -10010,7 +10012,7 @@ packages: strip-ansi: 6.0.1 supports-color: 8.1.1 supports-hyperlinks: 2.3.0 - ts-node: 10.9.1(@types/node@18.18.6)(typescript@4.9.5) + ts-node: 10.9.1(@types/node@18.18.7)(typescript@4.9.5) tslib: 2.6.2 widest-line: 3.1.0 wordwrap: 1.0.0 @@ -10022,7 +10024,7 @@ packages: - typescript dev: true - /@oclif/core@2.8.6(@types/node@18.18.6)(typescript@4.9.5): + /@oclif/core@2.8.6(@types/node@18.18.7)(typescript@4.9.5): resolution: {integrity: sha512-1QlPaHMhOORySCXkQyzjsIsy2GYTilOw3LkjeHkCgsPJQjAT4IclVytJusWktPbYNys9O+O4V23J44yomQvnBQ==} engines: {node: '>=14.0.0'} dependencies: @@ -10050,7 +10052,7 @@ packages: strip-ansi: 6.0.1 supports-color: 8.1.1 supports-hyperlinks: 2.3.0 - ts-node: 10.9.1(@types/node@18.18.6)(typescript@4.9.5) + ts-node: 10.9.1(@types/node@18.18.7)(typescript@4.9.5) tslib: 2.6.2 widest-line: 3.1.0 wordwrap: 1.0.0 @@ -10062,11 +10064,11 @@ packages: - typescript dev: true - /@oclif/plugin-autocomplete@2.3.10(@types/node@18.18.6)(typescript@4.9.5): + /@oclif/plugin-autocomplete@2.3.10(@types/node@18.18.7)(typescript@4.9.5): resolution: {integrity: sha512-Ow1AR8WtjzlyCtiWWPgzMyT8SbcDJFr47009riLioHa+MHX2BCDtVn2DVnN/E6b9JlPV5ptQpjefoRSNWBesmg==} engines: {node: '>=12.0.0'} dependencies: - '@oclif/core': 2.15.0(@types/node@18.18.6)(typescript@4.9.5) + '@oclif/core': 2.15.0(@types/node@18.18.7)(typescript@4.9.5) chalk: 4.1.2 debug: 4.3.4(supports-color@8.1.1) transitivePeerDependencies: @@ -10077,11 +10079,11 @@ packages: - typescript dev: true - /@oclif/plugin-not-found@2.4.3(@types/node@18.18.6)(typescript@4.9.5): + /@oclif/plugin-not-found@2.4.3(@types/node@18.18.7)(typescript@4.9.5): resolution: {integrity: sha512-nIyaR4y692frwh7wIHZ3fb+2L6XEecQwRDIb4zbEam0TvaVmBQWZoColQyWA84ljFBPZ8XWiQyTz+ixSwdRkqg==} engines: {node: '>=12.0.0'} dependencies: - '@oclif/core': 2.15.0(@types/node@18.18.6)(typescript@4.9.5) + '@oclif/core': 2.15.0(@types/node@18.18.7)(typescript@4.9.5) chalk: 4.1.2 fast-levenshtein: 3.0.0 transitivePeerDependencies: @@ -10091,14 +10093,26 @@ packages: - typescript dev: true - /@open-draft/until@1.0.3: - resolution: {integrity: sha512-Aq58f5HiWdyDlFffbbSjAlv596h/cOnt2DO1w3DOC7OJ5EHs0hd/nycJfiu9RJbT6Yk6F1knnRRXNSpxoIVZ9Q==} + /@openzeppelin/contracts-upgradeable@4.7.3: + resolution: {integrity: sha512-+wuegAMaLcZnLCJIvrVUDzA9z/Wp93f0Dla/4jJvIhijRrPabjQbZe6fWiECLaJyfn5ci9fqf9vTw3xpQOad2A==} + dev: true + + /@openzeppelin/contracts@3.4.2: + resolution: {integrity: sha512-z0zMCjyhhp4y7XKAcDAi3Vgms4T2PstwBdahiO0+9NaGICQKjynK3wduSRplTgk4LXmoO1yfDGO5RbjKYxtuxA==} + dev: true + + /@openzeppelin/contracts@4.3.3: + resolution: {integrity: sha512-tDBopO1c98Yk7Cv/PZlHqrvtVjlgK5R4J6jxLwoO7qxK4xqOiZG+zSkIvGFpPZ0ikc3QOED3plgdqjgNTnBc7g==} + dev: true + + /@openzeppelin/contracts@4.9.3: + resolution: {integrity: sha512-He3LieZ1pP2TNt5JbkPA4PNT9WC3gOTOlDcFGJW4Le4QKqwmiNJCRt44APfxMxvq7OugU/cqYuPcSBzOw38DAg==} dev: true - /@openzeppelin/defender-admin-client@1.49.0: - resolution: {integrity: sha512-ka+GTbsnGO6j1R2AGj027uu29es/EBVs3VjJStb+7u/1lNhx1xSRS11JBD0a0GNhrwqsKU4czIemlIKMlUzhhQ==} + /@openzeppelin/defender-admin-client@1.50.0(debug@4.3.4): + resolution: {integrity: sha512-JxeA111ifCIzXho2gFymhepufB0ElI1UMvFIMEfJLvRL7g7V69wSiN8v+OqZyqZTahiY32Rb+TwdhVjKF5Zu+A==} dependencies: - '@openzeppelin/defender-base-client': 1.49.0(debug@4.3.4) + '@openzeppelin/defender-base-client': 1.50.0(debug@4.3.4) axios: 1.5.1(debug@4.3.4) ethers: 5.7.2 lodash: 4.17.21 @@ -10110,11 +10124,11 @@ packages: - utf-8-validate dev: true - /@openzeppelin/defender-autotask-client@1.49.0: - resolution: {integrity: sha512-FhqFB/E0jaDNEgx0WklodpRS2RPfE181+kwtGL23a8uzGiyQRs7+Ia/a8ARGaLEqD9gWwAte6ODiqZAaim7/jg==} + /@openzeppelin/defender-autotask-client@1.50.0: + resolution: {integrity: sha512-QWob3F6xuOu8r8oPy0Y2XLfAL1PTuKE2F4nC4wGeu3JJT8/pJz3xnHX5DgUYwiGIMqnkitUNUoBcmi4CPI31yw==} hasBin: true dependencies: - '@openzeppelin/defender-base-client': 1.49.0(debug@4.3.4) + '@openzeppelin/defender-base-client': 1.50.0(debug@4.3.4) axios: 1.5.1(debug@4.3.4) dotenv: 10.0.0 glob: 7.2.3 @@ -10126,8 +10140,8 @@ packages: - encoding dev: false - /@openzeppelin/defender-autotask-utils@1.49.0: - resolution: {integrity: sha512-rJls6HOuddBsPJwbSmIN/nugdIsgdrwzgpVJC/hxv+amu0HsSkrH26LbcoDig7Eb2dp68Avtmo0EOyAUP1bNGA==} + /@openzeppelin/defender-autotask-utils@1.50.0: + resolution: {integrity: sha512-wuhm5idjsIiC7hdLj+z5ewDmyKx5q0tRXKHp05K9X8uo1CyLdHV2kKZjBrWzGE9qxVhJ79f9PzHZrLcyPHNDOg==} dev: false /@openzeppelin/defender-base-client@1.49.0(debug@4.3.4): @@ -10142,66 +10156,83 @@ packages: - debug - encoding - /@openzeppelin/defender-sentinel-client@1.49.0: - resolution: {integrity: sha512-fr39U1GRWvJP1fWgwqjTYCz7uhfVfXJReWcivwxMeaoyMl+jYFxj8NkMhqkkbmI6O4TUyNMsmAQ34qFf0IS0/A==} + /@openzeppelin/defender-base-client@1.50.0(debug@4.3.4): + resolution: {integrity: sha512-V5uJ4t3kr9ex1RrqGH2DwsHuyW7/hl3VK0sSkq3VVbAewtcsW3cdg/UkXd5ITu6mtz76RoYkvUBHtkYUm0nb+w==} dependencies: - '@ethersproject/abi': 5.7.0 - '@openzeppelin/defender-base-client': 1.49.0(debug@4.3.4) + amazon-cognito-identity-js: 6.3.6 + async-retry: 1.3.3 axios: 1.5.1(debug@4.3.4) lodash: 4.17.21 node-fetch: 2.7.0 transitivePeerDependencies: - debug - encoding - dev: false - /@openzeppelin/hardhat-defender@1.9.0(@nomiclabs/hardhat-ethers@2.2.3)(@nomiclabs/hardhat-etherscan@3.1.7)(ethers@5.7.2)(hardhat@2.13.1): - resolution: {integrity: sha512-dl2pQyBvwEZVq1sgw/i+mLQiu4ZD7iKn2/ghD9RbAGHIM8hZQ4ou8cXl1S6wCA92prpeO1rPGQ+NcJajbY4MCw==} - deprecated: '@openzeppelin/hardhat-defender is deprecated. This functionality is now included as part of @openzeppelin/hardhat-upgrades' + /@openzeppelin/defender-sdk-base-client@1.3.0: + resolution: {integrity: sha512-OMMt7NaAL8C95ralF9nMeKZpg96COLZT9FPpGpPsI7aB8fVZfCM8+6k99gTF44hMS6IsRdN2WthS3m7VzQeeoA==} dependencies: - '@openzeppelin/defender-admin-client': 1.49.0 - '@openzeppelin/defender-base-client': 1.49.0(debug@4.3.4) - '@openzeppelin/hardhat-upgrades': 1.28.0(@nomiclabs/hardhat-ethers@2.2.3)(@nomiclabs/hardhat-etherscan@3.1.7)(ethers@5.7.2)(hardhat@2.13.1) - ethereumjs-util: 7.1.5 + amazon-cognito-identity-js: 6.3.6 + async-retry: 1.3.3 + transitivePeerDependencies: + - encoding + dev: true + + /@openzeppelin/defender-sdk-deploy-client@1.3.0(debug@4.3.4): + resolution: {integrity: sha512-RTYM3HnVvD2d5NoYfTug8UwT41e0Jjwb13lk9v0Jl8z7mcclUVvAnKD4DHJ4b8RhKpg4B15oLQK/Igzjg1HHRA==} + dependencies: + '@ethersproject/abi': 5.7.0 + '@openzeppelin/defender-sdk-base-client': 1.3.0 + axios: 1.5.1(debug@4.3.4) + lodash: 4.17.21 transitivePeerDependencies: - - '@nomiclabs/hardhat-ethers' - - '@nomiclabs/hardhat-etherscan' - - '@nomiclabs/harhdat-etherscan' - - bufferutil - debug - encoding - - ethers - - hardhat - - supports-color - - utf-8-validate dev: true - /@openzeppelin/hardhat-upgrades@1.28.0(@nomiclabs/hardhat-ethers@2.2.3)(@nomiclabs/hardhat-etherscan@3.1.7)(ethers@5.7.2)(hardhat@2.13.1): - resolution: {integrity: sha512-7sb/Jf+X+uIufOBnmHR0FJVWuxEs2lpxjJnLNN6eCJCP8nD0v+Ot5lTOW2Qb/GFnh+fLvJtEkhkowz4ZQ57+zQ==} + /@openzeppelin/defender-sentinel-client@1.49.0: + resolution: {integrity: sha512-fr39U1GRWvJP1fWgwqjTYCz7uhfVfXJReWcivwxMeaoyMl+jYFxj8NkMhqkkbmI6O4TUyNMsmAQ34qFf0IS0/A==} + dependencies: + '@ethersproject/abi': 5.7.0 + '@openzeppelin/defender-base-client': 1.49.0(debug@4.3.4) + axios: 1.5.1(debug@4.3.4) + lodash: 4.17.21 + node-fetch: 2.7.0 + transitivePeerDependencies: + - debug + - encoding + dev: false + + /@openzeppelin/hardhat-upgrades@2.3.3(@nomicfoundation/hardhat-ethers@3.0.4)(@nomicfoundation/hardhat-verify@1.1.1)(ethers@6.8.0)(hardhat@2.18.3): + resolution: {integrity: sha512-rF87xYSz6Q2WFq5zcUF1T1tx3Kiq83hmke0xOBn5Qgrl++osseiDwS5oXfDK3NSWvj06oYGLERRGHcXnpQ31FQ==} hasBin: true peerDependencies: - '@nomiclabs/hardhat-ethers': ^2.0.0 - '@nomiclabs/hardhat-etherscan': ^3.1.0 - '@nomiclabs/harhdat-etherscan': '*' - ethers: ^5.7.2 + '@nomicfoundation/hardhat-ethers': ^3.0.0 + '@nomicfoundation/hardhat-verify': ^1.1.0 + ethers: ^6.6.0 hardhat: ^2.0.2 peerDependenciesMeta: - '@nomiclabs/harhdat-etherscan': + '@nomicfoundation/hardhat-verify': optional: true dependencies: - '@nomiclabs/hardhat-ethers': 2.2.3(ethers@5.7.2)(hardhat@2.13.1) - '@nomiclabs/hardhat-etherscan': 3.1.7(hardhat@2.13.1) + '@nomicfoundation/hardhat-ethers': 3.0.4(ethers@6.8.0)(hardhat@2.18.3) + '@nomicfoundation/hardhat-verify': 1.1.1(hardhat@2.18.3) + '@openzeppelin/defender-admin-client': 1.50.0(debug@4.3.4) '@openzeppelin/defender-base-client': 1.49.0(debug@4.3.4) - '@openzeppelin/platform-deploy-client': 0.8.0(debug@4.3.4) + '@openzeppelin/defender-sdk-base-client': 1.3.0 + '@openzeppelin/defender-sdk-deploy-client': 1.3.0(debug@4.3.4) '@openzeppelin/upgrades-core': 1.31.0 chalk: 4.1.2 debug: 4.3.4(supports-color@8.1.1) - ethers: 5.7.2 - hardhat: 2.13.1(ts-node@10.9.1)(typescript@4.9.5) + ethereumjs-util: 7.1.5 + ethers: 6.8.0 + hardhat: 2.18.3(ts-node@10.9.1)(typescript@4.9.5) proper-lockfile: 4.1.2 + undici: 5.26.5 transitivePeerDependencies: + - bufferutil - encoding - supports-color + - utf-8-validate dev: true /@openzeppelin/merkle-tree@1.0.5: @@ -10211,20 +10242,6 @@ packages: ethereum-cryptography: 1.2.0 dev: false - /@openzeppelin/platform-deploy-client@0.8.0(debug@4.3.4): - resolution: {integrity: sha512-POx3AsnKwKSV/ZLOU/gheksj0Lq7Is1q2F3pKmcFjGZiibf+4kjGxr4eSMrT+2qgKYZQH1ZLQZ+SkbguD8fTvA==} - deprecated: '@openzeppelin/platform-deploy-client is deprecated. Please use @openzeppelin/defender-sdk-deploy-client' - dependencies: - '@ethersproject/abi': 5.7.0 - '@openzeppelin/defender-base-client': 1.49.0(debug@4.3.4) - axios: 0.21.4(debug@4.3.4) - lodash: 4.17.21 - node-fetch: 2.7.0 - transitivePeerDependencies: - - debug - - encoding - dev: true - /@openzeppelin/upgrades-core@1.31.0: resolution: {integrity: sha512-E1Cz8lVpo2mnBeFWxiGDLWtuTYMFNTEWwbnhle4dZ+5UHX6xTRO+Q/CaWBHm33HHhuuiUbRwgGNnAR9zOu+fyQ==} hasBin: true @@ -10426,13 +10443,13 @@ packages: resolution: {integrity: sha512-P1st0aksCrn9sGZhp8GMYwBnQsbvAWsZAX44oXNNvLHGqAOcoVxmjZiohstwQ7SqKnbR47akdNi+uleWD8+g6A==} dev: false - /@primitivefi/hardhat-dodoc@0.2.3(hardhat@2.13.1)(squirrelly@8.0.8): + /@primitivefi/hardhat-dodoc@0.2.3(hardhat@2.18.3)(squirrelly@8.0.8): resolution: {integrity: sha512-ver9uHa79LTDTeebOKZ/eOVRL/FP1k0s0x/5Bo/8ZaDdLWFVClKqZyZYVjjW4CJqTPCt8uU9b9p71P2vzH4O9A==} peerDependencies: hardhat: ^2.6.4 squirrelly: ^8.0.8 dependencies: - hardhat: 2.13.1(ts-node@10.9.1)(typescript@4.9.5) + hardhat: 2.18.3(ts-node@10.9.1)(typescript@4.9.5) squirrelly: 8.0.8 dev: true @@ -10469,25 +10486,27 @@ packages: /@protobufjs/utf8@1.1.0: resolution: {integrity: sha512-Vvn3zZrhQZkkBE8LSuW3em98c0FwgO4nxzv6OdSxPKJIEKY2bGbHn+mhGIPerzI4twdxaP8/0+06HBpwf345Lw==} - /@rainbow-me/rainbowkit@1.0.8(@types/react@18.2.31)(react-dom@18.2.0)(react@18.2.0)(viem@1.5.3)(wagmi@1.3.9): - resolution: {integrity: sha512-m1B9/X3p8MLmj4fDfs2NpJlFRmKz7vOR0jmcdBw2SMFzXqP1FQFQc4pjvtLEeyfEUGSNNceGrecFZRVS0Qk//A==} + /@rainbow-me/rainbowkit@1.2.0(@types/react@18.2.33)(react-dom@18.2.0)(react@18.2.0)(viem@1.18.4)(wagmi@1.4.5): + resolution: {integrity: sha512-XjdeX31GwFdRR/1rCRqPXiO94nbq2qOlnaox5P4K/KMRIUwyelKzak27uWw8Krmor/Hcrd5FisfepGDS0tUfEA==} engines: {node: '>=12.4'} peerDependencies: react: '>=17' react-dom: '>=17' viem: ~0.3.19 || ^1.0.0 - wagmi: ~1.0.1 || ~1.1.0 || ~1.2.0 || ~1.3.0 + wagmi: ~1.0.1 || ~1.1.0 || ~1.2.0 || ~1.3.0 || ~1.4.0 dependencies: '@vanilla-extract/css': 1.9.1 '@vanilla-extract/dynamic': 2.0.2 '@vanilla-extract/sprinkles': 1.5.0(@vanilla-extract/css@1.9.1) clsx: 1.1.1 + i18n-js: 4.3.2 qrcode: 1.5.0 react: 18.2.0 react-dom: 18.2.0(react@18.2.0) - react-remove-scroll: 2.5.4(@types/react@18.2.31)(react@18.2.0) - viem: 1.5.3(typescript@5.1.6)(zod@3.22.4) - wagmi: 1.3.9(@types/react@18.2.31)(react-dom@18.2.0)(react-native@0.72.6)(react@18.2.0)(typescript@5.1.6)(viem@1.5.3)(zod@3.22.4) + react-remove-scroll: 2.5.4(@types/react@18.2.33)(react@18.2.0) + ua-parser-js: 1.0.36 + viem: 1.18.4(typescript@5.1.6)(zod@3.22.4) + wagmi: 1.4.5(@types/react@18.2.33)(react-dom@18.2.0)(react-native@0.72.6)(react@18.2.0)(typescript@5.1.6)(viem@1.18.4)(zod@3.22.4) transitivePeerDependencies: - '@types/react' dev: false @@ -11026,7 +11045,7 @@ packages: resolution: {integrity: sha512-gYw0ki/EAuV1oSyMxpqandHjnthZjYYy+YWpTAzf8BqfXM3ItcZLpjxfg+3+mXW8HIO+3jw6T9iiqEXsqHaMMw==} dependencies: '@safe-global/safe-gateway-typescript-sdk': 3.12.0 - viem: 1.5.3(typescript@5.1.6)(zod@3.22.4) + viem: 1.18.4(typescript@5.1.6)(zod@3.22.4) transitivePeerDependencies: - bufferutil - typescript @@ -11038,7 +11057,7 @@ packages: resolution: {integrity: sha512-XJbEPuaVc7b9n23MqlF6c+ToYIS3f7P2Sel8f3cSBQ9WORE4xrSuvhMpK9fDSFqJ7by/brc+rmJR/5HViRr0/w==} dependencies: '@safe-global/safe-gateway-typescript-sdk': 3.12.0 - viem: 1.5.3(typescript@5.1.6)(zod@3.22.4) + viem: 1.18.4(typescript@5.1.6)(zod@3.22.4) transitivePeerDependencies: - bufferutil - typescript @@ -11065,17 +11084,26 @@ packages: resolution: {integrity: sha512-bcKpo1oj54hGholplGLpqPHRbIsnbixFtc06nwuNM5/dwSXOq/AAYoIBRsBmnZJSdfeNW5rnff7NTAz3ZCqR9Q==} dependencies: '@noble/curves': 1.0.0 - '@noble/hashes': 1.3.0 + '@noble/hashes': 1.3.2 '@scure/base': 1.1.3 + dev: true /@scure/bip32@1.3.1: resolution: {integrity: sha512-osvveYtyzdEVbt3OfwwXFr4P2iVBL5u1Q3q4ONBfDY/UpOuXmOlbgwc1xECEboY8wIays8Yt6onaWMUdUbfl0A==} dependencies: '@noble/curves': 1.1.0 - '@noble/hashes': 1.3.1 + '@noble/hashes': 1.3.2 '@scure/base': 1.1.3 dev: true + /@scure/bip32@1.3.2: + resolution: {integrity: sha512-N1ZhksgwD3OBlwTv3R6KFEcPojl/W4ElJOeCZdi+vuI5QmTFwLq3OFf2zd2ROpKvxFdgZ6hUpb0dx9bVNEwYCA==} + dependencies: + '@noble/curves': 1.2.0 + '@noble/hashes': 1.3.2 + '@scure/base': 1.1.3 + dev: false + /@scure/bip39@1.1.1: resolution: {integrity: sha512-t+wDck2rVkh65Hmv280fYdVdY25J9YeEUIgn2LG1WM6gxFkGzcksoDiUkWVpVp3Oex9xGC68JU2dSbUfwZ2jPg==} dependencies: @@ -11085,36 +11113,34 @@ packages: /@scure/bip39@1.2.0: resolution: {integrity: sha512-SX/uKq52cuxm4YFXWFaVByaSHJh2w3BnokVSeUJVCv6K7WulT9u2BuNRBhuFl8vAuYnzx9bEu9WgpcNYTrYieg==} dependencies: - '@noble/hashes': 1.3.0 + '@noble/hashes': 1.3.2 '@scure/base': 1.1.3 + dev: true /@scure/bip39@1.2.1: resolution: {integrity: sha512-Z3/Fsz1yr904dduJD0NpiyRHhRYHdcnyh73FZWiV+/qhWi83wNJ3NWolYqCEN+ZWsUz2TWwajJggcRE9r1zUYg==} dependencies: - '@noble/hashes': 1.3.1 + '@noble/hashes': 1.3.2 '@scure/base': 1.1.3 - dev: true - /@sentry-internal/tracing@7.74.1: - resolution: {integrity: sha512-nNaiZreQxCitG2PzYPaC7XtyA9OMsETGYMKAtiK4p62/uTmeYbsBva9BoNx1XeiHRwbrVQYRMKQ9nV5e2jS4/A==} + /@sentry-internal/tracing@7.75.1: + resolution: {integrity: sha512-nynV+7iVcF8k3CqhvI2K7iA8h4ovJhgYHKnXR8RDDevQOqNG2AEX9+hjCj9fZM4MhKHYFqf1od2oO9lTr38kwg==} engines: {node: '>=8'} dependencies: - '@sentry/core': 7.74.1 - '@sentry/types': 7.74.1 - '@sentry/utils': 7.74.1 - tslib: 2.6.2 + '@sentry/core': 7.75.1 + '@sentry/types': 7.75.1 + '@sentry/utils': 7.75.1 dev: false - /@sentry/browser@7.74.1: - resolution: {integrity: sha512-OYWNne/KO60lOvkIpIlJUyiJt/9j8DGI57thSDFEYSmmbNqMitczUTBOaEStouvHKyfchqLZm1CZfWKt+z0VOA==} + /@sentry/browser@7.75.1: + resolution: {integrity: sha512-0+jPfPA5P9HVYYRQraDokGCY2NiMknSfz11dggClK4VmjvG+hOXiEyf73SFVwLFnv/hwrkWySjoIrVCX65xXQA==} engines: {node: '>=8'} dependencies: - '@sentry-internal/tracing': 7.74.1 - '@sentry/core': 7.74.1 - '@sentry/replay': 7.74.1 - '@sentry/types': 7.74.1 - '@sentry/utils': 7.74.1 - tslib: 2.6.2 + '@sentry-internal/tracing': 7.75.1 + '@sentry/core': 7.75.1 + '@sentry/replay': 7.75.1 + '@sentry/types': 7.75.1 + '@sentry/utils': 7.75.1 dev: false /@sentry/cli@1.75.2: @@ -11160,13 +11186,12 @@ packages: '@sentry/utils': 5.30.0 tslib: 1.14.1 - /@sentry/core@7.74.1: - resolution: {integrity: sha512-LvEhOSfdIvwkr+PdlrT/aA/iOLhkXrSkvjqAQyogE4ddCWeYfS0NoirxNt1EaxMBAWKhYZRqzkA7WA4LDLbzlA==} + /@sentry/core@7.75.1: + resolution: {integrity: sha512-Kw4KyKBxbxbh8OKO0S11Tm0gWP+6AaXXYrsq3hp8H338l/wOmIzyckmCbUrc/XJeoRqaFLJbdcCrcUEDZUvsVQ==} engines: {node: '>=8'} dependencies: - '@sentry/types': 7.74.1 - '@sentry/utils': 7.74.1 - tslib: 2.6.2 + '@sentry/types': 7.75.1 + '@sentry/utils': 7.75.1 dev: false /@sentry/hub@5.30.0: @@ -11177,15 +11202,14 @@ packages: '@sentry/utils': 5.30.0 tslib: 1.14.1 - /@sentry/integrations@7.74.1: - resolution: {integrity: sha512-Q7chPehHpHB4WOQ1J/X6NiN2ptiqJMmxtL+6wHumzIAyrjup3c9XekR83qEs8zpqYJAlb/4MUlwd9fPbkhGXnQ==} + /@sentry/integrations@7.75.1: + resolution: {integrity: sha512-qSCyTNX3DiL1aYRmdq10LRhPLfh1KJYKhbmGszC1PII4mt9FbLVmC8fSXiDbhgiuSUKKrDE+J2lC//w688lvHw==} engines: {node: '>=8'} dependencies: - '@sentry/core': 7.74.1 - '@sentry/types': 7.74.1 - '@sentry/utils': 7.74.1 + '@sentry/core': 7.75.1 + '@sentry/types': 7.75.1 + '@sentry/utils': 7.75.1 localforage: 1.10.0 - tslib: 2.6.2 dev: false /@sentry/minimal@5.30.0: @@ -11196,8 +11220,8 @@ packages: '@sentry/types': 5.30.0 tslib: 1.14.1 - /@sentry/nextjs@7.74.1(next@13.5.6)(react@18.2.0)(webpack@5.89.0): - resolution: {integrity: sha512-1RySEs3WBEqlpQCAFQ/XwV+oW4wEAtpYglvAyDBwPen/s6KnkkZ0za0l3Ug0O6S9HvMiNll1rPhvnkH5nM37Tg==} + /@sentry/nextjs@7.75.1(next@13.5.6)(react@18.2.0)(webpack@5.89.0): + resolution: {integrity: sha512-5DEW6Ksjuox8idf3O0NclF/rHSS0Z1VCIoFHW6d28FHFKU+/RkFwJTB13KfpQMBj1fiA9qSNJdy/2QlGUWVRmA==} engines: {node: '>=8'} peerDependencies: next: ^10.0.8 || ^11.0 || ^12.0 || ^13.0 @@ -11208,13 +11232,13 @@ packages: optional: true dependencies: '@rollup/plugin-commonjs': 24.0.0(rollup@2.78.0) - '@sentry/core': 7.74.1 - '@sentry/integrations': 7.74.1 - '@sentry/node': 7.74.1 - '@sentry/react': 7.74.1(react@18.2.0) - '@sentry/types': 7.74.1 - '@sentry/utils': 7.74.1 - '@sentry/vercel-edge': 7.74.1 + '@sentry/core': 7.75.1 + '@sentry/integrations': 7.75.1 + '@sentry/node': 7.75.1 + '@sentry/react': 7.75.1(react@18.2.0) + '@sentry/types': 7.75.1 + '@sentry/utils': 7.75.1 + '@sentry/vercel-edge': 7.75.1 '@sentry/webpack-plugin': 1.20.0 chalk: 3.0.0 next: 13.5.6(@babel/core@7.23.2)(react-dom@18.2.0)(react@18.2.0) @@ -11222,7 +11246,6 @@ packages: resolve: 1.22.8 rollup: 2.78.0 stacktrace-parser: 0.1.10 - tslib: 2.6.2 webpack: 5.89.0(webpack-cli@5.1.4) transitivePeerDependencies: - encoding @@ -11245,43 +11268,40 @@ packages: transitivePeerDependencies: - supports-color - /@sentry/node@7.74.1: - resolution: {integrity: sha512-aMUQ2LFZF64FBr+cgjAqjT4OkpYBIC9lyWI8QqjEHqNho5+LGu18/iVrJPD4fgs4UhGdCuAiQjpC36MbmnIDZA==} + /@sentry/node@7.75.1: + resolution: {integrity: sha512-E174NbP3j7OIqQQYPtpMGz1FfL/KE5PeGnhoACyMIk0D5MGB7Ia7Y9+nYfHB7+EOJPV2Ob6BYlhemX/MxPrYWg==} engines: {node: '>=8'} dependencies: - '@sentry-internal/tracing': 7.74.1 - '@sentry/core': 7.74.1 - '@sentry/types': 7.74.1 - '@sentry/utils': 7.74.1 - cookie: 0.5.0 + '@sentry-internal/tracing': 7.75.1 + '@sentry/core': 7.75.1 + '@sentry/types': 7.75.1 + '@sentry/utils': 7.75.1 https-proxy-agent: 5.0.1 - lru_map: 0.3.3 - tslib: 2.6.2 transitivePeerDependencies: - supports-color dev: false - /@sentry/react@7.74.1(react@18.2.0): - resolution: {integrity: sha512-16oTsNi2hl/S5AL/e5bo9DQZDwXPkX0nC8ajrpU0z2pH4cwjQZUZt/9Xq1+MKqDIEZkqDcMwpTmBptOvy1Pvkw==} + /@sentry/react@7.75.1(react@18.2.0): + resolution: {integrity: sha512-5zFcIor8vwQa13VRwk7yDE8U7uspj0eKpsjOcYcfSvDkiL7LW0sA6rXxvO3jwd1AKaB3EAfr1F4oIdEz8aRIkA==} engines: {node: '>=8'} peerDependencies: react: 15.x || 16.x || 17.x || 18.x dependencies: - '@sentry/browser': 7.74.1 - '@sentry/types': 7.74.1 - '@sentry/utils': 7.74.1 + '@sentry/browser': 7.75.1 + '@sentry/types': 7.75.1 + '@sentry/utils': 7.75.1 hoist-non-react-statics: 3.3.2 react: 18.2.0 - tslib: 2.6.2 dev: false - /@sentry/replay@7.74.1: - resolution: {integrity: sha512-qmbOl+jYdyhoHFbPp9WemKx8UojID5hVmuVLxNIP0ANqAwmE9OQEK9YFg2cf7L/TpKb1tqz0qLgi5MYIdcdpgQ==} + /@sentry/replay@7.75.1: + resolution: {integrity: sha512-MKQTDWNYs9QXCJ+irGX5gu8Kxdk/Ds5puhILy8+DnCoXgXuPFRMGob1Sxt8qXmbQmcGeogsx221MNTselsRS6g==} engines: {node: '>=12'} dependencies: - '@sentry/core': 7.74.1 - '@sentry/types': 7.74.1 - '@sentry/utils': 7.74.1 + '@sentry-internal/tracing': 7.75.1 + '@sentry/core': 7.75.1 + '@sentry/types': 7.75.1 + '@sentry/utils': 7.75.1 dev: false /@sentry/tracing@5.30.0: @@ -11298,8 +11318,8 @@ packages: resolution: {integrity: sha512-R8xOqlSTZ+htqrfteCWU5Nk0CDN5ApUTvrlvBuiH1DyP6czDZ4ktbZB0hAgBlVcK0U+qpD3ag3Tqqpa5Q67rPw==} engines: {node: '>=6'} - /@sentry/types@7.74.1: - resolution: {integrity: sha512-2jIuPc+YKvXqZETwr2E8VYnsH1zsSUR/wkIvg1uTVeVNyoowJv+YsOtCdeGyL2AwiotUBSPKu7O1Lz0kq5rMOQ==} + /@sentry/types@7.75.1: + resolution: {integrity: sha512-km+ygqgMDaFfTrbQwdhrptFqx0Oq15jZABqIoIpbaOCkCAMm+tyCqrFS8dTfaq5wpCktqWOy2qU/DOpppO99Cg==} engines: {node: '>=8'} dev: false @@ -11310,22 +11330,20 @@ packages: '@sentry/types': 5.30.0 tslib: 1.14.1 - /@sentry/utils@7.74.1: - resolution: {integrity: sha512-qUsqufuHYcy5gFhLZslLxA5kcEOkkODITXW3c7D+x+8iP/AJqa8v8CeUCVNS7RetHCuIeWAbbTClC4c411EwQg==} + /@sentry/utils@7.75.1: + resolution: {integrity: sha512-QzW2eRjY20epD//9/tQ0FTNwdAL6XZi+LyJNUQIeK3NMnc5NgHrgpxId87gmFq8cNx47utH1Blub8RuMbKqiwQ==} engines: {node: '>=8'} dependencies: - '@sentry/types': 7.74.1 - tslib: 2.6.2 + '@sentry/types': 7.75.1 dev: false - /@sentry/vercel-edge@7.74.1: - resolution: {integrity: sha512-E2lTfEtDFSh57EkjVe4EcgcdjOM8UvfZVsmANBqG4bnwRKrNX9GouClzKU2Ckd5vQnOiCH9r8x2aJ/dTqyBswQ==} + /@sentry/vercel-edge@7.75.1: + resolution: {integrity: sha512-TCiObqegXdWkObf0YUDTvAPgGS5rOpRtZKQmjJ03ZahwrSMZTWESvlKo1V/5JhgfZSRWJTvDnJAtomteopT5/A==} engines: {node: '>=8'} dependencies: - '@sentry/core': 7.74.1 - '@sentry/types': 7.74.1 - '@sentry/utils': 7.74.1 - tslib: 2.6.2 + '@sentry/core': 7.75.1 + '@sentry/types': 7.75.1 + '@sentry/utils': 7.75.1 dev: false /@sentry/webpack-plugin@1.20.0: @@ -11594,8 +11612,8 @@ packages: '@supabase/node-fetch': 2.6.14 dev: false - /@supabase/realtime-js@2.8.1: - resolution: {integrity: sha512-bka5U4OeoKMdorGMPjdF30cl8n8nbhn+I9H4iySKzbN45W6AGxi7xoODnxdq/QwaDGtVyTMVbU+GVWre0QCdtw==} + /@supabase/realtime-js@2.8.4: + resolution: {integrity: sha512-5C9slLTGikHnYmAnIBOaPogAgbcNY68vnIyE6GpqIKjHElVb6LIi4clwNcjHSj4z6szuvvzj8T/+ePEgGEGekw==} dependencies: '@supabase/node-fetch': 2.6.14 '@types/phoenix': 1.6.3 @@ -11611,14 +11629,14 @@ packages: '@supabase/node-fetch': 2.6.14 dev: false - /@supabase/supabase-js@2.38.2: - resolution: {integrity: sha512-yOCi94oO5WVUBhQ890BvtT7J3p8spP47PMhn22YldIcDLEQWE6N6X2JzfWCLHktXw+oCYUJfQBuqYhyLHAKb0w==} + /@supabase/supabase-js@2.38.3: + resolution: {integrity: sha512-qIQxXZJN42iM41VChBo3kmGNyRhM0LOk27fkTX8A4tHnWxt0zmxMGFKVCX7Qnrz8zttiJkcym/BZreM/F9k0FQ==} dependencies: '@supabase/functions-js': 2.1.5 '@supabase/gotrue-js': 2.57.0 '@supabase/node-fetch': 2.6.14 '@supabase/postgrest-js': 1.8.5 - '@supabase/realtime-js': 2.8.1 + '@supabase/realtime-js': 2.8.4 '@supabase/storage-js': 2.5.4 transitivePeerDependencies: - supports-color @@ -11788,7 +11806,7 @@ packages: engines: {node: '>=14'} hasBin: true dependencies: - '@cypress/code-coverage': 3.12.5(@babel/core@7.23.2)(@babel/preset-env@7.23.2)(babel-loader@9.1.3)(cypress@12.17.4)(webpack@5.89.0) + '@cypress/code-coverage': 3.12.6(@babel/core@7.23.2)(@babel/preset-env@7.23.2)(babel-loader@9.1.3)(cypress@12.17.4)(webpack@5.89.0) '@cypress/webpack-dev-server': 3.6.1(debug@4.3.4)(webpack@5.89.0) '@drptbl/gremlins.js': 2.2.1 '@foundry-rs/easy-foundryup': 0.1.3 @@ -11812,7 +11830,7 @@ packages: dotenv: 16.3.1 dotenv-parse-variables: 2.0.0 download: 8.0.0 - ethers: 5.7.2 + ethers: 6.8.0 etherscan-api: 10.3.0(debug@4.3.4) find-config: 1.0.0 get-port: 6.1.2 @@ -12015,7 +12033,7 @@ packages: '@babel/parser': 7.18.9 '@babel/traverse': 7.17.3 '@babel/types': 7.17.0 - '@vue/compiler-sfc': 3.3.6 + '@vue/compiler-sfc': 3.3.7 javascript-natural-sort: 0.7.1 lodash: 4.17.21 prettier: 2.8.8 @@ -12061,29 +12079,12 @@ packages: /@tsconfig/node16@1.0.4: resolution: {integrity: sha512-vxhUy4J8lyeyinH7Azl1pdd43GJhZH/tP2weN8TntQblOY+A0XbT8DJk1/oCPuOOyg/Ja757rG0CgHcWC8OfMA==} - /@typechain/ethers-v5@10.2.1(@ethersproject/abi@5.7.0)(@ethersproject/providers@5.7.2)(ethers@5.7.2)(typechain@8.3.2)(typescript@4.9.5): - resolution: {integrity: sha512-n3tQmCZjRE6IU4h6lqUGiQ1j866n5MTCBJreNEHHVWXa2u9GJTaeYyU1/k+1qLutkyw+sS6VAN+AbeiTqsxd/A==} - peerDependencies: - '@ethersproject/abi': ^5.0.0 - '@ethersproject/providers': ^5.0.0 - ethers: ^5.7.2 - typechain: ^8.1.1 - typescript: '>=4.3.0' - dependencies: - '@ethersproject/abi': 5.7.0 - '@ethersproject/providers': 5.7.2 - ethers: 5.7.2 - lodash: 4.17.21 - ts-essentials: 7.0.3(typescript@4.9.5) - typechain: 8.3.2(typescript@4.9.5) - typescript: 4.9.5 - /@typechain/ethers-v5@10.2.1(@ethersproject/abi@5.7.0)(@ethersproject/providers@5.7.2)(ethers@5.7.2)(typechain@8.3.2)(typescript@5.1.6): resolution: {integrity: sha512-n3tQmCZjRE6IU4h6lqUGiQ1j866n5MTCBJreNEHHVWXa2u9GJTaeYyU1/k+1qLutkyw+sS6VAN+AbeiTqsxd/A==} peerDependencies: '@ethersproject/abi': ^5.0.0 '@ethersproject/providers': ^5.0.0 - ethers: ^5.7.2 + ethers: ^5.1.3 typechain: ^8.1.1 typescript: '>=4.3.0' dependencies: @@ -12094,71 +12095,34 @@ packages: ts-essentials: 7.0.3(typescript@5.1.6) typechain: 8.3.2(typescript@5.1.6) typescript: 5.1.6 - dev: false - - /@typechain/ethers-v5@11.1.2(@ethersproject/abi@5.7.0)(@ethersproject/providers@5.7.2)(ethers@5.7.2)(typechain@8.3.2)(typescript@4.9.5): - resolution: {integrity: sha512-ID6pqWkao54EuUQa0P5RgjvfA3MYqxUQKpbGKERbsjBW5Ra7EIXvbMlPp2pcP5IAdUkyMCFYsP2SN5q7mPdLDQ==} - peerDependencies: - '@ethersproject/abi': ^5.0.0 - '@ethersproject/providers': ^5.0.0 - ethers: ^5.7.2 - typechain: ^8.3.2 - typescript: '>=4.3.0' - dependencies: - '@ethersproject/abi': 5.7.0 - '@ethersproject/providers': 5.7.2 - ethers: 5.7.2 - lodash: 4.17.21 - ts-essentials: 7.0.3(typescript@4.9.5) - typechain: 8.3.2(typescript@4.9.5) - typescript: 4.9.5 dev: true - /@typechain/ethers-v6@0.5.1(ethers@5.7.2)(typechain@8.3.2)(typescript@4.9.5): - resolution: {integrity: sha512-F+GklO8jBWlsaVV+9oHaPh5NJdd6rAKN4tklGfInX1Q7h0xPgVLP39Jl3eCulPB5qexI71ZFHwbljx4ZXNfouA==} + /@typechain/ethers-v6@0.4.3(ethers@6.8.0)(typechain@8.3.2)(typescript@4.9.5): + resolution: {integrity: sha512-TrxBsyb4ryhaY9keP6RzhFCviWYApcLCIRMPyWaKp2cZZrfaM3QBoxXTnw/eO4+DAY3l+8O0brNW0WgeQeOiDA==} peerDependencies: - ethers: ^5.7.2 - typechain: ^8.3.2 + ethers: 6.x + typechain: ^8.3.1 typescript: '>=4.7.0' dependencies: - ethers: 5.7.2 + ethers: 6.8.0 lodash: 4.17.21 ts-essentials: 7.0.3(typescript@4.9.5) typechain: 8.3.2(typescript@4.9.5) typescript: 4.9.5 dev: true - /@typechain/hardhat@6.1.6(@ethersproject/abi@5.7.0)(@ethersproject/providers@5.7.2)(@typechain/ethers-v5@10.2.1)(ethers@5.7.2)(hardhat@2.13.1)(typechain@8.3.2): - resolution: {integrity: sha512-BiVnegSs+ZHVymyidtK472syodx1sXYlYJJixZfRstHVGYTi8V1O7QG4nsjyb0PC/LORcq7sfBUcHto1y6UgJA==} + /@typechain/hardhat@8.0.3(@typechain/ethers-v6@0.4.3)(ethers@6.8.0)(hardhat@2.18.3)(typechain@8.3.2): + resolution: {integrity: sha512-MytSmJJn+gs7Mqrpt/gWkTCOpOQ6ZDfRrRT2gtZL0rfGe4QrU4x9ZdW15fFbVM/XTa+5EsKiOMYXhRABibNeng==} peerDependencies: - '@ethersproject/abi': ^5.4.7 - '@ethersproject/providers': ^5.4.7 - '@typechain/ethers-v5': ^10.2.1 - ethers: ^5.7.2 + '@typechain/ethers-v6': ^0.4.3 + ethers: ^6.1.0 hardhat: ^2.9.9 - typechain: ^8.1.1 + typechain: ^8.3.1 dependencies: - '@ethersproject/abi': 5.7.0 - '@ethersproject/providers': 5.7.2 - '@typechain/ethers-v5': 10.2.1(@ethersproject/abi@5.7.0)(@ethersproject/providers@5.7.2)(ethers@5.7.2)(typechain@8.3.2)(typescript@4.9.5) - ethers: 5.7.2 + '@typechain/ethers-v6': 0.4.3(ethers@6.8.0)(typechain@8.3.2)(typescript@4.9.5) + ethers: 6.8.0 fs-extra: 9.1.0 - hardhat: 2.13.1(ts-node@10.9.1)(typescript@4.9.5) - typechain: 8.3.2(typescript@4.9.5) - dev: false - - /@typechain/hardhat@9.1.0(@typechain/ethers-v6@0.5.1)(ethers@5.7.2)(hardhat@2.13.1)(typechain@8.3.2): - resolution: {integrity: sha512-mtaUlzLlkqTlfPwB3FORdejqBskSnh+Jl8AIJGjXNAQfRQ4ofHADPl1+oU7Z3pAJzmZbUXII8MhOLQltcHgKnA==} - peerDependencies: - '@typechain/ethers-v6': ^0.5.1 - ethers: ^5.7.2 - hardhat: ^2.9.9 - typechain: ^8.3.2 - dependencies: - '@typechain/ethers-v6': 0.5.1(ethers@5.7.2)(typechain@8.3.2)(typescript@4.9.5) - ethers: 5.7.2 - fs-extra: 9.1.0 - hardhat: 2.13.1(ts-node@10.9.1)(typescript@4.9.5) + hardhat: 2.18.3(ts-node@10.9.1)(typescript@4.9.5) typechain: 8.3.2(typescript@4.9.5) dev: true @@ -12182,49 +12146,53 @@ packages: '@types/babel__generator': 7.6.6 '@types/babel__template': 7.4.3 '@types/babel__traverse': 7.20.3 + dev: true /@types/babel__generator@7.6.6: resolution: {integrity: sha512-66BXMKb/sUWbMdBNdMvajU7i/44RkrA3z/Yt1c7R5xejt8qh84iU54yUWCtm0QwGJlDcf/gg4zd/x4mpLAlb/w==} dependencies: '@babel/types': 7.23.0 + dev: true /@types/babel__template@7.4.3: resolution: {integrity: sha512-ciwyCLeuRfxboZ4isgdNZi/tkt06m8Tw6uGbBSBgWrnnZGNXiEyM27xc/PjXGQLqlZ6ylbgHMnm7ccF9tCkOeQ==} dependencies: '@babel/parser': 7.23.0 '@babel/types': 7.23.0 + dev: true /@types/babel__traverse@7.20.3: resolution: {integrity: sha512-Lsh766rGEFbaxMIDH7Qa+Yha8cMVI3qAK6CHt3OR0YfxOIn5Z54iHiyDRycHrBqeIiqGa20Kpsv1cavfBKkRSw==} dependencies: '@babel/types': 7.23.0 + dev: true /@types/better-sqlite3@7.6.6: resolution: {integrity: sha512-nuFAptzt0hZYBvyLzKQCbuCCK+RN9PHH4ezar5EJLIg2qpVhwQ/uLvLO/K8A9O7N8DafawgFupiyXQSs0U48Ng==} dependencies: - '@types/node': 18.18.6 + '@types/node': 18.18.7 dev: true /@types/bn.js@4.11.6: resolution: {integrity: sha512-pqr857jrp2kPuO9uRjZ3PwnJTjoQy+fcdxvBTvHm6dkmEL9q+hDD/2j/0ELOBPtPnS8LjCX0gI9nbl8lVkadpg==} dependencies: - '@types/node': 18.18.6 + '@types/node': 18.18.7 /@types/bn.js@5.1.3: resolution: {integrity: sha512-wT1B4iIO82ecXkdN6waCK8Ou7E71WU+mP1osDA5Q8c6Ur+ozU2vIKUIhSpUr6uE5L2YHocKS1Z2jG2fBC1YVeg==} dependencies: - '@types/node': 18.18.6 + '@types/node': 18.18.7 /@types/body-parser@1.19.4: resolution: {integrity: sha512-N7UDG0/xiPQa2D/XrVJXjkWbpqHCd2sBaB32ggRF2l83RhPfamgKGF8gwwqyksS95qUS5ZYF9aF+lLPRlwI2UA==} dependencies: '@types/connect': 3.4.37 - '@types/node': 18.18.6 + '@types/node': 18.18.7 /@types/bonjour@3.5.12: resolution: {integrity: sha512-ky0kWSqXVxSqgqJvPIkgFkcn4C8MnRog308Ou8xBBIVo39OmUFy+jqNe0nPwLCDFxUpmT9EvT91YzOJgkDRcFg==} dependencies: - '@types/node': 18.18.6 + '@types/node': 18.18.7 /@types/chai-as-promised@7.1.7: resolution: {integrity: sha512-APucaP5rlmTRYKtRA6FE5QPP87x76ejw5t5guRJ4y5OgMnwtsvigw7HHhKZlx2MGXLeZd6R/GNZR/IqDHcbtQw==} @@ -12245,39 +12213,36 @@ packages: /@types/cli-progress@3.11.4: resolution: {integrity: sha512-yufTxeeNCZuEIxx2uebK8lpSAsJM4lvzakm/VxzYhDtqhXCzwH9jpn7nPCxzrROuEbLATqhFq4MIPoG0tlrsvw==} dependencies: - '@types/node': 18.18.6 + '@types/node': 18.18.7 dev: true /@types/concat-stream@1.6.1: resolution: {integrity: sha512-eHE4cQPoj6ngxBZMvVf6Hw7Mh4jMW4U9lpGmS5GBPB9RYxlFg+CHaVN7ErNY4W9XfLIEn20b4VDYaIrbq0q4uA==} dependencies: - '@types/node': 18.18.6 + '@types/node': 18.18.7 dev: true /@types/connect-history-api-fallback@1.5.2: resolution: {integrity: sha512-gX2j9x+NzSh4zOhnRPSdPPmTepS4DfxES0AvIFv3jGv5QyeAJf6u6dY5/BAoAJU9Qq1uTvwOku8SSC2GnCRl6Q==} dependencies: '@types/express-serve-static-core': 4.17.39 - '@types/node': 18.18.6 + '@types/node': 18.18.7 /@types/connect@3.4.37: resolution: {integrity: sha512-zBUSRqkfZ59OcwXon4HVxhx5oWCJmc0OtBTK05M+p0dYjgN6iTwIL2T/WbsQZrEsdnwaF9cWQ+azOnpPvIqY3Q==} dependencies: - '@types/node': 18.18.6 - - /@types/cookie@0.4.1: - resolution: {integrity: sha512-XW/Aa8APYr6jSVVA1y/DEIZX0/GMKLEVekNG727R8cs56ahETkRAy/3DR7+fJyh7oUgGwNQaRfXCun0+KbWY7Q==} - dev: true + '@types/node': 18.18.7 /@types/debug@4.1.10: resolution: {integrity: sha512-tOSCru6s732pofZ+sMv9o4o3Zc+Sa8l3bxd/tweTQudFn06vAzb13ZX46Zi6m6EJ+RUbRTHvgQJ1gBtSgkaUYA==} dependencies: '@types/ms': 0.7.33 + dev: false /@types/dns-packet@5.6.2: resolution: {integrity: sha512-vgUZ0ilYvpnTDx7tBmmAUn1HsyzK3huAtulHaDbBBCW5UdaDrEei5XJjWHnD4s8r9/MSL1hJ8s+nvJdcvNKgMA==} dependencies: - '@types/node': 18.18.6 + '@types/node': 18.18.7 dev: false /@types/eslint-scope@3.7.6: @@ -12298,7 +12263,7 @@ packages: /@types/express-serve-static-core@4.17.39: resolution: {integrity: sha512-BiEUfAiGCOllomsRAZOiMFP7LAnrifHpt56pc4Z7l9K6ACyN06Ns1JLMBxwkfLOjJRlSf06NwWsT7yzfpaVpyQ==} dependencies: - '@types/node': 18.18.6 + '@types/node': 18.18.7 '@types/qs': 6.9.9 '@types/range-parser': 1.2.6 '@types/send': 0.17.3 @@ -12314,20 +12279,21 @@ packages: /@types/form-data@0.0.33: resolution: {integrity: sha512-8BSvG1kGm83cyJITQMZSulnl6QV8jqAGreJsc5tPu1Jq0vTSOiY/k24Wx82JRpWwZSqrala6sd5rWi6aNXvqcw==} dependencies: - '@types/node': 18.18.6 + '@types/node': 18.18.7 dev: true /@types/glob@7.2.0: resolution: {integrity: sha512-ZUxbzKl0IfJILTS6t7ip5fQQM/J3TJYubDm3nMbgubNNYS62eXeUpoLUC8/7fJNiFYHTrGPQn7hspDUzIHX3UA==} dependencies: '@types/minimatch': 5.1.2 - '@types/node': 18.18.6 + '@types/node': 18.18.7 dev: true /@types/graceful-fs@4.1.8: resolution: {integrity: sha512-NhRH7YzWq8WiNKVavKPBmtLYZHxNY19Hh+az28O/phfp68CF45pMFud+ZzJ8ewnxnC5smIdF3dqFeiSUQ5I+pw==} dependencies: - '@types/node': 18.18.6 + '@types/node': 18.18.7 + dev: true /@types/hast@2.3.7: resolution: {integrity: sha512-EVLigw5zInURhzfXUM65eixfadfsHKomGKUakToXo84t8gGIJuTcD2xooM2See7GyQ7DRtYjhCHnSUQez8JaLw==} @@ -12341,7 +12307,7 @@ packages: /@types/hoist-non-react-statics@3.3.4: resolution: {integrity: sha512-ZchYkbieA+7tnxwX/SCBySx9WwvWR8TaP5tb2jRAzwvLb/rWchGw3v0w3pqUbUvj0GCwW2Xz/AVPSk6kUGctXQ==} dependencies: - '@types/react': 18.2.31 + '@types/react': 18.2.33 hoist-non-react-statics: 3.3.2 dev: false @@ -12358,7 +12324,7 @@ packages: /@types/http-proxy@1.17.13: resolution: {integrity: sha512-GkhdWcMNiR5QSQRYnJ+/oXzu0+7JJEPC8vkWXK351BkhjraZF+1W13CUYARUvX9+NqIU2n6YHA4iwywsc/M6Sw==} dependencies: - '@types/node': 18.18.6 + '@types/node': 18.18.7 /@types/istanbul-lib-coverage@2.0.5: resolution: {integrity: sha512-zONci81DZYCZjiLe0r6equvZut0b+dBRPBN5kBDjsONnutYNtJMoWQ9uR2RkL1gLG9NMTzvf+29e5RFfPbeKhQ==} @@ -12384,14 +12350,10 @@ packages: resolution: {integrity: sha512-aLkWa0C0vO5b4Sr798E26QgOkss68Un0bLjs7u9qxzPT5CG+8DuNTffWES58YzJs3hrVAOs1wonycqEBqNJubA==} dev: false - /@types/js-levenshtein@1.1.2: - resolution: {integrity: sha512-/NCbMABw2uacuyE16Iwka1EzREDD50/W2ggRBad0y1WHBvAkvR9OEINxModVY7D428gXBe0igeVX7bUc9GaslQ==} - dev: true - /@types/jsdom@20.0.1: resolution: {integrity: sha512-d0r18sZPmMQr1eG35u12FZfhIXNrnsPU/g5wvRKCUf/tOGilKKwYMYGqh33BNR6ba+2gkHw1EUiHoN3mn7E5IQ==} dependencies: - '@types/node': 18.18.6 + '@types/node': 18.18.7 '@types/tough-cookie': 4.0.4 parse5: 7.1.2 dev: true @@ -12407,7 +12369,7 @@ packages: /@types/keyv@3.1.4: resolution: {integrity: sha512-BQ5aZNSCpj7D6K2ksrRCTmKRLEpnPvWDiLPfoGyhZ++8YtiK9d/3DBKPJgry359X/P1PfruyYwvnvwFjuEiEIg==} dependencies: - '@types/node': 18.18.6 + '@types/node': 18.18.7 /@types/level-errors@3.0.1: resolution: {integrity: sha512-eFJZWaOUhgjSqgEsPKJZrqXS9aEDUQh/5F9saFhhkR5uEVKlYb4GSG8XyoVC7APklcQKPGDVenTointTZBGIQg==} @@ -12418,7 +12380,7 @@ packages: dependencies: '@types/abstract-leveldown': 7.2.4 '@types/level-errors': 3.0.1 - '@types/node': 18.18.6 + '@types/node': 18.18.7 dev: true /@types/lodash@4.14.200: @@ -12455,7 +12417,7 @@ packages: /@types/mkdirp@0.5.2: resolution: {integrity: sha512-U5icWpv7YnZYGsN4/cmh3WD2onMY0aJIiTE6+51TwJCttdHvtCYmkBNOobHlXwrJRL0nkH9jH4kD+1FAdMN4Tg==} dependencies: - '@types/node': 18.18.6 + '@types/node': 18.18.7 dev: true /@types/mocha@9.1.0: @@ -12464,18 +12426,19 @@ packages: /@types/ms@0.7.33: resolution: {integrity: sha512-AuHIyzR5Hea7ij0P9q7vx7xu4z0C28ucwjAZC0ja7JhINyCnOw8/DnvAPQQ9TfOlCtZAmCERKQX9+o1mgQhuOQ==} + dev: false /@types/multicast-dns@7.2.3: resolution: {integrity: sha512-2SZ079yRhuhDn5BssqkQGp07vErjm3PD8S/JAlduWXacZ8SVHF0q6R2m0PwjjgTDU1vE3kibNPlmnr1iKbP/Sw==} dependencies: '@types/dns-packet': 5.6.2 - '@types/node': 18.18.6 + '@types/node': 18.18.7 dev: false - /@types/node-fetch@2.6.7: - resolution: {integrity: sha512-lX17GZVpJ/fuCjguZ5b3TjEbSENxmEk1B2z02yoXSK9WMEWRivhdSY73wWMn6bpcCDAOh6qAdktpKHIlkDk2lg==} + /@types/node-fetch@2.6.8: + resolution: {integrity: sha512-nnH5lV9QCMPsbEVdTb5Y+F3GQxLSw1xQgIydrb2gSfEavRPs50FnMr+KUaa+LoPSqibm2N+ZZxH7lavZlAT4GA==} dependencies: - '@types/node': 18.18.6 + '@types/node': 18.18.7 form-data: 4.0.0 dev: true @@ -12498,8 +12461,13 @@ packages: resolution: {integrity: sha512-w+tIMs3rq2afQdsPJlODhoUEKzFP1ayaoyl1CcnwtIlsVe7K7bA1NGm4s3PraqTLlXnbIN84zuBlxBWo1u9BLw==} dev: false - /@types/node@18.18.6: - resolution: {integrity: sha512-wf3Vz+jCmOQ2HV1YUJuCWdL64adYxumkrxtc+H1VUQlnQI04+5HtH+qZCOE21lBE7gIrt+CwX2Wv8Acrw5Ak6w==} + /@types/node@18.15.13: + resolution: {integrity: sha512-N+0kuo9KgrUQ1Sn/ifDXsvg0TTleP7rIy4zOBGECxAljqvqfqpTfzx0Q1NUedOixRMBfe2Whhb056a42cWs26Q==} + + /@types/node@18.18.7: + resolution: {integrity: sha512-bw+lEsxis6eqJYW8Ql6+yTqkE6RuFtsQPSe5JxXbqYRFQEER5aJA9a5UH9igqDWm3X4iLHIKOHlnAXLM4mi7uQ==} + dependencies: + undici-types: 5.26.5 /@types/node@20.5.1: resolution: {integrity: sha512-4tT2UrL5LBqDwoed9wZ6N3umC4Yhz3W3FloMmiiG4JwmUJWpie0c7lcnUNd4gtMKuDEO4wRVS8B6Xa0uMRsMKg==} @@ -12515,7 +12483,7 @@ packages: /@types/papaparse@5.3.10: resolution: {integrity: sha512-mS1Fta/xJ9EDYmAvpeWzcV9Gr0cOl1ClpW7di9+wSUNDIDO55tBtyXg97O7K+Syrd9rDEmuejM2iqmJIJ1SO5g==} dependencies: - '@types/node': 18.18.6 + '@types/node': 18.18.7 dev: true /@types/parse-json@4.0.1: @@ -12528,7 +12496,7 @@ packages: /@types/pbkdf2@3.1.1: resolution: {integrity: sha512-4HCoGwR3221nOc7G0Z/6KgTNGgaaFGkbGrtUJsB+zlKX2LBVjFHHIUkieMBgHHXgBH5Gq6dZHJKdBYdtlhBQvw==} dependencies: - '@types/node': 18.18.6 + '@types/node': 18.18.7 /@types/phoenix@1.6.3: resolution: {integrity: sha512-D8TtchWVnU2ZdPVDY6tBJuz8MUDmCNVduilZTrf0Gn/u5I/uZEXOsaL4Gs4F0j43cysHsU/4h7eqAKc+SF2boQ==} @@ -12536,6 +12504,7 @@ packages: /@types/prettier@2.7.3: resolution: {integrity: sha512-+68kP9yzs4LMp7VNh8gdzMSPZFL44MLGqiHWvttYJe+6qnuVr4Ek9wSBQoveqY/r+LwjCcU29kNVkidwim+kYA==} + dev: true /@types/prop-types@15.7.9: resolution: {integrity: sha512-n1yyPsugYNSmHgxDFjicaI2+gCNjsBck8UX9kuofAKlc0h1bL+20oSF72KeNaW2DUlesbEVCFgyV2dPGTiY42g==} @@ -12549,37 +12518,37 @@ packages: /@types/react-dom@18.2.14: resolution: {integrity: sha512-V835xgdSVmyQmI1KLV2BEIUgqEuinxp9O4G6g3FqO/SqLac049E53aysv0oEFD2kHfejeKU+ZqL2bcFWj9gLAQ==} dependencies: - '@types/react': 18.2.31 + '@types/react': 18.2.33 dev: true /@types/react-router-config@5.0.9: resolution: {integrity: sha512-a7zOj9yVUtM3Ns5stoseQAAsmppNxZpXDv6tZiFV5qlRmV4W96u53on1vApBX1eRSc8mrFOiB54Hc0Pk1J8GFg==} dependencies: '@types/history': 4.7.11 - '@types/react': 18.2.31 + '@types/react': 18.2.33 '@types/react-router': 5.1.20 /@types/react-router-dom@5.3.3: resolution: {integrity: sha512-kpqnYK4wcdm5UaWI3fLcELopqLrHgLqNsdpHauzlQktfkHL3npOSwtj1Uz9oKBAzs7lFtVkV8j83voAz2D8fhw==} dependencies: '@types/history': 4.7.11 - '@types/react': 18.2.31 + '@types/react': 18.2.33 '@types/react-router': 5.1.20 /@types/react-router@5.1.20: resolution: {integrity: sha512-jGjmu/ZqS7FjSH6owMcD5qpq19+1RS9DeVRqfl1FeBMxTDQAGwlMWOcs52NDoXaNKyG3d1cYQFMs9rCrb88o9Q==} dependencies: '@types/history': 4.7.11 - '@types/react': 18.2.31 + '@types/react': 18.2.33 /@types/react-transition-group@4.4.8: resolution: {integrity: sha512-QmQ22q+Pb+HQSn04NL3HtrqHwYMf4h3QKArOy5F8U5nEVMaihBs3SR10WiOM1iwPz5jIo8x/u11al+iEGZZrvg==} dependencies: - '@types/react': 18.2.31 + '@types/react': 18.2.33 dev: false - /@types/react@18.2.31: - resolution: {integrity: sha512-c2UnPv548q+5DFh03y8lEDeMfDwBn9G3dRwfkrxQMo/dOtRHUUO57k6pHvBIfH/VF4Nh+98mZ5aaSe+2echD5g==} + /@types/react@18.2.33: + resolution: {integrity: sha512-v+I7S+hu3PIBoVkKGpSYYpiBT1ijqEzWpzQD62/jm4K74hPpSP7FF9BnKG6+fg2+62weJYkkBWDJlZt5JO/9hg==} dependencies: '@types/prop-types': 15.7.9 '@types/scheduler': 0.16.5 @@ -12588,7 +12557,7 @@ packages: /@types/readable-stream@2.3.15: resolution: {integrity: sha512-oM5JSKQCcICF1wvGgmecmHldZ48OZamtMxcGGVICOJA8o8cahXC1zEVAif8iwoc5j8etxFaRFnf095+CDsuoFQ==} dependencies: - '@types/node': 18.18.6 + '@types/node': 18.18.7 safe-buffer: 5.1.2 /@types/resolve@1.20.2: @@ -12598,7 +12567,7 @@ packages: /@types/responselike@1.0.2: resolution: {integrity: sha512-/4YQT5Kp6HxUDb4yhRkm0bJ7TbjvTddqX7PZ5hz6qV3pxSo72f/6YPRo+Mu2DU307tm9IioO69l7uAwn5XNcFA==} dependencies: - '@types/node': 18.18.6 + '@types/node': 18.18.7 /@types/retry@0.12.0: resolution: {integrity: sha512-wWKOClTTiizcZhXnPY4wikVAwmdYHp8q6DmC+EJUzAMsycb7HB32Kh9RN4+0gExjmPmZSAQjgURXIGATPegAvA==} @@ -12610,7 +12579,7 @@ packages: /@types/sax@1.2.6: resolution: {integrity: sha512-A1mpYCYu1aHFayy8XKN57ebXeAbh9oQIZ1wXcno6b1ESUAfMBDMx7mf/QGlYwcMRaFryh9YBuH03i/3FlPGDkQ==} dependencies: - '@types/node': 18.18.6 + '@types/node': 18.18.7 dev: false /@types/scheduler@0.16.5: @@ -12619,7 +12588,7 @@ packages: /@types/secp256k1@4.0.5: resolution: {integrity: sha512-aIonTBMErtE3T9MxDvTZRzcrT/mCqpEZBw3CCY/i+oG9n57N/+7obBkhFgavUAIrX21bU0LHg1XRgtaLdelBhA==} dependencies: - '@types/node': 18.18.6 + '@types/node': 18.18.7 /@types/seedrandom@3.0.1: resolution: {integrity: sha512-giB9gzDeiCeloIXDgzFBCgjj1k4WxcDrZtGl6h1IqmUPlxF+Nx8Ve+96QCyDZ/HseB/uvDsKbpib9hU5cU53pw==} @@ -12633,7 +12602,7 @@ packages: resolution: {integrity: sha512-/7fKxvKUoETxjFUsuFlPB9YndePpxxRAOfGC/yJdc9kTjTeP5kRCTzfnE8kPUKCeyiyIZu0YQ76s50hCedI1ug==} dependencies: '@types/mime': 1.3.4 - '@types/node': 18.18.6 + '@types/node': 18.18.7 /@types/serve-index@1.9.3: resolution: {integrity: sha512-4KG+yMEuvDPRrYq5fyVm/I2uqAJSAwZK9VSa+Zf+zUq9/oxSSvy3kkIqyL+jjStv6UCVi8/Aho0NHtB1Fwosrg==} @@ -12645,28 +12614,18 @@ packages: dependencies: '@types/http-errors': 2.0.3 '@types/mime': 3.0.3 - '@types/node': 18.18.6 - - /@types/set-cookie-parser@2.4.5: - resolution: {integrity: sha512-ZPmztaAQ4rbnW/WTUnT1dwSENQo4bjGqxCSeyK+gZxmd+zJl/QAeF6dpEXcS5UEJX22HwiggFSaY8nE1nRmkbg==} - dependencies: - '@types/node': 18.18.6 - dev: true + '@types/node': 18.18.7 /@types/sinon@10.0.20: resolution: {integrity: sha512-2APKKruFNCAZgx3daAyACGzWuJ028VVCUDk6o2rw/Z4PXT0ogwdV4KUegW0MwVs0Zu59auPXbbuBJHF12Sx1Eg==} dependencies: - '@types/sinonjs__fake-timers': 8.1.4 + '@types/sinonjs__fake-timers': 8.1.1 dev: true /@types/sinonjs__fake-timers@8.1.1: resolution: {integrity: sha512-0kSuKjAS0TrGLJ0M/+8MaFkGsQhZpB6pxOmvS3K8FYI72K//YmdfoW9X2qPsAKh1mkwxGD5zib9s1FIFed6E8g==} dev: true - /@types/sinonjs__fake-timers@8.1.4: - resolution: {integrity: sha512-GDV68H0mBSN449sa5HEj51E0wfpVQb8xNSMzxf/PrypMFcLTMwJMOM/cgXiv71Mq5drkOQmUGvL1okOZcu6RrQ==} - dev: true - /@types/sizzle@2.3.5: resolution: {integrity: sha512-tAe4Q+OLFOA/AMD+0lq8ovp8t3ysxAOeaScnfNdZpUxaGl51ZMDEITxkvFl1STudQ58mz6gzVGl9VhMKhwRnZQ==} dev: true @@ -12674,7 +12633,7 @@ packages: /@types/sockjs@0.3.35: resolution: {integrity: sha512-tIF57KB+ZvOBpAQwSaACfEu7htponHXaFzP7RfKYgsOS0NoYnn+9+jzp7bbq4fWerizI3dTB4NfAZoyeQKWJLw==} dependencies: - '@types/node': 18.18.6 + '@types/node': 18.18.7 /@types/source-list-map@0.1.4: resolution: {integrity: sha512-Kdfm7Sk5VX8dFW7Vbp18+fmAatBewzBILa1raHYxrGEFXT0jNl9x3LWfuW7bTbjEKFNey9Dfkj/UzT6z/NvRlg==} @@ -12725,7 +12684,7 @@ packages: /@types/webpack-sources@3.2.2: resolution: {integrity: sha512-acCzhuVe+UJy8abiSFQWXELhhNMZjQjQKpLNEi1pKGgKXZj0ul614ATcx4kkhunPost6Xw+aCq8y8cn1/WwAiA==} dependencies: - '@types/node': 18.18.6 + '@types/node': 18.18.7 '@types/source-list-map': 0.1.4 source-map: 0.7.4 dev: true @@ -12733,7 +12692,7 @@ packages: /@types/webpack@4.41.35: resolution: {integrity: sha512-XRC6HLGHtNfN8/xWeu1YUQV1GSE+28q8lSqvcJ+0xt/zW9Wmn4j9pCSvaXPyRlCKrl5OuqECQNEJUy2vo8oWqg==} dependencies: - '@types/node': 18.18.6 + '@types/node': 18.18.7 '@types/tapable': 1.0.10 '@types/uglify-js': 3.17.3 '@types/webpack-sources': 3.2.2 @@ -12744,18 +12703,18 @@ packages: /@types/websocket@1.0.8: resolution: {integrity: sha512-wvkOpWApbuxVfHhSQ1XrjVN4363vsfLJwEo4AboIZk0g1vJA5nmLp8GXUHuIdf4/Fe7+/V0Efe2HvWiLqHtlqw==} dependencies: - '@types/node': 18.18.6 + '@types/node': 18.18.7 dev: false /@types/ws@7.4.7: resolution: {integrity: sha512-JQbbmxZTZehdc2iszGKs5oC3NFnjeay7mtAWrdt7qNtAVK0g19muApzAy4bm9byz79xa2ZnO/BOBC2R8RC5Lww==} dependencies: - '@types/node': 18.18.6 + '@types/node': 18.18.7 /@types/ws@8.5.8: resolution: {integrity: sha512-flUksGIQCnJd6sZ1l5dqCEG/ksaoAg/eUwiLAGTJQcfgvZJKF++Ta4bJA6A5aPSJmsr+xlseHn4KLgVlNnvPTg==} dependencies: - '@types/node': 18.18.6 + '@types/node': 18.18.7 /@types/yargs-parser@21.0.2: resolution: {integrity: sha512-5qcvofLPbfjmBfKaLfj/+f+Sbd6pN4zl7w7VSVI5uz7m9QZTuB2aZAa2uo1wHFBNN2x6g/SoTkXmd8mQnQF2Cw==} @@ -12779,7 +12738,7 @@ packages: resolution: {integrity: sha512-Km7XAtUIduROw7QPgvcft0lIupeG8a8rdKL8RiSyKvlE7dYY31fEn41HVuQsRFDuROA8tA4K2UVL+WdfFmErBA==} requiresBuild: true dependencies: - '@types/node': 18.18.6 + '@types/node': 18.18.7 dev: true optional: true @@ -12794,7 +12753,7 @@ packages: typescript: optional: true dependencies: - '@eslint-community/regexpp': 4.9.1 + '@eslint-community/regexpp': 4.10.0 '@typescript-eslint/parser': 5.62.0(eslint@8.19.0)(typescript@5.1.6) '@typescript-eslint/scope-manager': 5.62.0 '@typescript-eslint/type-utils': 5.62.0(eslint@8.19.0)(typescript@5.1.6) @@ -12822,7 +12781,7 @@ packages: typescript: optional: true dependencies: - '@eslint-community/regexpp': 4.9.1 + '@eslint-community/regexpp': 4.10.0 '@typescript-eslint/parser': 5.62.0(eslint@8.52.0)(typescript@4.9.5) '@typescript-eslint/scope-manager': 5.62.0 '@typescript-eslint/type-utils': 5.62.0(eslint@8.52.0)(typescript@4.9.5) @@ -13024,7 +12983,6 @@ packages: /@ungap/structured-clone@1.2.0: resolution: {integrity: sha512-zuVdFrMJiuCDQUMCzQaD6KL28MjnqqN8XnAqiEq9PNm/hCPTSGfrXCOfwj1ow4LFb/tNymJPwsNbVePc1xFqrQ==} - dev: true /@vanilla-extract/css@1.9.1: resolution: {integrity: sha512-pu2SFiff5jRhPwvGoj8cM5l/qIyLvigOmy22ss5DGjwV5pJYezRjDLxWumi2luIwioMWvh9EozCjyfH8nq+7fQ==} @@ -13077,6 +13035,19 @@ packages: - utf-8-validate dev: true + /@viem/anvil@0.0.6: + resolution: {integrity: sha512-OjKR/+FVwzuygXYFqP8MBal1SXG8bT2gbZwqqB0XuLw81LNBBvmE/Repm6+5kkBh4IUj0PhYdrqOsnayS14Gtg==} + dependencies: + execa: 7.2.0 + get-port: 6.1.2 + http-proxy: 1.18.1(debug@4.3.4) + ws: 8.14.2(bufferutil@4.0.8)(utf-8-validate@5.0.10) + transitivePeerDependencies: + - bufferutil + - debug + - utf-8-validate + dev: true + /@vitest/expect@0.28.5: resolution: {integrity: sha512-gqTZwoUTwepwGIatnw4UKpQfnoyV0Z9Czn9+Lo2/jLIt4/AXLTn+oVZxlQ7Ng8bzcNkR+3DqLJ08kNr8jRmdNQ==} dependencies: @@ -13109,56 +13080,56 @@ packages: pretty-format: 27.5.1 dev: true - /@vue/compiler-core@3.3.6: - resolution: {integrity: sha512-2JNjemwaNwf+MkkatATVZi7oAH1Hx0B04DdPH3ZoZ8vKC1xZVP7nl4HIsk8XYd3r+/52sqqoz9TWzYc3yE9dqA==} + /@vue/compiler-core@3.3.7: + resolution: {integrity: sha512-pACdY6YnTNVLXsB86YD8OF9ihwpolzhhtdLVHhBL6do/ykr6kKXNYABRtNMGrsQXpEXXyAdwvWWkuTbs4MFtPQ==} dependencies: '@babel/parser': 7.23.0 - '@vue/shared': 3.3.6 + '@vue/shared': 3.3.7 estree-walker: 2.0.2 source-map-js: 1.0.2 dev: true - /@vue/compiler-dom@3.3.6: - resolution: {integrity: sha512-1MxXcJYMHiTPexjLAJUkNs/Tw2eDf2tY3a0rL+LfuWyiKN2s6jvSwywH3PWD8bKICjfebX3GWx2Os8jkRDq3Ng==} + /@vue/compiler-dom@3.3.7: + resolution: {integrity: sha512-0LwkyJjnUPssXv/d1vNJ0PKfBlDoQs7n81CbO6Q0zdL7H1EzqYRrTVXDqdBVqro0aJjo/FOa1qBAPVI4PGSHBw==} dependencies: - '@vue/compiler-core': 3.3.6 - '@vue/shared': 3.3.6 + '@vue/compiler-core': 3.3.7 + '@vue/shared': 3.3.7 dev: true - /@vue/compiler-sfc@3.3.6: - resolution: {integrity: sha512-/Kms6du2h1VrXFreuZmlvQej8B1zenBqIohP0690IUBkJjsFvJxY0crcvVRJ0UhMgSR9dewB+khdR1DfbpArJA==} + /@vue/compiler-sfc@3.3.7: + resolution: {integrity: sha512-7pfldWy/J75U/ZyYIXRVqvLRw3vmfxDo2YLMwVtWVNew8Sm8d6wodM+OYFq4ll/UxfqVr0XKiVwti32PCrruAw==} dependencies: '@babel/parser': 7.23.0 - '@vue/compiler-core': 3.3.6 - '@vue/compiler-dom': 3.3.6 - '@vue/compiler-ssr': 3.3.6 - '@vue/reactivity-transform': 3.3.6 - '@vue/shared': 3.3.6 + '@vue/compiler-core': 3.3.7 + '@vue/compiler-dom': 3.3.7 + '@vue/compiler-ssr': 3.3.7 + '@vue/reactivity-transform': 3.3.7 + '@vue/shared': 3.3.7 estree-walker: 2.0.2 magic-string: 0.30.5 postcss: 8.4.31 source-map-js: 1.0.2 dev: true - /@vue/compiler-ssr@3.3.6: - resolution: {integrity: sha512-QTIHAfDCHhjXlYGkUg5KH7YwYtdUM1vcFl/FxFDlD6d0nXAmnjizka3HITp8DGudzHndv2PjKVS44vqqy0vP4w==} + /@vue/compiler-ssr@3.3.7: + resolution: {integrity: sha512-TxOfNVVeH3zgBc82kcUv+emNHo+vKnlRrkv8YvQU5+Y5LJGJwSNzcmLUoxD/dNzv0bhQ/F0s+InlgV0NrApJZg==} dependencies: - '@vue/compiler-dom': 3.3.6 - '@vue/shared': 3.3.6 + '@vue/compiler-dom': 3.3.7 + '@vue/shared': 3.3.7 dev: true - /@vue/reactivity-transform@3.3.6: - resolution: {integrity: sha512-RlJl4dHfeO7EuzU1iJOsrlqWyJfHTkJbvYz/IOJWqu8dlCNWtxWX377WI0VsbAgBizjwD+3ZjdnvSyyFW1YVng==} + /@vue/reactivity-transform@3.3.7: + resolution: {integrity: sha512-APhRmLVbgE1VPGtoLQoWBJEaQk4V8JUsqrQihImVqKT+8U6Qi3t5ATcg4Y9wGAPb3kIhetpufyZ1RhwbZCIdDA==} dependencies: '@babel/parser': 7.23.0 - '@vue/compiler-core': 3.3.6 - '@vue/shared': 3.3.6 + '@vue/compiler-core': 3.3.7 + '@vue/shared': 3.3.7 estree-walker: 2.0.2 magic-string: 0.30.5 dev: true - /@vue/shared@3.3.6: - resolution: {integrity: sha512-Xno5pEqg8SVhomD0kTSmfh30ZEmV/+jZtyh39q6QflrjdJCXah5lrnOLi9KB6a5k5aAHXMXjoMnxlzUkCNfWLQ==} + /@vue/shared@3.3.7: + resolution: {integrity: sha512-N/tbkINRUDExgcPTBvxNkvHGu504k8lzlNQRITVnm6YjOjwa4r0nnbd4Jb01sNpur5hAllyRJzSK5PvB9PPwRg==} dev: true /@wagmi/chains@1.0.0(typescript@5.1.6): @@ -13172,26 +13143,47 @@ packages: typescript: 5.1.6 dev: true - /@wagmi/chains@1.6.0(typescript@5.1.6): - resolution: {integrity: sha512-5FRlVxse5P4ZaHG3GTvxwVANSmYJas1eQrTBHhjxVtqXoorm0aLmCHbhmN8Xo1yu09PaWKlleEvfE98yH4AgIw==} + /@wagmi/connectors@2.7.0(react@18.2.0)(typescript@5.1.6)(viem@1.18.4)(zod@3.22.4): + resolution: {integrity: sha512-1KOL0HTJl5kzSC/YdKwFwiokr6poUQn1V/tcT0TpG3iH2x0lSM7FTkvCjVVY/6lKzTXrLlo9y2aE7AsOPnkvqg==} peerDependencies: + '@wagmi/chains': '>=1.7.0' typescript: '>=5.0.4' + viem: '>=0.3.35' peerDependenciesMeta: + '@wagmi/chains': + optional: true typescript: optional: true dependencies: + '@coinbase/wallet-sdk': 3.7.2 + '@ledgerhq/connect-kit-loader': 1.1.2 + '@safe-global/safe-apps-provider': 0.17.1(typescript@5.1.6)(zod@3.22.4) + '@safe-global/safe-apps-sdk': 8.1.0(typescript@5.1.6)(zod@3.22.4) + '@walletconnect/ethereum-provider': 2.9.2(@walletconnect/modal@2.6.1) + '@walletconnect/legacy-provider': 2.0.0 + '@walletconnect/modal': 2.6.1(react@18.2.0) + '@walletconnect/utils': 2.9.2 + abitype: 0.8.7(typescript@5.1.6)(zod@3.22.4) + eventemitter3: 4.0.7 typescript: 5.1.6 + viem: 1.18.4(typescript@5.1.6)(zod@3.22.4) + transitivePeerDependencies: + - '@react-native-async-storage/async-storage' + - bufferutil + - encoding + - lokijs + - react + - supports-color + - utf-8-validate + - zod dev: false - /@wagmi/connectors@2.6.6(@wagmi/chains@1.6.0)(react@18.2.0)(typescript@5.1.6)(viem@1.5.3)(zod@3.22.4): - resolution: {integrity: sha512-/o1c/TCivQs8DOAUOcQvY2UIt3p2mWOAHi39D0LC74+ncpXzLC5/gyaWU38qnTxPM8s/PmTmaWDgz+VhICXrag==} + /@wagmi/connectors@3.1.3(@types/react@18.2.33)(react@18.2.0)(typescript@5.1.6)(viem@1.18.4)(zod@3.22.4): + resolution: {integrity: sha512-UgwsQKQDFObJVJMf9pDfFoXTv710o4zrTHyhIWKBTMMkLpCMsMxN5+ZaDhBYt/BgoRinfRYQo8uwuwLhxE6Log==} peerDependencies: - '@wagmi/chains': '>=1.3.0' typescript: '>=5.0.4' viem: '>=0.3.35' peerDependenciesMeta: - '@wagmi/chains': - optional: true typescript: optional: true dependencies: @@ -13199,17 +13191,17 @@ packages: '@ledgerhq/connect-kit-loader': 1.1.2 '@safe-global/safe-apps-provider': 0.17.1(typescript@5.1.6)(zod@3.22.4) '@safe-global/safe-apps-sdk': 8.1.0(typescript@5.1.6)(zod@3.22.4) - '@wagmi/chains': 1.6.0(typescript@5.1.6) - '@walletconnect/ethereum-provider': 2.9.0(@walletconnect/modal@2.5.9) + '@walletconnect/ethereum-provider': 2.10.2(@walletconnect/modal@2.6.2) '@walletconnect/legacy-provider': 2.0.0 - '@walletconnect/modal': 2.5.9(react@18.2.0) - '@walletconnect/utils': 2.9.0 + '@walletconnect/modal': 2.6.2(@types/react@18.2.33)(react@18.2.0) + '@walletconnect/utils': 2.10.2 abitype: 0.8.7(typescript@5.1.6)(zod@3.22.4) eventemitter3: 4.0.7 typescript: 5.1.6 - viem: 1.5.3(typescript@5.1.6)(zod@3.22.4) + viem: 1.18.4(typescript@5.1.6)(zod@3.22.4) transitivePeerDependencies: - '@react-native-async-storage/async-storage' + - '@types/react' - bufferutil - encoding - lokijs @@ -13219,8 +13211,8 @@ packages: - zod dev: false - /@wagmi/core@1.3.8(@types/react@18.2.31)(react@18.2.0)(typescript@5.1.6)(viem@1.5.3)(zod@3.22.4): - resolution: {integrity: sha512-OYSxikoMizqVnpSkFTwGE7PwFaz2k0PXteSiI0W2Mtk4j4sZzRFdP+9AWeDB6AYm0yU3WvgN1IATx0EEBKUe3w==} + /@wagmi/core@1.4.5(@types/react@18.2.33)(react@18.2.0)(typescript@5.1.6)(viem@1.18.4)(zod@3.22.4): + resolution: {integrity: sha512-N9luRb1Uk4tBN9kaYcQSWKE9AsRt/rvZaFt5IZech4JPzNN2sQlfhKd9GEjOXYRDqEPHdDvos7qyBKiDNTz4GA==} peerDependencies: typescript: '>=5.0.4' viem: '>=0.3.35' @@ -13228,13 +13220,12 @@ packages: typescript: optional: true dependencies: - '@wagmi/chains': 1.6.0(typescript@5.1.6) - '@wagmi/connectors': 2.6.6(@wagmi/chains@1.6.0)(react@18.2.0)(typescript@5.1.6)(viem@1.5.3)(zod@3.22.4) + '@wagmi/connectors': 3.1.3(@types/react@18.2.33)(react@18.2.0)(typescript@5.1.6)(viem@1.18.4)(zod@3.22.4) abitype: 0.8.7(typescript@5.1.6)(zod@3.22.4) eventemitter3: 4.0.7 typescript: 5.1.6 - viem: 1.5.3(typescript@5.1.6)(zod@3.22.4) - zustand: 4.4.4(@types/react@18.2.31)(react@18.2.0) + viem: 1.18.4(typescript@5.1.6)(zod@3.22.4) + zustand: 4.4.4(@types/react@18.2.33)(react@18.2.0) transitivePeerDependencies: - '@react-native-async-storage/async-storage' - '@types/react' @@ -13248,22 +13239,48 @@ packages: - zod dev: false - /@walletconnect/core@2.9.0: - resolution: {integrity: sha512-MZYJghS9YCvGe32UOgDj0mCasaOoGHQaYXWeQblXE/xb8HuaM6kAWhjIQN9P+MNp5QP134BHP5olQostcCotXQ==} + /@walletconnect/core@2.10.2: + resolution: {integrity: sha512-JQz/xp3SLEpTeRQctdck2ugSBVEpMxoSE+lFi2voJkZop1hv6P+uqr6E4PzjFluAjeAnKlT1xvra0aFWjPWVcw==} + dependencies: + '@walletconnect/heartbeat': 1.2.1 + '@walletconnect/jsonrpc-provider': 1.0.13 + '@walletconnect/jsonrpc-types': 1.0.3 + '@walletconnect/jsonrpc-utils': 1.0.8 + '@walletconnect/jsonrpc-ws-connection': 1.0.13 + '@walletconnect/keyvaluestorage': 1.0.2 + '@walletconnect/logger': 2.0.1 + '@walletconnect/relay-api': 1.0.9 + '@walletconnect/relay-auth': 1.0.4 + '@walletconnect/safe-json': 1.0.2 + '@walletconnect/time': 1.0.2 + '@walletconnect/types': 2.10.2 + '@walletconnect/utils': 2.10.2 + events: 3.3.0 + lodash.isequal: 4.5.0 + uint8arrays: 3.1.1 + transitivePeerDependencies: + - '@react-native-async-storage/async-storage' + - bufferutil + - lokijs + - utf-8-validate + dev: false + + /@walletconnect/core@2.9.2: + resolution: {integrity: sha512-VARMPAx8sIgodeyngDHbealP3B621PQqjqKsByFUTOep8ZI1/R/20zU+cmq6j9RCrL+kLKZcrZqeVzs8Z7OlqQ==} dependencies: '@walletconnect/heartbeat': 1.2.1 '@walletconnect/jsonrpc-provider': 1.0.13 '@walletconnect/jsonrpc-types': 1.0.3 '@walletconnect/jsonrpc-utils': 1.0.8 - '@walletconnect/jsonrpc-ws-connection': 1.0.12 + '@walletconnect/jsonrpc-ws-connection': 1.0.13 '@walletconnect/keyvaluestorage': 1.0.2 '@walletconnect/logger': 2.0.1 '@walletconnect/relay-api': 1.0.9 '@walletconnect/relay-auth': 1.0.4 '@walletconnect/safe-json': 1.0.2 '@walletconnect/time': 1.0.2 - '@walletconnect/types': 2.9.0 - '@walletconnect/utils': 2.9.0 + '@walletconnect/types': 2.9.2 + '@walletconnect/utils': 2.9.2 events: 3.3.0 lodash.isequal: 4.5.0 uint8arrays: 3.1.1 @@ -13299,8 +13316,34 @@ packages: tslib: 1.14.1 dev: false - /@walletconnect/ethereum-provider@2.9.0(@walletconnect/modal@2.5.9): - resolution: {integrity: sha512-rSXkC0SXMigJRdIi/M2RMuEuATY1AwtlTWQBnqyxoht7xbO2bQNPCXn0XL4s/GRNrSUtoKSY4aPMHXV4W4yLBA==} + /@walletconnect/ethereum-provider@2.10.2(@walletconnect/modal@2.6.2): + resolution: {integrity: sha512-QMYFZ6+rVq2CJLdIPdKK0j1Qm66UA27oQU5V2SrL8EVwl7wFfm0Bq7fnL+qAWeDpn612dNeNErpk/ROa1zWlWg==} + peerDependencies: + '@walletconnect/modal': '>=2' + peerDependenciesMeta: + '@walletconnect/modal': + optional: true + dependencies: + '@walletconnect/jsonrpc-http-connection': 1.0.7 + '@walletconnect/jsonrpc-provider': 1.0.13 + '@walletconnect/jsonrpc-types': 1.0.3 + '@walletconnect/jsonrpc-utils': 1.0.8 + '@walletconnect/modal': 2.6.2(@types/react@18.2.33)(react@18.2.0) + '@walletconnect/sign-client': 2.10.2 + '@walletconnect/types': 2.10.2 + '@walletconnect/universal-provider': 2.10.2 + '@walletconnect/utils': 2.10.2 + events: 3.3.0 + transitivePeerDependencies: + - '@react-native-async-storage/async-storage' + - bufferutil + - encoding + - lokijs + - utf-8-validate + dev: false + + /@walletconnect/ethereum-provider@2.9.2(@walletconnect/modal@2.6.1): + resolution: {integrity: sha512-eO1dkhZffV1g7vpG19XUJTw09M/bwGUwwhy1mJ3AOPbOSbMPvwiCuRz2Kbtm1g9B0Jv15Dl+TvJ9vTgYF8zoZg==} peerDependencies: '@walletconnect/modal': '>=2' peerDependenciesMeta: @@ -13311,11 +13354,11 @@ packages: '@walletconnect/jsonrpc-provider': 1.0.13 '@walletconnect/jsonrpc-types': 1.0.3 '@walletconnect/jsonrpc-utils': 1.0.8 - '@walletconnect/modal': 2.5.9(react@18.2.0) - '@walletconnect/sign-client': 2.9.0 - '@walletconnect/types': 2.9.0 - '@walletconnect/universal-provider': 2.9.0 - '@walletconnect/utils': 2.9.0 + '@walletconnect/modal': 2.6.1(react@18.2.0) + '@walletconnect/sign-client': 2.9.2 + '@walletconnect/types': 2.9.2 + '@walletconnect/universal-provider': 2.9.2 + '@walletconnect/utils': 2.9.2 events: 3.3.0 transitivePeerDependencies: - '@react-native-async-storage/async-storage' @@ -13374,8 +13417,8 @@ packages: tslib: 1.14.1 dev: false - /@walletconnect/jsonrpc-ws-connection@1.0.12: - resolution: {integrity: sha512-HAcadga3Qjt1Cqy+qXEW6zjaCs8uJGdGQrqltzl3OjiK4epGZRdvSzTe63P+t/3z+D2wG+ffEPn0GVcDozmN1w==} + /@walletconnect/jsonrpc-ws-connection@1.0.13: + resolution: {integrity: sha512-mfOM7uFH4lGtQxG+XklYuFBj6dwVvseTt5/ahOkkmpcAEgz2umuzu7fTR+h5EmjQBdrmYyEBOWADbeaFNxdySg==} dependencies: '@walletconnect/jsonrpc-utils': 1.0.8 '@walletconnect/safe-json': 1.0.2 @@ -13466,32 +13509,62 @@ packages: tslib: 1.14.1 dev: false - /@walletconnect/modal-core@2.5.9(react@18.2.0): - resolution: {integrity: sha512-isIebwF9hOknGouhS/Ob4YJ9Sa/tqNYG2v6Ua9EkCqIoLimepkG5eC53tslUWW29SLSfQ9qqBNG2+iE7yQXqgw==} + /@walletconnect/modal-core@2.6.1(react@18.2.0): + resolution: {integrity: sha512-f2hYlJ5pwzGvjyaZ6BoGR5uiMgXzWXt6w6ktt1N8lmY6PiYp8whZgqx2hTxVWwVlsGnaIfh6UHp1hGnANx0eTQ==} dependencies: - buffer: 6.0.3 - valtio: 1.10.6(react@18.2.0) + valtio: 1.11.0(react@18.2.0) transitivePeerDependencies: - react dev: false - /@walletconnect/modal-ui@2.5.9(react@18.2.0): - resolution: {integrity: sha512-nfBaAT9Ls7RZTBBgAq+Nt/3AoUcinIJ9bcq5UHXTV3lOPu/qCKmUC/0HY3GvUK8ykabUAsjr0OAGmcqkB91qug==} + /@walletconnect/modal-core@2.6.2(@types/react@18.2.33)(react@18.2.0): + resolution: {integrity: sha512-cv8ibvdOJQv2B+nyxP9IIFdxvQznMz8OOr/oR/AaUZym4hjXNL/l1a2UlSQBXrVjo3xxbouMxLb3kBsHoYP2CA==} dependencies: - '@walletconnect/modal-core': 2.5.9(react@18.2.0) - lit: 2.7.5 + valtio: 1.11.2(@types/react@18.2.33)(react@18.2.0) + transitivePeerDependencies: + - '@types/react' + - react + dev: false + + /@walletconnect/modal-ui@2.6.1(react@18.2.0): + resolution: {integrity: sha512-RFUOwDAMijSK8B7W3+KoLKaa1l+KEUG0LCrtHqaB0H0cLnhEGdLR+kdTdygw+W8+yYZbkM5tXBm7MlFbcuyitA==} + dependencies: + '@walletconnect/modal-core': 2.6.1(react@18.2.0) + lit: 2.7.6 motion: 10.16.2 qrcode: 1.5.3 transitivePeerDependencies: - react dev: false - /@walletconnect/modal@2.5.9(react@18.2.0): - resolution: {integrity: sha512-Zs2RvPwbBNRdBhb50FuJCxi3FJltt1KSpI7odjU/x9GTpTOcSOkmR66PBCy2JvNA0+ztnS1Xs0LVEr3lu7/Jzw==} + /@walletconnect/modal-ui@2.6.2(@types/react@18.2.33)(react@18.2.0): + resolution: {integrity: sha512-rbdstM1HPGvr7jprQkyPggX7rP4XiCG85ZA+zWBEX0dVQg8PpAgRUqpeub4xQKDgY7pY/xLRXSiCVdWGqvG2HA==} dependencies: - '@walletconnect/modal-core': 2.5.9(react@18.2.0) - '@walletconnect/modal-ui': 2.5.9(react@18.2.0) + '@walletconnect/modal-core': 2.6.2(@types/react@18.2.33)(react@18.2.0) + lit: 2.8.0 + motion: 10.16.2 + qrcode: 1.5.3 transitivePeerDependencies: + - '@types/react' + - react + dev: false + + /@walletconnect/modal@2.6.1(react@18.2.0): + resolution: {integrity: sha512-G84tSzdPKAFk1zimgV7JzIUFT5olZUVtI3GcOk77OeLYjlMfnDT23RVRHm5EyCrjkptnvpD0wQScXePOFd2Xcw==} + dependencies: + '@walletconnect/modal-core': 2.6.1(react@18.2.0) + '@walletconnect/modal-ui': 2.6.1(react@18.2.0) + transitivePeerDependencies: + - react + dev: false + + /@walletconnect/modal@2.6.2(@types/react@18.2.33)(react@18.2.0): + resolution: {integrity: sha512-eFopgKi8AjKf/0U4SemvcYw9zlLpx9njVN8sf6DAkowC2Md0gPU/UNEbH1Wwj407pEKnEds98pKWib1NN1ACoA==} + dependencies: + '@walletconnect/modal-core': 2.6.2(@types/react@18.2.33)(react@18.2.0) + '@walletconnect/modal-ui': 2.6.2(@types/react@18.2.33)(react@18.2.0) + transitivePeerDependencies: + - '@types/react' - react dev: false @@ -13528,17 +13601,36 @@ packages: tslib: 1.14.1 dev: false - /@walletconnect/sign-client@2.9.0: - resolution: {integrity: sha512-mEKc4LlLMebCe45qzqh+MX4ilQK4kOEBzLY6YJpG8EhyT45eX4JMNA7qQoYa9MRMaaVb/7USJcc4e3ZrjZvQmA==} + /@walletconnect/sign-client@2.10.2: + resolution: {integrity: sha512-vviSLV3f92I0bReX+OLr1HmbH0uIzYEQQFd1MzIfDk9PkfFT/LLAHhUnDaIAMkIdippqDcJia+5QEtT4JihL3Q==} dependencies: - '@walletconnect/core': 2.9.0 + '@walletconnect/core': 2.10.2 '@walletconnect/events': 1.0.1 '@walletconnect/heartbeat': 1.2.1 '@walletconnect/jsonrpc-utils': 1.0.8 '@walletconnect/logger': 2.0.1 '@walletconnect/time': 1.0.2 - '@walletconnect/types': 2.9.0 - '@walletconnect/utils': 2.9.0 + '@walletconnect/types': 2.10.2 + '@walletconnect/utils': 2.10.2 + events: 3.3.0 + transitivePeerDependencies: + - '@react-native-async-storage/async-storage' + - bufferutil + - lokijs + - utf-8-validate + dev: false + + /@walletconnect/sign-client@2.9.2: + resolution: {integrity: sha512-anRwnXKlR08lYllFMEarS01hp1gr6Q9XUgvacr749hoaC/AwGVlxYFdM8+MyYr3ozlA+2i599kjbK/mAebqdXg==} + dependencies: + '@walletconnect/core': 2.9.2 + '@walletconnect/events': 1.0.1 + '@walletconnect/heartbeat': 1.2.1 + '@walletconnect/jsonrpc-utils': 1.0.8 + '@walletconnect/logger': 2.0.1 + '@walletconnect/time': 1.0.2 + '@walletconnect/types': 2.9.2 + '@walletconnect/utils': 2.9.2 events: 3.3.0 transitivePeerDependencies: - '@react-native-async-storage/async-storage' @@ -13553,8 +13645,8 @@ packages: tslib: 1.14.1 dev: false - /@walletconnect/types@2.9.0: - resolution: {integrity: sha512-ORopsMfSRvUYqtjKKd6scfg8o4/aGebipLxx92AuuUgMTERSU6cGmIrK6rdLu7W6FBJkmngPLEGc9mRqAb9Lug==} + /@walletconnect/types@2.10.2: + resolution: {integrity: sha512-luNV+07Wdla4STi9AejseCQY31tzWKQ5a7C3zZZaRK/di+rFaAAb7YW04OP4klE7tw/mJRGPTlekZElmHxO8kQ==} dependencies: '@walletconnect/events': 1.0.1 '@walletconnect/heartbeat': 1.2.1 @@ -13567,17 +13659,31 @@ packages: - lokijs dev: false - /@walletconnect/universal-provider@2.9.0: - resolution: {integrity: sha512-k3nkSBkF69sJJVoe17IVoPtnhp/sgaa2t+x7BvA/BKeMxE0DGdtRJdEXotTc8DBmI7o2tkq6l8+HyFBGjQ/CjQ==} + /@walletconnect/types@2.9.2: + resolution: {integrity: sha512-7Rdn30amnJEEal4hk83cdwHUuxI1SWQ+K7fFFHBMqkuHLGi3tpMY6kpyfDxnUScYEZXqgRps4Jo5qQgnRqVM7A==} + dependencies: + '@walletconnect/events': 1.0.1 + '@walletconnect/heartbeat': 1.2.1 + '@walletconnect/jsonrpc-types': 1.0.3 + '@walletconnect/keyvaluestorage': 1.0.2 + '@walletconnect/logger': 2.0.1 + events: 3.3.0 + transitivePeerDependencies: + - '@react-native-async-storage/async-storage' + - lokijs + dev: false + + /@walletconnect/universal-provider@2.10.2: + resolution: {integrity: sha512-wFgI0LbQ3D56sgaUMsgOHCM5m8WLxiC71BGuCKQfApgsbNMVKugYVy2zWHyUyi8sqTQHI+uSaVpDev4UHq9LEw==} dependencies: '@walletconnect/jsonrpc-http-connection': 1.0.7 '@walletconnect/jsonrpc-provider': 1.0.13 '@walletconnect/jsonrpc-types': 1.0.3 '@walletconnect/jsonrpc-utils': 1.0.8 '@walletconnect/logger': 2.0.1 - '@walletconnect/sign-client': 2.9.0 - '@walletconnect/types': 2.9.0 - '@walletconnect/utils': 2.9.0 + '@walletconnect/sign-client': 2.10.2 + '@walletconnect/types': 2.10.2 + '@walletconnect/utils': 2.10.2 events: 3.3.0 transitivePeerDependencies: - '@react-native-async-storage/async-storage' @@ -13587,8 +13693,50 @@ packages: - utf-8-validate dev: false - /@walletconnect/utils@2.9.0: - resolution: {integrity: sha512-7Tu3m6dZL84KofrNBcblsgpSqU2vdo9ImLD7zWimLXERVGNQ8smXG+gmhQYblebIBhsPzjy9N38YMC3nPlfQNw==} + /@walletconnect/universal-provider@2.9.2: + resolution: {integrity: sha512-JmaolkO8D31UdRaQCHwlr8uIFUI5BYhBzqYFt54Mc6gbIa1tijGOmdyr6YhhFO70LPmS6gHIjljwOuEllmlrxw==} + dependencies: + '@walletconnect/jsonrpc-http-connection': 1.0.7 + '@walletconnect/jsonrpc-provider': 1.0.13 + '@walletconnect/jsonrpc-types': 1.0.3 + '@walletconnect/jsonrpc-utils': 1.0.8 + '@walletconnect/logger': 2.0.1 + '@walletconnect/sign-client': 2.9.2 + '@walletconnect/types': 2.9.2 + '@walletconnect/utils': 2.9.2 + events: 3.3.0 + transitivePeerDependencies: + - '@react-native-async-storage/async-storage' + - bufferutil + - encoding + - lokijs + - utf-8-validate + dev: false + + /@walletconnect/utils@2.10.2: + resolution: {integrity: sha512-syxXRpc2yhSknMu3IfiBGobxOY7fLfLTJuw+ppKaeO6WUdZpIit3wfuGOcc0Ms3ZPFCrGfyGOoZsCvgdXtptRg==} + dependencies: + '@stablelib/chacha20poly1305': 1.0.1 + '@stablelib/hkdf': 1.0.1 + '@stablelib/random': 1.0.2 + '@stablelib/sha256': 1.0.1 + '@stablelib/x25519': 1.0.3 + '@walletconnect/relay-api': 1.0.9 + '@walletconnect/safe-json': 1.0.2 + '@walletconnect/time': 1.0.2 + '@walletconnect/types': 2.10.2 + '@walletconnect/window-getters': 1.0.1 + '@walletconnect/window-metadata': 1.0.1 + detect-browser: 5.3.0 + query-string: 7.1.3 + uint8arrays: 3.1.1 + transitivePeerDependencies: + - '@react-native-async-storage/async-storage' + - lokijs + dev: false + + /@walletconnect/utils@2.9.2: + resolution: {integrity: sha512-D44hwXET/8JhhIjqljY6qxSu7xXnlPrf63UN/Qfl98vDjWlYVcDl2+JIQRxD9GPastw0S8XZXdRq59XDXLuZBg==} dependencies: '@stablelib/chacha20poly1305': 1.0.1 '@stablelib/hkdf': 1.0.1 @@ -13598,7 +13746,7 @@ packages: '@walletconnect/relay-api': 1.0.9 '@walletconnect/safe-json': 1.0.2 '@walletconnect/time': 1.0.2 - '@walletconnect/types': 2.9.0 + '@walletconnect/types': 2.9.2 '@walletconnect/window-getters': 1.0.1 '@walletconnect/window-metadata': 1.0.1 detect-browser: 5.3.0 @@ -13825,11 +13973,11 @@ packages: urlpattern-polyfill: 8.0.2 web-streams-polyfill: 3.2.1 - /@whatwg-node/fetch@0.9.13: - resolution: {integrity: sha512-PPtMwhjtS96XROnSpowCQM85gCUG2m7AXZFw0PZlGbhzx2GK7f2iOXilfgIJ0uSlCuuGbOIzfouISkA7C4FJOw==} + /@whatwg-node/fetch@0.9.14: + resolution: {integrity: sha512-wurZC82zzZwXRDSW0OS9l141DynaJQh7Yt0FD1xZ8niX7/Et/7RoiLiltbVU1fSF1RR9z6ndEaTUQBAmddTm1w==} engines: {node: '>=16.0.0'} dependencies: - '@whatwg-node/node-fetch': 0.4.19 + '@whatwg-node/node-fetch': 0.5.0 urlpattern-polyfill: 9.0.0 /@whatwg-node/node-fetch@0.3.6: @@ -13841,8 +13989,8 @@ packages: fast-url-parser: 1.1.3 tslib: 2.6.2 - /@whatwg-node/node-fetch@0.4.19: - resolution: {integrity: sha512-AW7/m2AuweAoSXmESrYQr/KBafueScNbn2iNO0u6xFr2JZdPmYsSm5yvAXYk6yDLv+eDmSSKrf7JnFZ0CsJIdA==} + /@whatwg-node/node-fetch@0.5.0: + resolution: {integrity: sha512-q76lDAafvHNGWedNAVHrz/EyYTS8qwRLcwne8SJQdRN5P3HydxU6XROFvJfTML6KZXQX2FDdGY4/SnaNyd7M0Q==} engines: {node: '>=16.0.0'} dependencies: '@whatwg-node/events': 0.1.1 @@ -13857,24 +14005,26 @@ packages: '@whatwg-node/fetch': 0.8.8 tslib: 2.6.2 - /@whatwg-node/server@0.9.15: - resolution: {integrity: sha512-MDmw3HYfZt8hzP8Vac/LPwD8LyZFByVuO1vHPBDsOMYNf4XWv6eHbRCk4UFfLT8OMFgd+qMy/zNYc74o+3tXZg==} + /@whatwg-node/server@0.9.16: + resolution: {integrity: sha512-gktQkRyONEw2EGpx7UZaC6zNlUm21CGlqAHQXU3QC6W0zlLM5ZQNDCeD66q/nsPHDV08X2NTHlABsuAEk5rh/w==} engines: {node: '>=16.0.0'} dependencies: - '@whatwg-node/fetch': 0.9.13 + '@whatwg-node/fetch': 0.9.14 tslib: 2.6.2 dev: false - /@wry/context@0.7.3: - resolution: {integrity: sha512-Nl8WTesHp89RF803Se9X3IiHjdmLBrIvPMaJkl+rKVJAYyPsz1TEUbu89943HpvujtSJgDUx9W4vZw3K1Mr3sA==} + /@wry/context@0.7.4: + resolution: {integrity: sha512-jmT7Sb4ZQWI5iyu3lobQxICu2nC/vbUhP0vIdd6tHC9PTfenmRmuIFqktc6GH9cgi+ZHnsLWPvfSvc4DrYmKiQ==} engines: {node: '>=8'} + requiresBuild: true dependencies: tslib: 2.6.2 dev: false - /@wry/equality@0.5.6: - resolution: {integrity: sha512-D46sfMTngaYlrH+OspKf8mIJETntFnf6Hsjb0V41jAXJ7Bx2kB8Rv8RCUujuVWYttFtHkUNp7g+FwxNQAr6mXA==} + /@wry/equality@0.5.7: + resolution: {integrity: sha512-BRFORjsTuQv5gxcXsuDXx6oGRhuVsEGwZy6LOzRRfgu+eSfxbhUQ9L9YtSEIuIjY/o7g3iWFjrc5eSY1GXP2Dw==} engines: {node: '>=8'} + requiresBuild: true dependencies: tslib: 2.6.2 dev: false @@ -13882,15 +14032,11 @@ packages: /@wry/trie@0.4.3: resolution: {integrity: sha512-I6bHwH0fSf6RqQcnnXLJKhkSXG45MFral3GxPaY4uAl0LYDZM+YDVDAiU9bYwjTuysy1S0IeecWtmq1SZA3M1w==} engines: {node: '>=8'} + requiresBuild: true dependencies: tslib: 2.6.2 dev: false - /@xmldom/xmldom@0.8.10: - resolution: {integrity: sha512-2WALfTl4xo2SkGCYRt6rDTFfk9R1czmBvUQy12gK2KuRKIpWEhcbbzy8EZXtz/jkRqHX8bFEc6FC1HjX4TUWYw==} - engines: {node: '>=10.0.0'} - dev: true - /@xobotyi/scrollbar-width@1.9.5: resolution: {integrity: sha512-N8tkAACJx2ww8vFMneJmaAgmjAG1tnVBZJRLRcx061tmsLRZHSEZSLuGWnwPtunsSLvSqXQ2wfp7Mgqg1I+2dQ==} dev: false @@ -13908,6 +14054,7 @@ packages: /@zxing/text-encoding@0.9.0: resolution: {integrity: sha512-U/4aVJ2mxI0aDNI8Uq0wEhMgY+u4CNtEb0om3+y3+niDAsoTCOB33UF0sxpzqzdqXLqmvc+vZyAt4O8pPdfkwA==} requiresBuild: true + dev: false optional: true /JSONStream@1.3.2: @@ -13933,6 +14080,21 @@ packages: resolution: {integrity: sha512-LEyx4aLEC3x6T0UguF6YILf+ntvmOaWsVfENmIW0E9H09vKlLDGelMjjSm0jkDHALj8A8quZ/HapKNigzwge+Q==} dev: true + /abitype@0.10.2(typescript@5.1.6)(zod@3.22.4): + resolution: {integrity: sha512-1XndI+RKFWK4+TXCNv1683MRyX5NGmlHXCvqzjOqhSS3PQrxT2QYRZq1bMPPRNjn89B3eVaM2w7y3jVj/OIUzA==} + peerDependencies: + typescript: '>=5.0.4' + zod: ^3 >=3.22.0 + peerDependenciesMeta: + typescript: + optional: true + zod: + optional: true + dependencies: + typescript: 5.1.6 + zod: 3.22.4 + dev: true + /abitype@0.8.7(typescript@5.1.6)(zod@3.22.4): resolution: {integrity: sha512-wQ7hV8Yg/yKmGyFpqrNZufCxbszDe5es4AZGYPBitocfSqXtjrTG9JMWFcc4N30ukl2ve48aBTwt7NJxVQdU3w==} peerDependencies: @@ -13945,8 +14107,8 @@ packages: typescript: 5.1.6 zod: 3.22.4 - /abitype@0.9.3(typescript@5.1.6)(zod@3.22.4): - resolution: {integrity: sha512-dz4qCQLurx97FQhnb/EIYTk/ldQ+oafEDUqC0VVIeQS1Q48/YWt/9YNfMmp9SLFqN41ktxny3c8aYxHjmFIB/w==} + /abitype@0.9.8(typescript@5.1.6)(zod@3.22.4): + resolution: {integrity: sha512-puLifILdm+8sjyss4S+fsUN09obiT1g2YW6CtcQF+QDzxR0euzgEB29MZujC6zMk2a6SVmtttq1fc6+YFA7WYQ==} peerDependencies: typescript: '>=5.0.4' zod: ^3 >=3.19.1 @@ -14054,7 +14216,6 @@ packages: acorn: ^6.0.0 || ^7.0.0 || ^8.0.0 dependencies: acorn: 8.10.0 - dev: true /acorn-walk@8.2.0: resolution: {integrity: sha512-k+iyHEuPgSw6SbuDpGQM+06HQUa04DZ3o+F6CSzXMvvI5KMvnaEqXe+YVe555R9nn6GPt404fos4wcgpw12SDA==} @@ -14080,6 +14241,9 @@ packages: resolution: {integrity: sha512-e5pEa2kBnBOgR4Y/p20pskXI74UEz7de8ZGVo58asOtvSVG5YAbJeELPZxOmt+Bnz3rX753YKhfIn4X4l1PPRQ==} dev: false + /aes-js@4.0.0-beta.5: + resolution: {integrity: sha512-G965FqalsNyrPqgEGON7nIx1e/OVENSgiEIzyC63haUMuvNnwIgIjMs52hlTCKhkBny7A2ORNlfY9Zu+jmGk1Q==} + /agent-base@6.0.2: resolution: {integrity: sha512-RZNwNclF7+MS/8bDg70amg32dyeZGZxiDuQmZxKLAlQjr3jGyLx+4Kkk58UO7D2QdgFIQCovuSuZESne6RG6XQ==} engines: {node: '>= 6.0.0'} @@ -14156,8 +14320,8 @@ packages: require-from-string: 2.0.2 uri-js: 4.4.1 - /algoliasearch-helper@3.14.2(algoliasearch@4.20.0): - resolution: {integrity: sha512-FjDSrjvQvJT/SKMW74nPgFpsoPUwZCzGbCqbp8HhBFfSk/OvNFxzCaCmuO0p7AWeLy1gD+muFwQEkBwcl5H4pg==} + /algoliasearch-helper@3.15.0(algoliasearch@4.20.0): + resolution: {integrity: sha512-DGUnK3TGtDQsaUE4ayF/LjSN0DGsuYThB8WBgnnDY0Wq04K6lNVruO3LfqJOgSfDiezp+Iyt8Tj4YKHi+/ivSA==} peerDependencies: algoliasearch: '>= 3.1 < 6' dependencies: @@ -14407,10 +14571,12 @@ packages: /array-back@3.1.0: resolution: {integrity: sha512-TkuxA4UCOvxuDK6NZYXCalszEzj+TLszyASooky+i742l9TqsOdYCMJJupxRic61hwquNtppB3hgcuq9SVSH1Q==} engines: {node: '>=6'} + dev: true /array-back@4.0.2: resolution: {integrity: sha512-NbdMezxqf94cnNfWLL7V/im0Ub+Anbb0IoZhvzie8+4HJ4nMQuzHuy49FkGYCJK2yAloZ3meiB6AVMClbrI1vg==} engines: {node: '>=8'} + dev: true /array-buffer-byte-length@1.0.0: resolution: {integrity: sha512-LPuwb2P+NrQw3XhxGc36+XSvuBPopovXYTR9Ew++Du9Yb/bx5AzBfrIsBoj0EZUifjQU+sHL21sseZ3jerWO/A==} @@ -14675,7 +14841,7 @@ packages: postcss: ^8.1.0 dependencies: browserslist: 4.22.1 - caniuse-lite: 1.0.30001553 + caniuse-lite: 1.0.30001554 fraction.js: 4.3.7 normalize-range: 0.1.2 picocolors: 1.0.0 @@ -14781,6 +14947,7 @@ packages: slash: 3.0.0 transitivePeerDependencies: - supports-color + dev: true /babel-loader@8.3.0(@babel/core@7.23.2)(webpack@5.89.0): resolution: {integrity: sha512-H8SvsMF+m9t15HNLMipppzkC+Y2Yq+v3SonZyU70RBL/h1gxPkH08Ot8pEE9Z4Kd+czyWJClmFS8qzIP9OZ04Q==} @@ -14843,6 +15010,7 @@ packages: test-exclude: 6.0.0 transitivePeerDependencies: - supports-color + dev: true /babel-plugin-jest-hoist@29.6.3: resolution: {integrity: sha512-ESAc/RJvGTFEzRwOTT4+lNDk/GNHMkKbNzsvT0qKRfDyyYTskxB5rnU2njIDYVxXCBHHEI1c0YwHob3WaYujOg==} @@ -14852,6 +15020,7 @@ packages: '@babel/types': 7.23.0 '@types/babel__core': 7.20.3 '@types/babel__traverse': 7.20.3 + dev: true /babel-plugin-macros@3.1.0: resolution: {integrity: sha512-Cg7TFGpIr01vOQNODXOOaGz2NpCU5gl8x1qJFbb6hbZxR7XrcE2vtbAsTAbJ7/xwJtUuJEw8K8Zr/AE0LHlesg==} @@ -14952,6 +15121,7 @@ packages: '@babel/plugin-syntax-optional-catch-binding': 7.8.3(@babel/core@7.23.2) '@babel/plugin-syntax-optional-chaining': 7.8.3(@babel/core@7.23.2) '@babel/plugin-syntax-top-level-await': 7.14.5(@babel/core@7.23.2) + dev: true /babel-preset-fbjs@3.4.0(@babel/core@7.23.2): resolution: {integrity: sha512-9ywCsCvo1ojrw0b+XYk7aFvTH6D9064t0RIL1rtMf3nsa02Xw41MS7sZw216Im35xj/UY0PDBQsa1brUDDF1Ow==} @@ -14996,6 +15166,7 @@ packages: '@babel/core': 7.23.2 babel-plugin-jest-hoist: 29.6.3 babel-preset-current-node-syntax: 1.0.1(@babel/core@7.23.2) + dev: true /babel-runtime@6.26.0: resolution: {integrity: sha512-ITKNuq2wKlW1fJg9sSW52eepoYgZBggvOAHC0u/CYu/qxQ9EVzThCgR69BnSXLHjy2f7SY5zaQ4yt7H9ZVxY2g==} @@ -15080,7 +15251,6 @@ packages: /bignumber.js@9.1.2: resolution: {integrity: sha512-2/mKyZH9K85bzOEfhXDBFZTGd1CTs+5IHpeFQo9luiBG7hghdC851Pj2WAhb6E3R6b9tZj/XKhbg4fum+Kepug==} - dev: true /binary-extensions@2.2.0: resolution: {integrity: sha512-jDctJ/IVQbZoJykoeHbhXpOlNBqGNcwXJKJog42E5HDPUwQTSdjCHdihjj0DlnheQ7blbT6dHOafNAiS8ooQKA==} @@ -15367,8 +15537,8 @@ packages: engines: {node: ^6 || ^7 || ^8 || ^9 || ^10 || ^11 || ^12 || >=13.7} hasBin: true dependencies: - caniuse-lite: 1.0.30001553 - electron-to-chromium: 1.4.564 + caniuse-lite: 1.0.30001554 + electron-to-chromium: 1.4.567 node-releases: 2.0.13 update-browserslist-db: 1.0.13(browserslist@4.22.1) @@ -15462,6 +15632,11 @@ packages: dependencies: node-gyp-build: 4.6.1 + /bufio@1.2.1: + resolution: {integrity: sha512-9oR3zNdupcg/Ge2sSHQF3GX+kmvL/fTPvD0nd5AGLq8SjUYnTz+SlFjK/GXidndbZtIj+pVKXiWeR9w6e9wKCA==} + engines: {node: '>=14.0.0'} + dev: true + /builtin-modules@3.3.0: resolution: {integrity: sha512-zhaCDicdLuWN5UbN5IMnFqNMhNfo919sH85y2/ea+5Yg9TsTkeZxpL+JLbp6cgYFS4sRLp3YV4S6yDuqVWHYOw==} engines: {node: '>=6'} @@ -15627,13 +15802,13 @@ packages: resolution: {integrity: sha512-bsTwuIg/BZZK/vreVTYYbSWoe2F+71P7K5QGEX+pT250DZbfU1MQ5prOKpPR+LL6uWKK3KMwMCAS74QB3Um1uw==} dependencies: browserslist: 4.22.1 - caniuse-lite: 1.0.30001553 + caniuse-lite: 1.0.30001554 lodash.memoize: 4.1.2 lodash.uniq: 4.5.0 dev: false - /caniuse-lite@1.0.30001553: - resolution: {integrity: sha512-N0ttd6TrFfuqKNi+pMgWJTb9qrdJu4JSpgPFLe/lrD19ugC6fZgF0pUewRowDwzdDnb9V41mFcdlYgl/PyKf4A==} + /caniuse-lite@1.0.30001554: + resolution: {integrity: sha512-A2E3U//MBwbJVzebddm1YfNp7Nud5Ip+IPn4BozBmn4KqVX7AvluoIDFWjsv5OkGnKUXQVmMSoMKLa3ScCblcQ==} /capital-case@1.0.4: resolution: {integrity: sha512-ds37W8CytHgwnhGGTi88pcPyR15qoNkOpYwmMMfnWqqWgESapLqvDx6huFjQ5vqWSn2Z06173XNA7LtMOeUh1A==} @@ -15689,8 +15864,8 @@ packages: resolution: {integrity: sha512-b3tFPA9pUr2zCUiCfRd2+wok2/LBSNUMKOuRRok+WlvvAgEt/PlbgPTsZUcwCOs53IJvLgTp0eotwtosE6njug==} hasBin: true - /cborg@4.0.4: - resolution: {integrity: sha512-nu+JXYskYqWN/tFWQVjL2ZYlUwK+dapqkTpruAtJkwmDv7XaTgg8PStUbO+sXfhqSWaeQ9LPSPCTrO2WZ2Bxfg==} + /cborg@4.0.5: + resolution: {integrity: sha512-q8TAjprr8pn9Fp53rOIGp/UFDdFY6os2Nq62YogPSIzczJD9M6g2b6igxMkpCiZZKJ0kn/KzDLDvG+EqBIEeCg==} hasBin: true dev: false @@ -15823,6 +15998,7 @@ packages: /char-regex@1.0.2: resolution: {integrity: sha512-kWWXztvZ5SBQV+eRgKFeh8q5sLuZY2+8WUIzlxWVTg+oGwY14qylx1KbKzHd8P6ZYkAg0xyIDU9JMHhyJMZ1jw==} engines: {node: '>=10'} + dev: true /character-entities-legacy@1.1.4: resolution: {integrity: sha512-3Xnr+7ZFS1uxeiUDvV02wQ+QDbc55o97tIV5zHScSPJpcLm/r0DFPcoY3tYRp+VZukxuMeKgXYmsXQHO05zQeA==} @@ -15925,6 +16101,7 @@ packages: /cjs-module-lexer@1.2.3: resolution: {integrity: sha512-0TNiGstbQmCFwt4akjjBg5pLRTSyj/PkWQ1ZoO2zntmg9yLqSRxwEa4iCfQLGjqhiqBfOJa7W/E8wfGrTDmlZQ==} + dev: true /class-is@1.1.0: resolution: {integrity: sha512-rhjH9AG1fvabIDoGRVH587413LPjTZgmDF9fOFCbFJQV4yuocX1mHxxvXI4g3cGwbVY9wAYIoKlg1N79frJKQw==} @@ -16144,6 +16321,7 @@ packages: /co@4.6.0: resolution: {integrity: sha512-QVb0dM5HvG+uaxitm8wONl7jltx8dqhfU33DcqtOZcLSVIKSDDLDi7+0LbAKiyI8hD9u42m2YxXSkMGWThaecQ==} engines: {iojs: '>= 1.0.0', node: '>= 0.12.0'} + dev: true /code-point-at@1.1.0: resolution: {integrity: sha512-RpAVKQA5T63xEj6/giIbUEtZwJ4UFIc3ZtvEkiaUERylqe8xb5IvqcgOurZLahv93CLKfxcw5YI+DZcUBRyLXA==} @@ -16156,6 +16334,7 @@ packages: /collect-v8-coverage@1.0.2: resolution: {integrity: sha512-lHl4d5/ONEbLlJvaJNtsF/Lz+WvB07u2ycqTYbdrq7UypDXailES4valYb2eWiJFxZlVmpGekfqoxQhzyFdT4Q==} + dev: true /color-convert@1.9.3: resolution: {integrity: sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==} @@ -16219,6 +16398,7 @@ packages: find-replace: 3.0.0 lodash.camelcase: 4.3.0 typical: 4.0.0 + dev: true /command-line-usage@6.1.3: resolution: {integrity: sha512-sH5ZSPr+7UStsloltmDh7Ce5fb8XPlHyoPzTpyyMuYCtervL65+ubVZ6Q61cFtFl62UyJlc8/JwERRbAFPUqgw==} @@ -16228,6 +16408,7 @@ packages: chalk: 2.4.2 table-layout: 1.0.2 typical: 5.2.0 + dev: true /commander@10.0.1: resolution: {integrity: sha512-y4Mg2tXshplEbSGzx7amzPwKKOCGuoSRP/CjEdwwk0FOGlUbq6lKuoyDZTNZkmxHdJtp54hdfY/JUrdL7Xfdug==} @@ -16274,13 +16455,13 @@ packages: resolution: {integrity: sha512-KRs7WVDKg86PWiuAqhDrAQnTXZKraVcCc6vFdL14qrZ/DcWwuRo7VoiYXalXO7S5GKpqYiVEwCbgFDfxNHKJBQ==} engines: {node: ^12.20.0 || >=14} - /commitizen@4.3.0: + /commitizen@4.3.0(typescript@4.9.5): resolution: {integrity: sha512-H0iNtClNEhT0fotHvGV3E9tDejDeS04sN1veIebsKYGMuGscFaswRoYJKmT3eW85eIJAs0F28bG2+a/9wCOfPw==} engines: {node: '>= 12'} hasBin: true dependencies: cachedir: 2.3.0 - cz-conventional-changelog: 3.3.0 + cz-conventional-changelog: 3.3.0(typescript@4.9.5) dedent: 0.7.0 detect-indent: 6.1.0 find-node-modules: 2.1.3 @@ -16294,8 +16475,7 @@ packages: strip-bom: 4.0.0 strip-json-comments: 3.1.1 transitivePeerDependencies: - - '@swc/core' - - '@swc/wasm' + - typescript dev: true /common-path-prefix@3.0.0: @@ -16456,7 +16636,7 @@ packages: resolution: {integrity: sha512-yCEafptTtb4bk7GLEQoM8KVJpxAfdBJYaXyzQEgQQQgYrZiDp8SJmGKlYza6CYjEDNstAdNdKA3UuoULlEbS6w==} engines: {node: '>=12.13'} dependencies: - is-what: 4.1.15 + is-what: 4.1.16 dev: false /copy-text-to-clipboard@3.2.0: @@ -16485,19 +16665,6 @@ packages: webpack: 5.89.0(webpack-cli@5.1.4) dev: false - /copyfiles@2.4.1: - resolution: {integrity: sha512-fereAvAvxDrQDOXybk3Qu3dPbOoKoysFMWtkY3mv5BsL8//OSZVL5DCLYqgRfY5cWirgRzlC+WSrxp6Bo3eNZg==} - hasBin: true - dependencies: - glob: 7.2.3 - minimatch: 3.1.2 - mkdirp: 1.0.4 - noms: 0.0.0 - through2: 2.0.5 - untildify: 4.0.0 - yargs: 16.2.0 - dev: true - /core-js-compat@3.33.1: resolution: {integrity: sha512-6pYKNOgD/j/bkC5xS5IIg6bncid3rfrI42oBH1SQJbsmYPKF7rhzcFzYCcxYMmNQQ0rCEB8WqpW7QHndOggaeQ==} dependencies: @@ -16536,7 +16703,7 @@ packages: layout-base: 2.0.1 dev: false - /cosmiconfig-typescript-loader@4.4.0(@types/node@18.18.6)(cosmiconfig@8.3.6)(ts-node@10.9.1)(typescript@5.2.2): + /cosmiconfig-typescript-loader@4.4.0(@types/node@20.5.1)(cosmiconfig@8.3.6)(ts-node@10.9.1)(typescript@4.9.5): resolution: {integrity: sha512-BabizFdC3wBHhbI4kJh0VkQP9GkBfoHPydD0COMce1nJ1kJAB3F2TmJ/I7diULBKtmEWSwEbuN/KDtgnmUUVmw==} engines: {node: '>=v14.21.3'} peerDependencies: @@ -16545,27 +16712,27 @@ packages: ts-node: '>=10' typescript: '>=4' dependencies: - '@types/node': 18.18.6 - cosmiconfig: 8.3.6(typescript@5.2.2) - ts-node: 10.9.1(@types/node@18.18.6)(typescript@5.2.2) - typescript: 5.2.2 + '@types/node': 20.5.1 + cosmiconfig: 8.3.6(typescript@4.9.5) + ts-node: 10.9.1(@types/node@20.5.1)(typescript@4.9.5) + typescript: 4.9.5 dev: true - optional: true - /cosmiconfig-typescript-loader@4.4.0(@types/node@20.5.1)(cosmiconfig@8.3.6)(ts-node@10.9.1)(typescript@4.9.5): - resolution: {integrity: sha512-BabizFdC3wBHhbI4kJh0VkQP9GkBfoHPydD0COMce1nJ1kJAB3F2TmJ/I7diULBKtmEWSwEbuN/KDtgnmUUVmw==} - engines: {node: '>=v14.21.3'} + /cosmiconfig-typescript-loader@5.0.0(@types/node@18.18.7)(cosmiconfig@8.3.6)(typescript@4.9.5): + resolution: {integrity: sha512-+8cK7jRAReYkMwMiG+bxhcNKiHJDM6bR9FD/nGBXOWdMLuYawjF5cGrtLilJ+LGd3ZjCXnJjR5DkfWPoIVlqJA==} + engines: {node: '>=v16'} + requiresBuild: true peerDependencies: '@types/node': '*' - cosmiconfig: '>=7' - ts-node: '>=10' + cosmiconfig: '>=8.2' typescript: '>=4' dependencies: - '@types/node': 20.5.1 + '@types/node': 18.18.7 cosmiconfig: 8.3.6(typescript@4.9.5) - ts-node: 10.9.1(@types/node@20.5.1)(typescript@4.9.5) + jiti: 1.20.0 typescript: 4.9.5 dev: true + optional: true /cosmiconfig@5.2.1: resolution: {integrity: sha512-H65gsXo1SKjf8zmrJ67eJk8aIRKV5ff2D4uKZIBZShbhGSpEmsQOPW/SKMKYhSTrqR7ufy6RP69rPogdaPh/kA==} @@ -16639,23 +16806,6 @@ packages: path-type: 4.0.0 typescript: 5.1.6 - /cosmiconfig@8.3.6(typescript@5.2.2): - resolution: {integrity: sha512-kcZ6+W5QzcJ3P1Mt+83OUv/oHFqZHIx8DuxG6eZ5RGMERoLqp4BuGjhHLYGK+Kf5XVkQvqBSmAy/nGWN3qDgEA==} - engines: {node: '>=14'} - peerDependencies: - typescript: '>=4.9.5' - peerDependenciesMeta: - typescript: - optional: true - dependencies: - import-fresh: 3.3.0 - js-yaml: 4.1.0 - parse-json: 5.2.0 - path-type: 4.0.0 - typescript: 5.2.2 - dev: true - optional: true - /crc-32@1.2.2: resolution: {integrity: sha512-ROmzCKrTnOwybPcJApAA6WBWij23HVfGVNKqqrZpuyZOHqK2CwHSvpGuyt/UNNvaIjEd8X5IFGp4Mh+Ie1IHJQ==} engines: {node: '>=0.8'} @@ -16680,7 +16830,7 @@ packages: safe-buffer: 5.2.1 sha.js: 2.4.11 - /create-jest@29.7.0(@types/node@18.18.6)(ts-node@10.9.1): + /create-jest@29.7.0(@types/node@18.18.7)(ts-node@10.9.1): resolution: {integrity: sha512-Adz2bdH0Vq3F53KEMJOoftQFutWCukm6J24wbPWRO4k1kMY7gS7ds/uoJkNuV8wDCtWWnuwGcJwpWcih+zEW1Q==} engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} hasBin: true @@ -16689,7 +16839,7 @@ packages: chalk: 4.1.2 exit: 0.1.2 graceful-fs: 4.2.11 - jest-config: 29.7.0(@types/node@18.18.6)(ts-node@10.9.1) + jest-config: 29.7.0(@types/node@18.18.7)(ts-node@10.9.1) jest-util: 29.7.0 prompts: 2.4.2 transitivePeerDependencies: @@ -16697,6 +16847,7 @@ packages: - babel-plugin-macros - supports-color - ts-node + dev: true /create-require@1.1.1: resolution: {integrity: sha512-dcKFX3jn0MpIaXjisoRvexIJVEKzaq7z2rZKxf+MSr9TkdmHmsU4m2lcLojrj/FHl8mk5VxMmYA+ftRkP/3oKQ==} @@ -17036,21 +17187,20 @@ packages: lodash: 4.17.21 dev: false - /cz-conventional-changelog@3.3.0: + /cz-conventional-changelog@3.3.0(typescript@4.9.5): resolution: {integrity: sha512-U466fIzU5U22eES5lTNiNbZ+d8dfcHcssH4o7QsdWaCcRs/feIPCxKYSWkYBNs5mny7MvEfwpTLWjvbm94hecw==} engines: {node: '>= 10'} dependencies: chalk: 2.4.2 - commitizen: 4.3.0 + commitizen: 4.3.0(typescript@4.9.5) conventional-commit-types: 3.0.0 lodash.map: 4.6.0 longest: 2.0.1 word-wrap: 1.2.5 optionalDependencies: - '@commitlint/load': 18.0.0 + '@commitlint/load': 18.2.0(typescript@4.9.5) transitivePeerDependencies: - - '@swc/core' - - '@swc/wasm' + - typescript dev: true /d3-array@3.2.4: @@ -17573,6 +17723,7 @@ packages: peerDependenciesMeta: babel-plugin-macros: optional: true + dev: true /deep-eql@4.1.3: resolution: {integrity: sha512-WaEtAOpRA1MQ0eohqZjpGD8zdI0Ovsm8mmFhaDN8dvDZzyoUMcYDnf5Y6iu7HTXxf8JDS23qWa4a+hKCDyOPzw==} @@ -17610,7 +17761,6 @@ packages: /deep-is@0.1.4: resolution: {integrity: sha512-oIPzksmTg4/MriiaYGO+okXDT7ztn/w3Eptv/+gSIdMdKsJo0u4CfYNFJPy+4SKMuCqGw2wxnA+URMg3t8a/bQ==} - dev: true /deep-object-diff@1.1.9: resolution: {integrity: sha512-Rn+RuwkmkDwCi2/oXOFS9Gsr5lJZu/yTGpK7wAaAIE75CC+LCGEZHpY6VQJa/RoJcrmaA/docWJZvYohlNkWPA==} @@ -17779,6 +17929,7 @@ packages: /detect-newline@3.1.0: resolution: {integrity: sha512-TLz+x/vEXm/Y7P7wn1EJFNLxYpUD4TgMosxY6fAVJUnJMbupHBOncxyWUG9OpTaH9EBD7uFI5LfEgmMOc54DsA==} engines: {node: '>=8'} + dev: true /detect-node-es@1.1.0: resolution: {integrity: sha512-ypdmJU/TbBby2Dxibuv7ZLW3Bs1QEmM7nHjEANfohJLvE0XVujisn1qPJcZxg+qDucsr+bP6fLD1rPS3AhJ7EQ==} @@ -17810,6 +17961,7 @@ packages: /diff-sequences@29.6.3: resolution: {integrity: sha512-EjePK1srD3P08o2j4f0ExnylqRs5B9tJjcp9t1krH2qRi8CCdsYfwe9JgSLurFBWwq4uOlipzfk5fHNvwFKr8Q==} engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} + dev: true /diff@3.5.0: resolution: {integrity: sha512-A46qtFgd+g7pDZinpnwiRJtxbC1hpgf0uzP3iG89scHk0AUC7A1TGxf5OiiOUv/JMZR8GOt8hL900hV0bOy5xA==} @@ -17927,7 +18079,6 @@ packages: engines: {node: '>=6.0.0'} dependencies: esutils: 2.0.3 - dev: true /docusaurus-plugin-remote-content@3.1.0(@docusaurus/core@2.4.3): resolution: {integrity: sha512-859WYmC75l9hRYa1f/2FNF+FLcKbkHCM/0dehN1Wl1fIuoFzEPf3tcWs4jcEobRHYnoMjyupqAhmu0q5j3JoIg==} @@ -17935,7 +18086,7 @@ packages: peerDependencies: '@docusaurus/core': 2.x dependencies: - '@docusaurus/core': 2.4.3(@docusaurus/types@2.4.3)(react-dom@18.2.0)(react@18.2.0)(typescript@4.9.5) + '@docusaurus/core': 2.4.3(@docusaurus/types@2.4.3)(eslint@8.52.0)(react-dom@18.2.0)(react@18.2.0)(typescript@4.9.5) axios: 0.26.1 picocolors: 1.0.0 pretty-ms: 7.0.1 @@ -18064,8 +18215,8 @@ packages: pify: 4.0.1 dev: true - /dset@3.1.2: - resolution: {integrity: sha512-g/M9sqy3oHe477Ar4voQxWtaPIFw1jTdKZuomOjhCcBx9nHUNn0pu6NopuFFrTh/TRZIKEj+76vLWFu9BNKk+Q==} + /dset@3.1.3: + resolution: {integrity: sha512-20TuZZHCEZ2O71q9/+8BwKwZ0QtD9D8ObhrihJPr+vLLYlSuAU3/zL4cSlgbfeoGHTjCSJBa7NGcrF9/Bx/WJQ==} engines: {node: '>=4'} /duplexer3@0.1.5: @@ -18119,8 +18270,8 @@ packages: dependencies: encoding: 0.1.13 - /electron-to-chromium@1.4.564: - resolution: {integrity: sha512-bGAx9+teIzL5I4esQwCMtiXtb78Ysc8xOKTPOvmafbJZ4SQ40kDO1ym3yRcGSkfaBtV81fGgHOgPoe6DsmpmkA==} + /electron-to-chromium@1.4.567: + resolution: {integrity: sha512-8KR114CAYQ4/r5EIEsOmOMqQ9j0MRbJZR3aXD/KFA8RuKzyoUB4XrUCg+l8RUGqTVQgKNIgTpjaG8YHRPAbX2w==} /elkjs@0.8.2: resolution: {integrity: sha512-L6uRgvZTH+4OF5NE/MBbzQx/WYpru1xCBE9respNj6qznEewGUIfhzmm7horWWxbNO2M0WckQypGctR8lH79xQ==} @@ -18149,6 +18300,7 @@ packages: /emittery@0.13.1: resolution: {integrity: sha512-DeWwawk6r5yR9jFgnDKYt4sLS0LmHJJi3ZOnb5/JdbYwj3nW+FxQnHIjhBKz8YLC7oRNPVM9NQ47I3CVx34eqQ==} engines: {node: '>=12'} + dev: true /emoji-regex@8.0.0: resolution: {integrity: sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==} @@ -18807,7 +18959,6 @@ packages: dependencies: esrecurse: 4.3.0 estraverse: 5.3.0 - dev: true /eslint-utils@3.0.0(eslint@8.19.0): resolution: {integrity: sha512-uuQC43IGctw68pJA1RgbQS8/NP7rch6Cwd4j3ZBtgo4/8Flj4eGE7ZYSZRN3iq5pVUv6GPdW5Z1RFleo84uLDA==} @@ -18827,7 +18978,6 @@ packages: /eslint-visitor-keys@3.4.3: resolution: {integrity: sha512-wpc+LXeiyiisxPlEkUzU6svyS1frIO3Mgxj1fdy7Pm8Ygzguax2N3Fa/D/ag1WqbOprdI+uY6wMUl8/a2G+iag==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} - dev: true /eslint@8.19.0: resolution: {integrity: sha512-SXOPj3x9VKvPe81TjjUJCYlV4oJjQw68Uek+AM0X4p+33dj2HY5bpTZOgnQHcG2eAm1mtCU9uNMnJi7exU/kYw==} @@ -18879,7 +19029,7 @@ packages: hasBin: true dependencies: '@eslint-community/eslint-utils': 4.4.0(eslint@8.52.0) - '@eslint-community/regexpp': 4.9.1 + '@eslint-community/regexpp': 4.10.0 '@eslint/eslintrc': 2.1.2 '@eslint/js': 8.52.0 '@humanwhocodes/config-array': 0.11.13 @@ -18918,7 +19068,6 @@ packages: text-table: 0.2.0 transitivePeerDependencies: - supports-color - dev: true /espree@9.6.1: resolution: {integrity: sha512-oruZaFkjorTpF32kDSI5/75ViwGeZginGGy2NoOSg3Q9bnwlnmDm4HLnkl0RE3n+njDXR037aY1+x58Z/zFdwQ==} @@ -18927,7 +19076,6 @@ packages: acorn: 8.10.0 acorn-jsx: 5.3.2(acorn@8.10.0) eslint-visitor-keys: 3.4.3 - dev: true /esprima@2.7.3: resolution: {integrity: sha512-OarPfz0lFCiW4/AV2Oy1Rp9qu0iusTKqykwTspGCZtPxmF81JR4MmIebvF1F9+UOKth2ZubLQ4XGGaU+hSn99A==} @@ -18945,7 +19093,6 @@ packages: engines: {node: '>=0.10'} dependencies: estraverse: 5.3.0 - dev: true /esrecurse@4.3.0: resolution: {integrity: sha512-KmfKL3b6G+RXvP8N1vr3Tq1kL/oCFgn2NYXEtqP8/L3pKapUA4G8cFVaoF3SU323CD4XypR/ffioHmkti6/Tag==} @@ -19056,6 +19203,12 @@ packages: fast-safe-stringify: 2.1.1 dev: false + /eth-rpc-errors@4.0.3: + resolution: {integrity: sha512-Z3ymjopaoft7JDoxZcEb3pwdGh7yiYMhOwm2doUt6ASXlMavpNlK6Cre0+IMl2VSGyEU9rkiperQhp5iRxn5Pg==} + dependencies: + fast-safe-stringify: 2.1.1 + dev: false + /ethereum-bloom-filters@1.0.10: resolution: {integrity: sha512-rxJ5OFN3RwjQxDcFP2Z5+Q9ho4eIdEmSc2ht0fCu8Se9nbXjZ7/031uXoUYJ87KHCOdVeiUuwSnoS7hmYAGVHA==} dependencies: @@ -19098,20 +19251,20 @@ packages: '@scure/bip39': 1.2.1 dev: true - /ethereum-waffle@4.0.10(@ensdomains/ens@0.4.5)(@ensdomains/resolver@0.2.4)(@ethersproject/abi@5.7.0)(@ethersproject/providers@5.7.2)(ethers@5.7.2)(typescript@4.9.5): + /ethereum-waffle@4.0.10(@ensdomains/ens@0.4.5)(@ensdomains/resolver@0.2.4)(@ethersproject/abi@5.7.0)(@ethersproject/providers@5.7.2)(ethers@5.7.2)(typescript@5.1.6): resolution: {integrity: sha512-iw9z1otq7qNkGDNcMoeNeLIATF9yKl1M8AIeu42ElfNBplq0e+5PeasQmm8ybY/elkZ1XyRO0JBQxQdVRb8bqQ==} engines: {node: '>=10.0'} hasBin: true peerDependencies: - ethers: ^5.7.2 + ethers: '*' dependencies: '@ethereum-waffle/chai': 4.0.10(@ensdomains/ens@0.4.5)(@ensdomains/resolver@0.2.4)(ethers@5.7.2) - '@ethereum-waffle/compiler': 4.0.3(@ethersproject/abi@5.7.0)(@ethersproject/providers@5.7.2)(ethers@5.7.2)(solc@0.8.15)(typechain@8.3.2)(typescript@4.9.5) + '@ethereum-waffle/compiler': 4.0.3(@ethersproject/abi@5.7.0)(@ethersproject/providers@5.7.2)(ethers@5.7.2)(solc@0.8.15)(typechain@8.3.2)(typescript@5.1.6) '@ethereum-waffle/mock-contract': 4.0.4(ethers@5.7.2) '@ethereum-waffle/provider': 4.0.5(@ensdomains/ens@0.4.5)(@ensdomains/resolver@0.2.4)(ethers@5.7.2) ethers: 5.7.2 solc: 0.8.15 - typechain: 8.3.2(typescript@4.9.5) + typechain: 8.3.2(typescript@5.1.6) transitivePeerDependencies: - '@ensdomains/ens' - '@ensdomains/resolver' @@ -19199,6 +19352,21 @@ packages: - bufferutil - utf-8-validate + /ethers@6.8.0: + resolution: {integrity: sha512-zrFbmQRlraM+cU5mE4CZTLBurZTs2gdp2ld0nG/f3ecBK+x6lZ69KSxBqZ4NjclxwfTxl5LeNufcBbMsTdY53Q==} + engines: {node: '>=14.0.0'} + dependencies: + '@adraffy/ens-normalize': 1.10.0 + '@noble/curves': 1.2.0 + '@noble/hashes': 1.3.2 + '@types/node': 18.15.13 + aes-js: 4.0.0-beta.5 + tslib: 2.4.0 + ws: 8.5.0 + transitivePeerDependencies: + - bufferutil + - utf-8-validate + /etherscan-api@10.3.0(debug@4.3.4): resolution: {integrity: sha512-XH+E7J2c6Wq750stvFuIIMdiLv5v65nTRftQojXuQXNfEsQaZOOgeY11WHdrGh6yh90ekDJQldgf033tIS1rCw==} dependencies: @@ -19228,7 +19396,7 @@ packages: resolution: {integrity: sha512-EzV94NYKoO09GLXGjXj9JIlXijVck4ONSr5wiCWDvhsvj5jxSrzTmRU/9C1DyB6uToszLs8aifA6NQ7lEQdvFw==} engines: {node: '>= 0.8'} dependencies: - '@types/node': 18.18.6 + '@types/node': 18.18.7 require-like: 0.1.2 dev: false @@ -19335,6 +19503,7 @@ packages: /exit@0.1.2: resolution: {integrity: sha512-Zk/eNKV2zbjpKzrsQ+n1G6poVbErQxJ0LBOJXaKZ1EViLzH+hrLu9cdXI4zw9dBQJslwBEpbQ2P1oS7nDxs6jQ==} engines: {node: '>= 0.8.0'} + dev: true /expand-tilde@2.0.2: resolution: {integrity: sha512-A5EmesHW6rfnZ9ysHQjPdJRni0SRar0tjtG5MNtm9n5TUvsYU8oozprtRD4AqHxcZWWlVuAmQo2nWKfN9oyjTw==} @@ -19352,6 +19521,7 @@ packages: jest-matcher-utils: 29.7.0 jest-message-util: 29.7.0 jest-util: 29.7.0 + dev: true /express@4.18.2: resolution: {integrity: sha512-5/PsL6iGPdfQ/lKM1UuielYgv3BUoJfz1aUwU9vHZ+J7gyvwdQXFEBIEIaxeGf0GIcreATNyBExtalisDbuMqQ==} @@ -19503,7 +19673,6 @@ packages: /fast-levenshtein@2.0.6: resolution: {integrity: sha512-DCXu6Ifhqcks7TZKY3Hxp3y6qphY5SJZmrWMDrKcERSOXWQdMhU9Ig/PYrzyw/ul9jOIyh0N4M0tbC5hodg8dw==} - dev: true /fast-levenshtein@3.0.0: resolution: {integrity: sha512-hKKNajm46uNmTlhHSyZkmToAc56uZJwYq7yrciZjqOxnlfQwERDQJmHPUp7m1m9wx8vgOe8IaCKZ5Kv2k1DdCQ==} @@ -19648,7 +19817,6 @@ packages: engines: {node: ^10.12.0 || >=12.0.0} dependencies: flat-cache: 3.1.1 - dev: true /file-loader@6.2.0(webpack@5.89.0): resolution: {integrity: sha512-qo3glqyTa61Ytg4u73GultjHGjdRyig3tG6lPtyX/jOEJvHif9uB0/OCI2Kif6ctF3caQTW2G5gym21oAsI4pw==} @@ -19822,6 +19990,7 @@ packages: engines: {node: '>=4.0.0'} dependencies: array-back: 3.1.0 + dev: true /find-root@1.1.0: resolution: {integrity: sha512-NKfW6bec6GfKc0SGx1e07QZY9PE99u0Bft/0rzSD5k3sO/vwkVUpDUKVm5Gpp5Ue3YfShPFTX2070tDs5kB9Ng==} @@ -19885,7 +20054,6 @@ packages: flatted: 3.2.9 keyv: 4.5.4 rimraf: 3.0.2 - dev: true /flat@5.0.2: resolution: {integrity: sha512-b6suED+5/3rTpUBdG1gupIl8MPFCAMA0QXwmljLhvCUKcUvdE4gWky9zpuGCcXHOsz4J9wPGNWq6OKpmIzz3hQ==} @@ -19893,7 +20061,6 @@ packages: /flatted@3.2.9: resolution: {integrity: sha512-36yxDn5H7OFZQla0/jFJmbIKTdZAQHngCedGxiMmpNfEZM0sdEeT+WczLQrjK6D7o2aiyLYDnkw0R3JK0Qv1RQ==} - dev: true /flow-enums-runtime@0.0.5: resolution: {integrity: sha512-PSZF9ZuaZD03sT9YaIs0FrGJ7lSUw7rHZIex+73UYVXg46eL/wxN5PaVcPJFudE2cJu5f0fezitV5aBkLHPUOQ==} @@ -19962,7 +20129,7 @@ packages: resolution: {integrity: sha512-j0KLYPhm6zeac4lz3oJ3o65qvgQCcPubiyotZrXqEaG4hNagNYO8qdlUrX5vwqv9ohqeT/Z3j6+yW067yWWdUw==} dev: true - /fork-ts-checker-webpack-plugin@6.5.3(typescript@4.9.5)(webpack@5.89.0): + /fork-ts-checker-webpack-plugin@6.5.3(eslint@8.52.0)(typescript@4.9.5)(webpack@5.89.0): resolution: {integrity: sha512-SbH/l9ikmMWycd5puHJKTkZJKddF4iRLyW3DeZ08HTI7NGyLS38MXd/KGgeWumQO7YNQbW2u/NtPT2YowbPaGQ==} engines: {node: '>=10', yarn: '>=1.0.0'} peerDependencies: @@ -19982,6 +20149,7 @@ packages: chokidar: 3.5.3 cosmiconfig: 6.0.0 deepmerge: 4.3.1 + eslint: 8.52.0 fs-extra: 9.1.0 glob: 7.2.3 memfs: 3.5.3 @@ -20025,7 +20193,7 @@ packages: dependencies: fetch-blob: 3.2.0 - /formik-mui-x-date-pickers@0.0.1(@emotion/react@11.11.1)(@emotion/styled@11.11.0)(@mui/material@5.14.14)(@mui/system@5.14.14)(@mui/x-date-pickers@5.0.20)(formik@2.4.5)(react@18.2.0)(tiny-warning@1.0.3): + /formik-mui-x-date-pickers@0.0.1(@emotion/react@11.11.1)(@emotion/styled@11.11.0)(@mui/material@5.14.15)(@mui/system@5.14.15)(@mui/x-date-pickers@5.0.20)(formik@2.4.5)(react@18.2.0)(tiny-warning@1.0.3): resolution: {integrity: sha512-IxZsY6er+g0eNsucIDHcNs6DLaPDdG14IYx/lS2HSuKnTgV4vGEWpXyGMpkY/vGyh+W3N5U4TrBVu+7eRb5rLA==} peerDependencies: '@emotion/react': '>=11.5.0' @@ -20037,17 +20205,17 @@ packages: react: '>=17.0.2' tiny-warning: '>=1.0.3' dependencies: - '@emotion/react': 11.11.1(@types/react@18.2.31)(react@18.2.0) - '@emotion/styled': 11.11.0(@emotion/react@11.11.1)(@types/react@18.2.31)(react@18.2.0) - '@mui/material': 5.14.14(@emotion/react@11.11.1)(@emotion/styled@11.11.0)(@types/react@18.2.31)(react-dom@18.2.0)(react@18.2.0) - '@mui/system': 5.14.14(@emotion/react@11.11.1)(@emotion/styled@11.11.0)(@types/react@18.2.31)(react@18.2.0) - '@mui/x-date-pickers': 5.0.20(@emotion/react@11.11.1)(@emotion/styled@11.11.0)(@mui/material@5.14.14)(@mui/system@5.14.14)(@types/react@18.2.31)(dayjs@1.11.10)(react-dom@18.2.0)(react@18.2.0) + '@emotion/react': 11.11.1(@types/react@18.2.33)(react@18.2.0) + '@emotion/styled': 11.11.0(@emotion/react@11.11.1)(@types/react@18.2.33)(react@18.2.0) + '@mui/material': 5.14.15(@emotion/react@11.11.1)(@emotion/styled@11.11.0)(@types/react@18.2.33)(react-dom@18.2.0)(react@18.2.0) + '@mui/system': 5.14.15(@emotion/react@11.11.1)(@emotion/styled@11.11.0)(@types/react@18.2.33)(react@18.2.0) + '@mui/x-date-pickers': 5.0.20(@emotion/react@11.11.1)(@emotion/styled@11.11.0)(@mui/material@5.14.15)(@mui/system@5.14.15)(@types/react@18.2.33)(dayjs@1.11.10)(react-dom@18.2.0)(react@18.2.0) formik: 2.4.5(react@18.2.0) react: 18.2.0 tiny-warning: 1.0.3 dev: false - /formik-mui@5.0.0-alpha.0(@emotion/react@11.11.1)(@emotion/styled@11.11.0)(@mui/material@5.14.14)(formik@2.4.5)(react@18.2.0)(tiny-warning@1.0.3): + /formik-mui@5.0.0-alpha.0(@emotion/react@11.11.1)(@emotion/styled@11.11.0)(@mui/material@5.14.15)(formik@2.4.5)(react@18.2.0)(tiny-warning@1.0.3): resolution: {integrity: sha512-tcY8B4I3N2UK9ghgVpeBWsXGMDe1y4LVKwI8GiUbLKGB86fI/CN9UMr4FuNo6kzNXvO42LFNmCxdEVzovNCyYQ==} peerDependencies: '@emotion/react': '>=11.5.0' @@ -20057,9 +20225,9 @@ packages: react: '>=17.0.2' tiny-warning: '>=1.0.3' dependencies: - '@emotion/react': 11.11.1(@types/react@18.2.31)(react@18.2.0) - '@emotion/styled': 11.11.0(@emotion/react@11.11.1)(@types/react@18.2.31)(react@18.2.0) - '@mui/material': 5.14.14(@emotion/react@11.11.1)(@emotion/styled@11.11.0)(@types/react@18.2.31)(react-dom@18.2.0)(react@18.2.0) + '@emotion/react': 11.11.1(@types/react@18.2.33)(react@18.2.0) + '@emotion/styled': 11.11.0(@emotion/react@11.11.1)(@types/react@18.2.33)(react@18.2.0) + '@mui/material': 5.14.15(@emotion/react@11.11.1)(@emotion/styled@11.11.0)(@types/react@18.2.33)(react-dom@18.2.0)(react@18.2.0) formik: 2.4.5(react@18.2.0) react: 18.2.0 tiny-warning: 1.0.3 @@ -20302,6 +20470,7 @@ packages: /get-package-type@0.1.0: resolution: {integrity: sha512-pjzuKtY64GYfWizNAJ0fr9VqttZkNiK2iS430LtIHzjBEr6bX8Am2zm4sW4Ro5wjWW5cAlRL1qAMTcXbjNAO2Q==} engines: {node: '>=8.0.0'} + dev: true /get-port@3.2.0: resolution: {integrity: sha512-x5UJKlgeUiNT8nyo/AcnwLnZuZNcSjSw0kogRB+Whd1fjjFq4B1hySFxSFWWSn4mIBzg3sRNUDFYc4g5gjPoLg==} @@ -20563,7 +20732,6 @@ packages: engines: {node: '>=8'} dependencies: type-fest: 0.20.2 - dev: true /globalthis@1.0.3: resolution: {integrity: sha512-sFdI5LyBiNTHjRd7cGPWapiHWMOXKyuBNX/cWJ3NfzrZQVa8GI/8cofCl74AOVqq9W5kNmguTIzJ/1s2gyI9wA==} @@ -20723,19 +20891,18 @@ packages: /graphemer@1.4.0: resolution: {integrity: sha512-EtKwoO6kxCL9WO5xipiHTZlSzBm7WLT627TqC/uVRd0HKmq8NXyebnNYxDoBi7wt8eTWrUrKXCOVaFq9x1kgag==} - dev: true /graphql-import-node@0.0.5(graphql@16.8.1): resolution: {integrity: sha512-OXbou9fqh9/Lm7vwXT0XoRN9J5+WCYKnbiTalgFDvkQERITRmcfncZs6aVABedd5B85yQU5EULS4a5pnbpuI0Q==} peerDependencies: - graphql: ^16.6.0 + graphql: '*' dependencies: graphql: 16.8.1 /graphql-jit@0.8.2(graphql@16.8.1): resolution: {integrity: sha512-P9KtM/UY4JTtHVRqRlZzFXPmDEtps1Bd27Mvj/naQIa5d0j83zPxAx4jewq1wueF3UEZu1JFZwX1XVBBkoo1Mg==} peerDependencies: - graphql: ^16.6.0 + graphql: '>=15' dependencies: '@graphql-typed-document-node/core': 3.2.0(graphql@16.8.1) fast-json-stringify: 1.21.0 @@ -20751,7 +20918,7 @@ packages: resolution: {integrity: sha512-FdSNcu2QQcWnM2VNvSCCDCVS5PpPqpzgFT8+GXzqJuoDd0CBncxCY278u4mhRO7tMgo2JjgJA5aZ+nWSQ/Z+xg==} engines: {node: '>=10'} peerDependencies: - graphql: ^16.6.0 + graphql: ^0.9.0 || ^0.10.0 || ^0.11.0 || ^0.12.0 || ^0.13.0 || ^14.0.0 || ^15.0.0 || ^16.0.0 dependencies: graphql: 16.8.1 tslib: 2.6.2 @@ -20760,7 +20927,7 @@ packages: resolution: {integrity: sha512-umt4f5NnMK46ChM2coO36PTFhHouBrK9stWWBczERguwYrGnPNxJ9dimU6IyOBfOkC6Izhkg4H8+F51W/8CYDg==} engines: {node: '>=10'} peerDependencies: - graphql: ^16.6.0 + graphql: '>=0.11 <=16' dependencies: graphql: 16.8.1 @@ -20768,14 +20935,14 @@ packages: resolution: {integrity: sha512-LycmCwhZ+Op2GlHz4BZDsUYHKRiiUz+3r9wbhBATMETNlORQJAaFlAgTFoeRh6xQoQegwYwIylVD1Qns9/DA3w==} engines: {node: '>=10'} peerDependencies: - graphql: ^16.6.0 + graphql: '>=0.11 <=16' dependencies: graphql: 16.8.1 /graphql-yoga@3.9.1(graphql@16.8.1): resolution: {integrity: sha512-BB6EkN64VBTXWmf9Kym2OsVZFzBC0mAsQNo9eNB5xIr3t+x7qepQ34xW5A353NWol3Js3xpzxwIKFVF6l9VsPg==} peerDependencies: - graphql: ^16.6.0 + graphql: ^15.2.0 || ^16.0.0 dependencies: '@envelop/core': 3.0.6 '@envelop/validation-cache': 5.1.3(@envelop/core@3.0.6)(graphql@16.8.1) @@ -20786,7 +20953,7 @@ packages: '@graphql-yoga/subscription': 3.1.0 '@whatwg-node/fetch': 0.8.8 '@whatwg-node/server': 0.7.7 - dset: 3.1.2 + dset: 3.1.3 graphql: 16.8.1 lru-cache: 7.18.3 tslib: 2.6.2 @@ -20795,7 +20962,7 @@ packages: resolution: {integrity: sha512-ZvZlO8MHMDWuLRoDhvJQnXg8SOJD0iDaCA+M/zWuD26AlhEugOEbpnhw/645oqXTYtvHsM91WyxtV7p5XJWYMg==} engines: {node: '>=18.0.0'} peerDependencies: - graphql: ^16.6.0 + graphql: ^15.2.0 || ^16.0.0 dependencies: '@envelop/core': 5.0.0 '@graphql-tools/executor': 1.2.0(graphql@16.8.1) @@ -20803,14 +20970,19 @@ packages: '@graphql-tools/utils': 10.0.7(graphql@16.8.1) '@graphql-yoga/logger': 2.0.0 '@graphql-yoga/subscription': 5.0.0 - '@whatwg-node/fetch': 0.9.13 - '@whatwg-node/server': 0.9.15 - dset: 3.1.2 + '@whatwg-node/fetch': 0.9.14 + '@whatwg-node/server': 0.9.16 + dset: 3.1.3 graphql: 16.8.1 lru-cache: 10.0.1 tslib: 2.6.2 dev: false + /graphql@15.5.0: + resolution: {integrity: sha512-OmaM7y0kaK31NKG31q4YbD2beNYa6jBBKtMFT6gLYJljHLJr42IqJ8KX08u3Li/0ifzTU5HjmoOOrwa5BRLeDA==} + engines: {node: '>= 10.x'} + dev: true + /graphql@16.8.1: resolution: {integrity: sha512-59LZHPdGZVh695Ud9lRzPBVTtlX9ZCV150Er2W43ro37wVof0ctenSaskPPjN7lVTIN8mSZt8PHUNKZuNQUuxw==} engines: {node: ^12.22.0 || ^14.16.0 || ^16.0.0 || >=17.0.0} @@ -20882,7 +21054,7 @@ packages: resolution: {integrity: sha512-VIZB+ibDhx7ObhAe7OVtoEbuP4h/MuOTHJ+J8h/eBXotJYl0fBgR72xDFCKgIh22OJZIOVNxBMWuhAr10r8HdA==} engines: {node: '>=6'} - /hardhat-abi-exporter@2.10.1(hardhat@2.13.1): + /hardhat-abi-exporter@2.10.1(hardhat@2.18.3): resolution: {integrity: sha512-X8GRxUTtebMAd2k4fcPyVnCdPa6dYK4lBsrwzKP5yiSq4i+WadWPIumaLfce53TUf/o2TnLpLOduyO1ylE2NHQ==} engines: {node: '>=14.14.0'} peerDependencies: @@ -20890,17 +21062,17 @@ packages: dependencies: '@ethersproject/abi': 5.7.0 delete-empty: 3.0.0 - hardhat: 2.13.1(ts-node@10.9.1)(typescript@4.9.5) + hardhat: 2.18.3(ts-node@10.9.1)(typescript@4.9.5) dev: true - /hardhat-gas-reporter@1.0.9(hardhat@2.13.1): + /hardhat-gas-reporter@1.0.9(hardhat@2.18.3): resolution: {integrity: sha512-INN26G3EW43adGKBNzYWOlI3+rlLnasXTwW79YNnUhXPDa+yHESgt639dJEs37gCjhkbNKcRRJnomXEuMFBXJg==} peerDependencies: hardhat: ^2.0.2 dependencies: array-uniq: 1.0.3 eth-gas-reporter: 0.2.27 - hardhat: 2.13.1(ts-node@10.9.1)(typescript@4.9.5) + hardhat: 2.18.3(ts-node@10.9.1)(typescript@4.9.5) sha1: 1.1.1 transitivePeerDependencies: - '@codechecks/client' @@ -20909,18 +21081,17 @@ packages: - utf-8-validate dev: true - /hardhat-preprocessor@0.1.5(hardhat@2.13.1): + /hardhat-preprocessor@0.1.5(hardhat@2.18.3): resolution: {integrity: sha512-j8m44mmPxpxAAd0G8fPHRHOas/INZdzptSur0TNJvMEGcFdLDhbHHxBcqZVQ/bmiW42q4gC60AP4CXn9EF018g==} peerDependencies: hardhat: ^2.0.5 dependencies: - hardhat: 2.13.1(ts-node@10.9.1)(typescript@4.9.5) + hardhat: 2.18.3(ts-node@10.9.1)(typescript@4.9.5) murmur-128: 0.2.1 dev: true - /hardhat@2.13.1(ts-node@10.9.1)(typescript@4.9.5): - resolution: {integrity: sha512-ZZL7LQxHmbw4JQJsiEv2qE35nbR+isr2sIdtgZVPp0+zWqRkpr1OT7gmvhCNYfjpEPyfjZIxWriQWlphJhVPLQ==} - engines: {node: '>=14.0.0'} + /hardhat@2.18.2(ts-node@10.9.1)(typescript@5.1.6): + resolution: {integrity: sha512-lUVmJg7DsKcUCDpqv57CJl6vHqo/1PeHSfM3+WIa8UtRKmXyVTj1qQK01TDiuetkZBVg9Dn52qU+ZwaJQynaKA==} hasBin: true peerDependencies: ts-node: '*' @@ -20933,21 +21104,88 @@ packages: dependencies: '@ethersproject/abi': 5.7.0 '@metamask/eth-sig-util': 4.0.1 - '@nomicfoundation/ethereumjs-block': 5.0.0 - '@nomicfoundation/ethereumjs-blockchain': 7.0.0 - '@nomicfoundation/ethereumjs-common': 4.0.0 - '@nomicfoundation/ethereumjs-evm': 2.0.0 - '@nomicfoundation/ethereumjs-rlp': 5.0.0 - '@nomicfoundation/ethereumjs-statemanager': 2.0.0 - '@nomicfoundation/ethereumjs-trie': 6.0.0 - '@nomicfoundation/ethereumjs-tx': 5.0.0 - '@nomicfoundation/ethereumjs-util': 9.0.0 - '@nomicfoundation/ethereumjs-vm': 7.0.0 + '@nomicfoundation/ethereumjs-block': 5.0.2 + '@nomicfoundation/ethereumjs-blockchain': 7.0.2 + '@nomicfoundation/ethereumjs-common': 4.0.2 + '@nomicfoundation/ethereumjs-evm': 2.0.2 + '@nomicfoundation/ethereumjs-rlp': 5.0.2 + '@nomicfoundation/ethereumjs-statemanager': 2.0.2 + '@nomicfoundation/ethereumjs-trie': 6.0.2 + '@nomicfoundation/ethereumjs-tx': 5.0.2 + '@nomicfoundation/ethereumjs-util': 9.0.2 + '@nomicfoundation/ethereumjs-vm': 7.0.2 + '@nomicfoundation/solidity-analyzer': 0.1.1 + '@sentry/node': 5.30.0 + '@types/bn.js': 5.1.3 + '@types/lru-cache': 5.1.1 + adm-zip: 0.4.16 + aggregate-error: 3.1.0 + ansi-escapes: 4.3.2 + chalk: 2.4.2 + chokidar: 3.5.3 + ci-info: 2.0.0 + debug: 4.3.4(supports-color@8.1.1) + enquirer: 2.4.1 + env-paths: 2.2.1 + ethereum-cryptography: 1.2.0 + ethereumjs-abi: 0.6.8 + find-up: 2.1.0 + fp-ts: 1.19.3 + fs-extra: 7.0.1 + glob: 7.2.0 + immutable: 4.3.4 + io-ts: 1.10.4 + keccak: 3.0.4 + lodash: 4.17.21 + mnemonist: 0.38.5 + mocha: 10.2.0 + p-map: 4.0.0 + raw-body: 2.5.2 + resolve: 1.17.0 + semver: 6.3.1 + solc: 0.7.3(debug@4.3.4) + source-map-support: 0.5.21 + stacktrace-parser: 0.1.10 + ts-node: 10.9.1(@types/node@18.18.7)(typescript@5.1.6) + tsort: 0.0.1 + typescript: 5.1.6 + undici: 5.26.5 + uuid: 8.3.2 + ws: 7.5.9 + transitivePeerDependencies: + - bufferutil + - supports-color + - utf-8-validate + dev: false + + /hardhat@2.18.3(ts-node@10.9.1)(typescript@4.9.5): + resolution: {integrity: sha512-JuYaTG+4ZHVjEHCW5Hn6jCHH3LpO75dtgznZpM/dLv12RcSlw/xHbeQh3FAsGahQr1epKryZcZEMHvztVZHe0g==} + hasBin: true + peerDependencies: + ts-node: '*' + typescript: '*' + peerDependenciesMeta: + ts-node: + optional: true + typescript: + optional: true + dependencies: + '@ethersproject/abi': 5.7.0 + '@metamask/eth-sig-util': 4.0.1 + '@nomicfoundation/ethereumjs-block': 5.0.2 + '@nomicfoundation/ethereumjs-blockchain': 7.0.2 + '@nomicfoundation/ethereumjs-common': 4.0.2 + '@nomicfoundation/ethereumjs-evm': 2.0.2 + '@nomicfoundation/ethereumjs-rlp': 5.0.2 + '@nomicfoundation/ethereumjs-statemanager': 2.0.2 + '@nomicfoundation/ethereumjs-trie': 6.0.2 + '@nomicfoundation/ethereumjs-tx': 5.0.2 + '@nomicfoundation/ethereumjs-util': 9.0.2 + '@nomicfoundation/ethereumjs-vm': 7.0.2 '@nomicfoundation/solidity-analyzer': 0.1.1 '@sentry/node': 5.30.0 '@types/bn.js': 5.1.3 '@types/lru-cache': 5.1.1 - abort-controller: 3.0.0 adm-zip: 0.4.16 aggregate-error: 3.1.0 ansi-escapes: 4.3.2 @@ -20970,14 +21208,13 @@ packages: mnemonist: 0.38.5 mocha: 10.2.0 p-map: 4.0.0 - qs: 6.11.2 raw-body: 2.5.2 resolve: 1.17.0 semver: 6.3.1 solc: 0.7.3(debug@4.3.4) source-map-support: 0.5.21 stacktrace-parser: 0.1.10 - ts-node: 10.9.1(@types/node@18.18.6)(typescript@4.9.5) + ts-node: 10.9.1(@types/node@18.18.7)(typescript@4.9.5) tsort: 0.0.1 typescript: 4.9.5 undici: 5.26.5 @@ -20988,9 +21225,8 @@ packages: - supports-color - utf-8-validate - /hardhat@2.13.1(typescript@5.1.6): - resolution: {integrity: sha512-ZZL7LQxHmbw4JQJsiEv2qE35nbR+isr2sIdtgZVPp0+zWqRkpr1OT7gmvhCNYfjpEPyfjZIxWriQWlphJhVPLQ==} - engines: {node: '>=14.0.0'} + /hardhat@2.18.3(typescript@5.1.6): + resolution: {integrity: sha512-JuYaTG+4ZHVjEHCW5Hn6jCHH3LpO75dtgznZpM/dLv12RcSlw/xHbeQh3FAsGahQr1epKryZcZEMHvztVZHe0g==} hasBin: true peerDependencies: ts-node: '*' @@ -21003,21 +21239,20 @@ packages: dependencies: '@ethersproject/abi': 5.7.0 '@metamask/eth-sig-util': 4.0.1 - '@nomicfoundation/ethereumjs-block': 5.0.0 - '@nomicfoundation/ethereumjs-blockchain': 7.0.0 - '@nomicfoundation/ethereumjs-common': 4.0.0 - '@nomicfoundation/ethereumjs-evm': 2.0.0 - '@nomicfoundation/ethereumjs-rlp': 5.0.0 - '@nomicfoundation/ethereumjs-statemanager': 2.0.0 - '@nomicfoundation/ethereumjs-trie': 6.0.0 - '@nomicfoundation/ethereumjs-tx': 5.0.0 - '@nomicfoundation/ethereumjs-util': 9.0.0 - '@nomicfoundation/ethereumjs-vm': 7.0.0 + '@nomicfoundation/ethereumjs-block': 5.0.2 + '@nomicfoundation/ethereumjs-blockchain': 7.0.2 + '@nomicfoundation/ethereumjs-common': 4.0.2 + '@nomicfoundation/ethereumjs-evm': 2.0.2 + '@nomicfoundation/ethereumjs-rlp': 5.0.2 + '@nomicfoundation/ethereumjs-statemanager': 2.0.2 + '@nomicfoundation/ethereumjs-trie': 6.0.2 + '@nomicfoundation/ethereumjs-tx': 5.0.2 + '@nomicfoundation/ethereumjs-util': 9.0.2 + '@nomicfoundation/ethereumjs-vm': 7.0.2 '@nomicfoundation/solidity-analyzer': 0.1.1 '@sentry/node': 5.30.0 '@types/bn.js': 5.1.3 '@types/lru-cache': 5.1.1 - abort-controller: 3.0.0 adm-zip: 0.4.16 aggregate-error: 3.1.0 ansi-escapes: 4.3.2 @@ -21040,7 +21275,6 @@ packages: mnemonist: 0.38.5 mocha: 10.2.0 p-map: 4.0.0 - qs: 6.11.2 raw-body: 2.5.2 resolve: 1.17.0 semver: 6.3.1 @@ -21225,10 +21459,6 @@ packages: capital-case: 1.0.4 tslib: 2.6.2 - /headers-polyfill@3.2.5: - resolution: {integrity: sha512-tUCGvt191vNSQgttSyJoibR+VO+I6+iCHIUdhzEMJKE+EAL8BwCN7fUOZlY4ofOelNHsK+gEjxB/B+9N3EWtdA==} - dev: true - /heap@0.2.7: resolution: {integrity: sha512-2bsegYkkHO+h/9MGbn6KWcE45cHZgPANo5LXF7EvWdT0yT2EguSVO1nDgU5c8+ZOPwp2vMNa7YFsJhVcDR9Sdg==} @@ -21270,6 +21500,7 @@ packages: /hoist-non-react-statics@3.3.2: resolution: {integrity: sha512-/gGivxi8JPKWNm/W0jSmzcMPpfpPLc3dY/6GxhX2hQ9iGj3aDfklV4ET7NjKpSinLpJ5vafa9iiGIEZg10SfBw==} + requiresBuild: true dependencies: react-is: 16.13.1 dev: false @@ -21313,6 +21544,7 @@ packages: /html-escaper@2.0.2: resolution: {integrity: sha512-H2iMtd0I4Mt5eYiapRdIDjp+XzelXQ0tFE4JS7YFwFevXXMmOp9myNrUvCg0D6ws8iqkRPBfKHgbwig1SmlLfg==} + dev: true /html-minifier-terser@5.1.1: resolution: {integrity: sha512-ZPr5MNObqnV/T9akshPKbVgyOqLmy+Bxo7juKCfTfnjNniTAMdy4hz21YQqoofMBJD2kdREaqPPdThoR78Tgxg==} @@ -21563,6 +21795,14 @@ packages: resolution: {integrity: sha512-ygGZLjmXfPHj+ZWh6LwbC37l43MhfztxetbFCoYTM2VjkIUpeHgSNn7QIyVFj7YQ1Wl9Cbw5sholVJPzWvC2MQ==} dev: false + /i18n-js@4.3.2: + resolution: {integrity: sha512-n8gbEbQEueym2/q2yrZk5/xKWjFcKtg3/Escw4JHSVWa8qtKqP8j7se3UjkRbHlO/REqFA0V/MG1q8tEfyHeOA==} + dependencies: + bignumber.js: 9.1.2 + lodash: 4.17.21 + make-plural: 7.3.0 + dev: false + /iconv-lite@0.4.24: resolution: {integrity: sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==} engines: {node: '>=0.10.0'} @@ -21739,27 +21979,6 @@ packages: wrap-ansi: 7.0.0 dev: true - /inquirer@8.2.6: - resolution: {integrity: sha512-M1WuAmb7pn9zdFRtQYk26ZBoY043Sse0wVDdk4Bppr+JOXyQYybdtvK+l9wUibhtjdjvtoiNy8tk+EgsYIUqKg==} - engines: {node: '>=12.0.0'} - dependencies: - ansi-escapes: 4.3.2 - chalk: 4.1.2 - cli-cursor: 3.1.0 - cli-width: 3.0.0 - external-editor: 3.1.0 - figures: 3.2.0 - lodash: 4.17.21 - mute-stream: 0.0.8 - ora: 5.4.1 - run-async: 2.4.1 - rxjs: 7.8.1 - string-width: 4.2.3 - strip-ansi: 6.0.1 - through: 2.3.8 - wrap-ansi: 6.2.0 - dev: true - /interface-blockstore@2.0.3: resolution: {integrity: sha512-OwVUnlNcx7H5HloK0Myv6c/C1q9cNG11HX6afdeU6q6kbuNj8jKCwVnmJHhC94LZaJ+9hvVOk4IUstb3Esg81w==} dependencies: @@ -22013,7 +22232,7 @@ packages: '@libp2p/interface-peer-info': 1.0.10 '@libp2p/interface-pubsub': 3.0.7 '@multiformats/multiaddr': 11.6.1 - '@types/node': 18.18.6 + '@types/node': 18.18.7 interface-datastore: 7.0.4 ipfs-unixfs: 8.0.0 multiformats: 10.0.3 @@ -22659,6 +22878,7 @@ packages: /is-generator-fn@2.1.0: resolution: {integrity: sha512-cTIB4yPYL/Grw0EaSzASzg6bBy9gqCofvWN8okThAYIxKJZC+udlRAmGbM0XLeniEJSs8uEgHPGuHSe1XsOLSQ==} engines: {node: '>=6'} + dev: true /is-generator-function@1.0.10: resolution: {integrity: sha512-jsEjy9l3yiXEQ+PsXdmBwEPcOxaXWLspKdplFUVI9vq1iZgIekeC0L167qeu86czQaxed3q/Uzuw0swL0irL8A==} @@ -22736,10 +22956,6 @@ packages: engines: {node: '>= 0.4'} dev: true - /is-node-process@1.2.0: - resolution: {integrity: sha512-Vg4o6/fqPxIjtxgUH5QLJhwZ7gW5diGCVlXpuUfELC62CuxM1iHcRe51f2W1FDy04Ai4KJkagKjx3XaqyfRKXw==} - dev: true - /is-npm@5.0.0: resolution: {integrity: sha512-WW/rQLOazUq+ST/bCAVBp/2oMERWLsR7OrKyt052dNDk4DHcDE0/7QSXITlmi+VBcV13DfIbysG3tZJm5RfdBA==} engines: {node: '>=10'} @@ -22961,8 +23177,8 @@ packages: get-intrinsic: 1.2.2 dev: true - /is-what@4.1.15: - resolution: {integrity: sha512-uKua1wfy3Yt+YqsD6mTUEa2zSi3G1oPlqTflgaPJ7z63vUGN5pxFpnQfeSLMFnJDEsdvOtkp1rUWkYjB4YfhgA==} + /is-what@4.1.16: + resolution: {integrity: sha512-ZhMwEosbFJkA0YhFnNDgTM4ZxDRsS6HqTo7qsZM08fehyRYIYa0yHu5R6mgo1n/8MgaPBXiPimPD77baVFYg+A==} engines: {node: '>=12.13'} dev: false @@ -23052,6 +23268,7 @@ packages: ws: '*' dependencies: ws: 8.12.0 + dev: true /isomorphic-ws@5.0.0(ws@8.13.0): resolution: {integrity: sha512-muId7Zzn9ywDsyXgTIafTry2sV3nySZeUDe6YedVd1Hvuuep5AsIlqK+XefWpYTyJG5e503F2xIuT2lcU6rCSw==} @@ -23067,6 +23284,14 @@ packages: dependencies: ws: 8.14.2(bufferutil@4.0.8)(utf-8-validate@5.0.10) + /isows@1.0.3(ws@8.13.0): + resolution: {integrity: sha512-2cKei4vlmg2cxEjm3wVSqn8pcoRF/LX/wpifuuNquFO4SQmPwarClT+SUCA2lt+l581tTeZIPIZuIDo2jWN1fg==} + peerDependencies: + ws: '*' + dependencies: + ws: 8.13.0 + dev: false + /isstream@0.1.2: resolution: {integrity: sha512-Yljz7ffyPbrLpLngrMtZ7NduUgVvi6wG9RJ9IUcyCd59YQ911PBJphODUcbOVbqYfxe1wuYf/LJ8PauMRwsM/g==} dev: true @@ -23079,6 +23304,7 @@ packages: /istanbul-lib-coverage@3.2.0: resolution: {integrity: sha512-eOeJ5BHCmHYvQK7xt9GkdHuzuCGS1Y6g9Gvnx3Ym33fz/HpLRYxiS0wHNr+m/MBC8B647Xt608vCDEvhl9c6Mw==} engines: {node: '>=8'} + dev: true /istanbul-lib-hook@3.0.0: resolution: {integrity: sha512-Pt/uge1Q9s+5VAZ+pCo16TYMWPBIl+oaNIjgLQxcX0itS6ueeaA+pEfThZpH8WxhFgCiEb8sAJY6MdUKgiIWaQ==} @@ -23110,6 +23336,7 @@ packages: semver: 6.3.1 transitivePeerDependencies: - supports-color + dev: true /istanbul-lib-instrument@6.0.1: resolution: {integrity: sha512-EAMEJBsYuyyztxMxW3g7ugGPkrZsV57v0Hmv3mm1uQsmB+QnZuepg731CRaIgeUVSdmsTngOkSnauNF8p7FIhA==} @@ -23122,6 +23349,7 @@ packages: semver: 7.5.4 transitivePeerDependencies: - supports-color + dev: true /istanbul-lib-processinfo@2.0.3: resolution: {integrity: sha512-NkwHbo3E00oybX6NGJi6ar0B29vxyvNwoC7eJ4G4Yq28UfY758Hgn/heV8VRFhevPED4LXfFz0DQ8z/0kw9zMg==} @@ -23142,6 +23370,7 @@ packages: istanbul-lib-coverage: 3.2.0 make-dir: 4.0.0 supports-color: 7.2.0 + dev: true /istanbul-lib-source-maps@4.0.1: resolution: {integrity: sha512-n3s8EwkdFIJCG3BPKBYvskgXGoy88ARzvegkitk60NxRdwltLOTaH7CUiMRXvwYorl0Q712iEjcWB+fK/MrWVw==} @@ -23152,6 +23381,7 @@ packages: source-map: 0.6.1 transitivePeerDependencies: - supports-color + dev: true /istanbul-reports@3.1.6: resolution: {integrity: sha512-TLgnMkKg3iTDsQ9PbPTdpfAK2DzjF9mqUG7RMgcQl8oFjad8ob4laGxv5XV5U9MAfx8D6tSJiUyuAwzLicaxlg==} @@ -23159,6 +23389,7 @@ packages: dependencies: html-escaper: 2.0.2 istanbul-lib-report: 3.0.1 + dev: true /isurl@1.0.0: resolution: {integrity: sha512-1P/yWsxPlDtn7QeRD+ULKQPaIaN6yF368GZ2vDfv0AL0NwpStafjWCDDdn0k8wgFMWpVAqG7oJhxHnlud42i9w==} @@ -23545,6 +23776,7 @@ packages: execa: 5.1.1 jest-util: 29.7.0 p-limit: 3.1.0 + dev: true /jest-circus@29.7.0: resolution: {integrity: sha512-3E1nCMgipcTkCocFwM90XXQab9bS+GMsjdpmPrlelaxwD93Ad8iVEjX/vvHPdLPnFf+L40u+5+iutRdA1N9myw==} @@ -23554,7 +23786,7 @@ packages: '@jest/expect': 29.7.0 '@jest/test-result': 29.7.0 '@jest/types': 29.6.3 - '@types/node': 18.18.6 + '@types/node': 18.18.7 chalk: 4.1.2 co: 4.6.0 dedent: 1.5.1 @@ -23573,8 +23805,9 @@ packages: transitivePeerDependencies: - babel-plugin-macros - supports-color + dev: true - /jest-cli@29.7.0(@types/node@18.18.6)(ts-node@10.9.1): + /jest-cli@29.7.0(@types/node@18.18.7)(ts-node@10.9.1): resolution: {integrity: sha512-OVVobw2IubN/GSYsxETi+gOe7Ka59EFMR/twOU3Jb2GnKKeMGJB5SGUUrEz3SFVmJASUdZUzy83sLNNQ2gZslg==} engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} hasBin: true @@ -23588,10 +23821,10 @@ packages: '@jest/test-result': 29.7.0 '@jest/types': 29.6.3 chalk: 4.1.2 - create-jest: 29.7.0(@types/node@18.18.6)(ts-node@10.9.1) + create-jest: 29.7.0(@types/node@18.18.7)(ts-node@10.9.1) exit: 0.1.2 import-local: 3.1.0 - jest-config: 29.7.0(@types/node@18.18.6)(ts-node@10.9.1) + jest-config: 29.7.0(@types/node@18.18.7)(ts-node@10.9.1) jest-util: 29.7.0 jest-validate: 29.7.0 yargs: 17.7.2 @@ -23600,8 +23833,9 @@ packages: - babel-plugin-macros - supports-color - ts-node + dev: true - /jest-config@29.7.0(@types/node@18.18.6)(ts-node@10.9.1): + /jest-config@29.7.0(@types/node@18.18.7)(ts-node@10.9.1): resolution: {integrity: sha512-uXbpfeQ7R6TZBqI3/TxCU4q4ttk3u0PJeC+E0zbfSoSjq6bJ7buBPxzQPL0ifrkY4DNu4JUdk0ImlBUYi840eQ==} engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} peerDependencies: @@ -23616,7 +23850,7 @@ packages: '@babel/core': 7.23.2 '@jest/test-sequencer': 29.7.0 '@jest/types': 29.6.3 - '@types/node': 18.18.6 + '@types/node': 18.18.7 babel-jest: 29.7.0(@babel/core@7.23.2) chalk: 4.1.2 ci-info: 3.9.0 @@ -23636,10 +23870,11 @@ packages: pretty-format: 29.7.0 slash: 3.0.0 strip-json-comments: 3.1.1 - ts-node: 10.9.1(@types/node@18.18.6)(typescript@4.9.5) + ts-node: 10.9.1(@types/node@18.18.7)(typescript@5.1.6) transitivePeerDependencies: - babel-plugin-macros - supports-color + dev: true /jest-diff@29.7.0: resolution: {integrity: sha512-LMIgiIrhigmPrs03JHpxUh2yISK3vLFPkAodPeo0+BuF7wA2FoQbkEg1u8gBYBThncu7e1oEDUfIXVuTqLRUjw==} @@ -23649,12 +23884,14 @@ packages: diff-sequences: 29.6.3 jest-get-type: 29.6.3 pretty-format: 29.7.0 + dev: true /jest-docblock@29.7.0: resolution: {integrity: sha512-q617Auw3A612guyaFgsbFeYpNP5t2aoUNLwBUbc/0kD1R4t9ixDbyFTHd1nok4epoVFpr7PmeWHrhvuV3XaJ4g==} engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} dependencies: detect-newline: 3.1.0 + dev: true /jest-each@29.7.0: resolution: {integrity: sha512-gns+Er14+ZrEoC5fhOfYCY1LOHHr0TI+rQUHZS8Ttw2l7gl+80eHc/gFf2Ktkw0+SIACDTeWvpFcv3B04VembQ==} @@ -23665,6 +23902,7 @@ packages: jest-get-type: 29.6.3 jest-util: 29.7.0 pretty-format: 29.7.0 + dev: true /jest-environment-jsdom@29.7.0: resolution: {integrity: sha512-k9iQbsf9OyOfdzWH8HDmrRT0gSIcX+FLNW7IQq94tFX0gynPwqDTW0Ho6iMVNjGz/nb+l/vW3dWM2bbLLpkbXA==} @@ -23679,7 +23917,7 @@ packages: '@jest/fake-timers': 29.7.0 '@jest/types': 29.6.3 '@types/jsdom': 20.0.1 - '@types/node': 18.18.6 + '@types/node': 18.18.7 jest-mock: 29.7.0 jest-util: 29.7.0 jsdom: 20.0.3 @@ -23696,7 +23934,7 @@ packages: '@jest/environment': 29.7.0 '@jest/fake-timers': 29.7.0 '@jest/types': 29.6.3 - '@types/node': 18.18.6 + '@types/node': 18.18.7 jest-mock: 29.7.0 jest-util: 29.7.0 @@ -23709,11 +23947,20 @@ packages: jest: optional: true dependencies: - jest: 29.7.0(@types/node@18.18.6)(ts-node@10.9.1) + jest: 29.7.0(@types/node@18.18.7)(ts-node@10.9.1) jest-diff: 29.7.0 jest-get-type: 29.6.3 dev: true + /jest-fetch-mock@3.0.3: + resolution: {integrity: sha512-Ux1nWprtLrdrH4XwE7O7InRY6psIi3GOsqNESJgMJ+M5cv4A8Lh7SN9d2V2kKRZ8ebAfcd1LNyZguAOb6JiDqw==} + dependencies: + cross-fetch: 3.1.8 + promise-polyfill: 8.3.0 + transitivePeerDependencies: + - encoding + dev: true + /jest-get-type@29.6.3: resolution: {integrity: sha512-zrteXnqYxfQh7l5FHyL38jL39di8H8rHoecLH3JNxH3BwOrBsNeabdap5e0I23lD4HHI8W5VFBZqG4Eaq5LNcw==} engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} @@ -23724,7 +23971,7 @@ packages: dependencies: '@jest/types': 29.6.3 '@types/graceful-fs': 4.1.8 - '@types/node': 18.18.6 + '@types/node': 18.18.7 anymatch: 3.1.3 fb-watchman: 2.0.2 graceful-fs: 4.2.11 @@ -23735,6 +23982,7 @@ packages: walker: 1.0.8 optionalDependencies: fsevents: 2.3.3 + dev: true /jest-leak-detector@29.7.0: resolution: {integrity: sha512-kYA8IJcSYtST2BY9I+SMC32nDpBT3J2NvWJx8+JCuCdl/CR1I4EKUJROiP8XtCcxqgTTBGJNdbB1A8XRKbTetw==} @@ -23742,6 +23990,7 @@ packages: dependencies: jest-get-type: 29.6.3 pretty-format: 29.7.0 + dev: true /jest-matcher-utils@29.7.0: resolution: {integrity: sha512-sBkD+Xi9DtcChsI3L3u0+N0opgPYnCRPtGcQYrgXmR+hmt/fYfWAL0xRXYU8eWOdfuLgBe0YCW3AFtnRLagq/g==} @@ -23751,6 +24000,7 @@ packages: jest-diff: 29.7.0 jest-get-type: 29.6.3 pretty-format: 29.7.0 + dev: true /jest-message-util@29.7.0: resolution: {integrity: sha512-GBEV4GRADeP+qtB2+6u61stea8mGcOT4mCtrYISZwfu9/ISHFJ/5zOMXYbpBE9RsS5+Gb63DW4FgmnKJ79Kf6w==} @@ -23771,7 +24021,7 @@ packages: engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} dependencies: '@jest/types': 29.6.3 - '@types/node': 18.18.6 + '@types/node': 18.18.7 jest-util: 29.7.0 /jest-pnp-resolver@1.2.3(jest-resolve@29.7.0): @@ -23784,6 +24034,7 @@ packages: optional: true dependencies: jest-resolve: 29.7.0 + dev: true /jest-regex-util@27.5.1: resolution: {integrity: sha512-4bfKq2zie+x16okqDXjXn9ql2B0dScQu+vcwe4TvFVhkVyuWLqpZrZtXxLLWoXYgn0E87I6r6GRYHF7wFZBUvg==} @@ -23792,6 +24043,7 @@ packages: /jest-regex-util@29.6.3: resolution: {integrity: sha512-KJJBsRCyyLNWCNBOvZyRDnAIfUiRJ8v+hOBQYGn8gDyF3UegwiP4gwRR3/SDa42g1YbVycTidUF3rKjyLFDWbg==} engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} + dev: true /jest-resolve-dependencies@29.7.0: resolution: {integrity: sha512-un0zD/6qxJ+S0et7WxeI3H5XSe9lTBBR7bOHCHXkKR6luG5mwDDlIzVQ0V5cZCuoTgEdcdwzTghYkTWfubi+nA==} @@ -23801,6 +24053,7 @@ packages: jest-snapshot: 29.7.0 transitivePeerDependencies: - supports-color + dev: true /jest-resolve@29.7.0: resolution: {integrity: sha512-IOVhZSrg+UvVAshDSDtHyFCCBUl/Q3AAJv8iZ6ZjnZ74xzvwuzLXid9IIIPgTnY62SJjfuupMKZsZQRsCvxEgA==} @@ -23815,6 +24068,7 @@ packages: resolve: 1.22.8 resolve.exports: 2.0.2 slash: 3.0.0 + dev: true /jest-runner@29.7.0: resolution: {integrity: sha512-fsc4N6cPCAahybGBfTRcq5wFR6fpLznMg47sY5aDpsoejOcVYFb07AHuSnR0liMcPTgBsA3ZJL6kFOjPdoNipQ==} @@ -23825,7 +24079,7 @@ packages: '@jest/test-result': 29.7.0 '@jest/transform': 29.7.0 '@jest/types': 29.6.3 - '@types/node': 18.18.6 + '@types/node': 18.18.7 chalk: 4.1.2 emittery: 0.13.1 graceful-fs: 4.2.11 @@ -23843,6 +24097,7 @@ packages: source-map-support: 0.5.13 transitivePeerDependencies: - supports-color + dev: true /jest-runtime@29.7.0: resolution: {integrity: sha512-gUnLjgwdGqW7B4LvOIkbKs9WGbn+QLqRQQ9juC6HndeDiezIwhDP+mhMwHWCEcfQ5RUXa6OPnFF8BJh5xegwwQ==} @@ -23855,7 +24110,7 @@ packages: '@jest/test-result': 29.7.0 '@jest/transform': 29.7.0 '@jest/types': 29.6.3 - '@types/node': 18.18.6 + '@types/node': 18.18.7 chalk: 4.1.2 cjs-module-lexer: 1.2.3 collect-v8-coverage: 1.0.2 @@ -23872,6 +24127,7 @@ packages: strip-bom: 4.0.0 transitivePeerDependencies: - supports-color + dev: true /jest-snapshot@29.7.0: resolution: {integrity: sha512-Rm0BMWtxBcioHr1/OX5YCP8Uov4riHvKPknOGs804Zg9JGZgmIBkbtlxJC/7Z4msKYVbIJtfU+tKb8xlYNfdkw==} @@ -23899,13 +24155,14 @@ packages: semver: 7.5.4 transitivePeerDependencies: - supports-color + dev: true /jest-util@27.5.1: resolution: {integrity: sha512-Kv2o/8jNvX1MQ0KGtw480E/w4fBCDOnH6+6DmeKi6LZUIlKA5kwY0YNdlzaWTiVgxqAqik11QyxDOKk543aKXw==} engines: {node: ^10.13.0 || ^12.13.0 || ^14.15.0 || >=15.0.0} dependencies: '@jest/types': 27.5.1 - '@types/node': 18.18.6 + '@types/node': 18.18.7 chalk: 4.1.2 ci-info: 3.9.0 graceful-fs: 4.2.11 @@ -23916,7 +24173,7 @@ packages: engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} dependencies: '@jest/types': 29.6.3 - '@types/node': 18.18.6 + '@types/node': 18.18.7 chalk: 4.1.2 ci-info: 3.9.0 graceful-fs: 4.2.11 @@ -23939,18 +24196,19 @@ packages: dependencies: '@jest/test-result': 29.7.0 '@jest/types': 29.6.3 - '@types/node': 18.18.6 + '@types/node': 18.18.7 ansi-escapes: 4.3.2 chalk: 4.1.2 emittery: 0.13.1 jest-util: 29.7.0 string-length: 4.0.2 + dev: true /jest-worker@27.5.1: resolution: {integrity: sha512-7vuh85V5cdDofPyxn58nrPjBktZo0u9x1g8WtjQol+jZDaE+fhN+cIvTj11GndBnMnyfrUOG1sZQxCdjKh+DKg==} engines: {node: '>= 10.13.0'} dependencies: - '@types/node': 18.18.6 + '@types/node': 18.18.7 merge-stream: 2.0.0 supports-color: 8.1.1 @@ -23958,12 +24216,12 @@ packages: resolution: {integrity: sha512-eIz2msL/EzL9UFTFFx7jBTkeZfku0yUAyZZZmJ93H2TYEiroIx2PQjEXcwYtYl8zXCxb+PAmA2hLIt/6ZEkPHw==} engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} dependencies: - '@types/node': 18.18.6 + '@types/node': 18.18.7 jest-util: 29.7.0 merge-stream: 2.0.0 supports-color: 8.1.1 - /jest@29.7.0(@types/node@18.18.6)(ts-node@10.9.1): + /jest@29.7.0(@types/node@18.18.7)(ts-node@10.9.1): resolution: {integrity: sha512-NIy3oAFp9shda19hy4HK0HRTWKtPJmGdnvywu01nOqNC2vZg+Z+fvJDxpMQA88eb2I9EcafcdjYgsDthnYTvGw==} engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} hasBin: true @@ -23976,17 +24234,17 @@ packages: '@jest/core': 29.7.0(ts-node@10.9.1) '@jest/types': 29.6.3 import-local: 3.1.0 - jest-cli: 29.7.0(@types/node@18.18.6)(ts-node@10.9.1) + jest-cli: 29.7.0(@types/node@18.18.7)(ts-node@10.9.1) transitivePeerDependencies: - '@types/node' - babel-plugin-macros - supports-color - ts-node + dev: true /jiti@1.20.0: resolution: {integrity: sha512-3TV69ZbrvV6U5DfQimop50jE9Dl6J8O1ja1dvBbMba/sZ3YBEQqJ2VZRoQPVnhlzjNtU1vaXRZVrVjU4qtm8yA==} hasBin: true - dev: false /joi@17.11.0: resolution: {integrity: sha512-NgB+lZLNoqISVy1rZocE9PZI36bL/77ie924Ri43yEvi9GUUMPeyVIr8KdFTMUlby1p0PBYMk9spIxEUQYqrJQ==} @@ -24002,6 +24260,10 @@ packages: engines: {node: '>=10'} dev: true + /js-base64@3.7.5: + resolution: {integrity: sha512-3MEt5DTINKqfScXKfJFrRbxkrnk2AxPWGBL/ycjz4dK8iqiSJ06UxD8jh8xuh6p10TX4t2+7FsBYVxxQbMg+qA==} + dev: false + /js-confetti@0.11.0: resolution: {integrity: sha512-Hc7I3VI4r4H0nq5q/oQK+JJwGoYRYVHK72fGk8E9Ay1dbh+aiZ9yl0yFp1K4oYeq7YFDQAndYChwqLPA3QWQuA==} dev: false @@ -24009,11 +24271,6 @@ packages: /js-cookie@2.2.1: resolution: {integrity: sha512-HvdH2LzI/EAZcUwA8+0nKNtWHqS+ZmijLA30RwZA0bo7ToCckjK5MkGhjED9KoRcXO6BaGI3I9UIzSA1FKFPOQ==} - /js-levenshtein@1.1.6: - resolution: {integrity: sha512-X2BB11YZtrRqY4EnQcLX5Rh373zbK4alC1FW7D7MBhL2gtcC17cTnr6DmfHZeS0s2rTHjUTMMHfG7gO8SSdw+g==} - engines: {node: '>=0.10.0'} - dev: true - /js-sdsl@4.4.2: resolution: {integrity: sha512-dwXFwByc/ajSV6m5bcKAPwe4yDDF6D614pxmIi5odytzxRlwqF6nwoiCek80Ixc7Cvma5awClxrzFtxCQvcM8w==} @@ -24147,7 +24404,6 @@ packages: /json-buffer@3.0.1: resolution: {integrity: sha512-4bV5BfR2mqfQTJm+V5tPPdf+ZpuhiIvTuAB5g8kcrXOZpTT/QwwVRWBywX1ozr6lEuPdbHxwaJlm9G6mI2sfSQ==} - dev: true /json-logic-js@2.0.2: resolution: {integrity: sha512-ZBtBdMJieqQcH7IX/LaBsr5pX+Y5JIW+EhejtM3Ffg2jdN9Iwf+Ht6TbHnvAZ/YtwyuhPaCBlnvzrwVeWdvGDQ==} @@ -24169,7 +24425,7 @@ packages: engines: {node: '>=10.0.0'} dependencies: '@metamask/safe-event-emitter': 2.0.0 - eth-rpc-errors: 4.0.2 + eth-rpc-errors: 4.0.3 dev: false /json-rpc-middleware-stream@4.2.3: @@ -24225,7 +24481,6 @@ packages: /json-stable-stringify-without-jsonify@1.0.1: resolution: {integrity: sha512-Bdboy+l7tA3OGW6FjyFHWkP5LuByj1Tk33Ljyq0axyzdk9//JSi2u3fP1QSmd1KNwq6VOKYGlAu87CisVir6Pw==} - dev: true /json-stringify-safe@5.0.1: resolution: {integrity: sha512-ZClg6AaYvamvYEE82d3Iyd3vSSIjQ+odgjaTzRuO3s7toCdFKczob2i0zCh7JE8kWn17yvAWhUVxvqGwUalsRA==} @@ -24239,6 +24494,7 @@ packages: /json5@1.0.2: resolution: {integrity: sha512-g1MWMLBiz8FKi1e4w0UyVL3w+iJceWAFBAaBnnGKOpNa5f8TLktkbre1+s6oICydWAm+HRUGTmI+//xv2hvXYA==} hasBin: true + requiresBuild: true dependencies: minimist: 1.2.8 dev: true @@ -24382,7 +24638,6 @@ packages: resolution: {integrity: sha512-oxVHkHR/EJf2CNXnWxRLW6mg7JyCCUcG0DtEGmL2ctUo1PNTin1PUil+r/+4r5MpVgC/fn1kjsx7mjSujKqIpw==} dependencies: json-buffer: 3.0.1 - dev: true /keyvaluestorage-interface@1.0.0: resolution: {integrity: sha512-8t6Q3TclQ4uZynJY9IGr2+SsIGwK9JHcO6ootkHCGA0CrQCRy+VkouYNO2xicET6b9al7QKzpebNow+gkpCL8g==} @@ -24581,7 +24836,6 @@ packages: dependencies: prelude-ls: 1.2.1 type-check: 0.4.0 - dev: true /libp2p-crypto@0.21.2: resolution: {integrity: sha512-EXFrhSpiHtJ+/L8xXDvQNK5VjUMG51u878jzZcaT5XhuN/zFg6PWJFnl/qB2Y2j7eMWnvCRP7Kp+ua2H36cG4g==} @@ -24763,8 +25017,16 @@ packages: '@types/trusted-types': 2.0.5 dev: false - /lit@2.7.5: - resolution: {integrity: sha512-i/cH7Ye6nBDUASMnfwcictBnsTN91+aBjXoTHF2xARghXScKxpD4F4WYI+VLXg9lqbMinDfvoI7VnZXjyHgdfQ==} + /lit@2.7.6: + resolution: {integrity: sha512-1amFHA7t4VaaDe+vdQejSVBklwtH9svGoG6/dZi9JhxtJBBlqY5D1RV7iLUYY0trCqQc4NfhYYZilZiVHt7Hxg==} + dependencies: + '@lit/reactive-element': 1.6.3 + lit-element: 3.3.3 + lit-html: 2.8.0 + dev: false + + /lit@2.8.0: + resolution: {integrity: sha512-4Sc3OFX9QHOJaHbmTMk28SYgVxLN3ePDjg7hofEft2zWlehFL3LiAuapWc4U/kYwMYJSh2hTCPZ6/LIC7ii0MA==} dependencies: '@lit/reactive-element': 1.6.3 lit-element: 3.3.3 @@ -24877,10 +25139,15 @@ packages: /lodash.camelcase@4.3.0: resolution: {integrity: sha512-TwuEnCnxbc3rAvhf/LbG7tJUDzhqXyFnv3dtzLOPgCG/hODL7WFnsbwktkD7yUV0RrreP/l1PALq/YSg6VvjlA==} + dev: true /lodash.clone@4.5.0: resolution: {integrity: sha512-GhrVeweiTD6uTmmn5hV/lzgCQhccwReIVRLHp7LT4SopOjqEZ5BbX8b5WWEtAKasjmy8hR7ZPwsYlxRCku5odg==} + /lodash.clonedeep@4.5.0: + resolution: {integrity: sha512-H5ZhCF25riFd9uB5UCkVKo61m3S/xZk1x4wA6yp/L3RFP6Z/eHH1ymQcGLo7J3GMPfm0V/7m1tryHuGVxpqEBQ==} + dev: true + /lodash.curry@4.1.1: resolution: {integrity: sha512-/u14pXGviLaweY5JI0IUzgzF2J6Ne8INyzAZjImcryjgkZ+ebruBxy2/JaOOkTqScddcYtakjhSaeemV8lR0tA==} dev: false @@ -24913,7 +25180,6 @@ packages: /lodash.isequal@4.5.0: resolution: {integrity: sha512-pDo3lu8Jhfjqls6GkMgpahsF9kCyayhgykjyLMNFTKWrpVdAQtYyB4muAMWozBB4ig/dtWAmsMxLEI8wuz+DYQ==} - dev: false /lodash.isfunction@3.0.9: resolution: {integrity: sha512-AirXNj15uRIMMPihnkInB4i3NHeb4iBtNg9WRWuK2o31S+ePwwNmDPaTL3o7dTJ+VXNZim7rFs4rxN4YU1oUJw==} @@ -25212,10 +25478,15 @@ packages: engines: {node: '>=10'} dependencies: semver: 7.5.4 + dev: true /make-error@1.3.6: resolution: {integrity: sha512-s8UhlNe7vPKomQhC1qFelMokr/Sc3AgNbso3n74mVPA5LTZwkB9NlXf4XPamLxJE8h0gh73rM94xvwRT2CVInw==} + /make-plural@7.3.0: + resolution: {integrity: sha512-/K3BC0KIsO+WK2i94LkMPv3wslMrazrQhfi5We9fMbLlLjzoOSJWr7TAdupLlDWaJcWxwoNosBkhFDejiu5VDw==} + dev: false + /makeerror@1.0.12: resolution: {integrity: sha512-JmqCvUhmt43madlpFzG4BQzG2Z3m6tvQDNKdClZnO3VbIudJYmxsT0FNJMeiB2+JTSlTQTSbU8QdesVmwJcmLg==} dependencies: @@ -25502,7 +25773,7 @@ packages: web-worker: 1.2.0 dev: false - /meros@1.3.0(@types/node@18.18.6): + /meros@1.3.0(@types/node@18.18.7): resolution: {integrity: sha512-2BNGOimxEz5hmjUG2FwoxCt5HN7BXdaWyFqEwxPTrJzVdABtrL4TiHTcsWSFAxPQ/tOnEaQEJh3qWq71QRMY+w==} engines: {node: '>=13'} peerDependencies: @@ -25511,7 +25782,7 @@ packages: '@types/node': optional: true dependencies: - '@types/node': 18.18.6 + '@types/node': 18.18.7 /methods@1.1.2: resolution: {integrity: sha512-iclAHeNqNm68zFtnZ0e+1L2yUIdvzNoauKU4WBA3VvH/vPFieF7qfRlwUZU+DA9P9bPXIS90ulxoUoCH23sV2w==} @@ -26300,42 +26571,6 @@ packages: /ms@2.1.3: resolution: {integrity: sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==} - /msw@1.3.2(typescript@4.9.5): - resolution: {integrity: sha512-wKLhFPR+NitYTkQl5047pia0reNGgf0P6a1eTnA5aNlripmiz0sabMvvHcicE8kQ3/gZcI0YiPFWmYfowfm3lA==} - engines: {node: '>=14'} - hasBin: true - requiresBuild: true - peerDependencies: - typescript: '>= 4.4.x <= 5.2.x' - peerDependenciesMeta: - typescript: - optional: true - dependencies: - '@mswjs/cookies': 0.2.2 - '@mswjs/interceptors': 0.17.10 - '@open-draft/until': 1.0.3 - '@types/cookie': 0.4.1 - '@types/js-levenshtein': 1.1.2 - chalk: 4.1.2 - chokidar: 3.5.3 - cookie: 0.4.2 - graphql: 16.8.1 - headers-polyfill: 3.2.5 - inquirer: 8.2.6 - is-node-process: 1.2.0 - js-levenshtein: 1.1.6 - node-fetch: 2.7.0 - outvariant: 1.4.0 - path-to-regexp: 6.2.1 - strict-event-emitter: 0.4.6 - type-fest: 2.19.0 - typescript: 4.9.5 - yargs: 17.7.2 - transitivePeerDependencies: - - encoding - - supports-color - dev: true - /multiaddr-to-uri@8.0.0(node-fetch@3.3.2): resolution: {integrity: sha512-dq4p/vsOOUdVEd1J1gl+R2GFrXJQH8yjLtz4hodqdVbieg39LvBOdMQRdQnfbg5LSM/q1BYNVf5CBbwZFFqBgA==} deprecated: This module is deprecated, please upgrade to @multiformats/multiaddr-to-uri @@ -26376,8 +26611,8 @@ packages: engines: {node: '>=16.0.0', npm: '>=7.0.0'} dev: false - /multiformats@12.1.2: - resolution: {integrity: sha512-6mRIsrZXyw5xNPO31IGBMmxgDXBSgCGDsBAtazkZ02ip4hMwZNrQvfxXZtytRoBSWuzSq5f9VmMnXj76fIz5FQ==} + /multiformats@12.1.3: + resolution: {integrity: sha512-eajQ/ZH7qXZQR2AgtfpmSMizQzmyYVmCql7pdhldPuYQi4atACekbJaQplk6dWyIi10jCaFnd6pqvcEFXjbaJw==} engines: {node: '>=16.0.0', npm: '>=7.0.0'} dev: false @@ -26537,7 +26772,7 @@ packages: '@next/env': 13.5.6 '@swc/helpers': 0.5.2 busboy: 1.6.0 - caniuse-lite: 1.0.30001553 + caniuse-lite: 1.0.30001554 postcss: 8.4.31 react: 18.2.0 react-dom: 18.2.0(react@18.2.0) @@ -26682,13 +26917,6 @@ packages: engines: {node: '>=12.19'} dev: true - /noms@0.0.0: - resolution: {integrity: sha512-lNDU9VJaOPxUmXcLb+HQFeUgQQPtMI24Gt6hgfuMHRJgMRHMF/qZ4HJD3GDru4sSw9IQl2jPjAYnQrdIeLbwow==} - dependencies: - inherits: 2.0.4 - readable-stream: 1.0.34 - dev: true - /non-layered-tidy-tree-layout@2.0.2: resolution: {integrity: sha512-gkXMxRzUH+PB0ax9dUN0yYF0S25BqeAYqhgMaLUFmpXLEk7Fcu8f4emJuOAY0V8kjDICxROIKsTAKsV/v355xw==} dev: false @@ -27017,8 +27245,9 @@ packages: /optimism@0.17.5: resolution: {integrity: sha512-TEcp8ZwK1RczmvMnvktxHSF2tKgMWjJ71xEFGX5ApLh67VsMSTy1ZUlipJw8W+KaqgOmQ+4pqwkeivY89j+4Vw==} + requiresBuild: true dependencies: - '@wry/context': 0.7.3 + '@wry/context': 0.7.4 '@wry/trie': 0.4.3 tslib: 2.6.2 dev: false @@ -27045,7 +27274,6 @@ packages: levn: 0.4.1 prelude-ls: 1.2.1 type-check: 0.4.0 - dev: true /ora@4.0.2: resolution: {integrity: sha512-YUOZbamht5mfLxPmk4M35CD/5DuOkAacxlEUbStVXpBAt4fyhBf+vZHI/HRkI++QUp3sNoeA2Gw4C+hi4eGSig==} @@ -27102,10 +27330,6 @@ packages: resolution: {integrity: sha512-KiOAIsdpUTcAXuykya5fnVVT+/5uS0Q1mrkRHcF89tpieSmY33O/tmc54CqwA+bfhbtEfZUNLHaPUiB9X3jt1A==} dev: false - /outvariant@1.4.0: - resolution: {integrity: sha512-AlWY719RF02ujitly7Kk/0QlV+pXGFDHrHf9O2OKqyqgBieaPOIeuSkL8sRK6j2WK+/ZAURq2kZsY0d8JapUiw==} - dev: true - /p-cancelable@0.4.1: resolution: {integrity: sha512-HNa1A8LvB1kie7cERyy21VNeHb2CWJJYqyyC2o3klWFfMGlFmWv2Z7sFgZH8ZiaYL95ydToKTFVXgMV/Os0bBQ==} engines: {node: '>=4'} @@ -28135,7 +28359,6 @@ packages: /prelude-ls@1.2.1: resolution: {integrity: sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g==} engines: {node: '>= 0.8.0'} - dev: true /prepend-http@2.0.0: resolution: {integrity: sha512-ravE6m9Atw9Z/jjttRUZ+clIXogdghyZAuWJ3qEzjT+jI/dL1ifAqhZeC5VHzQp1MSt1+jxKkFNemj/iO7tVUA==} @@ -28170,6 +28393,7 @@ packages: resolution: {integrity: sha512-tdN8qQGvNjw4CHbY+XXk0JgCXn9QiF21a55rBe5LJAU+kDyC4WQn4+awm2Xfk2lQMk5fKup9XgzTZtGkjBdP9Q==} engines: {node: '>=10.13.0'} hasBin: true + dev: true /pretty-bytes@5.6.0: resolution: {integrity: sha512-FFw039TmrBqFK8ma/7OL3sDz/VytdtJr044/QUJtH0wK9lb9jLq9tJyIxUwtQJHwar2BqtiA4iCWSwo9JLkzFg==} @@ -28227,7 +28451,7 @@ packages: engines: {node: '>=4'} dev: false - /primereact@9.6.3(@types/react@18.2.31)(react-dom@18.2.0)(react@18.2.0): + /primereact@9.6.3(@types/react@18.2.33)(react-dom@18.2.0)(react@18.2.0): resolution: {integrity: sha512-E1Apj4zHeEqFuNR43PFmcpYO51V17PDaVuZmYggEUxZHUo7XWoqkOGg7896SRRMDMBQcO3+HXdJQXi6DOWRV1g==} peerDependencies: '@types/react': ^17.0.0 || ^18.0.0 @@ -28237,7 +28461,7 @@ packages: '@types/react': optional: true dependencies: - '@types/react': 18.2.31 + '@types/react': 18.2.33 '@types/react-transition-group': 4.4.8 react: 18.2.0 react-dom: 18.2.0(react@18.2.0) @@ -28298,6 +28522,10 @@ packages: resolution: {integrity: sha512-7PiHtLll5LdnKIMw100I+8xJXR5gW2QwWYkT6iJva0bXitZKa/XMrSbdmg3r2Xnaidz9Qumd0VPaMrZlF9V9sA==} engines: {node: '>=0.4.0'} + /promise-polyfill@8.3.0: + resolution: {integrity: sha512-H5oELycFml5yto/atYqmjyigJoAo3+OXwolYiH7OfQuYlAqhxNvTfiNMbV9hsC6Yp83yE5r2KTVmtrG6R9i6Pg==} + dev: true + /promise@7.3.1: resolution: {integrity: sha512-nolQXZ/4L+bP/UGlkfaIujX9BKxGwmQ9OT4mOt5yvy8iK1h3wqTEJCijzGANTCCl9nWjY41juyAn2K3Q1hLLTg==} dependencies: @@ -28359,7 +28587,7 @@ packages: '@protobufjs/pool': 1.1.0 '@protobufjs/utf8': 1.1.0 '@types/long': 4.0.2 - '@types/node': 18.18.6 + '@types/node': 18.18.7 long: 4.0.0 /protobufjs@7.2.5: @@ -28377,7 +28605,7 @@ packages: '@protobufjs/path': 1.1.2 '@protobufjs/pool': 1.1.0 '@protobufjs/utf8': 1.1.0 - '@types/node': 18.18.6 + '@types/node': 18.18.7 long: 5.2.3 dev: false @@ -28462,6 +28690,7 @@ packages: /pure-rand@6.0.4: resolution: {integrity: sha512-LA0Y9kxMYv47GIPJy6MI84fqTd2HmYZI83W/kM/SkKfDlajnZYfmXFTxkbY+xSBPkLJxltMa9hIkmdc29eguMA==} + dev: true /pvtsutils@1.3.5: resolution: {integrity: sha512-ARvb14YB9Nm2Xi6nBq1ZX6dAM0FsJnuk+31aUp4TrcZEdKUlSqOqsxJHUPJDNE3qiIp+iUPEIeR6Je/tgV7zsA==} @@ -28658,7 +28887,7 @@ packages: pure-color: 1.3.0 dev: false - /react-dev-utils@12.0.1(typescript@4.9.5)(webpack@5.89.0): + /react-dev-utils@12.0.1(eslint@8.52.0)(typescript@4.9.5)(webpack@5.89.0): resolution: {integrity: sha512-84Ivxmr17KjUupyqzFode6xKhjwuEJDROWKJy/BthkL7Wn6NJ8h4WE6k/exAv6ImS+0oZLRRW5j/aINMHyeGeQ==} engines: {node: '>=14'} peerDependencies: @@ -28677,7 +28906,7 @@ packages: escape-string-regexp: 4.0.0 filesize: 8.0.7 find-up: 5.0.0 - fork-ts-checker-webpack-plugin: 6.5.3(typescript@4.9.5)(webpack@5.89.0) + fork-ts-checker-webpack-plugin: 6.5.3(eslint@8.52.0)(typescript@4.9.5)(webpack@5.89.0) global-modules: 2.0.0 globby: 11.1.0 gzip-size: 6.0.0 @@ -28700,8 +28929,8 @@ packages: - vue-template-compiler dev: false - /react-devtools-core@4.28.4: - resolution: {integrity: sha512-IUZKLv3CimeM07G3vX4H4loxVpByrzq3HvfTX7v9migalwvLs9ZY5D3S3pKR33U+GguYfBBdMMZyToFhsSE/iQ==} + /react-devtools-core@4.28.5: + resolution: {integrity: sha512-cq/o30z9W2Wb4rzBefjv5fBalHU0rJGZCHAkf/RHSBWSSYwh8PlQTqqOJmgIIbBtpj27T6FIPXeomIjZtCNVqA==} dependencies: shell-quote: 1.8.1 ws: 7.5.9 @@ -28757,6 +28986,7 @@ packages: /react-is@16.13.1: resolution: {integrity: sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ==} + requiresBuild: true /react-is@17.0.2: resolution: {integrity: sha512-w2GsyukL62IJnlaff/nRegPQR94C/XXamvMWmSHRJ4y7Ts/4ocGRmTHvOs8PSE6pB3dWOrD/nueuU5sduBsQ4w==} @@ -28797,7 +29027,7 @@ packages: webpack: 5.89.0(webpack-cli@5.1.4) dev: false - /react-markdown@8.0.7(@types/react@18.2.31)(react@18.2.0): + /react-markdown@8.0.7(@types/react@18.2.33)(react@18.2.0): resolution: {integrity: sha512-bvWbzG4MtOU62XqBx3Xx+zB2raaFFsq4mYiAzfjXJMEz2sixgeAfraA3tvzULF02ZdOMUOKTBFFaZJDDrq+BJQ==} peerDependencies: '@types/react': '>=16' @@ -28805,7 +29035,7 @@ packages: dependencies: '@types/hast': 2.3.7 '@types/prop-types': 15.7.9 - '@types/react': 18.2.31 + '@types/react': 18.2.33 '@types/unist': 2.0.9 comma-separated-tokens: 2.0.3 hast-util-whitespace: 2.0.1 @@ -28879,7 +29109,7 @@ packages: pretty-format: 26.6.2 promise: 8.3.0 react: 18.2.0 - react-devtools-core: 4.28.4 + react-devtools-core: 4.28.5 react-refresh: 0.4.3 react-shallow-renderer: 16.15.0(react@18.2.0) regenerator-runtime: 0.13.11 @@ -28901,7 +29131,7 @@ packages: resolution: {integrity: sha512-Hwln1VNuGl/6bVwnd0Xdn1e84gT/8T9aYNL+HAKDArLCS7LWjwr7StE30IEYbIkx0Vi3vs+coQxe+SQDbGbbpA==} engines: {node: '>=0.10.0'} - /react-remove-scroll-bar@2.3.4(@types/react@18.2.31)(react@18.2.0): + /react-remove-scroll-bar@2.3.4(@types/react@18.2.33)(react@18.2.0): resolution: {integrity: sha512-63C4YQBUt0m6ALadE9XV56hV8BgJWDmmTPY758iIJjfQKt2nYwoUrPk0LXRXcB/yIj82T1/Ixfdpdk68LwIB0A==} engines: {node: '>=10'} peerDependencies: @@ -28911,13 +29141,13 @@ packages: '@types/react': optional: true dependencies: - '@types/react': 18.2.31 + '@types/react': 18.2.33 react: 18.2.0 - react-style-singleton: 2.2.1(@types/react@18.2.31)(react@18.2.0) + react-style-singleton: 2.2.1(@types/react@18.2.33)(react@18.2.0) tslib: 2.6.2 dev: false - /react-remove-scroll@2.5.4(@types/react@18.2.31)(react@18.2.0): + /react-remove-scroll@2.5.4(@types/react@18.2.33)(react@18.2.0): resolution: {integrity: sha512-xGVKJJr0SJGQVirVFAUZ2k1QLyO6m+2fy0l8Qawbp5Jgrv3DeLalrfMNBFSlmz5kriGGzsVBtGVnf4pTKIhhWA==} engines: {node: '>=10'} peerDependencies: @@ -28927,13 +29157,13 @@ packages: '@types/react': optional: true dependencies: - '@types/react': 18.2.31 + '@types/react': 18.2.33 react: 18.2.0 - react-remove-scroll-bar: 2.3.4(@types/react@18.2.31)(react@18.2.0) - react-style-singleton: 2.2.1(@types/react@18.2.31)(react@18.2.0) + react-remove-scroll-bar: 2.3.4(@types/react@18.2.33)(react@18.2.0) + react-style-singleton: 2.2.1(@types/react@18.2.33)(react@18.2.0) tslib: 2.6.2 - use-callback-ref: 1.3.0(@types/react@18.2.31)(react@18.2.0) - use-sidecar: 1.1.2(@types/react@18.2.31)(react@18.2.0) + use-callback-ref: 1.3.0(@types/react@18.2.33)(react@18.2.0) + use-sidecar: 1.1.2(@types/react@18.2.33)(react@18.2.0) dev: false /react-router-config@5.1.1(react-router@5.3.4)(react@18.2.0): @@ -28988,7 +29218,7 @@ packages: react: 18.2.0 react-is: 18.2.0 - /react-style-singleton@2.2.1(@types/react@18.2.31)(react@18.2.0): + /react-style-singleton@2.2.1(@types/react@18.2.33)(react@18.2.0): resolution: {integrity: sha512-ZWj0fHEMyWkHzKYUr2Bs/4zU6XLmq9HsgBURm7g5pAVfyn49DgUiNgY2d4lXRlYSiCif9YBGpQleewkcqddc7g==} engines: {node: '>=10'} peerDependencies: @@ -28998,7 +29228,7 @@ packages: '@types/react': optional: true dependencies: - '@types/react': 18.2.31 + '@types/react': 18.2.33 get-nonce: 1.0.1 invariant: 2.2.4 react: 18.2.0 @@ -29232,6 +29462,7 @@ packages: /reduce-flatten@2.0.0: resolution: {integrity: sha512-EJ4UNY/U1t2P/2k6oqotuX2Cc3T6nxJwsM0N0asT7dhrtH1ltUxDn4NalSYmPE2rCkVpcf/X6R0wDwcFpzhd4w==} engines: {node: '>=6'} + dev: true /reflect.getprototypeof@1.0.4: resolution: {integrity: sha512-ECkTw8TmJwW60lOTR+ZkODISW6RQ8+2CL3COqtiJKLd6MmB45hN51HprHFziKLGkAuTGQhBb91V8cy+KHlaCjw==} @@ -29574,6 +29805,7 @@ packages: /resolve.exports@2.0.2: resolution: {integrity: sha512-X2UW6Nw3n/aMgDVy+0rSqgHlv39WZAlZrXCdnbyEiKm17DSqHX4MmQMaST3FbeWR5FTuRcUwYAziZajji0Y7mg==} engines: {node: '>=10'} + dev: true /resolve@1.1.7: resolution: {integrity: sha512-9znBF0vBcaSN3W2j7wKvdERPwqTxSpCq+if5C0WoTCyV9n24rua28jeuQ2pL/HOf+yUe/Mef+H/5p60K0Id3bg==} @@ -29604,6 +29836,7 @@ packages: /response-iterator@0.2.6: resolution: {integrity: sha512-pVzEEzrsg23Sh053rmDUvLSkGXluZio0qu8VT6ukrYuvtjVfCbDZH9d6PGXb8HZfzdNZt8feXv/jvUzlhRgLnw==} engines: {node: '>=0.8'} + requiresBuild: true dev: false /responselike@1.0.2: @@ -29730,7 +29963,7 @@ packages: semver: 5.7.2 dev: true - /rollup-plugin-dts@5.3.1(rollup@3.29.4)(typescript@4.9.5): + /rollup-plugin-dts@5.3.1(rollup@3.29.4)(typescript@5.1.6): resolution: {integrity: sha512-gusMi+Z4gY/JaEQeXnB0RUdU82h1kF0WYzCWgVmV4p3hWXqelaKuCvcJawfeg+EKn2T1Ie+YWF2OiN1/L8bTVg==} engines: {node: '>=v14.21.3'} peerDependencies: @@ -29739,7 +29972,7 @@ packages: dependencies: magic-string: 0.30.5 rollup: 3.29.4 - typescript: 4.9.5 + typescript: 5.1.6 optionalDependencies: '@babel/code-frame': 7.22.13 dev: true @@ -29868,8 +30101,8 @@ packages: '@babel/runtime': 7.23.2 dev: false - /rtl-detect@1.0.4: - resolution: {integrity: sha512-EBR4I2VDSSYr7PkBmFy04uhycIpDKp+21p/jARYXlCSjQksTBQcJ0HFUPOO79EPPH5JS6VAhiIQbycf0O3JAxQ==} + /rtl-detect@1.1.2: + resolution: {integrity: sha512-PGMBq03+TTG/p/cRB7HCLKJ1MgDIi07+QU1faSjiYRfmY5UsAttV9Hs08jDAHVwcOwmVLcSJkpwyfXszVjWfIQ==} dev: false /rtlcss@3.5.0: @@ -30578,7 +30811,7 @@ packages: resolution: {integrity: sha512-wciNMLg/Irp8OKGrh3S2tfvZiZ0NEyILfcRCXCD4mp7SgK/i9gzLfhY2hY7VMCQJ3kH9UB9BzNdibIVMchzyYw==} dev: true - /solidity-coverage@0.8.5(hardhat@2.13.1): + /solidity-coverage@0.8.5(hardhat@2.18.3): resolution: {integrity: sha512-6C6N6OV2O8FQA0FWA95FdzVH+L16HU94iFgg5wAFZ29UpLFkgNI/DRR2HotG1bC0F4gAc/OMs2BJI44Q/DYlKQ==} hasBin: true peerDependencies: @@ -30594,7 +30827,7 @@ packages: ghost-testrpc: 0.0.2 global-modules: 2.0.0 globby: 10.0.2 - hardhat: 2.13.1(ts-node@10.9.1)(typescript@4.9.5) + hardhat: 2.18.3(ts-node@10.9.1)(typescript@4.9.5) jsonschema: 1.4.1 lodash: 4.17.21 mocha: 10.2.0 @@ -30609,6 +30842,10 @@ packages: - supports-color dev: true + /solmate@6.2.0: + resolution: {integrity: sha512-AM38ioQ2P8zRsA42zenb9or6OybRjOLXIu3lhIT8rhddUuduCt76pUEuLxOIg9GByGojGz+EbpFdCB6B+QZVVA==} + dev: true + /sonic-boom@2.8.0: resolution: {integrity: sha512-kuonw1YOYYNOve5iHdSahXPOK49GqwA+LZhI6Wz/l0rP57iKyXXIHaRagOBHAPmGwJC6od2Z9zgvZ5loSgMlVg==} dependencies: @@ -30657,6 +30894,7 @@ packages: dependencies: buffer-from: 1.1.2 source-map: 0.6.1 + dev: true /source-map-support@0.5.21: resolution: {integrity: sha512-uBHU3L3czsIyYXKX88fdrGovxdSCoTGDRZ6SYXtSRxLZUzHg5P/66Ht6uoUlHu9EZod+inXhKo3qQgwXUT/y1w==} @@ -30919,16 +31157,6 @@ packages: resolution: {integrity: sha512-Mcc5wHehp9aXz1ax6bZUyY5afg9u2rv5cqQI3mRrYkGC8rW2hM02jWuwjtL++LS5qinSyhj2QfLyNsuc+VsExg==} engines: {node: '>=10.0.0'} - /strict-event-emitter@0.2.8: - resolution: {integrity: sha512-KDf/ujU8Zud3YaLtMCcTI4xkZlZVIYxTLr+XIULexP+77EEVWixeXroLUXQXiVtH4XH2W7jr/3PT1v3zBuvc3A==} - dependencies: - events: 3.3.0 - dev: true - - /strict-event-emitter@0.4.6: - resolution: {integrity: sha512-12KWeb+wixJohmnwNFerbyiBrAlq5qJLwIt38etRtKtmmHyDSoGlIqFE9wx+4IwG0aDjI7GV8tc8ZccjWZZtTg==} - dev: true - /strict-uri-encode@1.1.0: resolution: {integrity: sha512-R3f198pcvnB+5IpnBlRkphuE9n46WyVl8I39W/ZUTZLz4nqSP/oLYUrcnJrw462Ds8he4YKMov2efsTIw1BDGQ==} engines: {node: '>=0.10.0'} @@ -30946,6 +31174,7 @@ packages: /string-format@2.0.0: resolution: {integrity: sha512-bbEs3scLeYNXLecRRuk6uJxdXUSj6le/8rNPHChIJTn2V79aXVTR1EH2OH5zLKKoz0V02fOUKZZcw01pLUShZA==} + dev: true /string-length@4.0.2: resolution: {integrity: sha512-+l6rNN5fYHNhZZy41RXsYptCjA2Igmq4EG7kZAYFQI1E1VTXarr6ZPXBg6eq7Y6eK4FEhY6AJlyuFIb/v/S0VQ==} @@ -30953,6 +31182,7 @@ packages: dependencies: char-regex: 1.0.2 strip-ansi: 6.0.1 + dev: true /string-similarity@4.0.4: resolution: {integrity: sha512-/q/8Q4Bl4ZKAPjj8WerIBJWALKkaPRfrvhfF8k/B23i4nzrlRj2/go1m90In7nG/3XDSbOo0+pu6RvCTM9RGMQ==} @@ -31105,6 +31335,7 @@ packages: /strip-bom@4.0.0: resolution: {integrity: sha512-3xurFv5tEgii33Zi8Jtp55wEIILR9eh34FAW00PZf+JnSsTmV/ioewSgQl97JHvgjoRGwPShsWm+IdrxB35d0w==} engines: {node: '>=8'} + dev: true /strip-dirs@2.1.0: resolution: {integrity: sha512-JOCxOeKLm2CAS73y/U4ZeZPTkE+gNVCzKt7Eox84Iej1LT/2pTWYpZKJuxwQpvX1LiZb1xokNR7RLfuBAa7T3g==} @@ -31296,6 +31527,7 @@ packages: /symbol-observable@4.0.0: resolution: {integrity: sha512-b19dMThMV4HVFynSAM1++gBHAbk2Tc/osgLIBZMKsyqh34jb2e8Os7T6ZW/Bt3pJFdBTd2JwAnAAEQV7rSNvcQ==} engines: {node: '>=0.10'} + requiresBuild: true dev: false /symbol-tree@3.2.4: @@ -31325,6 +31557,7 @@ packages: deep-extend: 0.6.0 typical: 5.2.0 wordwrapjs: 4.0.1 + dev: true /table@6.8.1: resolution: {integrity: sha512-Y4X9zqrCftUhMeH2EptSSERdVKt/nEdijTOacGD/97EKjhQ/Qs8RTlEGABSJNNN8lac9kheH+af7yAkEWlgneA==} @@ -31436,6 +31669,7 @@ packages: '@istanbuljs/schema': 0.1.3 glob: 7.2.3 minimatch: 3.1.2 + dev: true /testrpc@0.0.1: resolution: {integrity: sha512-afH1hO+SQ/VPlmaLUFj2636QMeDvPCeQMc/9RBMW0IfjNe9gFD9Ra3ShqYkB7py0do1ZcCna/9acHyzTJ+GcNA==} @@ -31743,6 +31977,7 @@ packages: command-line-args: 5.2.1 command-line-usage: 6.1.3 string-format: 2.0.0 + dev: true /ts-dedent@2.2.0: resolution: {integrity: sha512-q5W7tVM71e2xjHZTlgfTDoPF/SmqKG5hddq9SzR49CH2hayqRKJtQ4mtRlSxKaJlR/+9rEM+mnBHf7I2/BQcpQ==} @@ -31759,6 +31994,7 @@ packages: typescript: '>=3.7.0' dependencies: typescript: 4.9.5 + dev: true /ts-essentials@7.0.3(typescript@5.1.6): resolution: {integrity: sha512-8+gr5+lqO3G84KdiTSMRLtuyJ+nTBVRKuCrK4lidMPdVeEp0uqC875uE5NMcaA7YYMN7XsNiFQuMvasF8HT/xQ==} @@ -31766,7 +32002,7 @@ packages: typescript: '>=3.7.0' dependencies: typescript: 5.1.6 - dev: false + dev: true /ts-interface-checker@0.1.13: resolution: {integrity: sha512-Y/arvbn+rrz3JCKl9C4kVNfTfSm2/mEp5FSz5EsZSANGPSlQrpRI5M4PKF+mJnE52jOO90PnPSc3Ur3bTQw0gA==} @@ -31775,6 +32011,7 @@ packages: /ts-invariant@0.10.3: resolution: {integrity: sha512-uivwYcQaxAucv1CzRp2n/QdYPo4ILf9VXgH19zEIjFx2EJufV16P0JtJVpYHy89DItG6Kwj2oIUjrcK5au+4tQ==} engines: {node: '>=8'} + requiresBuild: true dependencies: tslib: 2.6.2 dev: false @@ -31785,7 +32022,7 @@ packages: jest-resolve: 29.7.0 dev: true - /ts-jest@29.1.1(@babel/core@7.23.2)(babel-jest@29.7.0)(esbuild@0.17.19)(jest@29.7.0)(typescript@4.9.5): + /ts-jest@29.1.1(@babel/core@7.23.2)(babel-jest@29.7.0)(esbuild@0.17.19)(jest@29.7.0)(typescript@5.1.6): resolution: {integrity: sha512-D6xjnnbP17cC85nliwGiL+tpoKN0StpgE0TeOjXQTU6MVCfsB4v7aW05CgQ/1OywGb0x/oy9hHFnN+sczTiRaA==} engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} hasBin: true @@ -31811,13 +32048,13 @@ packages: bs-logger: 0.2.6 esbuild: 0.17.19 fast-json-stable-stringify: 2.1.0 - jest: 29.7.0(@types/node@18.18.6)(ts-node@10.9.1) + jest: 29.7.0(@types/node@18.18.7)(ts-node@10.9.1) jest-util: 29.7.0 json5: 2.2.3 lodash.memoize: 4.1.2 make-error: 1.3.6 semver: 7.5.4 - typescript: 4.9.5 + typescript: 5.1.6 yargs-parser: 21.1.1 dev: true @@ -31850,7 +32087,7 @@ packages: tsconfig-paths: 3.14.2 dev: true - /ts-node@10.9.1(@types/node@18.18.6)(typescript@4.9.5): + /ts-node@10.9.1(@types/node@18.18.7)(typescript@4.9.5): resolution: {integrity: sha512-NtVysVPkxxrwFGUUxGYhfux8k78pQB3JqYBXlLRZgdGUqTO5wU/UyHop5p70iEbGhB7q5KmiZiU0Y3KlJrScEw==} hasBin: true peerDependencies: @@ -31869,7 +32106,7 @@ packages: '@tsconfig/node12': 1.0.11 '@tsconfig/node14': 1.0.3 '@tsconfig/node16': 1.0.4 - '@types/node': 18.18.6 + '@types/node': 18.18.7 acorn: 8.10.0 acorn-walk: 8.2.0 arg: 4.1.3 @@ -31880,7 +32117,7 @@ packages: v8-compile-cache-lib: 3.0.1 yn: 3.1.1 - /ts-node@10.9.1(@types/node@18.18.6)(typescript@5.1.6): + /ts-node@10.9.1(@types/node@18.18.7)(typescript@5.1.6): resolution: {integrity: sha512-NtVysVPkxxrwFGUUxGYhfux8k78pQB3JqYBXlLRZgdGUqTO5wU/UyHop5p70iEbGhB7q5KmiZiU0Y3KlJrScEw==} hasBin: true peerDependencies: @@ -31899,7 +32136,7 @@ packages: '@tsconfig/node12': 1.0.11 '@tsconfig/node14': 1.0.3 '@tsconfig/node16': 1.0.4 - '@types/node': 18.18.6 + '@types/node': 18.18.7 acorn: 8.10.0 acorn-walk: 8.2.0 arg: 4.1.3 @@ -31910,38 +32147,6 @@ packages: v8-compile-cache-lib: 3.0.1 yn: 3.1.1 - /ts-node@10.9.1(@types/node@18.18.6)(typescript@5.2.2): - resolution: {integrity: sha512-NtVysVPkxxrwFGUUxGYhfux8k78pQB3JqYBXlLRZgdGUqTO5wU/UyHop5p70iEbGhB7q5KmiZiU0Y3KlJrScEw==} - hasBin: true - peerDependencies: - '@swc/core': '>=1.2.50' - '@swc/wasm': '>=1.2.50' - '@types/node': '*' - typescript: '>=2.7' - peerDependenciesMeta: - '@swc/core': - optional: true - '@swc/wasm': - optional: true - dependencies: - '@cspotcode/source-map-support': 0.8.1 - '@tsconfig/node10': 1.0.9 - '@tsconfig/node12': 1.0.11 - '@tsconfig/node14': 1.0.3 - '@tsconfig/node16': 1.0.4 - '@types/node': 18.18.6 - acorn: 8.10.0 - acorn-walk: 8.2.0 - arg: 4.1.3 - create-require: 1.1.1 - diff: 4.0.2 - make-error: 1.3.6 - typescript: 5.2.2 - v8-compile-cache-lib: 3.0.1 - yn: 3.1.1 - dev: true - optional: true - /ts-node@10.9.1(@types/node@20.5.1)(typescript@4.9.5): resolution: {integrity: sha512-NtVysVPkxxrwFGUUxGYhfux8k78pQB3JqYBXlLRZgdGUqTO5wU/UyHop5p70iEbGhB7q5KmiZiU0Y3KlJrScEw==} hasBin: true @@ -31990,6 +32195,7 @@ packages: /tsconfig-paths@3.14.2: resolution: {integrity: sha512-o/9iXgCYc5L/JxCHPe3Hvh8Q/2xm5Z+p18PESBU6Ff33695QnCHBEjcytY2q19ua7Mbl/DavtBOLq+oG0RCL+g==} + requiresBuild: true dependencies: '@types/json5': 0.0.29 json5: 1.0.2 @@ -32008,6 +32214,9 @@ packages: /tslib@1.14.1: resolution: {integrity: sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==} + /tslib@2.4.0: + resolution: {integrity: sha512-d6xOpEDfsi2CZVlPQzGeux8XMwLT9hssAsaPYExaQMuYskwb+x1x7J371tWlbBdWHroy99KnVB6qIkUbs5X3UQ==} + /tslib@2.4.1: resolution: {integrity: sha512-tGyy4dAjRIEwI7BzsB0lynWgOpfqjUdq91XXAlIWD2OwKBH7oCl/GZG/HT4BOHrTlPMOASlMQ7veyTqpmRcrNA==} @@ -32142,7 +32351,6 @@ packages: engines: {node: '>= 0.8.0'} dependencies: prelude-ls: 1.2.1 - dev: true /type-detect@4.0.8: resolution: {integrity: sha512-0fr/mIH1dlO+x7TlcMy+bIDqKPsw/70tVyeHW787goQjhmqaZe10uwLujubK9q9Lg6Fiho1KUKDYz0Z7k7g5/g==} @@ -32180,6 +32388,7 @@ packages: /type-fest@2.19.0: resolution: {integrity: sha512-RAH822pAdBgcNMAfWnCBU3CFZcfZ/i1eZjwFU/dsLKumyuuP3niueg2UAukXYF0E2AAoc82ZSSf9J0WQBinzHA==} engines: {node: '>=12.20'} + dev: false /type-is@1.6.18: resolution: {integrity: sha512-TkRKr9sUTxEH8MdfuCSP7VizJyzRNMjj2J2do2Jr3Kym598JVdEksuzPQCnlFPW4ky9Q+iA+ma9BGm06XQBy8g==} @@ -32213,6 +32422,7 @@ packages: typescript: 4.9.5 transitivePeerDependencies: - supports-color + dev: true /typechain@8.3.2(typescript@5.1.6): resolution: {integrity: sha512-x/sQYr5w9K7yv3es7jo4KTX05CLxOf7TRWwoHlrjRh8H82G64g+k7VuWPJlgMo6qrjfCulOdfBjiaDtmhFYD/Q==} @@ -32233,7 +32443,7 @@ packages: typescript: 5.1.6 transitivePeerDependencies: - supports-color - dev: false + dev: true /typed-array-buffer@1.0.0: resolution: {integrity: sha512-Y8KTSIglk9OZEr8zywiIHG/kmQ7KWyjseXs1CbSo8vC42w7hg2HgYTxSWwP0+is7bWDc1H+Fo026CpHFwm8tkw==} @@ -32282,13 +32492,13 @@ packages: resolution: {integrity: sha512-/aCDEGatGvZ2BIk+HmLf4ifCJFwvKFNb9/JeZPMulfgFracn9QFcAf5GO8B/mweUjSoblS5In0cWhqpfs/5PQA==} dev: true - /typedoc-plugin-markdown@3.16.0(typedoc@0.23.28): - resolution: {integrity: sha512-eeiC78fDNGFwemPIHiwRC+mEC7W5jwt3fceUev2gJ2nFnXpVHo8eRrpC9BLWZDee6ehnz/sPmNjizbXwpfaTBw==} + /typedoc-plugin-markdown@3.17.0(typedoc@0.23.28): + resolution: {integrity: sha512-+uh5fHNfNSGdUxae0FWOuJ8Xu9Sl08jkdshOg6dilAqN/ZXmYsUFFDKw70fYfiGxdCLvpUuyr9FYO+WAa2lHeA==} peerDependencies: typedoc: '>=0.24.0' dependencies: handlebars: 4.7.8 - typedoc: 0.23.28(typescript@4.9.5) + typedoc: 0.23.28(typescript@5.1.6) dev: true /typedoc-plugin-missing-exports@2.1.0(typedoc@0.23.28): @@ -32296,10 +32506,10 @@ packages: peerDependencies: typedoc: 0.24.x || 0.25.x dependencies: - typedoc: 0.23.28(typescript@4.9.5) + typedoc: 0.23.28(typescript@5.1.6) dev: true - /typedoc@0.23.28(typescript@4.9.5): + /typedoc@0.23.28(typescript@5.1.6): resolution: {integrity: sha512-9x1+hZWTHEQcGoP7qFmlo4unUoVJLB0H/8vfO/7wqTnZxg4kPuji9y3uRzEu0ZKez63OJAUmiGhUrtukC6Uj3w==} engines: {node: '>= 14.14'} hasBin: true @@ -32310,7 +32520,7 @@ packages: marked: 4.3.0 minimatch: 7.4.6 shiki: 0.14.5 - typescript: 4.9.5 + typescript: 5.1.6 dev: true /typescript@4.9.5: @@ -32323,21 +32533,15 @@ packages: engines: {node: '>=14.17'} hasBin: true - /typescript@5.2.2: - resolution: {integrity: sha512-mI4WrpHsbCIcwT9cF4FZvr80QUeKvsUsUvKDoR+X/7XHQH98xYD8YHZg7ANtz2GtZt/CBq2QJ0thkGJMHfqc1w==} - engines: {node: '>=14.17'} - hasBin: true - requiresBuild: true - dev: true - optional: true - /typical@4.0.0: resolution: {integrity: sha512-VAH4IvQ7BDFYglMd7BPRDfLgxZZX4O4TFcRDA6EN5X7erNJJq+McIEp8np9aVtxrCJ6qx4GTYVfOWNjcqwZgRw==} engines: {node: '>=8'} + dev: true /typical@5.2.0: resolution: {integrity: sha512-dvdQgNDNJo+8B2uBQoqdb11eUCE1JQXhvjC/CZtgvZseVd5TYMXnq0+vuUemXbd/Se29cTaUuPX3YIc2xgbvIg==} engines: {node: '>=8'} + dev: true /ua-parser-js@1.0.36: resolution: {integrity: sha512-znuyCIXzl8ciS3+y3fHJI/2OhQIXbXw9MWC/o3qwyR+RGppjZHrM27CGFSKCJXi2Kctiz537iOu2KnXs1lMQhw==} @@ -32394,7 +32598,7 @@ packages: /uint8arrays@4.0.6: resolution: {integrity: sha512-4ZesjQhqOU2Ip6GPReIwN60wRxIupavL8T0Iy36BBHr2qyMrNxsPJvr7vpS4eFt8F8kSguWUPad6ZM9izs/vyw==} dependencies: - multiformats: 12.1.2 + multiformats: 12.1.3 dev: false /unbox-primitive@1.0.2: @@ -32421,6 +32625,9 @@ packages: resolution: {integrity: sha512-+A5Sja4HP1M08MaXya7p5LvjuM7K6q/2EaC0+iovj/wOcMsTzMvDFbasi/oSapiwOlt252IqsKqPjCl7huKS0A==} dev: true + /undici-types@5.26.5: + resolution: {integrity: sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==} + /undici@5.26.5: resolution: {integrity: sha512-cSb4bPFd5qgR7qr2jYAi0hlX9n5YKK2ONKkLFkxl+v/9BvC0sOpZjBHDBSXc5lWAf5ty9oZdRXytBIHzgUcerw==} engines: {node: '>=14.0'} @@ -32722,7 +32929,7 @@ packages: /urlpattern-polyfill@9.0.0: resolution: {integrity: sha512-WHN8KDQblxd32odxeIgo83rdVDE2bvdkb86it7bMhYZwWKJz0+O0RK/eZiHYnM+zgt/U7hAHOlCQGfjjvSkw2g==} - /use-callback-ref@1.3.0(@types/react@18.2.31)(react@18.2.0): + /use-callback-ref@1.3.0(@types/react@18.2.33)(react@18.2.0): resolution: {integrity: sha512-3FT9PRuRdbB9HfXhEq35u4oZkvpJ5kuYbpqhCfmiZyReuRgpnhDlbr2ZEnnuS0RrJAPn6l23xjFg9kpDM+Ms7w==} engines: {node: '>=10'} peerDependencies: @@ -32732,7 +32939,7 @@ packages: '@types/react': optional: true dependencies: - '@types/react': 18.2.31 + '@types/react': 18.2.33 react: 18.2.0 tslib: 2.6.2 dev: false @@ -32770,7 +32977,7 @@ packages: use-isomorphic-layout-effect: 1.1.2(react@18.2.0) dev: false - /use-sidecar@1.1.2(@types/react@18.2.31)(react@18.2.0): + /use-sidecar@1.1.2(@types/react@18.2.33)(react@18.2.0): resolution: {integrity: sha512-epTbsLuzZ7lPClpz2TyryBfztm7m+28DlEv2ZCQ3MDr5ssiwyOwGH/e5F9CkfWjJ1t4clvI58yF822/GUkjjhw==} engines: {node: '>=10'} peerDependencies: @@ -32780,7 +32987,7 @@ packages: '@types/react': optional: true dependencies: - '@types/react': 18.2.31 + '@types/react': 18.2.33 detect-node-es: 1.1.0 react: 18.2.0 tslib: 2.6.2 @@ -32841,6 +33048,7 @@ packages: is-generator-function: 1.0.10 is-typed-array: 1.1.12 which-typed-array: 1.1.13 + dev: false /utila@0.4.0: resolution: {integrity: sha512-Z0DbgELS9/L/75wZbro8xAnT50pBVFQZ+hUEueGDU5FN51YSCYM+jdxsfCiHjwNP/4LCDD0i/graKpeBnOXKRA==} @@ -32899,6 +33107,7 @@ packages: '@jridgewell/trace-mapping': 0.3.20 '@types/istanbul-lib-coverage': 2.0.5 convert-source-map: 2.0.0 + dev: true /validate-npm-package-license@3.0.4: resolution: {integrity: sha512-DpKm2Ui/xN7/HQKCtpZxoRWBhZ9Z0kqtygG8XCgNQ8ZlDnxuQmWhj566j8fN4Cu3/JmbhsDo7fcAJq4s9h27Ew==} @@ -32913,15 +33122,33 @@ packages: builtins: 5.0.1 dev: true - /valtio@1.10.6(react@18.2.0): - resolution: {integrity: sha512-SxN1bHUmdhW6V8qsQTpCgJEwp7uHbntuH0S9cdLQtiohuevwBksbpXjwj5uDMA7bLwg1WKyq9sEpZrx3TIMrkA==} + /valtio@1.11.0(react@18.2.0): + resolution: {integrity: sha512-65Yd0yU5qs86b5lN1eu/nzcTgQ9/6YnD6iO+DDaDbQLn1Zv2w12Gwk43WkPlUBxk5wL/6cD5YMFf7kj6HZ1Kpg==} + engines: {node: '>=12.20.0'} + peerDependencies: + react: '>=16.8' + peerDependenciesMeta: + react: + optional: true + dependencies: + proxy-compare: 2.5.1 + react: 18.2.0 + use-sync-external-store: 1.2.0(react@18.2.0) + dev: false + + /valtio@1.11.2(@types/react@18.2.33)(react@18.2.0): + resolution: {integrity: sha512-1XfIxnUXzyswPAPXo1P3Pdx2mq/pIqZICkWN60Hby0d9Iqb+MEIpqgYVlbflvHdrp2YR/q3jyKWRPJJ100yxaw==} engines: {node: '>=12.20.0'} peerDependencies: + '@types/react': '>=16.8' react: '>=16.8' peerDependenciesMeta: + '@types/react': + optional: true react: optional: true dependencies: + '@types/react': 18.2.33 proxy-compare: 2.5.1 react: 18.2.0 use-sync-external-store: 1.2.0(react@18.2.0) @@ -33017,32 +33244,30 @@ packages: - zod dev: true - /viem@1.5.3(typescript@5.1.6)(zod@3.22.4): - resolution: {integrity: sha512-oImpSDDvm8Y72qxXV0pCAGAqQLYgo8YENdz9EKS8ExnnOJLascpex4LNazNyp9cksjm3ORpVpbqGMr9Cy1z2mg==} + /viem@1.18.4(typescript@5.1.6)(zod@3.22.4): + resolution: {integrity: sha512-im+y30k+IGT6VtfD/q1V0RX5PaiHPsFTHkKqvTjTqV+ZT8RgJXzOGPXr5E0uPIm2cbJAJp6A9nR9BCHY7BKR2Q==} peerDependencies: typescript: '>=5.0.4' peerDependenciesMeta: typescript: optional: true dependencies: - '@adraffy/ens-normalize': 1.9.0 - '@noble/curves': 1.0.0 - '@noble/hashes': 1.3.0 - '@scure/bip32': 1.3.0 - '@scure/bip39': 1.2.0 - '@types/ws': 8.5.8 - '@wagmi/chains': 1.6.0(typescript@5.1.6) - abitype: 0.9.3(typescript@5.1.6)(zod@3.22.4) - isomorphic-ws: 5.0.0(ws@8.12.0) + '@adraffy/ens-normalize': 1.9.4 + '@noble/curves': 1.2.0 + '@noble/hashes': 1.3.2 + '@scure/bip32': 1.3.2 + '@scure/bip39': 1.2.1 + abitype: 0.9.8(typescript@5.1.6)(zod@3.22.4) + isows: 1.0.3(ws@8.13.0) typescript: 5.1.6 - ws: 8.12.0 + ws: 8.13.0 transitivePeerDependencies: - bufferutil - utf-8-validate - zod dev: false - /vite-node@0.28.5(@types/node@18.18.6): + /vite-node@0.28.5(@types/node@18.18.7): resolution: {integrity: sha512-LmXb9saMGlrMZbXTvOveJKwMTBTNUH66c8rJnQ0ZPNX+myPEol64+szRzXtV5ORb0Hb/91yq+/D3oERoyAt6LA==} engines: {node: '>=v14.16.0'} hasBin: true @@ -33054,7 +33279,7 @@ packages: picocolors: 1.0.0 source-map: 0.6.1 source-map-support: 0.5.21 - vite: 4.5.0(@types/node@18.18.6) + vite: 4.5.0(@types/node@18.18.7) transitivePeerDependencies: - '@types/node' - less @@ -33066,7 +33291,7 @@ packages: - terser dev: true - /vite@4.5.0(@types/node@18.18.6): + /vite@4.5.0(@types/node@18.18.7): resolution: {integrity: sha512-ulr8rNLA6rkyFAlVWw2q5YJ91v098AFQ2R0PRFwPzREXOUJQPtFUG0t+/ZikhaOCDqFoDhN6/v8Sq0o4araFAw==} engines: {node: ^14.18.0 || >=16.0.0} hasBin: true @@ -33094,7 +33319,7 @@ packages: terser: optional: true dependencies: - '@types/node': 18.18.6 + '@types/node': 18.18.7 esbuild: 0.18.20 postcss: 8.4.31 rollup: 3.29.4 @@ -33126,7 +33351,7 @@ packages: dependencies: '@types/chai': 4.3.9 '@types/chai-subset': 1.3.4 - '@types/node': 18.18.6 + '@types/node': 18.18.7 '@vitest/expect': 0.28.5 '@vitest/runner': 0.28.5 '@vitest/spy': 0.28.5 @@ -33145,8 +33370,8 @@ packages: tinybench: 2.5.1 tinypool: 0.3.1 tinyspy: 1.1.1 - vite: 4.5.0(@types/node@18.18.6) - vite-node: 0.28.5(@types/node@18.18.6) + vite: 4.5.0(@types/node@18.18.7) + vite-node: 0.28.5(@types/node@18.18.7) why-is-node-running: 2.2.2 transitivePeerDependencies: - less @@ -33195,8 +33420,8 @@ packages: hasBin: true dev: true - /wagmi@1.3.9(@types/react@18.2.31)(react-dom@18.2.0)(react-native@0.72.6)(react@18.2.0)(typescript@5.1.6)(viem@1.5.3)(zod@3.22.4): - resolution: {integrity: sha512-BQbl+vWLNpLraXd/MWsl1P3I41l7DHrujx6qshIa1HDV7Mdh0GNrDuluRYBtuK2bBx9WM/Fjw45Ef2aKADan9A==} + /wagmi@1.4.5(@types/react@18.2.33)(react-dom@18.2.0)(react-native@0.72.6)(react@18.2.0)(typescript@5.1.6)(viem@1.18.4)(zod@3.22.4): + resolution: {integrity: sha512-Ph62E6cO5n2Z8Z5LTyZrkaNprxTsbC4w0qZJT4OJdXrEELziI8z/b4FO6amVFXdu2rDp/wpvF56e4mhKC8/Kdw==} peerDependencies: react: '>=17.0.0' typescript: '>=5.0.4' @@ -33208,12 +33433,12 @@ packages: '@tanstack/query-sync-storage-persister': 4.36.1 '@tanstack/react-query': 4.36.1(react-dom@18.2.0)(react-native@0.72.6)(react@18.2.0) '@tanstack/react-query-persist-client': 4.36.1(@tanstack/react-query@4.36.1) - '@wagmi/core': 1.3.8(@types/react@18.2.31)(react@18.2.0)(typescript@5.1.6)(viem@1.5.3)(zod@3.22.4) + '@wagmi/core': 1.4.5(@types/react@18.2.33)(react@18.2.0)(typescript@5.1.6)(viem@1.18.4)(zod@3.22.4) abitype: 0.8.7(typescript@5.1.6)(zod@3.22.4) react: 18.2.0 typescript: 5.1.6 use-sync-external-store: 1.2.0(react@18.2.0) - viem: 1.5.3(typescript@5.1.6)(zod@3.22.4) + viem: 1.18.4(typescript@5.1.6)(zod@3.22.4) transitivePeerDependencies: - '@react-native-async-storage/async-storage' - '@types/react' @@ -33284,6 +33509,7 @@ packages: util: 0.12.5 optionalDependencies: '@zxing/text-encoding': 0.9.0 + dev: false /web-namespaces@1.1.4: resolution: {integrity: sha512-wYxSGajtmoP4WxfejAPIr4l0fVh+jeMXZb08wNc0tMg6xsfZXj3cECqIK0G7ZAqUq0PP8WlMDtaOGVBTAWztNw==} @@ -33744,6 +33970,7 @@ packages: dependencies: reduce-flatten: 2.0.0 typical: 5.2.0 + dev: true /workerpool@6.2.1: resolution: {integrity: sha512-ILEIE97kDZvF9Wb9f6h5aXK4swSlKGUcOEGiIYb2OOu/IrDU9iwj0fD//SsA6E5ibwJxpEvhullJY4Sl4GcpAw==} @@ -33834,6 +34061,7 @@ packages: dependencies: imurmurhash: 0.1.4 signal-exit: 3.0.7 + dev: true /ws@6.2.2: resolution: {integrity: sha512-zmhltoSR8u1cnDsD43TX59mzoMZsLKqUweyYBAIvTngR3shc0W6aOZylZmq/7hqyVxPdi+5Ud2QInblgyE72fw==} @@ -33896,6 +34124,7 @@ packages: optional: true utf-8-validate: optional: true + dev: true /ws@8.13.0: resolution: {integrity: sha512-x9vcZYTrFPC7aSIbj7sRCYo7L/Xb8Iy+pW0ng0wt2vCJv7M9HOMy0UoN3rr+IFC7hb7vXoqS+P9ktyLLLhO+LA==} @@ -33924,6 +34153,18 @@ packages: bufferutil: 4.0.8 utf-8-validate: 5.0.10 + /ws@8.5.0: + resolution: {integrity: sha512-BWX0SWVgLPzYwF8lTzEy1egjhS4S4OEAHfsO8o65WOVsrnSRGaSiUaa9e0ggGlkMTtBlmOpEXiie9RUcBO86qg==} + engines: {node: '>=10.0.0'} + peerDependencies: + bufferutil: ^4.0.1 + utf-8-validate: ^5.0.2 + peerDependenciesMeta: + bufferutil: + optional: true + utf-8-validate: + optional: true + /xdg-basedir@4.0.0: resolution: {integrity: sha512-PSNhEJDejZYV7h50BohL09Er9VaIefr2LMAf3OEmpCkjOi34eYyQYAXUTjEQtZJTKcF0E2UKTh+osDLsgNim9Q==} engines: {node: '>=8'} @@ -34152,12 +34393,14 @@ packages: /zen-observable-ts@1.2.5: resolution: {integrity: sha512-QZWQekv6iB72Naeake9hS1KxHlotfRpe+WGNbNx5/ta+R3DNjVO2bswf63gXlWDcs+EMd7XY8HfVQyP1X6T4Zg==} + requiresBuild: true dependencies: zen-observable: 0.8.15 dev: false /zen-observable@0.8.15: resolution: {integrity: sha512-PQ2PC7R9rslx84ndNBZB/Dkv8V8fZEpk83RLgXtYd0fwUgEjseMn1Dgajh2x6S8QbZAFa9p2qVCEuYZNgve0dQ==} + requiresBuild: true dev: false /zod-to-json-schema@3.21.4(zod@3.22.4): @@ -34170,7 +34413,7 @@ packages: /zod@3.22.4: resolution: {integrity: sha512-iC+8Io04lddc+mVqQ9AZ7OQ2MrUKGN+oIQyq1vemgt46jwCwLfhq7/pwnBnNXXXZb8VTVLKwp9EDkx+ryxIWmg==} - /zustand@4.4.4(@types/react@18.2.31)(react@18.2.0): + /zustand@4.4.4(@types/react@18.2.33)(react@18.2.0): resolution: {integrity: sha512-5UTUIAiHMNf5+mFp7/AnzJXS7+XxktULFN0+D1sCiZWyX7ZG+AQpqs2qpYrynRij4QvoDdCD+U+bmg/cG3Ucxw==} engines: {node: '>=12.7.0'} peerDependencies: @@ -34185,7 +34428,7 @@ packages: react: optional: true dependencies: - '@types/react': 18.2.31 + '@types/react': 18.2.33 react: 18.2.0 use-sync-external-store: 1.2.0(react@18.2.0) dev: false diff --git a/pnpm-workspace.yaml b/pnpm-workspace.yaml index aaa9186b..fcd6e04d 100644 --- a/pnpm-workspace.yaml +++ b/pnpm-workspace.yaml @@ -4,6 +4,6 @@ packages: - "docs" - "frontend" - "graph" - - "vendor/observabletreemap" - "sdk" + - "vendor/observabletreemap" - "contracts" diff --git a/sdk/.graphclient/index.ts b/sdk/.graphclient/index.ts index ee00cdac..95f59d60 100644 --- a/sdk/.graphclient/index.ts +++ b/sdk/.graphclient/index.ts @@ -282,7 +282,7 @@ export type Claim = { creator?: Maybe; owner?: Maybe; totalUnits?: Maybe; - chainName: Scalars['String']; + graphName: Scalars['String']; }; export type ClaimToken = { @@ -291,7 +291,7 @@ export type ClaimToken = { claim: Claim; owner: Scalars['Bytes']; units: Scalars['BigInt']; - chainName: Scalars['String']; + graphName: Scalars['String']; }; export type ClaimToken_filter = { @@ -681,21 +681,21 @@ export type ResolversParentTypes = ResolversObject<{ export type entityDirectiveArgs = { }; -export type entityDirectiveResolver = DirectiveResolverFn; +export type entityDirectiveResolver = DirectiveResolverFn; export type subgraphIdDirectiveArgs = { id: Scalars['String']; }; -export type subgraphIdDirectiveResolver = DirectiveResolverFn; +export type subgraphIdDirectiveResolver = DirectiveResolverFn; export type derivedFromDirectiveArgs = { field: Scalars['String']; }; -export type derivedFromDirectiveResolver = DirectiveResolverFn; +export type derivedFromDirectiveResolver = DirectiveResolverFn; -export type QueryResolvers = ResolversObject<{ +export type QueryResolvers = ResolversObject<{ allowlist?: Resolver, ParentType, ContextType, RequireFields>; allowlists?: Resolver, ParentType, ContextType, RequireFields>; claim?: Resolver, ParentType, ContextType, RequireFields>; @@ -705,7 +705,7 @@ export type QueryResolvers, ParentType, ContextType, Partial>; }>; -export type SubscriptionResolvers = ResolversObject<{ +export type SubscriptionResolvers = ResolversObject<{ allowlist?: SubscriptionResolver, "allowlist", ParentType, ContextType, RequireFields>; allowlists?: SubscriptionResolver, "allowlists", ParentType, ContextType, RequireFields>; claim?: SubscriptionResolver, "claim", ParentType, ContextType, RequireFields>; @@ -715,7 +715,7 @@ export type SubscriptionResolvers, "_meta", ParentType, ContextType, Partial>; }>; -export type AllowlistResolvers = ResolversObject<{ +export type AllowlistResolvers = ResolversObject<{ id?: Resolver; root?: Resolver; claim?: Resolver; @@ -734,7 +734,7 @@ export interface BytesScalarConfig extends GraphQLScalarTypeConfig = ResolversObject<{ +export type ClaimResolvers = ResolversObject<{ id?: Resolver; creation?: Resolver; tokenID?: Resolver; @@ -743,17 +743,17 @@ export type ClaimResolvers, ParentType, ContextType>; owner?: Resolver, ParentType, ContextType>; totalUnits?: Resolver, ParentType, ContextType>; - chainName?: Resolver; + graphName?: Resolver; __isTypeOf?: IsTypeOfResolverFn; }>; -export type ClaimTokenResolvers = ResolversObject<{ +export type ClaimTokenResolvers = ResolversObject<{ id?: Resolver; tokenID?: Resolver; claim?: Resolver; owner?: Resolver; units?: Resolver; - chainName?: Resolver; + graphName?: Resolver; __isTypeOf?: IsTypeOfResolverFn; }>; @@ -761,21 +761,21 @@ export interface Int8ScalarConfig extends GraphQLScalarTypeConfig = ResolversObject<{ +export type _Block_Resolvers = ResolversObject<{ hash?: Resolver, ParentType, ContextType>; number?: Resolver; timestamp?: Resolver, ParentType, ContextType>; __isTypeOf?: IsTypeOfResolverFn; }>; -export type _Meta_Resolvers = ResolversObject<{ +export type _Meta_Resolvers = ResolversObject<{ block?: Resolver; deployment?: Resolver; hasIndexingErrors?: Resolver; __isTypeOf?: IsTypeOfResolverFn; }>; -export type Resolvers = ResolversObject<{ +export type Resolvers = ResolversObject<{ Query?: QueryResolvers; Subscription?: SubscriptionResolvers; Allowlist?: AllowlistResolvers; @@ -789,7 +789,7 @@ export type Resolvers; }>; -export type DirectiveResolvers = ResolversObject<{ +export type DirectiveResolvers = ResolversObject<{ entity?: entityDirectiveResolver; subgraphId?: subgraphIdDirectiveResolver; derivedFrom?: derivedFromDirectiveResolver; @@ -798,8 +798,7 @@ export type DirectiveResolvers(moduleId: string) => { const relativeModuleId = (pathModule.isAbsolute(moduleId) ? pathModule.relative(baseDir, moduleId) : moduleId).split('\\').join('/').replace(baseDir + '/', ''); @@ -853,7 +852,7 @@ sources[0] = { handler: hypercertsHandler, transforms: hypercertsTransforms } -const additionalTypeDefs = [parse("extend type Claim {\n chainName: String!\n}\n\nextend type ClaimToken {\n chainName: String!\n}"),] as any[]; +const additionalTypeDefs = [parse("extend type Claim {\n graphName: String!\n}\n\nextend type ClaimToken {\n graphName: String!\n}"),] as any[]; additionalEnvelopPlugins[0] = await UsePollingLive({ ...({ "defaultInterval": 5000 @@ -969,7 +968,7 @@ export type ClaimsByOwnerQueryVariables = Exact<{ }>; -export type ClaimsByOwnerQuery = { claims: Array> }; +export type ClaimsByOwnerQuery = { claims: Array> }; export type RecentClaimsQueryVariables = Exact<{ orderDirection?: InputMaybe; @@ -978,14 +977,14 @@ export type RecentClaimsQueryVariables = Exact<{ }>; -export type RecentClaimsQuery = { claims: Array> }; +export type RecentClaimsQuery = { claims: Array> }; export type ClaimByIdQueryVariables = Exact<{ id: Scalars['ID']; }>; -export type ClaimByIdQuery = { claim?: Maybe> }; +export type ClaimByIdQuery = { claim?: Maybe> }; export type ClaimTokensByOwnerQueryVariables = Exact<{ owner?: InputMaybe; @@ -996,7 +995,7 @@ export type ClaimTokensByOwnerQueryVariables = Exact<{ export type ClaimTokensByOwnerQuery = { claimTokens: Array<( - Pick + Pick & { claim: Pick } )> }; @@ -1008,7 +1007,7 @@ export type ClaimTokensByClaimQueryVariables = Exact<{ }>; -export type ClaimTokensByClaimQuery = { claimTokens: Array> }; +export type ClaimTokensByClaimQuery = { claimTokens: Array> }; export type ClaimTokenByIdQueryVariables = Exact<{ claimTokenId: Scalars['ID']; @@ -1016,7 +1015,7 @@ export type ClaimTokenByIdQueryVariables = Exact<{ export type ClaimTokenByIdQuery = { claimToken?: Maybe<( - Pick + Pick & { claim: Pick } )> }; @@ -1029,7 +1028,7 @@ export const ClaimsByOwnerDocument = gql` first: $first orderDirection: $orderDirection ) { - chainName + graphName contract tokenID creator @@ -1043,7 +1042,7 @@ export const ClaimsByOwnerDocument = gql` export const RecentClaimsDocument = gql` query RecentClaims($orderDirection: OrderDirection, $first: Int, $skip: Int) { claims(orderDirection: $orderDirection, orderBy: creation, first: $first) { - chainName + graphName contract tokenID creator @@ -1057,7 +1056,7 @@ export const RecentClaimsDocument = gql` export const ClaimByIdDocument = gql` query ClaimById($id: ID!) { claim(id: $id) { - chainName + graphName contract tokenID creator @@ -1076,7 +1075,7 @@ export const ClaimTokensByOwnerDocument = gql` first: $first orderDirection: $orderDirection ) { - chainName + graphName id owner tokenID @@ -1098,7 +1097,7 @@ export const ClaimTokensByClaimDocument = gql` first: $first orderDirection: $orderDirection ) { - chainName + graphName id owner tokenID @@ -1109,7 +1108,7 @@ export const ClaimTokensByClaimDocument = gql` export const ClaimTokenByIdDocument = gql` query ClaimTokenById($claimTokenId: ID!) { claimToken(id: $claimTokenId) { - chainName + graphName id owner tokenID diff --git a/sdk/.graphclient/schema.graphql b/sdk/.graphclient/schema.graphql index 8694426f..56dc3bc8 100644 --- a/sdk/.graphclient/schema.graphql +++ b/sdk/.graphclient/schema.graphql @@ -281,7 +281,7 @@ type Claim { creator: Bytes owner: Bytes totalUnits: BigInt - chainName: String! + graphName: String! } type ClaimToken { @@ -290,7 +290,7 @@ type ClaimToken { claim: Claim! owner: Bytes! units: BigInt! - chainName: String! + graphName: String! } input ClaimToken_filter { diff --git a/sdk/.graphclientrc.yml b/sdk/.graphclientrc.yml index bf07ad3d..9087a374 100644 --- a/sdk/.graphclientrc.yml +++ b/sdk/.graphclientrc.yml @@ -8,10 +8,10 @@ sources: additionalTypeDefs: | extend type Claim { - chainName: String! + graphName: String! } extend type ClaimToken { - chainName: String! + graphName: String! } additionalResolvers: @@ -21,7 +21,7 @@ documents: - ./src/indexer/queries/*.graphql codegen: - contextType: "MeshContext & { graphUrl: string, chainName: string }" + contextType: "MeshContext & { graphUrl: string, graphName: string }" plugins: - pollingLive: diff --git a/sdk/jest.config.ts b/sdk/jest.config.ts index 263def76..7d3d6afb 100644 --- a/sdk/jest.config.ts +++ b/sdk/jest.config.ts @@ -6,7 +6,6 @@ const config: Config = { setupFiles: ["./test/setup-env.ts"], setupFilesAfterEnv: ["jest-extended/all"], rootDir: ".", - moduleDirectories: ["node_modules", "/src", ".graphclient"], moduleNameMapper: { "^(\\.{1,2}/.*)\\.js$": "$1", "^@hypercerts-org/contracts$": require.resolve("@hypercerts-org/contracts"), // this is the trick! @@ -15,6 +14,7 @@ const config: Config = { resolver: "ts-jest-resolver", moduleFileExtensions: ["js", "jsx", "json", "ts"], transform: {}, + workerThreads: true, }; export default config; diff --git a/sdk/package.json b/sdk/package.json index 1227f74b..91b39d68 100644 --- a/sdk/package.json +++ b/sdk/package.json @@ -1,6 +1,6 @@ { "name": "@hypercerts-org/sdk", - "version": "0.8.16", + "version": "1.0.0-alpha.6", "description": "SDK for hypercerts protocol", "repository": "git@github.com:hypercerts-org/hypercerts.git", "author": "Hypercerts team", @@ -23,7 +23,7 @@ "package.json" ], "dependencies": { - "@ethereum-attestation-service/eas-sdk": "^0.28.3", + "@ethereum-attestation-service/eas-sdk": "1.2.2-beta.0", "@ethersproject/abstract-signer": "^5.7.0", "@graphprotocol/client-add-source-name": "^1.0.16", "@graphprotocol/client-polling-live": "^2.0.0", @@ -43,13 +43,13 @@ "ajv": "^8.11.2", "axios": "^1.2.2", "dotenv": "^16.0.3", - "ethers": "^5.7.2", + "ethers": "5.7.2", "graphql": "^16.6.0", "ipfs-core": "^0.17.0", - "jest": "^29.3.1", "loglevel": "^1.8.1", "mime": "^3.0.0", "nft.storage": "^7.1.1", + "viem": "^1.18.4", "web3.storage": "^4.5.5" }, "devDependencies": { @@ -65,8 +65,11 @@ "@types/chai": "^4.3.4", "@types/chai-subset": "^1.3.3", "@types/jest": "^29.2.5", + "@types/mocha": "9.1.0", "@types/node": "^18.11.17", "@types/sinon": "^10.0.15", + "@viem/anvil": "^0.0.6", + "abitype": "^0.10.2", "babel-jest": "^29.7.0", "chai": "^4.3.7", "chai-assertions-count": "^1.0.2", @@ -74,9 +77,10 @@ "esbuild": "^0.17.10", "ethereum-waffle": "^4.0.10", "it-all": "^2.0.0", + "jest": "^29.3.1", "jest-extended": "^4.0.0", + "jest-fetch-mock": "^3.0.3", "json-schema-to-typescript": "^12.0.0", - "msw": "^1.2.1", "nyc": "^15.1.0", "rollup": "^3.17.2", "rollup-plugin-auto-external": "^2.0.0", @@ -94,7 +98,7 @@ "typedoc": "^0.23.25", "typedoc-plugin-markdown": "^3.14.0", "typedoc-plugin-missing-exports": "^2.0.0", - "typescript": "^4.9.0" + "typescript": "5.1.6" }, "scripts": { "build": "pnpm types:json && pnpm graph:build:esm && rollup -c", @@ -106,7 +110,7 @@ "clean": "rm -rf ./dist", "prebuild": "pnpm clean", "prepack": "pnpm build", - "test": "NODE_OPTIONS=\"--no-warnings --experimental-vm-modules\" jest", + "test": "NODE_OPTIONS=\"--no-warnings --experimental-vm-modules\" jest --detectOpenHandles --forceExit", "types:json": "pnpm json2ts -i './src/resources/schema/' -o 'src/types' --cwd './src/resources/schema'" } } diff --git a/sdk/src/client.ts b/sdk/src/client.ts index 6163bf03..63b24c01 100644 --- a/sdk/src/client.ts +++ b/sdk/src/client.ts @@ -1,11 +1,9 @@ -import { HypercertMinter, HypercertMinterAbi } from "@hypercerts-org/contracts"; +import { HypercertMinterAbi } from "@hypercerts-org/contracts"; import { StandardMerkleTree } from "@openzeppelin/merkle-tree"; -import { BigNumber, BigNumberish, BytesLike, ContractTransaction, ethers, providers } from "ethers"; - -import { DEFAULT_CHAIN_ID } from "./constants.js"; -import HypercertEvaluator from "./evaluations/index.js"; -import HypercertIndexer from "./indexer.js"; -import HypercertsStorage from "./storage.js"; +import { ByteArray, GetContractReturnType, Hex, PublicClient, WalletClient, getContract, parseAbi } from "viem"; +import HypercertEvaluator from "./evaluations"; +import HypercertIndexer from "./indexer"; +import HypercertsStorage from "./storage"; import { AllowlistEntry, ClientError, @@ -14,52 +12,60 @@ import { HypercertMetadata, InvalidOrMissingError, MalformedDataError, + SupportedOverrides, TransferRestrictions, -} from "./types/index.js"; -import { getConfig } from "./utils/config.js"; -import logger from "./utils/logger.js"; -import { validateAllowlist, validateMetaData, verifyMerkleProof, verifyMerkleProofs } from "./validator/index.js"; +} from "./types"; +import { getConfig } from "./utils/config"; +import logger from "./utils/logger"; +import { validateAllowlist, validateMetaData, verifyMerkleProof, verifyMerkleProofs } from "./validator"; /** - * Hypercerts client factory - * @dev Creates a Hypercerts client instance - * @notice The client is readonly if no signer is set or if the contract address is not set + * The `HypercertClient` is a core class in the hypercerts SDK, providing a high-level interface to interact with the hypercerts system. + * + * It encapsulates the logic for storage, evaluation, indexing, and wallet interactions, abstracting the complexity and providing a simple API for users. + * The client is read-only if the storage is read-only (no nft.storage/web3.storage keys) or if no walletClient was found. + * + * Here's an example of how to create a new instance of `HypercertClient`: + * + * ```typescript + * const config: Partial = { + * id: 5 + * }; + * + * const client = new HypercertClient(config); + * ``` + * * @param config - Hypercerts client configuration - * @param storage - Hypercerts storage object + * @dev Creates a Hypercerts client instance */ export default class HypercertClient implements HypercertClientInterface { - readonly _config: HypercertClientConfig; + readonly _config; private _storage: HypercertsStorage; - private _evaluator: HypercertEvaluator; + // TODO better handling readonly. For now not needed since we don't use this class; + private _evaluator?: HypercertEvaluator; private _indexer: HypercertIndexer; - //TODO added the TypedDataSigner since that's needed for EAS signing. Will this work on front-end? - private _operator: ethers.providers.Provider | ethers.Signer; - private _contract: HypercertMinter; + private _publicClient: PublicClient; + private _walletClient?: WalletClient; readonly: boolean; /** * Creates a new instance of the `HypercertClient` class. * @param config The configuration options for the client. */ - constructor(config = { chainId: DEFAULT_CHAIN_ID } as Partial) { + constructor(config: Partial) { this._config = getConfig(config); - this._operator = this._config.operator; + if (!this._config.publicClient) { + throw new ClientError("Could not connect to public client."); + } - this._contract = ( - new ethers.Contract(this._config.contractAddress, HypercertMinterAbi, this._operator) - ); + this._publicClient = this._config.publicClient; + this._walletClient = this._config?.walletClient; this._storage = new HypercertsStorage(this._config); this._indexer = new HypercertIndexer(this._config); - this._evaluator = new HypercertEvaluator(this._config); - - this.readonly = - providers.Provider.isProvider(this._operator) || - !ethers.Signer.isSigner(this._operator) || - !this._config.contractAddress || - this._storage.readonly; + this.readonly = this._config.readOnly || this._storage.readonly || !this._walletClient; if (this.readonly) { logger.warn("HypercertsClient is in readonly mode", "client"); @@ -70,7 +76,7 @@ export default class HypercertClient implements HypercertClientInterface { * Gets the config for the client. * @returns The client config. */ - get config(): HypercertClientConfig { + get config(): Partial { return this._config; } @@ -94,8 +100,13 @@ export default class HypercertClient implements HypercertClientInterface { * Gets the HypercertMinter contract used by the client. * @returns The contract. */ - get contract(): HypercertMinter { - return this._contract; + get contract(): GetContractReturnType { + return getContract({ + address: this._config.contractAddress as `0x${string}`, + abi: parseAbi(HypercertMinterAbi), + publicClient: this._publicClient, + walletClient: this._walletClient, + }); } /** @@ -108,17 +119,11 @@ export default class HypercertClient implements HypercertClientInterface { */ mintClaim = async ( metaData: HypercertMetadata, - totalUnits: BigNumberish, + totalUnits: bigint, transferRestriction: TransferRestrictions, - overrides?: ethers.Overrides, - ): Promise => { - this.checkWritable(); - - if (!ethers.Signer.isSigner(this._config.operator)) { - throw new InvalidOrMissingError("Invalid operator: not a signer", { operator: this._config.operator }); - } - - const signerAddress = await this._config.operator.getAddress(); + overrides?: SupportedOverrides, + ) => { + const { account } = this.getWallet(); // validate metadata const { valid, errors } = validateMetaData(metaData); @@ -129,9 +134,15 @@ export default class HypercertClient implements HypercertClientInterface { // store metadata on IPFS const cid = await this.storage.storeMetadata(metaData); - return overrides - ? this.contract.mintClaim(signerAddress, totalUnits, cid, transferRestriction, overrides) - : this.contract.mintClaim(signerAddress, totalUnits, cid, transferRestriction); + const { request } = await this._publicClient.simulateContract({ + functionName: "mintClaim", + account, + args: [account?.address, totalUnits, cid, transferRestriction], + ...this.getContractConfig(), + ...this.getCleanedOverrides(overrides), + }); + + return this.submitRequest(request); }; /** @@ -147,17 +158,11 @@ export default class HypercertClient implements HypercertClientInterface { createAllowlist = async ( allowList: AllowlistEntry[], metaData: HypercertMetadata, - totalUnits: BigNumberish, + totalUnits: bigint, transferRestriction: TransferRestrictions, - overrides?: ethers.Overrides, + overrides?: SupportedOverrides, ) => { - this.checkWritable(); - - if (!ethers.Signer.isSigner(this._config.operator)) { - throw new InvalidOrMissingError("Invalid operator: not a signer", { operator: this._config.operator }); - } - - const signerAddress = await this._config.operator.getAddress(); + const { account } = this.getWallet(); // validate allowlist const { valid: validAllowlist, errors: allowlistErrors } = validateAllowlist(allowList, totalUnits); @@ -172,105 +177,129 @@ export default class HypercertClient implements HypercertClientInterface { } // create allowlist - const tuples = allowList.map((p) => [p.address, p.units]); + const tuples = allowList.map((p) => [p.address, p.units.toString()]); const tree = StandardMerkleTree.of(tuples, ["address", "uint256"]); const cidMerkle = await this.storage.storeData(JSON.stringify(tree.dump())); - metaData.allowList = cidMerkle; - // store metadata on IPFS - const cid = await this.storage.storeMetadata(metaData); + const cid = await this.storage.storeMetadata({ ...metaData, allowList: cidMerkle }); + + const { request } = await this._publicClient.simulateContract({ + functionName: "createAllowlist", + account, + args: [account?.address, totalUnits, tree.root, cid, transferRestriction], + ...this.getContractConfig(), + ...this.getCleanedOverrides(overrides), + }); - return overrides - ? this.contract.createAllowlist(signerAddress, totalUnits, tree.root, cid, transferRestriction, overrides) - : this.contract.createAllowlist(signerAddress, totalUnits, tree.root, cid, transferRestriction); + return this.submitRequest(request); }; /** * Split a Hypercert's unit into multiple claims with the given fractions * @dev Submit the ID of the claim to split and new fraction values. * @notice The sum of the fractions must be equal to the total units of the claim - * @param claimId - Hypercert claim id - * @param fractions - Fractions of the Hypercert claim to split + * @param fractionId - Hypercert claim id + * @param newFractions - Fractions of the Hypercert claim to split * @returns Contract transaction */ - splitClaimUnits = async (claimId: BigNumberish, fractions: BigNumberish[], overrides?: ethers.Overrides) => { - this.checkWritable(); + splitFractionUnits = async (fractionId: bigint, fractions: bigint[], overrides?: SupportedOverrides) => { + const { account } = this.getWallet(); - // check if claim exists and is owned by the signer - if (!ethers.Signer.isSigner(this._config.operator)) { - throw new InvalidOrMissingError("Invalid operator: not a signer", { operator: this._config.operator }); - } + const readContract = getContract({ + ...this.getContractConfig(), + publicClient: this._publicClient, + }); - const signerAddress = await this._config.operator.getAddress(); + const fractionOwner = (await readContract.read.ownerOf([fractionId])) as `0x${string}`; + const totalUnits = (await readContract.read.unitsOf([fractionId])) as bigint; - const claimOwner = await this._contract.ownerOf(claimId); - if (claimOwner.toLowerCase() !== signerAddress.toLowerCase()) - throw new ClientError("Claim is not owned by the signer", { signer: signerAddress, claimOwner }); + if (fractionOwner.toLowerCase() !== account?.address.toLowerCase()) + throw new ClientError("Claim is not owned by the signer", { signer: account?.address, fractionOwner }); // check if the sum of the fractions is equal to the total units - const totalUnits = await this._contract["unitsOf(uint256)"](claimId); - const sumFractions = fractions.reduce((a, b) => BigNumber.from(a).add(b), BigNumber.from(0)); - if (!BigNumber.from(sumFractions).eq(totalUnits)) + const sumFractions = fractions.reduce((a, b) => a + b, 0n); + if (sumFractions != totalUnits) throw new ClientError("Sum of fractions is not equal to the total units", { totalUnits, sumFractions }); - return overrides - ? this.contract.splitFraction(signerAddress, claimId, fractions, overrides) - : this.contract.splitFraction(signerAddress, claimId, fractions); + const { request } = await this._publicClient.simulateContract({ + functionName: "splitFraction", + account, + args: [account.address, fractionId, fractions], + ...this.getContractConfig(), + ...this.getCleanedOverrides(overrides), + }); + + return this.submitRequest(request); }; /** * Merge multiple Hypercert claims fractions into one * @dev Merges multiple Hypercert claims into one - * @param claimIds - Hypercert claim ids + * @param fractionIds - Hypercert claim ids * @returns Contract transaction */ - mergeClaimUnits = async (claimIds: BigNumberish[], overrides?: ethers.Overrides) => { - this.checkWritable(); + mergeFractionUnits = async (fractionIds: bigint[], overrides?: SupportedOverrides) => { + const { account } = this.getWallet(); - // check if all claims exist and are owned by the signer - if (!ethers.Signer.isSigner(this._config.operator)) { - throw new InvalidOrMissingError("Invalid operator: not a signer", { operator: this._config.operator }); - } + const readContract = getContract({ + ...this.getContractConfig(), + publicClient: this._publicClient, + }); - const signerAddress = await this._config.operator.getAddress(); + const fractions = await Promise.all( + fractionIds.map(async (id) => ({ id, owner: (await readContract.read.ownerOf([id])) as `0x${string}` })), + ); + + const notOwned = fractions.filter((fraction) => fraction.owner.toLowerCase() !== account?.address.toLowerCase()); - const claims = await Promise.all(claimIds.map(async (id) => ({ id, owner: await this._contract.ownerOf(id) }))); - if (claims.some((c) => c.owner.toLowerCase() !== signerAddress.toLowerCase())) { - const invalidClaimIDs = claims.filter((c) => c.owner !== signerAddress).map((c) => c.id); - throw new ClientError("One or more claims are not owned by the signer", { - signer: signerAddress, - claims: invalidClaimIDs, + if (notOwned.length > 0) { + throw new ClientError("One or more fractions are not owned by the signer", { + signer: account?.address, + notOwned, }); } - return overrides - ? this.contract.mergeFractions(signerAddress, claimIds, overrides) - : this.contract.mergeFractions(signerAddress, claimIds); + const { request } = await this._publicClient.simulateContract({ + functionName: "mergeFractions", + account, + args: [account?.address, fractionIds], + ...this.getContractConfig(), + ...this.getCleanedOverrides(overrides), + }); + + return this.submitRequest(request); }; /** * Burn a Hypercert claim by providing the claim id * @dev Burns a Hypercert claim - * @param claimId - Hypercert claim id + * @param fractionId - Hypercert claim id * @returns Contract transaction */ - burnClaimFraction = async (claimId: BigNumberish, overrides?: ethers.Overrides) => { - this.checkWritable(); + burnClaimFraction = async (claimId: bigint, overrides?: SupportedOverrides) => { + const { account } = this.getWallet(); + + const readContract = getContract({ + ...this.getContractConfig(), + publicClient: this._publicClient, + }); + + const claimOwner = (await readContract.read.ownerOf([claimId])) as `0x${string}`; - // check if claim exists and is owned by the signer - if (!ethers.Signer.isSigner(this._config.operator)) { - throw new InvalidOrMissingError("Invalid operator: not a signer", { operator: this._config.operator }); + if (claimOwner.toLowerCase() !== account?.address.toLowerCase()) { + throw new ClientError("Claim is not owned by the signer", { signer: account?.address, claimOwner }); } - const signerAddress = await this._config.operator.getAddress(); - const claimOwner = await this._contract.ownerOf(claimId); - if (claimOwner.toLowerCase() !== signerAddress.toLowerCase()) - throw new ClientError("Claim is not owned by the signer", { signer: signerAddress, claimOwner }); + const { request } = await this._publicClient.simulateContract({ + functionName: "burnFraction", + account, + args: [account?.address, claimId], + ...this.getContractConfig(), + ...this.getCleanedOverrides(overrides), + }); - return overrides - ? this.contract.burnFraction(signerAddress, claimId, overrides) - : this.contract.burnFraction(signerAddress, claimId); + return this.submitRequest(request); }; /** @@ -283,32 +312,34 @@ export default class HypercertClient implements HypercertClientInterface { * @returns Contract transaction */ mintClaimFractionFromAllowlist = async ( - claimId: BigNumberish, - units: BigNumberish, - proof: BytesLike[], - root?: BytesLike, - overrides?: ethers.Overrides, - ): Promise => { - this.checkWritable(); - - if (!ethers.Signer.isSigner(this._config.operator)) { - throw new InvalidOrMissingError("Invalid operator: not a signer", { operator: this._config.operator }); - } + claimId: bigint, + units: bigint, + proof: (Hex | ByteArray)[], + root?: Hex | ByteArray, + overrides?: SupportedOverrides, + ) => { + const { account } = this.getWallet(); - const signerAddress = await this._config.operator.getAddress(); //verify the proof using the OZ merkle tree library if (root && root.length > 0) { + if (!account?.address) throw new InvalidOrMissingError("No wallet address found, are you connected?"); verifyMerkleProof( root.toString(), - signerAddress, + account?.address, units, proof.map((p) => p.toString()), ); } - return overrides - ? this.contract.mintClaimFromAllowlist(signerAddress, proof, claimId, units, overrides) - : this.contract.mintClaimFromAllowlist(signerAddress, proof, claimId, units); + const { request } = await this._publicClient.simulateContract({ + functionName: "mintClaimFromAllowlist", + account, + args: [account?.address, proof, claimId, units], + ...this.getContractConfig(), + ...this.getCleanedOverrides(overrides), + }); + + return this.submitRequest(request); }; /** @@ -322,39 +353,73 @@ export default class HypercertClient implements HypercertClientInterface { * @returns A Promise that resolves to the transaction receipt */ batchMintClaimFractionsFromAllowlists = async ( - claimIds: BigNumberish[], - units: BigNumberish[], - proofs: BytesLike[][], - roots?: BytesLike[], - overrides?: ethers.Overrides, - ): Promise => { - this.checkWritable(); - - if (!ethers.Signer.isSigner(this._config.operator)) { - throw new InvalidOrMissingError("Invalid operator: not a signer", { operator: this._config.operator }); - } - - const signerAddress = await this._config.operator.getAddress(); + claimIds: bigint[], + units: bigint[], + proofs: (Hex | ByteArray)[][], + roots?: (Hex | ByteArray)[], + overrides?: SupportedOverrides, + ) => { + const { account } = this.getWallet(); //verify the proof using the OZ merkle tree library if (roots && roots.length > 0) { + if (!account?.address) throw new InvalidOrMissingError("No wallet address found, are you connected?"); + verifyMerkleProofs( roots.map((r) => r.toString()), - signerAddress, + account?.address, units, proofs.map((p) => p.map((p) => p.toString())), ); } - return overrides - ? this.contract.batchMintClaimsFromAllowlists(signerAddress, proofs, claimIds, units, overrides) - : this.contract.batchMintClaimsFromAllowlists(signerAddress, proofs, claimIds, units); + const { request } = await this._publicClient.simulateContract({ + functionName: "batchMintClaimsFromAllowlists", + account, + args: [account?.address, proofs, claimIds, units], + ...this.getContractConfig(), + ...this.getCleanedOverrides(overrides), + }); + + return this.submitRequest(request); }; - private checkWritable = () => { - //TODO add check on ContractRunner when migrating to ethers v6 + private getContractConfig = () => { + if (!this.config?.contractAddress) throw new ClientError("No contract address found", { config: this.config }); + + return getContract({ + address: this.config.contractAddress as `0x${string}`, + abi: parseAbi(HypercertMinterAbi), + }); + }; + + private getCleanedOverrides = (overrides?: SupportedOverrides) => { + const _overrides = { + value: overrides?.value, + gas: overrides?.gasLimit, + gasPrice: overrides?.gasPrice, + }; + + return Object.fromEntries(Object.entries(_overrides).filter(([_, value]) => value !== undefined)); + }; + + private getWallet = () => { + if (!this._walletClient) { + throw new ClientError("Could not connect to wallet; sending transactions not allowed.", { client: this }); + } if (this.readonly) throw new ClientError("Client is readonly", { client: this }); - return true; + return { walletClient: this._walletClient, account: this._walletClient.account }; + }; + + // eslint-disable-next-line @typescript-eslint/no-explicit-any + private submitRequest = async (request: any) => { + const hash = this._walletClient?.writeContract(request); + + if (!hash) { + throw new ClientError("Something went wrong when executing request", { request, hash }); + } + + return hash; }; } diff --git a/sdk/src/constants.ts b/sdk/src/constants.ts index da4383b5..05307613 100644 --- a/sdk/src/constants.ts +++ b/sdk/src/constants.ts @@ -2,37 +2,30 @@ * Constants */ -import { Deployment, SupportedChainIds } from "./types/index.js"; - -// Goerli is default if nothing specified -const DEFAULT_CHAIN_ID = 5; +import { Deployment, SupportedChainIds } from "./types"; const DEFAULT_GRAPH_BASE_URL = "https://api.thegraph.com/subgraphs/name/hypercerts-admin"; // These are the deployments we manage -const DEPLOYMENTS: { [key in SupportedChainIds]: Deployment } = { +const DEPLOYMENTS: { [key in SupportedChainIds]: Partial } = { 5: { - chainId: 5, - chainName: "goerli", contractAddress: "0x822F17A9A5EeCFd66dBAFf7946a8071C265D1d07", + graphName: "hypercerts-testnet", graphUrl: `${DEFAULT_GRAPH_BASE_URL}/hypercerts-testnet`, } as const, 10: { - chainId: 10, - chainName: "optimism-mainnet", contractAddress: "0x822F17A9A5EeCFd66dBAFf7946a8071C265D1d07", + graphName: "hypercerts-optimism-mainnet", graphUrl: `${DEFAULT_GRAPH_BASE_URL}/hypercerts-optimism-mainnet`, } as const, 42220: { - chainId: 42220, - chainName: "celo-mainnet", contractAddress: "0x16ba53b74c234c870c61efc04cd418b8f2865959", + graphName: "hypercerts-arbitrum", graphUrl: `${DEFAULT_GRAPH_BASE_URL}/hypercerts-celo`, }, 11155111: { - chainId: 11155111, - chainName: "sepolia", contractAddress: "0xa16DFb32Eb140a6f3F2AC68f41dAd8c7e83C4941", + graphName: "hypercerts-sepolia", graphUrl: `${DEFAULT_GRAPH_BASE_URL}/hypercerts-sepolia`, } as const, }; @@ -52,4 +45,4 @@ const EAS_SCHEMAS = { }, } as const; -export { DEFAULT_CHAIN_ID, DEPLOYMENTS, EAS_SCHEMAS }; +export { DEPLOYMENTS, EAS_SCHEMAS }; diff --git a/sdk/src/evaluations/eas.ts b/sdk/src/evaluations/eas.ts deleted file mode 100644 index 3a7923b1..00000000 --- a/sdk/src/evaluations/eas.ts +++ /dev/null @@ -1,155 +0,0 @@ -import { Offchain, SchemaEncoder, SignedOffchainAttestation } from "@ethereum-attestation-service/eas-sdk"; -import { TypedDataSigner } from "@ethersproject/abstract-signer"; -import { ethers } from "ethers"; - -import { EAS_SCHEMAS } from "../constants.js"; -import { - DuplicateEvaluation, - EvaluationData, - HypercertClientConfig, - InvalidOrMissingError, - MalformedDataError, - SimpleTextEvaluation, -} from "../types/index.js"; -import { validateDuplicateEvaluationData, validateSimpleTextEvaluationData } from "../validator/index.js"; - -/** - * The EasEvaluator class provides methods for signing off-chain attestations of evaluations. - * Schemas are stored on-chain in the Ethereum Attestation Service (EAS) contract. - */ -export default class EasEvaluator { - /** - * The Offchain instance used for signing off-chain attestations. - */ - offChain: Offchain; - - /** - * The TypedDataSigner instance used for signing typed data. - */ - signer?: ethers.Signer & TypedDataSigner; - - readonly = true; - - /** - * Creates a new EasEvaluator instance. - * @param {EasEvaluatorConfig} config - The configuration options for the EasEvaluator instance. - */ - constructor(config: Partial) { - const { easContractAddress, chainId, operator } = config; - - if (!easContractAddress || !chainId || !operator) { - const missingValue = !easContractAddress ? "easContractAddress" : !chainId ? "chainId" : "operator"; - - throw new InvalidOrMissingError(`Invalid or missing config value: ${missingValue}`, { easConfig: config }); - } - - //TODO when expanding the Evaluator functionallity, we should review if readonly makes sense - if (ethers.Signer.isSigner(config.operator)) { - this.signer = config.operator as ethers.Signer & TypedDataSigner; - this.readonly = false; - } - - this.offChain = new Offchain({ address: easContractAddress, chainId: chainId, version: "0.26" }); - } - - /** - * Gets a signature for an off-chain attestation. - * @param {string} encodedData - The encoded data to sign. - * @param {string} recipient - The address of the recipient of the attestation. - * @param {string} schemaUid - The UID of the schema to use for the attestation. - * @returns {Promise} - The signature for the attestation. - */ - getSignature = async ( - encodedData: string, - recipient: string, - schemaUid: string, - ): Promise => { - if (!this.signer) { - throw new InvalidOrMissingError("No valid signer available.", { signer: this.signer }); - } - - return await this.offChain.signOffchainAttestation( - { - // TODO who will be the recipient? The contract it points to? The creator? - recipient, - // Unix timestamp of when attestation expires. (0 for no expiration) - expirationTime: 0, - // Unix timestamp of current time - time: Date.now(), - revocable: true, - nonce: 0, - schema: schemaUid, - refUID: "0x0000000000000000000000000000000000000000000000000000000000000000", - data: encodedData, - }, - this.signer, - ); - }; - - /** - * Signs an offline evaluation. - * @param {EvaluationData} evaluation - The evaluation data to sign. - * @returns {Promise} - The signature for the evaluation. - * @throws {MalformedDataError} - If the evaluation data is malformed. - */ - signOfflineEvaluation = async (evaluation: EvaluationData) => { - if (isDuplicateEvaluation(evaluation)) { - const validation = validateDuplicateEvaluationData(evaluation); - if (!validation.valid) { - throw new MalformedDataError("Invalid evaluation data", { errors: validation.errors }); - } - - const duplicateSchema = EAS_SCHEMAS["sepolia"].duplicate; - const schemaEncoder = new SchemaEncoder(duplicateSchema.schema); - const recipient = evaluation.realHypercert.contract; - - // Initialize SchemaEncoder with the schema string - // TODO validate schema values - const encodedData = schemaEncoder.encodeData([ - { name: "chainId", value: evaluation.realHypercert.chainId as string, type: "uint256" }, - { name: "contract", value: evaluation.realHypercert.contract as string, type: "address" }, - { name: "claimId", value: evaluation.realHypercert.claimId as string, type: "uint256" }, - ]); - - return this.getSignature(encodedData, recipient, duplicateSchema.uid); - } - - if (isSimpleTextEvaluation(evaluation)) { - const validation = validateSimpleTextEvaluationData(evaluation); - if (!validation.valid) { - throw new MalformedDataError("Invalid evaluation data", { errors: validation.errors }); - } - - const simpleTextSchema = EAS_SCHEMAS["sepolia"].contentHash; - const schemaEncoder = new SchemaEncoder(simpleTextSchema.schema); - const recipient = evaluation.hypercert.contract; - - const contentHash = ethers.utils.id(evaluation.text); - - // Initialize SchemaEncoder with the schema string - // TODO validate schema values - const encodedData = schemaEncoder.encodeData([{ name: "contentHash", value: contentHash, type: "bytes32" }]); - - return this.getSignature(encodedData, recipient, simpleTextSchema.uid); - } - - assertNever(evaluation); - }; -} - -const isDuplicateEvaluation = (evaluation: EvaluationData): evaluation is DuplicateEvaluation => { - return ( - evaluation.type === "duplicate" && - "realHypercert" in evaluation && - "duplicateHypercerts" in evaluation && - "explanation" in evaluation - ); -}; - -const isSimpleTextEvaluation = (evaluation: EvaluationData): evaluation is SimpleTextEvaluation => { - return evaluation.type === "simpleText" && "hypercert" in evaluation && "text" in evaluation; -}; - -const assertNever = (evaluation: never): never => { - throw new Error(`Unexpected evaluation type: ${evaluation}`); -}; diff --git a/sdk/src/evaluations/index.ts b/sdk/src/evaluations/index.ts index 9092b0b7..44f13c23 100644 --- a/sdk/src/evaluations/index.ts +++ b/sdk/src/evaluations/index.ts @@ -1,20 +1,10 @@ -import type { TypedDataSigner } from "@ethersproject/abstract-signer"; -import { ethers } from "ethers"; -import { isAddress } from "ethers/lib/utils.js"; +import { isAddress } from "viem"; +//eslint-disable-next-line @typescript-eslint/ban-ts-comment +// @ts-ignore import { CIDString } from "nft.storage"; -import { DEFAULT_CHAIN_ID } from "../constants.js"; -import HypercertsStorage from "../storage.js"; -import { - EASEvaluation, - EvaluationSource, - HypercertClientConfig, - HypercertEvaluationSchema, - MalformedDataError, -} from "../types/index.js"; -import EasEvaluator from "./eas.js"; - -const EASContractAddress = "0xC2679fBD37d54388Ce493F1DB75320D236e1815e"; // Sepolia v0.26 +import HypercertsStorage from "../storage"; +import { HypercertClientConfig, HypercertEvaluationSchema, MalformedDataError } from "../types"; export interface EvaluatorInterface { /** @@ -26,28 +16,17 @@ export interface EvaluatorInterface { } export default class HypercertEvaluator implements EvaluatorInterface { - signer?: ethers.Signer & TypedDataSigner; - storage: HypercertsStorage; - eas: EasEvaluator; - readonly = true; - constructor( - config = { - chainId: DEFAULT_CHAIN_ID, - easContractAddress: EASContractAddress, - operator: new ethers.VoidSigner(""), - } as Partial, - ) { + constructor(config: Partial) { //TODO when expanding the Evaluator functionallity, we should review if readonly makes sense - if (ethers.Signer.isSigner(config.operator)) { - this.signer = config.operator as ethers.Signer & TypedDataSigner; + if (config?.walletClient?.account) { this.readonly = false; } + this.storage = new HypercertsStorage(config); - this.eas = new EasEvaluator(config); } submitEvaluation = async (evaluation: HypercertEvaluationSchema): Promise => { @@ -55,22 +34,6 @@ export default class HypercertEvaluator implements EvaluatorInterface { throw new MalformedDataError(`Invalid creator address: ${evaluation.creator}`); } - if (isEasEvaluation(evaluation.evaluationSource)) { - const signedData = await this.eas.signOfflineEvaluation(evaluation.evaluationData); - const evaluationData = { ...evaluation.evaluationData, signedData }; - - return this.storage.storeData({ ...evaluation, evaluationData }); - } - throw new Error(`Unexpected evaluation source: ${evaluation.evaluationSource.toString()}`); }; } - -const isEasEvaluation = (evaluationSource: EvaluationSource): evaluationSource is EASEvaluation => { - return ( - evaluationSource.type === "EAS" && - "chainId" in evaluationSource && - "contract" in evaluationSource && - "uid" in evaluationSource - ); -}; diff --git a/sdk/src/index.ts b/sdk/src/index.ts index 4bbdfcd6..abe5436b 100644 --- a/sdk/src/index.ts +++ b/sdk/src/index.ts @@ -1,9 +1,9 @@ import type { HypercertMinter, IHypercertToken } from "@hypercerts-org/contracts"; import { execute } from "../.graphclient"; -import HypercertClient from "./client.js"; -import HypercertsStorage from "./storage.js"; -import { DEPLOYMENTS } from "./constants.js"; +import HypercertClient from "./client"; +import HypercertsStorage from "./storage"; +import { DEPLOYMENTS } from "./constants"; /** * Protocol @@ -24,17 +24,17 @@ export { HypercertsStorage }; /** * Types */ -export * from "./types/index.js"; +export * from "./types"; /** * Validators */ -export * from "./validator/index.js"; +export * from "./validator"; /** * Formatters */ -export * from "./utils/formatter.js"; +export * from "./utils/formatter"; /** * Graph diff --git a/sdk/src/indexer.ts b/sdk/src/indexer.ts index 793e77ab..c3438f45 100644 --- a/sdk/src/indexer.ts +++ b/sdk/src/indexer.ts @@ -1,6 +1,6 @@ import { getBuiltGraphSDK, Sdk as GraphClient } from "../.graphclient"; -import { defaultQueryParams } from "./indexer/utils.js"; -import { HypercertIndexerInterface, QueryParams } from "./types/index.js"; +import { defaultQueryParams } from "./indexer/utils"; +import { HypercertClientConfig, HypercertIndexerInterface, QueryParams } from "./types"; /** * A class that provides indexing functionality for Hypercerts. @@ -14,9 +14,10 @@ export default class HypercertIndexer implements HypercertIndexerInterface { * Creates a new instance of the `HypercertIndexer` class. * @param options The configuration options for the indexer. */ - constructor(options: { graphUrl?: string }) { + constructor(options: Partial) { this._graphClient = getBuiltGraphSDK({ - graphUrl: options.graphUrl || "https://api.thegraph.com/subgraphs/name/hypercerts-admin/hypercerts-testnet", + graphUrl: options.graphUrl, + graphName: options.graphName, }); } diff --git a/sdk/src/indexer/queries/claims.graphql b/sdk/src/indexer/queries/claims.graphql index 776ee260..9e143ae8 100644 --- a/sdk/src/indexer/queries/claims.graphql +++ b/sdk/src/indexer/queries/claims.graphql @@ -1,6 +1,6 @@ query ClaimsByOwner($owner: Bytes = "", $orderDirection: OrderDirection, $first: Int, $skip: Int) { claims(where: { owner: $owner }, skip: $skip, first: $first, orderDirection: $orderDirection) { - chainName + graphName contract tokenID creator @@ -13,7 +13,7 @@ query ClaimsByOwner($owner: Bytes = "", $orderDirection: OrderDirection, $first: query RecentClaims($orderDirection: OrderDirection, $first: Int, $skip: Int) { claims(orderDirection: $orderDirection, orderBy: creation, first: $first) { - chainName + graphName contract tokenID creator @@ -26,7 +26,7 @@ query RecentClaims($orderDirection: OrderDirection, $first: Int, $skip: Int) { query ClaimById($id: ID!) { claim(id: $id) { - chainName + graphName contract tokenID creator diff --git a/sdk/src/indexer/queries/fractions.graphql b/sdk/src/indexer/queries/fractions.graphql index 20eb8ad0..df07f421 100644 --- a/sdk/src/indexer/queries/fractions.graphql +++ b/sdk/src/indexer/queries/fractions.graphql @@ -1,6 +1,6 @@ query ClaimTokensByOwner($owner: Bytes = "", $orderDirection: OrderDirection, $first: Int, $skip: Int) { claimTokens(where: { owner: $owner }, skip: $skip, first: $first, orderDirection: $orderDirection) { - chainName + graphName id owner tokenID @@ -16,7 +16,7 @@ query ClaimTokensByOwner($owner: Bytes = "", $orderDirection: OrderDirection, $f query ClaimTokensByClaim($claimId: String!, $orderDirection: OrderDirection, $first: Int, $skip: Int) { claimTokens(where: { claim: $claimId }, skip: $skip, first: $first, orderDirection: $orderDirection) { - chainName + graphName id owner tokenID @@ -26,7 +26,7 @@ query ClaimTokensByClaim($claimId: String!, $orderDirection: OrderDirection, $fi query ClaimTokenById($claimTokenId: ID!) { claimToken(id: $claimTokenId) { - chainName + graphName id owner tokenID diff --git a/sdk/src/indexer/utils.ts b/sdk/src/indexer/utils.ts index d016677e..28329336 100644 --- a/sdk/src/indexer/utils.ts +++ b/sdk/src/indexer/utils.ts @@ -1,4 +1,4 @@ -import { QueryParams } from "../types/index.js"; +import { QueryParams } from "../types"; export const defaultQueryParams: QueryParams = { orderDirections: "desc", diff --git a/sdk/src/storage.ts b/sdk/src/storage.ts index 8dd23c2a..19bab0e8 100644 --- a/sdk/src/storage.ts +++ b/sdk/src/storage.ts @@ -1,17 +1,21 @@ import axios from "axios"; +//eslint-disable-next-line @typescript-eslint/ban-ts-comment +// @ts-ignore import { CIDString, NFTStorage } from "nft.storage"; +//eslint-disable-next-line @typescript-eslint/ban-ts-comment +// @ts-ignore import { Blob, File, Web3Storage } from "web3.storage"; -import { validateMetaData } from "./validator/index.js"; +import { validateMetaData } from "./validator"; import { HypercertStorageConfig, HypercertStorageInterface, HypercertMetadata, MalformedDataError, StorageError, -} from "./types/index.js"; -import logger from "./utils/logger.js"; -import { getConfig } from "./utils/config.js"; +} from "./types"; +import logger from "./utils/logger"; +import { getNftStorageToken, getWeb3StorageToken } from "./utils/config"; const getCid = (cidOrIpfsUri: string) => cidOrIpfsUri.replace("ipfs://", ""); @@ -31,26 +35,45 @@ export default class HypercertsStorage implements HypercertStorageInterface { * @param overrides The configuration overrides for the storage. */ constructor(overrides: Partial) { - const { nftStorageToken, web3StorageToken } = getConfig(overrides); - - if (!nftStorageToken || nftStorageToken === "") { - logger.warn(`NFT Storage API key is missing or invalid: ${nftStorageToken}}`); - } - - if (!web3StorageToken || web3StorageToken === "") { - logger.warn(`Web3 Storage API key is missing or invalid: ${web3StorageToken}`); - } + const nftStorageToken = getNftStorageToken(overrides); + const web3StorageToken = getWeb3StorageToken(overrides); if (!nftStorageToken || !web3StorageToken) { logger.warn("HypercertsStorage is read only", "storage"); this.readonly = true; + + if (!nftStorageToken) { + logger.warn(`NFT Storage API key is missing or invalid: ${nftStorageToken}}`); + } + + if (!web3StorageToken) { + logger.warn(`Web3 Storage API key is missing or invalid: ${web3StorageToken}`); + } } else { - this.nftStorageClient = new NFTStorage({ token: nftStorageToken }); - this.web3StorageClient = new Web3Storage({ token: web3StorageToken }); + this.nftStorageClient = new NFTStorage({ token: nftStorageToken.nftStorageToken || "" }); + this.web3StorageClient = new Web3Storage({ token: web3StorageToken.web3StorageToken || "" }); this.readonly = false; } } + getFromIPFS = async (cidOrIpfsUri: string, timeout = 10000) => { + const nftStorageGatewayLink = this.getNftStorageGatewayUri(cidOrIpfsUri); + const web3StorageGatewayLink = this.getWeb3StorageGatewayUri(cidOrIpfsUri); + logger.debug(`Getting metadata ${cidOrIpfsUri} at ${nftStorageGatewayLink}`); + + const res = await axios.get(nftStorageGatewayLink, { timeout }).catch(() => { + logger.debug(`${nftStorageGatewayLink} timed out.`); + logger.debug(`Getting metadata ${cidOrIpfsUri} at ${web3StorageGatewayLink}`); + return axios.get(web3StorageGatewayLink, { timeout }); + }); + + if (!res || !res.data) { + throw new StorageError(`Failed to get ${cidOrIpfsUri}`); + } + + return res.data; + }; + /** * Stores metadata for a Hypercert. * @param data The metadata to store. @@ -91,22 +114,14 @@ export default class HypercertsStorage implements HypercertStorageInterface { * @throws A `MalformedDataError` if the metadata is invalid. E.g. unknown schema */ public async getMetadata(cidOrIpfsUri: string): Promise { - const nftStorageGatewayLink = this.getNftStorageGatewayUri(cidOrIpfsUri); - logger.debug(`Getting metadata ${cidOrIpfsUri} at ${nftStorageGatewayLink}`); - - const res = await axios.get(nftStorageGatewayLink); - - if (!res || !res.data) { - throw new StorageError(`Failed to get ${cidOrIpfsUri}`); - } + const res = await this.getFromIPFS(cidOrIpfsUri); - const data = res.data; - const validation = validateMetaData(data); + const validation = validateMetaData(res); if (!validation.valid) { throw new MalformedDataError(`Invalid metadata at ${cidOrIpfsUri}`, { errors: validation.errors }); } - return data; + return res; } /** @@ -168,14 +183,18 @@ export default class HypercertsStorage implements HypercertStorageInterface { */ // TODO: replace current temporary fix of just using NFT.Storage IPFS gateway - const nftStorageGatewayLink = this.getNftStorageGatewayUri(cidOrIpfsUri); - logger.info(`Getting data ${cidOrIpfsUri} at ${nftStorageGatewayLink}`, "storage"); + const res = await this.getFromIPFS(cidOrIpfsUri); - return axios.get(nftStorageGatewayLink).then((result) => result.data); + return res; } getNftStorageGatewayUri = (cidOrIpfsUri: string) => { const NFT_STORAGE_IPFS_GATEWAY = "https://nftstorage.link/ipfs/{cid}"; return NFT_STORAGE_IPFS_GATEWAY.replace("{cid}", getCid(cidOrIpfsUri)); }; + + getWeb3StorageGatewayUri = (cidOrIpfsUri: string) => { + const WEB3_STORAGE_IPFS_GATEWAY = "https://w3s.link/ipfs/{cid}"; + return WEB3_STORAGE_IPFS_GATEWAY.replace("{cid}", getCid(cidOrIpfsUri)); + }; } diff --git a/sdk/src/types/client.ts b/sdk/src/types/client.ts index 7d803a0c..0dd1082d 100644 --- a/sdk/src/types/client.ts +++ b/sdk/src/types/client.ts @@ -1,26 +1,31 @@ import { PartialTypedDataConfig } from "@ethereum-attestation-service/eas-sdk"; -import { HypercertMinter } from "@hypercerts-org/contracts"; -import { BigNumberish, BytesLike, ContractTransaction, ethers } from "ethers"; +//eslint-disable-next-line @typescript-eslint/ban-ts-comment +// @ts-ignore import { CIDString } from "nft.storage"; -import HypercertIndexer from "../indexer.js"; -import { AllowlistEntry, TransferRestrictions } from "./hypercerts.js"; -import { HypercertMetadata } from "./metadata.js"; +import HypercertIndexer from "../indexer"; +import { AllowlistEntry, TransferRestrictions } from "./hypercerts"; +import { HypercertMetadata } from "./metadata"; + +import { ByteArray, Chain, Hex, PublicClient, WalletClient, Abi } from "viem"; export type SupportedChainIds = 5 | 10 | 42220 | 11155111; +export type SupportedOverrides = { + value?: bigint; + gasPrice?: bigint; + gasLimit?: bigint; +}; /** * Represents a deployment of a contract on a specific network. */ export type Deployment = { - /** The ID of the network on which the contract is deployed. */ - chainId: number; - /** The name of the network on which the contract is deployed. */ - chainName: string; + chain: Partial; /** The address of the deployed contract. */ contractAddress: string; /** The url to the subgraph that indexes the contract events. Override for localized testing */ graphUrl: string; + graphName: string; }; /** @@ -29,10 +34,15 @@ export type Deployment = { export type HypercertClientConfig = Deployment & HypercertStorageConfig & HypercertEvaluatorConfig & { - /** The provider is inherently read-only */ - operator: ethers.providers.Provider | ethers.Signer; + /** The PublicClient is inherently read-only */ + publicClient: PublicClient; + walletClient: WalletClient; /** Force the use of overridden values */ unsafeForceOverrideConfig?: boolean; + /** Boolean to assert if the client is in readOnly mode */ + readOnly: boolean; + /** Reason for readOnly mode */ + readOnlyReason?: string; }; /** @@ -110,8 +120,7 @@ export interface HypercertClientState { storage: HypercertStorageInterface; /** The indexer used by the client. */ indexer: HypercertIndexer; - /** The contract used by the client. */ - contract: HypercertMinter; + contract: { abi: Abi; address?: `0x${string}` }; } /** @@ -127,9 +136,9 @@ export interface HypercertClientMethods { */ mintClaim: ( metaData: HypercertMetadata, - totalUnits: BigNumberish, + totalUnits: bigint, transferRestriction: TransferRestrictions, - ) => Promise; + ) => Promise<`0x${string}`>; /** * Creates a new allowlist and mints a new claim with the allowlist. @@ -142,31 +151,31 @@ export interface HypercertClientMethods { createAllowlist: ( allowList: AllowlistEntry[], metaData: HypercertMetadata, - totalUnits: BigNumberish, + totalUnits: bigint, transferRestriction: TransferRestrictions, - ) => Promise; + ) => Promise<`0x${string}`>; /** * Splits a claim into multiple fractions. - * @param claimId The ID of the claim to split. - * @param fractions The number of units for each fraction. + * @param fractionId The ID of the claim to split. + * @param newFractions The number of units for each fraction. * @returns A Promise that resolves to the transaction receipt */ - splitClaimUnits: (claimId: BigNumberish, fractions: BigNumberish[]) => Promise; + splitFractionUnits: (fractionId: bigint, fractions: bigint[]) => Promise<`0x${string}`>; /** * Merges multiple claim fractions into a single claim. - * @param claimIds The IDs of the claim fractions to merge. + * @param fractionIds The IDs of the claim fractions to merge. * @returns A Promise that resolves to the transaction receipt */ - mergeClaimUnits: (claimIds: BigNumberish[]) => Promise; + mergeFractionUnits: (fractionIds: bigint[]) => Promise<`0x${string}`>; /** * Burns a claim fraction. - * @param claimId The ID of the claim fraction to burn. + * @param fractionId The ID of the claim fraction to burn. * @returns A Promise that resolves to the transaction receipt */ - burnClaimFraction: (claimId: BigNumberish) => Promise; + burnClaimFraction: (fractionId: bigint) => Promise<`0x${string}`>; /** * Mints a claim fraction from an allowlist. @@ -176,10 +185,10 @@ export interface HypercertClientMethods { * @returns A Promise that resolves to the transaction receipt */ mintClaimFractionFromAllowlist: ( - claimId: BigNumberish, - units: BigNumberish, - proof: BytesLike[], - ) => Promise; + claimId: bigint, + units: bigint, + proof: (Hex | ByteArray)[], + ) => Promise<`0x${string}`>; /** * Batch mints a claim fraction from an allowlist @@ -192,8 +201,8 @@ export interface HypercertClientMethods { * @returns A Promise that resolves to the transaction receipt */ batchMintClaimFractionsFromAllowlists: ( - claimIds: BigNumberish[], - units: BigNumberish[], - proofs: BytesLike[][], - ) => Promise; + claimIds: bigint[], + units: bigint[], + proofs: (Hex | ByteArray)[][], + ) => Promise<`0x${string}`>; } diff --git a/sdk/src/types/hypercerts.ts b/sdk/src/types/hypercerts.ts index 31df75cb..9851d633 100644 --- a/sdk/src/types/hypercerts.ts +++ b/sdk/src/types/hypercerts.ts @@ -1,5 +1,3 @@ -import { BigNumberish } from "ethers"; - /** * Transfer restrictions for Hypercerts matching the definitions in the Hypercerts protocol * @dev AllowAll: All transfers are allowed @@ -21,5 +19,5 @@ export type TransferRestrictions = (typeof TransferRestrictions)[keyof typeof Tr */ export type AllowlistEntry = { address: string; - units: BigNumberish; + units: bigint; }; diff --git a/sdk/src/types/index.ts b/sdk/src/types/index.ts index b3f7dfc7..39d19b46 100644 --- a/sdk/src/types/index.ts +++ b/sdk/src/types/index.ts @@ -1,8 +1,8 @@ -export type { HypercertClaimdata } from "./claimdata.js"; -export * from "./client.js"; -export * from "./errors.js"; -export * from "./hypercerts.js"; -export * from "./indexer.js"; +export type { HypercertClaimdata } from "./claimdata"; +export * from "./client"; +export * from "./errors"; +export * from "./hypercerts"; +export * from "./indexer"; export type { EvaluationData, EvaluationSource, @@ -12,6 +12,6 @@ export type { EASEvaluation, IPFSEvaluation, HypercertPointer, -} from "./evaluation.js"; -export type { ClaimByIdQuery, ClaimTokensByClaimQuery, Claim, ClaimToken } from "./global.js"; -export type { HypercertMetadata } from "./metadata.js"; +} from "./evaluation"; +export type { ClaimByIdQuery, ClaimTokensByClaimQuery, Claim, ClaimToken } from "./global"; +export type { HypercertMetadata } from "./metadata"; diff --git a/sdk/src/utils/adapters.ts b/sdk/src/utils/adapters.ts new file mode 100644 index 00000000..9c33a336 --- /dev/null +++ b/sdk/src/utils/adapters.ts @@ -0,0 +1,41 @@ +import { providers } from "ethers"; +import { PublicClient, HttpTransport, WalletClient } from "viem"; +import logger from "./logger"; +import { Signer, TypedDataSigner } from "@ethersproject/abstract-signer"; + +export function publicClientToProvider(publicClient: PublicClient) { + const { chain, transport } = publicClient; + if (!chain) { + logger.warn("No chain found in public client, stopping signature request."); + return; + } + const network = { + chainId: chain.id, + name: chain.name, + ensAddress: chain.contracts?.ensRegistry?.address, + }; + if (transport.type === "fallback") + return new providers.FallbackProvider( + (transport.transports as ReturnType[]).map( + ({ value }) => new providers.JsonRpcProvider(value?.url, network), + ), + ); + return new providers.JsonRpcProvider(transport.url, network); +} + +export function walletClientToSigner(walletClient: WalletClient) { + const { account, chain, transport } = walletClient; + if (!chain) { + logger.warn("No chain found in public client, stopping signature request."); + return; + } + const network = { + chainId: chain.id, + name: chain.name, + ensAddress: chain.contracts?.ensRegistry?.address, + }; + const provider = new providers.Web3Provider(transport, network); + const signer = provider.getSigner(account?.address); + + return signer as Signer & TypedDataSigner; +} diff --git a/sdk/src/utils/config.ts b/sdk/src/utils/config.ts index a9dfb228..d8ad86d3 100644 --- a/sdk/src/utils/config.ts +++ b/sdk/src/utils/config.ts @@ -1,7 +1,6 @@ -import { ethers } from "ethers"; -import { isAddress } from "ethers/lib/utils.js"; +import { sepolia, goerli, optimism, celo, Chain } from "viem/chains"; -import { DEFAULT_CHAIN_ID, DEPLOYMENTS } from "../constants.js"; +import { DEPLOYMENTS } from "../constants"; import { ConfigurationError, Deployment, @@ -9,100 +8,109 @@ import { InvalidOrMissingError, SupportedChainIds, UnsupportedChainError, -} from "../types/index.js"; -import logger from "./logger.js"; +} from "../types"; +import logger from "./logger"; +import { createPublicClient, http, isAddress } from "viem"; +import { deployments } from "../../src"; /** * Returns the configuration for the Hypercert client, based on the given overrides. - * @param overrides An object containing overrides for the default configuration. + * @param config An object containing overrides for the default configuration. * @returns The configuration for the Hypercert client. - * @throws An `UnsupportedChainError` if the chain ID is not 5 or 10, or if the chain ID is missing or not found. + * @throws An `ConfigurationError` if the `environment` in `config` is not a supported environment, or if the chain ID was not found. + * @dev 5, 10, 42220, 11155111 and "test", "production" are supported environments. + * Test and production merge the Graphs by environment, while the chain IDs are specific to the chain. */ export const getConfig = (overrides: Partial) => { // Get the chainId, first from overrides, then environment variables, then the constant - const { chainId } = getChainConfig(overrides); + const chain = getChainConfig(overrides); + if (!chain) { + logger.warn("[getConfig]: No default config for chain found"); + } - let baseDeployment: Deployment & { unsafeForceOverrideConfig?: boolean }; + let baseDeployment: (Partial & { unsafeForceOverrideConfig?: boolean }) | undefined; if (overrides.unsafeForceOverrideConfig) { - if (!overrides.chainName || !overrides.contractAddress || !overrides.graphUrl) { - throw new UnsupportedChainError( - `attempted to override with chainId=${chainId}, but requires chainName, graphUrl, and contractAddress to be set`, - { chainID: chainId?.toString() || "undefined" }, + if (!overrides.chain?.id || !overrides.contractAddress || !overrides.graphUrl) { + throw new InvalidOrMissingError( + `attempted to override with chainId=${overrides.chain?.id}, but requires chainName, graphUrl, and contractAddress to be set`, + { + chainID: overrides.chain?.id?.toString(), + graphUrl: overrides.graphUrl, + contractAddress: overrides.contractAddress, + }, ); } baseDeployment = { - chainId: chainId, - chainName: overrides.chainName, + chain: { ...chain, id: overrides.chain?.id }, contractAddress: overrides.contractAddress, graphUrl: overrides.graphUrl, unsafeForceOverrideConfig: overrides.unsafeForceOverrideConfig, }; } else { - if (!chainId || [5, 10, 42220, 11155111].indexOf(chainId) === -1) { - throw new UnsupportedChainError(`chainId=${chainId} is not yet supported`, { - chainID: chainId?.toString() || "undefined", - }); - } - - baseDeployment = DEPLOYMENTS[chainId as SupportedChainIds]; + //TODO doo many casts + baseDeployment = overrides.chain?.id + ? (getDeployment(overrides.chain?.id as SupportedChainIds) as Partial & { + unsafeForceOverrideConfig?: boolean; + }) + : chain?.id + ? (getDeployment(chain.id as SupportedChainIds) as Partial & { unsafeForceOverrideConfig?: boolean }) + : undefined; if (!baseDeployment) { - throw new UnsupportedChainError(`Default config for chainId=${chainId} is missing in SDK`, { - chainID: chainId, + throw new UnsupportedChainError(`Default config for chainId=${overrides.chain?.id} is missing in SDK`, { + chainID: overrides.chain?.id, }); } + + baseDeployment = { ...baseDeployment, chain }; } - const config = { + const config: Partial = { // Start with the hardcoded values ...baseDeployment, // Let the user override from environment variables - ...getChainConfig(overrides), - ...getOperator(overrides), + ...getWalletClient(overrides), + ...getPublicClient(overrides), ...getContractAddress(overrides), ...getGraphUrl(overrides), ...getNftStorageToken(overrides), ...getWeb3StorageToken(overrides), ...getEasContractAddress(overrides), - } as HypercertClientConfig; + }; + + const missingKeys = []; for (const [key, value] of Object.entries(config)) { if (!value) { - logger.warn(`Cannot get chain config. ${key} is possibly undefined`); + missingKeys.push(key); } } + if (missingKeys.length > 0) logger.warn(`Missing properties in config: ${missingKeys.join(", ")}`); + return config; }; +const getDeployment = (chainId: SupportedChainIds) => { + return deployments[chainId]; +}; + const getChainConfig = (overrides: Partial) => { - const chainId = - overrides?.chainId ?? (process.env.DEFAULT_CHAIN_ID ? parseInt(process.env.DEFAULT_CHAIN_ID) : DEFAULT_CHAIN_ID); - let chainName: string; - - switch (chainId) { - case 5: - chainName = "goerli"; - break; - case 10: - chainName = "optimism-mainnet"; - break; - case 42220: - chainName = "celo"; - break; - case 11155111: - chainName = "sepolia"; - break; - default: - chainName = overrides?.chainName ?? ""; - if (!chainName) { - throw new UnsupportedChainError(`chainId=${chainId} is not yet supported`, { - chainID: chainId?.toString() || "undefined", - }); - } + const chainId = overrides?.chain?.id ? overrides.chain?.id : undefined; + + if (!chainId) { + throw new ConfigurationError("No chainId specified in config or environment variables"); + } + + const chain = getDefaultChain(chainId); + + if (!chain) { + throw new UnsupportedChainError(`No default config for chainId=${chainId} found in SDK`, { + chainID: chainId?.toString(), + }); } - return { chainId, chainName }; + return chain; }; const getContractAddress = (overrides: Partial) => { @@ -112,11 +120,6 @@ const getContractAddress = (overrides: Partial) => { } return { contractAddress: overrides.contractAddress }; } - const contractAddress = process.env.CONTRACT_ADDRESS; - if (contractAddress && !isAddress(contractAddress)) { - throw new InvalidOrMissingError("Invalid contract address.", { contractAddress }); - } - return contractAddress ? { contractAddress } : undefined; }; const getGraphUrl = (overrides: Partial) => { @@ -134,12 +137,12 @@ const getGraphUrl = (overrides: Partial) => { return { graphUrl }; } - const { chainId } = getChainConfig(overrides); + const chain = getChainConfig(overrides); - graphUrl = DEPLOYMENTS[chainId as keyof typeof DEPLOYMENTS].graphUrl ?? process.env.GRAPH_URL; + graphUrl = DEPLOYMENTS[chain?.id as keyof typeof DEPLOYMENTS].graphUrl ?? process.env.GRAPH_URL; if (!graphUrl) { - throw new UnsupportedChainError(`chainId=${chainId} is not yet supported`, { - chainID: chainId?.toString() || "undefined", + throw new UnsupportedChainError(`No Graph URL found in deployments or env vars`, { + chainID: chain?.toString(), }); } try { @@ -151,77 +154,56 @@ const getGraphUrl = (overrides: Partial) => { return { graphUrl }; }; -const getOperator = (overrides: Partial) => { - let operator: ethers.Signer | ethers.providers.Provider; +const getWalletClient = (overrides: Partial) => { + const walletClient = overrides.walletClient; - if ( - overrides.operator && - !ethers.providers.Provider.isProvider(overrides.operator) && - !ethers.Signer.isSigner(overrides.operator) - ) { - throw new InvalidOrMissingError("Invalid operator.", { operator: overrides.operator }); + if (!walletClient) { + logger.warn("No wallet client found", "getWalletClient", walletClient); } - if (ethers.Signer.isSigner(overrides.operator)) { - operator = overrides.operator; - } else if (ethers.providers.Provider.isProvider(overrides.operator)) { - operator = overrides.operator; - operator.on("network", (newNetwork, oldNetwork) => { - // When a Provider makes its initial connection, it emits a "network" - // event with a null oldNetwork along with the newNetwork. So, if the - // oldNetwork exists, it represents a changing network - - if (typeof window === "undefined") return; - if (oldNetwork && window.location) { - window.location.reload(); - } - }); - } else if (process.env.PRIVATE_KEY) { - const provider = ethers.getDefaultProvider(DEFAULT_CHAIN_ID); - operator = new ethers.Wallet(process.env.PRIVATE_KEY, provider); - } else { - operator = ethers.getDefaultProvider(DEFAULT_CHAIN_ID); + return { walletClient }; +}; + +const getPublicClient = (overrides: Partial) => { + const chain = getChainConfig(overrides); + let publicClient; + + publicClient = createPublicClient({ + chain: chain, + transport: http(), + }); + + if (overrides.publicClient) { + publicClient = overrides.publicClient; } - return { operator }; + return { publicClient }; }; -const getNftStorageToken = (overrides: Partial) => { +export const getNftStorageToken = (overrides: Partial) => { if (overrides.nftStorageToken) { return { nftStorageToken: overrides.nftStorageToken }; } - - if (process.env.NFT_STORAGE_TOKEN) { - return { nftStorageToken: process.env.NFT_STORAGE_TOKEN }; - } - - if (process.env.NEXT_PUBLIC_NFT_STORAGE_TOKEN) { - return { nftStorageToken: process.env.NEXT_PUBLIC_NFT_STORAGE_TOKEN }; - } - - return {}; }; -const getWeb3StorageToken = (overrides: Partial) => { +export const getWeb3StorageToken = (overrides: Partial) => { if (overrides.web3StorageToken) { return { web3StorageToken: overrides.web3StorageToken }; } - - if (process.env.WEB3_STORAGE_TOKEN) { - return { web3StorageToken: process.env.WEB3_STORAGE_TOKEN }; - } - - if (process.env.NEXT_PUBLIC_WEB3_STORAGE_TOKEN) { - return { web3StorageToken: process.env.NEXT_PUBLIC_WEB3_STORAGE_TOKEN }; - } - - return {}; }; const getEasContractAddress = (overrides: Partial) => { - if (overrides.easContractAddress) { - return { easContractAddress: overrides.easContractAddress }; - } + return { easContractAddress: overrides.easContractAddress }; +}; - return { easContractAddress: "0xC2679fBD37d54388Ce493F1DB75320D236e1815e" }; +const getDefaultChain = (chainId: number) => { + const _chains = [sepolia, goerli, optimism, celo]; + + for (const chain of Object.values(_chains)) { + if ("id" in chain) { + if (chain.id === chainId) { + return chain as Chain; + } + } + } }; diff --git a/sdk/src/utils/errors.ts b/sdk/src/utils/errors.ts index 2b44580d..29bd9c12 100644 --- a/sdk/src/utils/errors.ts +++ b/sdk/src/utils/errors.ts @@ -8,7 +8,7 @@ import { StorageError, UnknownSchemaError, UnsupportedChainError, -} from "../types/errors.js"; +} from "../types/errors"; /** * diff --git a/sdk/src/utils/formatter.ts b/sdk/src/utils/formatter.ts index d966b6b4..fa413cd9 100644 --- a/sdk/src/utils/formatter.ts +++ b/sdk/src/utils/formatter.ts @@ -1,5 +1,5 @@ -import { HypercertClaimdata, HypercertMetadata } from "../types/index.js"; -import { validateClaimData, validateMetaData } from "../validator/index.js"; +import { HypercertClaimdata, HypercertMetadata } from "../types"; +import { validateClaimData, validateMetaData } from "../validator"; export const INDEFINITE_DATE_STRING = "indefinite"; const formatUnixTime = (seconds: number) => { diff --git a/sdk/src/utils/resolvers.ts b/sdk/src/utils/resolvers.ts index 566795d1..3c52ea6d 100644 --- a/sdk/src/utils/resolvers.ts +++ b/sdk/src/utils/resolvers.ts @@ -1,10 +1,10 @@ -import { Resolvers } from "../../.graphclient/index.js"; +import { Resolvers } from "../../.graphclient"; export const resolvers: Resolvers = { Claim: { - chainName: (root, args, context) => context.chainName || "hypercerts-testnet", // The value we provide in the config + graphName: (root, args, context) => context.graphName, // The value we provide in the config }, ClaimToken: { - chainName: (root, args, context) => context.chainName || "hypercerts-testnet", // The value we provide in the config + graphName: (root, args, context) => context.graphName, // The value we provide in the config }, }; diff --git a/sdk/src/validator/index.ts b/sdk/src/validator/index.ts index b24244ce..e843fd84 100644 --- a/sdk/src/validator/index.ts +++ b/sdk/src/validator/index.ts @@ -1,7 +1,5 @@ import { StandardMerkleTree } from "@openzeppelin/merkle-tree"; import Ajv from "ajv"; -import { BigNumber, BigNumberish } from "ethers"; -import { isAddress } from "ethers/lib/utils.js"; import claimDataSchema from "../resources/schema/claimdata.json"; import evaluationSchema from "../resources/schema/evaluation.json"; @@ -13,7 +11,8 @@ import { HypercertMetadata, MintingError, SimpleTextEvaluation, -} from "../types/index.js"; +} from "../types"; +import { isAddress } from "viem"; const ajv = new Ajv({ allErrors: true }); // options can be passed, e.g. {allErrors: true} ajv.addSchema(metaDataSchema, "metaData"); @@ -88,16 +87,16 @@ const validateClaimData = (data: HypercertClaimdata): ValidationResult => { * @param units The total number of units in the allowlist. * @returns A `ValidationResult` object indicating whether the data is valid and any errors that were found. */ -const validateAllowlist = (data: AllowlistEntry[], units: BigNumberish) => { +const validateAllowlist = (data: AllowlistEntry[], units: bigint) => { const errors: Record = {}; - const totalUnits = data.reduce((acc, curr) => acc.add(curr.units), BigNumber.from(0)); - if (!totalUnits.eq(units)) { + const totalUnits = data.reduce((acc, curr) => acc + BigInt(curr.units.toString()), 0n); + if (totalUnits != units) { errors[ "units" ] = `Total units in allowlist must match total units [expected: ${units}, got: ${totalUnits.toString()}]`; } - if (totalUnits.eq(0)) { + if (totalUnits == 0n) { errors["units"] = "Total units in allowlist must be greater than 0"; } @@ -167,7 +166,7 @@ const validateSimpleTextEvaluationData = (data: SimpleTextEvaluation): Validatio * @param proof The Merkle proof to verify. * @throws {MintingError} If the Merkle proof verification fails. */ -function verifyMerkleProof(root: string, signerAddress: string, units: BigNumberish, proof: string[]): void { +function verifyMerkleProof(root: string, signerAddress: string, units: bigint, proof: string[]): void { if (!isAddress(signerAddress)) { throw new MintingError("Invalid address", { signerAddress }); } @@ -187,7 +186,7 @@ function verifyMerkleProof(root: string, signerAddress: string, units: BigNumber * @throws {MintingError} If the Merkle proof verification fails. * @notice Wrapper around `verifyMerkleProof` to batch verify multiple proofs */ -function verifyMerkleProofs(roots: string[], signerAddress: string, units: BigNumberish[], proofs: string[][]) { +function verifyMerkleProofs(roots: string[], signerAddress: string, units: bigint[], proofs: string[][]) { if (roots.length !== units.length || units.length !== proofs.length) { throw new MintingError("Invalid input", { roots, units, proofs }); } diff --git a/sdk/test/client.test.ts b/sdk/test/client.test.ts index 8540404b..6f9e124e 100644 --- a/sdk/test/client.test.ts +++ b/sdk/test/client.test.ts @@ -1,13 +1,9 @@ import { expect } from "chai"; -import { MockProvider } from "ethereum-waffle"; -import { ethers } from "ethers"; import sinon from "sinon"; -import { HypercertClient, HypercertMetadata, TransferRestrictions } from "../src/index.js"; -import { AllowlistEntry, ClientError, UnsupportedChainError } from "../src/types/index.js"; - -const provider = new MockProvider(); -sinon.stub(provider, "on"); +import { HypercertClient, HypercertMetadata, TransferRestrictions } from "../src"; +import { AllowlistEntry, ClientError, UnsupportedChainError } from "../src/types"; +import { publicClient, walletClient } from "./helpers"; describe("HypercertClient setup tests", () => { afterAll(() => { @@ -15,51 +11,50 @@ describe("HypercertClient setup tests", () => { }); it("should be able to create a new read only instance when missing storage keys", () => { - sinon.stub(process, "env").value({ NFT_STORAGE_TOKEN: null }); - sinon.stub(process, "env").value({ WEB3_STORAGE_TOKEN: null }); - sinon.stub(process, "env").value({ NEXT_PUBLIC_NFT_STORAGE_TOKEN: null }); - sinon.stub(process, "env").value({ NEXT_PUBLIC_WEB3_STORAGE_TOKEN: null }); - - const client = new HypercertClient({ operator: provider }); + const readOnlyClient = new HypercertClient({ + chain: { id: 5 }, + publicClient, + }); - expect(client).to.be.an.instanceOf(HypercertClient); - expect(client.readonly).to.be.true; + expect(readOnlyClient).to.be.an.instanceOf(HypercertClient); + expect(readOnlyClient.readonly).to.be.true; }); it("should be able to create a new instance", () => { - const operator = ethers.Wallet.createRandom(); - - const config = { chainId: 5, operator, nftStorageToken: "test", web3StorageToken: "test" }; - const client = new HypercertClient(config); + const client = new HypercertClient({ + chain: { id: 5 }, + publicClient, + walletClient, + nftStorageToken: "test", + web3StorageToken: "test", + }); expect(client).to.be.an.instanceOf(HypercertClient); + + //TODO currently only publicClient added as a test, also add other flows expect(client.readonly).to.be.false; }); it("should throw an error when the chainId is not supported", () => { + const falseChainId = 1337; try { - new HypercertClient({ operator: provider, chainId: 1337 }); + new HypercertClient({ chain: { id: falseChainId } }); expect.fail("Should throw UnsupportedChainError"); } catch (e) { expect(e).to.be.instanceOf(UnsupportedChainError); const error = e as UnsupportedChainError; - expect(error.message).to.eq("chainId=1337 is not yet supported"); - expect(Number(error.payload?.chainID)).to.eq(1337); + expect(error.message).to.eq("No default config for chainId=1337 found in SDK"); + expect(Number(error.payload?.chainID)).to.eq(falseChainId); } }); it("should throw an error when executing write method in readonly mode", async () => { - sinon.stub(process, "env").value({ NFT_STORAGE_TOKEN: null }); - sinon.stub(process, "env").value({ WEB3_STORAGE_TOKEN: null }); - sinon.stub(process, "env").value({ NEXT_PUBLIC_NFT_STORAGE_TOKEN: null }); - sinon.stub(process, "env").value({ NEXT_PUBLIC_WEB3_STORAGE_TOKEN: null }); - - const client = new HypercertClient({ operator: provider }); + const client = new HypercertClient({ chain: { id: 5 } }); // mintClaim try { const metaData = { name: "test" } as HypercertMetadata; - const totalUnits = 1; + const totalUnits = 1n; const transferRestrictions = TransferRestrictions.AllowAll; await client.mintClaim(metaData, totalUnits, transferRestrictions); @@ -68,15 +63,15 @@ describe("HypercertClient setup tests", () => { expect(e).to.be.instanceOf(ClientError); const error = e as ClientError; - expect(error.message).to.eq("Client is readonly"); + expect(error.message).to.eq("Could not connect to wallet; sending transactions not allowed."); expect(error.payload?.client instanceof HypercertClient).to.be.true; } // createAllowlist try { - const allowlist: AllowlistEntry[] = [{ address: "0x0000000", units: 100 }]; + const allowlist: AllowlistEntry[] = [{ address: "0x0000000", units: 100n }]; const metaData = { name: "test" } as HypercertMetadata; - const totalUnits = 1; + const totalUnits = 1n; const transferRestrictions = TransferRestrictions.AllowAll; await client.createAllowlist(allowlist, metaData, totalUnits, transferRestrictions); @@ -85,42 +80,42 @@ describe("HypercertClient setup tests", () => { expect(e).to.be.instanceOf(ClientError); const error = e as ClientError; - expect(error.message).to.eq("Client is readonly"); + expect(error.message).to.eq("Could not connect to wallet; sending transactions not allowed."); expect(error.payload?.client).to.be.instanceOf(HypercertClient); } // splitClaimUnits try { - const claimId = 1; - const fractions = [100, 200]; + const claimId = 1n; + const fractions = [100n, 200n]; - await client.splitClaimUnits(claimId, fractions); + await client.splitFractionUnits(claimId, fractions); expect.fail("Should throw ClientError"); } catch (e) { expect(e).to.be.instanceOf(ClientError); const error = e as ClientError; - expect(error.message).to.eq("Client is readonly"); + expect(error.message).to.eq("Could not connect to wallet; sending transactions not allowed."); expect(error.payload?.client).to.be.instanceOf(HypercertClient); } // mergeClaimUnits try { - const claimIds = [1, 2]; + const claimIds = [1n, 2n]; - await client.mergeClaimUnits(claimIds); + await client.mergeFractionUnits(claimIds); expect.fail("Should throw ClientError"); } catch (e) { expect(e).to.be.instanceOf(ClientError); const error = e as ClientError; - expect(error.message).to.eq("Client is readonly"); + expect(error.message).to.eq("Could not connect to wallet; sending transactions not allowed."); expect(error.payload?.client).to.be.instanceOf(HypercertClient); } // burnClaimFraction try { - const claimId = 1; + const claimId = 1n; await client.burnClaimFraction(claimId); expect.fail("Should throw ClientError"); @@ -128,16 +123,16 @@ describe("HypercertClient setup tests", () => { expect(e).to.be.instanceOf(ClientError); const error = e as ClientError; - expect(error.message).to.eq("Client is readonly"); + expect(error.message).to.eq("Could not connect to wallet; sending transactions not allowed."); expect(error.payload?.client).to.be.instanceOf(HypercertClient); } // mintClaimFractionFromAllowlist try { - const claimId = 1; - const units = 100; - const proof = ["0x1", "0x2", "0x3"]; - const root = "0x4"; + const claimId = 1n; + const units = 100n; + const proof = ["0x1", "0x2", "0x3"] as `0x${string}`[]; + const root = "0x4" as `0x${string}`; await client.mintClaimFractionFromAllowlist(claimId, units, proof, root); expect.fail("Should throw ClientError"); @@ -145,19 +140,16 @@ describe("HypercertClient setup tests", () => { expect(e).to.be.instanceOf(ClientError); const error = e as ClientError; - expect(error.message).to.eq("Client is readonly"); + expect(error.message).to.eq("Could not connect to wallet; sending transactions not allowed."); expect(error.payload?.client).to.be.instanceOf(HypercertClient); } // batchMintClaimFractionsFromAllowlist try { - const claimIds = [1, 2]; - const units = [100, 200]; - const proofs = [ - ["0x1", "0x2", "0x3"], - ["0x4", "0x5", "0x6"], - ]; - const roots = ["0x7", "0x8"]; + const claimIds = [1n, 2n]; + const units = [100n, 200n]; + const proofs = [["0x1", "0x2", "0x3"] as `0x${string}`[], ["0x4", "0x5", "0x6"] as `0x${string}`[]]; + const roots = ["0x7", "0x8"] as `0x${string}`[]; await client.batchMintClaimFractionsFromAllowlists(claimIds, units, proofs, roots); expect.fail("Should throw ClientError"); @@ -165,7 +157,7 @@ describe("HypercertClient setup tests", () => { expect(e).to.be.instanceOf(ClientError); const error = e as ClientError; - expect(error.message).to.eq("Client is readonly"); + expect(error.message).to.eq("Could not connect to wallet; sending transactions not allowed."); expect(error.payload?.client).to.be.instanceOf(HypercertClient); } }); diff --git a/sdk/test/client/allowlist.minting.test.ts b/sdk/test/client/allowlist.minting.test.ts index b2b9eb3c..efc6ac2f 100644 --- a/sdk/test/client/allowlist.minting.test.ts +++ b/sdk/test/client/allowlist.minting.test.ts @@ -1,59 +1,57 @@ -import { MockContract, MockProvider, deployMockContract } from "ethereum-waffle"; -import { BigNumber, ethers } from "ethers"; import sinon from "sinon"; import { expect } from "@jest/globals"; -import { HypercertClient } from "../../src/index.js"; +import { HypercertClient } from "../../src"; import HypercertsStorage from "../../src/storage.js"; -import { MalformedDataError, MintingError, TransferRestrictions } from "../../src/types/index.js"; -import { getAllowlist, getFormattedMetadata } from "../helpers.js"; -import { HypercertMinter, HypercertMinterAbi } from "@hypercerts-org/contracts"; -const mockCorrectMetadataCid = "testCID1234fkreigdm2flneb4khd7eixodagst5nrndptgezrjux7gohxcngjn67x6u"; +import { MalformedDataError, MintingError, TransferRestrictions } from "../../src/types"; +import { getAllowlist, getFormattedMetadata, publicClient, walletClient, mockDataSets } from "../helpers"; +import { HypercertMinterAbi } from "@hypercerts-org/contracts"; +import { encodeFunctionResult, isHex, parseAbi, stringToHex } from "viem"; describe("Allows for minting claims from an allowlist", () => { - const metaDataStub = sinon.stub(HypercertsStorage.prototype, "storeMetadata").resolves(mockCorrectMetadataCid); - const dataStub = sinon.stub(HypercertsStorage.prototype, "storeData").resolves(mockCorrectMetadataCid); + const { hypercertData, hypercertMetadata } = mockDataSets; + const metaDataStub = sinon.stub(HypercertsStorage.prototype, "storeMetadata").resolves(hypercertMetadata.cid); + const dataStub = sinon.stub(HypercertsStorage.prototype, "storeData").resolves(hypercertData.cid); + const wallet = walletClient; + const userAddress = wallet.account?.address; + const client = new HypercertClient({ + chain: { id: 5 }, + walletClient, + publicClient, + nftStorageToken: "test", + web3StorageToken: "test", + }); - const setUp = async () => { - const provider = new MockProvider(); - const [user, other, admin] = provider.getWallets(); - const stub = sinon.stub(provider, "on"); + const readSpy = sinon.stub(publicClient, "readContract"); + let writeSpy = sinon.stub(walletClient, "writeContract"); - const minter = await deployMockContract(user, HypercertMinterAbi); + const mintClaimFromAllowlistResult = encodeFunctionResult({ + abi: parseAbi(HypercertMinterAbi), + functionName: "mintClaimFromAllowlist", + result: [], + }); - const client = new HypercertClient({ - chainId: 5, - operator: user, - }); + const batchMintClaimFromAllowlistResult = encodeFunctionResult({ + abi: parseAbi(HypercertMinterAbi), + functionName: "batchMintClaimsFromAllowlists", + result: [], + }); - sinon.replaceGetter(client, "contract", () => minter as unknown as HypercertMinter); - - return { - client, - provider, - users: { user, other, admin }, - minter, - stub, - }; - }; - - let _client: HypercertClient; - let _provider: MockProvider; - let _users: { user: ethers.Wallet; other: ethers.Wallet; admin: ethers.Wallet }; - let _minter: MockContract; - let _stub: sinon.SinonStub; - - beforeAll(async () => { - const { client, provider, users, minter, stub } = await setUp(); - _client = client; - _provider = provider; - _users = users; - _minter = minter; - _stub = stub; + const mintClaimResult = encodeFunctionResult({ + abi: parseAbi(HypercertMinterAbi), + functionName: "createAllowlist", + result: [], }); - beforeEach(() => { - _provider.clearCallHistory(); + beforeEach(async () => { + readSpy.resetBehavior(); + readSpy.resetHistory(); + + writeSpy.resetBehavior(); + writeSpy.resetHistory(); + + metaDataStub.resetHistory(); + dataStub.resetHistory(); }); afterAll(() => { @@ -65,22 +63,24 @@ describe("Allows for minting claims from an allowlist", () => { const { allowlist, totalUnits } = getAllowlist(); const metaData = getFormattedMetadata(); - await _minter.mock.createAllowlist.returns(); - const res = await _client.createAllowlist(allowlist, metaData, totalUnits, TransferRestrictions.FromCreatorOnly); + writeSpy = writeSpy.resolves(mintClaimResult); - sinon.assert.calledOnce(metaDataStub); - sinon.assert.calledOnce(dataStub); + const hash = await client.createAllowlist(allowlist, metaData, totalUnits, TransferRestrictions.FromCreatorOnly); - expect(res.chainId).toBe(1337); - expect(_provider.callHistory.length).toBe(2); + expect(isHex(hash)).toBeTruthy(); + expect(metaDataStub.callCount).toBe(1); + expect(dataStub.callCount).toBe(1); + expect(readSpy.callCount).toBe(0); + expect(writeSpy.callCount).toBe(1); }); it("should not create an allowlist if the total units mismatch", async () => { const { allowlist, totalUnits } = getAllowlist(); const metaData = getFormattedMetadata(); + let hash; try { - await _client.createAllowlist(allowlist, metaData, totalUnits.add(1), TransferRestrictions.FromCreatorOnly); + hash = await client.createAllowlist(allowlist, metaData, totalUnits + 1n, TransferRestrictions.FromCreatorOnly); } catch (e) { expect(e instanceof MalformedDataError).toBeTruthy(); @@ -91,28 +91,40 @@ describe("Allows for minting claims from an allowlist", () => { }); } - expect(_provider.callHistory.length).toBe(0); - expect.assertions(4); + expect(hash).toBeUndefined(); + expect(metaDataStub.callCount).toBe(0); + expect(dataStub.callCount).toBe(0); + expect(readSpy.callCount).toBe(0); + expect(writeSpy.callCount).toBe(0); + expect.assertions(8); }); it("should not create an allowlist if the allowlist is empty", async () => { - const { allowlist, totalUnits } = getAllowlist({ size: 1 }); + const { allowlist, totalUnits } = getAllowlist(); const metaData = getFormattedMetadata(); - allowlist[0].units = BigNumber.from(0); + let hash; + + allowlist[0].units = 0n; try { - await _client.createAllowlist(allowlist, metaData, totalUnits, TransferRestrictions.FromCreatorOnly); + hash = await client.createAllowlist(allowlist, metaData, totalUnits, TransferRestrictions.FromCreatorOnly); } catch (e) { expect(e instanceof MalformedDataError).toBeTruthy(); const error = e as MalformedDataError; expect(error.message).toBe("Allowlist validation failed"); - expect(error.payload).toEqual({ units: "Total units in allowlist must be greater than 0" }); + expect(error.payload).toEqual({ + units: "Total units in allowlist must match total units [expected: 10, got: 9]", + }); } - expect(_provider.callHistory.length).toBe(0); - expect.assertions(4); + expect(hash).toBeUndefined(); + expect(metaDataStub.callCount).toBe(0); + expect(dataStub.callCount).toBe(0); + expect(readSpy.callCount).toBe(0); + expect(writeSpy.callCount).toBe(0); + expect.assertions(8); }); }); @@ -120,41 +132,53 @@ describe("Allows for minting claims from an allowlist", () => { it("should allow to mint a claim from an allowlist without the root", async () => { const { allowlist, merkleTree } = getAllowlist({ size: 1 }); - await _minter.mock.mintClaimFromAllowlist.returns(); + writeSpy = writeSpy.resolves(mintClaimFromAllowlistResult); - await _client.mintClaimFractionFromAllowlist( - 1, + const hash = await client.mintClaimFractionFromAllowlist( + 1n, allowlist[0].units, - merkleTree.getProof([allowlist[0].address, allowlist[0].units.toString()]), + merkleTree.getProof([allowlist[0].address, allowlist[0].units.toString()]) as `0x${string}`[], ); - expect(_provider.callHistory.length).toBe(2); + expect(isHex(hash)).toBeTruthy(); + expect(metaDataStub.callCount).toBe(0); + expect(dataStub.callCount).toBe(0); + expect(readSpy.callCount).toBe(0); + expect(writeSpy.callCount).toBe(1); + expect.assertions(5); }); it("should allow to mint a claim from an allowlist with a correct root", async () => { - const { allowlist, merkleTree } = getAllowlist({ size: 1, address: _users.user.address as `0x${string}` }); + const { allowlist, merkleTree } = getAllowlist({ size: 1, address: userAddress }); - await _minter.mock.mintClaimFromAllowlist.returns(); + writeSpy = writeSpy.resolves(mintClaimFromAllowlistResult); - await _client.mintClaimFractionFromAllowlist( - 1, + const hash = await client.mintClaimFractionFromAllowlist( + 1n, allowlist[0].units, - merkleTree.getProof([allowlist[0].address, allowlist[0].units.toString()]), - merkleTree.root, + merkleTree.getProof([allowlist[0].address, allowlist[0].units.toString()]) as `0x${string}`[], + merkleTree.root as `0x${string}`, ); - expect(_provider.callHistory.length).toBe(2); + expect(isHex(hash)).toBeTruthy(); + expect(metaDataStub.callCount).toBe(0); + expect(dataStub.callCount).toBe(0); + expect(readSpy.callCount).toBe(0); + expect(writeSpy.callCount).toBe(1); + expect.assertions(5); }); it("should not allow to mint a claim from an allowlist with an incorrect root", async () => { - const { allowlist, merkleTree } = getAllowlist({ size: 1, address: _users.user.address as `0x${string}` }); + const { allowlist, merkleTree } = getAllowlist({ size: 1, address: userAddress }); + + const mockRoot = stringToHex("MOCK_ROOT", { size: 32 }); - const mockRoot = ethers.utils.formatBytes32String("MOCK_ROOT"); + let hash; try { - await _client.mintClaimFractionFromAllowlist( - 1, + hash = await client.mintClaimFractionFromAllowlist( + 1n, allowlist[0].units, - merkleTree.getProof([allowlist[0].address, allowlist[0].units.toString()]), + merkleTree.getProof([allowlist[0].address, allowlist[0].units.toString()]) as `0x${string}`[], mockRoot, ); } catch (e) { @@ -168,17 +192,21 @@ describe("Allows for minting claims from an allowlist", () => { }); } - expect(_provider.callHistory.length).toBe(0); - expect.assertions(4); + expect(hash).toBeUndefined(); + expect(metaDataStub.callCount).toBe(0); + expect(dataStub.callCount).toBe(0); + expect(readSpy.callCount).toBe(0); + expect(writeSpy.callCount).toBe(0); + expect.assertions(8); }); }); describe("Batch mint fractions", () => { it("should allow to batch mint a claim from an allowlist without the root", async () => { const firstList = getAllowlist({ size: 1 }); - const secondList = getAllowlist({ size: 1, units: 42 }); + const secondList = getAllowlist({ size: 1, units: 42n }); - await _minter.mock.batchMintClaimsFromAllowlists.returns(); + writeSpy = writeSpy.resolves(batchMintClaimFromAllowlistResult); const firstProofs = firstList.merkleTree.getProof([ firstList.allowlist[0].address, @@ -188,20 +216,25 @@ describe("Allows for minting claims from an allowlist", () => { secondList.allowlist[0].address, secondList.allowlist[0].units.toString(), ]); - await _client.batchMintClaimFractionsFromAllowlists( - [1, 2], + const hash = await client.batchMintClaimFractionsFromAllowlists( + [1n, 2n], [firstList.allowlist[0].units, secondList.allowlist[0].units], - [firstProofs, secondProofs], + [firstProofs, secondProofs] as `0x${string}`[][], ); - expect(_provider.callHistory.length).toBe(2); + expect(isHex(hash)).toBeTruthy(); + expect(metaDataStub.callCount).toBe(0); + expect(dataStub.callCount).toBe(0); + expect(readSpy.callCount).toBe(0); + expect(writeSpy.callCount).toBe(1); + expect.assertions(5); }); it("should allow to mint a claim from an allowlist with a correct root", async () => { - const firstList = getAllowlist({ size: 1, address: _users.user.address as `0x${string}` }); - const secondList = getAllowlist({ size: 1, units: 42, address: _users.user.address as `0x${string}` }); + const firstList = getAllowlist({ size: 1, address: userAddress }); + const secondList = getAllowlist({ size: 1, units: 42n, address: userAddress }); - await _minter.mock.batchMintClaimsFromAllowlists.returns(); + writeSpy = writeSpy.resolves(batchMintClaimFromAllowlistResult); const firstProofs = firstList.merkleTree.getProof([ firstList.allowlist[0].address, @@ -211,21 +244,26 @@ describe("Allows for minting claims from an allowlist", () => { secondList.allowlist[0].address, secondList.allowlist[0].units.toString(), ]); - await _client.batchMintClaimFractionsFromAllowlists( - [1, 2], + const hash = await client.batchMintClaimFractionsFromAllowlists( + [1n, 2n], [firstList.allowlist[0].units, secondList.allowlist[0].units], - [firstProofs, secondProofs], - [firstList.merkleTree.root, secondList.merkleTree.root], + [firstProofs, secondProofs] as `0x${string}`[][], + [firstList.merkleTree.root, secondList.merkleTree.root] as `0x${string}`[], ); - expect(_provider.callHistory.length).toBe(2); + expect(isHex(hash)).toBeTruthy(); + expect(metaDataStub.callCount).toBe(0); + expect(dataStub.callCount).toBe(0); + expect(readSpy.callCount).toBe(0); + expect(writeSpy.callCount).toBe(1); + expect.assertions(5); }); it("should not allow to mint a claim from an allowlist with an incorrect root", async () => { - const firstList = getAllowlist({ size: 1, address: _users.user.address as `0x${string}` }); - const secondList = getAllowlist({ size: 1, units: 42, address: _users.user.address as `0x${string}` }); + const firstList = getAllowlist({ size: 1, address: userAddress }); + const secondList = getAllowlist({ size: 1, units: 42n, address: userAddress }); - await _minter.mock.batchMintClaimsFromAllowlists.returns(); + writeSpy = writeSpy.resolves(batchMintClaimFromAllowlistResult); const firstProofs = firstList.merkleTree.getProof([ firstList.allowlist[0].address, @@ -236,13 +274,14 @@ describe("Allows for minting claims from an allowlist", () => { secondList.allowlist[0].units.toString(), ]); - const mockRoot = ethers.utils.formatBytes32String("MOCK_ROOT"); + const mockRoot = stringToHex("MOCK_ROOT", { size: 32 }); + let hash; try { - await _client.batchMintClaimFractionsFromAllowlists( - [1, 2], + hash = await client.batchMintClaimFractionsFromAllowlists( + [1n, 2n], [firstList.allowlist[0].units, secondList.allowlist[0].units], - [firstProofs, secondProofs], - [firstList.merkleTree.root, mockRoot], + [firstProofs, secondProofs] as `0x${string}`[][], + [firstList.merkleTree.root as `0x${string}`, mockRoot], ); } catch (e) { expect(e instanceof MintingError).toBeTruthy(); @@ -255,8 +294,12 @@ describe("Allows for minting claims from an allowlist", () => { }); } - // Signer getAddress - expect(_provider.callHistory.length).toBe(1); + expect(hash).toBeUndefined(); + expect(metaDataStub.callCount).toBe(0); + expect(dataStub.callCount).toBe(0); + expect(readSpy.callCount).toBe(0); + expect(writeSpy.callCount).toBe(0); + expect.assertions(8); }); }); }); diff --git a/sdk/test/client/burn.test.ts b/sdk/test/client/burn.test.ts index c0d83887..64b2d877 100644 --- a/sdk/test/client/burn.test.ts +++ b/sdk/test/client/burn.test.ts @@ -1,68 +1,63 @@ -import { MockProvider, deployMockContract } from "ethereum-waffle"; -import { BigNumber, Wallet } from "ethers"; +import HypercertClient from "../../src/client"; +import { walletClient, publicClient } from "../helpers"; +import { ContractFunctionExecutionError, isHex, toHex } from "viem"; import sinon from "sinon"; +import { faker } from "@faker-js/faker"; +import { ClientError } from "../../src"; -import HypercertClient from "../../src/client.js"; -import { ClientError } from "../../src/types/errors.js"; -import { HypercertMinterAbi } from "@hypercerts-org/contracts"; describe("burn fraction tokens in HypercertClient", () => { - let stub: sinon.SinonStub; - let provider: MockProvider; - let user: Wallet; - let other: Wallet; - const fractionId = BigNumber.from("9868188640707215440437863615521278132232"); + const wallet = walletClient; + const userAddress = wallet.account?.address; + const client = new HypercertClient({ + chain: { id: 5 }, + walletClient, + publicClient, + nftStorageToken: "test", + web3StorageToken: "test", + }); - beforeAll(() => { - provider = new MockProvider(); - [user, other] = provider.getWallets(); + const fractionId = 9868188640707215440437863615521278132232n; - stub = sinon.stub(provider, "on"); - }); - beforeEach(() => { - provider.clearCallHistory(); + let readSpy = sinon.stub(publicClient, "readContract"); + let writeSpy = sinon.stub(walletClient, "writeContract"); + + beforeEach(async () => { + readSpy.resetBehavior(); + readSpy.resetHistory(); + + writeSpy.resetBehavior(); + writeSpy.resetHistory(); }); afterAll(() => { - stub.restore(); + sinon.restore(); }); it("allows for a hypercert fraction to be burned", async () => { - const userAddress = await user.getAddress(); - const mockMinter = await deployMockContract(user, HypercertMinterAbi); - await mockMinter.mock.ownerOf.withArgs(fractionId).returns(userAddress); - await mockMinter.mock["burnFraction(address,uint256)"].withArgs(userAddress, fractionId).returns(); + readSpy = readSpy.resolves(userAddress); - const client = new HypercertClient({ - chainId: 5, - operator: user, - contractAddress: mockMinter.address, - }); + writeSpy = writeSpy.resolves(toHex(420)); expect(client.readonly).toBe(false); - await client.burnClaimFraction(fractionId); + const hash = await client.burnClaimFraction(fractionId); + console.log(hash); //TODO determine underlying calls and mock those out. Some are provider simulation calls - expect(provider.callHistory.length).toBe(5); + expect(isHex(hash)).toBeTruthy(); + expect(readSpy.callCount).toBe(1); + expect(writeSpy.callCount).toBe(1); }); it("throws on burning fraction not owned by signer", async () => { - const otherUser = await other.getAddress(); - const mockMinter = await deployMockContract(user, HypercertMinterAbi); - await mockMinter.mock.ownerOf.withArgs(fractionId).returns(otherUser); - - const client = new HypercertClient({ - chainId: 5, - operator: user, - contractAddress: mockMinter.address, - }); + readSpy = readSpy.resolves(faker.finance.ethereumAddress()); expect(client.readonly).toBe(false); + let hash; try { - await client.burnClaimFraction(fractionId); + hash = await client.burnClaimFraction(fractionId); } catch (e) { - console.log(e); expect(e instanceof ClientError).toBeTruthy(); const error = e as ClientError; @@ -70,34 +65,36 @@ describe("burn fraction tokens in HypercertClient", () => { } //TODO determine underlying calls and mock those out. Some are provider simulation calls - // Owner - expect(provider.callHistory.length).toBe(3); - expect.assertions(4); + expect(hash).toBeUndefined(); + expect(readSpy.callCount).toBe(1); + expect(writeSpy.callCount).toBe(0); + expect.assertions(6); }); it("allows for a hypercert fraction to be burned with override params", async () => { - const userAddress = await user.getAddress(); - const mockMinter = await deployMockContract(user, HypercertMinterAbi); - await mockMinter.mock.ownerOf.withArgs(fractionId).returns(userAddress); - await mockMinter.mock["burnFraction(address,uint256)"].withArgs(userAddress, fractionId).returns(); + readSpy = readSpy.resolves(userAddress); - const client = new HypercertClient({ - chainId: 5, - operator: user, - contractAddress: mockMinter.address, - }); + writeSpy = writeSpy.resolves(toHex(420)); expect(client.readonly).toBe(false); + let noHash; + try { - await client.burnClaimFraction(fractionId, { gasLimit: "FALSE_VALUE" }); + noHash = await client.burnClaimFraction(fractionId, { gasLimit: "FALSE_VALUE" as unknown as bigint }); + expect.fail("should have thrown on incorrect gasLimit value"); } catch (e) { - expect((e as Error).message).toMatch(/invalid BigNumber string/); + expect(e instanceof ContractFunctionExecutionError).toBeTruthy(); } - await client.burnClaimFraction(fractionId, { gasLimit: "12300000" }); + const hash = await client.burnClaimFraction(fractionId, { gasLimit: 12300000n }); //TODO determine underlying calls and mock those out. Some are provider simulation calls - expect(provider.callHistory.length).toBe(6); + expect(noHash).toBeUndefined(); + + expect(isHex(hash)).toBeTrue(); + expect(readSpy.callCount).toBe(2); + expect(writeSpy.callCount).toBe(1); + expect.assertions(6); }); }); diff --git a/sdk/test/client/minting.test.ts b/sdk/test/client/minting.test.ts index 2d657062..1136704d 100644 --- a/sdk/test/client/minting.test.ts +++ b/sdk/test/client/minting.test.ts @@ -1,60 +1,45 @@ import { expect } from "chai"; -import { MockContract, MockProvider, deployMockContract } from "ethereum-waffle"; -import { ethers } from "ethers"; import sinon from "sinon"; -import { jest, test } from "@jest/globals"; +import { ContractFunctionExecutionError, encodeFunctionResult, isHex, parseAbi } from "viem"; -import HypercertClient from "../../src/client.js"; -import { HypercertMetadata, HypercertsStorage, formatHypercertData } from "../../src/index.js"; -import { MalformedDataError } from "../../src/types/errors.js"; -import { TransferRestrictions } from "../../src/types/hypercerts.js"; -import { getRawInputData } from "../helpers.js"; -import { HypercertMinter, HypercertMinterAbi } from "@hypercerts-org/contracts"; -const mockCorrectMetadataCid = "testCID1234fkreigdm2flneb4khd7eixodagst5nrndptgezrjux7gohxcngjn67x6u"; +import HypercertClient from "../../src/client"; +import { HypercertMetadata, formatHypercertData } from "../../src"; +import { MalformedDataError } from "../../src/types/errors"; +import { TransferRestrictions } from "../../src/types/hypercerts"; +import { getRawInputData, publicClient, walletClient } from "../helpers"; +import { HypercertMinterAbi } from "@hypercerts-org/contracts"; + +//eslint-disable-next-line @typescript-eslint/ban-ts-comment +// @ts-ignore +import { CIDString, NFTStorage } from "nft.storage"; describe("mintClaim in HypercertClient", () => { - const metaDataStub = sinon.stub(HypercertsStorage.prototype, "storeMetadata").resolves(mockCorrectMetadataCid); - - const setUp = async () => { - const provider = new MockProvider(); - const [user, other, admin] = provider.getWallets(); - const stub = sinon.stub(provider, "on"); - - const minter = await deployMockContract(user, HypercertMinterAbi); - - const client = new HypercertClient({ - chainId: 5, - operator: user, - }); - - sinon.replaceGetter(client, "contract", () => minter as unknown as HypercertMinter); - - return { - client, - provider, - users: { user, other, admin }, - minter, - stub, - }; - }; - - let _client: HypercertClient; - let _provider: MockProvider; - let _users: { user: ethers.Wallet; other: ethers.Wallet; admin: ethers.Wallet }; - let _minter: MockContract; - let _stub: sinon.SinonStub; - - beforeAll(async () => { - const { client, provider, users, minter, stub } = await setUp(); - _client = client; - _provider = provider; - _users = users; - _minter = minter; - _stub = stub; + const mockCorrectMetadataCid = "testCID1234fkreigdm2flneb4khd7eixodagst5nrndptgezrjux7gohxcngjn67x6u" as CIDString; + + const storeBlobMock = sinon.stub(NFTStorage, "storeBlob").resolves(mockCorrectMetadataCid); + + const client = new HypercertClient({ + chain: { id: 5 }, + walletClient, + publicClient, + nftStorageToken: "test", + web3StorageToken: "test", }); - beforeEach(() => { - _provider.clearCallHistory(); + const readSpy = sinon.stub(publicClient, "readContract"); + let writeSpy = sinon.stub(walletClient, "writeContract"); + + const mintClaimResult = encodeFunctionResult({ + abi: parseAbi(HypercertMinterAbi), + functionName: "mintClaim", + result: [], + }); + + beforeEach(async () => { + writeSpy.resetBehavior(); + writeSpy.resetHistory(); + + storeBlobMock.resetHistory(); }); afterAll(() => { @@ -62,49 +47,59 @@ describe("mintClaim in HypercertClient", () => { }); it("mints a hypercerts", async () => { - expect(_client.readonly).to.be.false; + expect(client.readonly).to.be.false; const rawData = getRawInputData(); const { data: formattedData } = formatHypercertData(rawData); - await _minter.mock.mintClaim.returns(); + writeSpy = writeSpy.resolves(mintClaimResult); // eslint-disable-next-line @typescript-eslint/no-non-null-assertion - await _client.mintClaim(formattedData!, 1000, TransferRestrictions.AllowAll); + const hash = await client.mintClaim(formattedData!, 1000n, TransferRestrictions.AllowAll); - sinon.assert.calledOnce(metaDataStub); - expect(_provider.callHistory.length).to.equal(2); - }, 10000); + expect(isHex(hash)).to.be.true; + expect(readSpy.callCount).to.equal(0); + expect(writeSpy.callCount).to.equal(1); + expect(storeBlobMock.callCount).to.equal(1); + }); it("throws on malformed metadata", async () => { try { - await _client.mintClaim({} as HypercertMetadata, 1000, TransferRestrictions.AllowAll); + await client.mintClaim({} as HypercertMetadata, 1000n, TransferRestrictions.AllowAll); expect.fail("Should throw MalformedDataError"); } catch (e) { expect(e).to.be.instanceOf(MalformedDataError); const error = e as MalformedDataError; expect(error.message).to.equal("Metadata validation failed"); } - expect(_provider.callHistory.length).to.equal(0); + expect(writeSpy.callCount).to.equal(0); }); it("mints a hypercerts with override params", async () => { const rawData = getRawInputData(); - await _minter.mock.mintClaim.returns(); const { data: formattedData } = formatHypercertData(rawData); + writeSpy = writeSpy.resolves(mintClaimResult); + + let hash; + try { // eslint-disable-next-line @typescript-eslint/no-non-null-assertion - await _client.mintClaim(formattedData!, 1000, TransferRestrictions.AllowAll, { gasPrice: "FALSE_VALUE" }); + hash = await client.mintClaim(formattedData!, 1000n, TransferRestrictions.AllowAll, { + gasPrice: "FALSE_VALUE" as unknown as bigint, + }); expect.fail("Should throw Error"); } catch (e) { - expect((e as Error).message).to.match(/.*invalid BigNumber string.*/); + expect(e).to.be.instanceOf(ContractFunctionExecutionError); } // eslint-disable-next-line @typescript-eslint/no-non-null-assertion - await _client.mintClaim(formattedData!, 1000, TransferRestrictions.AllowAll, { gasPrice: "100" }); + hash = await client.mintClaim(formattedData!, 1000n, TransferRestrictions.AllowAll, { gasPrice: 100n }); - expect(_provider.callHistory.length).to.equal(2); - }, 10000); + expect(isHex(hash)).to.be.true; + expect(readSpy.callCount).to.equal(0); + expect(writeSpy.callCount).to.equal(1); + expect(storeBlobMock.callCount).to.equal(2); + }); }); diff --git a/sdk/test/client/split.merge.test.ts b/sdk/test/client/split.merge.test.ts index fec89bf8..57d19762 100644 --- a/sdk/test/client/split.merge.test.ts +++ b/sdk/test/client/split.merge.test.ts @@ -1,252 +1,218 @@ -import { MockProvider, deployMockContract } from "ethereum-waffle"; -import { BigNumber, Wallet } from "ethers"; import sinon from "sinon"; -import HypercertClient from "../../src/client.js"; -import { ClientError } from "../../src/types/errors.js"; +import HypercertClient from "../../src/client"; -import { HypercertMinterAbi } from "@hypercerts-org/contracts"; +import { publicClient, walletClient } from "../helpers"; +import { ContractFunctionExecutionError, isHex, toHex } from "viem"; describe("splitClaimUnits in HypercertClient", () => { - let stub: sinon.SinonStub; - let provider: MockProvider; - let wallet: Wallet; - const fractionId = BigNumber.from("9868188640707215440437863615521278132232"); + const wallet = walletClient; + const userAddress = wallet.account?.address; + + let readSpy = sinon.stub(publicClient, "readContract"); + let writeSpy = sinon.stub(walletClient, "writeContract"); + + const client = new HypercertClient({ + chain: { id: 5 }, + walletClient, + publicClient, + nftStorageToken: "test", + web3StorageToken: "test", + }); - beforeAll(() => { - provider = new MockProvider(); - wallet = provider.getWallets()[0]; + const fractionId = 9868188640707215440437863615521278132232n; - stub = sinon.stub(provider, "on"); - }); - beforeEach(() => { - provider.clearCallHistory(); + beforeEach(async () => { + readSpy.resetBehavior(); + readSpy.resetHistory(); + + writeSpy.resetBehavior(); + writeSpy.resetHistory(); }); afterAll(() => { - stub.restore(); + sinon.restore(); }); it("allows for a hypercert fractions to be splitted over value", async () => { - const userAddress = await wallet.getAddress(); - const mockMinter = await deployMockContract(wallet, HypercertMinterAbi); - await mockMinter.mock.ownerOf.withArgs(fractionId).returns(userAddress); - await mockMinter.mock["unitsOf(uint256)"].withArgs(fractionId).returns(300); - await mockMinter.mock["splitFraction(address,uint256,uint256[])"] - .withArgs(userAddress, fractionId, [100, 200]) - .returns(); - - const signer = wallet.connect(provider); - - const client = new HypercertClient({ - chainId: 5, - operator: signer, - contractAddress: mockMinter.address, - }); - - expect(client.readonly).toBe(false); - - await client.splitClaimUnits(fractionId, [100, 200]); - - //TODO determine underlying calls and mock those out. Some are provider simulation calls - expect(provider.callHistory.length).toBe(7); - }, 10000); - - it("allows for a hypercert fractions to be splitted over value with override params", async () => { - const userAddress = await wallet.getAddress(); - const mockMinter = await deployMockContract(wallet, HypercertMinterAbi); - await mockMinter.mock.ownerOf.withArgs(fractionId).returns(userAddress); - await mockMinter.mock["unitsOf(uint256)"].withArgs(fractionId).returns(300); - await mockMinter.mock["splitFraction(address,uint256,uint256[])"] - .withArgs(userAddress, fractionId, [100, 200]) - .returns(); - - const signer = wallet.connect(provider); - - const client = new HypercertClient({ - chainId: 5, - operator: signer, - contractAddress: mockMinter.address, - }); - expect(client.readonly).toBe(false); - - // eslint-disable-next-line @typescript-eslint/no-non-null-assertion - try { - // eslint-disable-next-line @typescript-eslint/no-non-null-assertion - await client.splitClaimUnits(fractionId, [100, 200], { gasLimit: "FALSE_VALUE" }); - } catch (e) { - expect((e as Error).message).toMatch(/invalid BigNumber string/); - } - - await client.splitClaimUnits(fractionId, [100, 200], { gasLimit: "12300000" }); - - //TODO determine underlying calls and mock those out. Some are provider simulation calls - expect(provider.callHistory.length).toBe(9); - }, 10000); - - it("throws on splitting with incorrect new total value", async () => { - const userAddress = await wallet.getAddress(); - const mockMinter = await deployMockContract(wallet, HypercertMinterAbi); - await mockMinter.mock.ownerOf.withArgs(fractionId).returns(userAddress); - await mockMinter.mock["unitsOf(uint256)"].withArgs(fractionId).returns(42); - - const signer = wallet.connect(provider); - - const client = new HypercertClient({ - chainId: 5, - operator: signer, - contractAddress: mockMinter.address, - }); - expect(client.readonly).toBe(false); - - try { - await client.splitClaimUnits(fractionId, [100, 200]); - } catch (e) { - expect(e instanceof ClientError).toBeTruthy(); - - const error = e as ClientError; - expect(error.message).toBe("Sum of fractions is not equal to the total units"); - } - - //TODO determine underlying calls and mock those out. Some are provider simulation calls - // Owner - // UnitsOf - expect(provider.callHistory.length).toBe(5); - expect.assertions(4); - }); - - it("throws on splitting fractions not owned by signer", async () => { - const otherUser = await provider.getWallets()[1].getAddress(); - const mockMinter = await deployMockContract(wallet, HypercertMinterAbi); - await mockMinter.mock.ownerOf.withArgs(fractionId).returns(otherUser); - - const signer = wallet.connect(provider); + readSpy = readSpy.onFirstCall().resolves(userAddress).onSecondCall().resolves(300n); + writeSpy = writeSpy.resolves(toHex(420)); - const client = new HypercertClient({ - chainId: 5, - operator: signer, - contractAddress: mockMinter.address, - }); expect(client.readonly).toBe(false); - try { - await client.splitClaimUnits(fractionId, [100, 200]); - } catch (e) { - expect(e instanceof ClientError).toBeTruthy(); - - const error = e as ClientError; - expect(error.message).toBe("Claim is not owned by the signer"); - } + const hash = await client.splitFractionUnits(fractionId, [100n, 200n]); //TODO determine underlying calls and mock those out. Some are provider simulation calls - // Owner - expect(provider.callHistory.length).toBe(3); + expect(isHex(hash)).toBeTruthy(); + expect(readSpy.callCount).toBe(2); + expect(writeSpy.callCount).toBe(1); expect.assertions(4); }); -}); - -describe("mergeClaimUnits in HypercertClient", () => { - let stub: sinon.SinonStub; - let provider: MockProvider; - let wallet: Wallet; - const fractionId = BigNumber.from("9868188640707215440437863615521278132232"); - beforeAll(() => { - provider = new MockProvider(); - wallet = provider.getWallets()[0]; - stub = sinon.stub(provider, "on"); - }); - beforeEach(() => { - provider.clearCallHistory(); - }); - - afterAll(() => { - stub.restore(); - }); - - it("allows for hypercert fractions to merge value", async () => { - const userAddress = await wallet.getAddress(); - const mockMinter = await deployMockContract(wallet, HypercertMinterAbi); - await mockMinter.mock.ownerOf.withArgs(fractionId).returns(userAddress); - await mockMinter.mock.ownerOf.withArgs(fractionId.add(1)).returns(userAddress); - await mockMinter.mock["mergeFractions(address,uint256[])"] - .withArgs(userAddress, [fractionId, fractionId.add(1)]) - .returns(); - - const signer = wallet.connect(provider); - - const client = new HypercertClient({ - chainId: 5, - operator: signer, - contractAddress: mockMinter.address, - }); - expect(client.readonly).toBe(false); - - await client.mergeClaimUnits([fractionId, fractionId.add(1)]); + it("allows for a hypercert fractions to be splitted over value with override params", async () => { + readSpy = readSpy + .onFirstCall() + .resolves(userAddress) + .onSecondCall() + .resolves(300n) + .onThirdCall() + .resolves(userAddress) + .onCall(3) + .resolves(300n); + + writeSpy = writeSpy.resolves(toHex(420)); - //TODO determine underlying calls and mock those out. Some are provider simulation calls - expect(provider.callHistory.length).toBe(7); - }, 10000); - - it("allows for hypercert fractions to merge value with override params", async () => { - const userAddress = await wallet.getAddress(); - const mockMinter = await deployMockContract(wallet, HypercertMinterAbi); - await mockMinter.mock.ownerOf.withArgs(fractionId).returns(userAddress); - await mockMinter.mock.ownerOf.withArgs(fractionId.add(1)).returns(userAddress); - await mockMinter.mock["mergeFractions(address,uint256[])"] - .withArgs(userAddress, [fractionId, fractionId.add(1)]) - .returns(); - - const signer = wallet.connect(provider); - - const client = new HypercertClient({ - chainId: 5, - operator: signer, - contractAddress: mockMinter.address, - }); expect(client.readonly).toBe(false); - // eslint-disable-next-line @typescript-eslint/no-non-null-assertion try { - // eslint-disable-next-line @typescript-eslint/no-non-null-assertion - await client.mergeClaimUnits([fractionId, fractionId.add(1)], { gasLimit: "FALSE_VALUE" }); + await client.splitFractionUnits(fractionId, [100n, 200n], { gasLimit: "FALSE_VALUE" as unknown as bigint }); } catch (e) { - expect((e as Error).message).toMatch(/invalid BigNumber string/); + expect(e instanceof ContractFunctionExecutionError).toBeTruthy(); } - await client.mergeClaimUnits([fractionId, fractionId.add(1)], { gasLimit: "12300000" }); + const hash = await client.splitFractionUnits(fractionId, [100n, 200n], { gasLimit: 12300000n }); //TODO determine underlying calls and mock those out. Some are provider simulation calls - expect(provider.callHistory.length).toBe(9); - }, 10000); - - it("throws on splitting fractions not owned by signer", async () => { - const userAddress = await wallet.getAddress(); - const otherUser = await provider.getWallets()[1].getAddress(); - - const mockMinter = await deployMockContract(wallet, HypercertMinterAbi); - await mockMinter.mock.ownerOf.withArgs(fractionId).returns(userAddress); - await mockMinter.mock.ownerOf.withArgs(fractionId.add(1)).returns(otherUser); - - const signer = wallet.connect(provider); - - const client = new HypercertClient({ - chainId: 5, - operator: signer, - contractAddress: mockMinter.address, - }); - expect(client.readonly).toBe(false); - - try { - await client.mergeClaimUnits([fractionId, fractionId.add(1)]); - } catch (e) { - expect(e instanceof ClientError).toBeTruthy(); - - const error = e as ClientError; - expect(error.message).toBe("One or more claims are not owned by the signer"); - } - - //TODO determine underlying calls and mock those out. Some are provider simulation calls - expect(provider.callHistory.length).toBe(5); + expect(isHex(hash)).toBeTruthy(); + expect(readSpy.callCount).toBe(4); + expect(writeSpy.callCount).toBe(1); + expect.assertions(5); }); + + // it("throws on splitting with incorrect new total value", async () => { + // const mockMinter = await deployMockContract(wallet, HypercertMinterAbi); + // await mockMinter.mock.ownerOf.withArgs(fractionId).returns(userAddress); + // await mockMinter.mock["unitsOf(uint256)"].withArgs(fractionId).returns(42); + + // const client = new HypercertClient({ + // chainId: 5, + // operator: walletClient, + // contractAddress: mockMinter.address, + // }); + // expect(client.readonly).toBe(false); + + // try { + // await client.splitClaimUnits(fractionId, [100n, 200n]); + // } catch (e) { + // expect(e instanceof ClientError).toBeTruthy(); + + // const error = e as ClientError; + // expect(error.message).toBe("Sum of fractions is not equal to the total units"); + // } + + // //TODO determine underlying calls and mock those out. Some are provider simulation calls + // // Owner + // // UnitsOf + // expect(provider.callHistory.length).toBe(5); + // expect.assertions(4); + // }); + + // it("throws on splitting fractions not owned by signer", async () => { + // const otherUser = await provider.getWallets()[1].getAddress(); + // const mockMinter = await deployMockContract(wallet, HypercertMinterAbi); + // await mockMinter.mock.ownerOf.withArgs(fractionId).returns(otherUser); + + // const client = new HypercertClient({ + // chainId: 5, + // operator: walletClient, + // contractAddress: mockMinter.address, + // }); + // expect(client.readonly).toBe(false); + + // try { + // await client.splitClaimUnits(fractionId, [100n, 200n]); + // } catch (e) { + // expect(e instanceof ClientError).toBeTruthy(); + + // const error = e as ClientError; + // expect(error.message).toBe("Claim is not owned by the signer"); + // } + + // //TODO determine underlying calls and mock those out. Some are provider simulation calls + // // Owner + // expect(provider.callHistory.length).toBe(3); + // expect.assertions(4); + // }); }); + +// describe("mergeClaimUnits in HypercertClient", () => { +// const provider = testClient; +// const wallet = walletClient; +// const fractionId = 9868188640707215440437863615521278132232n; +// const userAddress = wallet.account.address; + +// it("allows for hypercert fractions to merge value", async () => { +// const mockMinter = await deployMockContract(wallet, HypercertMinterAbi); +// await mockMinter.mock.ownerOf.withArgs(fractionId).returns(userAddress); +// await mockMinter.mock.ownerOf.withArgs(fractionId + 1n).returns(userAddress); +// await mockMinter.mock["mergeFractions(address,uint256[])"] +// .withArgs(userAddress, [fractionId, fractionId + 1n]) +// .returns(); + +// const client = new HypercertClient({ +// chainId: 5, +// operator: walletClient, +// contractAddress: mockMinter.address, +// }); +// expect(client.readonly).toBe(false); + +// await client.mergeClaimUnits([fractionId, fractionId + 1n]); + +// //TODO determine underlying calls and mock those out. Some are provider simulation calls +// expect(provider.callHistory.length).toBe(7); +// }, 10000); + +// it("allows for hypercert fractions to merge value with override params", async () => { +// const mockMinter = await deployMockContract(wallet, HypercertMinterAbi); +// await mockMinter.mock.ownerOf.withArgs(fractionId).returns(userAddress); +// await mockMinter.mock.ownerOf.withArgs(fractionId + 1n).returns(userAddress); +// await mockMinter.mock["mergeFractions(address,uint256[])"] +// .withArgs(userAddress, [fractionId, fractionId + 1n]) +// .returns(); + +// const client = new HypercertClient({ +// chainId: 5, +// operator: walletClient, +// contractAddress: mockMinter.address, +// }); +// expect(client.readonly).toBe(false); + +// try { +// await client.mergeClaimUnits([fractionId, fractionId + 1n], { gasLimit: "FALSE_VALUE" as unknown as bigint }); +// } catch (e) { +// expect((e as Error).message).toMatch(/invalid BigNumber string/); +// } + +// await client.mergeClaimUnits([fractionId, fractionId + 1n], { gasLimit: 12300000n }); + +// //TODO determine underlying calls and mock those out. Some are provider simulation calls +// expect(provider.callHistory.length).toBe(9); +// }, 10000); + +// it("throws on splitting fractions not owned by signer", async () => { +// const otherUser = await provider.getWallets()[1].getAddress(); + +// const mockMinter = await deployMockContract(wallet, HypercertMinterAbi); +// await mockMinter.mock.ownerOf.withArgs(fractionId).returns(userAddress); +// await mockMinter.mock.ownerOf.withArgs(fractionId + 1n).returns(otherUser); + +// const client = new HypercertClient({ +// chainId: 5, +// operator: walletClient, +// contractAddress: mockMinter.address, +// }); +// expect(client.readonly).toBe(false); + +// try { +// await client.mergeClaimUnits([fractionId, fractionId + 1n]); +// } catch (e) { +// expect(e instanceof ClientError).toBeTruthy(); + +// const error = e as ClientError; +// expect(error.message).toBe("One or more claims are not owned by the signer"); +// } + +// //TODO determine underlying calls and mock those out. Some are provider simulation calls +// expect(provider.callHistory.length).toBe(5); +// }); +// }); diff --git a/sdk/test/evaluations/easEvaluator.test.ts b/sdk/test/evaluations/easEvaluator.test.ts deleted file mode 100644 index 048ec024..00000000 --- a/sdk/test/evaluations/easEvaluator.test.ts +++ /dev/null @@ -1,90 +0,0 @@ -import { MockProvider } from "ethereum-waffle"; -import sinon from "sinon"; - -import { EAS_SCHEMAS } from "../../src/constants.js"; -import EasEvaluator from "../../src/evaluations/eas.js"; -import { HypercertClientConfig } from "../../src/index.js"; -import { DuplicateEvaluation, SimpleTextEvaluation } from "../../src/types/evaluation.js"; - -describe("EasEvaluator", () => { - let stub: sinon.SinonStub; - const provider = new MockProvider(); - - beforeAll(() => { - stub = sinon.stub(provider, "on"); - }); - const [wallet] = provider.getWallets(); - const signer = wallet.connect(provider); - - afterAll(() => { - stub.restore(); - }); - - const config = { - chainId: 5, - easContractAddress: "0xC2679fBD37d54388Ce493F1DB75320D236e1815e", - operator: signer, - } as Partial; - const easEvaluator = new EasEvaluator(config); - - describe("getSignature", () => { - it("should return a signature", async () => { - const encodedData = "0x1234567890abcdef"; - const recipient = "0x0987654321098765432109876543210987654321"; - const schema = EAS_SCHEMAS["sepolia"].duplicate; - - const signature = await easEvaluator.getSignature(encodedData, recipient, schema.uid); - - expect(signature).toBeDefined(); - expect(signature.message.schema).toEqual(schema.uid); - expect(Object.keys(signature)).toEqual( - expect.arrayContaining(["domain", "message", "primaryType", "signature", "types", "uid"]), - ); - }); - }); - - describe("signOfflineEvaluation", () => { - it("should sign a duplicate evaluation", async () => { - const evaluation = { - type: "duplicate", - realHypercert: { - chainId: "0x1", - contract: "0x1234567890123456789012345678901234567890", - claimId: "1", - }, - duplicateHypercerts: [ - { - chainId: "0x1", - contract: "0x0987654321098765432109876543210987654321", - claimId: "2", - }, - ], - explanation: "explanation", - } as DuplicateEvaluation; - - const signature = await easEvaluator.signOfflineEvaluation(evaluation); - - expect(signature).toBeDefined(); - expect(signature?.message.schema).toEqual(EAS_SCHEMAS["sepolia"].duplicate.uid); - expect(signature).toContainKeys(["domain", "message", "primaryType", "signature", "types", "uid"]); - }); - - it("should sign a simple text evaluation", async () => { - const evaluation = { - type: "simpleText", - hypercert: { - chainId: "0x1", - contract: "0x0987654321098765432109876543210987654321", - claimId: "2", - }, - text: "text", - } as SimpleTextEvaluation; - - const signature = await easEvaluator.signOfflineEvaluation(evaluation); - - expect(signature).toBeDefined(); - expect(signature?.message.schema).toEqual(EAS_SCHEMAS["sepolia"].contentHash.uid); - expect(signature).toContainKeys(["domain", "message", "primaryType", "signature", "types", "uid"]); - }); - }); -}); diff --git a/sdk/test/evaluations/evaluator.test.ts b/sdk/test/evaluations/evaluator.test.ts index b3ca52c7..542abd21 100644 --- a/sdk/test/evaluations/evaluator.test.ts +++ b/sdk/test/evaluations/evaluator.test.ts @@ -1,30 +1,17 @@ import { expect } from "@jest/globals"; -import { providers } from "ethers"; -import { Wallet, ethers } from "ethers"; -import { CIDString } from "nft.storage"; import sinon from "sinon"; import HypercertEvaluator from "../../src/evaluations/index.js"; -import { InvalidOrMissingError, MalformedDataError, StorageError } from "../../src/types/errors.js"; +import { MalformedDataError, StorageError } from "../../src/types/errors.js"; import { HypercertEvaluationSchema } from "../../src/types/evaluation.js"; -import { getEvaluationData } from "../helpers.js"; +import { getEvaluationData, publicClient, walletClient } from "../helpers.js"; describe("HypercertEvaluator", () => { - let stubSubscription: sinon.SinonStub; - let stubStorage: sinon.SinonStub; - let signer: Wallet; - let evaluator: HypercertEvaluator; - const mockCid = "bafybeibxm2nsadl3fnxv2sxcxmxaco2jl53wpeorjdzidjwf5aqdg7wa6u"; - - beforeAll(() => { - stubSubscription = sinon.stub(providers.JsonRpcProvider.prototype, "on"); - signer = ethers.Wallet.createRandom(); - evaluator = new HypercertEvaluator({ - chainId: 5, - easContractAddress: "0xC2679fBD37d54388Ce493F1DB75320D236e1815e", - operator: signer, - }); - stubStorage = sinon.stub(evaluator.storage, "storeData").resolves(mockCid); + const signer = walletClient.account; + const evaluator = new HypercertEvaluator({ + chain: { id: 5 }, + easContractAddress: "0xC2679fBD37d54388Ce493F1DB75320D236e1815e", + publicClient, }); beforeEach(() => { @@ -32,42 +19,13 @@ describe("HypercertEvaluator", () => { }); afterAll(() => { - // reloadEnv(); - - stubStorage.restore(); - stubSubscription.restore(); + sinon.restore(); }); describe("submitEvaluation", () => { - it("should submit an EAS evaluation", async () => { - const evaluation: HypercertEvaluationSchema = getEvaluationData({ creator: await signer.getAddress() }); - - const result: CIDString = await evaluator.submitEvaluation(evaluation); - - console.log(result); - - expect(result).toEqual("bafybeibxm2nsadl3fnxv2sxcxmxaco2jl53wpeorjdzidjwf5aqdg7wa6u"); - sinon.assert.calledOnce(stubStorage); - }); - - it("should throw an error for missing signer", async () => { - try { - new HypercertEvaluator({ - chainId: 5, - easContractAddress: "0xC2679fBD37d54388Ce493F1DB75320D236e1815e", - }); - } catch (e) { - expect(e).toBeInstanceOf(InvalidOrMissingError); - const error = e as InvalidOrMissingError; - expect(error.message).toEqual("Invalid or missing config value: operator"); - } - - expect.assertions(2); - }); - it("should throw an error for unexpected evaluation source", async () => { const evaluation = { - creator: await signer.getAddress(), + creator: signer?.address, evaluationSource: { type: "invalid", }, @@ -105,25 +63,20 @@ describe("HypercertEvaluator", () => { }); it("should throw an error for readonly storage", async () => { - sinon.stub(process, "env").value({ NFT_STORAGE_TOKEN: null }); - sinon.stub(process, "env").value({ WEB3_STORAGE_TOKEN: null }); - sinon.stub(process, "env").value({ NEXT_PUBLIC_NFT_STORAGE_TOKEN: null }); - sinon.stub(process, "env").value({ NEXT_PUBLIC_WEB3_STORAGE_TOKEN: null }); - - const evaluation: HypercertEvaluationSchema = getEvaluationData({ creator: await signer.getAddress() }); + const evaluation: HypercertEvaluationSchema = getEvaluationData({ creator: signer?.address }); const readonlyEvaluator = new HypercertEvaluator({ - chainId: 5, + chain: { id: 5 }, easContractAddress: "0xC2679fBD37d54388Ce493F1DB75320D236e1815e", - operator: signer, + publicClient, }); try { await readonlyEvaluator.submitEvaluation(evaluation); } catch (e) { - expect(e).toBeInstanceOf(StorageError); - const error = e as StorageError; - expect(error.message).toEqual("Web3.storage client is not configured"); + const error = e as Error; + expect(error).toBeInstanceOf(Error); + expect(error.message).toMatch(/Unexpected evaluation source/); } expect.assertions(2); diff --git a/sdk/test/helpers.ts b/sdk/test/helpers.ts index ccc5b712..a35aedb1 100644 --- a/sdk/test/helpers.ts +++ b/sdk/test/helpers.ts @@ -1,15 +1,74 @@ import { faker } from "@faker-js/faker"; import { StandardMerkleTree } from "@openzeppelin/merkle-tree"; -import { BigNumber, BigNumberish, ContractReceipt, ContractTransaction } from "ethers"; -import { HypercertMetadata } from "../src/index.js"; -import { - AllowlistEntry, - DuplicateEvaluation, - HypercertEvaluationSchema, - SimpleTextEvaluation, -} from "../src/types/index.js"; -import { formatHypercertData } from "../src/utils/formatter.js"; +import { HypercertMetadata } from "../src"; +import { AllowlistEntry, DuplicateEvaluation, HypercertEvaluationSchema, SimpleTextEvaluation } from "../src/types"; +import { formatHypercertData } from "../src/utils/formatter"; +import { Chain, foundry } from "viem/chains"; +import { PublicClient, WalletClient, createPublicClient, createTestClient, createWalletClient, http } from "viem"; +import * as HypercertMinter from "./resources/HypercertMinter.json"; +import mockMetadata from "./res/mockMetadata"; +import mockData from "./res/mockData"; + +const mockCorrectMetadataCid = "testCIDMETAfkreigdm2flneb4khd7eixodagst5nrndptgezrjux7gohxcngjn67x6u"; +const mockCorrectDataCid = "testCIDDATAfkreigdm2flneb4khd7eixodagst5nrndptgezrjux7gohxcngjn67x6u"; +const mockSomeDataCid = "someCIDDATAfkreigdm2flneb4khd7eixodagst5nrndptgezrjux7gohxcngjn67x6u"; + +export const mockDataSets = { + hypercertMetadata: { + cid: mockCorrectMetadataCid, + data: mockMetadata, + }, + hypercertData: { + cid: mockCorrectDataCid, + data: mockMetadata.hypercert, + }, + someData: { + cid: mockSomeDataCid, + data: mockData, + }, +}; + +export const pool = Number(process.env.VITEST_POOL_ID ?? 1); +export const anvil = { + ...foundry, // We are using a mainnet fork for testing. + id: foundry.id, + rpcUrls: { + // These rpc urls are automatically used in the transports. + default: { + // Note how we append the worker id to the local rpc urls. + http: [`http://127.0.0.1:8545/${pool}`], + webSocket: [`ws://127.0.0.1:8545/${pool}`], + }, + public: { + // Note how we append the worker id to the local rpc urls. + http: [`http://127.0.0.1:8545/${pool}`], + webSocket: [`ws://127.0.0.1:8545/${pool}`], + }, + }, +} as const satisfies Chain; + +export const testClient = createTestClient({ + chain: anvil, + mode: "anvil", + transport: http(), +}); + +export const publicClient: PublicClient = createPublicClient({ + chain: anvil, + batch: { + multicall: true, + }, + transport: http(), +}); + +export const walletClient: WalletClient = createWalletClient({ + chain: anvil, + transport: http(), + account: faker.finance.ethereumAddress() as `0x${string}`, +}); + +export const HypercertMinterByteCode = HypercertMinter.bytecode as `0x${string}`; export type TestDataType = Parameters[0]; @@ -19,12 +78,12 @@ export type TestDataType = Parameters[0]; */ const getAllowlist = ({ size = 10, - units = 1, + units = 1n, address, }: { size?: number; address?: `0x${string}`; - units?: BigNumberish; + units?: bigint; } = {}) => { //generate allowlist array based on possible overrides const allowlist: AllowlistEntry[] = []; @@ -43,7 +102,7 @@ const getAllowlist = ({ const merkleTree = StandardMerkleTree.of(mappedAllowlist, ["address", "uint256"]); - const totalUnits = allowlist.reduce((acc, entry) => acc.add(entry.units), BigNumber.from(0)); + const totalUnits = allowlist.reduce((acc, entry) => acc + BigInt(entry.units), 0n); return { allowlist, merkleTree, totalUnits }; }; @@ -78,42 +137,6 @@ const getFormattedMetadata = (overrides?: Partial): HypercertMetad return formattedData as HypercertMetadata; }; -const mockContractResponse = (): Promise => { - // mock transaction receipt - const receipt: ContractReceipt = { - to: "0x0", - from: "0x0", - contractAddress: "0x0", - transactionIndex: 0, - gasUsed: BigNumber.from(0), - logsBloom: "0x0", - blockHash: "0x0", - transactionHash: "0x0", - logs: [], - blockNumber: 0, - confirmations: 0, - cumulativeGasUsed: BigNumber.from(0), - effectiveGasPrice: BigNumber.from(0), - byzantium: true, - type: 0, - status: 1, - }; - - const transaction: ContractTransaction = { - gasLimit: BigNumber.from(0), - data: "0x0", - value: BigNumber.from(0), - chainId: 1337, - hash: "0x0", - confirmations: 1, - from: "0x0", - nonce: 0, - wait: () => Promise.resolve(receipt), - }; - - return Promise.resolve(transaction); -}; - const getEvaluationData = (overrides?: Partial): HypercertEvaluationSchema => { const mockData: HypercertEvaluationSchema = { creator: "0x17ec8597ff92C3F44523bDc65BF0f1bE632917ff", @@ -139,10 +162,8 @@ const getEvaluationData = (overrides?: Partial): Hype explanation: "These hypercerts are duplicates", }, evaluationSource: { - type: "EAS", - chainId: "0x1", - contract: "0xC2679fBD37d54388Ce493F1DB75320D236e1815e", - uid: "0x1234567890abcdef", + type: "IPFS", + cid: "0xC2679fBD37d54388Ce493F1DB75320D236e1815e", }, }; @@ -193,7 +214,6 @@ export { getAllowlist, getFormattedMetadata, getRawInputData, - mockContractResponse, getEvaluationData, getDuplicateEvaluationData, getSimpleTextEvaluationData, diff --git a/sdk/test/indexer.test.ts b/sdk/test/indexer.test.ts index fb80767a..71c12b13 100644 --- a/sdk/test/indexer.test.ts +++ b/sdk/test/indexer.test.ts @@ -1,6 +1,6 @@ import { expect } from "chai"; -import HypercertsIndexer from "../src/indexer.js"; +import HypercertsIndexer from "../src/indexer"; describe("HypercertsIndexer", () => { it("should be able to create a new instance without valid graphName", () => { diff --git a/sdk/test/resources/HypercertMinter.json b/sdk/test/resources/HypercertMinter.json new file mode 100644 index 00000000..39fdd403 --- /dev/null +++ b/sdk/test/resources/HypercertMinter.json @@ -0,0 +1,1139 @@ +{ + "_format": "hh-sol-artifact-1", + "contractName": "HypercertMinter", + "sourceName": "src/protocol/HypercertMinter.sol", + "abi": [ + { + "inputs": [], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "inputs": [], + "name": "AlreadyClaimed", + "type": "error" + }, + { + "inputs": [], + "name": "ArraySize", + "type": "error" + }, + { + "inputs": [], + "name": "DoesNotExist", + "type": "error" + }, + { + "inputs": [], + "name": "DuplicateEntry", + "type": "error" + }, + { + "inputs": [], + "name": "Invalid", + "type": "error" + }, + { + "inputs": [], + "name": "NotAllowed", + "type": "error" + }, + { + "inputs": [], + "name": "NotApprovedOrOwner", + "type": "error" + }, + { + "inputs": [], + "name": "TransfersNotAllowed", + "type": "error" + }, + { + "inputs": [], + "name": "TypeMismatch", + "type": "error" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "previousAdmin", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "newAdmin", + "type": "address" + } + ], + "name": "AdminChanged", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "tokenID", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "bytes32", + "name": "root", + "type": "bytes32" + } + ], + "name": "AllowlistCreated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "account", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "operator", + "type": "address" + }, + { + "indexed": false, + "internalType": "bool", + "name": "approved", + "type": "bool" + } + ], + "name": "ApprovalForAll", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256[]", + "name": "claimIDs", + "type": "uint256[]" + }, + { + "indexed": false, + "internalType": "uint256[]", + "name": "fromTokenIDs", + "type": "uint256[]" + }, + { + "indexed": false, + "internalType": "uint256[]", + "name": "toTokenIDs", + "type": "uint256[]" + }, + { + "indexed": false, + "internalType": "uint256[]", + "name": "values", + "type": "uint256[]" + } + ], + "name": "BatchValueTransfer", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "beacon", + "type": "address" + } + ], + "name": "BeaconUpgraded", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "uint256", + "name": "claimID", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "string", + "name": "uri", + "type": "string" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "totalUnits", + "type": "uint256" + } + ], + "name": "ClaimStored", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint8", + "name": "version", + "type": "uint8" + } + ], + "name": "Initialized", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "tokenID", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "bytes32", + "name": "leaf", + "type": "bytes32" + } + ], + "name": "LeafClaimed", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "previousOwner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "OwnershipTransferred", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "Paused", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "operator", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "from", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256[]", + "name": "ids", + "type": "uint256[]" + }, + { + "indexed": false, + "internalType": "uint256[]", + "name": "values", + "type": "uint256[]" + } + ], + "name": "TransferBatch", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "operator", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "from", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "id", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "value", + "type": "uint256" + } + ], + "name": "TransferSingle", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "string", + "name": "value", + "type": "string" + }, + { + "indexed": true, + "internalType": "uint256", + "name": "id", + "type": "uint256" + } + ], + "name": "URI", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "Unpaused", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "implementation", + "type": "address" + } + ], + "name": "Upgraded", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "claimID", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "fromTokenID", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "toTokenID", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "value", + "type": "uint256" + } + ], + "name": "ValueTransfer", + "type": "event" + }, + { + "inputs": [], + "name": "__SemiFungible1155_init", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + }, + { + "internalType": "uint256", + "name": "id", + "type": "uint256" + } + ], + "name": "balanceOf", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address[]", + "name": "accounts", + "type": "address[]" + }, + { + "internalType": "uint256[]", + "name": "ids", + "type": "uint256[]" + } + ], + "name": "balanceOfBatch", + "outputs": [ + { + "internalType": "uint256[]", + "name": "", + "type": "uint256[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_account", + "type": "address" + }, + { + "internalType": "uint256[]", + "name": "_tokenIDs", + "type": "uint256[]" + } + ], + "name": "batchBurnFraction", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + }, + { + "internalType": "bytes32[][]", + "name": "proofs", + "type": "bytes32[][]" + }, + { + "internalType": "uint256[]", + "name": "claimIDs", + "type": "uint256[]" + }, + { + "internalType": "uint256[]", + "name": "units", + "type": "uint256[]" + } + ], + "name": "batchMintClaimsFromAllowlists", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + }, + { + "internalType": "uint256", + "name": "id", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "name": "burn", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + }, + { + "internalType": "uint256[]", + "name": "ids", + "type": "uint256[]" + }, + { + "internalType": "uint256[]", + "name": "", + "type": "uint256[]" + } + ], + "name": "burnBatch", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_account", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_tokenID", + "type": "uint256" + } + ], + "name": "burnFraction", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + }, + { + "internalType": "uint256", + "name": "units", + "type": "uint256" + }, + { + "internalType": "bytes32", + "name": "merkleRoot", + "type": "bytes32" + }, + { + "internalType": "string", + "name": "_uri", + "type": "string" + }, + { + "internalType": "enum IHypercertToken.TransferRestrictions", + "name": "restrictions", + "type": "uint8" + } + ], + "name": "createAllowlist", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + }, + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "name": "hasBeenClaimed", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "initialize", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32[]", + "name": "proof", + "type": "bytes32[]" + }, + { + "internalType": "uint256", + "name": "claimID", + "type": "uint256" + }, + { + "internalType": "bytes32", + "name": "leaf", + "type": "bytes32" + } + ], + "name": "isAllowedToClaim", + "outputs": [ + { + "internalType": "bool", + "name": "isAllowed", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + }, + { + "internalType": "address", + "name": "operator", + "type": "address" + } + ], + "name": "isApprovedForAll", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_account", + "type": "address" + }, + { + "internalType": "uint256[]", + "name": "_fractionIDs", + "type": "uint256[]" + } + ], + "name": "mergeFractions", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + }, + { + "internalType": "uint256", + "name": "units", + "type": "uint256" + }, + { + "internalType": "string", + "name": "_uri", + "type": "string" + }, + { + "internalType": "enum IHypercertToken.TransferRestrictions", + "name": "restrictions", + "type": "uint8" + } + ], + "name": "mintClaim", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + }, + { + "internalType": "bytes32[]", + "name": "proof", + "type": "bytes32[]" + }, + { + "internalType": "uint256", + "name": "claimID", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "units", + "type": "uint256" + } + ], + "name": "mintClaimFromAllowlist", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + }, + { + "internalType": "uint256", + "name": "units", + "type": "uint256" + }, + { + "internalType": "uint256[]", + "name": "fractions", + "type": "uint256[]" + }, + { + "internalType": "string", + "name": "_uri", + "type": "string" + }, + { + "internalType": "enum IHypercertToken.TransferRestrictions", + "name": "restrictions", + "type": "uint8" + } + ], + "name": "mintClaimWithFractions", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "name", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "owner", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "tokenID", + "type": "uint256" + } + ], + "name": "ownerOf", + "outputs": [ + { + "internalType": "address", + "name": "_owner", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "pause", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "paused", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "proxiableUUID", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "tokenID", + "type": "uint256" + } + ], + "name": "readTransferRestriction", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "renounceOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "from", + "type": "address" + }, + { + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "internalType": "uint256[]", + "name": "ids", + "type": "uint256[]" + }, + { + "internalType": "uint256[]", + "name": "amounts", + "type": "uint256[]" + }, + { + "internalType": "bytes", + "name": "data", + "type": "bytes" + } + ], + "name": "safeBatchTransferFrom", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "from", + "type": "address" + }, + { + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "internalType": "uint256", + "name": "id", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "internalType": "bytes", + "name": "data", + "type": "bytes" + } + ], + "name": "safeTransferFrom", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "operator", + "type": "address" + }, + { + "internalType": "bool", + "name": "approved", + "type": "bool" + } + ], + "name": "setApprovalForAll", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_account", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_tokenID", + "type": "uint256" + }, + { + "internalType": "uint256[]", + "name": "_newFractions", + "type": "uint256[]" + } + ], + "name": "splitFraction", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes4", + "name": "interfaceId", + "type": "bytes4" + } + ], + "name": "supportsInterface", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "transferOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + }, + { + "internalType": "uint256", + "name": "tokenID", + "type": "uint256" + } + ], + "name": "unitsOf", + "outputs": [ + { + "internalType": "uint256", + "name": "units", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "tokenID", + "type": "uint256" + } + ], + "name": "unitsOf", + "outputs": [ + { + "internalType": "uint256", + "name": "units", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "unpause", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newImplementation", + "type": "address" + } + ], + "name": "upgradeTo", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newImplementation", + "type": "address" + }, + { + "internalType": "bytes", + "name": "data", + "type": "bytes" + } + ], + "name": "upgradeToAndCall", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "tokenID", + "type": "uint256" + } + ], + "name": "uri", + "outputs": [ + { + "internalType": "string", + "name": "_uri", + "type": "string" + } + ], + "stateMutability": "view", + "type": "function" + } + ], + "bytecode": "0x60a0604052306080523480156200001557600080fd5b506200002062000026565b620000e7565b600054610100900460ff1615620000935760405162461bcd60e51b815260206004820152602760248201527f496e697469616c697a61626c653a20636f6e747261637420697320696e697469604482015266616c697a696e6760c81b606482015260840160405180910390fd5b60005460ff90811614620000e5576000805460ff191660ff9081179091556040519081527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b565b608051615dcb6200011f60003960008181610b1601528181610bac01528181610f6701528181610ffd01526110f80152615dcb6000f3fe6080604052600436106102695760003560e01c8063715018a611610153578063b316962f116100cb578063f242432a1161007f578063f5298aca11610064578063f5298aca14610732578063f6b1229314610752578063fda4823c1461077257600080fd5b8063f242432a146106f2578063f2fde38b1461071257600080fd5b8063e985e9c5116100b0578063e985e9c514610669578063eb568a14146106b2578063f1169062146106d257600080fd5b8063b316962f14610629578063c7b26c541461064957600080fd5b80638fc202dd1161012257806399f771a71161010757806399f771a7146105ad578063a21ed980146105cd578063a22cb4651461060957600080fd5b80638fc202dd14610578578063993de1841461058d57600080fd5b8063715018a61461051b5780638129fc1c146105305780638456cb59146105455780638da5cb5b1461055a57600080fd5b80633f4ba83a116101e657806352d1902d116101b55780636352211e1161019a5780636352211e1461048c5780636b20c454146104db5780636ebd893f146104fb57600080fd5b806352d1902d1461045e5780635c975abb1461047357600080fd5b80633f4ba83a146103e95780633f71e944146103fe5780634e1273f41461041e5780634f1ef2861461044b57600080fd5b80631a2e98241161023d5780632eb2c2d6116102225780632eb2c2d6146103895780633659cfe6146103a95780633e11eefe146103c957600080fd5b80631a2e9824146103475780631e75a8b51461036757600080fd5b8062fdd58e1461026e57806301ffc9a7146102a157806306fdde03146102d15780630e89341c14610327575b600080fd5b34801561027a57600080fd5b5061028e610289366004614d0a565b610792565b6040519081526020015b60405180910390f35b3480156102ad57600080fd5b506102c16102bc366004614d62565b610840565b6040519015158152602001610298565b3480156102dd57600080fd5b5061031a6040518060400160405280600f81526020017f4879706572636572744d696e746572000000000000000000000000000000000081525081565b6040516102989190614dcf565b34801561033357600080fd5b5061031a610342366004614de2565b610923565b34801561035357600080fd5b5061028e610362366004614d0a565b61092e565b34801561037357600080fd5b50610387610382366004614f26565b610941565b005b34801561039557600080fd5b506103876103a436600461504e565b610a6a565b3480156103b557600080fd5b506103876103c43660046150f8565b610b0c565b3480156103d557600080fd5b506102c16103e4366004615113565b610ca9565b3480156103f557600080fd5b50610387610cd0565b34801561040a57600080fd5b5061031a610419366004614de2565b610ce2565b34801561042a57600080fd5b5061043e610439366004615164565b610e1f565b604051610298919061526a565b61038761045936600461527d565b610f5d565b34801561046a57600080fd5b5061028e6110eb565b34801561047f57600080fd5b506101cd5460ff166102c1565b34801561049857600080fd5b506104c36104a7366004614de2565b600090815261019260205260409020546001600160a01b031690565b6040516001600160a01b039091168152602001610298565b3480156104e757600080fd5b506103876104f63660046152c1565b6111b1565b34801561050757600080fd5b50610387610516366004615335565b6111c8565b34801561052757600080fd5b506103876111e2565b34801561053c57600080fd5b506103876111f4565b34801561055157600080fd5b50610387611355565b34801561056657600080fd5b5060fb546001600160a01b03166104c3565b34801561058457600080fd5b50610387611365565b34801561059957600080fd5b506103876105a836600461538f565b611408565b3480156105b957600080fd5b5061028e6105c8366004614de2565b61142f565b3480156105d957600080fd5b506102c16105e83660046153f4565b6101b060209081526000928352604080842090915290825290205460ff1681565b34801561061557600080fd5b50610387610624366004615416565b611444565b34801561063557600080fd5b50610387610644366004615452565b61144f565b34801561065557600080fd5b506103876106643660046154c4565b6114e4565b34801561067557600080fd5b506102c1610684366004615517565b6001600160a01b03918216600090815260666020908152604080832093909416825291909152205460ff1690565b3480156106be57600080fd5b506103876106cd36600461554a565b611529565b3480156106de57600080fd5b506103876106ed36600461558e565b61153b565b3480156106fe57600080fd5b5061038761070d366004615639565b6115ce565b34801561071e57600080fd5b5061038761072d3660046150f8565b611669565b34801561073e57600080fd5b5061038761074d36600461569e565b6116f6565b34801561075e57600080fd5b5061038761076d366004614d0a565b611708565b34801561077e57600080fd5b5061038761078d3660046156d1565b61171a565b60006001600160a01b0383166108155760405162461bcd60e51b815260206004820152602a60248201527f455243313135353a2061646472657373207a65726f206973206e6f742061207660448201527f616c6964206f776e65720000000000000000000000000000000000000000000060648201526084015b60405180910390fd5b5060008181526065602090815260408083206001600160a01b03861684529091529020545b92915050565b60007fffffffff0000000000000000000000000000000000000000000000000000000082167fd9b67a260000000000000000000000000000000000000000000000000000000014806108d357507fffffffff0000000000000000000000000000000000000000000000000000000082167f0e89341c00000000000000000000000000000000000000000000000000000000145b8061083a57507f01ffc9a7000000000000000000000000000000000000000000000000000000007fffffffff0000000000000000000000000000000000000000000000000000000083161461083a565b606061083a826117cc565b600061093a83836117ea565b9392505050565b610949611822565b336001600160a01b0387161461097257604051631eb49d6d60e11b815260040160405180910390fd5b846109af85858080602002602001604051908101604052809392919081815260200183836020028082843760009201919091525061187692505050565b146109e6576040517f6dac6a0900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60006109f4878686866118f5565b60008181526101ff602052604090208054919250839160ff19166001836002811115610a2257610a22615739565b0217905550807f19789dde2d660b739733377add05f87576a360d2d4adea587c2592264f7f6d4e8488604051610a59929190615768565b60405180910390a250505050505050565b6001600160a01b038516331480610a865750610a868533610684565b610af85760405162461bcd60e51b815260206004820152602e60248201527f455243313135353a2063616c6c6572206973206e6f7420746f6b656e206f776e60448201527f6572206f7220617070726f766564000000000000000000000000000000000000606482015260840161080c565b610b05858585858561196f565b5050505050565b6001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000163003610baa5760405162461bcd60e51b815260206004820152602c60248201527f46756e6374696f6e206d7573742062652063616c6c6564207468726f7567682060448201527f64656c656761746563616c6c0000000000000000000000000000000000000000606482015260840161080c565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316610c057f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc546001600160a01b031690565b6001600160a01b031614610c815760405162461bcd60e51b815260206004820152602c60248201527f46756e6374696f6e206d7573742062652063616c6c6564207468726f7567682060448201527f6163746976652070726f78790000000000000000000000000000000000000000606482015260840161080c565b610c8a81611c24565b60408051600080825260208201909252610ca691839190611c2c565b50565b60008281526101af6020526040812054610cc7908690869085611dcc565b95945050505050565b610cd8611de4565b610ce0611e3e565b565b6fffffffffffffffffffffffffffffffff19811660009081526101ff602052604081205460609160ff90911690816002811115610d2157610d21615739565b03610d6157505060408051808201909152600881527f416c6c6f77416c6c0000000000000000000000000000000000000000000000006020820152919050565b6001816002811115610d7557610d75615739565b03610db557505060408051808201909152600b81527f446973616c6c6f77416c6c0000000000000000000000000000000000000000006020820152919050565b6002816002811115610dc957610dc9615739565b03610e0957505060408051808201909152600f81527f46726f6d43726561746f724f6e6c7900000000000000000000000000000000006020820152919050565b5050604080516020810190915260008152919050565b60608151835114610e985760405162461bcd60e51b815260206004820152602960248201527f455243313135353a206163636f756e747320616e6420696473206c656e67746860448201527f206d69736d617463680000000000000000000000000000000000000000000000606482015260840161080c565b6000835167ffffffffffffffff811115610eb457610eb4614e47565b604051908082528060200260200182016040528015610edd578160200160208202803683370190505b50905060005b8451811015610f5557610f28858281518110610f0157610f0161578a565b6020026020010151858381518110610f1b57610f1b61578a565b6020026020010151610792565b828281518110610f3a57610f3a61578a565b6020908102919091010152610f4e816157e8565b9050610ee3565b509392505050565b6001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000163003610ffb5760405162461bcd60e51b815260206004820152602c60248201527f46756e6374696f6e206d7573742062652063616c6c6564207468726f7567682060448201527f64656c656761746563616c6c0000000000000000000000000000000000000000606482015260840161080c565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03166110567f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc546001600160a01b031690565b6001600160a01b0316146110d25760405162461bcd60e51b815260206004820152602c60248201527f46756e6374696f6e206d7573742062652063616c6c6564207468726f7567682060448201527f6163746976652070726f78790000000000000000000000000000000000000000606482015260840161080c565b6110db82611c24565b6110e782826001611c2c565b5050565b6000306001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000161461118b5760405162461bcd60e51b815260206004820152603860248201527f555550535570677261646561626c653a206d757374206e6f742062652063616c60448201527f6c6564207468726f7567682064656c656761746563616c6c0000000000000000606482015260840161080c565b507f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc5b90565b6111b9611822565b6111c38383611e91565b505050565b6111d0611822565b6111dc8484848461211f565b50505050565b6111ea611de4565b610ce06000612667565b600054610100900460ff16158080156112145750600054600160ff909116105b8061122e5750303b15801561122e575060005460ff166001145b6112a05760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201527f647920696e697469616c697a6564000000000000000000000000000000000000606482015260840161080c565b6000805460ff1916600117905580156112e057600080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ff166101001790555b6112e8611365565b6112f06126d1565b8015610ca657600080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ff169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a150565b61135d611de4565b610ce0612744565b600054610100900460ff166113d05760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201526a6e697469616c697a696e6760a81b606482015260840161080c565b6113e860405180602001604052806000815250612782565b6113f06127f6565b6113f8612861565b6114006128d4565b610ce06127f6565b611410611822565b61141c84848484612947565b611427858383612ad0565b505050505050565b6000818152610194602052604081205461083a565b6110e7338383612ba8565b611457611822565b6000611464868685612c9c565b9050611471818587612d6d565b60008181526101ff60205260409020805483919060ff1916600183600281111561149d5761149d615739565b0217905550807f19789dde2d660b739733377add05f87576a360d2d4adea587c2592264f7f6d4e84876040516114d4929190615768565b60405180910390a2505050505050565b6114ec611822565b6111c383838380806020026020016040519081016040528093929190818152602001838360200280828437600092019190915250612e5392505050565b611531611822565b6110e78282611e91565b611543611822565b8260005b818110156115b5576115ad8888838181106115645761156461578a565b90506020028101906115769190615802565b8888858181106115885761158861578a565b905060200201358787868181106115a1576115a161578a565b90506020020135612947565b600101611547565b506115c38886868686613167565b505050505050505050565b6001600160a01b0385163314806115ea57506115ea8533610684565b61165c5760405162461bcd60e51b815260206004820152602e60248201527f455243313135353a2063616c6c6572206973206e6f7420746f6b656e206f776e60448201527f6572206f7220617070726f766564000000000000000000000000000000000000606482015260840161080c565b610b0585858585856133a2565b611671611de4565b6001600160a01b0381166116ed5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f6464726573730000000000000000000000000000000000000000000000000000606482015260840161080c565b610ca681612667565b6116fe611822565b6111c3838361358d565b611710611822565b6110e7828261358d565b611722611822565b336001600160a01b0385161461174b57604051631eb49d6d60e11b815260040160405180910390fd5b600061175885858561365c565b60008181526101ff602052604090208054919250839160ff1916600183600281111561178657611786615739565b0217905550807f19789dde2d660b739733377add05f87576a360d2d4adea587c2592264f7f6d4e84866040516117bd929190615768565b60405180910390a25050505050565b606061083a6fffffffffffffffffffffffffffffffff198316613741565b600081815261019260205260408120546001600160a01b0384811691160361083a575060009081526101946020526040902054919050565b6101cd5460ff1615610ce05760405162461bcd60e51b815260206004820152601060248201527f5061757361626c653a2070617573656400000000000000000000000000000000604482015260640161080c565b8051600090815b818110156118ee578381815181106118975761189761578a565b60200260200101516000036118bf57604051631eb49d6d60e11b815260040160405180910390fd5b8381815181106118d1576118d161578a565b6020026020010151836118e4919061586a565b925060010161187d565b5050919050565b600061193d8561193786868080602002602001604051908101604052809392919081815260200183836020028082843760009201919091525061187692505050565b8461365c565b60008181526101956020526040902054909150611967908690611960908461586a565b868661211f565b949350505050565b81518351146119e65760405162461bcd60e51b815260206004820152602860248201527f455243313135353a2069647320616e6420616d6f756e7473206c656e6774682060448201527f6d69736d61746368000000000000000000000000000000000000000000000000606482015260840161080c565b6001600160a01b038416611a625760405162461bcd60e51b815260206004820152602560248201527f455243313135353a207472616e7366657220746f20746865207a65726f20616460448201527f6472657373000000000000000000000000000000000000000000000000000000606482015260840161080c565b33611a71818787878787613820565b60005b8451811015611bb0576000858281518110611a9157611a9161578a565b602002602001015190506000858381518110611aaf57611aaf61578a565b60209081029190910181015160008481526065835260408082206001600160a01b038e168352909352919091205490915081811015611b565760405162461bcd60e51b815260206004820152602a60248201527f455243313135353a20696e73756666696369656e742062616c616e636520666f60448201527f72207472616e7366657200000000000000000000000000000000000000000000606482015260840161080c565b60008381526065602090815260408083206001600160a01b038e8116855292528083208585039055908b16825281208054849290611b9590849061586a565b9250508190555050505080611ba9906157e8565b9050611a74565b50846001600160a01b0316866001600160a01b0316826001600160a01b03167f4a39dc06d4c0dbc64b70af90fd698a233a518aa5d07e595d983b8c0526c8f7fb8787604051611c0092919061587d565b60405180910390a4611c16818787878787613968565b6114278187878787876139d2565b610ca6611de4565b7f4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd91435460ff1615611c5f576111c383613bdf565b826001600160a01b03166352d1902d6040518163ffffffff1660e01b8152600401602060405180830381865afa925050508015611cb9575060408051601f3d908101601f19168201909252611cb6918101906158a2565b60015b611d2b5760405162461bcd60e51b815260206004820152602e60248201527f45524331393637557067726164653a206e657720696d706c656d656e7461746960448201527f6f6e206973206e6f742055555053000000000000000000000000000000000000606482015260840161080c565b7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc8114611dc05760405162461bcd60e51b815260206004820152602960248201527f45524331393637557067726164653a20756e737570706f727465642070726f7860448201527f6961626c65555549440000000000000000000000000000000000000000000000606482015260840161080c565b506111c3838383613cb5565b600082611dda868685613cda565b1495945050505050565b60fb546001600160a01b03163314610ce05760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015260640161080c565b611e46613d26565b6101cd805460ff191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa335b6040516001600160a01b03909116815260200160405180910390a1565b6001600160a01b0382163314801590611eb15750611eaf8233610684565b155b15611ee8576040517fe433766c00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b805160008167ffffffffffffffff811115611f0557611f05614e47565b604051908082528060200260200182016040528015611f2e578160200160208202803683370190505b50905060008267ffffffffffffffff811115611f4c57611f4c614e47565b604051908082528060200260200182016040528015611f75578160200160208202803683370190505b50905060008367ffffffffffffffff811115611f9357611f93614e47565b604051908082528060200260200182016040528015611fbc578160200160208202803683370190505b50905060008467ffffffffffffffff811115611fda57611fda614e47565b604051908082528060200260200182016040528015612003578160200160208202803683370190505b50905060005b858110156120cd5760008782815181106120255761202561578a565b602090810291909101810151600081815261019490925260408220805492905591506fffffffffffffffffffffffffffffffff19821687848151811061206d5761206d61578a565b6020026020010181815250508085848151811061208c5761208c61578a565b60200260200101818152505060018484815181106120ac576120ac61578a565b602002602001018181525050505080806120c5906157e8565b915050612009565b506120d9878783613d79565b7f088515a3c7b4e71520602d818f4dec002fadefde30c55e13f390c8d96046990a8487858560405161210e94939291906158bb565b60405180910390a150505050505050565b60fd81118061212e5750600281105b15612165576040517f3ada02e500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6121a182828080602002602001604051908101604052809392919081815260200183836020028082843760009201919091525061187692505050565b60008481526101946020526040902054146121cf57604051631eb49d6d60e11b815260040160405180910390fd5b600083815261019460205260408120546fffffffffffffffffffffffffffffffff198516916121ff600185615913565b905060008167ffffffffffffffff81111561221c5761221c614e47565b604051908082528060200260200182016040528015612245578160200160208202803683370190505b50905060008267ffffffffffffffff81111561226357612263614e47565b60405190808252806020026020018201604052801561228c578160200160208202803683370190505b50905060008367ffffffffffffffff8111156122aa576122aa614e47565b6040519080825280602002602001820160405280156122d3578160200160208202803683370190505b50905060008467ffffffffffffffff8111156122f1576122f1614e47565b60405190808252806020026020018201604052801561231a578160200160208202803683370190505b50905060008567ffffffffffffffff81111561233857612338614e47565b604051908082528060200260200182016040528015612361578160200160208202803683370190505b50905060008a8a8080602002602001604051908101604052809392919081815260200183836020028082843760009201829052508451949550938593508b9250821090506123b1576123b161578a565b60200260200101519050816000815181106123ce576123ce61578a565b60200260200101518289815181106123e8576123e861578a565b60200260200101818152505080826000815181106124085761240861578a565b60200260200101818152505060005b888110156125235760008b8152610195602052604090205461243890614023565b8a88828151811061244b5761244b61578a565b6020026020010181815250508d87828151811061246a5761246a61578a565b60200260200101818152505061019560008c815260200190815260200160002060008154612497906157e8565b91829055506124a6908c61586a565b8682815181106124b8576124b861578a565b60200260200101818152505060018582815181106124d8576124d861578a565b6020026020010181815250508281815181106124f6576124f661578a565b60200260200101518482815181106125105761251061578a565b6020908102919091010152600101612417565b5050506125656125303390565b60008d8152610192602090815260408083205481519283019091529181526001600160a01b039091169087908790869061402d565b60005b868110156125ed578181815181106125825761258261578a565b6020026020010151886125959190615913565b97508181815181106125a9576125a961578a565b602002602001015161019460008684815181106125c8576125c861578a565b6020026020010151815260200190815260200160002081905550806001019050612568565b5060008b8152610194602090815260408083208a90558051918201905290815261261c908d908590859061415d565b7f088515a3c7b4e71520602d818f4dec002fadefde30c55e13f390c8d96046990a8585858460405161265194939291906158bb565b60405180910390a1505050505050505050505050565b60fb80546001600160a01b038381167fffffffffffffffffffffffff0000000000000000000000000000000000000000831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b600054610100900460ff1661273c5760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201526a6e697469616c697a696e6760a81b606482015260840161080c565b610ce0614373565b61274c611822565b6101cd805460ff191660011790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a258611e743390565b600054610100900460ff166127ed5760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201526a6e697469616c697a696e6760a81b606482015260840161080c565b610ca6816143eb565b600054610100900460ff16610ce05760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201526a6e697469616c697a696e6760a81b606482015260840161080c565b600054610100900460ff166128cc5760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201526a6e697469616c697a696e6760a81b606482015260840161080c565b610ce061445f565b600054610100900460ff1661293f5760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201526a6e697469616c697a696e6760a81b606482015260840161080c565b610ce06144e6565b60008281526101af60209081526040805133818401528082018590528151808203830181526060820183528051908401206080808301919091528251808303909101815260a090910182528051908301208584526101b083528184208185529092529091205460ff16156129e7576040517f646cf55800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60008381526101af6020526040902054612a05908690869084611dcc565b1580612a36575060008381526101b160209081526040808320546101b290925290912054612a3490849061586a565b115b15612a6d576040517f6dac6a0900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60008381526101b060209081526040808320848452825291829020805460ff1916600117905581518581529081018390527f51483c8cc684284e9ba3215822230838b766f1698bcc7e922a31e02c3c203bd7910160405180910390a15050505050565b6000612adb8361455a565b612af857604051631eb49d6d60e11b815260040160405180910390fd5b60008381526101956020526040902054612b1190614023565b5060008281526101956020908152604080832080546001808201909255860181018085526101948452828520869055825193840190925292825291612b599186918491614590565b6040805184815260006020820152908101829052606081018390527f5e65fcde72b913ac2870f9df6ea5b6bca757862f44636cb368ed5e339fc524fb9060800160405180910390a19392505050565b816001600160a01b0316836001600160a01b031603612c2f5760405162461bcd60e51b815260206004820152602960248201527f455243313135353a2073657474696e6720617070726f76616c2073746174757360448201527f20666f722073656c660000000000000000000000000000000000000000000000606482015260840161080c565b6001600160a01b03838116600081815260666020908152604080832094871680845294825291829020805460ff191686151590811790915591519182527f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a3505050565b6000612caa610191546146d7565b608061019160008154612cbc906157e8565b9182905550901b60008181526101936020908152604080832080547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b038a1617905561019490915290208490559050612d1d81836146e5565b604080518281526000602082018190529182916001600160a01b038816917fc3d58168c5ae7397731d063d5bbf3d657854427343f4c083240f7aacaa2d0f62910160405180910390a49392505050565b811580612d78575080155b15612daf576040517f6dac6a0900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60008381526101af602052604090205415612df6576040517f357d0cc400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60008381526101af602090815260408083208590556101b182529182902083905581518581529081018490527f233c854c30aaaad173f2dd900c76d53c64e556d1d009d71466ec1afcb7b5844d91015b60405180910390a1505050565b60fd81511180612e64575060028151105b15612e9b576040517f3ada02e500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600060018251612eab9190615913565b90506000828281518110612ec157612ec161578a565b602002602001015190506000808367ffffffffffffffff811115612ee757612ee7614e47565b604051908082528060200260200182016040528015612f10578160200160208202803683370190505b50905060008467ffffffffffffffff811115612f2e57612f2e614e47565b604051908082528060200260200182016040528015612f57578160200160208202803683370190505b50905060008567ffffffffffffffff811115612f7557612f75614e47565b604051908082528060200260200182016040528015612f9e578160200160208202803683370190505b50905060008667ffffffffffffffff811115612fbc57612fbc614e47565b604051908082528060200260200182016040528015612fe5578160200160208202803683370190505b50905060005b878110156130aa5760008982815181106130075761300761578a565b60200260200101519050808683815181106130245761302461578a565b602002602001018181525050878583815181106130435761304361578a565b60200260200101818152505060018383815181106130635761306361578a565b6020026020010181815250506101946000828152602001908152602001600020548483815181106130965761309661578a565b602090810291909101015250600101612feb565b506130c8338a8686866040518060200160405280600081525061402d565b60005b87811015613136578281815181106130e5576130e561578a565b6020026020010151866130f8919061586a565b955061019460008683815181106131115761311161578a565b60200260200101518152602001908152602001600020600090558060010190506130cb565b50600086815261019460205260408120805487929061315690849061586a565b909155506115c39050898583613d79565b6060838067ffffffffffffffff81111561318357613183614e47565b6040519080825280602002602001820160405280156131ac578160200160208202803683370190505b50915060008167ffffffffffffffff8111156131ca576131ca614e47565b6040519080825280602002602001820160405280156131f3578160200160208202803683370190505b50905060008267ffffffffffffffff81111561321157613211614e47565b60405190808252806020026020018201604052801561323a578160200160208202803683370190505b50905060005b8381101561333957600089898381811061325c5761325c61578a565b90506020020135905061326e8161455a565b61328b57604051631eb49d6d60e11b815260040160405180910390fd5b600081815261019560205260409020546132a490614023565b600081815261019560205260409020805460018082019092558201018888848181106132d2576132d261578a565b90506020020135610194600083815260200190815260200160002081905550808784815181106133045761330461578a565b60200260200101818152505060018584815181106133245761332461578a565b60209081029190910101525050600101613240565b506133558985846040518060200160405280600081525061415d565b7f088515a3c7b4e71520602d818f4dec002fadefde30c55e13f390c8d96046990a888883878a8a60405161338e96959493929190615971565b60405180910390a150505095945050505050565b6001600160a01b03841661341e5760405162461bcd60e51b815260206004820152602560248201527f455243313135353a207472616e7366657220746f20746865207a65726f20616460448201527f6472657373000000000000000000000000000000000000000000000000000000606482015260840161080c565b33600061342a85614742565b9050600061343785614742565b9050613447838989858589613820565b60008681526065602090815260408083206001600160a01b038c168452909152902054858110156134e05760405162461bcd60e51b815260206004820152602a60248201527f455243313135353a20696e73756666696369656e742062616c616e636520666f60448201527f72207472616e7366657200000000000000000000000000000000000000000000606482015260840161080c565b60008781526065602090815260408083206001600160a01b038d8116855292528083208985039055908a1682528120805488929061351f90849061586a565b909155505060408051888152602081018890526001600160a01b03808b16928c821692918816917fc3d58168c5ae7397731d063d5bbf3d657854427343f4c083240f7aacaa2d0f62910160405180910390a461357f848a8a86868a613968565b6115c3848a8a8a8a8a61478d565b6001600160a01b03821633148015906135ad57506135ab8233610684565b155b156135e4576040517fe433766c00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000818152610194602052604081208054919055613604838360016148e8565b7f5e65fcde72b913ac2870f9df6ea5b6bca757862f44636cb368ed5e339fc524fb6fffffffffffffffffffffffffffffffff198316604080519182526020820185905260009082015260608101839052608001612e46565b60008260000361367f57604051631eb49d6d60e11b815260040160405180910390fd5b61368a848484612c9c565b6000818152610195602052604081208054929350909182906136ab906157e8565b91829055506136ba908361586a565b9050836101946000838152602001908152602001600020819055506136f18582600160405180602001604052806000815250614590565b6040805183815260006020820152908101829052606081018590527f5e65fcde72b913ac2870f9df6ea5b6bca757862f44636cb368ed5e339fc524fb9060800160405180910390a1509392505050565b600081815260ca602052604081208054606092919061375f906159cd565b80601f016020809104026020016040519081016040528092919081815260200182805461378b906159cd565b80156137d85780601f106137ad576101008083540402835291602001916137d8565b820191906000526020600020905b8154815290600101906020018083116137bb57829003601f168201915b5050505050905060008151116137f6576137f183614ab9565b61093a565b60c98160405160200161380a929190615a20565b6040516020818303038152906040529392505050565b6001600160a01b03851615611427576001600160a01b0384161561142757825160005b8181101561395e5760006138808683815181106138625761386261578a565b60200260200101516fffffffffffffffffffffffffffffffff191690565b60008181526101ff602052604090205490915060ff1660018160028111156138aa576138aa615739565b036138e1576040517fab064ad300000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60028160028111156138f5576138f5615739565b14801561391d5750600082815261019360205260409020546001600160a01b038a8116911614155b15613954576040517fab064ad300000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5050600101613843565b5050505050505050565b825160005b8181101561395e5785610192600087848151811061398d5761398d61578a565b6020026020010151815260200190815260200160002060006101000a8154816001600160a01b0302191690836001600160a01b0316021790555080600101905061396d565b6001600160a01b0384163b15611427576040517fbc197c810000000000000000000000000000000000000000000000000000000081526001600160a01b0385169063bc197c8190613a2f9089908990889088908890600401615aa7565b6020604051808303816000875af1925050508015613a6a575060408051601f3d908101601f19168201909252613a6791810190615b05565b60015b613b1f57613a76615b22565b806308c379a003613aaf5750613a8a615b3d565b80613a955750613ab1565b8060405162461bcd60e51b815260040161080c9190614dcf565b505b60405162461bcd60e51b815260206004820152603460248201527f455243313135353a207472616e7366657220746f206e6f6e2d4552433131353560448201527f526563656976657220696d706c656d656e746572000000000000000000000000606482015260840161080c565b7fffffffff0000000000000000000000000000000000000000000000000000000081167fbc197c810000000000000000000000000000000000000000000000000000000014613bd65760405162461bcd60e51b815260206004820152602860248201527f455243313135353a204552433131353552656365697665722072656a6563746560448201527f6420746f6b656e73000000000000000000000000000000000000000000000000606482015260840161080c565b50505050505050565b6001600160a01b0381163b613c5c5760405162461bcd60e51b815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201527f6f74206120636f6e747261637400000000000000000000000000000000000000606482015260840161080c565b7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc80547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b0392909216919091179055565b613cbe83614b4d565b600082511180613ccb5750805b156111c3576111dc8383614b8d565b600081815b84811015613d1d57613d0982878784818110613cfd57613cfd61578a565b90506020020135614c8f565b915080613d15816157e8565b915050613cdf565b50949350505050565b6101cd5460ff16610ce05760405162461bcd60e51b815260206004820152601460248201527f5061757361626c653a206e6f7420706175736564000000000000000000000000604482015260640161080c565b6001600160a01b038316613df55760405162461bcd60e51b815260206004820152602360248201527f455243313135353a206275726e2066726f6d20746865207a65726f206164647260448201527f6573730000000000000000000000000000000000000000000000000000000000606482015260840161080c565b8051825114613e6c5760405162461bcd60e51b815260206004820152602860248201527f455243313135353a2069647320616e6420616d6f756e7473206c656e6774682060448201527f6d69736d61746368000000000000000000000000000000000000000000000000606482015260840161080c565b6000339050613e8f81856000868660405180602001604052806000815250613820565b60005b8351811015613fac576000848281518110613eaf57613eaf61578a565b602002602001015190506000848381518110613ecd57613ecd61578a565b60209081029190910181015160008481526065835260408082206001600160a01b038c168352909352919091205490915081811015613f735760405162461bcd60e51b8152602060048201526024808201527f455243313135353a206275726e20616d6f756e7420657863656564732062616c60448201527f616e636500000000000000000000000000000000000000000000000000000000606482015260840161080c565b60009283526065602090815260408085206001600160a01b038b1686529091529092209103905580613fa4816157e8565b915050613e92565b5060006001600160a01b0316846001600160a01b0316826001600160a01b03167f4a39dc06d4c0dbc64b70af90fd698a233a518aa5d07e595d983b8c0526c8f7fb8686604051613ffd92919061587d565b60405180910390a46111dc81856000868660405180602001604052806000815250613968565b806111c381615be5565b835160005b8181101561395e57600086828151811061404e5761404e61578a565b60200260200101519050600086838151811061406c5761406c61578a565b6020026020010151905061407f8261455a565b1561409d57604051631eb49d6d60e11b815260040160405180910390fd5b6fffffffffffffffffffffffffffffffff1981166fffffffffffffffffffffffffffffffff198316146140fc576040517fb4902a1300000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6001600160a01b038916331480159061411c575061411a8933610684565b155b15614153576040517fe433766c00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5050600101614032565b6001600160a01b0384166141d95760405162461bcd60e51b815260206004820152602160248201527f455243313135353a206d696e7420746f20746865207a65726f2061646472657360448201527f7300000000000000000000000000000000000000000000000000000000000000606482015260840161080c565b81518351146142505760405162461bcd60e51b815260206004820152602860248201527f455243313135353a2069647320616e6420616d6f756e7473206c656e6774682060448201527f6d69736d61746368000000000000000000000000000000000000000000000000606482015260840161080c565b3361426081600087878787613820565b60005b84518110156142fc5783818151811061427e5761427e61578a565b60200260200101516065600087848151811061429c5761429c61578a565b602002602001015181526020019081526020016000206000886001600160a01b03166001600160a01b0316815260200190815260200160002060008282546142e4919061586a565b909155508190506142f4816157e8565b915050614263565b50846001600160a01b031660006001600160a01b0316826001600160a01b03167f4a39dc06d4c0dbc64b70af90fd698a233a518aa5d07e595d983b8c0526c8f7fb878760405161434d92919061587d565b60405180910390a461436481600087878787613968565b610b05816000878787876139d2565b600054610100900460ff166143de5760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201526a6e697469616c697a696e6760a81b606482015260840161080c565b6101cd805460ff19169055565b600054610100900460ff166144565760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201526a6e697469616c697a696e6760a81b606482015260840161080c565b610ca681614cbe565b600054610100900460ff166144ca5760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201526a6e697469616c697a696e6760a81b606482015260840161080c565b60408051602081019091526000815260c990610ca69082615c5a565b600054610100900460ff166145515760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201526a6e697469616c697a696e6760a81b606482015260840161080c565b610ce033612667565b60006fffffffffffffffffffffffffffffffff1982168214801561083a5750506fffffffffffffffffffffffffffffffff161590565b6001600160a01b03841661460c5760405162461bcd60e51b815260206004820152602160248201527f455243313135353a206d696e7420746f20746865207a65726f2061646472657360448201527f7300000000000000000000000000000000000000000000000000000000000000606482015260840161080c565b33600061461885614742565b9050600061462585614742565b905061463683600089858589613820565b60008681526065602090815260408083206001600160a01b038b1684529091528120805487929061466890849061586a565b909155505060408051878152602081018790526001600160a01b03808a1692600092918716917fc3d58168c5ae7397731d063d5bbf3d657854427343f4c083240f7aacaa2d0f62910160405180910390a46146c883600089858589613968565b613bd68360008989898961478d565b608081901c6111c381615be5565b600082815260ca602052604090206146fd8282615c5a565b50817f6bb7ff708619ba0610cba295a58592e0451dee2622938c8755667688daf3529b61472984610923565b6040516147369190614dcf565b60405180910390a25050565b6040805160018082528183019092526060916000919060208083019080368337019050509050828160008151811061477c5761477c61578a565b602090810291909101015292915050565b6001600160a01b0384163b15611427576040517ff23a6e610000000000000000000000000000000000000000000000000000000081526001600160a01b0385169063f23a6e61906147ea9089908990889088908890600401615d1a565b6020604051808303816000875af1925050508015614825575060408051601f3d908101601f1916820190925261482291810190615b05565b60015b61483157613a76615b22565b7fffffffff0000000000000000000000000000000000000000000000000000000081167ff23a6e610000000000000000000000000000000000000000000000000000000014613bd65760405162461bcd60e51b815260206004820152602860248201527f455243313135353a204552433131353552656365697665722072656a6563746560448201527f6420746f6b656e73000000000000000000000000000000000000000000000000606482015260840161080c565b6001600160a01b0383166149645760405162461bcd60e51b815260206004820152602360248201527f455243313135353a206275726e2066726f6d20746865207a65726f206164647260448201527f6573730000000000000000000000000000000000000000000000000000000000606482015260840161080c565b33600061497084614742565b9050600061497d84614742565b905061499d83876000858560405180602001604052806000815250613820565b60008581526065602090815260408083206001600160a01b038a16845290915290205484811015614a355760405162461bcd60e51b8152602060048201526024808201527f455243313135353a206275726e20616d6f756e7420657863656564732062616c60448201527f616e636500000000000000000000000000000000000000000000000000000000606482015260840161080c565b60008681526065602090815260408083206001600160a01b038b81168086529184528285208a8703905582518b81529384018a90529092908816917fc3d58168c5ae7397731d063d5bbf3d657854427343f4c083240f7aacaa2d0f62910160405180910390a4613bd684886000868660405180602001604052806000815250613968565b606060678054614ac8906159cd565b80601f0160208091040260200160405190810160405280929190818152602001828054614af4906159cd565b8015614b415780601f10614b1657610100808354040283529160200191614b41565b820191906000526020600020905b815481529060010190602001808311614b2457829003601f168201915b50505050509050919050565b614b5681613bdf565b6040516001600160a01b038216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b60606001600160a01b0383163b614c0c5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f60448201527f6e74726163740000000000000000000000000000000000000000000000000000606482015260840161080c565b600080846001600160a01b031684604051614c279190615d52565b600060405180830381855af49150503d8060008114614c62576040519150601f19603f3d011682016040523d82523d6000602084013e614c67565b606091505b5091509150610cc78282604051806060016040528060278152602001615d6f60279139614cca565b6000818310614cab57600082815260208490526040902061093a565b600083815260208390526040902061093a565b60676110e78282615c5a565b60608315614cd957508161093a565b61093a8383815115613a955781518083602001fd5b80356001600160a01b0381168114614d0557600080fd5b919050565b60008060408385031215614d1d57600080fd5b614d2683614cee565b946020939093013593505050565b7fffffffff0000000000000000000000000000000000000000000000000000000081168114610ca657600080fd5b600060208284031215614d7457600080fd5b813561093a81614d34565b60005b83811015614d9a578181015183820152602001614d82565b50506000910152565b60008151808452614dbb816020860160208601614d7f565b601f01601f19169290920160200192915050565b60208152600061093a6020830184614da3565b600060208284031215614df457600080fd5b5035919050565b60008083601f840112614e0d57600080fd5b50813567ffffffffffffffff811115614e2557600080fd5b6020830191508360208260051b8501011115614e4057600080fd5b9250929050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b601f19601f830116810181811067ffffffffffffffff82111715614e9c57614e9c614e47565b6040525050565b600082601f830112614eb457600080fd5b813567ffffffffffffffff811115614ece57614ece614e47565b604051614ee56020601f19601f8501160182614e76565b818152846020838601011115614efa57600080fd5b816020850160208301376000918101602001919091529392505050565b803560038110614d0557600080fd5b60008060008060008060a08789031215614f3f57600080fd5b614f4887614cee565b955060208701359450604087013567ffffffffffffffff80821115614f6c57600080fd5b614f788a838b01614dfb565b90965094506060890135915080821115614f9157600080fd5b50614f9e89828a01614ea3565b925050614fad60808801614f17565b90509295509295509295565b600067ffffffffffffffff821115614fd357614fd3614e47565b5060051b60200190565b600082601f830112614fee57600080fd5b81356020614ffb82614fb9565b6040516150088282614e76565b83815260059390931b850182019282810191508684111561502857600080fd5b8286015b84811015615043578035835291830191830161502c565b509695505050505050565b600080600080600060a0868803121561506657600080fd5b61506f86614cee565b945061507d60208701614cee565b9350604086013567ffffffffffffffff8082111561509a57600080fd5b6150a689838a01614fdd565b945060608801359150808211156150bc57600080fd5b6150c889838a01614fdd565b935060808801359150808211156150de57600080fd5b506150eb88828901614ea3565b9150509295509295909350565b60006020828403121561510a57600080fd5b61093a82614cee565b6000806000806060858703121561512957600080fd5b843567ffffffffffffffff81111561514057600080fd5b61514c87828801614dfb565b90989097506020870135966040013595509350505050565b6000806040838503121561517757600080fd5b823567ffffffffffffffff8082111561518f57600080fd5b818501915085601f8301126151a357600080fd5b813560206151b082614fb9565b6040516151bd8282614e76565b83815260059390931b85018201928281019150898411156151dd57600080fd5b948201945b83861015615202576151f386614cee565b825294820194908201906151e2565b9650508601359250508082111561521857600080fd5b5061522585828601614fdd565b9150509250929050565b600081518084526020808501945080840160005b8381101561525f57815187529582019590820190600101615243565b509495945050505050565b60208152600061093a602083018461522f565b6000806040838503121561529057600080fd5b61529983614cee565b9150602083013567ffffffffffffffff8111156152b557600080fd5b61522585828601614ea3565b6000806000606084860312156152d657600080fd5b6152df84614cee565b9250602084013567ffffffffffffffff808211156152fc57600080fd5b61530887838801614fdd565b9350604086013591508082111561531e57600080fd5b5061532b86828701614fdd565b9150509250925092565b6000806000806060858703121561534b57600080fd5b61535485614cee565b935060208501359250604085013567ffffffffffffffff81111561537757600080fd5b61538387828801614dfb565b95989497509550505050565b6000806000806000608086880312156153a757600080fd5b6153b086614cee565b9450602086013567ffffffffffffffff8111156153cc57600080fd5b6153d888828901614dfb565b9699909850959660408101359660609091013595509350505050565b6000806040838503121561540757600080fd5b50508035926020909101359150565b6000806040838503121561542957600080fd5b61543283614cee565b91506020830135801515811461544757600080fd5b809150509250929050565b600080600080600060a0868803121561546a57600080fd5b61547386614cee565b94506020860135935060408601359250606086013567ffffffffffffffff81111561549d57600080fd5b6154a988828901614ea3565b9250506154b860808701614f17565b90509295509295909350565b6000806000604084860312156154d957600080fd5b6154e284614cee565b9250602084013567ffffffffffffffff8111156154fe57600080fd5b61550a86828701614dfb565b9497909650939450505050565b6000806040838503121561552a57600080fd5b61553383614cee565b915061554160208401614cee565b90509250929050565b6000806040838503121561555d57600080fd5b61556683614cee565b9150602083013567ffffffffffffffff81111561558257600080fd5b61522585828601614fdd565b60008060008060008060006080888a0312156155a957600080fd5b6155b288614cee565b9650602088013567ffffffffffffffff808211156155cf57600080fd5b6155db8b838c01614dfb565b909850965060408a01359150808211156155f457600080fd5b6156008b838c01614dfb565b909650945060608a013591508082111561561957600080fd5b506156268a828b01614dfb565b989b979a50959850939692959293505050565b600080600080600060a0868803121561565157600080fd5b61565a86614cee565b945061566860208701614cee565b93506040860135925060608601359150608086013567ffffffffffffffff81111561569257600080fd5b6150eb88828901614ea3565b6000806000606084860312156156b357600080fd5b6156bc84614cee565b95602085013595506040909401359392505050565b600080600080608085870312156156e757600080fd5b6156f085614cee565b935060208501359250604085013567ffffffffffffffff81111561571357600080fd5b61571f87828801614ea3565b92505061572e60608601614f17565b905092959194509250565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602160045260246000fd5b60408152600061577b6040830185614da3565b90508260208301529392505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b600060001982036157fb576157fb6157b9565b5060010190565b60008083357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe184360301811261583757600080fd5b83018035915067ffffffffffffffff82111561585257600080fd5b6020019150600581901b3603821315614e4057600080fd5b8082018082111561083a5761083a6157b9565b604081526000615890604083018561522f565b8281036020840152610cc7818561522f565b6000602082840312156158b457600080fd5b5051919050565b6080815260006158ce608083018761522f565b82810360208401526158e0818761522f565b905082810360408401526158f4818661522f565b90508281036060840152615908818561522f565b979650505050505050565b8181038181111561083a5761083a6157b9565b81835260007f07ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff83111561595857600080fd5b8260051b80836020870137939093016020019392505050565b60808152600061598560808301888a615926565b8281036020840152615997818861522f565b905082810360408401526159ab818761522f565b905082810360608401526159c0818587615926565b9998505050505050505050565b600181811c908216806159e157607f821691505b602082108103615a1a577f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b50919050565b6000808454615a2e816159cd565b60018281168015615a465760018114615a5b57615a8a565b60ff1984168752821515830287019450615a8a565b8860005260208060002060005b85811015615a815781548a820152908401908201615a68565b50505082870194505b505050508351615a9e818360208801614d7f565b01949350505050565b60006001600160a01b03808816835280871660208401525060a06040830152615ad360a083018661522f565b8281036060840152615ae5818661522f565b90508281036080840152615af98185614da3565b98975050505050505050565b600060208284031215615b1757600080fd5b815161093a81614d34565b600060033d11156111ae5760046000803e5060005160e01c90565b600060443d1015615b4b5790565b6040517ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc803d016004833e81513d67ffffffffffffffff8160248401118184111715615b9957505050505090565b8285019150815181811115615bb15750505050505090565b843d8701016020828501011115615bcb5750505050505090565b615bda60208286010187614e76565b509095945050505050565b60006fffffffffffffffffffffffffffffffff808316818103615c0a57615c0a6157b9565b6001019392505050565b601f8211156111c357600081815260208120601f850160051c81016020861015615c3b5750805b601f850160051c820191505b8181101561142757828155600101615c47565b815167ffffffffffffffff811115615c7457615c74614e47565b615c8881615c8284546159cd565b84615c14565b602080601f831160018114615cbd5760008415615ca55750858301515b600019600386901b1c1916600185901b178555611427565b600085815260208120601f198616915b82811015615cec57888601518255948401946001909101908401615ccd565b5085821015615d0a5787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b60006001600160a01b03808816835280871660208401525084604083015283606083015260a0608083015261590860a0830184614da3565b60008251615d64818460208701614d7f565b919091019291505056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a26469706673582212204c37f0793ff8af27d30569e38fca163a67b4a79dd8f7dad4b36c16831acb84e764736f6c63430008110033", + "deployedBytecode": "0x6080604052600436106102695760003560e01c8063715018a611610153578063b316962f116100cb578063f242432a1161007f578063f5298aca11610064578063f5298aca14610732578063f6b1229314610752578063fda4823c1461077257600080fd5b8063f242432a146106f2578063f2fde38b1461071257600080fd5b8063e985e9c5116100b0578063e985e9c514610669578063eb568a14146106b2578063f1169062146106d257600080fd5b8063b316962f14610629578063c7b26c541461064957600080fd5b80638fc202dd1161012257806399f771a71161010757806399f771a7146105ad578063a21ed980146105cd578063a22cb4651461060957600080fd5b80638fc202dd14610578578063993de1841461058d57600080fd5b8063715018a61461051b5780638129fc1c146105305780638456cb59146105455780638da5cb5b1461055a57600080fd5b80633f4ba83a116101e657806352d1902d116101b55780636352211e1161019a5780636352211e1461048c5780636b20c454146104db5780636ebd893f146104fb57600080fd5b806352d1902d1461045e5780635c975abb1461047357600080fd5b80633f4ba83a146103e95780633f71e944146103fe5780634e1273f41461041e5780634f1ef2861461044b57600080fd5b80631a2e98241161023d5780632eb2c2d6116102225780632eb2c2d6146103895780633659cfe6146103a95780633e11eefe146103c957600080fd5b80631a2e9824146103475780631e75a8b51461036757600080fd5b8062fdd58e1461026e57806301ffc9a7146102a157806306fdde03146102d15780630e89341c14610327575b600080fd5b34801561027a57600080fd5b5061028e610289366004614d0a565b610792565b6040519081526020015b60405180910390f35b3480156102ad57600080fd5b506102c16102bc366004614d62565b610840565b6040519015158152602001610298565b3480156102dd57600080fd5b5061031a6040518060400160405280600f81526020017f4879706572636572744d696e746572000000000000000000000000000000000081525081565b6040516102989190614dcf565b34801561033357600080fd5b5061031a610342366004614de2565b610923565b34801561035357600080fd5b5061028e610362366004614d0a565b61092e565b34801561037357600080fd5b50610387610382366004614f26565b610941565b005b34801561039557600080fd5b506103876103a436600461504e565b610a6a565b3480156103b557600080fd5b506103876103c43660046150f8565b610b0c565b3480156103d557600080fd5b506102c16103e4366004615113565b610ca9565b3480156103f557600080fd5b50610387610cd0565b34801561040a57600080fd5b5061031a610419366004614de2565b610ce2565b34801561042a57600080fd5b5061043e610439366004615164565b610e1f565b604051610298919061526a565b61038761045936600461527d565b610f5d565b34801561046a57600080fd5b5061028e6110eb565b34801561047f57600080fd5b506101cd5460ff166102c1565b34801561049857600080fd5b506104c36104a7366004614de2565b600090815261019260205260409020546001600160a01b031690565b6040516001600160a01b039091168152602001610298565b3480156104e757600080fd5b506103876104f63660046152c1565b6111b1565b34801561050757600080fd5b50610387610516366004615335565b6111c8565b34801561052757600080fd5b506103876111e2565b34801561053c57600080fd5b506103876111f4565b34801561055157600080fd5b50610387611355565b34801561056657600080fd5b5060fb546001600160a01b03166104c3565b34801561058457600080fd5b50610387611365565b34801561059957600080fd5b506103876105a836600461538f565b611408565b3480156105b957600080fd5b5061028e6105c8366004614de2565b61142f565b3480156105d957600080fd5b506102c16105e83660046153f4565b6101b060209081526000928352604080842090915290825290205460ff1681565b34801561061557600080fd5b50610387610624366004615416565b611444565b34801561063557600080fd5b50610387610644366004615452565b61144f565b34801561065557600080fd5b506103876106643660046154c4565b6114e4565b34801561067557600080fd5b506102c1610684366004615517565b6001600160a01b03918216600090815260666020908152604080832093909416825291909152205460ff1690565b3480156106be57600080fd5b506103876106cd36600461554a565b611529565b3480156106de57600080fd5b506103876106ed36600461558e565b61153b565b3480156106fe57600080fd5b5061038761070d366004615639565b6115ce565b34801561071e57600080fd5b5061038761072d3660046150f8565b611669565b34801561073e57600080fd5b5061038761074d36600461569e565b6116f6565b34801561075e57600080fd5b5061038761076d366004614d0a565b611708565b34801561077e57600080fd5b5061038761078d3660046156d1565b61171a565b60006001600160a01b0383166108155760405162461bcd60e51b815260206004820152602a60248201527f455243313135353a2061646472657373207a65726f206973206e6f742061207660448201527f616c6964206f776e65720000000000000000000000000000000000000000000060648201526084015b60405180910390fd5b5060008181526065602090815260408083206001600160a01b03861684529091529020545b92915050565b60007fffffffff0000000000000000000000000000000000000000000000000000000082167fd9b67a260000000000000000000000000000000000000000000000000000000014806108d357507fffffffff0000000000000000000000000000000000000000000000000000000082167f0e89341c00000000000000000000000000000000000000000000000000000000145b8061083a57507f01ffc9a7000000000000000000000000000000000000000000000000000000007fffffffff0000000000000000000000000000000000000000000000000000000083161461083a565b606061083a826117cc565b600061093a83836117ea565b9392505050565b610949611822565b336001600160a01b0387161461097257604051631eb49d6d60e11b815260040160405180910390fd5b846109af85858080602002602001604051908101604052809392919081815260200183836020028082843760009201919091525061187692505050565b146109e6576040517f6dac6a0900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60006109f4878686866118f5565b60008181526101ff602052604090208054919250839160ff19166001836002811115610a2257610a22615739565b0217905550807f19789dde2d660b739733377add05f87576a360d2d4adea587c2592264f7f6d4e8488604051610a59929190615768565b60405180910390a250505050505050565b6001600160a01b038516331480610a865750610a868533610684565b610af85760405162461bcd60e51b815260206004820152602e60248201527f455243313135353a2063616c6c6572206973206e6f7420746f6b656e206f776e60448201527f6572206f7220617070726f766564000000000000000000000000000000000000606482015260840161080c565b610b05858585858561196f565b5050505050565b6001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000163003610baa5760405162461bcd60e51b815260206004820152602c60248201527f46756e6374696f6e206d7573742062652063616c6c6564207468726f7567682060448201527f64656c656761746563616c6c0000000000000000000000000000000000000000606482015260840161080c565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316610c057f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc546001600160a01b031690565b6001600160a01b031614610c815760405162461bcd60e51b815260206004820152602c60248201527f46756e6374696f6e206d7573742062652063616c6c6564207468726f7567682060448201527f6163746976652070726f78790000000000000000000000000000000000000000606482015260840161080c565b610c8a81611c24565b60408051600080825260208201909252610ca691839190611c2c565b50565b60008281526101af6020526040812054610cc7908690869085611dcc565b95945050505050565b610cd8611de4565b610ce0611e3e565b565b6fffffffffffffffffffffffffffffffff19811660009081526101ff602052604081205460609160ff90911690816002811115610d2157610d21615739565b03610d6157505060408051808201909152600881527f416c6c6f77416c6c0000000000000000000000000000000000000000000000006020820152919050565b6001816002811115610d7557610d75615739565b03610db557505060408051808201909152600b81527f446973616c6c6f77416c6c0000000000000000000000000000000000000000006020820152919050565b6002816002811115610dc957610dc9615739565b03610e0957505060408051808201909152600f81527f46726f6d43726561746f724f6e6c7900000000000000000000000000000000006020820152919050565b5050604080516020810190915260008152919050565b60608151835114610e985760405162461bcd60e51b815260206004820152602960248201527f455243313135353a206163636f756e747320616e6420696473206c656e67746860448201527f206d69736d617463680000000000000000000000000000000000000000000000606482015260840161080c565b6000835167ffffffffffffffff811115610eb457610eb4614e47565b604051908082528060200260200182016040528015610edd578160200160208202803683370190505b50905060005b8451811015610f5557610f28858281518110610f0157610f0161578a565b6020026020010151858381518110610f1b57610f1b61578a565b6020026020010151610792565b828281518110610f3a57610f3a61578a565b6020908102919091010152610f4e816157e8565b9050610ee3565b509392505050565b6001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000163003610ffb5760405162461bcd60e51b815260206004820152602c60248201527f46756e6374696f6e206d7573742062652063616c6c6564207468726f7567682060448201527f64656c656761746563616c6c0000000000000000000000000000000000000000606482015260840161080c565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03166110567f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc546001600160a01b031690565b6001600160a01b0316146110d25760405162461bcd60e51b815260206004820152602c60248201527f46756e6374696f6e206d7573742062652063616c6c6564207468726f7567682060448201527f6163746976652070726f78790000000000000000000000000000000000000000606482015260840161080c565b6110db82611c24565b6110e782826001611c2c565b5050565b6000306001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000161461118b5760405162461bcd60e51b815260206004820152603860248201527f555550535570677261646561626c653a206d757374206e6f742062652063616c60448201527f6c6564207468726f7567682064656c656761746563616c6c0000000000000000606482015260840161080c565b507f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc5b90565b6111b9611822565b6111c38383611e91565b505050565b6111d0611822565b6111dc8484848461211f565b50505050565b6111ea611de4565b610ce06000612667565b600054610100900460ff16158080156112145750600054600160ff909116105b8061122e5750303b15801561122e575060005460ff166001145b6112a05760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201527f647920696e697469616c697a6564000000000000000000000000000000000000606482015260840161080c565b6000805460ff1916600117905580156112e057600080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ff166101001790555b6112e8611365565b6112f06126d1565b8015610ca657600080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ff169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a150565b61135d611de4565b610ce0612744565b600054610100900460ff166113d05760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201526a6e697469616c697a696e6760a81b606482015260840161080c565b6113e860405180602001604052806000815250612782565b6113f06127f6565b6113f8612861565b6114006128d4565b610ce06127f6565b611410611822565b61141c84848484612947565b611427858383612ad0565b505050505050565b6000818152610194602052604081205461083a565b6110e7338383612ba8565b611457611822565b6000611464868685612c9c565b9050611471818587612d6d565b60008181526101ff60205260409020805483919060ff1916600183600281111561149d5761149d615739565b0217905550807f19789dde2d660b739733377add05f87576a360d2d4adea587c2592264f7f6d4e84876040516114d4929190615768565b60405180910390a2505050505050565b6114ec611822565b6111c383838380806020026020016040519081016040528093929190818152602001838360200280828437600092019190915250612e5392505050565b611531611822565b6110e78282611e91565b611543611822565b8260005b818110156115b5576115ad8888838181106115645761156461578a565b90506020028101906115769190615802565b8888858181106115885761158861578a565b905060200201358787868181106115a1576115a161578a565b90506020020135612947565b600101611547565b506115c38886868686613167565b505050505050505050565b6001600160a01b0385163314806115ea57506115ea8533610684565b61165c5760405162461bcd60e51b815260206004820152602e60248201527f455243313135353a2063616c6c6572206973206e6f7420746f6b656e206f776e60448201527f6572206f7220617070726f766564000000000000000000000000000000000000606482015260840161080c565b610b0585858585856133a2565b611671611de4565b6001600160a01b0381166116ed5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f6464726573730000000000000000000000000000000000000000000000000000606482015260840161080c565b610ca681612667565b6116fe611822565b6111c3838361358d565b611710611822565b6110e7828261358d565b611722611822565b336001600160a01b0385161461174b57604051631eb49d6d60e11b815260040160405180910390fd5b600061175885858561365c565b60008181526101ff602052604090208054919250839160ff1916600183600281111561178657611786615739565b0217905550807f19789dde2d660b739733377add05f87576a360d2d4adea587c2592264f7f6d4e84866040516117bd929190615768565b60405180910390a25050505050565b606061083a6fffffffffffffffffffffffffffffffff198316613741565b600081815261019260205260408120546001600160a01b0384811691160361083a575060009081526101946020526040902054919050565b6101cd5460ff1615610ce05760405162461bcd60e51b815260206004820152601060248201527f5061757361626c653a2070617573656400000000000000000000000000000000604482015260640161080c565b8051600090815b818110156118ee578381815181106118975761189761578a565b60200260200101516000036118bf57604051631eb49d6d60e11b815260040160405180910390fd5b8381815181106118d1576118d161578a565b6020026020010151836118e4919061586a565b925060010161187d565b5050919050565b600061193d8561193786868080602002602001604051908101604052809392919081815260200183836020028082843760009201919091525061187692505050565b8461365c565b60008181526101956020526040902054909150611967908690611960908461586a565b868661211f565b949350505050565b81518351146119e65760405162461bcd60e51b815260206004820152602860248201527f455243313135353a2069647320616e6420616d6f756e7473206c656e6774682060448201527f6d69736d61746368000000000000000000000000000000000000000000000000606482015260840161080c565b6001600160a01b038416611a625760405162461bcd60e51b815260206004820152602560248201527f455243313135353a207472616e7366657220746f20746865207a65726f20616460448201527f6472657373000000000000000000000000000000000000000000000000000000606482015260840161080c565b33611a71818787878787613820565b60005b8451811015611bb0576000858281518110611a9157611a9161578a565b602002602001015190506000858381518110611aaf57611aaf61578a565b60209081029190910181015160008481526065835260408082206001600160a01b038e168352909352919091205490915081811015611b565760405162461bcd60e51b815260206004820152602a60248201527f455243313135353a20696e73756666696369656e742062616c616e636520666f60448201527f72207472616e7366657200000000000000000000000000000000000000000000606482015260840161080c565b60008381526065602090815260408083206001600160a01b038e8116855292528083208585039055908b16825281208054849290611b9590849061586a565b9250508190555050505080611ba9906157e8565b9050611a74565b50846001600160a01b0316866001600160a01b0316826001600160a01b03167f4a39dc06d4c0dbc64b70af90fd698a233a518aa5d07e595d983b8c0526c8f7fb8787604051611c0092919061587d565b60405180910390a4611c16818787878787613968565b6114278187878787876139d2565b610ca6611de4565b7f4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd91435460ff1615611c5f576111c383613bdf565b826001600160a01b03166352d1902d6040518163ffffffff1660e01b8152600401602060405180830381865afa925050508015611cb9575060408051601f3d908101601f19168201909252611cb6918101906158a2565b60015b611d2b5760405162461bcd60e51b815260206004820152602e60248201527f45524331393637557067726164653a206e657720696d706c656d656e7461746960448201527f6f6e206973206e6f742055555053000000000000000000000000000000000000606482015260840161080c565b7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc8114611dc05760405162461bcd60e51b815260206004820152602960248201527f45524331393637557067726164653a20756e737570706f727465642070726f7860448201527f6961626c65555549440000000000000000000000000000000000000000000000606482015260840161080c565b506111c3838383613cb5565b600082611dda868685613cda565b1495945050505050565b60fb546001600160a01b03163314610ce05760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015260640161080c565b611e46613d26565b6101cd805460ff191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa335b6040516001600160a01b03909116815260200160405180910390a1565b6001600160a01b0382163314801590611eb15750611eaf8233610684565b155b15611ee8576040517fe433766c00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b805160008167ffffffffffffffff811115611f0557611f05614e47565b604051908082528060200260200182016040528015611f2e578160200160208202803683370190505b50905060008267ffffffffffffffff811115611f4c57611f4c614e47565b604051908082528060200260200182016040528015611f75578160200160208202803683370190505b50905060008367ffffffffffffffff811115611f9357611f93614e47565b604051908082528060200260200182016040528015611fbc578160200160208202803683370190505b50905060008467ffffffffffffffff811115611fda57611fda614e47565b604051908082528060200260200182016040528015612003578160200160208202803683370190505b50905060005b858110156120cd5760008782815181106120255761202561578a565b602090810291909101810151600081815261019490925260408220805492905591506fffffffffffffffffffffffffffffffff19821687848151811061206d5761206d61578a565b6020026020010181815250508085848151811061208c5761208c61578a565b60200260200101818152505060018484815181106120ac576120ac61578a565b602002602001018181525050505080806120c5906157e8565b915050612009565b506120d9878783613d79565b7f088515a3c7b4e71520602d818f4dec002fadefde30c55e13f390c8d96046990a8487858560405161210e94939291906158bb565b60405180910390a150505050505050565b60fd81118061212e5750600281105b15612165576040517f3ada02e500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6121a182828080602002602001604051908101604052809392919081815260200183836020028082843760009201919091525061187692505050565b60008481526101946020526040902054146121cf57604051631eb49d6d60e11b815260040160405180910390fd5b600083815261019460205260408120546fffffffffffffffffffffffffffffffff198516916121ff600185615913565b905060008167ffffffffffffffff81111561221c5761221c614e47565b604051908082528060200260200182016040528015612245578160200160208202803683370190505b50905060008267ffffffffffffffff81111561226357612263614e47565b60405190808252806020026020018201604052801561228c578160200160208202803683370190505b50905060008367ffffffffffffffff8111156122aa576122aa614e47565b6040519080825280602002602001820160405280156122d3578160200160208202803683370190505b50905060008467ffffffffffffffff8111156122f1576122f1614e47565b60405190808252806020026020018201604052801561231a578160200160208202803683370190505b50905060008567ffffffffffffffff81111561233857612338614e47565b604051908082528060200260200182016040528015612361578160200160208202803683370190505b50905060008a8a8080602002602001604051908101604052809392919081815260200183836020028082843760009201829052508451949550938593508b9250821090506123b1576123b161578a565b60200260200101519050816000815181106123ce576123ce61578a565b60200260200101518289815181106123e8576123e861578a565b60200260200101818152505080826000815181106124085761240861578a565b60200260200101818152505060005b888110156125235760008b8152610195602052604090205461243890614023565b8a88828151811061244b5761244b61578a565b6020026020010181815250508d87828151811061246a5761246a61578a565b60200260200101818152505061019560008c815260200190815260200160002060008154612497906157e8565b91829055506124a6908c61586a565b8682815181106124b8576124b861578a565b60200260200101818152505060018582815181106124d8576124d861578a565b6020026020010181815250508281815181106124f6576124f661578a565b60200260200101518482815181106125105761251061578a565b6020908102919091010152600101612417565b5050506125656125303390565b60008d8152610192602090815260408083205481519283019091529181526001600160a01b039091169087908790869061402d565b60005b868110156125ed578181815181106125825761258261578a565b6020026020010151886125959190615913565b97508181815181106125a9576125a961578a565b602002602001015161019460008684815181106125c8576125c861578a565b6020026020010151815260200190815260200160002081905550806001019050612568565b5060008b8152610194602090815260408083208a90558051918201905290815261261c908d908590859061415d565b7f088515a3c7b4e71520602d818f4dec002fadefde30c55e13f390c8d96046990a8585858460405161265194939291906158bb565b60405180910390a1505050505050505050505050565b60fb80546001600160a01b038381167fffffffffffffffffffffffff0000000000000000000000000000000000000000831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b600054610100900460ff1661273c5760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201526a6e697469616c697a696e6760a81b606482015260840161080c565b610ce0614373565b61274c611822565b6101cd805460ff191660011790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a258611e743390565b600054610100900460ff166127ed5760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201526a6e697469616c697a696e6760a81b606482015260840161080c565b610ca6816143eb565b600054610100900460ff16610ce05760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201526a6e697469616c697a696e6760a81b606482015260840161080c565b600054610100900460ff166128cc5760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201526a6e697469616c697a696e6760a81b606482015260840161080c565b610ce061445f565b600054610100900460ff1661293f5760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201526a6e697469616c697a696e6760a81b606482015260840161080c565b610ce06144e6565b60008281526101af60209081526040805133818401528082018590528151808203830181526060820183528051908401206080808301919091528251808303909101815260a090910182528051908301208584526101b083528184208185529092529091205460ff16156129e7576040517f646cf55800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60008381526101af6020526040902054612a05908690869084611dcc565b1580612a36575060008381526101b160209081526040808320546101b290925290912054612a3490849061586a565b115b15612a6d576040517f6dac6a0900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60008381526101b060209081526040808320848452825291829020805460ff1916600117905581518581529081018390527f51483c8cc684284e9ba3215822230838b766f1698bcc7e922a31e02c3c203bd7910160405180910390a15050505050565b6000612adb8361455a565b612af857604051631eb49d6d60e11b815260040160405180910390fd5b60008381526101956020526040902054612b1190614023565b5060008281526101956020908152604080832080546001808201909255860181018085526101948452828520869055825193840190925292825291612b599186918491614590565b6040805184815260006020820152908101829052606081018390527f5e65fcde72b913ac2870f9df6ea5b6bca757862f44636cb368ed5e339fc524fb9060800160405180910390a19392505050565b816001600160a01b0316836001600160a01b031603612c2f5760405162461bcd60e51b815260206004820152602960248201527f455243313135353a2073657474696e6720617070726f76616c2073746174757360448201527f20666f722073656c660000000000000000000000000000000000000000000000606482015260840161080c565b6001600160a01b03838116600081815260666020908152604080832094871680845294825291829020805460ff191686151590811790915591519182527f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a3505050565b6000612caa610191546146d7565b608061019160008154612cbc906157e8565b9182905550901b60008181526101936020908152604080832080547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b038a1617905561019490915290208490559050612d1d81836146e5565b604080518281526000602082018190529182916001600160a01b038816917fc3d58168c5ae7397731d063d5bbf3d657854427343f4c083240f7aacaa2d0f62910160405180910390a49392505050565b811580612d78575080155b15612daf576040517f6dac6a0900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60008381526101af602052604090205415612df6576040517f357d0cc400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60008381526101af602090815260408083208590556101b182529182902083905581518581529081018490527f233c854c30aaaad173f2dd900c76d53c64e556d1d009d71466ec1afcb7b5844d91015b60405180910390a1505050565b60fd81511180612e64575060028151105b15612e9b576040517f3ada02e500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600060018251612eab9190615913565b90506000828281518110612ec157612ec161578a565b602002602001015190506000808367ffffffffffffffff811115612ee757612ee7614e47565b604051908082528060200260200182016040528015612f10578160200160208202803683370190505b50905060008467ffffffffffffffff811115612f2e57612f2e614e47565b604051908082528060200260200182016040528015612f57578160200160208202803683370190505b50905060008567ffffffffffffffff811115612f7557612f75614e47565b604051908082528060200260200182016040528015612f9e578160200160208202803683370190505b50905060008667ffffffffffffffff811115612fbc57612fbc614e47565b604051908082528060200260200182016040528015612fe5578160200160208202803683370190505b50905060005b878110156130aa5760008982815181106130075761300761578a565b60200260200101519050808683815181106130245761302461578a565b602002602001018181525050878583815181106130435761304361578a565b60200260200101818152505060018383815181106130635761306361578a565b6020026020010181815250506101946000828152602001908152602001600020548483815181106130965761309661578a565b602090810291909101015250600101612feb565b506130c8338a8686866040518060200160405280600081525061402d565b60005b87811015613136578281815181106130e5576130e561578a565b6020026020010151866130f8919061586a565b955061019460008683815181106131115761311161578a565b60200260200101518152602001908152602001600020600090558060010190506130cb565b50600086815261019460205260408120805487929061315690849061586a565b909155506115c39050898583613d79565b6060838067ffffffffffffffff81111561318357613183614e47565b6040519080825280602002602001820160405280156131ac578160200160208202803683370190505b50915060008167ffffffffffffffff8111156131ca576131ca614e47565b6040519080825280602002602001820160405280156131f3578160200160208202803683370190505b50905060008267ffffffffffffffff81111561321157613211614e47565b60405190808252806020026020018201604052801561323a578160200160208202803683370190505b50905060005b8381101561333957600089898381811061325c5761325c61578a565b90506020020135905061326e8161455a565b61328b57604051631eb49d6d60e11b815260040160405180910390fd5b600081815261019560205260409020546132a490614023565b600081815261019560205260409020805460018082019092558201018888848181106132d2576132d261578a565b90506020020135610194600083815260200190815260200160002081905550808784815181106133045761330461578a565b60200260200101818152505060018584815181106133245761332461578a565b60209081029190910101525050600101613240565b506133558985846040518060200160405280600081525061415d565b7f088515a3c7b4e71520602d818f4dec002fadefde30c55e13f390c8d96046990a888883878a8a60405161338e96959493929190615971565b60405180910390a150505095945050505050565b6001600160a01b03841661341e5760405162461bcd60e51b815260206004820152602560248201527f455243313135353a207472616e7366657220746f20746865207a65726f20616460448201527f6472657373000000000000000000000000000000000000000000000000000000606482015260840161080c565b33600061342a85614742565b9050600061343785614742565b9050613447838989858589613820565b60008681526065602090815260408083206001600160a01b038c168452909152902054858110156134e05760405162461bcd60e51b815260206004820152602a60248201527f455243313135353a20696e73756666696369656e742062616c616e636520666f60448201527f72207472616e7366657200000000000000000000000000000000000000000000606482015260840161080c565b60008781526065602090815260408083206001600160a01b038d8116855292528083208985039055908a1682528120805488929061351f90849061586a565b909155505060408051888152602081018890526001600160a01b03808b16928c821692918816917fc3d58168c5ae7397731d063d5bbf3d657854427343f4c083240f7aacaa2d0f62910160405180910390a461357f848a8a86868a613968565b6115c3848a8a8a8a8a61478d565b6001600160a01b03821633148015906135ad57506135ab8233610684565b155b156135e4576040517fe433766c00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000818152610194602052604081208054919055613604838360016148e8565b7f5e65fcde72b913ac2870f9df6ea5b6bca757862f44636cb368ed5e339fc524fb6fffffffffffffffffffffffffffffffff198316604080519182526020820185905260009082015260608101839052608001612e46565b60008260000361367f57604051631eb49d6d60e11b815260040160405180910390fd5b61368a848484612c9c565b6000818152610195602052604081208054929350909182906136ab906157e8565b91829055506136ba908361586a565b9050836101946000838152602001908152602001600020819055506136f18582600160405180602001604052806000815250614590565b6040805183815260006020820152908101829052606081018590527f5e65fcde72b913ac2870f9df6ea5b6bca757862f44636cb368ed5e339fc524fb9060800160405180910390a1509392505050565b600081815260ca602052604081208054606092919061375f906159cd565b80601f016020809104026020016040519081016040528092919081815260200182805461378b906159cd565b80156137d85780601f106137ad576101008083540402835291602001916137d8565b820191906000526020600020905b8154815290600101906020018083116137bb57829003601f168201915b5050505050905060008151116137f6576137f183614ab9565b61093a565b60c98160405160200161380a929190615a20565b6040516020818303038152906040529392505050565b6001600160a01b03851615611427576001600160a01b0384161561142757825160005b8181101561395e5760006138808683815181106138625761386261578a565b60200260200101516fffffffffffffffffffffffffffffffff191690565b60008181526101ff602052604090205490915060ff1660018160028111156138aa576138aa615739565b036138e1576040517fab064ad300000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60028160028111156138f5576138f5615739565b14801561391d5750600082815261019360205260409020546001600160a01b038a8116911614155b15613954576040517fab064ad300000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5050600101613843565b5050505050505050565b825160005b8181101561395e5785610192600087848151811061398d5761398d61578a565b6020026020010151815260200190815260200160002060006101000a8154816001600160a01b0302191690836001600160a01b0316021790555080600101905061396d565b6001600160a01b0384163b15611427576040517fbc197c810000000000000000000000000000000000000000000000000000000081526001600160a01b0385169063bc197c8190613a2f9089908990889088908890600401615aa7565b6020604051808303816000875af1925050508015613a6a575060408051601f3d908101601f19168201909252613a6791810190615b05565b60015b613b1f57613a76615b22565b806308c379a003613aaf5750613a8a615b3d565b80613a955750613ab1565b8060405162461bcd60e51b815260040161080c9190614dcf565b505b60405162461bcd60e51b815260206004820152603460248201527f455243313135353a207472616e7366657220746f206e6f6e2d4552433131353560448201527f526563656976657220696d706c656d656e746572000000000000000000000000606482015260840161080c565b7fffffffff0000000000000000000000000000000000000000000000000000000081167fbc197c810000000000000000000000000000000000000000000000000000000014613bd65760405162461bcd60e51b815260206004820152602860248201527f455243313135353a204552433131353552656365697665722072656a6563746560448201527f6420746f6b656e73000000000000000000000000000000000000000000000000606482015260840161080c565b50505050505050565b6001600160a01b0381163b613c5c5760405162461bcd60e51b815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201527f6f74206120636f6e747261637400000000000000000000000000000000000000606482015260840161080c565b7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc80547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b0392909216919091179055565b613cbe83614b4d565b600082511180613ccb5750805b156111c3576111dc8383614b8d565b600081815b84811015613d1d57613d0982878784818110613cfd57613cfd61578a565b90506020020135614c8f565b915080613d15816157e8565b915050613cdf565b50949350505050565b6101cd5460ff16610ce05760405162461bcd60e51b815260206004820152601460248201527f5061757361626c653a206e6f7420706175736564000000000000000000000000604482015260640161080c565b6001600160a01b038316613df55760405162461bcd60e51b815260206004820152602360248201527f455243313135353a206275726e2066726f6d20746865207a65726f206164647260448201527f6573730000000000000000000000000000000000000000000000000000000000606482015260840161080c565b8051825114613e6c5760405162461bcd60e51b815260206004820152602860248201527f455243313135353a2069647320616e6420616d6f756e7473206c656e6774682060448201527f6d69736d61746368000000000000000000000000000000000000000000000000606482015260840161080c565b6000339050613e8f81856000868660405180602001604052806000815250613820565b60005b8351811015613fac576000848281518110613eaf57613eaf61578a565b602002602001015190506000848381518110613ecd57613ecd61578a565b60209081029190910181015160008481526065835260408082206001600160a01b038c168352909352919091205490915081811015613f735760405162461bcd60e51b8152602060048201526024808201527f455243313135353a206275726e20616d6f756e7420657863656564732062616c60448201527f616e636500000000000000000000000000000000000000000000000000000000606482015260840161080c565b60009283526065602090815260408085206001600160a01b038b1686529091529092209103905580613fa4816157e8565b915050613e92565b5060006001600160a01b0316846001600160a01b0316826001600160a01b03167f4a39dc06d4c0dbc64b70af90fd698a233a518aa5d07e595d983b8c0526c8f7fb8686604051613ffd92919061587d565b60405180910390a46111dc81856000868660405180602001604052806000815250613968565b806111c381615be5565b835160005b8181101561395e57600086828151811061404e5761404e61578a565b60200260200101519050600086838151811061406c5761406c61578a565b6020026020010151905061407f8261455a565b1561409d57604051631eb49d6d60e11b815260040160405180910390fd5b6fffffffffffffffffffffffffffffffff1981166fffffffffffffffffffffffffffffffff198316146140fc576040517fb4902a1300000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6001600160a01b038916331480159061411c575061411a8933610684565b155b15614153576040517fe433766c00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5050600101614032565b6001600160a01b0384166141d95760405162461bcd60e51b815260206004820152602160248201527f455243313135353a206d696e7420746f20746865207a65726f2061646472657360448201527f7300000000000000000000000000000000000000000000000000000000000000606482015260840161080c565b81518351146142505760405162461bcd60e51b815260206004820152602860248201527f455243313135353a2069647320616e6420616d6f756e7473206c656e6774682060448201527f6d69736d61746368000000000000000000000000000000000000000000000000606482015260840161080c565b3361426081600087878787613820565b60005b84518110156142fc5783818151811061427e5761427e61578a565b60200260200101516065600087848151811061429c5761429c61578a565b602002602001015181526020019081526020016000206000886001600160a01b03166001600160a01b0316815260200190815260200160002060008282546142e4919061586a565b909155508190506142f4816157e8565b915050614263565b50846001600160a01b031660006001600160a01b0316826001600160a01b03167f4a39dc06d4c0dbc64b70af90fd698a233a518aa5d07e595d983b8c0526c8f7fb878760405161434d92919061587d565b60405180910390a461436481600087878787613968565b610b05816000878787876139d2565b600054610100900460ff166143de5760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201526a6e697469616c697a696e6760a81b606482015260840161080c565b6101cd805460ff19169055565b600054610100900460ff166144565760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201526a6e697469616c697a696e6760a81b606482015260840161080c565b610ca681614cbe565b600054610100900460ff166144ca5760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201526a6e697469616c697a696e6760a81b606482015260840161080c565b60408051602081019091526000815260c990610ca69082615c5a565b600054610100900460ff166145515760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201526a6e697469616c697a696e6760a81b606482015260840161080c565b610ce033612667565b60006fffffffffffffffffffffffffffffffff1982168214801561083a5750506fffffffffffffffffffffffffffffffff161590565b6001600160a01b03841661460c5760405162461bcd60e51b815260206004820152602160248201527f455243313135353a206d696e7420746f20746865207a65726f2061646472657360448201527f7300000000000000000000000000000000000000000000000000000000000000606482015260840161080c565b33600061461885614742565b9050600061462585614742565b905061463683600089858589613820565b60008681526065602090815260408083206001600160a01b038b1684529091528120805487929061466890849061586a565b909155505060408051878152602081018790526001600160a01b03808a1692600092918716917fc3d58168c5ae7397731d063d5bbf3d657854427343f4c083240f7aacaa2d0f62910160405180910390a46146c883600089858589613968565b613bd68360008989898961478d565b608081901c6111c381615be5565b600082815260ca602052604090206146fd8282615c5a565b50817f6bb7ff708619ba0610cba295a58592e0451dee2622938c8755667688daf3529b61472984610923565b6040516147369190614dcf565b60405180910390a25050565b6040805160018082528183019092526060916000919060208083019080368337019050509050828160008151811061477c5761477c61578a565b602090810291909101015292915050565b6001600160a01b0384163b15611427576040517ff23a6e610000000000000000000000000000000000000000000000000000000081526001600160a01b0385169063f23a6e61906147ea9089908990889088908890600401615d1a565b6020604051808303816000875af1925050508015614825575060408051601f3d908101601f1916820190925261482291810190615b05565b60015b61483157613a76615b22565b7fffffffff0000000000000000000000000000000000000000000000000000000081167ff23a6e610000000000000000000000000000000000000000000000000000000014613bd65760405162461bcd60e51b815260206004820152602860248201527f455243313135353a204552433131353552656365697665722072656a6563746560448201527f6420746f6b656e73000000000000000000000000000000000000000000000000606482015260840161080c565b6001600160a01b0383166149645760405162461bcd60e51b815260206004820152602360248201527f455243313135353a206275726e2066726f6d20746865207a65726f206164647260448201527f6573730000000000000000000000000000000000000000000000000000000000606482015260840161080c565b33600061497084614742565b9050600061497d84614742565b905061499d83876000858560405180602001604052806000815250613820565b60008581526065602090815260408083206001600160a01b038a16845290915290205484811015614a355760405162461bcd60e51b8152602060048201526024808201527f455243313135353a206275726e20616d6f756e7420657863656564732062616c60448201527f616e636500000000000000000000000000000000000000000000000000000000606482015260840161080c565b60008681526065602090815260408083206001600160a01b038b81168086529184528285208a8703905582518b81529384018a90529092908816917fc3d58168c5ae7397731d063d5bbf3d657854427343f4c083240f7aacaa2d0f62910160405180910390a4613bd684886000868660405180602001604052806000815250613968565b606060678054614ac8906159cd565b80601f0160208091040260200160405190810160405280929190818152602001828054614af4906159cd565b8015614b415780601f10614b1657610100808354040283529160200191614b41565b820191906000526020600020905b815481529060010190602001808311614b2457829003601f168201915b50505050509050919050565b614b5681613bdf565b6040516001600160a01b038216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b60606001600160a01b0383163b614c0c5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f60448201527f6e74726163740000000000000000000000000000000000000000000000000000606482015260840161080c565b600080846001600160a01b031684604051614c279190615d52565b600060405180830381855af49150503d8060008114614c62576040519150601f19603f3d011682016040523d82523d6000602084013e614c67565b606091505b5091509150610cc78282604051806060016040528060278152602001615d6f60279139614cca565b6000818310614cab57600082815260208490526040902061093a565b600083815260208390526040902061093a565b60676110e78282615c5a565b60608315614cd957508161093a565b61093a8383815115613a955781518083602001fd5b80356001600160a01b0381168114614d0557600080fd5b919050565b60008060408385031215614d1d57600080fd5b614d2683614cee565b946020939093013593505050565b7fffffffff0000000000000000000000000000000000000000000000000000000081168114610ca657600080fd5b600060208284031215614d7457600080fd5b813561093a81614d34565b60005b83811015614d9a578181015183820152602001614d82565b50506000910152565b60008151808452614dbb816020860160208601614d7f565b601f01601f19169290920160200192915050565b60208152600061093a6020830184614da3565b600060208284031215614df457600080fd5b5035919050565b60008083601f840112614e0d57600080fd5b50813567ffffffffffffffff811115614e2557600080fd5b6020830191508360208260051b8501011115614e4057600080fd5b9250929050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b601f19601f830116810181811067ffffffffffffffff82111715614e9c57614e9c614e47565b6040525050565b600082601f830112614eb457600080fd5b813567ffffffffffffffff811115614ece57614ece614e47565b604051614ee56020601f19601f8501160182614e76565b818152846020838601011115614efa57600080fd5b816020850160208301376000918101602001919091529392505050565b803560038110614d0557600080fd5b60008060008060008060a08789031215614f3f57600080fd5b614f4887614cee565b955060208701359450604087013567ffffffffffffffff80821115614f6c57600080fd5b614f788a838b01614dfb565b90965094506060890135915080821115614f9157600080fd5b50614f9e89828a01614ea3565b925050614fad60808801614f17565b90509295509295509295565b600067ffffffffffffffff821115614fd357614fd3614e47565b5060051b60200190565b600082601f830112614fee57600080fd5b81356020614ffb82614fb9565b6040516150088282614e76565b83815260059390931b850182019282810191508684111561502857600080fd5b8286015b84811015615043578035835291830191830161502c565b509695505050505050565b600080600080600060a0868803121561506657600080fd5b61506f86614cee565b945061507d60208701614cee565b9350604086013567ffffffffffffffff8082111561509a57600080fd5b6150a689838a01614fdd565b945060608801359150808211156150bc57600080fd5b6150c889838a01614fdd565b935060808801359150808211156150de57600080fd5b506150eb88828901614ea3565b9150509295509295909350565b60006020828403121561510a57600080fd5b61093a82614cee565b6000806000806060858703121561512957600080fd5b843567ffffffffffffffff81111561514057600080fd5b61514c87828801614dfb565b90989097506020870135966040013595509350505050565b6000806040838503121561517757600080fd5b823567ffffffffffffffff8082111561518f57600080fd5b818501915085601f8301126151a357600080fd5b813560206151b082614fb9565b6040516151bd8282614e76565b83815260059390931b85018201928281019150898411156151dd57600080fd5b948201945b83861015615202576151f386614cee565b825294820194908201906151e2565b9650508601359250508082111561521857600080fd5b5061522585828601614fdd565b9150509250929050565b600081518084526020808501945080840160005b8381101561525f57815187529582019590820190600101615243565b509495945050505050565b60208152600061093a602083018461522f565b6000806040838503121561529057600080fd5b61529983614cee565b9150602083013567ffffffffffffffff8111156152b557600080fd5b61522585828601614ea3565b6000806000606084860312156152d657600080fd5b6152df84614cee565b9250602084013567ffffffffffffffff808211156152fc57600080fd5b61530887838801614fdd565b9350604086013591508082111561531e57600080fd5b5061532b86828701614fdd565b9150509250925092565b6000806000806060858703121561534b57600080fd5b61535485614cee565b935060208501359250604085013567ffffffffffffffff81111561537757600080fd5b61538387828801614dfb565b95989497509550505050565b6000806000806000608086880312156153a757600080fd5b6153b086614cee565b9450602086013567ffffffffffffffff8111156153cc57600080fd5b6153d888828901614dfb565b9699909850959660408101359660609091013595509350505050565b6000806040838503121561540757600080fd5b50508035926020909101359150565b6000806040838503121561542957600080fd5b61543283614cee565b91506020830135801515811461544757600080fd5b809150509250929050565b600080600080600060a0868803121561546a57600080fd5b61547386614cee565b94506020860135935060408601359250606086013567ffffffffffffffff81111561549d57600080fd5b6154a988828901614ea3565b9250506154b860808701614f17565b90509295509295909350565b6000806000604084860312156154d957600080fd5b6154e284614cee565b9250602084013567ffffffffffffffff8111156154fe57600080fd5b61550a86828701614dfb565b9497909650939450505050565b6000806040838503121561552a57600080fd5b61553383614cee565b915061554160208401614cee565b90509250929050565b6000806040838503121561555d57600080fd5b61556683614cee565b9150602083013567ffffffffffffffff81111561558257600080fd5b61522585828601614fdd565b60008060008060008060006080888a0312156155a957600080fd5b6155b288614cee565b9650602088013567ffffffffffffffff808211156155cf57600080fd5b6155db8b838c01614dfb565b909850965060408a01359150808211156155f457600080fd5b6156008b838c01614dfb565b909650945060608a013591508082111561561957600080fd5b506156268a828b01614dfb565b989b979a50959850939692959293505050565b600080600080600060a0868803121561565157600080fd5b61565a86614cee565b945061566860208701614cee565b93506040860135925060608601359150608086013567ffffffffffffffff81111561569257600080fd5b6150eb88828901614ea3565b6000806000606084860312156156b357600080fd5b6156bc84614cee565b95602085013595506040909401359392505050565b600080600080608085870312156156e757600080fd5b6156f085614cee565b935060208501359250604085013567ffffffffffffffff81111561571357600080fd5b61571f87828801614ea3565b92505061572e60608601614f17565b905092959194509250565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602160045260246000fd5b60408152600061577b6040830185614da3565b90508260208301529392505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b600060001982036157fb576157fb6157b9565b5060010190565b60008083357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe184360301811261583757600080fd5b83018035915067ffffffffffffffff82111561585257600080fd5b6020019150600581901b3603821315614e4057600080fd5b8082018082111561083a5761083a6157b9565b604081526000615890604083018561522f565b8281036020840152610cc7818561522f565b6000602082840312156158b457600080fd5b5051919050565b6080815260006158ce608083018761522f565b82810360208401526158e0818761522f565b905082810360408401526158f4818661522f565b90508281036060840152615908818561522f565b979650505050505050565b8181038181111561083a5761083a6157b9565b81835260007f07ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff83111561595857600080fd5b8260051b80836020870137939093016020019392505050565b60808152600061598560808301888a615926565b8281036020840152615997818861522f565b905082810360408401526159ab818761522f565b905082810360608401526159c0818587615926565b9998505050505050505050565b600181811c908216806159e157607f821691505b602082108103615a1a577f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b50919050565b6000808454615a2e816159cd565b60018281168015615a465760018114615a5b57615a8a565b60ff1984168752821515830287019450615a8a565b8860005260208060002060005b85811015615a815781548a820152908401908201615a68565b50505082870194505b505050508351615a9e818360208801614d7f565b01949350505050565b60006001600160a01b03808816835280871660208401525060a06040830152615ad360a083018661522f565b8281036060840152615ae5818661522f565b90508281036080840152615af98185614da3565b98975050505050505050565b600060208284031215615b1757600080fd5b815161093a81614d34565b600060033d11156111ae5760046000803e5060005160e01c90565b600060443d1015615b4b5790565b6040517ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc803d016004833e81513d67ffffffffffffffff8160248401118184111715615b9957505050505090565b8285019150815181811115615bb15750505050505090565b843d8701016020828501011115615bcb5750505050505090565b615bda60208286010187614e76565b509095945050505050565b60006fffffffffffffffffffffffffffffffff808316818103615c0a57615c0a6157b9565b6001019392505050565b601f8211156111c357600081815260208120601f850160051c81016020861015615c3b5750805b601f850160051c820191505b8181101561142757828155600101615c47565b815167ffffffffffffffff811115615c7457615c74614e47565b615c8881615c8284546159cd565b84615c14565b602080601f831160018114615cbd5760008415615ca55750858301515b600019600386901b1c1916600185901b178555611427565b600085815260208120601f198616915b82811015615cec57888601518255948401946001909101908401615ccd565b5085821015615d0a5787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b60006001600160a01b03808816835280871660208401525084604083015283606083015260a0608083015261590860a0830184614da3565b60008251615d64818460208701614d7f565b919091019291505056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a26469706673582212204c37f0793ff8af27d30569e38fca163a67b4a79dd8f7dad4b36c16831acb84e764736f6c63430008110033", + "linkReferences": {}, + "deployedLinkReferences": {} +} diff --git a/sdk/test/setup-env.ts b/sdk/test/setup-env.ts index 5b983c4f..893c3429 100644 --- a/sdk/test/setup-env.ts +++ b/sdk/test/setup-env.ts @@ -1,4 +1,8 @@ import dotenv from "dotenv"; +import { startProxy } from "@viem/anvil"; +import fetchMock from "jest-fetch-mock"; + +fetchMock.enableMocks(); dotenv.config({ path: "./.env" }); @@ -6,4 +10,11 @@ const reloadEnv = () => { dotenv.config({ path: "./.env" }); }; +export default async function () { + return await startProxy({ + port: 8545, // By default, the proxy will listen on port 8545. + host: "::", // By default, the proxy will listen on all interfaces. + }); +} + export { reloadEnv }; diff --git a/sdk/test/storage.test.ts b/sdk/test/storage.test.ts index 004815bc..110da473 100644 --- a/sdk/test/storage.test.ts +++ b/sdk/test/storage.test.ts @@ -1,25 +1,12 @@ import { expect } from "chai"; -import { providers } from "ethers"; -import sinon from "sinon"; -import { HypercertMetadata } from "src/index.js"; +import { HypercertMetadata } from "../src"; -import HypercertsStorage from "../src/storage.js"; -import { StorageError } from "../src/types/errors.js"; -import { reloadEnv } from "./setup-env.js"; +import HypercertsStorage from "../src/storage"; +import { StorageError } from "../src/types/errors"; +import { reloadEnv } from "./setup-env"; describe("HypercertsStorage", () => { - let stub: sinon.SinonStub; - beforeAll(() => { - stub = sinon.stub(providers.BaseProvider.prototype, "on"); - - delete process.env.NFT_STORAGE_TOKEN; - delete process.env.WEB3_STORAGE_TOKEN; - delete process.env.NEXT_PUBLIC_NFT_STORAGE_TOKEN; - delete process.env.NEXT_PUBLIC_WEB3_STORAGE_TOKEN; - }); - afterAll(() => { - stub.restore(); reloadEnv(); }); @@ -47,11 +34,6 @@ describe("HypercertsStorage", () => { }); it("should throw an error when executing write method in readonly mode", async () => { - delete process.env.NFT_STORAGE_TOKEN; - delete process.env.WEB3_STORAGE_TOKEN; - delete process.env.NEXT_PUBLIC_NFT_STORAGE_TOKEN; - delete process.env.NEXT_PUBLIC_WEB3_STORAGE_TOKEN; - const client = new HypercertsStorage({}); // storeMetadata diff --git a/sdk/test/storage/nft.storage.test.ts b/sdk/test/storage/nft.storage.test.ts index 5ba4fc1a..d5244a4d 100644 --- a/sdk/test/storage/nft.storage.test.ts +++ b/sdk/test/storage/nft.storage.test.ts @@ -1,47 +1,37 @@ import { jest } from "@jest/globals"; -import { rest } from "msw"; -import { setupServer } from "msw/node"; +//eslint-disable-next-line @typescript-eslint/ban-ts-comment +// @ts-ignore import { NFTStorage } from "nft.storage"; import HypercertsStorage from "../../src/storage.js"; import { MalformedDataError } from "../../src/types/errors.js"; import { HypercertMetadata } from "../../src/types/metadata.js"; -import logger from "../../src/utils/logger.js"; -import { getFormattedMetadata } from "../helpers.js"; -import mockData from "../res/mockData.js"; -import mockMetadata from "../res/mockMetadata.js"; +import { getFormattedMetadata, mockDataSets } from "../helpers.js"; describe("NFT.Storage Client", () => { - const mockCorrectMetadataCid = "testCID1234fkreigdm2flneb4khd7eixodagst5nrndptgezrjux7gohxcngjn67x6u"; - const mockIncorrectMetadataCid = "errrCID1234fkreigdm2flneb4khd7eixodagst5nrndptgezrjux7gohxcngjn67x6u"; + const { hypercertData, hypercertMetadata } = mockDataSets; const storeBlobMock = jest.spyOn(NFTStorage.prototype, "storeBlob").mockImplementation((_: unknown, __?: unknown) => { - logger.debug("Hit mock storeBlob"); - - return Promise.resolve(mockCorrectMetadataCid); + return Promise.resolve(hypercertMetadata.cid); }); - const server = setupServer( - rest.get(`https://nftstorage.link/ipfs/${mockCorrectMetadataCid}`, (_, res, ctx) => { - return res(ctx.status(200), ctx.json(mockMetadata)); - }), - rest.get(`https://nftstorage.link/ipfs/${mockIncorrectMetadataCid}`, (_, res, ctx) => { - return res(ctx.status(200), ctx.json(mockData)); - }), - ); - - const storage = new HypercertsStorage({}); + const storage = new HypercertsStorage({ + nftStorageToken: process.env.NFT_STORAGE_TOKEN, + web3StorageToken: process.env.WEB3_STORAGE_TOKEN, + }); - beforeAll(() => server.listen()); + jest.spyOn(storage, "getFromIPFS").mockImplementation((cid: string) => { + if (cid === hypercertMetadata.cid) return Promise.resolve(hypercertMetadata.data); + if (cid === hypercertData.cid) return Promise.resolve(hypercertData.data); - afterEach(() => server.resetHandlers()); + return Promise.resolve("testData"); + }); afterEach(() => { jest.clearAllMocks(); }); afterAll(() => { - server.close(); jest.resetAllMocks(); }); @@ -54,15 +44,15 @@ describe("NFT.Storage Client", () => { }); it("Smoke test - get metadata", async () => { - const res = await storage.getMetadata(mockCorrectMetadataCid); + const res = await storage.getMetadata(hypercertMetadata.cid); - expect(res).toMatchObject(mockMetadata); + expect(res).toMatchObject(hypercertMetadata.data); }); it("Throws when trying to store incorrect metadata", async () => { // storeData try { - await storage.storeMetadata(mockData as HypercertMetadata); + await storage.storeMetadata({ data: "false" } as unknown as HypercertMetadata); } catch (e) { expect(e instanceof MalformedDataError).toBeTruthy(); @@ -74,14 +64,15 @@ describe("NFT.Storage Client", () => { }); it("Throws when trying to fetch incorrect metadata", async () => { + const incorrectCID = "incorrect-cid"; // storeData try { - await storage.getMetadata(mockIncorrectMetadataCid); + await storage.getMetadata(incorrectCID); } catch (e) { expect(e instanceof MalformedDataError).toBeTruthy(); const error = e as MalformedDataError; - expect(error.message).toBe(`Invalid metadata at ${mockIncorrectMetadataCid}`); + expect(error.message).toBe(`Invalid metadata at ${incorrectCID}`); } expect.assertions(2); diff --git a/sdk/test/storage/web3.storage.test.ts b/sdk/test/storage/web3.storage.test.ts index 8acf5020..e5845098 100644 --- a/sdk/test/storage/web3.storage.test.ts +++ b/sdk/test/storage/web3.storage.test.ts @@ -1,44 +1,35 @@ import { jest } from "@jest/globals"; -import { rest } from "msw"; -import { setupServer } from "msw/node"; //eslint-disable-next-line @typescript-eslint/ban-ts-comment // @ts-ignore import { Web3Storage } from "web3.storage"; -import HypercertsStorage from "../../src/storage.js"; -import logger from "../../src/utils/logger.js"; -import mockData from "../res/mockData.js"; -import mockMetadata from "../res/mockMetadata.js"; +import HypercertsStorage from "../../src/storage"; +import { mockDataSets } from "../helpers"; describe("Web3.Storage Client", () => { - const mockCorrectMetadataCid = "testCID1234fkreigdm2flneb4khd7eixodagst5nrndptgezrjux7gohxcngjn67x6u"; - const mockIncorrectMetadataCid = "errrCID1234fkreigdm2flneb4khd7eixodagst5nrndptgezrjux7gohxcngjn67x6u"; + const { hypercertData, hypercertMetadata } = mockDataSets; const storeBlobMock = jest.spyOn(Web3Storage.prototype, "put").mockImplementation((_: unknown, __?: unknown) => { - logger.debug("Hit mock storeBlob"); + return Promise.resolve(hypercertMetadata.cid); + }); - return Promise.resolve(mockCorrectMetadataCid); + const storage = new HypercertsStorage({ + nftStorageToken: process.env.NFT_STORAGE_TOKEN, + web3StorageToken: process.env.WEB3_STORAGE_TOKEN, }); - const server = setupServer( - rest.get(`https://nftstorage.link/ipfs/${mockCorrectMetadataCid}`, (_, res, ctx) => { - return res(ctx.status(200), ctx.json(mockMetadata)); - }), - rest.get(`https://nftstorage.link/ipfs/${mockIncorrectMetadataCid}`, (_, res, ctx) => { - return res(ctx.status(200), ctx.json(mockData)); - }), - ); - const storage = new HypercertsStorage({}); + jest.spyOn(storage, "getFromIPFS").mockImplementation((cid: string) => { + if (cid === hypercertMetadata.cid) return Promise.resolve(hypercertMetadata.data); + if (cid === hypercertData.cid) return Promise.resolve(hypercertData.data); - beforeAll(() => server.listen()); + return Promise.resolve("testData"); + }); afterEach(() => { - server.resetHandlers(); jest.clearAllMocks(); }); afterAll(() => { - server.close(); jest.resetAllMocks(); }); @@ -46,13 +37,13 @@ describe("Web3.Storage Client", () => { * Currently just testing against the production NFT.Storage service. */ it("Smoke test - add data", async () => { - await storage.storeData(mockData); + await storage.storeData(hypercertData.data); expect(storeBlobMock).toHaveBeenCalledTimes(1); }); it("Smoke test - get data", async () => { - const res = await storage.getData(mockCorrectMetadataCid); + const res = await storage.getData(hypercertData.cid); - expect(res).toMatchObject(mockMetadata); + expect(res).toMatchObject(hypercertData.data); }); }); diff --git a/sdk/test/types/errors.test.ts b/sdk/test/types/errors.test.ts index 012a88eb..de5e66c5 100644 --- a/sdk/test/types/errors.test.ts +++ b/sdk/test/types/errors.test.ts @@ -8,7 +8,7 @@ import { StorageError, UnknownSchemaError, UnsupportedChainError, -} from "../../src/types/errors.js"; +} from "../../src/types/errors"; describe.only("Error types", () => { it("has ClientError", () => { diff --git a/sdk/test/utils/config.test.ts b/sdk/test/utils/config.test.ts index 1290fa90..f27c44e5 100644 --- a/sdk/test/utils/config.test.ts +++ b/sdk/test/utils/config.test.ts @@ -1,33 +1,14 @@ import chai, { expect } from "chai"; import chaiSubset from "chai-subset"; -import { ethers } from "ethers"; import sinon from "sinon"; -import { DEFAULT_CHAIN_ID } from "../../src/constants.js"; -import { - ConfigurationError, - HypercertClientConfig, - InvalidOrMissingError, - UnsupportedChainError, -} from "../../src/types/index.js"; -import { getConfig } from "../../src/utils/config.js"; -import { reloadEnv } from "../../test/setup-env.js"; +import { ConfigurationError, HypercertClientConfig, InvalidOrMissingError } from "../../src/types"; +import { getConfig } from "../../src/utils/config"; +import { reloadEnv } from "../../test/setup-env"; +import { walletClient, publicClient } from "../helpers"; chai.use(chaiSubset); -describe("Config: chainId and chainName", () => { - it("should throw an error when the chainId is not supported", () => { - try { - getConfig({ chainId: 1337 }); - expect.fail("Should throw UnsupportedChainError"); - } catch (e) { - expect(e instanceof UnsupportedChainError).to.be.true; - const error = e as UnsupportedChainError; - expect(error.message).to.eq("chainId=1337 is not yet supported"); - } - }); -}); - describe("Config: contractAddress", () => { afterEach(() => { sinon.restore(); @@ -36,23 +17,23 @@ describe("Config: contractAddress", () => { }); it("should return the contract address specified by overrides", () => { - const overrides: Partial = { contractAddress: "0x1234567890123456789012345678901234567890" }; + const overrides: Partial = { + chain: { id: 5 }, + contractAddress: "0x1234567890123456789012345678901234567890", + }; const config = getConfig(overrides); expect(config.contractAddress).to.equal(overrides.contractAddress); }); - it("should return the contract address specified by the CONTRACT_ADDRESS environment variable", () => { - const CONTRACT_ADDRESS = "0x1234567890123456789012345678901234567890"; - sinon.stub(process, "env").value({ CONTRACT_ADDRESS }); - - const config = getConfig({}); - expect(config.contractAddress).to.equal(CONTRACT_ADDRESS); - delete process.env.CONTRACT_ADDRESS; - }); - it("should throw an error when the contract address specified by overrides is invalid", () => { - const overrides: Partial = { contractAddress: "invalid-address" }; - expect(() => getConfig(overrides)).to.throw(InvalidOrMissingError, "Invalid contract address"); + const overrides: Partial = { chain: { id: 5 }, contractAddress: "invalid-address" }; + try { + getConfig(overrides); + } catch (e) { + expect(e instanceof InvalidOrMissingError).to.be.true; + const error = e as InvalidOrMissingError; + expect(error.message).to.eq("Invalid contract address."); + } }); }); @@ -62,13 +43,13 @@ describe("Config: graphUrl", () => { }); it("should return the default graphUrl when no overrides are specified", () => { - const result = getConfig({}); + const result = getConfig({ chain: { id: 5 } }); expect(result.graphUrl).to.equal("https://api.thegraph.com/subgraphs/name/hypercerts-admin/hypercerts-testnet"); }); it("should return the config specified by overrides", () => { const overrides: Partial = { - chainName: "testnet", + chain: { id: 5 }, graphUrl: "https://api.example.com", contractAddress: "0x1234567890123456789012345678901234567890", unsafeForceOverrideConfig: true, @@ -79,115 +60,105 @@ describe("Config: graphUrl", () => { it("should throw an error when the graph URL specified by overrides is invalid", () => { const overrides: Partial = { - chainName: "testnet", + chain: { id: 5 }, graphUrl: "incorrect-url", contractAddress: "0x1234567890123456789012345678901234567890", unsafeForceOverrideConfig: true, }; - expect(() => getConfig(overrides)).to.throw(ConfigurationError, "Invalid graph URL"); + try { + getConfig(overrides); + } catch (e) { + expect(e instanceof ConfigurationError).to.be.true; + const error = e as ConfigurationError; + expect(error.message).to.eq("Invalid graph URL"); + } }); it("should throw an error when the graph URL specified by overrides is missing", () => { const overrides: Partial = { - chainName: "testnet", + chain: { id: 5 }, contractAddress: "0x1234567890123456789012345678901234567890", unsafeForceOverrideConfig: true, }; - expect(() => getConfig(overrides)).to.throw( - UnsupportedChainError, - "attempted to override with chainId=5, but requires chainName, graphUrl, and contractAddress to be set", - ); + + try { + getConfig(overrides); + } catch (e) { + expect(e instanceof InvalidOrMissingError).to.be.true; + const error = e as InvalidOrMissingError; + expect(error.message).to.eq( + "attempted to override with chainId=5, but requires chainName, graphUrl, and contractAddress to be set", + ); + } }); }); -describe("Config: nftStorageToken", () => { +describe("Config: nftStorageToken & web3storageToken", () => { afterEach(() => { sinon.restore(); reloadEnv(); }); it("should return an empty object when no overrides or environment variables are specified", () => { - sinon.stub(process, "env").value({ NFT_STORAGE_TOKEN: "NFTSTOR" }); - - const result = getConfig({}); - expect(result).to.deep.include({ - nftStorageToken: "NFTSTOR", - }); + const result = getConfig({ chain: { id: 5 } }); + expect(result.nftStorageToken).to.be.undefined; }); it("should return the nftStorageToken specified by overrides", () => { const overrides: Partial = { + chain: { id: 5 }, nftStorageToken: "NFTSTOR", + web3StorageToken: "WEB3STOR", }; const result = getConfig(overrides); expect(result).to.deep.include({ nftStorageToken: overrides.nftStorageToken, + web3StorageToken: overrides.web3StorageToken, }); }); it("should return the nftStorageToken specified by the NFT_STORAGE_TOKEN environment variable", () => { - sinon.stub(process, "env").value({ NFT_STORAGE_TOKEN: "NFTSTOR" }); - const result = getConfig({}); - expect(result).to.deep.include({ - nftStorageToken: "NFTSTOR", - }); - }); - - it("should return the nftStorageToken specified by the NEXT_PUBLIC_NFT_STORAGE_TOKEN environment variable", () => { - sinon.stub(process, "env").value({ NEXT_PUBLIC_NFT_STORAGE_TOKEN: "NFTSTOR" }); - - const result = getConfig({}); - expect(result).to.deep.include({ - nftStorageToken: "NFTSTOR", - }); + const result = getConfig({ chain: { id: 5 }, nftStorageToken: "NFTSTOR" }); + expect(result.nftStorageToken).to.be.eq("NFTSTOR"); }); - it("should not throw an error when the nftStorageToken specified by overrides is invalid", () => { - sinon.stub(process, "env").value({ NFT_STORAGE_TOKEN: null }); - - const overrides: Partial = {}; + const overrides: Partial = { chain: { id: 5 }, nftStorageToken: undefined }; expect(() => getConfig(overrides)).to.not.throw(); }); }); -describe("Config: getOperator", () => { +describe("Config: getPublicClient", () => { afterEach(() => { sinon.restore(); reloadEnv(); }); - it("should return a default provider when no overrides or environment variables are specified", () => { - const result = getConfig({}); - //TODO: hacky solution to compare providers - expect(JSON.stringify(result.operator)).to.equal(JSON.stringify(ethers.getDefaultProvider(DEFAULT_CHAIN_ID))); - }); it("should return the operator specified by overrides", () => { - const provider = ethers.getDefaultProvider(DEFAULT_CHAIN_ID); - const wallet = new ethers.Wallet("0x0123456789012345678901234567890123456789012345678901234567890123", provider); const overrides: Partial = { - operator: wallet, + chain: { id: 5 }, + publicClient, }; const result = getConfig(overrides); - expect(result.operator).to.equal(overrides.operator); + expect(result.publicClient).to.equal(overrides.publicClient); }); +}); - it("should return the operator specified by the PRIVATE_KEY environment variable", () => { - const PRIVATE_KEY = "0x0123456789012345678901234567890123456789012345678901234567890123"; - sinon.stub(process, "env").value({ PRIVATE_KEY }); +describe("Config: getWalletClient", () => { + afterEach(() => { + sinon.restore(); - const result = getConfig({}); - const provider = ethers.getDefaultProvider(DEFAULT_CHAIN_ID); - const wallet = new ethers.Wallet(PRIVATE_KEY, provider); - expect(JSON.stringify(result.operator)).to.equal(JSON.stringify(wallet)); + reloadEnv(); }); - it("should throw an error when the operator specified by overrides is invalid", () => { + it("should return the operator specified by overrides", () => { const overrides: Partial = { - operator: "invalid" as unknown as ethers.Signer, + chain: { id: 5 }, + walletClient, }; - expect(() => getConfig(overrides)).to.throw(InvalidOrMissingError, "Invalid operator."); + const result = getConfig(overrides); + expect(result.walletClient).to.equal(overrides.walletClient); }); }); @@ -199,46 +170,24 @@ describe("Config: web3StorageToken", () => { }); it("should return an empty object when no overrides or environment variables are specified", () => { - const WEB3_STORAGE_TOKEN = "WEB3"; - sinon.stub(process, "env").value({ WEB3_STORAGE_TOKEN }); - const result = getConfig({}); - expect(result).to.deep.include({ - web3StorageToken: WEB3_STORAGE_TOKEN, - }); + const result = getConfig({ chain: { id: 5 } }); + expect(result.web3StorageToken).to.be.undefined; }); it("should return the web3StorageToken specified by overrides", () => { const overrides: Partial = { + chain: { id: 5 }, web3StorageToken: "WEB3STOR", }; + const result = getConfig(overrides); expect(result).to.deep.include({ web3StorageToken: overrides.web3StorageToken, }); }); - it("should return the web3StorageToken specified by the WEB3_STORAGE_TOKEN environment variable", () => { - const WEB3_STORAGE_TOKEN = "WEB3"; - sinon.stub(process, "env").value({ WEB3_STORAGE_TOKEN }); - const result = getConfig({}); - expect(result).to.deep.include({ - web3StorageToken: WEB3_STORAGE_TOKEN, - }); - }); - - it("should return the web3StorageToken specified by the NEXT_PUBLIC_WEB3_STORAGE_TOKEN environment variable", () => { - const NEXT_PUBLIC_WEB3_STORAGE_TOKEN = "WEB3"; - sinon.stub(process, "env").value({ NEXT_PUBLIC_WEB3_STORAGE_TOKEN }); - - const result = getConfig({}); - expect(result).to.deep.include({ - web3StorageToken: NEXT_PUBLIC_WEB3_STORAGE_TOKEN, - }); - }); - it("should not throw an error when the web3StorageToken specified by overrides is invalid", () => { - sinon.stub(process, "env").value({ WEB3_STORAGE_TOKEN: null }); - const overrides: Partial = {}; + const overrides: Partial = { chain: { id: 5 }, web3StorageToken: undefined }; expect(() => getConfig(overrides)).to.not.throw(); }); }); diff --git a/sdk/test/utils/errors.test.ts b/sdk/test/utils/errors.test.ts index affc4362..46f07a1b 100644 --- a/sdk/test/utils/errors.test.ts +++ b/sdk/test/utils/errors.test.ts @@ -1,7 +1,7 @@ import { expect } from "chai"; -import { FetchError, MalformedDataError, UnsupportedChainError } from "../../src/types/errors.js"; -import { handleError } from "../../src/utils/errors.js"; +import { FetchError, MalformedDataError, UnsupportedChainError } from "../../src/types/errors"; +import { handleError } from "../../src/utils/errors"; describe("Error handler test", () => { it("checking error handler", () => { diff --git a/sdk/test/utils/formatter.test.ts b/sdk/test/utils/formatter.test.ts index 0875cde2..15cd6c5e 100644 --- a/sdk/test/utils/formatter.test.ts +++ b/sdk/test/utils/formatter.test.ts @@ -1,7 +1,7 @@ import { expect } from "chai"; -import { formatHypercertData } from "../../src/index.js"; -import { INDEFINITE_DATE_STRING, formatDate, formatUnixTime } from "../../src/utils/formatter.js"; +import { formatHypercertData } from "../../src"; +import { INDEFINITE_DATE_STRING, formatDate, formatUnixTime } from "../../src/utils/formatter"; type TestDataType = Parameters[0]; const testData: Partial = { diff --git a/sdk/test/validator.test.ts b/sdk/test/validator.test.ts index 6036f72d..210fdd1e 100644 --- a/sdk/test/validator.test.ts +++ b/sdk/test/validator.test.ts @@ -1,15 +1,16 @@ import { expect } from "chai"; -import { validateClaimData, validateMetaData } from "../src/index.js"; -import type { HypercertClaimdata, HypercertMetadata } from "../src/index.js"; -import testData from "./res/mockMetadata.js"; -import { validateDuplicateEvaluationData, validateSimpleTextEvaluationData } from "../src/validator/index.js"; -import { getDuplicateEvaluationData, getSimpleTextEvaluationData } from "./helpers.js"; -import { DuplicateEvaluation, SimpleTextEvaluation } from "../src/types/evaluation.js"; +import { validateClaimData, validateMetaData } from "../src"; +import type { HypercertClaimdata, HypercertMetadata } from "../src"; +import { validateDuplicateEvaluationData, validateSimpleTextEvaluationData } from "../src/validator"; +import { getDuplicateEvaluationData, getSimpleTextEvaluationData, mockDataSets } from "./helpers"; +import { DuplicateEvaluation, SimpleTextEvaluation } from "../src/types/evaluation"; describe("Validate claim test", () => { + const { hypercertData, hypercertMetadata } = mockDataSets; it("checking default metadata", () => { - expect(validateMetaData(testData).valid).to.be.true; + const result = validateMetaData(hypercertMetadata.data); + expect(result.valid).to.be.true; const invalidResult = validateMetaData({} as HypercertMetadata); @@ -18,7 +19,9 @@ describe("Validate claim test", () => { }); it("checking default claimdata", () => { - expect(validateClaimData(testData.hypercert).valid).to.be.true; + const result = validateClaimData(hypercertData.data); + console.log(result); + expect(result.valid).to.be.true; const invalidResult = validateClaimData({} as HypercertClaimdata); diff --git a/sdk/tsconfig.json b/sdk/tsconfig.json index 368097f4..2c208243 100644 --- a/sdk/tsconfig.json +++ b/sdk/tsconfig.json @@ -2,8 +2,8 @@ "compilerOptions": { "lib": ["ES6", "DOM", "ESNext"], "target": "ESNext", - "module": "ESNext", - "moduleResolution": "node", + "module": "NodeNext", + "moduleResolution": "NodeNext", "baseUrl": ".", "outDir": "dist", "allowJs": true, @@ -22,5 +22,5 @@ "skipLibCheck": true }, "exclude": ["node_modules"], - "include": ["./src/*.ts", "./src/**/*", "./test", "global.d.ts"] + "include": ["./src/*.ts", "./src/**/*", "./test/*.ts", "./test/**/*.ts", "global.d.ts"] }