@@ -3,16 +3,19 @@ import { readFileSync } from "fs";
3
3
import {
4
4
ContractInfoResponse ,
5
5
CosmwasmQuerier ,
6
- DeploymentType ,
7
- getPythConfig ,
8
6
Price ,
9
7
PythWrapperExecutor ,
10
8
PythWrapperQuerier ,
11
9
} from "@pythnetwork/cosmwasm-deploy-tools" ;
12
10
import { Coin } from "@cosmjs/stargate" ;
13
- import { CHAINS , DataSource } from "xc_admin_common" ;
11
+ import { DataSource } from "xc_admin_common" ;
14
12
import { CosmWasmClient } from "@cosmjs/cosmwasm-stargate" ;
15
- import { Contract , PrivateKey , TxResult } from "../base" ;
13
+ import {
14
+ Contract ,
15
+ getDefaultDeploymentConfig ,
16
+ PrivateKey ,
17
+ TxResult ,
18
+ } from "../base" ;
16
19
import { WormholeContract } from "./wormhole" ;
17
20
18
21
/**
@@ -85,7 +88,7 @@ export class CosmWasmContract extends Contract {
85
88
async getDataSources ( ) : Promise < DataSource [ ] > {
86
89
const config = await this . getConfig ( ) ;
87
90
return config . config_v1 . data_sources . map (
88
- ( { emitter, chain_id } : { emitter : string ; chain_id : string } ) => {
91
+ ( { emitter, chain_id } : WormholeSource ) => {
89
92
return {
90
93
emitterChain : Number ( chain_id ) ,
91
94
emitterAddress : Buffer . from ( emitter , "base64" ) . toString ( "hex" ) ,
@@ -124,19 +127,6 @@ export class CosmWasmContract extends Contract {
124
127
return CosmWasmContract . type ;
125
128
}
126
129
127
- static getDeploymentConfig (
128
- chain : CosmWasmChain ,
129
- deploymentType : DeploymentType ,
130
- wormholeContract : string
131
- ) : DeploymentConfig {
132
- return getPythConfig ( {
133
- feeDenom : chain . feeDenom ,
134
- wormholeChainId : CHAINS [ chain . wormholeChainName ] ,
135
- wormholeContract,
136
- deploymentType : deploymentType ,
137
- } ) ;
138
- }
139
-
140
130
/**
141
131
* Stores the wasm code on the specified chain using the provided private key as the signer
142
132
* You can find the wasm artifacts from the repo releases
@@ -180,28 +170,6 @@ export class CosmWasmContract extends Contract {
180
170
return new CosmWasmContract ( chain , result . contractAddr ) ;
181
171
}
182
172
183
- /**
184
- * Uploads the wasm code and initializes a new contract to the specified chain.
185
- * Use this method if you are deploying to a new chain, or you want a fresh contract in
186
- * a testnet environment. Uses the default deployment configurations for governance, data sources,
187
- * valid time period, etc. You can manually run the storeCode and initialize methods if you want
188
- * more control over the deployment process.
189
- * @param chain
190
- * @param wormholeContract
191
- * @param privateKey private key to use for signing the transaction in hex format without 0x prefix
192
- * @param wasmPath
193
- */
194
- static async deploy (
195
- chain : CosmWasmChain ,
196
- wormholeContract : string ,
197
- privateKey : PrivateKey ,
198
- wasmPath : string
199
- ) : Promise < CosmWasmContract > {
200
- const config = this . getDeploymentConfig ( chain , "beta" , wormholeContract ) ;
201
- const { codeId } = await this . storeCode ( chain , privateKey , wasmPath ) ;
202
- return this . initialize ( chain , codeId , config , privateKey ) ;
203
- }
204
-
205
173
getId ( ) : string {
206
174
return `${ this . chain . getId ( ) } _${ this . address } ` ;
207
175
}
@@ -247,9 +215,6 @@ export class CosmWasmContract extends Contract {
247
215
return Number ( config . config_v1 . governance_sequence_number ) ;
248
216
}
249
217
250
- // TODO: function for upgrading the contract
251
- // TODO: Cleanup and more strict linter to convert let to const
252
-
253
218
private parsePrice ( priceInfo : Price ) {
254
219
return {
255
220
conf : priceInfo . conf . toString ( ) ,
@@ -295,31 +260,20 @@ export class CosmWasmContract extends Contract {
295
260
296
261
async getDeploymentType ( ) : Promise < string > {
297
262
const config = await this . getConfig ( ) ;
298
- const wormholeContract = config . config_v1 . wormhole_contract ;
299
- const stableConfig = getPythConfig ( {
300
- feeDenom : this . chain . feeDenom ,
301
- wormholeChainId : CHAINS [ this . chain . getId ( ) as keyof typeof CHAINS ] ,
302
- wormholeContract,
303
- deploymentType : "stable" ,
304
- } ) ;
305
- const betaConfig = getPythConfig ( {
306
- feeDenom : this . chain . feeDenom ,
307
- wormholeChainId : CHAINS [ this . chain . getId ( ) as keyof typeof CHAINS ] ,
308
- wormholeContract,
309
- deploymentType : "beta" ,
310
- } ) ;
311
- if (
312
- this . equalDataSources (
313
- config . config_v1 . data_sources ,
314
- stableConfig . data_sources
315
- )
316
- )
263
+ const convertDataSource = ( source : DataSource ) => {
264
+ return {
265
+ emitter : Buffer . from ( source . emitterAddress , "hex" ) . toString ( "base64" ) ,
266
+ chain_id : source . emitterChain ,
267
+ } ;
268
+ } ;
269
+ const stableDataSources =
270
+ getDefaultDeploymentConfig ( "stable" ) . dataSources . map ( convertDataSource ) ;
271
+ const betaDataSources =
272
+ getDefaultDeploymentConfig ( "beta" ) . dataSources . map ( convertDataSource ) ;
273
+ if ( this . equalDataSources ( config . config_v1 . data_sources , stableDataSources ) )
317
274
return "stable" ;
318
275
else if (
319
- this . equalDataSources (
320
- config . config_v1 . data_sources ,
321
- betaConfig . data_sources
322
- )
276
+ this . equalDataSources ( config . config_v1 . data_sources , betaDataSources )
323
277
)
324
278
return "beta" ;
325
279
else return "unknown" ;
0 commit comments