Skip to content

Commit b1c3454

Browse files
author
Stan Drozd
committed
p2w-relay: Fix faulty merge resolution in favor of origin/main
1 parent d75b8ab commit b1c3454

File tree

2 files changed

+25
-9
lines changed

2 files changed

+25
-9
lines changed

third_party/pyth/p2w-relay/package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

third_party/pyth/p2w-relay/src/relay/terra.ts

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { fromUint8Array } from "js-base64";
21
import {
32
Coin,
43
LCDClient,
@@ -7,7 +6,6 @@ import {
76
Msg,
87
MsgExecuteContract,
98
} from "@terra-money/terra.js";
10-
import { hexToUint8Array } from "@certusone/wormhole-sdk";
119
import axios from "axios";
1210
import { logger } from "../helpers";
1311

@@ -67,6 +65,9 @@ export class TerraRelay implements Relay {
6765

6866
const wallet = lcdClient.wallet(mk);
6967

68+
logger.debug("TIME: Querying fee");
69+
let fee: Coin = await this.getUpdateFee(signedVAAs);
70+
7071
logger.debug("TIME: creating messages");
7172

7273
let base64VAAs = [];
@@ -182,18 +183,33 @@ export class TerraRelay implements Relay {
182183
logger.info("Querying terra for price info for priceId [" + priceId + "]");
183184

184185
const lcdClient = new LCDClient(this.lcdConfig);
185-
186-
const mk = new MnemonicKey({
187-
mnemonic: this.walletPrivateKey,
188-
});
189-
190186
return await lcdClient.wasm.contractQuery(this.contractAddress, {
191187
price_feed: {
192188
id: priceId,
193189
},
194190
});
195191
}
196192

193+
async getUpdateFee(hexVAAs: Array<string>): Promise<Coin> {
194+
const lcdClient = new LCDClient(this.lcdConfig);
195+
196+
let base64VAAs = [];
197+
for (let idx = 0; idx < hexVAAs.length; ++idx) {
198+
base64VAAs.push(Buffer.from(hexVAAs[idx], "hex").toString("base64"));
199+
}
200+
201+
let result = await lcdClient.wasm.contractQuery<Coin.Data>(
202+
this.contractAddress,
203+
{
204+
get_update_fee: {
205+
vaas: base64VAAs,
206+
},
207+
}
208+
);
209+
210+
return Coin.fromData(result);
211+
}
212+
197213
async getPayerInfo(): Promise<{ address: string; balance: bigint }> {
198214
const lcdClient = new LCDClient(this.lcdConfig);
199215

0 commit comments

Comments
 (0)