From 44cb22e43a5b73577fe278bcb228948240c3477d Mon Sep 17 00:00:00 2001 From: raymond-me Date: Mon, 7 Oct 2024 09:41:50 -0700 Subject: [PATCH 1/3] update scripts for set stages to handle multiple ids (#148) --- scripts/set1155Stages.ts | 33 +++++++++++++++++++-------------- scripts/utils/helper.ts | 4 +++- 2 files changed, 22 insertions(+), 15 deletions(-) diff --git a/scripts/set1155Stages.ts b/scripts/set1155Stages.ts index bb123574..6201bea8 100644 --- a/scripts/set1155Stages.ts +++ b/scripts/set1155Stages.ts @@ -3,7 +3,7 @@ import { HardhatRuntimeEnvironment } from 'hardhat/types'; import { MerkleTree } from 'merkletreejs'; import fs from 'fs'; import { ContractDetails } from './common/constants'; -import { cleanVariableWalletLimit, cleanWhitelist, estimateGas } from './utils/helper'; +import { cleanVariableWalletLimit, cleanWhitelist, ensureArray, estimateGas } from './utils/helper'; import { Overrides } from 'ethers'; export interface ISet1155StagesParams { @@ -14,12 +14,12 @@ export interface ISet1155StagesParams { } interface StageConfig { - price: string; - mintFee?: string; + price: string | string[]; + mintFee?: string | string[]; startDate: number; endDate: number; - walletLimit?: number; - maxSupply?: number; + walletLimit?: number | number[]; + maxSupply?: number | number[]; whitelistPath?: string; variableWalletLimitPath?: string; } @@ -91,15 +91,20 @@ export const set1155Stages = async ( }), ); - const stages = stagesConfig.map((s, i) => ({ - price: [ethers.utils.parseEther(s.price)], - mintFee: [s.mintFee ? ethers.utils.parseEther(s.mintFee) : 0], - maxStageSupply: [s.maxSupply ?? 0], - walletLimit: [s.walletLimit ?? 0], - merkleRoot: [merkleRoots[i]], - startTimeUnixSeconds: Math.floor(new Date(s.startDate).getTime() / 1000), - endTimeUnixSeconds: Math.floor(new Date(s.endDate).getTime() / 1000), - })); + const stages = stagesConfig.map((s, i) => { + const price = ensureArray(s.price).map(p => ethers.utils.parseEther(p)); + const tokenCount = price.length; + + return { + price, + mintFee: s.mintFee ? ensureArray(s.mintFee).map(f => ethers.utils.parseEther(f)) : Array(tokenCount).fill(0), + maxStageSupply: s.maxSupply ? ensureArray(s.maxSupply) : Array(tokenCount).fill(0), + walletLimit: s.walletLimit ? ensureArray(s.walletLimit) : Array(tokenCount).fill(0), + merkleRoot: Array(tokenCount).fill(merkleRoots[i]), + startTimeUnixSeconds: Math.floor(new Date(s.startDate).getTime() / 1000), + endTimeUnixSeconds: Math.floor(new Date(s.endDate).getTime() / 1000), + }; + }); console.log( `Stage params: `, diff --git a/scripts/utils/helper.ts b/scripts/utils/helper.ts index 4f68e06d..6be69a56 100644 --- a/scripts/utils/helper.ts +++ b/scripts/utils/helper.ts @@ -204,4 +204,6 @@ export const cleanWhitelist = async (whitelistPath: string, writeToFile: boolean } console.log(`=========================================`); return wallets; -} \ No newline at end of file +} + +export const ensureArray = (value: any) => Array.isArray(value) ? value : [value]; \ No newline at end of file From a49259a9a494835b1cdddcd8ddfa7e2a4514c91c Mon Sep 17 00:00:00 2001 From: Channing <95395274+channing-magiceden@users.noreply.github.com> Date: Mon, 21 Oct 2024 16:02:14 -0700 Subject: [PATCH 2/3] Support ApeChain (#157) - Add Hardhat network - Add Etherscan config for verification Signed-off-by: Channing <95395274+channing-magiceden@users.noreply.github.com> --- hardhat.config.ts | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/hardhat.config.ts b/hardhat.config.ts index aa0fd088..04107329 100644 --- a/hardhat.config.ts +++ b/hardhat.config.ts @@ -80,6 +80,11 @@ const config: HardhatUserConfig = { accountsBalance: '1000000000000000000000' } }, + apechain: { + url: 'https://apechain.calderachain.xyz/http', + accounts: + process.env.PRIVATE_KEY !== undefined ? [process.env.PRIVATE_KEY] : [], + }, base: { url: process.env.BASE_URL || '', accounts: @@ -128,6 +133,16 @@ const config: HardhatUserConfig = { }, etherscan: { apiKey: process.env.ETHERSCAN_API_KEY, + customChains: [ + { + network: "apechain", + chainId: 33139, + urls: { + apiURL: "https://api.apescan.io/api", + browserURL: "https://apescan.io/" + } + } + ] }, sourcify: { enabled: true From dcd115edafe8ed73b4d3b9a938e926153479bf99 Mon Sep 17 00:00:00 2001 From: Channing <95395274+channing-magiceden@users.noreply.github.com> Date: Thu, 31 Oct 2024 10:01:38 -0700 Subject: [PATCH 3/3] Support customized 721C validator and list (#159) --- package-lock.json | 328 ++++++++++++++++++++++++++++++++++++- package.json | 7 +- scripts/deploy.ts | 25 ++- scripts/utils/helper.ts | 5 + scripts/utils/validator.ts | 64 ++++++++ 5 files changed, 416 insertions(+), 13 deletions(-) create mode 100644 scripts/utils/validator.ts diff --git a/package-lock.json b/package-lock.json index 509cac1a..cc4de0b7 100644 --- a/package-lock.json +++ b/package-lock.json @@ -59,7 +59,8 @@ "solidity-coverage": "^0.8.11", "ts-node": "^10.7.0", "typechain": "^8.1.0", - "typescript": "^4.6.4" + "typescript": "^5.6.3", + "viem": "^2.21.37" }, "peerDependencies": { "ethers": "^5.0.0" @@ -68,6 +69,12 @@ "../magicdrop-types": { "extraneous": true }, + "node_modules/@adraffy/ens-normalize": { + "version": "1.11.0", + "resolved": "https://registry.npmjs.org/@adraffy/ens-normalize/-/ens-normalize-1.11.0.tgz", + "integrity": "sha512-/3DDPKHqqIqxUULp8yP4zODUY1i+2xvVWsv8A79xGWdCAG+8sb0hRh0Rk2QyOJUnnbyPUAZYcpBuRe3nS2OIUg==", + "dev": true + }, "node_modules/@aws-crypto/sha256-js": { "version": "1.2.2", "resolved": "https://registry.npmjs.org/@aws-crypto/sha256-js/-/sha256-js-1.2.2.tgz", @@ -2514,6 +2521,33 @@ "node": ">=12.0.0" } }, + "node_modules/@noble/curves": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/@noble/curves/-/curves-1.6.0.tgz", + "integrity": "sha512-TlaHRXDehJuRNR9TfZDNQ45mMEd5dwUwmicsafcIX4SsNiqnCHKjE/1alYPd/lDRVhxdhUAlv8uEhMCI5zjIJQ==", + "dev": true, + "dependencies": { + "@noble/hashes": "1.5.0" + }, + "engines": { + "node": "^14.21.3 || >=16" + }, + "funding": { + "url": "https://paulmillr.com/funding/" + } + }, + "node_modules/@noble/curves/node_modules/@noble/hashes": { + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/@noble/hashes/-/hashes-1.5.0.tgz", + "integrity": "sha512-1j6kQFb7QRru7eKN3ZDvRcP13rugwdxZqCjbiAVZfIJwgj2A65UmT4TgARXGlXgnRkORLTDTrO19ZErt7+QXgA==", + "dev": true, + "engines": { + "node": "^14.21.3 || >=16" + }, + "funding": { + "url": "https://paulmillr.com/funding/" + } + }, "node_modules/@noble/hashes": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/@noble/hashes/-/hashes-1.0.0.tgz", @@ -4283,6 +4317,27 @@ "integrity": "sha512-LEyx4aLEC3x6T0UguF6YILf+ntvmOaWsVfENmIW0E9H09vKlLDGelMjjSm0jkDHALj8A8quZ/HapKNigzwge+Q==", "dev": true }, + "node_modules/abitype": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/abitype/-/abitype-1.0.6.tgz", + "integrity": "sha512-MMSqYh4+C/aVqI2RQaWqbvI4Kxo5cQV40WQ4QFtDnNzCkqChm8MuENhElmynZlO0qUy/ObkEUaXtKqYnx1Kp3A==", + "dev": true, + "funding": { + "url": "https://github.com/sponsors/wevm" + }, + "peerDependencies": { + "typescript": ">=5.0.4", + "zod": "^3 >=3.22.0" + }, + "peerDependenciesMeta": { + "typescript": { + "optional": true + }, + "zod": { + "optional": true + } + } + }, "node_modules/acorn": { "version": "7.4.1", "resolved": "https://registry.npmjs.org/acorn/-/acorn-7.4.1.tgz", @@ -18978,6 +19033,21 @@ "unfetch": "^4.2.0" } }, + "node_modules/isows": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/isows/-/isows-1.0.6.tgz", + "integrity": "sha512-lPHCayd40oW98/I0uvgaHKWCSvkzY27LjWLbtzOm64yQ+G3Q5npjjbdppU65iZXkK1Zt+kH9pfegli0AYfwYYw==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/wevm" + } + ], + "peerDependencies": { + "ws": "*" + } + }, "node_modules/isstream": { "version": "0.1.2", "resolved": "https://registry.npmjs.org/isstream/-/isstream-0.1.2.tgz", @@ -23518,16 +23588,16 @@ "integrity": "sha512-/aCDEGatGvZ2BIk+HmLf4ifCJFwvKFNb9/JeZPMulfgFracn9QFcAf5GO8B/mweUjSoblS5In0cWhqpfs/5PQA==" }, "node_modules/typescript": { - "version": "4.8.3", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.8.3.tgz", - "integrity": "sha512-goMHfm00nWPa8UvR/CPSvykqf6dVV8x/dp0c5mFTMTIu0u0FlGWRioyy7Nn0PGAdHxpJZnuO/ut+PpQ8UiHAig==", + "version": "5.6.3", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.6.3.tgz", + "integrity": "sha512-hjcS1mhfuyi4WW8IWtjP7brDrG2cuDZukyrYrSauoXGNgx0S7zceP07adYkJycEr56BOUTNPzbInooiN3fn1qw==", "devOptional": true, "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" }, "engines": { - "node": ">=4.2.0" + "node": ">=14.17" } }, "node_modules/typical": { @@ -23723,6 +23793,106 @@ "extsprintf": "^1.2.0" } }, + "node_modules/viem": { + "version": "2.21.37", + "resolved": "https://registry.npmjs.org/viem/-/viem-2.21.37.tgz", + "integrity": "sha512-JupwyttT4aJNnP9+kD7E8jorMS5VmgpC3hm3rl5zXsO8WNBTsP3JJqZUSg4AG6s2lTrmmpzS/qpmXMZu5gJw5Q==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/wevm" + } + ], + "dependencies": { + "@adraffy/ens-normalize": "1.11.0", + "@noble/curves": "1.6.0", + "@noble/hashes": "1.5.0", + "@scure/bip32": "1.5.0", + "@scure/bip39": "1.4.0", + "abitype": "1.0.6", + "isows": "1.0.6", + "webauthn-p256": "0.0.10", + "ws": "8.18.0" + }, + "peerDependencies": { + "typescript": ">=5.0.4" + }, + "peerDependenciesMeta": { + "typescript": { + "optional": true + } + } + }, + "node_modules/viem/node_modules/@noble/hashes": { + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/@noble/hashes/-/hashes-1.5.0.tgz", + "integrity": "sha512-1j6kQFb7QRru7eKN3ZDvRcP13rugwdxZqCjbiAVZfIJwgj2A65UmT4TgARXGlXgnRkORLTDTrO19ZErt7+QXgA==", + "dev": true, + "engines": { + "node": "^14.21.3 || >=16" + }, + "funding": { + "url": "https://paulmillr.com/funding/" + } + }, + "node_modules/viem/node_modules/@scure/base": { + "version": "1.1.9", + "resolved": "https://registry.npmjs.org/@scure/base/-/base-1.1.9.tgz", + "integrity": "sha512-8YKhl8GHiNI/pU2VMaofa2Tor7PJRAjwQLBBuilkJ9L5+13yVbC7JO/wS7piioAvPSwR3JKM1IJ/u4xQzbcXKg==", + "dev": true, + "funding": { + "url": "https://paulmillr.com/funding/" + } + }, + "node_modules/viem/node_modules/@scure/bip32": { + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/@scure/bip32/-/bip32-1.5.0.tgz", + "integrity": "sha512-8EnFYkqEQdnkuGBVpCzKxyIwDCBLDVj3oiX0EKUFre/tOjL/Hqba1D6n/8RcmaQy4f95qQFrO2A8Sr6ybh4NRw==", + "dev": true, + "dependencies": { + "@noble/curves": "~1.6.0", + "@noble/hashes": "~1.5.0", + "@scure/base": "~1.1.7" + }, + "funding": { + "url": "https://paulmillr.com/funding/" + } + }, + "node_modules/viem/node_modules/@scure/bip39": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/@scure/bip39/-/bip39-1.4.0.tgz", + "integrity": "sha512-BEEm6p8IueV/ZTfQLp/0vhw4NPnT9oWf5+28nvmeUICjP99f4vr2d+qc7AVGDDtwRep6ifR43Yed9ERVmiITzw==", + "dev": true, + "dependencies": { + "@noble/hashes": "~1.5.0", + "@scure/base": "~1.1.8" + }, + "funding": { + "url": "https://paulmillr.com/funding/" + } + }, + "node_modules/viem/node_modules/ws": { + "version": "8.18.0", + "resolved": "https://registry.npmjs.org/ws/-/ws-8.18.0.tgz", + "integrity": "sha512-8VbfWfHLbbwu3+N6OKsOMpBdT4kXPDDB9cJk2bJ6mh9ucxdlnNvH1e+roYkKmN9Nxw2yjz7VzeO9oOz2zJ04Pw==", + "dev": true, + "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 + } + } + }, "node_modules/web3-utils": { "version": "1.8.0", "resolved": "https://registry.npmjs.org/web3-utils/-/web3-utils-1.8.0.tgz", @@ -23780,6 +23950,34 @@ "node": ">=10.0.0" } }, + "node_modules/webauthn-p256": { + "version": "0.0.10", + "resolved": "https://registry.npmjs.org/webauthn-p256/-/webauthn-p256-0.0.10.tgz", + "integrity": "sha512-EeYD+gmIT80YkSIDb2iWq0lq2zbHo1CxHlQTeJ+KkCILWpVy3zASH3ByD4bopzfk0uCwXxLqKGLqp2W4O28VFA==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/wevm" + } + ], + "dependencies": { + "@noble/curves": "^1.4.0", + "@noble/hashes": "^1.4.0" + } + }, + "node_modules/webauthn-p256/node_modules/@noble/hashes": { + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/@noble/hashes/-/hashes-1.5.0.tgz", + "integrity": "sha512-1j6kQFb7QRru7eKN3ZDvRcP13rugwdxZqCjbiAVZfIJwgj2A65UmT4TgARXGlXgnRkORLTDTrO19ZErt7+QXgA==", + "dev": true, + "engines": { + "node": "^14.21.3 || >=16" + }, + "funding": { + "url": "https://paulmillr.com/funding/" + } + }, "node_modules/webidl-conversions": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz", @@ -24155,6 +24353,12 @@ } }, "dependencies": { + "@adraffy/ens-normalize": { + "version": "1.11.0", + "resolved": "https://registry.npmjs.org/@adraffy/ens-normalize/-/ens-normalize-1.11.0.tgz", + "integrity": "sha512-/3DDPKHqqIqxUULp8yP4zODUY1i+2xvVWsv8A79xGWdCAG+8sb0hRh0Rk2QyOJUnnbyPUAZYcpBuRe3nS2OIUg==", + "dev": true + }, "@aws-crypto/sha256-js": { "version": "1.2.2", "resolved": "https://registry.npmjs.org/@aws-crypto/sha256-js/-/sha256-js-1.2.2.tgz", @@ -25919,6 +26123,23 @@ "tweetnacl-util": "^0.15.1" } }, + "@noble/curves": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/@noble/curves/-/curves-1.6.0.tgz", + "integrity": "sha512-TlaHRXDehJuRNR9TfZDNQ45mMEd5dwUwmicsafcIX4SsNiqnCHKjE/1alYPd/lDRVhxdhUAlv8uEhMCI5zjIJQ==", + "dev": true, + "requires": { + "@noble/hashes": "1.5.0" + }, + "dependencies": { + "@noble/hashes": { + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/@noble/hashes/-/hashes-1.5.0.tgz", + "integrity": "sha512-1j6kQFb7QRru7eKN3ZDvRcP13rugwdxZqCjbiAVZfIJwgj2A65UmT4TgARXGlXgnRkORLTDTrO19ZErt7+QXgA==", + "dev": true + } + } + }, "@noble/hashes": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/@noble/hashes/-/hashes-1.0.0.tgz", @@ -27172,6 +27393,13 @@ "integrity": "sha512-LEyx4aLEC3x6T0UguF6YILf+ntvmOaWsVfENmIW0E9H09vKlLDGelMjjSm0jkDHALj8A8quZ/HapKNigzwge+Q==", "dev": true }, + "abitype": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/abitype/-/abitype-1.0.6.tgz", + "integrity": "sha512-MMSqYh4+C/aVqI2RQaWqbvI4Kxo5cQV40WQ4QFtDnNzCkqChm8MuENhElmynZlO0qUy/ObkEUaXtKqYnx1Kp3A==", + "dev": true, + "requires": {} + }, "acorn": { "version": "7.4.1", "resolved": "https://registry.npmjs.org/acorn/-/acorn-7.4.1.tgz", @@ -38385,6 +38613,13 @@ "unfetch": "^4.2.0" } }, + "isows": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/isows/-/isows-1.0.6.tgz", + "integrity": "sha512-lPHCayd40oW98/I0uvgaHKWCSvkzY27LjWLbtzOm64yQ+G3Q5npjjbdppU65iZXkK1Zt+kH9pfegli0AYfwYYw==", + "dev": true, + "requires": {} + }, "isstream": { "version": "0.1.2", "resolved": "https://registry.npmjs.org/isstream/-/isstream-0.1.2.tgz", @@ -41819,9 +42054,9 @@ "integrity": "sha512-/aCDEGatGvZ2BIk+HmLf4ifCJFwvKFNb9/JeZPMulfgFracn9QFcAf5GO8B/mweUjSoblS5In0cWhqpfs/5PQA==" }, "typescript": { - "version": "4.8.3", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.8.3.tgz", - "integrity": "sha512-goMHfm00nWPa8UvR/CPSvykqf6dVV8x/dp0c5mFTMTIu0u0FlGWRioyy7Nn0PGAdHxpJZnuO/ut+PpQ8UiHAig==", + "version": "5.6.3", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.6.3.tgz", + "integrity": "sha512-hjcS1mhfuyi4WW8IWtjP7brDrG2cuDZukyrYrSauoXGNgx0S7zceP07adYkJycEr56BOUTNPzbInooiN3fn1qw==", "devOptional": true }, "typical": { @@ -41986,6 +42221,65 @@ "extsprintf": "^1.2.0" } }, + "viem": { + "version": "2.21.37", + "resolved": "https://registry.npmjs.org/viem/-/viem-2.21.37.tgz", + "integrity": "sha512-JupwyttT4aJNnP9+kD7E8jorMS5VmgpC3hm3rl5zXsO8WNBTsP3JJqZUSg4AG6s2lTrmmpzS/qpmXMZu5gJw5Q==", + "dev": true, + "requires": { + "@adraffy/ens-normalize": "1.11.0", + "@noble/curves": "1.6.0", + "@noble/hashes": "1.5.0", + "@scure/bip32": "1.5.0", + "@scure/bip39": "1.4.0", + "abitype": "1.0.6", + "isows": "1.0.6", + "webauthn-p256": "0.0.10", + "ws": "8.18.0" + }, + "dependencies": { + "@noble/hashes": { + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/@noble/hashes/-/hashes-1.5.0.tgz", + "integrity": "sha512-1j6kQFb7QRru7eKN3ZDvRcP13rugwdxZqCjbiAVZfIJwgj2A65UmT4TgARXGlXgnRkORLTDTrO19ZErt7+QXgA==", + "dev": true + }, + "@scure/base": { + "version": "1.1.9", + "resolved": "https://registry.npmjs.org/@scure/base/-/base-1.1.9.tgz", + "integrity": "sha512-8YKhl8GHiNI/pU2VMaofa2Tor7PJRAjwQLBBuilkJ9L5+13yVbC7JO/wS7piioAvPSwR3JKM1IJ/u4xQzbcXKg==", + "dev": true + }, + "@scure/bip32": { + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/@scure/bip32/-/bip32-1.5.0.tgz", + "integrity": "sha512-8EnFYkqEQdnkuGBVpCzKxyIwDCBLDVj3oiX0EKUFre/tOjL/Hqba1D6n/8RcmaQy4f95qQFrO2A8Sr6ybh4NRw==", + "dev": true, + "requires": { + "@noble/curves": "~1.6.0", + "@noble/hashes": "~1.5.0", + "@scure/base": "~1.1.7" + } + }, + "@scure/bip39": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/@scure/bip39/-/bip39-1.4.0.tgz", + "integrity": "sha512-BEEm6p8IueV/ZTfQLp/0vhw4NPnT9oWf5+28nvmeUICjP99f4vr2d+qc7AVGDDtwRep6ifR43Yed9ERVmiITzw==", + "dev": true, + "requires": { + "@noble/hashes": "~1.5.0", + "@scure/base": "~1.1.8" + } + }, + "ws": { + "version": "8.18.0", + "resolved": "https://registry.npmjs.org/ws/-/ws-8.18.0.tgz", + "integrity": "sha512-8VbfWfHLbbwu3+N6OKsOMpBdT4kXPDDB9cJk2bJ6mh9ucxdlnNvH1e+roYkKmN9Nxw2yjz7VzeO9oOz2zJ04Pw==", + "dev": true, + "requires": {} + } + } + }, "web3-utils": { "version": "1.8.0", "resolved": "https://registry.npmjs.org/web3-utils/-/web3-utils-1.8.0.tgz", @@ -42039,6 +42333,24 @@ } } }, + "webauthn-p256": { + "version": "0.0.10", + "resolved": "https://registry.npmjs.org/webauthn-p256/-/webauthn-p256-0.0.10.tgz", + "integrity": "sha512-EeYD+gmIT80YkSIDb2iWq0lq2zbHo1CxHlQTeJ+KkCILWpVy3zASH3ByD4bopzfk0uCwXxLqKGLqp2W4O28VFA==", + "dev": true, + "requires": { + "@noble/curves": "^1.4.0", + "@noble/hashes": "^1.4.0" + }, + "dependencies": { + "@noble/hashes": { + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/@noble/hashes/-/hashes-1.5.0.tgz", + "integrity": "sha512-1j6kQFb7QRru7eKN3ZDvRcP13rugwdxZqCjbiAVZfIJwgj2A65UmT4TgARXGlXgnRkORLTDTrO19ZErt7+QXgA==", + "dev": true + } + } + }, "webidl-conversions": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz", diff --git a/package.json b/package.json index 7da8528a..e590d37d 100644 --- a/package.json +++ b/package.json @@ -86,13 +86,16 @@ "solidity-coverage": "^0.8.11", "ts-node": "^10.7.0", "typechain": "^8.1.0", - "typescript": "^4.6.4" + "typescript": "^5.6.3", + "viem": "^2.21.37" }, "lint-staged": { "*.{js,ts}": [ "eslint --ext .ts,.js scripts test --fix", "prettier --write scripts cosign-server test hardhat.config.ts" ], - "*.sol": ["prettier --write --plugin=prettier-plugin-solidity contracts"] + "*.sol": [ + "prettier --write --plugin=prettier-plugin-solidity contracts" + ] } } diff --git a/scripts/deploy.ts b/scripts/deploy.ts index 262cba44..36671d27 100644 --- a/scripts/deploy.ts +++ b/scripts/deploy.ts @@ -5,10 +5,12 @@ // Runtime Environment's members available in the global scope. import { confirm } from '@inquirer/prompts'; +import { encodeFunctionData } from 'viem'; import { HardhatRuntimeEnvironment } from 'hardhat/types'; import { ContractDetails, RESERVOIR_RELAYER_MUTLICALLER, RESERVOIR_RELAYER_ROUTER } from './common/constants'; import { checkCodeVersion, estimateGas } from './utils/helper'; import { Overrides } from 'ethers'; +import { getTargetListOnValidatorV3, APPLY_LIST_TO_COLLECTION_ABI } from './utils/validator'; interface IDeployParams { name: string; @@ -123,15 +125,32 @@ export const deploy = async ( `npx hardhat verify --network ${hre.network.name} ${contract.address} ${paramsStr}`, ); - // Set security policy to ME default + // Set validator and list to enforce royalties if (args.useerc721c) { console.log('[ERC721CM] Setting security policy to ME default...'); 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'); + const validatorSetting = getTargetListOnValidatorV3(hre.network.name); + if (validatorSetting) { + await erc721cm.setTransferValidator(validatorSetting.validatorAddress); + console.log('[ERC721CM] Validator set to: ', validatorSetting.validatorAddress); + + const encodedData = encodeFunctionData({ + abi: APPLY_LIST_TO_COLLECTION_ABI, + functionName: 'applyListToCollection', + args: [contract.address, validatorSetting.listId], + }); + + await signer.sendTransaction({ + to: validatorSetting.validatorAddress as `0x${string}`, + data: encodedData, + }); + console.log('[ERC721CM] Validator v3 list set to: ', validatorSetting.listId); + } else { + console.log('[ERC721CM] No validator setting found for network: ', hre.network.name); + } } // Add reservoir relay as authorized minter by default diff --git a/scripts/utils/helper.ts b/scripts/utils/helper.ts index 6be69a56..b2c6b77d 100644 --- a/scripts/utils/helper.ts +++ b/scripts/utils/helper.ts @@ -110,6 +110,7 @@ export const estimateGas = async ( const getTokenName = (hre: HardhatRuntimeEnvironment) => { switch (hre.network.name) { + case 'base': case 'mainnet': case 'sepolia': case 'goerli': @@ -117,6 +118,10 @@ const getTokenName = (hre: HardhatRuntimeEnvironment) => { case 'polygon': case 'mumbai': return 'MATIC'; + case 'apechain': + return 'APE'; + case 'arbitrum': + return 'ARB'; default: return 'ETH'; } diff --git a/scripts/utils/validator.ts b/scripts/utils/validator.ts new file mode 100644 index 00000000..8ff20f47 --- /dev/null +++ b/scripts/utils/validator.ts @@ -0,0 +1,64 @@ +const LIMITBREAK_TRANSFER_VALIDATOR_V3 = + '0x721C0078c2328597Ca70F5451ffF5A7B38D4E947'; +const ME_TRANSFER_VALIDATOR_V3 = '0x721C00D4FB075b22a5469e9CF2440697F729aA13'; + +export const APPLY_LIST_TO_COLLECTION_ABI = [ + { + inputs: [ + { + internalType: 'address', + name: 'collection', + type: 'address', + }, + { + internalType: 'uint120', + name: 'id', + type: 'uint120', + }, + ], + name: 'applyListToCollection', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, +]; + +export type TransferValidatorSetting = { + validatorAddress: string; + listId: number; +}; + +// ME owned list id on transfer validator v3 +const NETWORK_VALIDATOR_LIST_ID: Record = { + // ME owned listId = 1, 2, 3 on ME owned validator + 'apechain': { + validatorAddress: ME_TRANSFER_VALIDATOR_V3, + listId: 1, + }, + // ME owned listId = 3, 4, 5 on LB owned validator + 'arbitrum': { + validatorAddress: LIMITBREAK_TRANSFER_VALIDATOR_V3, + listId: 1, + }, + // ME owned listId = 1, 2, 3 on LB owned validator + 'base': { + validatorAddress: LIMITBREAK_TRANSFER_VALIDATOR_V3, + listId: 1, + }, + // ME owned listId = 3, 4, 5 on LB owned validator + 'mainnet': { + validatorAddress: LIMITBREAK_TRANSFER_VALIDATOR_V3, + listId: 1, + }, + // ME owned listId = 3, 4, 5 on LB owned validator + 'polygon': { + validatorAddress: LIMITBREAK_TRANSFER_VALIDATOR_V3, + listId: 3, + }, +}; + +export function getTargetListOnValidatorV3( + network: string, +): TransferValidatorSetting { + return NETWORK_VALIDATOR_LIST_ID[network]; +}