@@ -13,51 +13,53 @@ import {
13
13
resolveAddress ,
14
14
} from "@thirdweb-dev/sdk" ;
15
15
import { Signer } from "ethers" ;
16
- import { apiMap , chainIdApiKey , chainIdToName } from "./constants" ;
16
+ import { DEFAULT_CHAINS , apiMap , chainIdApiKey } from "./constants" ;
17
17
18
18
////// To run this script: `npx ts-node scripts/deploy-prebuilt-deterministic/deploy-deterministic-std-chains.ts` //////
19
19
///// MAKE SURE TO PUT IN THE RIGHT CONTRACT NAME HERE AFTER PUBLISHING IT /////
20
20
//// 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" ;
23
23
const deployerKey : string = process . env . PRIVATE_KEY as string ;
24
24
const secretKey : string = process . env . THIRDWEB_SECRET_KEY as string ;
25
25
26
- const polygonSDK = ThirdwebSDK . fromPrivateKey ( publisherKey , "polygon" , { secretKey } ) ;
26
+ const polygonSDK = new ThirdwebSDK ( "polygon" , { secretKey } ) ;
27
27
28
28
async 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 ) ;
31
30
32
31
if ( latest && latest . metadataUri ) {
33
32
const { extendedMetadata } = await fetchAndCacheDeployMetadata ( latest ?. metadataUri , polygonSDK . storage ) ;
34
33
35
- for ( const [ chainId , networkName ] of Object . entries ( chainIdToName ) ) {
34
+ for ( const chain of DEFAULT_CHAINS ) {
36
35
const isNetworkEnabled =
37
- extendedMetadata ?. networksForDeployment ?. networksEnabled . includes ( parseInt ( chainId ) ) ||
36
+ extendedMetadata ?. networksForDeployment ?. networksEnabled . includes ( chain . chainId ) ||
38
37
extendedMetadata ?. networksForDeployment ?. allNetworks ;
39
38
40
39
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` ) ;
42
41
continue ;
43
42
}
44
43
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
47
46
const signer = sdk . getSigner ( ) as Signer ;
48
47
// const chainId = (await sdk.getProvider().getNetwork()).chainId;
49
48
50
49
try {
51
- const implAddr = await getThirdwebContractAddress ( publishedContractName , parseInt ( chainId ) , sdk . storage ) ;
50
+ const implAddr = await getThirdwebContractAddress ( publishedContractName , chain . chainId , sdk . storage ) ;
52
51
if ( implAddr ) {
53
- console . log ( `implementation ${ implAddr } already deployed on chainId: ${ chainId } ` ) ;
52
+ console . log ( `implementation ${ implAddr } already deployed on chainId: ${ chain . slug } ` ) ;
54
53
console . log ( ) ;
55
54
continue ;
56
55
}
57
- } catch ( error ) { }
56
+ } catch ( error ) {
57
+ // no-op
58
+ }
58
59
59
60
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 ) ) ;
61
63
// any evm deployment flow
62
64
63
65
// Deploy CREATE2 factory (if not already exists)
@@ -133,14 +135,16 @@ async function main() {
133
135
console . log ( ) ;
134
136
console . log ( "---------- Verification ---------" ) ;
135
137
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 ) ;
139
143
try {
140
144
await sdk . verifier . verifyThirdwebContract (
141
145
publishedContractName ,
142
- apiMap [ parseInt ( chainId ) ] ,
143
- chainIdApiKey [ parseInt ( chainId ) ] as string ,
146
+ apiMap [ chain . chainId ] ,
147
+ chainIdApiKey [ chain . chainId ] as string ,
144
148
) ;
145
149
console . log ( ) ;
146
150
} catch ( error ) {
0 commit comments