33import { ethers , run } from 'hardhat'
44import type { ContractTransaction } from 'ethers'
55
6+ import { wait } from './utils/wait'
7+
68async function main ( ) {
79 console . log ( 'Starting deploySBTFactory script on sbt-tokens...' )
810
@@ -19,7 +21,7 @@ async function main() {
1921 // @TODO : modify this address when deploying...
2022 const proxyAdmin = '0xec4562C829661c891FcEadb44F831c8a5e71bC8F'
2123 // @TODO : check and change this whenever required.
22- const identifier = ethers . utils . formatBytes32String ( 'First SBT' )
24+ const identifier = ethers . utils . formatBytes32String ( 'Test Achievement SBT' )
2325 // @TODO : check and change this whenever required.
2426 const sbtFactoryAddress = '0x0F0b8697169aF45FC61814C3e5b4d784a909b9A7'
2527
@@ -37,10 +39,17 @@ async function main() {
3739 identifier
3840 ) ) as ContractTransaction
3941 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- )
42+ const txReceipt = await txn . wait ( 10 )
43+ const logs = txReceipt . logs . map ( ( log ) => {
44+ try {
45+ // Because here events/logs contains some deployment/general blockchain events which cannot be parsed by contract.interface.
46+ const l = sbtFactoryInstance . interface . parseLog ( log )
47+ return l
48+ } catch ( err ) {
49+ // Hence, we are removing those as we do not need those events.
50+ return { name : '' , args : [ ] }
51+ }
52+ } )
4453 const proxyCreationLog = logs . find ( ( log ) => log . name === 'SBTProxyCreated' )
4554 const implementationCreationLog = logs . find (
4655 ( log ) => log . name === 'SBTImplementationCreated'
@@ -51,6 +60,7 @@ async function main() {
5160 1
5261 ) as string
5362
63+ await wait ( 30 * 1000 ) // For block explorer to scan newly deployed address and attach it's bytecode to it.
5464 if ( implementationCreationLog ) {
5565 console . log (
5666 ` - SBT implementation deployed at addr:${ implementationContractAddress } `
@@ -63,6 +73,8 @@ async function main() {
6373 } )
6474 }
6575
76+ await wait ( 30 * 1000 ) // For block explorer to scan newly deployed address and attach it's bytecode to it.
77+
6678 if ( proxyCreationLog ) {
6779 console . log ( ` - SBT proxy deployed at addr:${ proxyContractAddress } ` )
6880 console . log ( ' - Verifying SBT proxy contract...' )
0 commit comments