[price-service] Update wormhole sdk package (#495)
* [price-service] Update wormhole sdk package Wormhole new sdk does not use wasm and is cleaner. It makes our code one step closer to no wasm too. * trigger ci * Fix pre-commit errors
This commit is contained in:
parent
c10ed691da
commit
b05845ede5
File diff suppressed because it is too large
Load Diff
|
@ -29,7 +29,7 @@
|
|||
"typescript": "^4.3.5"
|
||||
},
|
||||
"dependencies": {
|
||||
"@certusone/wormhole-sdk": "^0.1.4",
|
||||
"@certusone/wormhole-sdk": "^0.9.9",
|
||||
"@certusone/wormhole-spydk": "^0.0.1",
|
||||
"@pythnetwork/p2w-sdk-js": "file:../third_party/pyth/p2w-sdk/js",
|
||||
"@pythnetwork/pyth-sdk-js": "^1.1.0",
|
||||
|
|
|
@ -42,7 +42,7 @@ function dummyPriceInfoPair(
|
|||
priceFeed: dummyPriceFeed(id),
|
||||
publishTime: 0,
|
||||
attestationTime: 0,
|
||||
seqNum,
|
||||
seqNum: BigInt(seqNum),
|
||||
vaa: Buffer.from(vaa, "hex"),
|
||||
emitterChainId: 0,
|
||||
priceServiceReceiveTime: 0,
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
import { setDefaultWasm } from "@certusone/wormhole-sdk/lib/cjs/solana/wasm";
|
||||
|
||||
import { envOrErr } from "./helpers";
|
||||
import { Listener } from "./listen";
|
||||
import { initLogger } from "./logging";
|
||||
|
@ -17,8 +15,6 @@ console.log("Loading config file [%s]", configFile);
|
|||
// tslint:disable:no-var-requires
|
||||
require("dotenv").config({ path: configFile });
|
||||
|
||||
setDefaultWasm("node");
|
||||
|
||||
// Set up the logger.
|
||||
initLogger({ logLevel: process.env.LOG_LEVEL });
|
||||
|
||||
|
|
|
@ -1,11 +1,9 @@
|
|||
import { ChainId, uint8ArrayToHex } from "@certusone/wormhole-sdk";
|
||||
|
||||
import {
|
||||
createSpyRPCServiceClient,
|
||||
subscribeSignedVAA,
|
||||
} from "@certusone/wormhole-spydk";
|
||||
|
||||
import { importCoreWasm } from "@certusone/wormhole-sdk/lib/cjs/solana/wasm";
|
||||
import { ChainId, uint8ArrayToHex, parseVaa } from "@certusone/wormhole-sdk";
|
||||
|
||||
import {
|
||||
FilterEntry,
|
||||
|
@ -25,7 +23,7 @@ import { PromClient } from "./promClient";
|
|||
|
||||
export type PriceInfo = {
|
||||
vaa: Buffer;
|
||||
seqNum: number;
|
||||
seqNum: bigint;
|
||||
publishTime: TimestampInSec;
|
||||
attestationTime: TimestampInSec;
|
||||
priceFeed: PriceFeed;
|
||||
|
@ -249,14 +247,12 @@ export class Listener implements PriceStore {
|
|||
}
|
||||
|
||||
async processVaa(vaa: Buffer) {
|
||||
const { parse_vaa } = await importCoreWasm();
|
||||
const parsedVaa = parseVaa(vaa);
|
||||
|
||||
const parsedVaa = parse_vaa(vaa);
|
||||
|
||||
const vaaEmitterAddressHex = Buffer.from(
|
||||
parsedVaa.emitter_address
|
||||
).toString("hex");
|
||||
const observedVaasKey: VaaKey = `${parsedVaa.emitter_chain}#${vaaEmitterAddressHex}#${parsedVaa.sequence}`;
|
||||
const vaaEmitterAddressHex = Buffer.from(parsedVaa.emitterAddress).toString(
|
||||
"hex"
|
||||
);
|
||||
const observedVaasKey: VaaKey = `${parsedVaa.emitterChain}#${vaaEmitterAddressHex}#${parsedVaa.sequence}`;
|
||||
|
||||
if (this.observedVaas.has(observedVaasKey)) {
|
||||
return;
|
||||
|
@ -287,7 +283,7 @@ export class Listener implements PriceStore {
|
|||
publishTime: priceAttestation.publishTime,
|
||||
attestationTime: priceAttestation.attestationTime,
|
||||
priceFeed,
|
||||
emitterChainId: parsedVaa.emitter_chain,
|
||||
emitterChainId: parsedVaa.emitterChain,
|
||||
priceServiceReceiveTime: Math.floor(new Date().getTime() / 1000),
|
||||
};
|
||||
|
||||
|
@ -318,9 +314,9 @@ export class Listener implements PriceStore {
|
|||
|
||||
logger.info(
|
||||
"Parsed a new Batch Price Attestation: [" +
|
||||
parsedVaa.emitter_chain +
|
||||
parsedVaa.emitterChain +
|
||||
":" +
|
||||
uint8ArrayToHex(parsedVaa.emitter_address) +
|
||||
uint8ArrayToHex(parsedVaa.emitterAddress) +
|
||||
"], seqNum: " +
|
||||
parsedVaa.sequence +
|
||||
", Batch Summary: " +
|
||||
|
|
|
@ -84,7 +84,7 @@ export class RestAPI {
|
|||
|
||||
// Multiple price ids might share same vaa, we use sequence number as
|
||||
// key of a vaa and deduplicate using a map of seqnum to vaa bytes.
|
||||
const vaaMap = new Map<number, Buffer>();
|
||||
const vaaMap = new Map<bigint, Buffer>();
|
||||
|
||||
const notFoundIds: string[] = [];
|
||||
|
||||
|
|
Loading…
Reference in New Issue