@@ -13,51 +13,53 @@ import {
1313 resolveAddress ,
1414} from "@thirdweb-dev/sdk" ;
1515import { Signer } from "ethers" ;
16- import { apiMap , chainIdApiKey , chainIdToName } from "./constants" ;
16+ import { DEFAULT_CHAINS , apiMap , chainIdApiKey } from "./constants" ;
1717
1818////// To run this script: `npx ts-node scripts/deploy-prebuilt-deterministic/deploy-deterministic-std-chains.ts` //////
1919///// MAKE SURE TO PUT IN THE RIGHT CONTRACT NAME HERE AFTER PUBLISHING IT /////
2020//// THE CONTRACT SHOULD BE PUBLISHED WITH THE NEW PUBLISH FLOW ////
21- const publishedContractName = "DropERC1155 " ;
22- const publisherKey : string = process . env . THIRDWEB_PUBLISHER_PRIVATE_KEY as string ;
21+ const publishedContractName = "AccountExtension " ;
22+ const publisherAddress : string = "deployer.thirdweb.eth" ;
2323const deployerKey : string = process . env . PRIVATE_KEY as string ;
2424const secretKey : string = process . env . THIRDWEB_SECRET_KEY as string ;
2525
26- const polygonSDK = ThirdwebSDK . fromPrivateKey ( publisherKey , "polygon" , { secretKey } ) ;
26+ const polygonSDK = new ThirdwebSDK ( "polygon" , { secretKey } ) ;
2727
2828async function main ( ) {
29- const publisher = await polygonSDK . wallet . getAddress ( ) ;
30- const latest = await polygonSDK . getPublisher ( ) . getLatest ( publisher , publishedContractName ) ;
29+ const latest = await polygonSDK . getPublisher ( ) . getLatest ( publisherAddress , publishedContractName ) ;
3130
3231 if ( latest && latest . metadataUri ) {
3332 const { extendedMetadata } = await fetchAndCacheDeployMetadata ( latest ?. metadataUri , polygonSDK . storage ) ;
3433
35- for ( const [ chainId , networkName ] of Object . entries ( chainIdToName ) ) {
34+ for ( const chain of DEFAULT_CHAINS ) {
3635 const isNetworkEnabled =
37- extendedMetadata ?. networksForDeployment ?. networksEnabled . includes ( parseInt ( chainId ) ) ||
36+ extendedMetadata ?. networksForDeployment ?. networksEnabled . includes ( chain . chainId ) ||
3837 extendedMetadata ?. networksForDeployment ?. allNetworks ;
3938
4039 if ( extendedMetadata ?. networksForDeployment && ! isNetworkEnabled ) {
41- console . log ( `Deployment of ${ publishedContractName } disabled on ${ networkName } \n` ) ;
40+ console . log ( `Deployment of ${ publishedContractName } disabled on ${ chain . slug } \n` ) ;
4241 continue ;
4342 }
4443
45- console . log ( `Deploying ${ publishedContractName } on ${ networkName } ` ) ;
46- const sdk = ThirdwebSDK . fromPrivateKey ( deployerKey , chainId , { secretKey } ) ; // can also hardcode the chain here
44+ console . log ( `Deploying ${ publishedContractName } on ${ chain . slug } ` ) ;
45+ const sdk = ThirdwebSDK . fromPrivateKey ( deployerKey , chain , { secretKey } ) ; // can also hardcode the chain here
4746 const signer = sdk . getSigner ( ) as Signer ;
4847 // const chainId = (await sdk.getProvider().getNetwork()).chainId;
4948
5049 try {
51- const implAddr = await getThirdwebContractAddress ( publishedContractName , parseInt ( chainId ) , sdk . storage ) ;
50+ const implAddr = await getThirdwebContractAddress ( publishedContractName , chain . chainId , sdk . storage ) ;
5251 if ( implAddr ) {
53- console . log ( `implementation ${ implAddr } already deployed on chainId: ${ chainId } ` ) ;
52+ console . log ( `implementation ${ implAddr } already deployed on chainId: ${ chain . slug } ` ) ;
5453 console . log ( ) ;
5554 continue ;
5655 }
57- } catch ( error ) { }
56+ } catch ( error ) {
57+ // no-op
58+ }
5859
5960 try {
60- console . log ( "Deploying as" , await signer ?. getAddress ( ) ) ;
61+ console . log ( "Deploying as" , await sdk . wallet . getAddress ( ) ) ;
62+ console . log ( "Balance" , await sdk . wallet . balance ( ) . then ( b => b . displayValue ) ) ;
6163 // any evm deployment flow
6264
6365 // Deploy CREATE2 factory (if not already exists)
@@ -133,14 +135,16 @@ async function main() {
133135 console . log ( ) ;
134136 console . log ( "---------- Verification ---------" ) ;
135137 console . log ( ) ;
136- for ( const [ chainId , networkName ] of Object . entries ( chainIdToName ) ) {
137- const sdk = new ThirdwebSDK ( chainId ) ;
138- console . log ( "Network: " , networkName ) ;
138+ for ( const chain of DEFAULT_CHAINS ) {
139+ const sdk = new ThirdwebSDK ( chain , {
140+ secretKey,
141+ } ) ;
142+ console . log ( "Verifying on: " , chain . slug ) ;
139143 try {
140144 await sdk . verifier . verifyThirdwebContract (
141145 publishedContractName ,
142- apiMap [ parseInt ( chainId ) ] ,
143- chainIdApiKey [ parseInt ( chainId ) ] as string ,
146+ apiMap [ chain . chainId ] ,
147+ chainIdApiKey [ chain . chainId ] as string ,
144148 ) ;
145149 console . log ( ) ;
146150 } catch ( error ) {
0 commit comments