1
- import { Storable } from "./base" ;
1
+ import { KeyValueConfig , PrivateKey , Storable } from "./base" ;
2
2
import {
3
3
ChainName ,
4
- CHAINS ,
5
4
SetFee ,
6
5
CosmosUpgradeContract ,
7
6
EvmUpgradeContract ,
@@ -22,6 +21,10 @@ import {
22
21
} from "@pythnetwork/cosmwasm-deploy-tools" ;
23
22
import { Network } from "@injectivelabs/networks" ;
24
23
24
+ export type ChainConfig = Record < string , string > & {
25
+ mainnet : boolean ;
26
+ id : string ;
27
+ } ;
25
28
export abstract class Chain extends Storable {
26
29
public wormholeChainName : ChainName ;
27
30
@@ -92,15 +95,15 @@ export abstract class Chain extends Storable {
92
95
* Returns the payload for a governance contract upgrade instruction for contracts deployed on this chain
93
96
* @param upgradeInfo based on the contract type, this can be a contract address, codeId, package digest, etc.
94
97
*/
95
- abstract generateGovernanceUpgradePayload ( upgradeInfo : any ) : Buffer ;
98
+ abstract generateGovernanceUpgradePayload ( upgradeInfo : unknown ) : Buffer ;
96
99
}
97
100
98
101
export class GlobalChain extends Chain {
99
- static type : string = "GlobalChain" ;
102
+ static type = "GlobalChain" ;
100
103
constructor ( ) {
101
104
super ( "global" , true , "unset" ) ;
102
105
}
103
- generateGovernanceUpgradePayload ( upgradeInfo : any ) : Buffer {
106
+ generateGovernanceUpgradePayload ( ) : Buffer {
104
107
throw new Error (
105
108
"Can not create a governance message for upgrading contracts on all chains!"
106
109
) ;
@@ -110,7 +113,7 @@ export class GlobalChain extends Chain {
110
113
return GlobalChain . type ;
111
114
}
112
115
113
- toJson ( ) : any {
116
+ toJson ( ) : KeyValueConfig {
114
117
return {
115
118
id : this . id ,
116
119
wormholeChainName : this . wormholeChainName ,
@@ -121,7 +124,7 @@ export class GlobalChain extends Chain {
121
124
}
122
125
123
126
export class CosmWasmChain extends Chain {
124
- static type : string = "CosmWasmChain" ;
127
+ static type = "CosmWasmChain" ;
125
128
126
129
constructor (
127
130
id : string ,
@@ -135,7 +138,7 @@ export class CosmWasmChain extends Chain {
135
138
super ( id , mainnet , wormholeChainName ) ;
136
139
}
137
140
138
- static fromJson ( parsed : any ) : CosmWasmChain {
141
+ static fromJson ( parsed : ChainConfig ) : CosmWasmChain {
139
142
if ( parsed . type !== CosmWasmChain . type ) throw new Error ( "Invalid type" ) ;
140
143
return new CosmWasmChain (
141
144
parsed . id ,
@@ -148,7 +151,7 @@ export class CosmWasmChain extends Chain {
148
151
) ;
149
152
}
150
153
151
- toJson ( ) : any {
154
+ toJson ( ) : KeyValueConfig {
152
155
return {
153
156
endpoint : this . endpoint ,
154
157
id : this . id ,
@@ -174,7 +177,7 @@ export class CosmWasmChain extends Chain {
174
177
return new CosmosUpgradeContract ( this . wormholeChainName , codeId ) . encode ( ) ;
175
178
}
176
179
177
- async getExecutor ( privateKey : string ) {
180
+ async getExecutor ( privateKey : PrivateKey ) {
178
181
if ( this . getId ( ) . indexOf ( "injective" ) > - 1 ) {
179
182
return InjectiveExecutor . fromPrivateKey (
180
183
this . isMainnet ( ) ? Network . Mainnet : Network . Testnet ,
@@ -190,7 +193,7 @@ export class CosmWasmChain extends Chain {
190
193
}
191
194
192
195
export class SuiChain extends Chain {
193
- static type : string = "SuiChain" ;
196
+ static type = "SuiChain" ;
194
197
195
198
constructor (
196
199
id : string ,
@@ -201,7 +204,7 @@ export class SuiChain extends Chain {
201
204
super ( id , mainnet , wormholeChainName ) ;
202
205
}
203
206
204
- static fromJson ( parsed : any ) : SuiChain {
207
+ static fromJson ( parsed : ChainConfig ) : SuiChain {
205
208
if ( parsed . type !== SuiChain . type ) throw new Error ( "Invalid type" ) ;
206
209
return new SuiChain (
207
210
parsed . id ,
@@ -211,7 +214,7 @@ export class SuiChain extends Chain {
211
214
) ;
212
215
}
213
216
214
- toJson ( ) : any {
217
+ toJson ( ) : KeyValueConfig {
215
218
return {
216
219
id : this . id ,
217
220
wormholeChainName : this . wormholeChainName ,
@@ -238,7 +241,7 @@ export class SuiChain extends Chain {
238
241
}
239
242
240
243
export class EvmChain extends Chain {
241
- static type : string = "EvmChain" ;
244
+ static type = "EvmChain" ;
242
245
243
246
constructor (
244
247
id : string ,
@@ -250,7 +253,7 @@ export class EvmChain extends Chain {
250
253
super ( id , mainnet , wormholeChainName ) ;
251
254
}
252
255
253
- static fromJson ( parsed : any ) : EvmChain {
256
+ static fromJson ( parsed : ChainConfig & { networkId : number } ) : EvmChain {
254
257
if ( parsed . type !== EvmChain . type ) throw new Error ( "Invalid type" ) ;
255
258
return new EvmChain (
256
259
parsed . id ,
@@ -277,7 +280,7 @@ export class EvmChain extends Chain {
277
280
return new EvmSetWormholeAddress ( this . wormholeChainName , address ) . encode ( ) ;
278
281
}
279
282
280
- toJson ( ) : any {
283
+ toJson ( ) : KeyValueConfig {
281
284
return {
282
285
id : this . id ,
283
286
wormholeChainName : this . wormholeChainName ,
@@ -311,10 +314,10 @@ export class EvmChain extends Chain {
311
314
* @returns the address of the deployed contract
312
315
*/
313
316
async deploy (
314
- privateKey : string ,
315
- abi : any ,
317
+ privateKey : PrivateKey ,
318
+ abi : any , // eslint-disable-line @typescript-eslint/no-explicit-any
316
319
bytecode : string ,
317
- deployArgs : any [ ]
320
+ deployArgs : any [ ] // eslint-disable-line @typescript-eslint/no-explicit-any
318
321
) : Promise < string > {
319
322
const web3 = new Web3 ( this . getRpcUrl ( ) ) ;
320
323
const signer = web3 . eth . accounts . privateKeyToAccount ( privateKey ) ;
@@ -375,7 +378,7 @@ export class AptosChain extends Chain {
375
378
return AptosChain . type ;
376
379
}
377
380
378
- toJson ( ) : any {
381
+ toJson ( ) : KeyValueConfig {
379
382
return {
380
383
id : this . id ,
381
384
wormholeChainName : this . wormholeChainName ,
@@ -385,7 +388,7 @@ export class AptosChain extends Chain {
385
388
} ;
386
389
}
387
390
388
- static fromJson ( parsed : any ) : AptosChain {
391
+ static fromJson ( parsed : ChainConfig ) : AptosChain {
389
392
if ( parsed . type !== AptosChain . type ) throw new Error ( "Invalid type" ) ;
390
393
return new AptosChain (
391
394
parsed . id ,
0 commit comments