From cb4e39dbdef6fa2be22d0bcf9a7f2d2b88d7002e Mon Sep 17 00:00:00 2001 From: kneelsdev Date: Thu, 7 Sep 2023 20:38:45 -0400 Subject: [PATCH 1/5] deploy and initialize script --- package-lock.json | 105 +++++++++++++++++++++++- package.json | 1 + scripts/deployArchetypeAndInitialize.ts | 105 ++++++++++++++++++++++++ 3 files changed, 209 insertions(+), 2 deletions(-) create mode 100644 scripts/deployArchetypeAndInitialize.ts diff --git a/package-lock.json b/package-lock.json index 92f3ca0..75b831d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -12,6 +12,7 @@ "concurrently": "6.4.0", "ethereumjs-util": "7.1.4", "ipfsh": "0.0.6", + "readline-sync": "^1.4.10", "solady": "^0.0.19" }, "devDependencies": { @@ -49,6 +50,7 @@ "hardhat-contract-sizer": "^2.6.1", "hardhat-gas-reporter": "^1.0.8", "hardhat-log-remover": "^2.0.2", + "hardhat-preprocessor": "^0.1.5", "invitelist": "0.0.2", "keccak256": "1.0.6", "merkletreejs": "0.2.31", @@ -9882,6 +9884,12 @@ "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==" }, + "node_modules/encode-utf8": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/encode-utf8/-/encode-utf8-1.0.3.tgz", + "integrity": "sha512-ucAnuBEhUK4boH2HjVYG5Q2mQyPorvv0u/ocS+zhdw0S8AlHYY+GOFhP1Gio5z4icpP2ivFSvhtFjQi8+T9ppw==", + "dev": true + }, "node_modules/encodeurl": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-1.0.2.tgz", @@ -11476,6 +11484,15 @@ "integrity": "sha512-8/sOawo8tJ4QOBX8YlQBMxL8+RLZfxMQOif9o0KUKTNTjMYElWPE0r/m5VNFxTRd0NSw8qSy8dajrwX4RYI1Hw==", "dev": true }, + "node_modules/fmix": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/fmix/-/fmix-0.1.0.tgz", + "integrity": "sha512-Y6hyofImk9JdzU8k5INtTXX1cu8LDlePWDFU5sftm9H+zKCr5SGrVjdhkvsim646cw5zD0nADj8oHyXMZmCZ9w==", + "dev": true, + "dependencies": { + "imul": "^1.0.0" + } + }, "node_modules/follow-redirects": { "version": "1.15.2", "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.2.tgz", @@ -22104,7 +22121,6 @@ "resolved": "https://registry.npmjs.org/bufferutil/-/bufferutil-4.0.5.tgz", "integrity": "sha512-HTm14iMQKK2FjFLRTM5lAVcyaUzOnqbPtesFIvREgXpJHdQm8bWS+GkQgIkfaBYRHuCnea7w8UVNfwiAQhlr9A==", "dev": true, - "hasInstallScript": true, "optional": true, "peer": true, "dependencies": { @@ -22493,7 +22509,6 @@ "resolved": "https://registry.npmjs.org/utf-8-validate/-/utf-8-validate-5.0.7.tgz", "integrity": "sha512-vLt1O5Pp+flcArHGIyKEQq883nBt8nN8tVBcoL0qUXj2XT1n7p70yGIq2VK98I5FdZ1YHc0wk/koOnHjnXWk1Q==", "dev": true, - "hasInstallScript": true, "optional": true, "peer": true, "dependencies": { @@ -23028,6 +23043,18 @@ "hardhat": "^2.0.0" } }, + "node_modules/hardhat-preprocessor": { + "version": "0.1.5", + "resolved": "https://registry.npmjs.org/hardhat-preprocessor/-/hardhat-preprocessor-0.1.5.tgz", + "integrity": "sha512-j8m44mmPxpxAAd0G8fPHRHOas/INZdzptSur0TNJvMEGcFdLDhbHHxBcqZVQ/bmiW42q4gC60AP4CXn9EF018g==", + "dev": true, + "dependencies": { + "murmur-128": "^0.2.1" + }, + "peerDependencies": { + "hardhat": "^2.0.5" + } + }, "node_modules/hardhat/node_modules/ansi-styles": { "version": "3.2.1", "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", @@ -23789,6 +23816,15 @@ "node": ">=6" } }, + "node_modules/imul": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/imul/-/imul-1.0.1.tgz", + "integrity": "sha512-WFAgfwPLAjU66EKt6vRdTlKj4nAgIDQzh29JonLa4Bqtl6D8JrIMvWjCnx7xEjVNmP3U0fM5o8ZObk7d0f62bA==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, "node_modules/imurmurhash": { "version": "0.1.4", "resolved": "https://registry.npmjs.org/imurmurhash/-/imurmurhash-0.1.4.tgz", @@ -26354,6 +26390,17 @@ "buffer": "^5.5.0" } }, + "node_modules/murmur-128": { + "version": "0.2.1", + "resolved": "https://registry.npmjs.org/murmur-128/-/murmur-128-0.2.1.tgz", + "integrity": "sha512-WseEgiRkI6aMFBbj8Cg9yBj/y+OdipwVC7zUo3W2W1JAJITwouUOtpqsmGSg67EQmwwSyod7hsVsWY5LsrfQVg==", + "dev": true, + "dependencies": { + "encode-utf8": "^1.0.2", + "fmix": "^0.1.0", + "imul": "^1.0.0" + } + }, "node_modules/murmurhash3js-revisited": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/murmurhash3js-revisited/-/murmurhash3js-revisited-3.0.0.tgz", @@ -28247,6 +28294,14 @@ "node": ">=8.10.0" } }, + "node_modules/readline-sync": { + "version": "1.4.10", + "resolved": "https://registry.npmjs.org/readline-sync/-/readline-sync-1.4.10.tgz", + "integrity": "sha512-gNva8/6UAe8QYepIQH/jQ2qn91Qj0B9sYjMBBs3QOB8F2CXcKgLxQaJRP76sWVRQt+QU+8fAkCbCvjjMFu7Ycw==", + "engines": { + "node": ">= 0.8.0" + } + }, "node_modules/receptacle": { "version": "1.3.2", "resolved": "https://registry.npmjs.org/receptacle/-/receptacle-1.3.2.tgz", @@ -40867,6 +40922,12 @@ "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==" }, + "encode-utf8": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/encode-utf8/-/encode-utf8-1.0.3.tgz", + "integrity": "sha512-ucAnuBEhUK4boH2HjVYG5Q2mQyPorvv0u/ocS+zhdw0S8AlHYY+GOFhP1Gio5z4icpP2ivFSvhtFjQi8+T9ppw==", + "dev": true + }, "encodeurl": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-1.0.2.tgz", @@ -42221,6 +42282,15 @@ "integrity": "sha512-8/sOawo8tJ4QOBX8YlQBMxL8+RLZfxMQOif9o0KUKTNTjMYElWPE0r/m5VNFxTRd0NSw8qSy8dajrwX4RYI1Hw==", "dev": true }, + "fmix": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/fmix/-/fmix-0.1.0.tgz", + "integrity": "sha512-Y6hyofImk9JdzU8k5INtTXX1cu8LDlePWDFU5sftm9H+zKCr5SGrVjdhkvsim646cw5zD0nADj8oHyXMZmCZ9w==", + "dev": true, + "requires": { + "imul": "^1.0.0" + } + }, "follow-redirects": { "version": "1.15.2", "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.2.tgz", @@ -51276,6 +51346,15 @@ "dev": true, "requires": {} }, + "hardhat-preprocessor": { + "version": "0.1.5", + "resolved": "https://registry.npmjs.org/hardhat-preprocessor/-/hardhat-preprocessor-0.1.5.tgz", + "integrity": "sha512-j8m44mmPxpxAAd0G8fPHRHOas/INZdzptSur0TNJvMEGcFdLDhbHHxBcqZVQ/bmiW42q4gC60AP4CXn9EF018g==", + "dev": true, + "requires": { + "murmur-128": "^0.2.1" + } + }, "has": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/has/-/has-1.0.3.tgz", @@ -51532,6 +51611,12 @@ "resolve-from": "^4.0.0" } }, + "imul": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/imul/-/imul-1.0.1.tgz", + "integrity": "sha512-WFAgfwPLAjU66EKt6vRdTlKj4nAgIDQzh29JonLa4Bqtl6D8JrIMvWjCnx7xEjVNmP3U0fM5o8ZObk7d0f62bA==", + "dev": true + }, "imurmurhash": { "version": "0.1.4", "resolved": "https://registry.npmjs.org/imurmurhash/-/imurmurhash-0.1.4.tgz", @@ -53658,6 +53743,17 @@ } } }, + "murmur-128": { + "version": "0.2.1", + "resolved": "https://registry.npmjs.org/murmur-128/-/murmur-128-0.2.1.tgz", + "integrity": "sha512-WseEgiRkI6aMFBbj8Cg9yBj/y+OdipwVC7zUo3W2W1JAJITwouUOtpqsmGSg67EQmwwSyod7hsVsWY5LsrfQVg==", + "dev": true, + "requires": { + "encode-utf8": "^1.0.2", + "fmix": "^0.1.0", + "imul": "^1.0.0" + } + }, "murmurhash3js-revisited": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/murmurhash3js-revisited/-/murmurhash3js-revisited-3.0.0.tgz", @@ -55228,6 +55324,11 @@ "picomatch": "^2.2.1" } }, + "readline-sync": { + "version": "1.4.10", + "resolved": "https://registry.npmjs.org/readline-sync/-/readline-sync-1.4.10.tgz", + "integrity": "sha512-gNva8/6UAe8QYepIQH/jQ2qn91Qj0B9sYjMBBs3QOB8F2CXcKgLxQaJRP76sWVRQt+QU+8fAkCbCvjjMFu7Ycw==" + }, "receptacle": { "version": "1.3.2", "resolved": "https://registry.npmjs.org/receptacle/-/receptacle-1.3.2.tgz", diff --git a/package.json b/package.json index ffcb42e..eae79e6 100644 --- a/package.json +++ b/package.json @@ -27,6 +27,7 @@ "concurrently": "6.4.0", "ethereumjs-util": "7.1.4", "ipfsh": "0.0.6", + "readline-sync": "^1.4.10", "solady": "^0.0.19" }, "devDependencies": { diff --git a/scripts/deployArchetypeAndInitialize.ts b/scripts/deployArchetypeAndInitialize.ts new file mode 100644 index 0000000..1912acb --- /dev/null +++ b/scripts/deployArchetypeAndInitialize.ts @@ -0,0 +1,105 @@ +import { ethers, run } from "hardhat"; +import * as readlineSync from 'readline-sync'; +import { ArchetypeLogic } from "../typechain"; + +const ZERO = "0x0000000000000000000000000000000000000000"; + +async function main() { + + // set to empty for new deploy + const LIBRARY_ADDRESS: string = "0xE11FcB03d07CDbf3D2870105b6d6BbF78d44acf5" // SEPOLIA 0.6.0 + // const LIBRARY_ADDRESS: string = "0x73cA112A50C4eAb928AaE07aAF96944d431720EF" // MAINNET 0.6.0 + const NAME: string = "my nft" + const SYMBOL: string = "MYNFT" + const CONFIG = { + baseUri: "ipfs://CID/", + affiliateSigner: "0x1f285dD528cf4cDE3081C6d48D9df7A4F8FA9383", + ownerAltPayout: ethers.constants.AddressZero, + superAffiliatePayout: ethers.constants.AddressZero, + maxSupply: 5000, + maxBatchSize: 5000, + affiliateFee: 500, + platformFee: 500, + defaultRoyalty: 500, + discounts: { affiliateDiscount: 0, mintTiers: [] } + }; + + console.log({LIBRARY_ADDRESS, NAME, SYMBOL, CONFIG}); + + if (!readlineSync.keyInYN('Is the above config correct?')) { + console.log("config not confirmed. Not deploying contract."); + process.exit(); + } + + const [deployer] = await ethers.getSigners(); + const deployerAddress = await deployer.getAddress(); + + let archetypeLogic: ArchetypeLogic; + const ArchetypeLogic = await ethers.getContractFactory("ArchetypeLogic"); + if (LIBRARY_ADDRESS === "") { + archetypeLogic = await ArchetypeLogic.deploy() + } else { + archetypeLogic = ArchetypeLogic.attach(LIBRARY_ADDRESS) + } + + + // Check the library + const expectedBytecode = (await ethers.getContractFactory("ArchetypeLogic")).bytecode; + const actualBytecode = await ethers.provider.getCode(archetypeLogic.address); + const matchRate = calculateMatchRate(expectedBytecode, actualBytecode) + + console.log("ArchetypeLogic bytecode has a match rate of", matchRate) + if (matchRate > 90) { + console.log("ArchetypeLogic bytecode match passes"); + } else { + console.log("ArchetypeLogic bytecode match fails, make sure its the correct address. Exiting ..."); + process.exit(1); + } + + const Archetype = await ethers.getContractFactory("Archetype", { + libraries: { + ArchetypeLogic: archetypeLogic.address, + }, + }); + + const archetype = await Archetype.deploy(); + + await archetype.deployed(); + + console.log("Archetype deployed to:", archetype.address); + + await archetype.initialize(NAME, SYMBOL, CONFIG, deployerAddress) + + console.log("Archetype initialized!"); +} + +main() + .then(() => process.exit(0)) + .catch(error => { + console.error(error); + process.exit(1); + }); + +/* + Uses a sliding window approach, chunkBytecode produces overlapping chunks. + E.g., for "ABCDEF" and chunk size 3, we get ["ABC", "BCD", "CDE", "DEF"]. + This ensures better matching, especially when bytecodes have minor offsets. +*/ + function calculateMatchRate(bytecode1: string, bytecode2: string): number { + function chunkBytecode(bytecode: string, chunkSize: number): string[] { + const chunks = []; + for (let i = 0; i <= bytecode.length - chunkSize; i++) { + chunks.push(bytecode.slice(i, i + chunkSize)); + } + return chunks; + } + + const chunkSize = 10; + const chunks1 = chunkBytecode(bytecode1, chunkSize); + const chunks2 = new Set(chunkBytecode(bytecode2, chunkSize)); + + const commonChunks = chunks1.filter(chunk => chunks2.has(chunk)).length; + + const maxPossibleMatches = Math.max(chunks1.length, chunks2.size); + return (commonChunks / maxPossibleMatches) * 100; +} \ No newline at end of file From 932e3e4fa4299c80087570a88b7de0aff3442c8f Mon Sep 17 00:00:00 2001 From: kneelsdev Date: Thu, 7 Sep 2023 21:20:55 -0400 Subject: [PATCH 2/5] add batch send eth script --- package.json | 1 + scripts/batchSendEth.ts | 111 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 112 insertions(+) create mode 100644 scripts/batchSendEth.ts diff --git a/package.json b/package.json index eae79e6..44c2428 100644 --- a/package.json +++ b/package.json @@ -25,6 +25,7 @@ "homepage": "https://github.com/scatter-art/contracts#readme", "dependencies": { "concurrently": "6.4.0", + "csv-parse": "^5.5.0", "ethereumjs-util": "7.1.4", "ipfsh": "0.0.6", "readline-sync": "^1.4.10", diff --git a/scripts/batchSendEth.ts b/scripts/batchSendEth.ts new file mode 100644 index 0000000..54cb8ee --- /dev/null +++ b/scripts/batchSendEth.ts @@ -0,0 +1,111 @@ +import { ethers, } from "hardhat"; +import * as readlineSync from 'readline-sync'; +import * as fs from 'fs'; +import { parse } from 'csv-parse'; +import { ArchetypeBatch } from "../typechain"; + +function parseCsv(csvString: string): Promise { + const options = { + columns: true, + skip_empty_lines: true + } + return new Promise((resolve, reject) => { + parse(csvString, options, (err, output) => { + if (err) { + reject(err); + } else { + resolve(output); + } + }); + }); +} + +async function main() { + + const BATCH_ADDRESS: string = "0x0e1356208CA2eB9Cc4EFaEb42cc8287CB7ED8e1F" // SEPOLIA + // const BATCH_ADDRESS: string = "0x6Bc558A6DC48dEfa0e7022713c23D65Ab26e4Fa7" // MAINNET + + // Check the batch contract + const archetypeBatch: ArchetypeBatch = await ethers.getContractAt("ArchetypeBatch", BATCH_ADDRESS); + const expectedBytecode = (await ethers.getContractFactory("ArchetypeBatch")).bytecode; + const actualBytecode = await ethers.provider.getCode(archetypeBatch.address); + const matchRate = calculateMatchRate(expectedBytecode, actualBytecode) + + console.log("ArchetypeBatch bytecode has a match rate of", matchRate) + if (matchRate > 90) { + console.log("ArchetypeBatch bytecode match passes"); + } else { + console.log("ArchetypeBatch bytecode match fails, make sure its the correct address. Exiting ..."); + process.exit(1); + } + + const csvContent = fs.readFileSync('./scripts/refundList.csv', 'utf-8'); + const records = await parseCsv(csvContent); + + let balances: { [address: string]: ethers.BigNumber } = {}; + let totalValue = ethers.BigNumber.from(0); + for (let record of records) { + try { + let address = ethers.utils.getAddress(record['address']); + let value = ethers.utils.parseEther(record['value']); + + if (!balances[address]) { + balances[address] = value; + } else { + balances[address] = balances[address].add(value) + } + totalValue = totalValue.add(value); + } catch { + continue; + } + } + + console.log(balances) + console.log({totalValue: totalValue, totalValueFormatted: ethers.utils.formatEther(totalValue)}) + + if (!readlineSync.keyInYN('Are the above values correct?')) { + console.log("config not confirmed. Not sending eth."); + process.exit(); + } + + // Formulate the calls + let targets = Object.keys(balances); + let values = Object.values(balances).map(v => v.toString()); + let datas = targets.map(() => "0x"); + + let tx = await archetypeBatch.executeBatch(targets, values, datas, { value: totalValue }); + let receipt = await tx.wait(); + + console.log(`Transaction hash: ${receipt.transactionHash}`); +} + +main() + .then(() => process.exit(0)) + .catch(error => { + console.error(error); + process.exit(1); + }); + +/* + Uses a sliding window approach, chunkBytecode produces overlapping chunks. + E.g., for "ABCDEF" and chunk size 3, we get ["ABC", "BCD", "CDE", "DEF"]. + This ensures better matching, especially when bytecodes have minor offsets. +*/ +function calculateMatchRate(bytecode1: string, bytecode2: string): number { + function chunkBytecode(bytecode: string, chunkSize: number): string[] { + const chunks = []; + for (let i = 0; i <= bytecode.length - chunkSize; i++) { + chunks.push(bytecode.slice(i, i + chunkSize)); + } + return chunks; + } + + const chunkSize = 10; + const chunks1 = chunkBytecode(bytecode1, chunkSize); + const chunks2 = new Set(chunkBytecode(bytecode2, chunkSize)); + + const commonChunks = chunks1.filter(chunk => chunks2.has(chunk)).length; + + const maxPossibleMatches = Math.max(chunks1.length, chunks2.size); + return (commonChunks / maxPossibleMatches) * 100; +} \ No newline at end of file From 6d0785a0bb8e0ed550467248a456a07943154f14 Mon Sep 17 00:00:00 2001 From: PolyDegen Date: Thu, 28 Sep 2023 22:35:16 +0530 Subject: [PATCH 3/5] add refundList.csv --- package-lock.json | 11 ++ package.json | 1 + scripts/batchSendEth.ts | 68 +++++----- scripts/data/refundList.csv | 259 ++++++++++++++++++++++++++++++++++++ typechain/hardhat.d.ts | 9 ++ typechain/index.ts | 4 +- 6 files changed, 320 insertions(+), 32 deletions(-) create mode 100644 scripts/data/refundList.csv diff --git a/package-lock.json b/package-lock.json index 75b831d..c086388 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10,6 +10,7 @@ "license": "ISC", "dependencies": { "concurrently": "6.4.0", + "csv-parse": "^5.5.0", "ethereumjs-util": "7.1.4", "ipfsh": "0.0.6", "readline-sync": "^1.4.10", @@ -9338,6 +9339,11 @@ "optional": true, "peer": true }, + "node_modules/csv-parse": { + "version": "5.5.0", + "resolved": "https://registry.npmjs.org/csv-parse/-/csv-parse-5.5.0.tgz", + "integrity": "sha512-RxruSK3M4XgzcD7Trm2wEN+SJ26ChIb903+IWxNOcB5q4jT2Cs+hFr6QP39J05EohshRFEvyzEBoZ/466S2sbw==" + }, "node_modules/d": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/d/-/d-1.0.1.tgz", @@ -40477,6 +40483,11 @@ "optional": true, "peer": true }, + "csv-parse": { + "version": "5.5.0", + "resolved": "https://registry.npmjs.org/csv-parse/-/csv-parse-5.5.0.tgz", + "integrity": "sha512-RxruSK3M4XgzcD7Trm2wEN+SJ26ChIb903+IWxNOcB5q4jT2Cs+hFr6QP39J05EohshRFEvyzEBoZ/466S2sbw==" + }, "d": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/d/-/d-1.0.1.tgz", diff --git a/package.json b/package.json index 44c2428..54c92f0 100644 --- a/package.json +++ b/package.json @@ -11,6 +11,7 @@ "start": "concurrently \"cd api && npm start\" \"cd app && npm run dev\"", "deploy": "npx hardhat run scripts/deployArchetype.ts --network localhost", "network": "npx hardhat node", + "refund": "npx hardhat run scripts/batchSendEth.ts --network mainnet", "verify": "npx hardhat verify 0xc078Aed674c230cDD7ADD602E077797d08d8f0c2 --network goerli" }, "repository": { diff --git a/scripts/batchSendEth.ts b/scripts/batchSendEth.ts index 54cb8ee..8bd7635 100644 --- a/scripts/batchSendEth.ts +++ b/scripts/batchSendEth.ts @@ -1,14 +1,15 @@ -import { ethers, } from "hardhat"; -import * as readlineSync from 'readline-sync'; -import * as fs from 'fs'; -import { parse } from 'csv-parse'; +import { ethers } from "hardhat"; +import * as readlineSync from "readline-sync"; +import * as fs from "fs"; +import { parse } from "csv-parse"; import { ArchetypeBatch } from "../typechain"; +const path = require("path"); function parseCsv(csvString: string): Promise { const options = { columns: true, - skip_empty_lines: true - } + skip_empty_lines: true, + }; return new Promise((resolve, reject) => { parse(csvString, options, (err, output) => { if (err) { @@ -21,38 +22,42 @@ function parseCsv(csvString: string): Promise { } async function main() { - - const BATCH_ADDRESS: string = "0x0e1356208CA2eB9Cc4EFaEb42cc8287CB7ED8e1F" // SEPOLIA - // const BATCH_ADDRESS: string = "0x6Bc558A6DC48dEfa0e7022713c23D65Ab26e4Fa7" // MAINNET + // const BATCH_ADDRESS: string = "0x0e1356208CA2eB9Cc4EFaEb42cc8287CB7ED8e1F"; // SEPOLIA + const BATCH_ADDRESS: string = "0x6Bc558A6DC48dEfa0e7022713c23D65Ab26e4Fa7"; // MAINNET // Check the batch contract - const archetypeBatch: ArchetypeBatch = await ethers.getContractAt("ArchetypeBatch", BATCH_ADDRESS); + const archetypeBatch: ArchetypeBatch = await ethers.getContractAt( + "ArchetypeBatch", + BATCH_ADDRESS + ); const expectedBytecode = (await ethers.getContractFactory("ArchetypeBatch")).bytecode; const actualBytecode = await ethers.provider.getCode(archetypeBatch.address); - const matchRate = calculateMatchRate(expectedBytecode, actualBytecode) + const matchRate = calculateMatchRate(expectedBytecode, actualBytecode); - console.log("ArchetypeBatch bytecode has a match rate of", matchRate) + console.log("ArchetypeBatch bytecode has a match rate of", matchRate); if (matchRate > 90) { console.log("ArchetypeBatch bytecode match passes"); } else { - console.log("ArchetypeBatch bytecode match fails, make sure its the correct address. Exiting ..."); + console.log( + "ArchetypeBatch bytecode match fails, make sure its the correct address. Exiting ..." + ); process.exit(1); } - const csvContent = fs.readFileSync('./scripts/refundList.csv', 'utf-8'); + const csvContent = fs.readFileSync(path.join(__dirname, "./data/refundList.csv"), "utf-8"); const records = await parseCsv(csvContent); - let balances: { [address: string]: ethers.BigNumber } = {}; + const balances: { [address: string]: ethers.BigNumber } = {}; let totalValue = ethers.BigNumber.from(0); - for (let record of records) { + for (const record of records) { try { - let address = ethers.utils.getAddress(record['address']); - let value = ethers.utils.parseEther(record['value']); + const address = ethers.utils.getAddress(record.address); + const value = ethers.utils.parseEther(record.value); if (!balances[address]) { balances[address] = value; } else { - balances[address] = balances[address].add(value) + balances[address] = balances[address].add(value); } totalValue = totalValue.add(value); } catch { @@ -60,21 +65,24 @@ async function main() { } } - console.log(balances) - console.log({totalValue: totalValue, totalValueFormatted: ethers.utils.formatEther(totalValue)}) + console.log(balances); + console.log({ + totalValue: totalValue, + totalValueFormatted: ethers.utils.formatEther(totalValue), + }); - if (!readlineSync.keyInYN('Are the above values correct?')) { + if (!readlineSync.keyInYN("Are the above values correct?")) { console.log("config not confirmed. Not sending eth."); process.exit(); } // Formulate the calls - let targets = Object.keys(balances); - let values = Object.values(balances).map(v => v.toString()); - let datas = targets.map(() => "0x"); + const targets = Object.keys(balances); + const values = Object.values(balances).map(v => v.toString()); + const datas = targets.map(() => "0x"); - let tx = await archetypeBatch.executeBatch(targets, values, datas, { value: totalValue }); - let receipt = await tx.wait(); + const tx = await archetypeBatch.executeBatch(targets, values, datas, { value: totalValue }); + const receipt = await tx.wait(); console.log(`Transaction hash: ${receipt.transactionHash}`); } @@ -88,14 +96,14 @@ main() /* Uses a sliding window approach, chunkBytecode produces overlapping chunks. - E.g., for "ABCDEF" and chunk size 3, we get ["ABC", "BCD", "CDE", "DEF"]. + E.g., for "ABCDEF" and chunk size 3, we get ["ABC", "BCD", "CDE", "DEF"]. This ensures better matching, especially when bytecodes have minor offsets. */ function calculateMatchRate(bytecode1: string, bytecode2: string): number { function chunkBytecode(bytecode: string, chunkSize: number): string[] { const chunks = []; for (let i = 0; i <= bytecode.length - chunkSize; i++) { - chunks.push(bytecode.slice(i, i + chunkSize)); + chunks.push(bytecode.slice(i, i + chunkSize)); } return chunks; } @@ -108,4 +116,4 @@ function calculateMatchRate(bytecode1: string, bytecode2: string): number { const maxPossibleMatches = Math.max(chunks1.length, chunks2.size); return (commonChunks / maxPossibleMatches) * 100; -} \ No newline at end of file +} diff --git a/scripts/data/refundList.csv b/scripts/data/refundList.csv new file mode 100644 index 0000000..2634bd9 --- /dev/null +++ b/scripts/data/refundList.csv @@ -0,0 +1,259 @@ +address,value +0xEFDD802C3472cD271B65caaEfe3820BDF833Bb52,0.05 +0xaAA5ee9449F0935969fAFdD44677559BC02042f2,0.05 +0xF7c6ed98CEb19f6044a702Cf14602B08798944cF,0.05 +0x19f640e19F777a8206ed892e003a436eF427999F,0.05 +0x32b4F0DE622904ba561f66E9E27094BfAb2952C2,0.05 +0xD65abcA843f8b35ecde3fe67c95779134fD4A018,0.05 +0x75aC87867C347EE901da3b05489B35112d980e1f,0.05 +0x7Be55317fE283d15b4B84C3a373679483Df28B72,0.05 +0xcfBBdF308FbED76A96e6059A810F086192655082,0.05 +0x0EAaaa876465deb2B9184F89a08ba2351Fd2D821,0.05 +0x4099555ad12a30870501b957a23ca567cf0ca88a,0.05 +0xB2582C87b7aed282B7C5345ae986af64c857D99c,0.05 +0x02782369877a02C290B27C00f8494b14c399DF53,0.05 +0x2A5318d92f93569D85C3c4fEb01c36d31e155EC5,0.05 +0x52146fFf9Db1208fcE2d15253aCA5D9B3f6b3048,0.05 +0xF792a1d9BA34C4892C004cD2227F3EE819c77304,0.05 +0x7B80368a57D5B8d2511546BCf639015C46958002,0.05 +0xcaa7783BcaE371f75C9c675c82A4f4B6D0B570e4,0.05 +0x7797B31C1BC72B0f5e575dA284b0954e19cB67dA,0.05 +0x2f59Ec271Bb23fCB88A01328EAD107b5A9F7B75A,0.05 +0xf18b6B944F9Ee1cAD1C9CB8e1aAD0a0bb98Df499,0.05 +0x4aDb2981E42241e268e0EF4711af9f0daEE0E32E,0.02 +0x2fEC27a886bf04D02006E66026B9de5cA6414e3f,0.05 +0x4aB62D17E2c8f9ca79AD3429DA12D495a1055EAe,0.05 +0xC0bF08682e29796f27652a26aBd98650e374C97D,0.05 +0x170AcB0595C1e53f4d7E82c58Bc698b7806e58E5,0.05 +0x31043fe8C590A4f858532AEC5B601f63f23947BF,0.05 +0x201f3C75cBd3c0678F49090B7247eb501c047485,0.05 +0xe63fA6524Fa2d252cC3B46fDb4839900BfBFBB49,0.05 +0xafa9834eC213Feb5102480986FC453632df9510E,0.05 +0x9f31a480fd2425283A73F70f96883f5793f90EAd,0.05 +0xB3f0a16c246187381C9A1fb192C6eC8a9AE961f5,0.05 +0x21bFa5c8990032E16ff04BA8D369fB0F5a815Ad6,0.05 +0x815282DB3de3e9379bbE9dfF04d1a8d2198b744b,0.05 +0x73Fae928C6dc77068d9A7D75216b7e5bcEA18cb0,0.05 +0x0890658818d01b70146fc547BbB6B71987eD4E7b,0.05 +0x38668c1ad4F991C2d8246A7fe1bA3A05df0F5Bf6,0.05 +0x68Fb3961C3218D4F679e472AB72393b6287f2c49,0.05 +0xD5394a34422550831Cd7D3eBc1b8163092BD101D,0.05 +0x11F1dc878C755E1e1901b819045ec2E1b1b4e865,0.05 +0xDe96fDFC8cdb35b213aE4b5bDA40D6AFDe39771b,0.05 +0xACd3f76D932F6c4f0731a85Be68a6897F88CabB0,0.05 +0x10547e22baC3eF28039d4eCe86e40081634911c6,0.05 +0x1A569D78D8F445C77f61adc559BE9d3dCd3e288D,0.05 +0x3e95aAa5B966AE244F75aaca17834DbcB05FA114,0.05 +0x1F182e402372f31d05d79f628c3eB16d73c165A3,0.05 +0x6B6445369ee8CfD592467d3d205BB51e25754330,0.05 +0xB9Bc0e8B96E76F5863A9bF926079429D9861fd14,0.05 +0x01CFB3aeE7267877d4Dd07d659e4f10bBaAfA1f3,0.05 +0x3eEcc77755eEebF913498D25e583887372Dbaf9A,0.05 +0x6b3709e0A0e878397587221d3d38223D34662fD9,0.05 +0xd5e498570d50881b1865f0EEbcBfC565E4606c62,0.05 +0xD301b5fB85a66Fc84B2931b26b46Cf16a7DbD751,0.05 +0x1feDb294fFbb91f3654dDf79A344d8F6b245a9c9,0.05 +0xEEdF7A957666bc1a3DA448E5A248c768A94A567B,0.05 +0x7a7892b3EF64ABeDe8348684BA57a37fd7EDC0d9,0.05 +0x28FD522E9682997f18b824ed104d9996D4001782,0.03 +0x210a0C4b4D55A87b7eb98bB2205DD53b77033Bec,0.05 +0x0f06bcBBb8f3285c66aC7ADF8B5a1e4AeF8EE129,0.05 +0x7e8B0E64F6F2B7E813D2007F513F19A666847b42,0.05 +0x820f52A5691dcD00E9656ad0f74804b7bd141276,0.05 +0xF588b1fDe5B8796CE0505869ddFc1f8f9F502Aa1,0.05 +0x44b1b1138fE257794717122E0b515B667EC09C0E,0.05 +0xc026d70DA21f9360d34f95C4664d90819Cf752e6,0.05 +0x52A7d9aeD72bde27052eB4A82BE45EF3987ab71b,0.05 +0xe84b19a5F1Cfc0C2B3cf2127A458DAEdB1B4fCb4,0.05 +0x14425eE4B0A419aa797Cd9979AD91e870f9e4D62,0.05 +0x35c56Be9b9747c06B236B27c735FA98E724DD1c5,0.05 +0xA8dAa4FD7f080aD1d34597AC6a82DC86dF265180,0.05 +0xDa9EB754793f5fd1Ef49e60fC64f12072C3f3ee9,0.05 +0xb68107a544c23f3630d5c5283667be94c5ddc4ed,0.05 +0x78b1c5fab52c4bbc17ef90b5388570d2b53d9a76,0.05 +0xf8511df3550070fb5778b37785a22cf12b3db7dc,0.05 +0xc53d65e9611c2e8e00ad3f7e7dad7a2c4c6e3045,0.04959441003 +0x43134dd29523c86c1ac6d0ccb920278b2b89eac0,0.05 +0x246713f30adc84875a0927a83fbccc648984a8da,0.05 +0xaac98d26f483fcbc10aa849f01f82d50fb162567,0.05 +0x568e77d2dc8f5deb370d3aed95e51a3b2d3bf7dd,0.05 +0x8eb3e8e89cfae673460ae423bd6edf515b9de8f8,0.05 +0x6293192944038e216de0d0cf06056e697682a2d5,0.05 +0x126553b789bffa9d2aab7762511ca29418c89d9c,0.05 +0x007423a71af436392e807cfdd38800868e32f9bb,0.05 +0x32cf53e80641b3365dc52882b520d317d807342b,0.05 +0x43d7193cf6b4718e856949cad4d1d0e093324f0e,0.05 +0xcf952e2bfa80c995a1ff94985394dcbb27d71ba4,0.05 +0x57d180bb8bfb5b021f96dd71eb499f70294ce4ae,0.05 +0x5d7d892511191f2d7da0aa32aaccbac8b9d2c181,0.05 +0x0a9c52dcce024dd72aafeb43c1c253b93ab6ee2c,0.05 +0xd37b7b7ae0814ba69e81159e5315a2c4fc560307,0.05 +0xf809042b0d5f46a69d8a646330f76b1ca356be0b,0.05 +0x39847e7c4a5ddc7ef5766f1c0f13070332afe726,0.05 +0xa7f08f485e6f4af2272328b6bf42cdf11e827f56,0.05 +0xea388c0bf4cbea270473a0e4218bed7aa26ae4a7,0.01 +0x138a581b2ca20a72b705d88c1cd722d34cb88e2b,0.05 +0x2fca42bb308cbc7ab6067285080c38173b7e7152,0.05 +0x03da6b5a21e3f3bf9c508ae7e97510887e1aeabb,0.05 +0x6b5b5f2de5fb8ac403c2632a21b55efc4dcc1ed3,0.05 +0x8610ff806682f712ee4648647c04e49a9c4d65cb,0.05 +0x6eb7b2699cda6690d7ff955d1be2c553507f7cdf,0.05 +0x19d6e66f3c967ef53b62cfdf198ce4d5372a5ce8,0.05 +0x2d86499a410a9ac2139833ba8d6942b8a8700a7b,0.05 +0xccd239b1ca5fb55068e72368327bb6e143ea5ac7,0.05 +0xf8a6c758b0478ddfacf5c95a1f507415ad51a831,0.05 +0x32efdb659e7194367f2bc1db4abe9ad10c3448cc,0.05 +0x05bd50f2a782602bae8a228ffaeabc4a56a896b9,0.05 +0xee0d3a42ea15660fd4261036c1bf6ba33a0cf0f6,0.05 +0xdb58db310b3512c4b2266831fce9bc654d0b18fd,0.05 +0xc791bad11c80535e338bf97a99fbc42ec218a51a,0.05 +0x672ecffaa0bfc08191a9b52329c7d8295c2c3d09,0.05 +0x8b27cd7b03f285b32186d1f6b114e4333e4fb181,0.05 +0x6b3cbcd407ae97d584b9669c5a56b8cc218dcd1b,0.05 +0x33372a300fb17200055a680ca418575455498235,0.05 +0x992ced559e04be7890f5f152236a2ccf6a9a2843,0.05 +0xdd02742baec73ad2460054a01cc41ee2ae41ed2d,0.05 +0x6e59ac9d1e08daf0ae635de9afe3ad1b272048de,0.05 +0xaf673e793c365229c2f17f4e7f95ce6a95d07466,0.05 +0x02f1def94e50063a32acda4be8188f1b3b7bdcc5,0.05 +0x0272a76aadea13f0418a0e2d956bee9f07ecdcd6,0.05 +0x0f9d76acdbc4417b026f876be1e2042e45f3bcd2,0.05 +0xdea857e0896837a624b810e255f9b3848adc8efe,0.05 +0xdead9a1ae5481e3eb4d22497511b6187544faded,0.05 +0x6b6d15c1042ef292c1c258fa8d2b3d7e4161cdc4,0.05 +0x9d677132e636bfce3275cc067d2cd3b11f16903a,0.05 +0xb43e269be65518658e22b6118e67176fece91a7e,0.05 +0x2081e188f138488e4ca7ebf5e19ef6f9d1d3d717,0.05 +0xd508f8d40f4e23fccefbacf6a8365282420efb82,0.05 +0xbb668495e3b7803a358884c8f1cb6404e819bb64,0.05 +0x492267078361a00c342b56517aea043f5a8e4466,0.05 +0xd35f45193f69073c19c68f6584cd8d1064cf3533,0.05 +0xa3ddf7e2907c5a94fa337218d29c539f6d1b6edb,0.05 +0x385915c3c38c880eb2fe9f628e24b519f4968738,0.05 +0xc0fac8f7779f2b9db9b4b5574ca3c716970823a2,0.05 +0xa1e25b837b22b5034fae1c4d90431f6e7fc61a17,0.05 +0x2576676a94854e4a1f4136d1d948c76daf9c2f93,0.05 +0x9eb4fe33c47319fa146d4bb76e6d600ac83e1c9e,0.05 +0x2314b041aed2bcb3054fdaa5abf5460bbc1ab876,0.05 +0x88febd0a4ab094ef59954cb229235316a2d15952,0.05 +0x68182338027f35d3b2dee6ba4b0d9d833719e578,0.05 +0x7fcc26970c765b6af6966af6d81f541dfe2e195f,0.05 +0x1d17541e010761e0687a51bc27a6c0a8e7f9d4af,0.05 +0x526337c34ff95c1706f8be9821f37fadb9db2ceb,0.05 +0x470f8da3d708e23c3402056e611e66a9d046dd7c,0.05 +0x0115cd06b91731ea3aac11d9073b2d89e3c3b082,0.05 +0x730aba725664974efb753ee72ca789541c733db4,0.05 +0x83a26b7bd07d5bb58b038887f8ac8557736f65ec,0.05 +0xa040c6fc91dabca0f5ec1d32fe7241a94e43ea7d,0.05 +0x06cbe8063205b60c4ac8b73d70e5870ac63c8aa4,0.05 +0x12bee7a5c2b1dfd1baced332ebebdd1b3fe68e91,0.05 +0x58e12b6a68530d8eaf1925f30b9386ef7176feb0,0.05 +0x5aba902c17afd30c7abbc65d71bd5714a2671155,0.05 +0x5b93972361d074e4ba897292afac60dc671ab6ae,0.05 +0x7ca462fef213b221832a0e9c0d0406a2b49c95bc,0.05 +0x4038a44b34dc6974b2d609715c00da7df845c4f9,0.05 +0x89db7449a656a3f3075f6d4542a6c221fae15316,0.05 +0x5c0200218ffce954145c57d3a09738a922d22337,0.05 +0x7da85687dbb8966237dc9f4c774d62d8d21947b1,0.05 +0xaa9c52276069b58227697805f24707e175313351,0.05 +0x9155927619c94bf4a1d931e487dee74c92017930,0.05 +0xe9ed3ad8e68b3925a33cab867a29c73e8357cfc4,0.05 +0xf9e7c73c5ce617baff2c7694fe625a326611c27c,0.05 +0x07427c476501e03b1802541625cefd1df24484d2,0.05 +0x449c51e9b517aa6c12fe6d44f136b64aac32fbaf,0.05 +0xdbe84e2326cc0ea420dd3aff8713fb1e465776df,0.05 +0x4f27ee7ad5ef8d881f62511a36a245e99eaed800,0.05 +0x4e322ad2809c5cd20dc29c1eb0e972d67a9eb3e7,0.05 +0xd301b5fb85a66fc84b2931b26b46cf16a7dbd751,0.05 +0x9e35c408fd3cd4981d95cc3fa49ef7acb213e9fb,0.05 +0x299fee10cd3f03ebb2f9eb5d59bfeb6c502dfeeb,0.05 +0xb1e079854268985431935ce53aa54c8e1722fa0d,0.05 +0x08db6002f22dfcbf5f4e09038a451c26dccc9ac0,0.05 +0xaecfe4eff84a1cd9a24accc1914ac537af7f6e1b,0.05 +0x4b4763fec9099ed66403cf353898d46145b136cd,0.05 +0xee0e12d6150813f49beb4a5359c9f70ab0b88815,0.05 +0xbda1741c86954e6022701881965a9047caf2c6a4,0.05 +0x0ab14149a86332f5e7b5f0b3b2b7847ee7ff7b0b,0.05 +0xe1e1f32f5d86e4bcf91c375e09d02225a76c8d21,0.05 +0xad615f88d4483b80dd415a0cf533c027d6ecde01,0.05 +0x1a9175bc9a928187bbd21e711987576bd04bfe61,0.05 +0xd9e449d54914984db1b3fa4022cba4fac9fe95b8,0.05 +0x2450e4344deabc72cebe4532b0800c33c3f7500a,0.05 +0xacae6a30a2550787c63c1ab96dbb174411c329ce,0.05 +0x93e90eb4f36d3bfb760e07977d9d1ca9e4574139,0.05 +0x33743a9d8d54eeabcdaed6e8e4be62d38230e564,0.05 +0x4ada23a97451e0b43444abe15a2ea50a3e6110f9,0.05 +0xbb09152ccf12a44e9f9478ca4713ee29d6888888,0.05 +0x1b099a0f9f49078b7fe52a139fbe43c8e5f6efb8,0.05 +0x1038384f5bc3a3f16acffc439edbafb0eeaee232,0.05 +0x70a16f2a51dd6a32b42c41afbe15772d652abaff,0.05 +0x800d304399ddfbb0a8ef7acc3197dc99f35d8ae6,0.05 +0x011f4c1045214949328f669d5432171ee1cfdd5c,0.05 +0x187fbe05b796bf18a740ef3e7d1d8abaa0082e4a,0.05 +0x7ceab2270ac57cb547fb58d054a5f8146cb3ef52,0.05 +0xcfe9c3afa9492b4404eb0a9b237f2c07315f2556,0.05 +0x4a671356dddf2e12bcba704bee80b956d7e0da8d,0.05 +0x05b668e202ba99e09b605560e3606b63812ca6a6,0.05 +0x1bcbbad6f2aa0c3420309672d3b08f85aef2683b,0.05 +0x78f66d1f6f40807a88daa0ba2892ef3a7d28c927,0.05 +0x327c86581e15d6a72207e655216938ef10c78999,0.05 +0x35948609753e169b0dccc6412f537c8ee7ecea73,0.05 +0x55ac335bf3e9032bb69090f1d704e5346770cce9,0.05 +0x0528f7f19eb407b41d2369c1e88d437fcfd13e6f,0.05 +0xa086c3bbf195aa18bee2805d568072b8af58fbd6,0.05 +0x70536936907f5c21c5467fea77ff95a20945a61d,0.01 +0xb051e29500066d77e3715a95a583fabf016efb31,0.005 +0x7aaacf5381a2a0e029f0526b85e07924eb09fa37,0.05 +0x8f70b3ac45a6896532fb90b992d5b7827ba88d3c,0.05 +0x6b1b45c925b29ea9d5bdde5490d7016edd288700,0.05 +0x624d3d9069b46603eeda137aac49441d6a7d9110,0.01 +0x9a1dc1bdd3a92422dd93c4a568b34c27b3644444,0.05 +0x6c7ffd767a2d179ee1a9e89e49ecb2f8f771e837,0.05 +0xafef0d037d0ea9542ac29752a4860c7f472b919e,0.05 +0xc0454a26dcb6fcf8b612e070a47ec078139de591,0.05 +0x4b59fdf70b9d8281dff5a04dc37a71a94463d4bf,0.05 +0x8b833437f92474613c10311cd993bc6e82c5ffe6,0.05 +0x05234ed1cab8f3173fa48df4ef4fae7390286661,0.05 +0xce7b29586c5371e315d9080b4508fc93c512bab0,0.05 +0x0eaeb1cf458e2aa1781a9566fac56180c54a5eda,0.05 +0x1f7e787a20b84ac6d20a319e4eff57e6d290c5eb,0.05 +0xf4003bec8088f1a187c7a889971685e7460a27c7,0.05 +0x8876902ef3e0626d5e9521d52930ca586ad325ce,0.05 +0x55701a8a8f3bb87db53b38a9e27df23e85d024ab,0.05 +0xb32238e06e480ddae5b4a57a9288e839461b2435,0.05 +0x000000002d4db35b28c690a28a7b4d58f1e2c738,0.05 +0xd28cd87918545d173f15886a77008032d5ce6aaa,0.05 +0xbbf6059c31c377c6ec37cbef6487d9cc0d2a8307,0.01 +0x296274082f06406d66ec2f155b5ffbe998ca9410,0.05 +0x75bc0cc04b443ca707a6426d2b960a059441a5c1,0.05 +0xb5b0f3dd0ac67d97ad7bb14de9b3c411d7091857,0.05 +0x08f60397db11bad8b225f36aac866a13f19e0457,0.05 +0xb376137b79af638c2bf26beee2c4cd6184966b8b,0.05 +0x5feacb48000f0dbfa523a4eb8fb8c3ea295034a7,0.05 +0x037b41bbc7ff4120c18db161d62c39522e8ae0a5,0.05 +0x7523e9757a5531d5eb629f6cea85ae94ee98b839,0.05 +0xb63c26620481b5ee5bb15a33cb0390877ff83dde,0.05 +0x9f394f68da843c5f388cb8e9ab262c224346eec3,0.05 +0x87ad66b64843467115e425df088c438f6aedb24e,0.05 +0x8b0c3eef1443315ee63e955d4167ade9a52e75fb,0.05 +0x520499977253f8688344ae29afa6d3f153c4072d,0.05 +0xab7ea013c46e14098474850b019f33b458bbf8b9,0.05 +0x5d528d717b44642f09fdcb1dd96bd427de408715,0.05 +0x38237d83555b6e46d0bcd2f56c7af8cbedcecd13,0.05 +0x42125be48e9837fe5e0b68c0bc0152e5a8a8c50c,0.05 +0xf448ba3ab40df0d3c324051ec889bbdf8aebd79f,0.05 +0x60dd57724d56918fe0814b4293e85d825517a997,0.05 +0x61590c830e7a4ade6d27e39f3d872bdf5a37c9ac,0.05 +0xb91d7226c999629241ad1f3322875144ebba9d63,0.05 +0x8c7c1f1f26050aaaed5992b41291f34f7b731679,0.05 +0x1dd488fbba94c408b3a6a6200daeb72bce4a943a,0.05 +0x42b21a5285424b0547f4e2c61d937ea1b19f0c5b,0.05 +0x43227629cdba0b8cedfc307dec96eb4ae050ad14,0.05 +0x03c1136a900fd4f0511ce1008e97dc2ee00de856,0.05 +0x5c0244174cd2b2b2c4dbbbf69b94b323e59670b4,0.05 +0x6e9a4c0c11e4da2ffa060e069fe0f5a6decd25f0,0.05 +0x5ccca9a23a7622704b696529ba22922756501a37,0.05 +0xa50f399e2570ae41e17488fbd8e2368b604eed9c,0.05 +0xd8b4cb6ae2cc72217831104d400134ce0ce05352,0.00312230701 +0xfb2285df9dfbb69188ee8fab3ebf23422a3910a6,0.05 +0x2f2b9a0c53fd4d21499de7f6c8eb536ba0ee6a63,0.05 \ No newline at end of file diff --git a/typechain/hardhat.d.ts b/typechain/hardhat.d.ts index c6526e4..1831f31 100644 --- a/typechain/hardhat.d.ts +++ b/typechain/hardhat.d.ts @@ -48,6 +48,10 @@ declare module "hardhat/types/runtime" { name: "IERC20Upgradeable", signerOrOptions?: ethers.Signer | FactoryOptions ): Promise; + getContractFactory( + name: "ERC721Upgradeable", + signerOrOptions?: ethers.Signer | FactoryOptions + ): Promise; getContractFactory( name: "IERC721MetadataUpgradeable", signerOrOptions?: ethers.Signer | FactoryOptions @@ -242,6 +246,11 @@ declare module "hardhat/types/runtime" { address: string, signer?: ethers.Signer ): Promise; + getContractAt( + name: "ERC721Upgradeable", + address: string, + signer?: ethers.Signer + ): Promise; getContractAt( name: "IERC721MetadataUpgradeable", address: string, diff --git a/typechain/index.ts b/typechain/index.ts index 2edf2e9..00f356b 100644 --- a/typechain/index.ts +++ b/typechain/index.ts @@ -10,6 +10,7 @@ export type { IERC1155MetadataURIUpgradeable } from "./IERC1155MetadataURIUpgrad export type { IERC1155ReceiverUpgradeable } from "./IERC1155ReceiverUpgradeable"; export type { IERC1155Upgradeable } from "./IERC1155Upgradeable"; export type { IERC20Upgradeable } from "./IERC20Upgradeable"; +export type { ERC721Upgradeable } from "./ERC721Upgradeable"; export type { IERC721MetadataUpgradeable } from "./IERC721MetadataUpgradeable"; export type { IERC721ReceiverUpgradeable } from "./IERC721ReceiverUpgradeable"; export type { IERC721Upgradeable } from "./IERC721Upgradeable"; @@ -33,7 +34,6 @@ export type { ERC721AIERC721Receiver } from "./ERC721AIERC721Receiver"; export type { ERC721A } from "./ERC721A"; export type { ERC721AQueryable } from "./ERC721AQueryable"; export type { F0 } from "./F0"; -export type { ERC721Upgradeable } from "./ERC721Upgradeable"; export type { Factory } from "./Factory"; export type { HelloWorld } from "./HelloWorld"; export type { IERC721A } from "./IERC721A"; @@ -54,6 +54,7 @@ export { IERC1155MetadataURIUpgradeable__factory } from "./factories/IERC1155Met export { IERC1155ReceiverUpgradeable__factory } from "./factories/IERC1155ReceiverUpgradeable__factory"; export { IERC1155Upgradeable__factory } from "./factories/IERC1155Upgradeable__factory"; export { IERC20Upgradeable__factory } from "./factories/IERC20Upgradeable__factory"; +export { ERC721Upgradeable__factory } from "./factories/ERC721Upgradeable__factory"; export { IERC721MetadataUpgradeable__factory } from "./factories/IERC721MetadataUpgradeable__factory"; export { IERC721ReceiverUpgradeable__factory } from "./factories/IERC721ReceiverUpgradeable__factory"; export { IERC721Upgradeable__factory } from "./factories/IERC721Upgradeable__factory"; @@ -77,7 +78,6 @@ export { ERC721AIERC721Receiver__factory } from "./factories/ERC721AIERC721Recei export { ERC721A__factory } from "./factories/ERC721A__factory"; export { ERC721AQueryable__factory } from "./factories/ERC721AQueryable__factory"; export { F0__factory } from "./factories/F0__factory"; -export { ERC721Upgradeable__factory } from "./factories/ERC721Upgradeable__factory"; export { Factory__factory } from "./factories/Factory__factory"; export { HelloWorld__factory } from "./factories/HelloWorld__factory"; export { IERC721A__factory } from "./factories/IERC721A__factory"; From 79ca9753c64dc83608ff9ee75aa15c84c680751c Mon Sep 17 00:00:00 2001 From: PolyDegen Date: Tue, 3 Oct 2023 00:36:01 +0530 Subject: [PATCH 4/5] update getWithdrawable script --- .gitignore | 4 ++ package.json | 2 + scripts/getERC20Names.ts | 100 +++++++++++++++++++++++++++++++ scripts/getWithdrawable.ts | 51 +++++++++++----- scripts/getWithdrawableTokens.ts | 62 +++++++++++++++++++ 5 files changed, 203 insertions(+), 16 deletions(-) create mode 100644 scripts/getERC20Names.ts create mode 100644 scripts/getWithdrawableTokens.ts diff --git a/.gitignore b/.gitignore index 360a1e5..7619a6f 100644 --- a/.gitignore +++ b/.gitignore @@ -54,3 +54,7 @@ artifacts .secret* *.sw* + +getERC20Names.csv +getWithdrawable.csv +getWithdrawableTokens.csv \ No newline at end of file diff --git a/package.json b/package.json index 54c92f0..7ec6c63 100644 --- a/package.json +++ b/package.json @@ -12,6 +12,8 @@ "deploy": "npx hardhat run scripts/deployArchetype.ts --network localhost", "network": "npx hardhat node", "refund": "npx hardhat run scripts/batchSendEth.ts --network mainnet", + "withdraw": "npx hardhat run scripts/getWithdrawable.ts --network mainnet", + "withdrawTokens": "npx hardhat run scripts/getWithdrawableTokens.ts --network mainnet", "verify": "npx hardhat verify 0xc078Aed674c230cDD7ADD602E077797d08d8f0c2 --network goerli" }, "repository": { diff --git a/scripts/getERC20Names.ts b/scripts/getERC20Names.ts new file mode 100644 index 0000000..1b826f5 --- /dev/null +++ b/scripts/getERC20Names.ts @@ -0,0 +1,100 @@ +import { ethers, run } from "hardhat"; +import fs from "fs"; // Import fs module + +async function main() { + // const contracts = await ( + // await fetch("https://scatter-api.fly.dev/api/fetchHotCollections") + // ).json(); + + const contracts = [ + "0xdDc6625FEcA10438857DD8660C021Cd1088806FB", + "0x088f21a9f387aa4395836344c6bb26d0c207b8d4", + "0x365F721a522A7Fc66d08449C4f3984D1E36D58dC", + "0x726516B20c4692a6beA3900971a37e0cCf7A6BFf", + "0x3fd77fda258fa66f30579ca4b1250651a2462bad", + "0xAFCdd4f666c84Fed1d8BD825aA762e3714F652c9", + "0x544613F087aC194ABa134Be08F9c699c0050ebD1", + "0xA381e7073EA828Fb963157DcC4b414DA4344e3Fd", + "0xEE526EB643A8cD392a853B533582183721eFEB5D", + "0xF03D5fC6E08dE6Ad886fCa34aBF9a59ef633b78a", + "0x3007083EAA95497cD6B2b809fB97B6A30bdF53D3", + "0x07E0EDf8ce600FB51d44F51E3348D77D67F298ae", + "0x6AF36AdD4E2F6e8A9cB121450d59f6C30F3F3722", + "0x6e08B5D1169765f94d5ACe5524F56E8ac75B77c6", + "0xaaeE1A9723aaDB7afA2810263653A34bA2C21C7a", + "0x802d0359e1308C32D13264be9Bf248b06660D4E3", + "0x72e4f9F808C49A2a61dE9C5896298920Dc4EEEa9", + "0xbbBa7FaB56Db7c471b2094e6f132A88130Ae2C94", + "0xf03d5fc6e08de6ad886fca34abf9a59ef633b78a", + "0x3D806324b6Df5AF3c1a81aCbA14A8A62Fe6D643F", + "0xdAC17F958D2ee523a2206206994597C13D831ec7", + "0x0000000000000000000000000000000000000000", + "0x1A963Df363D01EEBB2816b366d61C917F20e1EbE", + "0x36d7aa5c67efd83992fc5cbc488cc2f9ba7689b8", + "0x79DB761B6E0f426152052eeD399E3Fbb1922Fae3", + "0x0a693a301215aad39d83a32a5b5279f2d238851b", + "0xf072dDC2f80f490b4D507d04424E112CCF307386", + "0xB22C05CeDbF879a661fcc566B5a759d005Cf7b4C", + "0xc83aedf16f508539763bb7c1d86ff6f9ae97d9e3", + "0xae7ab96520DE3A18E5e111B5EaAb095312D7fE84", + "0x088F21A9f387aa4395836344c6Bb26D0C207B8D4", + "0xE59aCBE910dcdb8a0E79F337de4391907Dc8989c", + "0x2890dF158D76E584877a1D17A85FEA3aeeB85aa6", + "0x51187Cab377eD5E1386042919A9C3D6b5ea402f0", + "0xa12fe47a20c3a13773da0e5c0c05b35223a9054a", + "0x427A03Fb96D9A94A6727fbcfbBA143444090dd64", + "0xddc6625feca10438857dd8660c021cd1088806fb", + "0x1142866f451d9d5281c5c8349a332bd338e552a1", + "0x514910771AF9Ca656af840dff83E8264EcF986CA", + "0x9416bA76e88D873050A06e5956A3EBF10386b863", + "0xa12fe47A20C3a13773DA0E5c0C05b35223a9054a", + "0xB90B2A35C65dBC466b04240097Ca756ad2005295", + "0x30BCd71b8d21FE830e493b30e90befbA29de9114", + "0xE0f63A424a4439cBE457D80E4f4b51aD25b2c56C", + "0x6982508145454ce325ddbe47a25d4ec3d2311933", + "0xb5c0fb97512cabb70d8b164639416cee9d54b5be", + "0xDe950e159655cA981cb46d4ccfE251Ba8D6c7772", + "0x8cbf530219037cEC95Db91Db8EeeCB3661968865", + "0x72e4f9f808c49a2a61de9c5896298920dc4eeea9", + "0x5A9BEe6cFb395f93d426A41B93C647E05D058EAb", + "0x423f4e6138E475D85CF7Ea071AC92097Ed631eea", + "0xD3D9ddd0CF0A5F0BFB8f7fcEAe075DF687eAEBaB", + "0x6982508145454Ce325dDbE47a25d4ec3d2311933", + "0xa358491CA72B793ddf21cF46C7289CC6e0ce9e5A", + "0x04E6cA1EaA6622858Ef07E26496f627f4Cb8A0cc", + "0xaaee1a9723aadb7afa2810263653a34ba2c21c7a", + "0x2890df158d76e584877a1d17a85fea3aeeb85aa6", + "0xC56bC8232eaA35Af16167c946436a0F9b66B4c1A", + "0x9657477ac915F56ca87C253db1320218Ec2D5DDD", + ]; + + // scatter-api.fly.dev/api/contracts + + // Prepare the file with the header + const filename = "getERC20Names.csv"; + + fs.writeFileSync(filename, "name,symbol,address\n"); // Initialize the CSV file with headers + + for (const contract of contracts) { + try { + const archetype = await ethers.getContractAt("Archetype", contract); + const name = await archetype.name(); + const symbol = await archetype.symbol(); + + console.log(symbol, name, contract); + + // Append to the CSV file + fs.appendFileSync(filename, `${symbol},${name},${contract}\n`); // Append the row to the CSV file + } catch (e) { + console.log(contract, "not Archetype"); + continue; + } + } +} + +main() + .then(() => process.exit(0)) + .catch(error => { + console.error(error); + process.exit(1); + }); diff --git a/scripts/getWithdrawable.ts b/scripts/getWithdrawable.ts index fd0b343..3c031cd 100644 --- a/scripts/getWithdrawable.ts +++ b/scripts/getWithdrawable.ts @@ -1,25 +1,44 @@ import { ethers, run } from "hardhat"; -import fetch from 'node-fetch'; +import fetch from "node-fetch"; +import fs from "fs"; // Import fs module const ZERO = "0x0000000000000000000000000000000000000000"; async function main() { - const contracts = await (await fetch('https://scatter-api.fly.dev/api/contracts')).json() - - let totalPlat = 0 - for(const contract of contracts.body) { - // const archetype = Archetype.attach(contract); - try{ - const archetype = await ethers.getContractAt("Archetype", contract); - const balance = await archetype.ownerBalance(); - console.log(contract, "platform:", ethers.utils.formatEther(balance.platform), "owner:", ethers.utils.formatEther(balance.owner)); - totalPlat += Number(ethers.utils.formatEther(balance.platform)) - } catch(e) { - console.log(contract, "not Archetype"); - continue - } + const contracts = await ( + await fetch("https://scatter-api.fly.dev/api/fetchHotCollections") + ).json(); + + // scatter-api.fly.dev/api/contracts + + // Prepare the file with the header + const filename = "getWithdrawable.csv"; + fs.writeFileSync(filename, "name,address,platform,owner\n"); // Initialize the CSV file with headers + + let totalPlat = 0; + for (const contract of contracts.body) { + try { + const archetype = await ethers.getContractAt("Archetype", contract.token_address); + const balance = await archetype.ownerBalance(); + + const platform = ethers.utils.formatEther(balance.platform); + const owner = ethers.utils.formatEther(balance.owner); + + console.log(contract.name, "platform:", platform, "owner:", owner); + + // Append to the CSV file + fs.appendFileSync( + filename, + `${contract.name},${contract.token_address},${platform},${owner}\n` + ); // Append the row to the CSV file + + totalPlat += Number(platform); + } catch (e) { + console.log(contract.name, "not Archetype"); + continue; } + } - console.log("total platform:", totalPlat) + console.log("total platform:", totalPlat); } main() diff --git a/scripts/getWithdrawableTokens.ts b/scripts/getWithdrawableTokens.ts new file mode 100644 index 0000000..ae58b2e --- /dev/null +++ b/scripts/getWithdrawableTokens.ts @@ -0,0 +1,62 @@ +import { ethers, run } from "hardhat"; +import fetch from "node-fetch"; +import fs from "fs"; // Import fs module +const ZERO = "0x0000000000000000000000000000000000000000"; + +async function main() { + // const contracts = await ( + // await fetch("https://scatter-api.fly.dev/api/fetchHotCollections") + // ).json(); + + const contracts = [ + "0xc0a1271687ec0B8AB8edDa560F0f6A62488204C2", + "0x69491B875B2DA3CA3e02Ae7b4A08827ce3198ad4", + "0x67063f01D24b55C66D2802dF1Dd019f241338303", + "0xC735b0BE4955c8bABd41F8F9bc88c9b296CB3fea", + "0x98003b0512138e08c4410De5C8CDD2dC67742FB6", + "0x9D9524DB652d2D23c3CB4fb24d5e654bB07bC376", + "0x83777291535223DBf2685d314fBb2A38bB120626", + "0x4D259D525eab5C05442f86b9a83A68BA286c37F3", + "0x83777291535223DBf2685d314fBb2A38bB120626", + "0xC48657E9EcbDd6c43173F10d1e71E2cf8708d888", + ]; + + // scatter-api.fly.dev/api/contracts + + // Prepare the file with the header + const filename = "getWithdrawableTokens.csv"; + const ERC20_ADDRESS = "0xaaee1a9723aadb7afa2810263653a34ba2c21c7a"; + + fs.writeFileSync(filename, "name,address,platform,owner\n"); // Initialize the CSV file with headers + + let totalPlat = 0; + for (const contract of contracts) { + try { + const archetype = await ethers.getContractAt("Archetype", contract); + const balance = await archetype.ownerBalanceToken(ERC20_ADDRESS); + const name = await archetype.name(); + + const platform = ethers.utils.formatUnits(balance.platform, 8); + const owner = ethers.utils.formatUnits(balance.owner, 8); + + console.log(name, contract, "platform:", platform, "owner:", owner); + + // Append to the CSV file + fs.appendFileSync(filename, `${name},${contract},${platform},${owner}\n`); // Append the row to the CSV file + + totalPlat += Number(platform); + } catch (e) { + console.log(contract, "not Archetype"); + continue; + } + } + + console.log("total platform:", totalPlat); +} + +main() + .then(() => process.exit(0)) + .catch(error => { + console.error(error); + process.exit(1); + }); From b8596d9c46bdcc1cbdeba92bc8550aadd46260d1 Mon Sep 17 00:00:00 2001 From: CoinDegen Date: Thu, 30 Nov 2023 21:01:02 -0800 Subject: [PATCH 5/5] add mondo prize batch transfer script --- scripts/batchTransferMondo.ts | 130 ++++++++++++++++++++++++++++++++++ 1 file changed, 130 insertions(+) create mode 100644 scripts/batchTransferMondo.ts diff --git a/scripts/batchTransferMondo.ts b/scripts/batchTransferMondo.ts new file mode 100644 index 0000000..d1866fe --- /dev/null +++ b/scripts/batchTransferMondo.ts @@ -0,0 +1,130 @@ +import { ethers } from "hardhat"; +import * as readlineSync from "readline-sync"; +import * as fs from "fs"; +import { parse } from "csv-parse"; +import { ArchetypeBatch } from "../typechain"; +const path = require("path"); + +async function parseCsv(csvString: string): Promise { + const options = { + columns: true, + skip_empty_lines: true, + }; + return new Promise((resolve, reject) => { + parse(csvString, options, (err, output) => { + if (err) { + reject(err); + } else { + resolve(output); + } + }); + }); +} + +async function main() { + const BATCH_ADDRESS: string = "0x6Bc558A6DC48dEfa0e7022713c23D65Ab26e4Fa7"; // MAINNET + + const archetypeBatch: ArchetypeBatch = await ethers.getContractAt( + "ArchetypeBatch", + BATCH_ADDRESS + ); + const expectedBytecode = (await ethers.getContractFactory("ArchetypeBatch")).bytecode; + const actualBytecode = await ethers.provider.getCode(archetypeBatch.address); + const matchRate = calculateMatchRate(expectedBytecode, actualBytecode); + + console.log("ArchetypeBatch bytecode has a match rate of", matchRate); + if (matchRate > 90) { + console.log("ArchetypeBatch bytecode match passes"); + } else { + console.log( + "ArchetypeBatch bytecode match fails, make sure its the correct address. Exiting ..." + ); + process.exit(1); + } + + const TOKEN_ADDRESS: string = "0x750ee3529D13819E00E4e67063D6e500870d5AF3"; + const tokenContract = await ethers.getContractAt("IERC1155", TOKEN_ADDRESS); + + const csvContent = fs.readFileSync(path.join(__dirname, "./data/mondo_transfer.csv"), "utf-8"); + const records = await parseCsv(csvContent); + + const recipientList = records.map(record => record["ETH Address"]); + const quantityList = records.map(record => record["Amount"]); + console.log({ recipientList, quantityList }); + + const ownedTokenIds = [ + 213, 237, 172, 169, 247, 211, 177, 140, 151, 241, 232, 230, 142, 188, 249, 228, 211, 245, 152, + 157, 163, 187, + ]; + + const [signer] = await ethers.getSigners(); + console.log(`Distributing tokens from address: ${signer.address}`); + + // Formulate the calls + const targets: string[] = []; + const values: number[] = []; + const datas: string[] = []; + + let i = 0; + for (let j = 0; j < recipientList.length; j++) { + for (let k = 0; k < quantityList[j]; k++) { + targets.push(TOKEN_ADDRESS); // This remains the token address for each entry + values.push(0); // This remains 0 for each entry + + console.log({ receiver: recipientList[j], tokenId: ownedTokenIds[i], quantity: 1 }); + const data = tokenContract.interface.encodeFunctionData("safeTransferFrom", [ + signer.address, + recipientList[j], + ownedTokenIds[i], + 1, + "0x", + ]); + + datas.push(data); + i++; + } + } + + console.log({ targets, values, datas, tokenIdsToSend: ownedTokenIds }); + + if (!readlineSync.keyInYN("Are the above values correct?")) { + console.log("config not confirmed. Not sending eth."); + process.exit(); + } + + const tx = await archetypeBatch.executeBatch(targets, values, datas); + const receipt = await tx.wait(); + + console.log(`Transaction hash: ${receipt.transactionHash}`); +} + +main() + .then(() => process.exit(0)) + .catch(error => { + console.error(error); + process.exit(1); + }); + +/* + Uses a sliding window approach, chunkBytecode produces overlapping chunks. + E.g., for "ABCDEF" and chunk size 3, we get ["ABC", "BCD", "CDE", "DEF"]. + This ensures better matching, especially when bytecodes have minor offsets. +*/ +function calculateMatchRate(bytecode1: string, bytecode2: string): number { + function chunkBytecode(bytecode: string, chunkSize: number): string[] { + const chunks = []; + for (let i = 0; i <= bytecode.length - chunkSize; i++) { + chunks.push(bytecode.slice(i, i + chunkSize)); + } + return chunks; + } + + const chunkSize = 10; + const chunks1 = chunkBytecode(bytecode1, chunkSize); + const chunks2 = new Set(chunkBytecode(bytecode2, chunkSize)); + + const commonChunks = chunks1.filter(chunk => chunks2.has(chunk)).length; + + const maxPossibleMatches = Math.max(chunks1.length, chunks2.size); + return (commonChunks / maxPossibleMatches) * 100; +}