@@ -7,13 +7,10 @@ import {
7
7
import { readFileSync } from "fs" ;
8
8
import { Bech32 , toHex } from "@cosmjs/encoding" ;
9
9
import { zeroPad } from "ethers/lib/utils.js" ;
10
- import axios from "axios" ;
11
10
import yargs from "yargs" ;
12
11
import { hideBin } from "yargs/helpers" ;
13
12
import assert from "assert" ;
14
13
15
- export const TERRA_GAS_PRICES_URL = "https://fcd.terra.dev/v1/txs/gas_prices" ;
16
-
17
14
const argv = yargs ( hideBin ( process . argv ) )
18
15
. option ( "network" , {
19
16
description : "Which network to deploy to" ,
@@ -64,38 +61,96 @@ const artifact = argv.artifact;
64
61
const CONFIG = {
65
62
mainnet : {
66
63
terraHost : {
67
- URL : "https://lcd.terra.dev" ,
68
- chainID : "columbus-5 " ,
64
+ URL : "https://phoenix- lcd.terra.dev" ,
65
+ chainID : "phoenix-1 " ,
69
66
name : "mainnet" ,
70
67
} ,
71
- wormholeContract : "terra1dq03ugtd40zu9hcgdzrsq6z2z4hwhc9tqk2uy5" ,
72
- pythEmitterAddress :
73
- "6bb14509a612f01fbbc4cffeebd4bbfb492a86df717ebe92eb6df432a3f00a25" ,
68
+ pyth_config : {
69
+ wormhole_contract :
70
+ "terra12mrnzvhx3rpej6843uge2yyfppfyd3u9c3uq223q8sl48huz9juqffcnh" ,
71
+ data_sources : [
72
+ {
73
+ emitter : Buffer . from (
74
+ "6bb14509a612f01fbbc4cffeebd4bbfb492a86df717ebe92eb6df432a3f00a25" ,
75
+ "hex"
76
+ ) . toString ( "base64" ) ,
77
+ chain_id : 1 ,
78
+ } ,
79
+ {
80
+ emitter : Buffer . from (
81
+ "f8cd23c2ab91237730770bbea08d61005cdda0984348f3f6eecb559638c0bba0" ,
82
+ "hex"
83
+ ) . toString ( "base64" ) ,
84
+ chain_id : 26 ,
85
+ } ,
86
+ ] ,
87
+ governance_source : {
88
+ emitter : Buffer . from (
89
+ "5635979a221c34931e32620b9293a463065555ea71fe97cd6237ade875b12e9e" ,
90
+ "hex"
91
+ ) . toString ( "base64" ) ,
92
+ chain_id : 1 ,
93
+ } ,
94
+ governance_source_index : 0 ,
95
+ governance_sequence_number : 0 ,
96
+ chain_id : 18 ,
97
+ valid_time_period_secs : 60 ,
98
+ fee : {
99
+ amount : "1" ,
100
+ denom : "uluna" ,
101
+ } ,
102
+ } ,
74
103
} ,
75
104
testnet : {
76
105
terraHost : {
77
- URL : "https://bombay -lcd.terra.dev" ,
78
- chainID : "bombay-12 " ,
106
+ URL : "https://pisco -lcd.terra.dev" ,
107
+ chainID : "pisco-1 " ,
79
108
name : "testnet" ,
80
109
} ,
81
- wormholeContract : "terra1pd65m0q9tl3v8znnz5f5ltsfegyzah7g42cx5v" ,
82
- pythEmitterAddress :
83
- "f346195ac02f37d60d4db8ffa6ef74cb1be3550047543a4a9ee9acf4d78697b0" ,
110
+ pyth_config : {
111
+ wormhole_contract :
112
+ "terra19nv3xr5lrmmr7egvrk2kqgw4kcn43xrtd5g0mpgwwvhetusk4k7s66jyv0" ,
113
+ data_sources : [
114
+ {
115
+ emitter : Buffer . from (
116
+ "f346195ac02f37d60d4db8ffa6ef74cb1be3550047543a4a9ee9acf4d78697b0" ,
117
+ "hex"
118
+ ) . toString ( "base64" ) ,
119
+ chain_id : 1 ,
120
+ } ,
121
+ {
122
+ emitter : Buffer . from (
123
+ "a27839d641b07743c0cb5f68c51f8cd31d2c0762bec00dc6fcd25433ef1ab5b6" ,
124
+ "hex"
125
+ ) . toString ( "base64" ) ,
126
+ chain_id : 26 ,
127
+ } ,
128
+ ] ,
129
+ governance_source : {
130
+ emitter : Buffer . from (
131
+ "63278d271099bfd491951b3e648f08b1c71631e4a53674ad43e8f9f98068c385" ,
132
+ "hex"
133
+ ) . toString ( "base64" ) ,
134
+ chain_id : 1 ,
135
+ } ,
136
+ governance_source_index : 0 ,
137
+ governance_sequence_number : 0 ,
138
+ chain_id : 18 ,
139
+ valid_time_period_secs : 60 ,
140
+ fee : {
141
+ amount : "1" ,
142
+ denom : "uluna" ,
143
+ } ,
144
+ } ,
84
145
} ,
85
146
} ;
86
147
87
148
const terraHost = CONFIG [ argv . network ] . terraHost ;
88
- const wormholeContract = CONFIG [ argv . network ] . wormholeContract ;
89
- const pythEmitterAddress = CONFIG [ argv . network ] . pythEmitterAddress ;
90
-
149
+ const pythConfig = CONFIG [ argv . network ] . pyth_config ;
91
150
const lcd = new LCDClient ( terraHost ) ;
92
151
93
152
const feeDenoms = [ "uluna" ] ;
94
153
95
- const gasPrices = await axios
96
- . get ( TERRA_GAS_PRICES_URL )
97
- . then ( ( result ) => result . data ) ;
98
-
99
154
const wallet = lcd . wallet (
100
155
new MnemonicKey ( {
101
156
mnemonic : argv . mnemonic ,
@@ -124,22 +179,9 @@ if (argv.codeId !== undefined) {
124
179
contract_bytes . toString ( "base64" )
125
180
) ;
126
181
127
- const feeEstimate = await lcd . tx . estimateFee (
128
- wallet . key . accAddress ,
129
- [ store_code ] ,
130
- {
131
- feeDenoms,
132
- gasPrices,
133
- }
134
- ) ;
135
-
136
- console . log ( "Deploy fee: " , feeEstimate . amount . toString ( ) ) ;
137
-
138
182
const tx = await wallet . createAndSignTx ( {
139
183
msgs : [ store_code ] ,
140
184
feeDenoms,
141
- gasPrices,
142
- fee : feeEstimate ,
143
185
} ) ;
144
186
145
187
const rs = await lcd . tx . broadcast ( tx ) ;
@@ -166,7 +208,7 @@ if (argv.codeId !== undefined) {
166
208
if ( argv . instantiate ) {
167
209
console . log ( "Instantiating a contract" ) ;
168
210
169
- async function instantiate ( codeId , inst_msg ) {
211
+ async function instantiate ( codeId , inst_msg , label ) {
170
212
var address ;
171
213
await wallet
172
214
. createAndSignTx ( {
@@ -175,7 +217,9 @@ if (argv.instantiate) {
175
217
wallet . key . accAddress ,
176
218
wallet . key . accAddress ,
177
219
codeId ,
178
- inst_msg
220
+ inst_msg ,
221
+ undefined ,
222
+ label
179
223
) ,
180
224
] ,
181
225
} )
@@ -199,13 +243,7 @@ if (argv.instantiate) {
199
243
return address ;
200
244
}
201
245
202
- const pythChain = 1 ;
203
-
204
- const contractAddress = await instantiate ( codeId , {
205
- wormhole_contract : wormholeContract ,
206
- pyth_emitter : Buffer . from ( pythEmitterAddress , "hex" ) . toString ( "base64" ) ,
207
- pyth_emitter_chain : pythChain ,
208
- } ) ;
246
+ const contractAddress = await instantiate ( codeId , pythConfig , "pyth" ) ;
209
247
210
248
console . log ( `Deployed Pyth contract at ${ contractAddress } ` ) ;
211
249
}
@@ -233,7 +271,6 @@ if (argv.migrate) {
233
271
) ,
234
272
] ,
235
273
feeDenoms,
236
- gasPrices,
237
274
} ) ;
238
275
239
276
const rs = await lcd . tx . broadcast ( tx ) ;
0 commit comments