|
| 1 | +/* eslint-disable @typescript-eslint/prefer-readonly-parameter-types */ |
| 2 | + |
| 3 | +import { ethers, run } from 'hardhat' |
| 4 | +import type { ContractTransaction } from 'ethers' |
| 5 | + |
| 6 | +async function main() { |
| 7 | + console.log('Starting deploySBTFactory script on sbt-tokens...') |
| 8 | + |
| 9 | + const [signer] = await ethers.getSigners() |
| 10 | + console.log('Signer is: ', signer.address) |
| 11 | + console.log() |
| 12 | + |
| 13 | + // @TODO: modify this when deploying... |
| 14 | + const minterUpdater = signer.address |
| 15 | + // @TODO: modify this when deploying... |
| 16 | + const minters = [signer.address] |
| 17 | + // @TODO: change this whenever required. |
| 18 | + const proxyCalldata = ethers.utils.arrayify('0x') |
| 19 | + // @TODO: modify this address when deploying... |
| 20 | + const proxyAdmin = '0xec4562C829661c891FcEadb44F831c8a5e71bC8F' |
| 21 | + // @TODO: check and change this whenever required. |
| 22 | + const sbtFactoryAddress = '' |
| 23 | + // @TODO: check and change this whenever required. |
| 24 | + const identifier = ethers.utils.formatBytes32String('First SBT') |
| 25 | + |
| 26 | + // >>> Deploy using SBTFactory >>> |
| 27 | + console.log('Deploying new SBT using SBTFactory...') |
| 28 | + const sbtFactoryInstance = await ethers.getContractAt( |
| 29 | + 'SBTFactory', |
| 30 | + sbtFactoryAddress |
| 31 | + ) |
| 32 | + const txn = (await sbtFactoryInstance.functions.makeNewSBT( |
| 33 | + proxyAdmin, |
| 34 | + proxyCalldata, |
| 35 | + minterUpdater, |
| 36 | + minters, |
| 37 | + identifier |
| 38 | + )) as ContractTransaction |
| 39 | + console.log(` - SBT deployment using SBTFactory at txn:${txn.hash}`) |
| 40 | + const txReceipt = await txn.wait(2) |
| 41 | + const logs = txReceipt.logs.map((log) => |
| 42 | + sbtFactoryInstance.interface.parseLog(log) |
| 43 | + ) |
| 44 | + const proxyCreationLog = logs.find((log) => log.name === 'SBTProxyCreated') |
| 45 | + const implementationCreationLog = logs.find( |
| 46 | + (log) => log.name === 'SBTImplementationCreated' |
| 47 | + ) |
| 48 | + |
| 49 | + const proxyContractAddress = proxyCreationLog?.args.at(1) as string |
| 50 | + const implementationContractAddress = implementationCreationLog?.args.at( |
| 51 | + 1 |
| 52 | + ) as string |
| 53 | + |
| 54 | + if (implementationCreationLog) { |
| 55 | + console.log( |
| 56 | + ` - SBT implementation deployed at addr:${implementationContractAddress}` |
| 57 | + ) |
| 58 | + console.log(' - Verifying SBT implementation contract...') |
| 59 | + await run(`verify:verify`, { |
| 60 | + address: implementationContractAddress, |
| 61 | + contract: 'contracts/SBT.sol:SBT', |
| 62 | + constructorArguments: [], |
| 63 | + }) |
| 64 | + } |
| 65 | + |
| 66 | + if (proxyCreationLog) { |
| 67 | + console.log(` - SBT proxy deployed at addr:${proxyContractAddress}`) |
| 68 | + console.log(' - Verifying SBT proxy contract...') |
| 69 | + await run(`verify:verify`, { |
| 70 | + address: proxyContractAddress, |
| 71 | + contract: 'contracts/SBTProxy.sol:SBTProxy', |
| 72 | + constructorArguments: [ |
| 73 | + implementationContractAddress, |
| 74 | + proxyAdmin, |
| 75 | + proxyCalldata, |
| 76 | + ], |
| 77 | + }) |
| 78 | + } |
| 79 | + |
| 80 | + console.log() |
| 81 | +} |
| 82 | + |
| 83 | +main() |
| 84 | + .then(() => process.exit(0)) |
| 85 | + .catch((error) => { |
| 86 | + console.error(error) |
| 87 | + process.exit(1) |
| 88 | + }) |
0 commit comments