Add receive time to the price service (#360)
* Add receive time to the price service * Bump version to 2.1.0
This commit is contained in:
parent
3eb2beabe7
commit
4629f689e4
|
@ -11,7 +11,7 @@
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@certusone/wormhole-sdk": "0.2.1",
|
"@certusone/wormhole-sdk": "0.2.1",
|
||||||
"@improbable-eng/grpc-web-node-http-transport": "^0.14.1",
|
"@improbable-eng/grpc-web-node-http-transport": "^0.14.1",
|
||||||
"@pythnetwork/pyth-sdk-js": "^1.0.0"
|
"@pythnetwork/pyth-sdk-js": "^1.1.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@openzeppelin/contracts": "^4.2.0",
|
"@openzeppelin/contracts": "^4.2.0",
|
||||||
|
@ -913,9 +913,9 @@
|
||||||
"integrity": "sha1-p3c2C1s5oaLlEG+OhY8v0tBgxXA="
|
"integrity": "sha1-p3c2C1s5oaLlEG+OhY8v0tBgxXA="
|
||||||
},
|
},
|
||||||
"node_modules/@pythnetwork/pyth-sdk-js": {
|
"node_modules/@pythnetwork/pyth-sdk-js": {
|
||||||
"version": "1.0.0",
|
"version": "1.1.0",
|
||||||
"resolved": "https://registry.npmjs.org/@pythnetwork/pyth-sdk-js/-/pyth-sdk-js-1.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/@pythnetwork/pyth-sdk-js/-/pyth-sdk-js-1.1.0.tgz",
|
||||||
"integrity": "sha512-nZ3tmn5EhR7Y6177cAE7p7iQJK40bipMUI4ZBwRhgTONOcg35jG0fsvlETZYgij0baQ1PMJQE6dIqZ50EMZpJw=="
|
"integrity": "sha512-IfZI/D+7HiA01TfzuA7Fh0SMhsE+hZWoI1pt48G+XMbNkXhiZG4lSQJRsnquSEY06YAFcAX2D66cFtV6BHy8IA=="
|
||||||
},
|
},
|
||||||
"node_modules/@solana/buffer-layout": {
|
"node_modules/@solana/buffer-layout": {
|
||||||
"version": "4.0.0",
|
"version": "4.0.0",
|
||||||
|
@ -3236,9 +3236,9 @@
|
||||||
"integrity": "sha1-p3c2C1s5oaLlEG+OhY8v0tBgxXA="
|
"integrity": "sha1-p3c2C1s5oaLlEG+OhY8v0tBgxXA="
|
||||||
},
|
},
|
||||||
"@pythnetwork/pyth-sdk-js": {
|
"@pythnetwork/pyth-sdk-js": {
|
||||||
"version": "1.0.0",
|
"version": "1.1.0",
|
||||||
"resolved": "https://registry.npmjs.org/@pythnetwork/pyth-sdk-js/-/pyth-sdk-js-1.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/@pythnetwork/pyth-sdk-js/-/pyth-sdk-js-1.1.0.tgz",
|
||||||
"integrity": "sha512-nZ3tmn5EhR7Y6177cAE7p7iQJK40bipMUI4ZBwRhgTONOcg35jG0fsvlETZYgij0baQ1PMJQE6dIqZ50EMZpJw=="
|
"integrity": "sha512-IfZI/D+7HiA01TfzuA7Fh0SMhsE+hZWoI1pt48G+XMbNkXhiZG4lSQJRsnquSEY06YAFcAX2D66cFtV6BHy8IA=="
|
||||||
},
|
},
|
||||||
"@solana/buffer-layout": {
|
"@solana/buffer-layout": {
|
||||||
"version": "4.0.0",
|
"version": "4.0.0",
|
||||||
|
|
|
@ -42,7 +42,7 @@
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@certusone/wormhole-sdk": "0.2.1",
|
"@certusone/wormhole-sdk": "0.2.1",
|
||||||
"@improbable-eng/grpc-web-node-http-transport": "^0.14.1",
|
"@improbable-eng/grpc-web-node-http-transport": "^0.14.1",
|
||||||
"@pythnetwork/pyth-sdk-js": "^1.0.0"
|
"@pythnetwork/pyth-sdk-js": "^1.1.0"
|
||||||
},
|
},
|
||||||
"bugs": {
|
"bugs": {
|
||||||
"url": "https://github.com/pyth-network/pyth-crosschain/issues"
|
"url": "https://github.com/pyth-network/pyth-crosschain/issues"
|
||||||
|
|
|
@ -1,18 +1,18 @@
|
||||||
{
|
{
|
||||||
"name": "@pythnetwork/pyth-price-service",
|
"name": "@pythnetwork/pyth-price-service",
|
||||||
"version": "2.0.0",
|
"version": "2.1.0",
|
||||||
"lockfileVersion": 2,
|
"lockfileVersion": 2,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "@pythnetwork/pyth-price-service",
|
"name": "@pythnetwork/pyth-price-service",
|
||||||
"version": "2.0.0",
|
"version": "2.1.0",
|
||||||
"license": "Apache-2.0",
|
"license": "Apache-2.0",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@certusone/wormhole-sdk": "^0.1.4",
|
"@certusone/wormhole-sdk": "^0.1.4",
|
||||||
"@certusone/wormhole-spydk": "^0.0.1",
|
"@certusone/wormhole-spydk": "^0.0.1",
|
||||||
"@pythnetwork/p2w-sdk-js": "file:../p2w-sdk/js",
|
"@pythnetwork/p2w-sdk-js": "file:../p2w-sdk/js",
|
||||||
"@pythnetwork/pyth-sdk-js": "^1.0.0",
|
"@pythnetwork/pyth-sdk-js": "^1.1.0",
|
||||||
"@types/cors": "^2.8.12",
|
"@types/cors": "^2.8.12",
|
||||||
"@types/express": "^4.17.13",
|
"@types/express": "^4.17.13",
|
||||||
"@types/morgan": "^1.9.3",
|
"@types/morgan": "^1.9.3",
|
||||||
|
@ -2201,9 +2201,9 @@
|
||||||
"link": true
|
"link": true
|
||||||
},
|
},
|
||||||
"node_modules/@pythnetwork/pyth-sdk-js": {
|
"node_modules/@pythnetwork/pyth-sdk-js": {
|
||||||
"version": "1.0.0",
|
"version": "1.1.0",
|
||||||
"resolved": "https://registry.npmjs.org/@pythnetwork/pyth-sdk-js/-/pyth-sdk-js-1.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/@pythnetwork/pyth-sdk-js/-/pyth-sdk-js-1.1.0.tgz",
|
||||||
"integrity": "sha512-nZ3tmn5EhR7Y6177cAE7p7iQJK40bipMUI4ZBwRhgTONOcg35jG0fsvlETZYgij0baQ1PMJQE6dIqZ50EMZpJw=="
|
"integrity": "sha512-IfZI/D+7HiA01TfzuA7Fh0SMhsE+hZWoI1pt48G+XMbNkXhiZG4lSQJRsnquSEY06YAFcAX2D66cFtV6BHy8IA=="
|
||||||
},
|
},
|
||||||
"node_modules/@sideway/address": {
|
"node_modules/@sideway/address": {
|
||||||
"version": "4.1.4",
|
"version": "4.1.4",
|
||||||
|
@ -10545,9 +10545,9 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"@pythnetwork/pyth-sdk-js": {
|
"@pythnetwork/pyth-sdk-js": {
|
||||||
"version": "1.0.0",
|
"version": "1.1.0",
|
||||||
"resolved": "https://registry.npmjs.org/@pythnetwork/pyth-sdk-js/-/pyth-sdk-js-1.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/@pythnetwork/pyth-sdk-js/-/pyth-sdk-js-1.1.0.tgz",
|
||||||
"integrity": "sha512-nZ3tmn5EhR7Y6177cAE7p7iQJK40bipMUI4ZBwRhgTONOcg35jG0fsvlETZYgij0baQ1PMJQE6dIqZ50EMZpJw=="
|
"integrity": "sha512-IfZI/D+7HiA01TfzuA7Fh0SMhsE+hZWoI1pt48G+XMbNkXhiZG4lSQJRsnquSEY06YAFcAX2D66cFtV6BHy8IA=="
|
||||||
},
|
},
|
||||||
"@sideway/address": {
|
"@sideway/address": {
|
||||||
"version": "4.1.4",
|
"version": "4.1.4",
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "@pythnetwork/pyth-price-service",
|
"name": "@pythnetwork/pyth-price-service",
|
||||||
"version": "2.0.0",
|
"version": "2.1.0",
|
||||||
"description": "Pyth Price Service",
|
"description": "Pyth Price Service",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
@ -28,10 +28,10 @@
|
||||||
"typescript": "^4.3.5"
|
"typescript": "^4.3.5"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@pythnetwork/p2w-sdk-js": "file:../p2w-sdk/js",
|
|
||||||
"@certusone/wormhole-sdk": "^0.1.4",
|
"@certusone/wormhole-sdk": "^0.1.4",
|
||||||
"@certusone/wormhole-spydk": "^0.0.1",
|
"@certusone/wormhole-spydk": "^0.0.1",
|
||||||
"@pythnetwork/pyth-sdk-js": "^1.0.0",
|
"@pythnetwork/p2w-sdk-js": "file:../p2w-sdk/js",
|
||||||
|
"@pythnetwork/pyth-sdk-js": "^1.1.0",
|
||||||
"@types/cors": "^2.8.12",
|
"@types/cors": "^2.8.12",
|
||||||
"@types/express": "^4.17.13",
|
"@types/express": "^4.17.13",
|
||||||
"@types/morgan": "^1.9.3",
|
"@types/morgan": "^1.9.3",
|
||||||
|
|
|
@ -43,6 +43,7 @@ function dummyPriceInfoPair(
|
||||||
seqNum,
|
seqNum,
|
||||||
vaaBytes: Buffer.from(vaa, "hex").toString("binary"),
|
vaaBytes: Buffer.from(vaa, "hex").toString("binary"),
|
||||||
emitterChainId: 0,
|
emitterChainId: 0,
|
||||||
|
priceServiceReceiveTime: 0,
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
import { HexString, PriceFeed } from "@pythnetwork/pyth-sdk-js";
|
import { HexString, PriceFeed } from "@pythnetwork/pyth-sdk-js";
|
||||||
import { Server } from "http";
|
import { Server } from "http";
|
||||||
|
import { number } from "joi";
|
||||||
import { WebSocket, WebSocketServer } from "ws";
|
import { WebSocket, WebSocketServer } from "ws";
|
||||||
import { sleep } from "../helpers";
|
import { sleep } from "../helpers";
|
||||||
import { PriceInfo, PriceStore } from "../listen";
|
import { PriceInfo, PriceStore } from "../listen";
|
||||||
|
@ -21,12 +22,14 @@ function expandTo64Len(id: string): string {
|
||||||
function dummyPriceMetadata(
|
function dummyPriceMetadata(
|
||||||
attestationTime: number,
|
attestationTime: number,
|
||||||
emitterChainId: number,
|
emitterChainId: number,
|
||||||
seqNum: number
|
seqNum: number,
|
||||||
|
priceServiceReceiveTime: number
|
||||||
): any {
|
): any {
|
||||||
return {
|
return {
|
||||||
attestation_time: attestationTime,
|
attestation_time: attestationTime,
|
||||||
emitter_chain: emitterChainId,
|
emitter_chain: emitterChainId,
|
||||||
sequence_number: seqNum,
|
sequence_number: seqNum,
|
||||||
|
price_service_receive_time: priceServiceReceiveTime,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -41,6 +44,7 @@ function dummyPriceInfo(
|
||||||
emitterChainId: dummyPriceMetadataValue.emitter_chain,
|
emitterChainId: dummyPriceMetadataValue.emitter_chain,
|
||||||
priceFeed: dummyPriceFeed(id),
|
priceFeed: dummyPriceFeed(id),
|
||||||
vaaBytes: Buffer.from(vaa, "hex").toString("binary"),
|
vaaBytes: Buffer.from(vaa, "hex").toString("binary"),
|
||||||
|
priceServiceReceiveTime: dummyPriceMetadataValue.price_service_receive_time,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -92,7 +96,7 @@ async function createSocketClient(): Promise<[WebSocket, any[]]> {
|
||||||
}
|
}
|
||||||
|
|
||||||
beforeAll(async () => {
|
beforeAll(async () => {
|
||||||
priceMetadata = dummyPriceMetadata(0, 0, 0);
|
priceMetadata = dummyPriceMetadata(0, 0, 0, 0);
|
||||||
priceInfos = [
|
priceInfos = [
|
||||||
dummyPriceInfo(expandTo64Len("abcd"), "a1b2c3d4", priceMetadata),
|
dummyPriceInfo(expandTo64Len("abcd"), "a1b2c3d4", priceMetadata),
|
||||||
dummyPriceInfo(expandTo64Len("ef01"), "a1b2c3d4", priceMetadata),
|
dummyPriceInfo(expandTo64Len("ef01"), "a1b2c3d4", priceMetadata),
|
||||||
|
|
|
@ -32,6 +32,7 @@ export type PriceInfo = {
|
||||||
attestationTime: TimestampInSec;
|
attestationTime: TimestampInSec;
|
||||||
priceFeed: PriceFeed;
|
priceFeed: PriceFeed;
|
||||||
emitterChainId: number;
|
emitterChainId: number;
|
||||||
|
priceServiceReceiveTime: number;
|
||||||
};
|
};
|
||||||
|
|
||||||
export interface PriceStore {
|
export interface PriceStore {
|
||||||
|
@ -198,6 +199,7 @@ export class Listener implements PriceStore {
|
||||||
attestationTime: priceAttestation.attestationTime,
|
attestationTime: priceAttestation.attestationTime,
|
||||||
priceFeed,
|
priceFeed,
|
||||||
emitterChainId: parsedVAA.emitter_chain,
|
emitterChainId: parsedVAA.emitter_chain,
|
||||||
|
priceServiceReceiveTime: Math.floor(new Date().getTime() / 1000),
|
||||||
};
|
};
|
||||||
this.priceFeedVaaMap.set(key, priceInfo);
|
this.priceFeedVaaMap.set(key, priceInfo);
|
||||||
|
|
||||||
|
|
|
@ -179,6 +179,8 @@ export class RestAPI {
|
||||||
emitter_chain: latestPriceInfo.emitterChainId,
|
emitter_chain: latestPriceInfo.emitterChainId,
|
||||||
attestation_time: latestPriceInfo.attestationTime,
|
attestation_time: latestPriceInfo.attestationTime,
|
||||||
sequence_number: latestPriceInfo.seqNum,
|
sequence_number: latestPriceInfo.seqNum,
|
||||||
|
price_service_receive_time:
|
||||||
|
latestPriceInfo.priceServiceReceiveTime,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -109,6 +109,7 @@ export class WebSocketAPI {
|
||||||
emitter_chain: priceInfo.emitterChainId,
|
emitter_chain: priceInfo.emitterChainId,
|
||||||
attestation_time: priceInfo.attestationTime,
|
attestation_time: priceInfo.attestationTime,
|
||||||
sequence_number: priceInfo.seqNum,
|
sequence_number: priceInfo.seqNum,
|
||||||
|
price_service_receive_time: priceInfo.priceServiceReceiveTime,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue