@@ -7,13 +7,10 @@ import {
77import { readFileSync } from "fs" ;
88import { Bech32 , toHex } from "@cosmjs/encoding" ;
99import { zeroPad } from "ethers/lib/utils.js" ;
10- import axios from "axios" ;
1110import yargs from "yargs" ;
1211import { hideBin } from "yargs/helpers" ;
1312import assert from "assert" ;
1413
15- export const TERRA_GAS_PRICES_URL = "https://fcd.terra.dev/v1/txs/gas_prices" ;
16-
1714const argv = yargs ( hideBin ( process . argv ) )
1815 . option ( "network" , {
1916 description : "Which network to deploy to" ,
@@ -64,38 +61,96 @@ const artifact = argv.artifact;
6461const CONFIG = {
6562 mainnet : {
6663 terraHost : {
67- URL : "https://lcd.terra.dev" ,
68- chainID : "columbus-5 " ,
64+ URL : "https://phoenix- lcd.terra.dev" ,
65+ chainID : "phoenix-1 " ,
6966 name : "mainnet" ,
7067 } ,
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+ } ,
74103 } ,
75104 testnet : {
76105 terraHost : {
77- URL : "https://bombay -lcd.terra.dev" ,
78- chainID : "bombay-12 " ,
106+ URL : "https://pisco -lcd.terra.dev" ,
107+ chainID : "pisco-1 " ,
79108 name : "testnet" ,
80109 } ,
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+ } ,
84145 } ,
85146} ;
86147
87148const 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 ;
91150const lcd = new LCDClient ( terraHost ) ;
92151
93152const feeDenoms = [ "uluna" ] ;
94153
95- const gasPrices = await axios
96- . get ( TERRA_GAS_PRICES_URL )
97- . then ( ( result ) => result . data ) ;
98-
99154const wallet = lcd . wallet (
100155 new MnemonicKey ( {
101156 mnemonic : argv . mnemonic ,
@@ -124,22 +179,9 @@ if (argv.codeId !== undefined) {
124179 contract_bytes . toString ( "base64" )
125180 ) ;
126181
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-
138182 const tx = await wallet . createAndSignTx ( {
139183 msgs : [ store_code ] ,
140184 feeDenoms,
141- gasPrices,
142- fee : feeEstimate ,
143185 } ) ;
144186
145187 const rs = await lcd . tx . broadcast ( tx ) ;
@@ -166,7 +208,7 @@ if (argv.codeId !== undefined) {
166208if ( argv . instantiate ) {
167209 console . log ( "Instantiating a contract" ) ;
168210
169- async function instantiate ( codeId , inst_msg ) {
211+ async function instantiate ( codeId , inst_msg , label ) {
170212 var address ;
171213 await wallet
172214 . createAndSignTx ( {
@@ -175,7 +217,9 @@ if (argv.instantiate) {
175217 wallet . key . accAddress ,
176218 wallet . key . accAddress ,
177219 codeId ,
178- inst_msg
220+ inst_msg ,
221+ undefined ,
222+ label
179223 ) ,
180224 ] ,
181225 } )
@@ -199,13 +243,7 @@ if (argv.instantiate) {
199243 return address ;
200244 }
201245
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" ) ;
209247
210248 console . log ( `Deployed Pyth contract at ${ contractAddress } ` ) ;
211249}
@@ -233,7 +271,6 @@ if (argv.migrate) {
233271 ) ,
234272 ] ,
235273 feeDenoms,
236- gasPrices,
237274 } ) ;
238275
239276 const rs = await lcd . tx . broadcast ( tx ) ;
0 commit comments