@pythnetwork/pyth-solana-receiver 0.9.0 → 0.10.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.
- package/LICENSE +1 -1
- package/lib/PythSolanaReceiver.d.ts +9 -2
- package/lib/PythSolanaReceiver.d.ts.map +1 -1
- package/lib/PythSolanaReceiver.js +18 -8
- package/lib/vaa.d.ts +3 -2
- package/lib/vaa.d.ts.map +1 -1
- package/lib/vaa.js +3 -2
- package/package.json +4 -4
package/LICENSE
CHANGED
|
@@ -16,6 +16,11 @@ export type TwapUpdateAccount = IdlAccounts<PythSolanaReceiverProgram>["twapUpda
|
|
|
16
16
|
export type PythTransactionBuilderConfig = {
|
|
17
17
|
closeUpdateAccounts?: boolean;
|
|
18
18
|
};
|
|
19
|
+
/**
|
|
20
|
+
* A stable treasury ID. This ID's corresponding treasury address
|
|
21
|
+
* can be cached in an account lookup table in order to reduce the overall txn size.
|
|
22
|
+
*/
|
|
23
|
+
export declare const DEFAULT_TREASURY_ID = 0;
|
|
19
24
|
/**
|
|
20
25
|
* A builder class to build transactions that:
|
|
21
26
|
* - Post price updates (fully or partially verified) or update price feed accounts
|
|
@@ -248,17 +253,19 @@ export declare class PythSolanaReceiver {
|
|
|
248
253
|
readonly receiver: Program<PythSolanaReceiverProgram>;
|
|
249
254
|
readonly wormhole: Program<WormholeCoreBridgeSolana>;
|
|
250
255
|
readonly pushOracle: Program<PythPushOracle>;
|
|
251
|
-
|
|
256
|
+
readonly treasuryId?: number;
|
|
257
|
+
constructor({ connection, wallet, wormholeProgramId, receiverProgramId, pushOracleProgramId, treasuryId, }: {
|
|
252
258
|
connection: Connection;
|
|
253
259
|
wallet: Wallet;
|
|
254
260
|
wormholeProgramId?: PublicKey;
|
|
255
261
|
receiverProgramId?: PublicKey;
|
|
256
262
|
pushOracleProgramId?: PublicKey;
|
|
263
|
+
treasuryId?: number;
|
|
257
264
|
});
|
|
258
265
|
/**
|
|
259
266
|
* Get a new transaction builder to build transactions that interact with the Pyth Solana Receiver program and consume price updates
|
|
260
267
|
*/
|
|
261
|
-
newTransactionBuilder(config: PythTransactionBuilderConfig): PythTransactionBuilder;
|
|
268
|
+
newTransactionBuilder(config: PythTransactionBuilderConfig, addressLookupAccount?: AddressLookupTableAccount): PythTransactionBuilder;
|
|
262
269
|
/**
|
|
263
270
|
* Build a series of helper instructions that post price updates to the Pyth Solana Receiver program and another series to close the price update accounts.
|
|
264
271
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PythSolanaReceiver.d.ts","sourceRoot":"","sources":["../src/PythSolanaReceiver.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AACzE,OAAO,EACL,yBAAyB,EACzB,UAAU,EACV,MAAM,EACN,WAAW,EACX,oBAAoB,EACrB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,kBAAkB,IAAI,yBAAyB,EAEhD,MAAM,4BAA4B,CAAC;AACpC,OAAO,EACL,wBAAwB,EAEzB,MAAM,mCAAmC,CAAC;AAU3C,OAAO,EAAE,SAAS,EAAW,MAAM,iBAAiB,CAAC;AAYrD,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAS3C,OAAO,EACL,kBAAkB,EAClB,+BAA+B,EAC/B,iBAAiB,EAClB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EACL,cAAc,EAEf,MAAM,wBAAwB,CAAC;AAEhC,MAAM,MAAM,kBAAkB,GAC5B,WAAW,CAAC,yBAAyB,CAAC,CAAC,eAAe,CAAC,CAAC;AAC1D,MAAM,MAAM,iBAAiB,GAC3B,WAAW,CAAC,yBAAyB,CAAC,CAAC,YAAY,CAAC,CAAC;AACvD;;;GAGG;AACH,MAAM,MAAM,4BAA4B,GAAG;IACzC,mBAAmB,CAAC,EAAE,OAAO,CAAC;CAC/B,CAAC;AAEF;;;;;;;;;;;;;;;;;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EACf,WAAW,EAAE,MAAM,GAAG,MAAM,GAC3B,OAAO,CAAC,kBAAkB,GAAG,IAAI,CAAC;IAMrC;;;;;OAKG;IACH,0BAA0B,CACxB,OAAO,EAAE,MAAM,EACf,WAAW,EAAE,MAAM,GAAG,MAAM,GAC3B,SAAS;IAQZ;;;OAGG;IACG,2BAA2B;CAOlC;AAED;;;;;;GAMG;AACH,wBAAgB,6BAA6B,CAC3C,OAAO,EAAE,MAAM,EACf,WAAW,EAAE,MAAM,GAAG,MAAM,EAC5B,mBAAmB,CAAC,EAAE,SAAS,GAC9B,SAAS,CAmBX"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getPriceFeedAccountForProgram = exports.PythSolanaReceiver = exports.PythTransactionBuilder = void 0;
|
|
3
|
+
exports.getPriceFeedAccountForProgram = exports.PythSolanaReceiver = exports.PythTransactionBuilder = exports.DEFAULT_TREASURY_ID = void 0;
|
|
4
4
|
const anchor_1 = require("@coral-xyz/anchor");
|
|
5
5
|
const pyth_solana_receiver_1 = require("./idl/pyth_solana_receiver");
|
|
6
6
|
const wormhole_core_bridge_solana_1 = require("./idl/wormhole_core_bridge_solana");
|
|
@@ -11,6 +11,11 @@ const compute_budget_1 = require("./compute_budget");
|
|
|
11
11
|
const vaa_1 = require("./vaa");
|
|
12
12
|
const solana_utils_1 = require("@pythnetwork/solana-utils");
|
|
13
13
|
const pyth_push_oracle_1 = require("./idl/pyth_push_oracle");
|
|
14
|
+
/**
|
|
15
|
+
* A stable treasury ID. This ID's corresponding treasury address
|
|
16
|
+
* can be cached in an account lookup table in order to reduce the overall txn size.
|
|
17
|
+
*/
|
|
18
|
+
exports.DEFAULT_TREASURY_ID = 0;
|
|
14
19
|
/**
|
|
15
20
|
* A builder class to build transactions that:
|
|
16
21
|
* - Post price updates (fully or partially verified) or update price feed accounts
|
|
@@ -293,7 +298,11 @@ class PythSolanaReceiver {
|
|
|
293
298
|
receiver;
|
|
294
299
|
wormhole;
|
|
295
300
|
pushOracle;
|
|
296
|
-
|
|
301
|
+
treasuryId;
|
|
302
|
+
constructor({ connection, wallet, wormholeProgramId = address_1.DEFAULT_WORMHOLE_PROGRAM_ID, receiverProgramId = address_1.DEFAULT_RECEIVER_PROGRAM_ID, pushOracleProgramId = address_1.DEFAULT_PUSH_ORACLE_PROGRAM_ID, treasuryId = undefined, }) {
|
|
303
|
+
if (treasuryId !== undefined && (treasuryId < 0 || treasuryId > 255)) {
|
|
304
|
+
throw new Error("treasuryId must be between 0 and 255");
|
|
305
|
+
}
|
|
297
306
|
this.connection = connection;
|
|
298
307
|
this.wallet = wallet;
|
|
299
308
|
this.provider = new anchor_1.AnchorProvider(this.connection, this.wallet, {
|
|
@@ -302,12 +311,13 @@ class PythSolanaReceiver {
|
|
|
302
311
|
this.receiver = new anchor_1.Program(pyth_solana_receiver_1.IDL, receiverProgramId, this.provider);
|
|
303
312
|
this.wormhole = new anchor_1.Program(wormhole_core_bridge_solana_1.IDL, wormholeProgramId, this.provider);
|
|
304
313
|
this.pushOracle = new anchor_1.Program(pyth_push_oracle_1.IDL, pushOracleProgramId, this.provider);
|
|
314
|
+
this.treasuryId = treasuryId;
|
|
305
315
|
}
|
|
306
316
|
/**
|
|
307
317
|
* Get a new transaction builder to build transactions that interact with the Pyth Solana Receiver program and consume price updates
|
|
308
318
|
*/
|
|
309
|
-
newTransactionBuilder(config) {
|
|
310
|
-
return new PythTransactionBuilder(this, config);
|
|
319
|
+
newTransactionBuilder(config, addressLookupAccount) {
|
|
320
|
+
return new PythTransactionBuilder(this, config, addressLookupAccount);
|
|
311
321
|
}
|
|
312
322
|
/**
|
|
313
323
|
* Build a series of helper instructions that post price updates to the Pyth Solana Receiver program and another series to close the price update accounts.
|
|
@@ -324,7 +334,7 @@ class PythSolanaReceiver {
|
|
|
324
334
|
const postInstructions = [];
|
|
325
335
|
const priceFeedIdToPriceUpdateAccount = {};
|
|
326
336
|
const closeInstructions = [];
|
|
327
|
-
const treasuryId = (0, address_1.getRandomTreasuryId)();
|
|
337
|
+
const treasuryId = this.treasuryId ?? (0, address_1.getRandomTreasuryId)();
|
|
328
338
|
for (const priceUpdateData of priceUpdateDataArray) {
|
|
329
339
|
const accumulatorUpdateData = (0, price_service_sdk_1.parseAccumulatorUpdateData)(Buffer.from(priceUpdateData, "base64"));
|
|
330
340
|
const guardianSetIndex = (0, vaa_1.getGuardianSetIndex)(accumulatorUpdateData.vaa);
|
|
@@ -370,7 +380,7 @@ class PythSolanaReceiver {
|
|
|
370
380
|
const postInstructions = [];
|
|
371
381
|
const priceFeedIdToPriceUpdateAccount = {};
|
|
372
382
|
const closeInstructions = [];
|
|
373
|
-
const treasuryId = (0, address_1.getRandomTreasuryId)();
|
|
383
|
+
const treasuryId = this.treasuryId ?? (0, address_1.getRandomTreasuryId)();
|
|
374
384
|
for (const priceUpdateData of priceUpdateDataArray) {
|
|
375
385
|
const accumulatorUpdateData = (0, price_service_sdk_1.parseAccumulatorUpdateData)(Buffer.from(priceUpdateData, "base64"));
|
|
376
386
|
const { postInstructions: postEncodedVaaInstructions, encodedVaaAddress: encodedVaa, closeInstructions: postEncodedVaacloseInstructions, } = await this.buildPostEncodedVaaInstructions(accumulatorUpdateData.vaa);
|
|
@@ -416,7 +426,7 @@ class PythSolanaReceiver {
|
|
|
416
426
|
const postInstructions = [];
|
|
417
427
|
const priceFeedIdToTwapUpdateAccount = {};
|
|
418
428
|
const closeInstructions = [];
|
|
419
|
-
const treasuryId = (0, address_1.getRandomTreasuryId)();
|
|
429
|
+
const treasuryId = this.treasuryId ?? (0, address_1.getRandomTreasuryId)();
|
|
420
430
|
if (twapUpdateDataArray.length !== 2) {
|
|
421
431
|
throw new Error("twapUpdateDataArray must contain exactly two updates (start and end)");
|
|
422
432
|
}
|
|
@@ -474,7 +484,7 @@ class PythSolanaReceiver {
|
|
|
474
484
|
const postInstructions = [];
|
|
475
485
|
const priceFeedIdToPriceUpdateAccount = {};
|
|
476
486
|
const closeInstructions = [];
|
|
477
|
-
const treasuryId = (0, address_1.getRandomTreasuryId)();
|
|
487
|
+
const treasuryId = this.treasuryId ?? (0, address_1.getRandomTreasuryId)();
|
|
478
488
|
for (const priceUpdateData of priceUpdateDataArray) {
|
|
479
489
|
const accumulatorUpdateData = (0, price_service_sdk_1.parseAccumulatorUpdateData)(Buffer.from(priceUpdateData, "base64"));
|
|
480
490
|
const { postInstructions: postEncodedVaaInstructions, encodedVaaAddress: encodedVaa, closeInstructions: postEncodedVaacloseInstructions, } = await this.buildPostEncodedVaaInstructions(accumulatorUpdateData.vaa);
|
package/lib/vaa.d.ts
CHANGED
|
@@ -28,10 +28,11 @@ export declare const VAA_START = 46;
|
|
|
28
28
|
*
|
|
29
29
|
* The first one writes the first `VAA_SPLIT_INDEX` bytes and the second one writes the rest.
|
|
30
30
|
*
|
|
31
|
-
* This number was chosen as the biggest number such that one can still call `createInstruction`,
|
|
31
|
+
* This number was chosen as the biggest number such that one can still call `createInstruction`,
|
|
32
|
+
* `initEncodedVaa` and `writeEncodedVaa` in a single Solana transaction, while using an address lookup table.
|
|
32
33
|
* This way, the packing of the instructions to post an encoded vaa is more efficient.
|
|
33
34
|
*/
|
|
34
|
-
export declare const VAA_SPLIT_INDEX =
|
|
35
|
+
export declare const VAA_SPLIT_INDEX = 721;
|
|
35
36
|
/**
|
|
36
37
|
* Trim the number of signatures of a VAA.
|
|
37
38
|
*
|
package/lib/vaa.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vaa.d.ts","sourceRoot":"","sources":["../src/vaa.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACjE,OAAO,EAAE,wBAAwB,EAAE,MAAM,mCAAmC,CAAC;AAC7E,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAC5C,OAAO,EAAE,+BAA+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gB,EAAE,+BAA+B,EAAE,CAAC;IACpD,iBAAiB,EAAE,+BAA+B,EAAE,CAAC;CACtD,CAAC,CAeD;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAsB,uCAAuC,CAC3D,QAAQ,EAAE,OAAO,CAAC,wBAAwB,CAAC,EAC3C,eAAe,EAAE,qBAAqB,EACtC,aAAa,EAAE,qBAAqB,GACnC,OAAO,CAAC;IACT,sBAAsB,EAAE,SAAS,CAAC;IAClC,oBAAoB,EAAE,SAAS,CAAC;IAChC,gBAAgB,EAAE,+BAA+B,EAAE,CAAC;IACpD,iBAAiB,EAAE,+BAA+B,EAAE,CAAC;CACtD,CAAC,CAmCD;AAED;;GAEG;AACH,wBAAsB,+BAA+B,CACnD,QAAQ,EAAE,OAAO,CAAC,wBAAwB,CAAC,EAC3C,UAAU,EAAE,SAAS,GACpB,OAAO,CAAC,+BAA+B,CAAC,CAU1C;AAED;;;;GAIG;AACH,wBAAsB,gCAAgC,CACpD,QAAQ,EAAE,OAAO,CAAC,wBAAwB,CAAC,EAC3C,GAAG,EAAE,MAAM,EACX,iBAAiB,EAAE,OAAO,GACzB,OAAO,CAAC,+BAA+B,CAAC,CAS1C;AAED;;;GAGG;AACH,wBAAsB,sCAAsC,CAC1D,UAAU,EAAE,UAAU,EACtB,cAAc,EAAE,SAAS,EACzB,iBAAiB,EAAE,SAAS,GAC3B,OAAO,CAAC,SAAS,EAAE,CAAC,CAoBtB"}
|
package/lib/vaa.js
CHANGED
|
@@ -33,10 +33,11 @@ exports.VAA_START = 46;
|
|
|
33
33
|
*
|
|
34
34
|
* The first one writes the first `VAA_SPLIT_INDEX` bytes and the second one writes the rest.
|
|
35
35
|
*
|
|
36
|
-
* This number was chosen as the biggest number such that one can still call `createInstruction`,
|
|
36
|
+
* This number was chosen as the biggest number such that one can still call `createInstruction`,
|
|
37
|
+
* `initEncodedVaa` and `writeEncodedVaa` in a single Solana transaction, while using an address lookup table.
|
|
37
38
|
* This way, the packing of the instructions to post an encoded vaa is more efficient.
|
|
38
39
|
*/
|
|
39
|
-
exports.VAA_SPLIT_INDEX =
|
|
40
|
+
exports.VAA_SPLIT_INDEX = 721;
|
|
40
41
|
/**
|
|
41
42
|
* Trim the number of signatures of a VAA.
|
|
42
43
|
*
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pythnetwork/pyth-solana-receiver",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.10.0",
|
|
4
4
|
"description": "Pyth solana receiver SDK",
|
|
5
5
|
"homepage": "https://pyth.network",
|
|
6
6
|
"main": "lib/index.js",
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
],
|
|
31
31
|
"license": "Apache-2.0",
|
|
32
32
|
"devDependencies": {
|
|
33
|
-
"@pythnetwork/hermes-client": "
|
|
33
|
+
"@pythnetwork/hermes-client": "2.0.0",
|
|
34
34
|
"@types/jest": "^29.4.0",
|
|
35
35
|
"@typescript-eslint/eslint-plugin": "^5.20.0",
|
|
36
36
|
"@typescript-eslint/parser": "^5.20.0",
|
|
@@ -46,8 +46,8 @@
|
|
|
46
46
|
"@coral-xyz/anchor": "^0.29.0",
|
|
47
47
|
"@noble/hashes": "^1.4.0",
|
|
48
48
|
"@pythnetwork/price-service-sdk": "1.8.0",
|
|
49
|
-
"@pythnetwork/solana-utils": "0.4.
|
|
49
|
+
"@pythnetwork/solana-utils": "0.4.4",
|
|
50
50
|
"@solana/web3.js": "^1.90.0"
|
|
51
51
|
},
|
|
52
|
-
"gitHead": "
|
|
52
|
+
"gitHead": "4bd2adacc4d30b0899492026c7071d5d5007bb3b"
|
|
53
53
|
}
|