@pythnetwork/pyth-lazer-sdk 0.3.3 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -5,6 +5,8 @@ export type BinaryResponse = {
5
5
  evm?: Buffer | undefined;
6
6
  solana?: Buffer | undefined;
7
7
  parsed?: ParsedPayload | undefined;
8
+ leEcdsa?: Buffer | undefined;
9
+ leUnsigned?: Buffer | undefined;
8
10
  };
9
11
  export type JsonOrBinaryResponse = {
10
12
  type: "json";
@@ -39,9 +39,9 @@ class PythLazerClient {
39
39
  }
40
40
  else if (Buffer.isBuffer(data)) {
41
41
  let pos = 0;
42
- const magic = data.subarray(pos, pos + UINT32_NUM_BYTES).readUint32BE();
42
+ const magic = data.subarray(pos, pos + UINT32_NUM_BYTES).readUint32LE();
43
43
  pos += UINT32_NUM_BYTES;
44
- if (magic != protocol_js_1.BINARY_UPDATE_FORMAT_MAGIC) {
44
+ if (magic != protocol_js_1.BINARY_UPDATE_FORMAT_MAGIC_LE) {
45
45
  throw new Error("binary update format magic mismatch");
46
46
  }
47
47
  // TODO: some uint64 values may not be representable as Number.
@@ -53,14 +53,20 @@ class PythLazerClient {
53
53
  pos += UINT16_NUM_BYTES;
54
54
  const magic = data
55
55
  .subarray(pos, pos + UINT32_NUM_BYTES)
56
- .readUint32BE();
57
- if (magic == protocol_js_1.EVM_FORMAT_MAGIC) {
56
+ .readUint32LE();
57
+ if (magic == protocol_js_1.FORMAT_MAGICS_LE.EVM) {
58
58
  value.evm = data.subarray(pos, pos + len);
59
59
  }
60
- else if (magic == protocol_js_1.SOLANA_FORMAT_MAGIC_BE) {
60
+ else if (magic == protocol_js_1.FORMAT_MAGICS_LE.SOLANA) {
61
61
  value.solana = data.subarray(pos, pos + len);
62
62
  }
63
- else if (magic == protocol_js_1.PARSED_FORMAT_MAGIC) {
63
+ else if (magic == protocol_js_1.FORMAT_MAGICS_LE.LE_ECDSA) {
64
+ value.leEcdsa = data.subarray(pos, pos + len);
65
+ }
66
+ else if (magic == protocol_js_1.FORMAT_MAGICS_LE.LE_UNSIGNED) {
67
+ value.leUnsigned = data.subarray(pos, pos + len);
68
+ }
69
+ else if (magic == protocol_js_1.FORMAT_MAGICS_LE.JSON) {
64
70
  value.parsed = JSON.parse(data.subarray(pos + UINT32_NUM_BYTES, pos + len).toString());
65
71
  }
66
72
  else {
@@ -1,4 +1,4 @@
1
- export type Chain = "evm" | "solana";
1
+ export type Format = "evm" | "solana" | "leEcdsa" | "leUnsigned";
2
2
  export type DeliveryFormat = "json" | "binary";
3
3
  export type JsonBinaryEncoding = "base64" | "hex";
4
4
  export type PriceFeedProperty = "price" | "bestBidPrice" | "bestAskPrice" | "exponent" | "publisherCount" | "confidence";
@@ -8,7 +8,7 @@ export type Request = {
8
8
  subscriptionId: number;
9
9
  priceFeedIds: number[];
10
10
  properties: PriceFeedProperty[];
11
- chains: Chain[];
11
+ formats: Format[];
12
12
  deliveryFormat?: DeliveryFormat;
13
13
  jsonBinaryEncoding?: JsonBinaryEncoding;
14
14
  parsed?: boolean;
@@ -53,8 +53,14 @@ export type Response = {
53
53
  parsed?: ParsedPayload | undefined;
54
54
  evm?: JsonBinaryData | undefined;
55
55
  solana?: JsonBinaryData | undefined;
56
+ leEcdsa?: JsonBinaryData | undefined;
57
+ leUnsigned?: JsonBinaryData | undefined;
58
+ };
59
+ export declare const BINARY_UPDATE_FORMAT_MAGIC_LE = 461928307;
60
+ export declare const FORMAT_MAGICS_LE: {
61
+ JSON: number;
62
+ EVM: number;
63
+ SOLANA: number;
64
+ LE_ECDSA: number;
65
+ LE_UNSIGNED: number;
56
66
  };
57
- export declare const BINARY_UPDATE_FORMAT_MAGIC = 1937213467;
58
- export declare const PARSED_FORMAT_MAGIC = 2584795844;
59
- export declare const EVM_FORMAT_MAGIC = 706910618;
60
- export declare const SOLANA_FORMAT_MAGIC_BE = 3103857282;
@@ -1,7 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.SOLANA_FORMAT_MAGIC_BE = exports.EVM_FORMAT_MAGIC = exports.PARSED_FORMAT_MAGIC = exports.BINARY_UPDATE_FORMAT_MAGIC = void 0;
4
- exports.BINARY_UPDATE_FORMAT_MAGIC = 1_937_213_467;
5
- exports.PARSED_FORMAT_MAGIC = 2_584_795_844;
6
- exports.EVM_FORMAT_MAGIC = 706_910_618;
7
- exports.SOLANA_FORMAT_MAGIC_BE = 3_103_857_282;
3
+ exports.FORMAT_MAGICS_LE = exports.BINARY_UPDATE_FORMAT_MAGIC_LE = void 0;
4
+ exports.BINARY_UPDATE_FORMAT_MAGIC_LE = 461_928_307;
5
+ exports.FORMAT_MAGICS_LE = {
6
+ JSON: 3_302_625_434,
7
+ EVM: 2_593_727_018,
8
+ SOLANA: 2_182_742_457,
9
+ LE_ECDSA: 1_296_547_300,
10
+ LE_UNSIGNED: 1_499_680_012,
11
+ };
@@ -5,6 +5,8 @@ export type BinaryResponse = {
5
5
  evm?: Buffer | undefined;
6
6
  solana?: Buffer | undefined;
7
7
  parsed?: ParsedPayload | undefined;
8
+ leEcdsa?: Buffer | undefined;
9
+ leUnsigned?: Buffer | undefined;
8
10
  };
9
11
  export type JsonOrBinaryResponse = {
10
12
  type: "json";
@@ -1,6 +1,6 @@
1
1
  import WebSocket from "isomorphic-ws";
2
2
  import { dummyLogger } from "ts-log";
3
- import { BINARY_UPDATE_FORMAT_MAGIC, EVM_FORMAT_MAGIC, PARSED_FORMAT_MAGIC, SOLANA_FORMAT_MAGIC_BE, } from "./protocol.js";
3
+ import { BINARY_UPDATE_FORMAT_MAGIC_LE, FORMAT_MAGICS_LE, } from "./protocol.js";
4
4
  import { WebSocketPool } from "./socket/websocket-pool.js";
5
5
  const UINT16_NUM_BYTES = 2;
6
6
  const UINT32_NUM_BYTES = 4;
@@ -37,9 +37,9 @@ export class PythLazerClient {
37
37
  }
38
38
  else if (Buffer.isBuffer(data)) {
39
39
  let pos = 0;
40
- const magic = data.subarray(pos, pos + UINT32_NUM_BYTES).readUint32BE();
40
+ const magic = data.subarray(pos, pos + UINT32_NUM_BYTES).readUint32LE();
41
41
  pos += UINT32_NUM_BYTES;
42
- if (magic != BINARY_UPDATE_FORMAT_MAGIC) {
42
+ if (magic != BINARY_UPDATE_FORMAT_MAGIC_LE) {
43
43
  throw new Error("binary update format magic mismatch");
44
44
  }
45
45
  // TODO: some uint64 values may not be representable as Number.
@@ -51,14 +51,20 @@ export class PythLazerClient {
51
51
  pos += UINT16_NUM_BYTES;
52
52
  const magic = data
53
53
  .subarray(pos, pos + UINT32_NUM_BYTES)
54
- .readUint32BE();
55
- if (magic == EVM_FORMAT_MAGIC) {
54
+ .readUint32LE();
55
+ if (magic == FORMAT_MAGICS_LE.EVM) {
56
56
  value.evm = data.subarray(pos, pos + len);
57
57
  }
58
- else if (magic == SOLANA_FORMAT_MAGIC_BE) {
58
+ else if (magic == FORMAT_MAGICS_LE.SOLANA) {
59
59
  value.solana = data.subarray(pos, pos + len);
60
60
  }
61
- else if (magic == PARSED_FORMAT_MAGIC) {
61
+ else if (magic == FORMAT_MAGICS_LE.LE_ECDSA) {
62
+ value.leEcdsa = data.subarray(pos, pos + len);
63
+ }
64
+ else if (magic == FORMAT_MAGICS_LE.LE_UNSIGNED) {
65
+ value.leUnsigned = data.subarray(pos, pos + len);
66
+ }
67
+ else if (magic == FORMAT_MAGICS_LE.JSON) {
62
68
  value.parsed = JSON.parse(data.subarray(pos + UINT32_NUM_BYTES, pos + len).toString());
63
69
  }
64
70
  else {
@@ -1,4 +1,4 @@
1
- export type Chain = "evm" | "solana";
1
+ export type Format = "evm" | "solana" | "leEcdsa" | "leUnsigned";
2
2
  export type DeliveryFormat = "json" | "binary";
3
3
  export type JsonBinaryEncoding = "base64" | "hex";
4
4
  export type PriceFeedProperty = "price" | "bestBidPrice" | "bestAskPrice" | "exponent" | "publisherCount" | "confidence";
@@ -8,7 +8,7 @@ export type Request = {
8
8
  subscriptionId: number;
9
9
  priceFeedIds: number[];
10
10
  properties: PriceFeedProperty[];
11
- chains: Chain[];
11
+ formats: Format[];
12
12
  deliveryFormat?: DeliveryFormat;
13
13
  jsonBinaryEncoding?: JsonBinaryEncoding;
14
14
  parsed?: boolean;
@@ -53,8 +53,14 @@ export type Response = {
53
53
  parsed?: ParsedPayload | undefined;
54
54
  evm?: JsonBinaryData | undefined;
55
55
  solana?: JsonBinaryData | undefined;
56
+ leEcdsa?: JsonBinaryData | undefined;
57
+ leUnsigned?: JsonBinaryData | undefined;
58
+ };
59
+ export declare const BINARY_UPDATE_FORMAT_MAGIC_LE = 461928307;
60
+ export declare const FORMAT_MAGICS_LE: {
61
+ JSON: number;
62
+ EVM: number;
63
+ SOLANA: number;
64
+ LE_ECDSA: number;
65
+ LE_UNSIGNED: number;
56
66
  };
57
- export declare const BINARY_UPDATE_FORMAT_MAGIC = 1937213467;
58
- export declare const PARSED_FORMAT_MAGIC = 2584795844;
59
- export declare const EVM_FORMAT_MAGIC = 706910618;
60
- export declare const SOLANA_FORMAT_MAGIC_BE = 3103857282;
@@ -1,4 +1,8 @@
1
- export const BINARY_UPDATE_FORMAT_MAGIC = 1_937_213_467;
2
- export const PARSED_FORMAT_MAGIC = 2_584_795_844;
3
- export const EVM_FORMAT_MAGIC = 706_910_618;
4
- export const SOLANA_FORMAT_MAGIC_BE = 3_103_857_282;
1
+ export const BINARY_UPDATE_FORMAT_MAGIC_LE = 461_928_307;
2
+ export const FORMAT_MAGICS_LE = {
3
+ JSON: 3_302_625_434,
4
+ EVM: 2_593_727_018,
5
+ SOLANA: 2_182_742_457,
6
+ LE_ECDSA: 1_296_547_300,
7
+ LE_UNSIGNED: 1_499_680_012,
8
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pythnetwork/pyth-lazer-sdk",
3
- "version": "0.3.3",
3
+ "version": "0.4.0",
4
4
  "description": "Pyth Lazer SDK",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -23,8 +23,8 @@
23
23
  "scripts": {
24
24
  "build:cjs": "tsc --project tsconfig.build.json --verbatimModuleSyntax false --module commonjs --outDir ./dist/cjs && echo '{\"type\":\"commonjs\"}' > dist/cjs/package.json",
25
25
  "build:esm": "tsc --project tsconfig.build.json --outDir ./dist/esm && echo '{\"type\":\"module\"}' > dist/esm/package.json",
26
- "fix:lint": "eslint --fix .",
27
- "test:lint": "eslint .",
26
+ "fix:lint": "eslint --fix . --max-warnings 0",
27
+ "test:lint": "eslint . --max-warnings 0",
28
28
  "test:types": "tsc",
29
29
  "example": "node --loader ts-node/esm examples/index.js",
30
30
  "doc": "typedoc --out docs/typedoc src",
@@ -67,5 +67,5 @@
67
67
  "ts-log": "^2.2.7",
68
68
  "ws": "^8.18.0"
69
69
  },
70
- "gitHead": "5aababcf9efb72594ab8f5e1083454f2ecab1c43"
70
+ "gitHead": "f61d4dd5465375d8b4addf1bcd3bc1c634fcb5a1"
71
71
  }