diff --git a/.eslintignore b/.eslintignore index 85f5562..e4af3ac 100644 --- a/.eslintignore +++ b/.eslintignore @@ -2,3 +2,7 @@ node_modules artifacts cache coverage +gasReporterOutput.json +dist +rollup.cache +docs diff --git a/.prettierignore b/.prettierignore index f268596..6f71d1d 100644 --- a/.prettierignore +++ b/.prettierignore @@ -1,5 +1,7 @@ node_modules artifacts cache -coverage* +coverage gasReporterOutput.json +dist +rollup.cache diff --git a/cosign-server/tsconfig.json b/cosign-server/tsconfig.json index cbea026..39e27fb 100644 --- a/cosign-server/tsconfig.json +++ b/cosign-server/tsconfig.json @@ -1,105 +1,105 @@ { - "compilerOptions": { - /* Visit https://aka.ms/tsconfig.json to read more about this file */ + "compilerOptions": { + /* Visit https://aka.ms/tsconfig.json to read more about this file */ - /* Projects */ - // "incremental": true, /* Enable incremental compilation */ - // "composite": true, /* Enable constraints that allow a TypeScript project to be used with project references. */ - // "tsBuildInfoFile": "./", /* Specify the folder for .tsbuildinfo incremental compilation files. */ - // "disableSourceOfProjectReferenceRedirect": true, /* Disable preferring source files instead of declaration files when referencing composite projects */ - // "disableSolutionSearching": true, /* Opt a project out of multi-project reference checking when editing. */ - // "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */ + /* Projects */ + // "incremental": true, /* Enable incremental compilation */ + // "composite": true, /* Enable constraints that allow a TypeScript project to be used with project references. */ + // "tsBuildInfoFile": "./", /* Specify the folder for .tsbuildinfo incremental compilation files. */ + // "disableSourceOfProjectReferenceRedirect": true, /* Disable preferring source files instead of declaration files when referencing composite projects */ + // "disableSolutionSearching": true, /* Opt a project out of multi-project reference checking when editing. */ + // "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */ - /* Language and Environment */ - "target": "es2021" /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */, - "lib": [ - "es2021" - ] /* Specify a set of bundled library declaration files that describe the target runtime environment. */, - "jsx": "react" /* Specify what JSX code is generated. */, - // "experimentalDecorators": true, /* Enable experimental support for TC39 stage 2 draft decorators. */ - // "emitDecoratorMetadata": true, /* Emit design-type metadata for decorated declarations in source files. */ - // "jsxFactory": "", /* Specify the JSX factory function used when targeting React JSX emit, e.g. 'React.createElement' or 'h' */ - // "jsxFragmentFactory": "", /* Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. 'React.Fragment' or 'Fragment'. */ - // "jsxImportSource": "", /* Specify module specifier used to import the JSX factory functions when using `jsx: react-jsx*`.` */ - // "reactNamespace": "", /* Specify the object invoked for `createElement`. This only applies when targeting `react` JSX emit. */ - // "noLib": true, /* Disable including any library files, including the default lib.d.ts. */ - // "useDefineForClassFields": true, /* Emit ECMAScript-standard-compliant class fields. */ + /* Language and Environment */ + "target": "es2021" /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */, + "lib": [ + "es2021" + ] /* Specify a set of bundled library declaration files that describe the target runtime environment. */, + "jsx": "react" /* Specify what JSX code is generated. */, + // "experimentalDecorators": true, /* Enable experimental support for TC39 stage 2 draft decorators. */ + // "emitDecoratorMetadata": true, /* Emit design-type metadata for decorated declarations in source files. */ + // "jsxFactory": "", /* Specify the JSX factory function used when targeting React JSX emit, e.g. 'React.createElement' or 'h' */ + // "jsxFragmentFactory": "", /* Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. 'React.Fragment' or 'Fragment'. */ + // "jsxImportSource": "", /* Specify module specifier used to import the JSX factory functions when using `jsx: react-jsx*`.` */ + // "reactNamespace": "", /* Specify the object invoked for `createElement`. This only applies when targeting `react` JSX emit. */ + // "noLib": true, /* Disable including any library files, including the default lib.d.ts. */ + // "useDefineForClassFields": true, /* Emit ECMAScript-standard-compliant class fields. */ - /* Modules */ - "module": "es2022" /* Specify what module code is generated. */, - // "rootDir": "./", /* Specify the root folder within your source files. */ - "moduleResolution": "node" /* Specify how TypeScript looks up a file from a given module specifier. */, - // "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */ - // "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */ - // "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */ - // "typeRoots": [], /* Specify multiple folders that act like `./node_modules/@types`. */ - "types": [ - "@cloudflare/workers-types" - ] /* Specify type package names to be included without being referenced in a source file. */, - // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */ - "resolveJsonModule": true /* Enable importing .json files */, - // "noResolve": true, /* Disallow `import`s, `require`s or ``s from expanding the number of files TypeScript should add to a project. */ + /* Modules */ + "module": "es2022" /* Specify what module code is generated. */, + // "rootDir": "./", /* Specify the root folder within your source files. */ + "moduleResolution": "node" /* Specify how TypeScript looks up a file from a given module specifier. */, + // "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */ + // "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */ + // "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */ + // "typeRoots": [], /* Specify multiple folders that act like `./node_modules/@types`. */ + "types": [ + "@cloudflare/workers-types" + ] /* Specify type package names to be included without being referenced in a source file. */, + // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */ + "resolveJsonModule": true /* Enable importing .json files */, + // "noResolve": true, /* Disallow `import`s, `require`s or ``s from expanding the number of files TypeScript should add to a project. */ - /* JavaScript Support */ - "allowJs": true /* Allow JavaScript files to be a part of your program. Use the `checkJS` option to get errors from these files. */, - "checkJs": false /* Enable error reporting in type-checked JavaScript files. */, - // "maxNodeModuleJsDepth": 1, /* Specify the maximum folder depth used for checking JavaScript files from `node_modules`. Only applicable with `allowJs`. */ + /* JavaScript Support */ + "allowJs": true /* Allow JavaScript files to be a part of your program. Use the `checkJS` option to get errors from these files. */, + "checkJs": false /* Enable error reporting in type-checked JavaScript files. */, + // "maxNodeModuleJsDepth": 1, /* Specify the maximum folder depth used for checking JavaScript files from `node_modules`. Only applicable with `allowJs`. */ - /* Emit */ - // "declaration": true, /* Generate .d.ts files from TypeScript and JavaScript files in your project. */ - // "declarationMap": true, /* Create sourcemaps for d.ts files. */ - // "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */ - // "sourceMap": true, /* Create source map files for emitted JavaScript files. */ - // "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If `declaration` is true, also designates a file that bundles all .d.ts output. */ - // "outDir": "./", /* Specify an output folder for all emitted files. */ - // "removeComments": true, /* Disable emitting comments. */ - "noEmit": true /* Disable emitting files from a compilation. */, - // "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */ - // "importsNotUsedAsValues": "remove", /* Specify emit/checking behavior for imports that are only used for types */ - // "downlevelIteration": true, /* Emit more compliant, but verbose and less performant JavaScript for iteration. */ - // "sourceRoot": "", /* Specify the root path for debuggers to find the reference source code. */ - // "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */ - // "inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */ - // "inlineSources": true, /* Include source code in the sourcemaps inside the emitted JavaScript. */ - // "emitBOM": true, /* Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files. */ - // "newLine": "crlf", /* Set the newline character for emitting files. */ - // "stripInternal": true, /* Disable emitting declarations that have `@internal` in their JSDoc comments. */ - // "noEmitHelpers": true, /* Disable generating custom helper functions like `__extends` in compiled output. */ - // "noEmitOnError": true, /* Disable emitting files if any type checking errors are reported. */ - // "preserveConstEnums": true, /* Disable erasing `const enum` declarations in generated code. */ - // "declarationDir": "./", /* Specify the output directory for generated declaration files. */ - // "preserveValueImports": true, /* Preserve unused imported values in the JavaScript output that would otherwise be removed. */ + /* Emit */ + // "declaration": true, /* Generate .d.ts files from TypeScript and JavaScript files in your project. */ + // "declarationMap": true, /* Create sourcemaps for d.ts files. */ + // "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */ + // "sourceMap": true, /* Create source map files for emitted JavaScript files. */ + // "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If `declaration` is true, also designates a file that bundles all .d.ts output. */ + // "outDir": "./", /* Specify an output folder for all emitted files. */ + // "removeComments": true, /* Disable emitting comments. */ + "noEmit": true /* Disable emitting files from a compilation. */, + // "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */ + // "importsNotUsedAsValues": "remove", /* Specify emit/checking behavior for imports that are only used for types */ + // "downlevelIteration": true, /* Emit more compliant, but verbose and less performant JavaScript for iteration. */ + // "sourceRoot": "", /* Specify the root path for debuggers to find the reference source code. */ + // "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */ + // "inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */ + // "inlineSources": true, /* Include source code in the sourcemaps inside the emitted JavaScript. */ + // "emitBOM": true, /* Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files. */ + // "newLine": "crlf", /* Set the newline character for emitting files. */ + // "stripInternal": true, /* Disable emitting declarations that have `@internal` in their JSDoc comments. */ + // "noEmitHelpers": true, /* Disable generating custom helper functions like `__extends` in compiled output. */ + // "noEmitOnError": true, /* Disable emitting files if any type checking errors are reported. */ + // "preserveConstEnums": true, /* Disable erasing `const enum` declarations in generated code. */ + // "declarationDir": "./", /* Specify the output directory for generated declaration files. */ + // "preserveValueImports": true, /* Preserve unused imported values in the JavaScript output that would otherwise be removed. */ - /* Interop Constraints */ - "isolatedModules": true /* Ensure that each file can be safely transpiled without relying on other imports. */, - "allowSyntheticDefaultImports": true /* Allow 'import x from y' when a module doesn't have a default export. */, - // "esModuleInterop": true /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables `allowSyntheticDefaultImports` for type compatibility. */, - // "preserveSymlinks": true, /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */ - "forceConsistentCasingInFileNames": true /* Ensure that casing is correct in imports. */, + /* Interop Constraints */ + "isolatedModules": true /* Ensure that each file can be safely transpiled without relying on other imports. */, + "allowSyntheticDefaultImports": true /* Allow 'import x from y' when a module doesn't have a default export. */, + // "esModuleInterop": true /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables `allowSyntheticDefaultImports` for type compatibility. */, + // "preserveSymlinks": true, /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */ + "forceConsistentCasingInFileNames": true /* Ensure that casing is correct in imports. */, - /* Type Checking */ - "strict": true /* Enable all strict type-checking options. */, - // "noImplicitAny": true, /* Enable error reporting for expressions and declarations with an implied `any` type.. */ - // "strictNullChecks": true, /* When type checking, take into account `null` and `undefined`. */ - // "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */ - // "strictBindCallApply": true, /* Check that the arguments for `bind`, `call`, and `apply` methods match the original function. */ - // "strictPropertyInitialization": true, /* Check for class properties that are declared but not set in the constructor. */ - // "noImplicitThis": true, /* Enable error reporting when `this` is given the type `any`. */ - // "useUnknownInCatchVariables": true, /* Type catch clause variables as 'unknown' instead of 'any'. */ - // "alwaysStrict": true, /* Ensure 'use strict' is always emitted. */ - // "noUnusedLocals": true, /* Enable error reporting when a local variables aren't read. */ - // "noUnusedParameters": true, /* Raise an error when a function parameter isn't read */ - // "exactOptionalPropertyTypes": true, /* Interpret optional property types as written, rather than adding 'undefined'. */ - // "noImplicitReturns": true, /* Enable error reporting for codepaths that do not explicitly return in a function. */ - // "noFallthroughCasesInSwitch": true, /* Enable error reporting for fallthrough cases in switch statements. */ - // "noUncheckedIndexedAccess": true, /* Include 'undefined' in index signature results */ - // "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an override modifier. */ - // "noPropertyAccessFromIndexSignature": true, /* Enforces using indexed accessors for keys declared using an indexed type */ - // "allowUnusedLabels": true, /* Disable error reporting for unused labels. */ - // "allowUnreachableCode": true, /* Disable error reporting for unreachable code. */ + /* Type Checking */ + "strict": true /* Enable all strict type-checking options. */, + // "noImplicitAny": true, /* Enable error reporting for expressions and declarations with an implied `any` type.. */ + // "strictNullChecks": true, /* When type checking, take into account `null` and `undefined`. */ + // "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */ + // "strictBindCallApply": true, /* Check that the arguments for `bind`, `call`, and `apply` methods match the original function. */ + // "strictPropertyInitialization": true, /* Check for class properties that are declared but not set in the constructor. */ + // "noImplicitThis": true, /* Enable error reporting when `this` is given the type `any`. */ + // "useUnknownInCatchVariables": true, /* Type catch clause variables as 'unknown' instead of 'any'. */ + // "alwaysStrict": true, /* Ensure 'use strict' is always emitted. */ + // "noUnusedLocals": true, /* Enable error reporting when a local variables aren't read. */ + // "noUnusedParameters": true, /* Raise an error when a function parameter isn't read */ + // "exactOptionalPropertyTypes": true, /* Interpret optional property types as written, rather than adding 'undefined'. */ + // "noImplicitReturns": true, /* Enable error reporting for codepaths that do not explicitly return in a function. */ + // "noFallthroughCasesInSwitch": true, /* Enable error reporting for fallthrough cases in switch statements. */ + // "noUncheckedIndexedAccess": true, /* Include 'undefined' in index signature results */ + // "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an override modifier. */ + // "noPropertyAccessFromIndexSignature": true, /* Enforces using indexed accessors for keys declared using an indexed type */ + // "allowUnusedLabels": true, /* Disable error reporting for unused labels. */ + // "allowUnreachableCode": true, /* Disable error reporting for unreachable code. */ - /* Completeness */ - // "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */ - "skipLibCheck": true /* Skip type checking all .d.ts files. */ - } + /* Completeness */ + // "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */ + "skipLibCheck": true /* Skip type checking all .d.ts files. */ + } } diff --git a/hardhat.config.ts b/hardhat.config.ts index 67561aa..0fb5b36 100644 --- a/hardhat.config.ts +++ b/hardhat.config.ts @@ -8,40 +8,41 @@ import 'hardhat-gas-reporter'; import 'hardhat-watcher'; import { HardhatUserConfig, task, types } from 'hardhat/config'; import 'solidity-coverage'; - -import { deploy } from './scripts/deploy'; -import { deployBA } from './scripts/deployBA'; -import { mint } from './scripts/mint'; -import { ownerMint } from './scripts/ownerMint'; -import { setBaseURI } from './scripts/setBaseURI'; -import { setCrossmintAddress } from './scripts/setCrossmintAddress'; -import { setGlobalWalletLimit } from './scripts/setGlobalWalletLimit'; -import { setMaxMintableSupply } from './scripts/setMaxMintableSupply'; -import { setMintable } from './scripts/setMintable'; -import { setStages } from './scripts/setStages'; -import { setTimestampExpirySeconds } from './scripts/setTimestampExpirySeconds'; -import { transferOwnership } from './scripts/transferOwnership'; -import { setStartAndEndTimeUnixSeconds } from './scripts/setStartAndEndTimeUnixSeconds'; -import { setMinContributionInWei } from './scripts/setMinContributionInWei'; -import { sendRefund } from './scripts/sendRefund'; -import { sendRefundBatch } from './scripts/sendRefundBatch'; -import { sendTokensAndRefund } from './scripts/sendTokensAndRefund'; -import { sendTokensAndRefundBatch } from './scripts/sendTokensAndRefundBatch'; -import { setPrice } from './scripts/setPrice'; -import { getPrice } from './scripts/dev/getPrice'; -import { getStartTimeBA } from './scripts/dev/getStartTimeBA'; -import { getEndTimeBA } from './scripts/dev/getEndTimeBA'; -import { getMinContributionInWei } from './scripts/dev/getMinContributionInWei'; -import { deployOnft } from './scripts/deployOnft'; -import { setOnftMinDstGas } from './scripts/setOnftMinDstGas'; -import { setTrustedRemote } from './scripts/setTrustedRemote'; -import { sendOnft } from './scripts/sendOnft'; -import { deployOwnedRegistrant } from './scripts/deployOwnedRegistrant'; -import { getContractCodehash } from './scripts/dev/getContractCodehash'; -import { deploy721BatchTransfer } from './scripts/dev/deploy721BatchTransfer'; -import { send721Batch } from './scripts/send721Batch'; -import { freezeTrading } from './scripts/freezeTrading'; -import { thawTrading } from './scripts/thawTrading'; +import { + setStages, + setMintable, + deploy, + setBaseURI, + setCrossmintAddress, + mint, + ownerMint, + setGlobalWalletLimit, + setMaxMintableSupply, + deployBA, + setTimestampExpirySeconds, + transferOwnership, + setStartAndEndTimeUnixSeconds, + setMinContributionInWei, + sendRefund, + sendRefundBatch, + sendTokensAndRefund, + sendTokensAndRefundBatch, + getMinContributionInWei, + getStartTimeBA, + getEndTimeBA, + getPrice, + setPrice, + deployOnft, + setTrustedRemote, + setOnftMinDstGas, + sendOnft, + deployOwnedRegistrant, + getContractCodehash, + deploy721BatchTransfer, + send721Batch, + freezeTrading, + thawTrading, +} from './scripts'; const config: HardhatUserConfig = { solidity: { @@ -78,8 +79,7 @@ const config: HardhatUserConfig = { process.env.PRIVATE_KEY !== undefined ? [process.env.PRIVATE_KEY] : [], }, sepolia: { - url: - process.env.SEPOLIA_URL || 'https://rpc.sepolia.org', + url: process.env.SEPOLIA_URL || 'https://rpc.sepolia.org', accounts: process.env.PRIVATE_KEY !== undefined ? [process.env.PRIVATE_KEY] : [], }, @@ -102,7 +102,7 @@ const config: HardhatUserConfig = { url: process.env.FUJI_URL || 'https://api.avax-test.network/ext/bc/C/rpc', accounts: process.env.PRIVATE_KEY !== undefined ? [process.env.PRIVATE_KEY] : [], - } + }, }, gasReporter: { enabled: process.env.REPORT_GAS !== undefined, @@ -117,7 +117,12 @@ task('setStages', 'Set stages for ERC721M') .addParam('contract', 'contract address') .addParam('stages', 'stages json file') .addOptionalParam('gaspricegwei', 'Set gas price in Gwei') - .addOptionalParam('gaslimit', 'Set maximum gas units to spend on transaction', 500000, types.int) + .addOptionalParam( + 'gaslimit', + 'Set maximum gas units to spend on transaction', + 500000, + types.int, + ) .setAction(setStages); task('setMintable', 'Set mintable state for ERC721M') @@ -145,21 +150,48 @@ task('deploy', 'Deploy ERC721M') .addOptionalParam('autoapproveaddress', 'auto approve address') .addParam( 'increasesupply', - 'whether or not to enable increasing supply behavior', false, + 'whether or not to enable increasing supply behavior', + false, + types.boolean, + ) + .addParam( + 'pausable', + 'whether to allow transfers to be paused', + false, + types.boolean, + ) + .addParam( + 'useoperatorfilterer', + 'whether or not to use operator filterer', + false, types.boolean, ) - .addParam('pausable', 'whether to allow transfers to be paused', false, types.boolean) - .addParam('useoperatorfilterer', 'whether or not to use operator filterer', false, types.boolean) .addParam( 'openedition', 'whether or not a open edition mint (unlimited supply, 999,999,999)', false, types.boolean, ) - .addOptionalParam('useerc721c', 'whether or not to use ERC721C', true, types.boolean) - .addOptionalParam('useerc2198', 'whether or not to use ERC2198', true, types.boolean) - .addOptionalParam('erc2198royaltyreceiver', 'erc2198 royalty receiver address') - .addOptionalParam('erc2198royaltyfeenumerator', 'erc2198 royalty fee numerator') + .addOptionalParam( + 'useerc721c', + 'whether or not to use ERC721C', + true, + types.boolean, + ) + .addOptionalParam( + 'useerc2198', + 'whether or not to use ERC2198', + true, + types.boolean, + ) + .addOptionalParam( + 'erc2198royaltyreceiver', + 'erc2198 royalty receiver address', + ) + .addOptionalParam( + 'erc2198royaltyfeenumerator', + 'erc2198 royalty fee numerator', + ) .addOptionalParam('gaspricegwei', 'Set gas price in Gwei') .addOptionalParam('gaslimit', 'Set maximum gas units to spend on transaction') .setAction(deploy); @@ -168,7 +200,12 @@ task('setBaseURI', 'Set the base uri') .addParam('uri', 'uri') .addParam('contract', 'contract address') .addOptionalParam('gaspricegwei', 'Set gas price in Gwei') - .addOptionalParam('gaslimit', 'Set maximum gas units to spend on transaction', 500000, types.int) + .addOptionalParam( + 'gaslimit', + 'Set maximum gas units to spend on transaction', + 500000, + types.int, + ) .setAction(setBaseURI); task('setCrossmintAddress', 'Set crossmint address') @@ -349,21 +386,32 @@ task('sendOnft', 'Send tokens to target network') .setAction(sendOnft); task('deployOwnedRegistrant', 'Deploy OwnedRegistrant') - .addParam('newowner', 'new owner address', '0x0000000000000000000000000000000000000000') + .addParam( + 'newowner', + 'new owner address', + '0x0000000000000000000000000000000000000000', + ) .setAction(deployOwnedRegistrant); task('getContractCodehash', 'Get the code hash of a contract') .addParam('contract', 'contract address') .setAction(getContractCodehash); -task('deploy721BatchTransfer', 'Deploy ERC721BatchTransfer') - .setAction(deploy721BatchTransfer); +task('deploy721BatchTransfer', 'Deploy ERC721BatchTransfer').setAction( + deploy721BatchTransfer, +); task('send721Batch', 'Send ERC721 tokens in batch') .addParam('contract', 'contract address') - .addOptionalParam('transferfile', 'path to the file with the transfer details') + .addOptionalParam( + 'transferfile', + 'path to the file with the transfer details', + ) .addOptionalParam('to', 'recipient address (if not using transferFile)') - .addOptionalParam('tokenids', 'token ids (if not using transferFile), separate with comma') + .addOptionalParam( + 'tokenids', + 'token ids (if not using transferFile), separate with comma', + ) .setAction(send721Batch); task('freezeTrading', 'Freeze trading for 721Cv2') diff --git a/package-lock.json b/package-lock.json index 9390422..5cbb535 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@magiceden-oss/erc721m", - "version": "0.0.11", + "version": "0.1.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@magiceden-oss/erc721m", - "version": "0.0.11", + "version": "0.1.0", "dependencies": { "@inquirer/prompts": "^2.2.0", "@layerzerolabs/solidity-examples": "^0.0.13", @@ -49,8 +49,8 @@ "hardhat-watcher": "^2.5.0", "lint-staged": "^12.4.1", "merkletreejs": "^0.2.32", - "prettier": "^2.7.1", - "prettier-plugin-solidity": "^1.0.0-beta.24", + "prettier": "^3.2.1", + "prettier-plugin-solidity": "^1.3.1", "rollup": "^3.3.0", "rollup-plugin-copy": "^3.4.0", "solhint": "^3.3.7", @@ -6051,11 +6051,6 @@ "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.12.0.tgz", "integrity": "sha512-c98Bf3tPniI+scsdk237ku1Dc3ujXQTSgyiPUDEOe7tRkhrqridvh8klBv0HCEso1OLOYcHuCv/cS6DNxKH+ZA==" }, - "node_modules/emoji-regex": { - "version": "10.1.0", - "dev": true, - "license": "MIT" - }, "node_modules/encode-utf8": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/encode-utf8/-/encode-utf8-1.0.3.tgz", @@ -20961,14 +20956,15 @@ } }, "node_modules/prettier": { - "version": "2.7.1", + "version": "3.2.5", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-3.2.5.tgz", + "integrity": "sha512-3/GWa9aOC0YeD7LUfvOG2NiDyhOWRvt1k+rcKhOuYnMY24iiCphgneUfJDyFXd6rZCAnuLBv6UeAULtrhT/F4A==", "dev": true, - "license": "MIT", "bin": { - "prettier": "bin-prettier.js" + "prettier": "bin/prettier.cjs" }, "engines": { - "node": ">=10.13.0" + "node": ">=14" }, "funding": { "url": "https://github.com/prettier/prettier?sponsor=1" @@ -20987,51 +20983,26 @@ } }, "node_modules/prettier-plugin-solidity": { - "version": "1.0.0-beta.24", + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/prettier-plugin-solidity/-/prettier-plugin-solidity-1.3.1.tgz", + "integrity": "sha512-MN4OP5I2gHAzHZG1wcuJl0FsLS3c4Cc5494bbg+6oQWBPuEamjwDvmGfFMZ6NFzsh3Efd9UUxeT7ImgjNH4ozA==", "dev": true, - "license": "MIT", "dependencies": { - "@solidity-parser/parser": "^0.14.3", - "emoji-regex": "^10.1.0", - "escape-string-regexp": "^4.0.0", - "semver": "^7.3.7", - "solidity-comments-extractor": "^0.0.7", - "string-width": "^4.2.3" + "@solidity-parser/parser": "^0.17.0", + "semver": "^7.5.4", + "solidity-comments-extractor": "^0.0.8" }, "engines": { - "node": ">=12" + "node": ">=16" }, "peerDependencies": { - "prettier": "^2.3.0" - } - }, - "node_modules/prettier-plugin-solidity/node_modules/is-fullwidth-code-point": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", - "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==", - "dev": true, - "engines": { - "node": ">=8" - } - }, - "node_modules/prettier-plugin-solidity/node_modules/string-width": { - "version": "4.2.3", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", - "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", - "dev": true, - "dependencies": { - "emoji-regex": "^8.0.0", - "is-fullwidth-code-point": "^3.0.0", - "strip-ansi": "^6.0.1" - }, - "engines": { - "node": ">=8" + "prettier": ">=2.3.0" } }, - "node_modules/prettier-plugin-solidity/node_modules/string-width/node_modules/emoji-regex": { - "version": "8.0.0", - "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", - "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==", + "node_modules/prettier-plugin-solidity/node_modules/@solidity-parser/parser": { + "version": "0.17.0", + "resolved": "https://registry.npmjs.org/@solidity-parser/parser/-/parser-0.17.0.tgz", + "integrity": "sha512-Nko8R0/kUo391jsEHHxrGM07QFdnPGvlmox4rmH0kNiNAashItAilhy4Mv4pK5gQmW5f4sXAF58fwJbmlkGcVw==", "dev": true }, "node_modules/process-nextick-args": { @@ -21906,8 +21877,9 @@ } }, "node_modules/semver": { - "version": "7.3.7", - "license": "ISC", + "version": "7.6.0", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.6.0.tgz", + "integrity": "sha512-EnwXhrlwXMk9gKu5/flx5sv/an57AkRplG3hTK68W7FRDN+k+OWBj65M7719OkA82XLBxrcX0KSHj+X5COhOVg==", "dependencies": { "lru-cache": "^6.0.0" }, @@ -22722,9 +22694,9 @@ "integrity": "sha512-Pr5sCAj1SFqzwFZw1HPKSq0PehlQNdM8GwKyAVYh2DOn7/cCK8LUKD1HeHnKtTgBW7hi9h4nnnan7hpAg5RhWQ==" }, "node_modules/solidity-comments-extractor": { - "version": "0.0.7", - "resolved": "https://registry.npmjs.org/solidity-comments-extractor/-/solidity-comments-extractor-0.0.7.tgz", - "integrity": "sha512-wciNMLg/Irp8OKGrh3S2tfvZiZ0NEyILfcRCXCD4mp7SgK/i9gzLfhY2hY7VMCQJ3kH9UB9BzNdibIVMchzyYw==", + "version": "0.0.8", + "resolved": "https://registry.npmjs.org/solidity-comments-extractor/-/solidity-comments-extractor-0.0.8.tgz", + "integrity": "sha512-htM7Vn6LhHreR+EglVMd2s+sZhcXAirB1Zlyrv5zBuTxieCvjfnRpd7iZk75m/u6NOlEyQ94C6TWbBn2cY7w8g==", "dev": true }, "node_modules/solidity-coverage": { @@ -24066,6 +24038,21 @@ "mkdirp": "bin/cmd.js" } }, + "node_modules/ts-generator/node_modules/prettier": { + "version": "2.8.8", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-2.8.8.tgz", + "integrity": "sha512-tdN8qQGvNjw4CHbY+XXk0JgCXn9QiF21a55rBe5LJAU+kDyC4WQn4+awm2Xfk2lQMk5fKup9XgzTZtGkjBdP9Q==", + "dev": true, + "bin": { + "prettier": "bin-prettier.js" + }, + "engines": { + "node": ">=10.13.0" + }, + "funding": { + "url": "https://github.com/prettier/prettier?sponsor=1" + } + }, "node_modules/ts-generator/node_modules/ts-essentials": { "version": "1.0.4", "resolved": "https://registry.npmjs.org/ts-essentials/-/ts-essentials-1.0.4.tgz", @@ -24239,6 +24226,21 @@ "typescript": ">=4.3.0" } }, + "node_modules/typechain/node_modules/prettier": { + "version": "2.8.8", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-2.8.8.tgz", + "integrity": "sha512-tdN8qQGvNjw4CHbY+XXk0JgCXn9QiF21a55rBe5LJAU+kDyC4WQn4+awm2Xfk2lQMk5fKup9XgzTZtGkjBdP9Q==", + "dev": true, + "bin": { + "prettier": "bin-prettier.js" + }, + "engines": { + "node": ">=10.13.0" + }, + "funding": { + "url": "https://github.com/prettier/prettier?sponsor=1" + } + }, "node_modules/typedarray": { "version": "0.0.6", "resolved": "https://registry.npmjs.org/typedarray/-/typedarray-0.0.6.tgz", @@ -29373,10 +29375,6 @@ } } }, - "emoji-regex": { - "version": "10.1.0", - "dev": true - }, "encode-utf8": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/encode-utf8/-/encode-utf8-1.0.3.tgz", @@ -40692,7 +40690,9 @@ "dev": true }, "prettier": { - "version": "2.7.1", + "version": "3.2.5", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-3.2.5.tgz", + "integrity": "sha512-3/GWa9aOC0YeD7LUfvOG2NiDyhOWRvt1k+rcKhOuYnMY24iiCphgneUfJDyFXd6rZCAnuLBv6UeAULtrhT/F4A==", "dev": true }, "prettier-linter-helpers": { @@ -40705,41 +40705,21 @@ } }, "prettier-plugin-solidity": { - "version": "1.0.0-beta.24", + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/prettier-plugin-solidity/-/prettier-plugin-solidity-1.3.1.tgz", + "integrity": "sha512-MN4OP5I2gHAzHZG1wcuJl0FsLS3c4Cc5494bbg+6oQWBPuEamjwDvmGfFMZ6NFzsh3Efd9UUxeT7ImgjNH4ozA==", "dev": true, "requires": { - "@solidity-parser/parser": "^0.14.3", - "emoji-regex": "^10.1.0", - "escape-string-regexp": "^4.0.0", - "semver": "^7.3.7", - "solidity-comments-extractor": "^0.0.7", - "string-width": "^4.2.3" + "@solidity-parser/parser": "^0.17.0", + "semver": "^7.5.4", + "solidity-comments-extractor": "^0.0.8" }, "dependencies": { - "is-fullwidth-code-point": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", - "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==", + "@solidity-parser/parser": { + "version": "0.17.0", + "resolved": "https://registry.npmjs.org/@solidity-parser/parser/-/parser-0.17.0.tgz", + "integrity": "sha512-Nko8R0/kUo391jsEHHxrGM07QFdnPGvlmox4rmH0kNiNAashItAilhy4Mv4pK5gQmW5f4sXAF58fwJbmlkGcVw==", "dev": true - }, - "string-width": { - "version": "4.2.3", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", - "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", - "dev": true, - "requires": { - "emoji-regex": "^8.0.0", - "is-fullwidth-code-point": "^3.0.0", - "strip-ansi": "^6.0.1" - }, - "dependencies": { - "emoji-regex": { - "version": "8.0.0", - "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", - "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==", - "dev": true - } - } } } }, @@ -41387,7 +41367,9 @@ } }, "semver": { - "version": "7.3.7", + "version": "7.6.0", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.6.0.tgz", + "integrity": "sha512-EnwXhrlwXMk9gKu5/flx5sv/an57AkRplG3hTK68W7FRDN+k+OWBj65M7719OkA82XLBxrcX0KSHj+X5COhOVg==", "requires": { "lru-cache": "^6.0.0" }, @@ -42010,9 +41992,9 @@ "integrity": "sha512-Pr5sCAj1SFqzwFZw1HPKSq0PehlQNdM8GwKyAVYh2DOn7/cCK8LUKD1HeHnKtTgBW7hi9h4nnnan7hpAg5RhWQ==" }, "solidity-comments-extractor": { - "version": "0.0.7", - "resolved": "https://registry.npmjs.org/solidity-comments-extractor/-/solidity-comments-extractor-0.0.7.tgz", - "integrity": "sha512-wciNMLg/Irp8OKGrh3S2tfvZiZ0NEyILfcRCXCD4mp7SgK/i9gzLfhY2hY7VMCQJ3kH9UB9BzNdibIVMchzyYw==", + "version": "0.0.8", + "resolved": "https://registry.npmjs.org/solidity-comments-extractor/-/solidity-comments-extractor-0.0.8.tgz", + "integrity": "sha512-htM7Vn6LhHreR+EglVMd2s+sZhcXAirB1Zlyrv5zBuTxieCvjfnRpd7iZk75m/u6NOlEyQ94C6TWbBn2cY7w8g==", "dev": true }, "solidity-coverage": { @@ -43060,6 +43042,12 @@ "minimist": "^1.2.6" } }, + "prettier": { + "version": "2.8.8", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-2.8.8.tgz", + "integrity": "sha512-tdN8qQGvNjw4CHbY+XXk0JgCXn9QiF21a55rBe5LJAU+kDyC4WQn4+awm2Xfk2lQMk5fKup9XgzTZtGkjBdP9Q==", + "dev": true + }, "ts-essentials": { "version": "1.0.4", "resolved": "https://registry.npmjs.org/ts-essentials/-/ts-essentials-1.0.4.tgz", @@ -43177,6 +43165,14 @@ "prettier": "^2.3.1", "ts-command-line-args": "^2.2.0", "ts-essentials": "^7.0.1" + }, + "dependencies": { + "prettier": { + "version": "2.8.8", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-2.8.8.tgz", + "integrity": "sha512-tdN8qQGvNjw4CHbY+XXk0JgCXn9QiF21a55rBe5LJAU+kDyC4WQn4+awm2Xfk2lQMk5fKup9XgzTZtGkjBdP9Q==", + "dev": true + } } }, "typedarray": { diff --git a/package.json b/package.json index 979bb98..c309f05 100644 --- a/package.json +++ b/package.json @@ -74,8 +74,8 @@ "hardhat-watcher": "^2.5.0", "lint-staged": "^12.4.1", "merkletreejs": "^0.2.32", - "prettier": "^2.7.1", - "prettier-plugin-solidity": "^1.0.0-beta.24", + "prettier": "^3.2.1", + "prettier-plugin-solidity": "^1.3.1", "rollup": "^3.3.0", "rollup-plugin-copy": "^3.4.0", "solhint": "^3.3.7", @@ -87,10 +87,10 @@ "lint-staged": { "*.{js,ts}": [ "eslint --ext .ts,.js scripts test --fix", - "prettier --write" + "prettier --write scripts cosign-server test hardhat.config.ts" ], "*.sol": [ - "prettier --write" + "prettier --write contracts" ] } } diff --git a/scripts/common/constants.ts b/scripts/common/constants.ts index 22bf500..376259c 100644 --- a/scripts/common/constants.ts +++ b/scripts/common/constants.ts @@ -61,8 +61,9 @@ export const ChainIds: Record = { 'zksync-testnet': 10165, }; -export const ERC721BatchTransferContract = '0x38F7ba911f7efc434D29D6E39c814E9d4De3FEef'; +export const ERC721BatchTransferContract = + '0x38F7ba911f7efc434D29D6E39c814E9d4De3FEef'; export const ERC721CV2_VALIDATOR = '0x721C00182a990771244d7A71B9FA2ea789A3b433'; export const ERC721CV2_FREEZE_LEVEL = 4; -export const ERC721CV2_EMPTY_LIST = 4; \ No newline at end of file +export const ERC721CV2_EMPTY_LIST = 4; diff --git a/scripts/deploy.ts b/scripts/deploy.ts index f7641e7..2e690c4 100644 --- a/scripts/deploy.ts +++ b/scripts/deploy.ts @@ -10,7 +10,7 @@ import { ContractDetails } from './common/constants'; import { checkCodeVersion, estimateGas } from './utils/helper'; import { Overrides } from 'ethers'; -export interface IDeployParams { +interface IDeployParams { name: string; symbol: string; tokenurisuffix: string; @@ -36,7 +36,7 @@ export const deploy = async ( args: IDeployParams, hre: HardhatRuntimeEnvironment, ) => { - if (!await checkCodeVersion()) { + if (!(await checkCodeVersion())) { return; } @@ -130,19 +130,25 @@ export const deploy = async ( console.log(`${contractName} deployed to:`, contract.address); console.log('run the following command to verify the contract:'); - const paramsStr = params.map((param) => { - if (hre.ethers.BigNumber.isBigNumber(param)) { - return `"${param.toString()}"`; - } - return `"${param}"`; - }).join(' '); + const paramsStr = params + .map((param) => { + if (hre.ethers.BigNumber.isBigNumber(param)) { + return `"${param.toString()}"`; + } + return `"${param}"`; + }) + .join(' '); - console.log(`npx hardhat verify --network ${hre.network.name} ${contract.address} ${paramsStr}`); + console.log( + `npx hardhat verify --network ${hre.network.name} ${contract.address} ${paramsStr}`, + ); // Set security policy to ME default if (args.useerc721c) { console.log('[ERC721CM] Setting security policy to ME default...'); - const ERC721CM = await hre.ethers.getContractFactory(ContractDetails.ERC721CM.name); + const ERC721CM = await hre.ethers.getContractFactory( + ContractDetails.ERC721CM.name, + ); const erc721cm = ERC721CM.attach(contract.address); const tx = await erc721cm.setToDefaultSecurityPolicy(); console.log('[ERC721CM] Security policy set'); diff --git a/scripts/deployBA.ts b/scripts/deployBA.ts index 8a30c40..a2b4ece 100644 --- a/scripts/deployBA.ts +++ b/scripts/deployBA.ts @@ -9,7 +9,7 @@ import { ContractDetails } from './common/constants'; import { HardhatRuntimeEnvironment } from 'hardhat/types'; import { estimateGas } from './utils/helper'; -export interface IDeployParams { +interface IDeployParams { name: string; symbol: string; tokenurisuffix: string; @@ -73,7 +73,7 @@ export const deployBA = async ( await estimateGas(hre, contractFactory.getDeployTransaction(...params)); - if (!await confirm({ message: 'Continue to deploy?' })) return; + if (!(await confirm({ message: 'Continue to deploy?' }))) return; const contract = await contractFactory.deploy(...params); await contract.deployed(); diff --git a/scripts/deployOnft.ts b/scripts/deployOnft.ts index d09d0be..695f425 100644 --- a/scripts/deployOnft.ts +++ b/scripts/deployOnft.ts @@ -8,7 +8,7 @@ import { confirm } from '@inquirer/prompts'; import { HardhatRuntimeEnvironment } from 'hardhat/types'; import { ContractDetails, LayerZeroEndpoints } from './common/constants'; -export interface IDeployParams { +interface IDeployParams { ismintingcontract: boolean; name: string; symbol: string; @@ -24,7 +24,6 @@ export const deployOnft = async ( args: IDeployParams, hre: HardhatRuntimeEnvironment, ) => { - let contractName; let deployParams; @@ -68,7 +67,7 @@ export const deployOnft = async ( ), ); - if (!await confirm({ message: 'Continue to deploy?' })) return; + if (!(await confirm({ message: 'Continue to deploy?' }))) return; const contract = await hre.ethers.getContractFactory(contractName); const erc721MOnft = await contract.deploy(...deployParams); diff --git a/scripts/deployOwnedRegistrant.ts b/scripts/deployOwnedRegistrant.ts index 7d10c2f..c8b7e1d 100644 --- a/scripts/deployOwnedRegistrant.ts +++ b/scripts/deployOwnedRegistrant.ts @@ -15,9 +15,7 @@ export const deployOwnedRegistrant = async ( const OwnedRegistrant = await hre.ethers.getContractFactory(contractName); - const params = [ - args.newowner - ] as const; + const params = [args.newowner] as const; console.log( `Constructor params: `, diff --git a/scripts/dev/deploy721BatchTransfer.ts b/scripts/dev/deploy721BatchTransfer.ts index c7176ba..c19f6b8 100644 --- a/scripts/dev/deploy721BatchTransfer.ts +++ b/scripts/dev/deploy721BatchTransfer.ts @@ -4,10 +4,13 @@ import { estimateGas } from '../utils/helper'; export const deploy721BatchTransfer = async ( args: {}, - hre: HardhatRuntimeEnvironment + hre: HardhatRuntimeEnvironment, ) => { const [signer] = await hre.ethers.getSigners(); - const factory = await hre.ethers.getContractFactory('ERC721BatchTransfer', signer); + const factory = await hre.ethers.getContractFactory( + 'ERC721BatchTransfer', + signer, + ); await estimateGas(hre, factory.getDeployTransaction()); @@ -16,6 +19,4 @@ export const deploy721BatchTransfer = async ( const contract = await factory.deploy(); await contract.deployed(); console.log('ERC721BatchTransfer deployed to:', contract.address); -} - - +}; diff --git a/scripts/dev/getContractCodehash.ts b/scripts/dev/getContractCodehash.ts index 7b4a412..c5d426c 100644 --- a/scripts/dev/getContractCodehash.ts +++ b/scripts/dev/getContractCodehash.ts @@ -2,11 +2,11 @@ import { HardhatRuntimeEnvironment } from 'hardhat/types'; export const getContractCodehash = async ( args: { contract: string }, - hre: HardhatRuntimeEnvironment + hre: HardhatRuntimeEnvironment, ) => { const [signer] = await hre.ethers.getSigners(); const provider = signer.provider; const code = await provider!.getCode(args.contract); const codehash = hre.ethers.utils.keccak256(code); console.log(codehash); -} +}; diff --git a/scripts/freezeTrading.ts b/scripts/freezeTrading.ts index 86ccfb3..0661085 100644 --- a/scripts/freezeTrading.ts +++ b/scripts/freezeTrading.ts @@ -1,6 +1,11 @@ import { confirm } from '@inquirer/prompts'; import { HardhatRuntimeEnvironment } from 'hardhat/types'; -import { ContractDetails, ERC721CV2_EMPTY_LIST, ERC721CV2_FREEZE_LEVEL, ERC721CV2_VALIDATOR } from './common/constants'; +import { + ContractDetails, + ERC721CV2_EMPTY_LIST, + ERC721CV2_FREEZE_LEVEL, + ERC721CV2_VALIDATOR, +} from './common/constants'; import { estimateGas } from './utils/helper'; export interface IFreezeTrading { @@ -16,20 +21,33 @@ export const freezeTrading = async ( hre: HardhatRuntimeEnvironment, ) => { const { ethers } = hre; - const factory = await ethers.getContractFactory(ContractDetails.ERC721CM.name); + const factory = await ethers.getContractFactory( + ContractDetails.ERC721CM.name, + ); const contract = factory.attach(args.contract); - const validator = args.validator?? ERC721CV2_VALIDATOR; - const level = args.level?? ERC721CV2_FREEZE_LEVEL; - const whitelistid = args.whitelistid?? ERC721CV2_EMPTY_LIST; - const permittedreceiverid = args.permittedreceiverid?? ERC721CV2_EMPTY_LIST; + const validator = args.validator ?? ERC721CV2_VALIDATOR; + const level = args.level ?? ERC721CV2_FREEZE_LEVEL; + const whitelistid = args.whitelistid ?? ERC721CV2_EMPTY_LIST; + const permittedreceiverid = args.permittedreceiverid ?? ERC721CV2_EMPTY_LIST; - const tx = await contract.populateTransaction.setToCustomValidatorAndSecurityPolicy(validator, level, whitelistid, permittedreceiverid); + const tx = + await contract.populateTransaction.setToCustomValidatorAndSecurityPolicy( + validator, + level, + whitelistid, + permittedreceiverid, + ); await estimateGas(hre, tx); console.log(`Going to freeze contract: ${args.contract}`); - if (!await confirm({ message: 'Continue?' })) return; + if (!(await confirm({ message: 'Continue?' }))) return; - const submittedTx = await contract.setToCustomValidatorAndSecurityPolicy(validator, level, whitelistid, permittedreceiverid); + const submittedTx = await contract.setToCustomValidatorAndSecurityPolicy( + validator, + level, + whitelistid, + permittedreceiverid, + ); console.log(`Submitted tx ${submittedTx.hash}`); await submittedTx.wait(); diff --git a/scripts/index.ts b/scripts/index.ts new file mode 100644 index 0000000..622474e --- /dev/null +++ b/scripts/index.ts @@ -0,0 +1,33 @@ +export { deploy } from './deploy'; +export * from './deployBA'; +export * from './mint'; +export * from './ownerMint'; +export * from './setBaseURI'; +export * from './setCrossmintAddress'; +export * from './setGlobalWalletLimit'; +export * from './setMaxMintableSupply'; +export * from './setMintable'; +export * from './setStages'; +export * from './setTimestampExpirySeconds'; +export * from './transferOwnership'; +export * from './setStartAndEndTimeUnixSeconds'; +export * from './setMinContributionInWei'; +export * from './sendRefund'; +export * from './sendRefundBatch'; +export * from './sendTokensAndRefund'; +export * from './sendTokensAndRefundBatch'; +export * from './setPrice'; +export * from './dev/getPrice'; +export * from './dev/getStartTimeBA'; +export * from './dev/getEndTimeBA'; +export * from './dev/getMinContributionInWei'; +export * from './deployOnft'; +export * from './setOnftMinDstGas'; +export * from './setTrustedRemote'; +export * from './sendOnft'; +export * from './deployOwnedRegistrant'; +export * from './dev/getContractCodehash'; +export * from './dev/deploy721BatchTransfer'; +export * from './send721Batch'; +export * from './freezeTrading'; +export * from './thawTrading'; diff --git a/scripts/ownerMint.ts b/scripts/ownerMint.ts index 34d3028..fd7919e 100644 --- a/scripts/ownerMint.ts +++ b/scripts/ownerMint.ts @@ -33,7 +33,7 @@ export const ownerMint = async ( const tx = await contract.populateTransaction.ownerMint(qty, to); if (!(await estimateGas(hre, tx, overrides))) return; console.log(`Going to mint ${qty.toNumber()} token(s) to ${to}`); - if (!await confirm({ message: 'Continue?' })) return; + if (!(await confirm({ message: 'Continue?' }))) return; const submittedTx = await contract.ownerMint(qty, to, overrides); diff --git a/scripts/send721Batch.ts b/scripts/send721Batch.ts index 114d9b2..1719aa0 100644 --- a/scripts/send721Batch.ts +++ b/scripts/send721Batch.ts @@ -18,13 +18,20 @@ export const send721Batch = async ( // check if the BatchTransfer721 contract has the approval to transfer the tokens const [signer] = await hre.ethers.getSigners(); - const erc721Contract = (await hre.ethers.getContractFactory('ERC721A')).attach(args.contract); - const approved = await erc721Contract.isApprovedForAll(signer.address , ERC721BatchTransferContract); + const erc721Contract = ( + await hre.ethers.getContractFactory('ERC721A') + ).attach(args.contract); + const approved = await erc721Contract.isApprovedForAll( + signer.address, + ERC721BatchTransferContract, + ); if (!approved) { - console.warn('ERC721BatchTransfer contract is not approved to transfer tokens. Approving...'); - await erc721Contract.setApprovalForAll(ERC721BatchTransferContract, true ); + console.warn( + 'ERC721BatchTransfer contract is not approved to transfer tokens. Approving...', + ); + await erc721Contract.setApprovalForAll(ERC721BatchTransferContract, true); console.log('Approved'); - } + } const tokenids = args.tokenids?.split(',').map((id) => parseInt(id)); const factory = await hre.ethers.getContractFactory('ERC721BatchTransfer'); @@ -35,18 +42,31 @@ export const send721Batch = async ( console.error('Missing required arguments: to, tokenIds'); return; } - const tx = await batchTransferContract.populateTransaction.safeBatchTransferToSingleWallet(args.contract, args.to, tokenids!); + const tx = + await batchTransferContract.populateTransaction.safeBatchTransferToSingleWallet( + args.contract, + args.to, + tokenids!, + ); await estimateGas(hre, tx); if (!(await confirm({ message: 'Continue to transfer?' }))) return; console.log(`Transferring tokens to ${args.to}...`); - const submittedTx = await batchTransferContract.safeBatchTransferToSingleWallet(args.contract, args.to, tokenids!); + const submittedTx = + await batchTransferContract.safeBatchTransferToSingleWallet( + args.contract, + args.to, + tokenids!, + ); console.log(`Submitted tx ${submittedTx.hash}`); await submittedTx.wait(); console.log('Tokens transferred'); } else { - const lines = fs.readFileSync(args.transferfile, 'utf-8').split('\n').filter(Boolean); + const lines = fs + .readFileSync(args.transferfile, 'utf-8') + .split('\n') + .filter(Boolean); const tos = []; const tokenIds = []; @@ -66,13 +86,23 @@ export const send721Batch = async ( return; } - const tx = await batchTransferContract.populateTransaction.safeBatchTransferToMultipleWallets(args.contract, tos, tokenIds); + const tx = + await batchTransferContract.populateTransaction.safeBatchTransferToMultipleWallets( + args.contract, + tos, + tokenIds, + ); await estimateGas(hre, tx); if (!(await confirm({ message: 'Continue to transfer?' }))) return; console.log(`Transferring tokens...`); - const submittedTx = await batchTransferContract.safeBatchTransferToMultipleWallets(args.contract, tos, tokenIds); + const submittedTx = + await batchTransferContract.safeBatchTransferToMultipleWallets( + args.contract, + tos, + tokenIds, + ); console.log(`Submitted tx ${submittedTx.hash}`); await submittedTx.wait(); console.log('Tokens transferred'); diff --git a/scripts/sendOnft.ts b/scripts/sendOnft.ts index 63f7b59..c70cd6b 100644 --- a/scripts/sendOnft.ts +++ b/scripts/sendOnft.ts @@ -13,43 +13,64 @@ export interface ISendOnftParams { } export const sendOnft = async ( - args: ISendOnftParams, - hre: HardhatRuntimeEnvironment, - ) => { - const supportedNetworks = Object.keys(ChainIds); - if (!supportedNetworks.includes(args.targetnetwork)) { - throw new Error(`Invalid network. Supported networks are: ${supportedNetworks.join(', ')}`); - } - - const { ethers } = hre; - const ERC721MOnft = await ethers.getContractFactory( - ContractDetails.ERC721MOnft.name, + args: ISendOnftParams, + hre: HardhatRuntimeEnvironment, +) => { + const supportedNetworks = Object.keys(ChainIds); + if (!supportedNetworks.includes(args.targetnetwork)) { + throw new Error( + `Invalid network. Supported networks are: ${supportedNetworks.join(', ')}`, ); - const contract = ERC721MOnft.attach(args.contract); + } - const signers = await ethers.getSigners(); - const owner = signers[0].address; - const targetChainId = ChainIds[args.targetnetwork]; - const newOwner = args.newowner ?? owner; - const refundAddress = args.refundaddress ?? owner; - const zeroPaymentAddress = args.refundaddress ?? ethers.constants.AddressZero; + const { ethers } = hre; + const ERC721MOnft = await ethers.getContractFactory( + ContractDetails.ERC721MOnft.name, + ); + const contract = ERC721MOnft.attach(args.contract); - // quote fee with default adapterParams - const adapterParams = ethers.utils.solidityPack(["uint16", "uint256"], [1, 200000]) // default adapterParams example - const fees = await contract.estimateSendFee(targetChainId, newOwner, args.tokenid, /* useZro= */false, adapterParams); + const signers = await ethers.getSigners(); + const owner = signers[0].address; + const targetChainId = ChainIds[args.targetnetwork]; + const newOwner = args.newowner ?? owner; + const refundAddress = args.refundaddress ?? owner; + const zeroPaymentAddress = args.refundaddress ?? ethers.constants.AddressZero; - const nativeFee = fees[0]; - console.log(`native fees (wei): ${nativeFee}`) - console.log(`Going to send tokenId: ${args.tokenid} from ${hre.network.name}/${args.contract} owned by ${owner} \n\rto \n\r trusted remote on ${args.targetnetwork} owned by ${newOwner} `); - if (!await confirm({ message: 'Continue?' })) return; + // quote fee with default adapterParams + const adapterParams = ethers.utils.solidityPack( + ['uint16', 'uint256'], + [1, 200000], + ); // default adapterParams example + const fees = await contract.estimateSendFee( + targetChainId, + newOwner, + args.tokenid, + /* useZro= */ false, + adapterParams, + ); - try { - const tx = await contract.sendFrom(owner, targetChainId, newOwner, args.tokenid, refundAddress, zeroPaymentAddress, adapterParams, { value: nativeFee.mul(5).div(4) }); - console.log(`Submitted tx ${tx.hash}`); - await tx.wait(); - console.log(`✅ Sent.`) - } catch (error) { - console.log(error); - } -} + const nativeFee = fees[0]; + console.log(`native fees (wei): ${nativeFee}`); + console.log( + `Going to send tokenId: ${args.tokenid} from ${hre.network.name}/${args.contract} owned by ${owner} \n\rto \n\r trusted remote on ${args.targetnetwork} owned by ${newOwner} `, + ); + if (!(await confirm({ message: 'Continue?' }))) return; + try { + const tx = await contract.sendFrom( + owner, + targetChainId, + newOwner, + args.tokenid, + refundAddress, + zeroPaymentAddress, + adapterParams, + { value: nativeFee.mul(5).div(4) }, + ); + console.log(`Submitted tx ${tx.hash}`); + await tx.wait(); + console.log(`✅ Sent.`); + } catch (error) { + console.log(error); + } +}; diff --git a/scripts/setBaseURI.ts b/scripts/setBaseURI.ts index d4cb87d..d739c77 100644 --- a/scripts/setBaseURI.ts +++ b/scripts/setBaseURI.ts @@ -3,7 +3,7 @@ import { ContractDetails } from './common/constants'; import { Overrides } from 'ethers'; import { estimateGas } from './utils/helper'; -export interface ISetBaseURIParams { +interface ISetBaseURIParams { uri: string; contract: string; gaspricegwei?: number; diff --git a/scripts/setGlobalWalletLimit.ts b/scripts/setGlobalWalletLimit.ts index 4ca314a..272c438 100644 --- a/scripts/setGlobalWalletLimit.ts +++ b/scripts/setGlobalWalletLimit.ts @@ -1,7 +1,7 @@ import { HardhatRuntimeEnvironment } from 'hardhat/types'; import { ContractDetails } from './common/constants'; -export interface ISetBaseURIParams { +interface ISetBaseURIParams { limit: string; contract: string; } diff --git a/scripts/setMaxMintableSupply.ts b/scripts/setMaxMintableSupply.ts index 22a9889..6f66431 100644 --- a/scripts/setMaxMintableSupply.ts +++ b/scripts/setMaxMintableSupply.ts @@ -1,6 +1,6 @@ import { HardhatRuntimeEnvironment } from 'hardhat/types'; -export interface ISetBaseURIParams { +interface ISetBaseURIParams { supply: string; contract: string; } diff --git a/scripts/setOnftMinDstGas.ts b/scripts/setOnftMinDstGas.ts index ced151f..9002e05 100644 --- a/scripts/setOnftMinDstGas.ts +++ b/scripts/setOnftMinDstGas.ts @@ -15,25 +15,32 @@ export const setOnftMinDstGas = async ( ) => { const supportedNetworks = Object.keys(ChainIds); if (!supportedNetworks.includes(args.targetnetwork)) { - throw new Error(`Invalid network. Supported networks are: ${supportedNetworks.join(', ')}`); + throw new Error( + `Invalid network. Supported networks are: ${supportedNetworks.join(', ')}`, + ); } const { ethers } = hre; const ERC721MOnft = await ethers.getContractFactory( ContractDetails.ERC721MOnft.name, ); const contract = ERC721MOnft.attach(args.contract); - const dstChainId = ChainIds[args.targetnetwork] + const dstChainId = ChainIds[args.targetnetwork]; + + console.log( + `Setting min destination gas for ${hre.network.name}/${args.contract} to packetType: ${args.packettype} and minGas: ${args.mingas}`, + ); + if (!(await confirm({ message: 'Continue?' }))) return; - console.log(`Setting min destination gas for ${hre.network.name}/${args.contract} to packetType: ${args.packettype} and minGas: ${args.mingas}`) - if (!await confirm({ message: 'Continue?' })) return; - try { - const tx = await contract.setMinDstGas(dstChainId, args.packettype, args.mingas) + const tx = await contract.setMinDstGas( + dstChainId, + args.packettype, + args.mingas, + ); console.log(`Submitted tx ${tx.hash}`); await tx.wait(); - console.log(`✅ Sent.`) + console.log(`✅ Sent.`); } catch (error) { console.log(error); } -} - +}; diff --git a/scripts/setPrice.ts b/scripts/setPrice.ts index 015919a..e36cc1b 100644 --- a/scripts/setPrice.ts +++ b/scripts/setPrice.ts @@ -17,7 +17,10 @@ export const setPrice = async ( ); const contract = ERC721M.attach(args.contract); - const tx = await contract.setPrice(ethers.BigNumber.from(args.priceinwei), overrides); + const tx = await contract.setPrice( + ethers.BigNumber.from(args.priceinwei), + overrides, + ); console.log(`Result: ${tx.hash}`); await tx.wait(); diff --git a/scripts/setStages.ts b/scripts/setStages.ts index cd92b9b..5023c3d 100644 --- a/scripts/setStages.ts +++ b/scripts/setStages.ts @@ -51,14 +51,25 @@ export const setStages = async ( ); // Clean up whitelist - const filteredWhitelist= whitelist.filter((address: string) => ethers.utils.isAddress(address)); - console.log(`Filtered whitelist: ${filteredWhitelist.length} addresses. ${whitelist.length - filteredWhitelist.length} invalid addresses removed.`); - const invalidWhitelist= whitelist.filter((address: string) => !ethers.utils.isAddress(address)); - console.log(`❌ Invalid whitelist: ${invalidWhitelist.length} addresses.\r\n${invalidWhitelist.join(', \r\n')}`); + const filteredWhitelist = whitelist.filter((address: string) => + ethers.utils.isAddress(address), + ); + console.log( + `Filtered whitelist: ${filteredWhitelist.length} addresses. ${whitelist.length - filteredWhitelist.length} invalid addresses removed.`, + ); + const invalidWhitelist = whitelist.filter( + (address: string) => !ethers.utils.isAddress(address), + ); + console.log( + `❌ Invalid whitelist: ${invalidWhitelist.length} addresses.\r\n${invalidWhitelist.join(', \r\n')}`, + ); if (invalidWhitelist.length > 0) { console.log(`🔄 🚨 updating whitelist file: ${stage.whitelistPath}`); - fs.writeFileSync(stage.whitelistPath, JSON.stringify(filteredWhitelist, null, 2)) + fs.writeFileSync( + stage.whitelistPath, + JSON.stringify(filteredWhitelist, null, 2), + ); } const mt = new MerkleTree( @@ -85,14 +96,16 @@ export const setStages = async ( console.log( `Stage params: `, JSON.stringify( - stages.map(stage => hre.ethers.BigNumber.isBigNumber(stage)? stage.toString() : stage) + stages.map((stage) => + hre.ethers.BigNumber.isBigNumber(stage) ? stage.toString() : stage, + ), ), ); const tx = await contract.populateTransaction.setStages(stages); if (!(await estimateGas(hre, tx, overrides))) return; - if (!await confirm({ message: 'Continue to set stages?' })) return; + if (!(await confirm({ message: 'Continue to set stages?' }))) return; const submittedTx = await contract.setStages(stages, overrides); diff --git a/scripts/setTrustedRemote.ts b/scripts/setTrustedRemote.ts index 96bbb1f..0a5ed14 100644 --- a/scripts/setTrustedRemote.ts +++ b/scripts/setTrustedRemote.ts @@ -3,41 +3,47 @@ import { ChainIds, ContractDetails } from './common/constants'; import { HardhatRuntimeEnvironment } from 'hardhat/types'; export interface ISetTrustedRemoteParams { - sourceaddress: string; - targetnetwork: string; - targetaddress: string; + sourceaddress: string; + targetnetwork: string; + targetaddress: string; } export const setTrustedRemote = async ( - args: ISetTrustedRemoteParams, - hre: HardhatRuntimeEnvironment, - ) => { - const supportedNetworks = Object.keys(ChainIds); - if (!supportedNetworks.includes(args.targetnetwork)) { - throw new Error(`Invalid network. Supported networks are: ${supportedNetworks.join(', ')}`); - } - const remoteChainId = ChainIds[args.targetnetwork]; - - const remoteAndLocal = hre.ethers.utils.solidityPack( - ['address','address'], - [args.targetaddress, args.sourceaddress] + args: ISetTrustedRemoteParams, + hre: HardhatRuntimeEnvironment, +) => { + const supportedNetworks = Object.keys(ChainIds); + if (!supportedNetworks.includes(args.targetnetwork)) { + throw new Error( + `Invalid network. Supported networks are: ${supportedNetworks.join(', ')}`, ); + } + const remoteChainId = ChainIds[args.targetnetwork]; - const { ethers } = hre; - const ERC721MOnft = await ethers.getContractFactory( - ContractDetails.ERC721MOnft.name, - ); - const contract = ERC721MOnft.attach(args.sourceaddress); + const remoteAndLocal = hre.ethers.utils.solidityPack( + ['address', 'address'], + [args.targetaddress, args.sourceaddress], + ); - console.log(`Setting TrustedRemote on ${hre.network.name}/${args.sourceaddress} to target ${args.targetnetwork}/${args.targetaddress}`) - if (!await confirm({ message: 'Continue?' })) return; + const { ethers } = hre; + const ERC721MOnft = await ethers.getContractFactory( + ContractDetails.ERC721MOnft.name, + ); + const contract = ERC721MOnft.attach(args.sourceaddress); - try { - const tx = await contract.setTrustedRemote(remoteChainId, remoteAndLocal); - console.log(`Submitted tx ${tx.hash}`); - await tx.wait(); - console.log(`✅ Set TrustedRemote on ${hre.network.name}/${args.sourceaddress} to target ${args.targetnetwork}/${args.targetaddress}`) - } catch (error) { - console.log(error); - } -} + console.log( + `Setting TrustedRemote on ${hre.network.name}/${args.sourceaddress} to target ${args.targetnetwork}/${args.targetaddress}`, + ); + if (!(await confirm({ message: 'Continue?' }))) return; + + try { + const tx = await contract.setTrustedRemote(remoteChainId, remoteAndLocal); + console.log(`Submitted tx ${tx.hash}`); + await tx.wait(); + console.log( + `✅ Set TrustedRemote on ${hre.network.name}/${args.sourceaddress} to target ${args.targetnetwork}/${args.targetaddress}`, + ); + } catch (error) { + console.log(error); + } +}; diff --git a/scripts/thawTrading.ts b/scripts/thawTrading.ts index 0963249..b66b1f0 100644 --- a/scripts/thawTrading.ts +++ b/scripts/thawTrading.ts @@ -12,13 +12,15 @@ export const thawTrading = async ( hre: HardhatRuntimeEnvironment, ) => { const { ethers } = hre; - const factory = await ethers.getContractFactory(ContractDetails.ERC721CM.name); + const factory = await ethers.getContractFactory( + ContractDetails.ERC721CM.name, + ); const contract = factory.attach(args.contract); const tx = await contract.populateTransaction.setToDefaultSecurityPolicy(); await estimateGas(hre, tx); console.log(`Going to thaw contract: ${args.contract}`); - if (!await confirm({ message: 'Continue?' })) return; + if (!(await confirm({ message: 'Continue?' }))) return; const submittedTx = await contract.setToDefaultSecurityPolicy(); diff --git a/scripts/utils/helper.ts b/scripts/utils/helper.ts index cdc9fbd..27bb910 100644 --- a/scripts/utils/helper.ts +++ b/scripts/utils/helper.ts @@ -1,26 +1,36 @@ import { confirm } from '@inquirer/prompts'; import { Deferrable } from 'ethers/lib/utils'; import { HardhatRuntimeEnvironment } from 'hardhat/types'; -import { TransactionRequest } from "@ethersproject/abstract-provider"; +import { TransactionRequest } from '@ethersproject/abstract-provider'; import * as child from 'child_process'; import { BigNumber, Overrides } from 'ethers'; const gasPricePctDiffAlert = 20; // Set threshold to alert when attempting to under/overpay against the current gas price median by X% (e.g. 20 = 20%) export const checkCodeVersion = async () => { - const localLatestCommit = child.execSync('git rev-parse HEAD').toString().trim(); - const remoteLatestCommit = child.execSync("git ls-remote https://github.com/magicoss/erc721m.git HEAD | awk '{ print $1}'").toString().trim(); + const localLatestCommit = child + .execSync('git rev-parse HEAD') + .toString() + .trim(); + const remoteLatestCommit = child + .execSync( + "git ls-remote https://github.com/magicoss/erc721m.git HEAD | awk '{ print $1}'", + ) + .toString() + .trim(); console.log('local latest commit:\t', localLatestCommit); console.log('remote latest commit:\t', remoteLatestCommit); if (localLatestCommit !== remoteLatestCommit) { - console.log("🟡 Warning: you are NOT using the latest version of the code. Please run `git pull` on main branch to update the code."); + console.log( + '🟡 Warning: you are NOT using the latest version of the code. Please run `git pull` on main branch to update the code.', + ); if (!(await confirm({ message: 'Proceed anyway?', default: false }))) { return false; - }; + } } return true; -} +}; export const estimateGas = async ( hre: HardhatRuntimeEnvironment, @@ -97,7 +107,7 @@ export const estimateGas = async ( }; const getTokenName = (hre: HardhatRuntimeEnvironment) => { - switch(hre.network.name) { + switch (hre.network.name) { case 'mainnet': case 'sepolia': case 'goerli': @@ -108,5 +118,4 @@ const getTokenName = (hre: HardhatRuntimeEnvironment) => { default: return 'ETH'; } -} - +}; diff --git a/test/ERC721BatchTransfer.test.ts b/test/ERC721BatchTransfer.test.ts index 2981689..b78b318 100644 --- a/test/ERC721BatchTransfer.test.ts +++ b/test/ERC721BatchTransfer.test.ts @@ -12,7 +12,7 @@ const addresses = { addr3: '0x78731D3Ca6b7E34aC0F824c42a7cC18A495cabaB', addr4: '0x617F2E2fD72FD9D5503197092aC168c91465E7f2', addr5: '0x17F6AD8Ef982297579C203069C1DbfFE4348c372', -} +}; describe('ERC721BatchTransfer', function () { let transferContract: ERC721BatchTransfer; @@ -22,11 +22,15 @@ describe('ERC721BatchTransfer', function () { beforeEach(async () => { [owner] = await ethers.getSigners(); - const batchTransfer = await (await ethers.getContractFactory('ERC721BatchTransfer')).deploy(); + const batchTransfer = await ( + await ethers.getContractFactory('ERC721BatchTransfer') + ).deploy(); await batchTransfer.deployed(); transferContract = batchTransfer.connect(owner); - const erc721a = await (await ethers.getContractFactory('MockERC721A')).deploy(); + const erc721a = await ( + await ethers.getContractFactory('MockERC721A') + ).deploy(); await erc721a.deployed(); nftContract = erc721a.connect(owner); @@ -41,7 +45,11 @@ describe('ERC721BatchTransfer', function () { }); it('batchTransferToSingleWallet', async () => { - await transferContract.batchTransferToSingleWallet(nftContract.address, addresses.addr1, [0, 1, 2, 3, 4]); + await transferContract.batchTransferToSingleWallet( + nftContract.address, + addresses.addr1, + [0, 1, 2, 3, 4], + ); for (let i = 0; i < 5; i++) { const tokenOwner = await nftContract.ownerOf(i); expect(tokenOwner).to.equal(addresses.addr1); @@ -50,7 +58,11 @@ describe('ERC721BatchTransfer', function () { it('safeBatchTransferToSingleWallet', async () => { const tokenIds = [0, 1, 2, 3, 4]; - await transferContract.safeBatchTransferToSingleWallet(nftContract.address, addresses.addr1, [0, 1, 2, 3, 4]); + await transferContract.safeBatchTransferToSingleWallet( + nftContract.address, + addresses.addr1, + [0, 1, 2, 3, 4], + ); for (let i = 0; i < tokenIds.length; i++) { const tokenOwner = await nftContract.ownerOf(tokenIds[i]); expect(tokenOwner).to.equal(addresses.addr1); @@ -59,8 +71,18 @@ describe('ERC721BatchTransfer', function () { it('batchTransferToMultipleWallets', async () => { const tokenIds = [0, 1, 2, 3, 4]; - const tos = [addresses.addr1, addresses.addr2, addresses.addr3, addresses.addr4, addresses.addr5]; - await transferContract.batchTransferToMultipleWallets(nftContract.address, tos, tokenIds); + const tos = [ + addresses.addr1, + addresses.addr2, + addresses.addr3, + addresses.addr4, + addresses.addr5, + ]; + await transferContract.batchTransferToMultipleWallets( + nftContract.address, + tos, + tokenIds, + ); for (let i = 0; i < tokenIds.length; i++) { const tokenOwner = await nftContract.ownerOf(tokenIds[i]); expect(tokenOwner).to.equal(tos[i]); @@ -69,8 +91,18 @@ describe('ERC721BatchTransfer', function () { it('safeBatchTransferToMultipleWallets', async () => { const tokenIds = [4, 1, 2, 0, 3]; - const tos = [addresses.addr1, addresses.addr2, addresses.addr2, addresses.addr2, addresses.addr4]; - await transferContract.safeBatchTransferToMultipleWallets(nftContract.address, tos, tokenIds); + const tos = [ + addresses.addr1, + addresses.addr2, + addresses.addr2, + addresses.addr2, + addresses.addr4, + ]; + await transferContract.safeBatchTransferToMultipleWallets( + nftContract.address, + tos, + tokenIds, + ); for (let i = 0; i < tokenIds.length; i++) { const tokenOwner = await nftContract.ownerOf(tokenIds[i]); expect(tokenOwner).to.equal(tos[i]); @@ -79,20 +111,44 @@ describe('ERC721BatchTransfer', function () { it('revert if tokens not owned', async () => { const tokenIds = [0, 1, 2, 3, 4]; - const tos = [addresses.addr1, addresses.addr2, addresses.addr3, addresses.addr4, addresses.addr5]; - await transferContract.batchTransferToMultipleWallets(nftContract.address, tos, tokenIds); + const tos = [ + addresses.addr1, + addresses.addr2, + addresses.addr3, + addresses.addr4, + addresses.addr5, + ]; + await transferContract.batchTransferToMultipleWallets( + nftContract.address, + tos, + tokenIds, + ); await expect( - transferContract.batchTransferToMultipleWallets(nftContract.address, tos, tokenIds) - ).to.be.revertedWith('NotOwnerOfToken'); + transferContract.batchTransferToMultipleWallets( + nftContract.address, + tos, + tokenIds, + ), + ).to.be.revertedWith('NotOwnerOfToken'); }); it('revert if invalid arguments', async () => { - const tokenIds = [0, 1, 2, 3, ]; - const tos = [addresses.addr1, addresses.addr2, addresses.addr3, addresses.addr4, addresses.addr5]; + const tokenIds = [0, 1, 2, 3]; + const tos = [ + addresses.addr1, + addresses.addr2, + addresses.addr3, + addresses.addr4, + addresses.addr5, + ]; await expect( - transferContract.batchTransferToMultipleWallets(nftContract.address, tos, tokenIds) - ).to.be.revertedWith('InvalidArguments'); + transferContract.batchTransferToMultipleWallets( + nftContract.address, + tos, + tokenIds, + ), + ).to.be.revertedWith('InvalidArguments'); }); }); diff --git a/test/ERC721CM.test.ts b/test/ERC721CM.test.ts index d180944..f243ebe 100644 --- a/test/ERC721CM.test.ts +++ b/test/ERC721CM.test.ts @@ -1310,9 +1310,8 @@ describe('ERC721CM', function () { await ownerConn.setCrossmintAddress(crossmintAddressStr); // Impersonate Crossmint wallet - const crossmintSigner = await ethers.getImpersonatedSigner( - crossmintAddressStr, - ); + const crossmintSigner = + await ethers.getImpersonatedSigner(crossmintAddressStr); const crossmintAddress = await crossmintSigner.getAddress(); // Send some wei to impersonated account @@ -1377,9 +1376,8 @@ describe('ERC721CM', function () { await ownerConn.setCrossmintAddress(crossmintAddressStr); // Impersonate Crossmint wallet - const crossmintSigner = await ethers.getImpersonatedSigner( - crossmintAddressStr, - ); + const crossmintSigner = + await ethers.getImpersonatedSigner(crossmintAddressStr); const crossmintAddress = await crossmintSigner.getAddress(); // Send some wei to impersonated account @@ -1865,9 +1863,11 @@ describe('ERC721CM', function () { }); }); - describe('Contract URI', function() { + describe('Contract URI', function () { it('can set contract URI', async () => { - await contract.setContractURI('ipfs://bafybeidntqfipbuvdhdjosntmpxvxyse2dkyfpa635u4g6txruvt5qf7y4'); + await contract.setContractURI( + 'ipfs://bafybeidntqfipbuvdhdjosntmpxvxyse2dkyfpa635u4g6txruvt5qf7y4', + ); const contractURI = await contract.contractURI(); expect(contractURI).to.equal( 'ipfs://bafybeidntqfipbuvdhdjosntmpxvxyse2dkyfpa635u4g6txruvt5qf7y4', @@ -1875,9 +1875,11 @@ describe('ERC721CM', function () { }); }); - describe('Transfer validator', function() { + describe('Transfer validator', function () { it('default validator settings', async () => { - expect(await contract.getTransferValidator()).to.equal('0x0000000000000000000000000000000000000000'); + expect(await contract.getTransferValidator()).to.equal( + '0x0000000000000000000000000000000000000000', + ); }); // TODO: figure out a way to mock the validator contract diff --git a/test/ERC721CMBasicRoyalties.test.ts b/test/ERC721CMBasicRoyalties.test.ts index fe7efb1..5517f6b 100644 --- a/test/ERC721CMBasicRoyalties.test.ts +++ b/test/ERC721CMBasicRoyalties.test.ts @@ -11,7 +11,9 @@ describe('ERC721CMBasicRoyalties', function () { let owner: SignerWithAddress; beforeEach(async () => { - const ERC721CMBasicRoyalties = await ethers.getContractFactory('ERC721CMBasicRoyalties'); + const ERC721CMBasicRoyalties = await ethers.getContractFactory( + 'ERC721CMBasicRoyalties', + ); const erc721cmBasicRoyalties = await ERC721CMBasicRoyalties.deploy( 'Test', 'TEST', @@ -32,15 +34,21 @@ describe('ERC721CMBasicRoyalties', function () { it('Royalty info', async () => { let royaltyInfo = await contract.royaltyInfo(0, 1000); - expect(royaltyInfo[0]).to.equal('0x0764844ac95ABCa4F6306E592c7D9C9f3615f590'); + expect(royaltyInfo[0]).to.equal( + '0x0764844ac95ABCa4F6306E592c7D9C9f3615f590', + ); expect(royaltyInfo[1].toNumber()).to.equal(1); royaltyInfo = await contract.royaltyInfo(1, 9999); - expect(royaltyInfo[0]).to.equal('0x0764844ac95ABCa4F6306E592c7D9C9f3615f590'); + expect(royaltyInfo[0]).to.equal( + '0x0764844ac95ABCa4F6306E592c7D9C9f3615f590', + ); expect(royaltyInfo[1].toNumber()).to.equal(9); royaltyInfo = await contract.royaltyInfo(1111, 9999999999); - expect(royaltyInfo[0]).to.equal('0x0764844ac95ABCa4F6306E592c7D9C9f3615f590'); + expect(royaltyInfo[0]).to.equal( + '0x0764844ac95ABCa4F6306E592c7D9C9f3615f590', + ); expect(royaltyInfo[1].toNumber()).to.equal(9999999); }); diff --git a/test/ERC721CMRoyalties.test.ts b/test/ERC721CMRoyalties.test.ts index e466049..971c91e 100644 --- a/test/ERC721CMRoyalties.test.ts +++ b/test/ERC721CMRoyalties.test.ts @@ -15,7 +15,8 @@ describe('ERC721CMRoyalties', function () { let owner: SignerWithAddress; beforeEach(async () => { - const ERC721CMRoyalties = await ethers.getContractFactory('ERC721CMRoyalties'); + const ERC721CMRoyalties = + await ethers.getContractFactory('ERC721CMRoyalties'); erc721cmRoyalties = await ERC721CMRoyalties.deploy( 'Test', 'TEST', @@ -47,7 +48,7 @@ describe('ERC721CMRoyalties', function () { expect(royaltyInfo[0]).to.equal(WALLET_1); expect(royaltyInfo[1].toNumber()).to.equal(9999999); - await connection.setDefaultRoyalty(WALLET_2, 0) + await connection.setDefaultRoyalty(WALLET_2, 0); royaltyInfo = await connection.royaltyInfo(0, 1000); expect(royaltyInfo[0]).to.equal(WALLET_2); @@ -75,7 +76,7 @@ describe('ERC721CMRoyalties', function () { expect(royaltyInfo[0]).to.equal(WALLET_1); expect(royaltyInfo[1].toNumber()).to.equal(9999999); - await connection.setTokenRoyalty(1, WALLET_2, 100) + await connection.setTokenRoyalty(1, WALLET_2, 100); royaltyInfo = await connection.royaltyInfo(0, 1000); expect(royaltyInfo[0]).to.equal(WALLET_1); @@ -95,12 +96,12 @@ describe('ERC721CMRoyalties', function () { const nonOwnerConnection = erc721cmRoyalties.connect(nonOwner); await expect( - nonOwnerConnection.setTokenRoyalty(1, WALLET_2, 100) - ).to.be.revertedWith('Ownable: caller is not the owner'); + nonOwnerConnection.setTokenRoyalty(1, WALLET_2, 100), + ).to.be.revertedWith('Ownable: caller is not the owner'); await expect( - nonOwnerConnection.setDefaultRoyalty(WALLET_2, 0) - ).to.be.revertedWith('Ownable: caller is not the owner'); + nonOwnerConnection.setDefaultRoyalty(WALLET_2, 0), + ).to.be.revertedWith('Ownable: caller is not the owner'); }); it('Supports the right interfaces', async () => { diff --git a/test/ERC721MOnft.test.ts b/test/ERC721MOnft.test.ts index 80eb359..1ac4df6 100644 --- a/test/ERC721MOnft.test.ts +++ b/test/ERC721MOnft.test.ts @@ -10,13 +10,15 @@ describe('ERC721MOnft Test', () => { let minter: Signer; const mintPrice = 50; - const targetChainId = 10109; // mumbnai - const targetAddress = '0x15f963ae86e562535a1546f9417b604e29fe78f6'; // a random address + const targetChainId = 10109; // mumbnai + const targetAddress = '0x15f963ae86e562535a1546f9417b604e29fe78f6'; // a random address describe('mint and bridge', function () { beforeEach(async function () { // Deploy the mock LayerZero endpoint contract that will be used for minting - const MockLayerZeroEndpoint = await ethers.getContractFactory('MockLayerZeroEndpoint'); + const MockLayerZeroEndpoint = await ethers.getContractFactory( + 'MockLayerZeroEndpoint', + ); lzEndpoint = await MockLayerZeroEndpoint.deploy(); await lzEndpoint.deployed(); @@ -31,7 +33,7 @@ describe('ERC721MOnft Test', () => { ethers.constants.AddressZero, 60, 15000, - lzEndpoint.address + lzEndpoint.address, ); await erc721MOnft.deployed(); @@ -67,7 +69,7 @@ describe('ERC721MOnft Test', () => { const remoteAndLocal = ethers.utils.solidityPack( ['address', 'address'], - [targetAddress, contract.address] + [targetAddress, contract.address], ); await contract.setTrustedRemote(targetChainId, remoteAndLocal); @@ -80,11 +82,29 @@ describe('ERC721MOnft Test', () => { expect(walletMintedCount).to.equal(2); expect(stagedMintedCount.toNumber()).to.equal(2); - const adapterParams = ethers.utils.solidityPack(["uint16", "uint256"], [1, 200000]) // default adapterParams example - const fees = await contract.estimateSendFee(targetChainId, owner.getAddress(), 0, /* useZro= */false, adapterParams); + const adapterParams = ethers.utils.solidityPack( + ['uint16', 'uint256'], + [1, 200000], + ); // default adapterParams example + const fees = await contract.estimateSendFee( + targetChainId, + owner.getAddress(), + 0, + /* useZro= */ false, + adapterParams, + ); const nativeFee = fees[0]; - await contract.sendFrom(owner.getAddress(), targetChainId, owner.getAddress(), 0, owner.getAddress(), ethers.constants.AddressZero, adapterParams, { value: nativeFee.mul(5).div(4) }) + await contract.sendFrom( + owner.getAddress(), + targetChainId, + owner.getAddress(), + 0, + owner.getAddress(), + ethers.constants.AddressZero, + adapterParams, + { value: nativeFee.mul(5).div(4) }, + ); }); it('bridge fails if min destination gas not set', async function () { @@ -92,24 +112,61 @@ describe('ERC721MOnft Test', () => { value: ethers.utils.parseEther('50'), }); - const adapterParams = ethers.utils.solidityPack(["uint16", "uint256"], [1, 200000]) // default adapterParams example - const fees = await contract.estimateSendFee(targetChainId, owner.getAddress(), 0, /* useZro= */false, adapterParams); + const adapterParams = ethers.utils.solidityPack( + ['uint16', 'uint256'], + [1, 200000], + ); // default adapterParams example + const fees = await contract.estimateSendFee( + targetChainId, + owner.getAddress(), + 0, + /* useZro= */ false, + adapterParams, + ); const nativeFee = fees[0]; - await expect(contract.sendFrom(owner.getAddress(), targetChainId, owner.getAddress(), 0, owner.getAddress(), ethers.constants.AddressZero, adapterParams, { value: nativeFee.mul(5).div(4) }) + await expect( + contract.sendFrom( + owner.getAddress(), + targetChainId, + owner.getAddress(), + 0, + owner.getAddress(), + ethers.constants.AddressZero, + adapterParams, + { value: nativeFee.mul(5).div(4) }, + ), ).to.be.revertedWith('minGasLimit not set'); }); it('bridge fails if the token not exist', async function () { - const adapterParams = ethers.utils.solidityPack(["uint16", "uint256"], [1, 200000]) // default adapterParams example - const fees = await contract.estimateSendFee(targetChainId, owner.getAddress(), 0, /* useZro= */false, adapterParams); + const adapterParams = ethers.utils.solidityPack( + ['uint16', 'uint256'], + [1, 200000], + ); // default adapterParams example + const fees = await contract.estimateSendFee( + targetChainId, + owner.getAddress(), + 0, + /* useZro= */ false, + adapterParams, + ); const nativeFee = fees[0]; - await expect(contract.sendFrom(owner.getAddress(), targetChainId, owner.getAddress(), 0, owner.getAddress(), ethers.constants.AddressZero, adapterParams, { value: nativeFee.mul(5).div(4) }) + await expect( + contract.sendFrom( + owner.getAddress(), + targetChainId, + owner.getAddress(), + 0, + owner.getAddress(), + ethers.constants.AddressZero, + adapterParams, + { value: nativeFee.mul(5).div(4) }, + ), ).to.be.revertedWith('OwnerQueryForNonexistentToken'); }); - it('bridge fails if the destination chain not trusted', async function () { await contract.setMinDstGas(targetChainId, 1, 15000); @@ -117,11 +174,30 @@ describe('ERC721MOnft Test', () => { value: ethers.utils.parseEther('50'), }); - const adapterParams = ethers.utils.solidityPack(["uint16", "uint256"], [1, 200000]) // default adapterParams example - const fees = await contract.estimateSendFee(targetChainId, owner.getAddress(), 0, /* useZro= */false, adapterParams); + const adapterParams = ethers.utils.solidityPack( + ['uint16', 'uint256'], + [1, 200000], + ); // default adapterParams example + const fees = await contract.estimateSendFee( + targetChainId, + owner.getAddress(), + 0, + /* useZro= */ false, + adapterParams, + ); const nativeFee = fees[0]; - await expect(contract.sendFrom(owner.getAddress(), targetChainId, owner.getAddress(), 0, owner.getAddress(), ethers.constants.AddressZero, adapterParams, { value: nativeFee.mul(5).div(4) }) + await expect( + contract.sendFrom( + owner.getAddress(), + targetChainId, + owner.getAddress(), + 0, + owner.getAddress(), + ethers.constants.AddressZero, + adapterParams, + { value: nativeFee.mul(5).div(4) }, + ), ).to.be.revertedWith('destination chain not a trusted source'); }); }); diff --git a/test/ERC721MPausable.test.ts b/test/ERC721MPausable.test.ts index 1fe1a55..ef5d05d 100644 --- a/test/ERC721MPausable.test.ts +++ b/test/ERC721MPausable.test.ts @@ -8,9 +8,8 @@ describe('ERC721MPausable', function () { let receiver: any; beforeEach(async function () { - const ERC721MPausableFactory = await ethers.getContractFactory( - 'ERC721MPausable', - ); + const ERC721MPausableFactory = + await ethers.getContractFactory('ERC721MPausable'); [owner, receiver] = await ethers.getSigners(); erc721MPausable = await ERC721MPausableFactory.deploy( diff --git a/test/erc721m.test.ts b/test/erc721m.test.ts index c4838bf..77a44ea 100644 --- a/test/erc721m.test.ts +++ b/test/erc721m.test.ts @@ -1311,9 +1311,8 @@ describe('ERC721M', function () { await ownerConn.setCrossmintAddress(crossmintAddressStr); // Impersonate Crossmint wallet - const crossmintSigner = await ethers.getImpersonatedSigner( - crossmintAddressStr, - ); + const crossmintSigner = + await ethers.getImpersonatedSigner(crossmintAddressStr); const crossmintAddress = await crossmintSigner.getAddress(); // Send some wei to impersonated account @@ -1378,9 +1377,8 @@ describe('ERC721M', function () { await ownerConn.setCrossmintAddress(crossmintAddressStr); // Impersonate Crossmint wallet - const crossmintSigner = await ethers.getImpersonatedSigner( - crossmintAddressStr, - ); + const crossmintSigner = + await ethers.getImpersonatedSigner(crossmintAddressStr); const crossmintAddress = await crossmintSigner.getAddress(); // Send some wei to impersonated account