@pythnetwork/pyth-solana-receiver 0.7.0 → 0.8.1
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/README.md +4 -4
- package/lib/PythSolanaReceiver.d.ts +3 -3
- package/lib/PythSolanaReceiver.d.ts.map +1 -1
- package/lib/PythSolanaReceiver.js +8 -7
- package/lib/vaa.d.ts +1 -1
- package/lib/vaa.js +1 -1
- package/package.json +6 -6
package/LICENSE
CHANGED
package/README.md
CHANGED
|
@@ -52,7 +52,7 @@ Applications can therefore store the address of a price feed account and read it
|
|
|
52
52
|
Price feed accounts have a fixed address derived from the feed id and a shard id.
|
|
53
53
|
The shard id allows different applications to use different accounts for the same feed, thereby reducing the impact of solana congestion.
|
|
54
54
|
This method of using Pyth prices is a good fit for applications that always want to use the most recent price.
|
|
55
|
-
Additionally, the [Price Scheduler](../../../../../../../price_pusher/) can be used to continuously write fresh updates to a price feed account, freeing applications from worrying about writing their own updates.
|
|
55
|
+
Additionally, the [Price Scheduler](../../../../../../../apps/price_pusher/) can be used to continuously write fresh updates to a price feed account, freeing applications from worrying about writing their own updates.
|
|
56
56
|
|
|
57
57
|
This SDK provides methods for working with both types of accounts.
|
|
58
58
|
|
|
@@ -177,9 +177,9 @@ You can run these examples by performing the following steps.
|
|
|
177
177
|
First, install and build any necessary typescript dependencies:
|
|
178
178
|
|
|
179
179
|
1. Clone the `pyth-crosschain` git repo
|
|
180
|
-
2. Run `
|
|
181
|
-
3. Run `
|
|
182
|
-
4. From the `pyth_solana_receiver` directory, run `
|
|
180
|
+
2. Run `pnpm i` in the root of the repo
|
|
181
|
+
3. Run `pnpm exec lerna run build` anywhere in the repo
|
|
182
|
+
4. From the `pyth_solana_receiver` directory, run `pnpm exec ts-node examples/<example filename>.ts`
|
|
183
183
|
|
|
184
184
|
The examples require a Solana keypair with SOL to send Solana transactions.
|
|
185
185
|
By default, the examples will use the same Solana keypair used by the Solana CLI (at `~/.config/solana/id.json`).
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import { AnchorProvider, IdlAccounts, Program } from "@coral-xyz/anchor";
|
|
3
|
-
import { Connection, Signer, Transaction, VersionedTransaction } from "@solana/web3.js";
|
|
3
|
+
import { AddressLookupTableAccount, Connection, Signer, Transaction, VersionedTransaction } from "@solana/web3.js";
|
|
4
4
|
import { PythSolanaReceiver as PythSolanaReceiverProgram } from "./idl/pyth_solana_receiver";
|
|
5
5
|
import { WormholeCoreBridgeSolana } from "./idl/wormhole_core_bridge_solana";
|
|
6
6
|
import { PublicKey } from "@solana/web3.js";
|
|
@@ -50,7 +50,7 @@ export declare class PythTransactionBuilder extends TransactionBuilder {
|
|
|
50
50
|
readonly closeInstructions: InstructionWithEphemeralSigners[];
|
|
51
51
|
readonly priceFeedIdToPriceUpdateAccount: Record<string, PublicKey>;
|
|
52
52
|
readonly closeUpdateAccounts: boolean;
|
|
53
|
-
constructor(pythSolanaReceiver: PythSolanaReceiver, config: PythTransactionBuilderConfig);
|
|
53
|
+
constructor(pythSolanaReceiver: PythSolanaReceiver, config: PythTransactionBuilderConfig, addressLookupTable?: AddressLookupTableAccount);
|
|
54
54
|
/**
|
|
55
55
|
* Add instructions to post price updates to the builder.
|
|
56
56
|
* Use this function to post fully verified price updates from the present or from the past for your program to consume.
|
|
@@ -271,7 +271,7 @@ export declare class PythSolanaReceiver {
|
|
|
271
271
|
/**
|
|
272
272
|
* Returns a set of versioned transactions that contain the provided instructions in the same order and with efficient batching
|
|
273
273
|
*/
|
|
274
|
-
batchIntoVersionedTransactions(instructions: InstructionWithEphemeralSigners[], priorityFeeConfig: PriorityFeeConfig): Promise<{
|
|
274
|
+
batchIntoVersionedTransactions(instructions: InstructionWithEphemeralSigners[], priorityFeeConfig: PriorityFeeConfig, addressLookupTable?: AddressLookupTableAccount): Promise<{
|
|
275
275
|
tx: VersionedTransaction;
|
|
276
276
|
signers: Signer[];
|
|
277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C;IA2DF;;OAEG;IACG,+BAA+B,CACnC,UAAU,EAAE,SAAS,GACpB,OAAO,CAAC,+BAA+B,CAAC;IAY3C;;OAEG;IACG,yCAAyC,CAC7C,eAAe,EAAE,MAAM,GACtB,OAAO,CAAC,+BAA+B,EAAE,CAAC;IAS7C;;OAEG;IACG,gCAAgC,CACpC,kBAAkB,EAAE,SAAS,GAC5B,OAAO,CAAC,+BAA+B,CAAC;IAQ3C;;OAEG;IACG,8BAA8B,CAClC,YAAY,EAAE,+BAA+B,EAAE,EAC/C,iBAAiB,EAAE,iBAAiB,EACpC,kBAAkB,CAAC,EAAE,yBAAyB,GAC7C,OAAO,CAAC;QAAE,EAAE,EAAE,oBAAoB,CAAC;QAAC,OAAO,EAAE,MAAM,EAAE,CAAA;KAAE,EAAE,CAAC;IAU7D;;;;OAIG;IACG,uBAAuB,CAC3B,kBAAkB,EAAE,SAAS,GAC5B,OAAO,CAAC,kBAAkB,GAAG,IAAI,CAAC;IAMrC;;;;;OAKG;IACG,qBAAqB,CACzB,OAAO,EAAE,MAAM,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"}
|
|
@@ -46,8 +46,8 @@ class PythTransactionBuilder extends solana_utils_1.TransactionBuilder {
|
|
|
46
46
|
closeInstructions;
|
|
47
47
|
priceFeedIdToPriceUpdateAccount;
|
|
48
48
|
closeUpdateAccounts;
|
|
49
|
-
constructor(pythSolanaReceiver, config) {
|
|
50
|
-
super(pythSolanaReceiver.wallet.publicKey, pythSolanaReceiver.connection);
|
|
49
|
+
constructor(pythSolanaReceiver, config, addressLookupTable) {
|
|
50
|
+
super(pythSolanaReceiver.wallet.publicKey, pythSolanaReceiver.connection, addressLookupTable);
|
|
51
51
|
this.pythSolanaReceiver = pythSolanaReceiver;
|
|
52
52
|
this.closeInstructions = [];
|
|
53
53
|
this.priceFeedIdToPriceUpdateAccount = {};
|
|
@@ -295,11 +295,12 @@ class PythSolanaReceiver {
|
|
|
295
295
|
* @returns `closeInstructions`: the instructions to close the encoded VAA account
|
|
296
296
|
*/
|
|
297
297
|
async buildPostEncodedVaaInstructions(vaa) {
|
|
298
|
+
const trimmedVaa = (0, vaa_1.trimSignatures)(vaa, 13);
|
|
298
299
|
const postInstructions = [];
|
|
299
300
|
const closeInstructions = [];
|
|
300
301
|
const encodedVaaKeypair = new web3_js_1.Keypair();
|
|
301
|
-
const guardianSetIndex = (0, vaa_1.getGuardianSetIndex)(
|
|
302
|
-
postInstructions.push(await (0, vaa_1.buildEncodedVaaCreateInstruction)(this.wormhole,
|
|
302
|
+
const guardianSetIndex = (0, vaa_1.getGuardianSetIndex)(trimmedVaa);
|
|
303
|
+
postInstructions.push(await (0, vaa_1.buildEncodedVaaCreateInstruction)(this.wormhole, trimmedVaa, encodedVaaKeypair));
|
|
303
304
|
postInstructions.push({
|
|
304
305
|
instruction: await this.wormhole.methods
|
|
305
306
|
.initEncodedVaa()
|
|
@@ -310,7 +311,7 @@ class PythSolanaReceiver {
|
|
|
310
311
|
signers: [],
|
|
311
312
|
computeUnits: compute_budget_1.INIT_ENCODED_VAA_COMPUTE_BUDGET,
|
|
312
313
|
});
|
|
313
|
-
postInstructions.push(...(await (0, vaa_1.buildWriteEncodedVaaWithSplitInstructions)(this.wormhole,
|
|
314
|
+
postInstructions.push(...(await (0, vaa_1.buildWriteEncodedVaaWithSplitInstructions)(this.wormhole, trimmedVaa, encodedVaaKeypair.publicKey)));
|
|
314
315
|
postInstructions.push({
|
|
315
316
|
instruction: await this.wormhole.methods
|
|
316
317
|
.verifyEncodedVaaV1()
|
|
@@ -460,8 +461,8 @@ class PythSolanaReceiver {
|
|
|
460
461
|
/**
|
|
461
462
|
* Returns a set of versioned transactions that contain the provided instructions in the same order and with efficient batching
|
|
462
463
|
*/
|
|
463
|
-
async batchIntoVersionedTransactions(instructions, priorityFeeConfig) {
|
|
464
|
-
return solana_utils_1.TransactionBuilder.batchIntoVersionedTransactions(this.wallet.publicKey, this.connection, instructions, priorityFeeConfig);
|
|
464
|
+
async batchIntoVersionedTransactions(instructions, priorityFeeConfig, addressLookupTable) {
|
|
465
|
+
return solana_utils_1.TransactionBuilder.batchIntoVersionedTransactions(this.wallet.publicKey, this.connection, instructions, priorityFeeConfig, addressLookupTable);
|
|
465
466
|
}
|
|
466
467
|
/**
|
|
467
468
|
* Fetch the contents of a price update account
|
package/lib/vaa.d.ts
CHANGED
|
@@ -38,7 +38,7 @@ export declare const VAA_START = 46;
|
|
|
38
38
|
*/
|
|
39
39
|
export declare function buildEncodedVaaCreateInstruction(wormhole: Program<WormholeCoreBridgeSolana>, vaa: Buffer, encodedVaaKeypair: Keypair): Promise<InstructionWithEphemeralSigners>;
|
|
40
40
|
/**
|
|
41
|
-
* Writing the VAA to
|
|
41
|
+
* Writing the VAA to an encoded VAA account is done in 2 instructions.
|
|
42
42
|
*
|
|
43
43
|
* The first one writes the first `VAA_SPLIT_INDEX` bytes and the second one writes the rest.
|
|
44
44
|
*
|
package/lib/vaa.js
CHANGED
|
@@ -62,7 +62,7 @@ async function buildEncodedVaaCreateInstruction(wormhole, vaa, encodedVaaKeypair
|
|
|
62
62
|
}
|
|
63
63
|
exports.buildEncodedVaaCreateInstruction = buildEncodedVaaCreateInstruction;
|
|
64
64
|
/**
|
|
65
|
-
* Writing the VAA to
|
|
65
|
+
* Writing the VAA to an encoded VAA account is done in 2 instructions.
|
|
66
66
|
*
|
|
67
67
|
* The first one writes the first `VAA_SPLIT_INDEX` bytes and the second one writes the rest.
|
|
68
68
|
*
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pythnetwork/pyth-solana-receiver",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.1",
|
|
4
4
|
"description": "Pyth solana receiver SDK",
|
|
5
5
|
"homepage": "https://pyth.network",
|
|
6
6
|
"main": "lib/index.js",
|
|
@@ -21,9 +21,9 @@
|
|
|
21
21
|
"format": "prettier --write \"src/**/*.ts\"",
|
|
22
22
|
"lint": "eslint src/",
|
|
23
23
|
"test": "jest src/ --passWithNoTests",
|
|
24
|
-
"prepublishOnly": "
|
|
25
|
-
"preversion": "
|
|
26
|
-
"version": "
|
|
24
|
+
"prepublishOnly": "pnpm run build && pnpm test && pnpm run lint",
|
|
25
|
+
"preversion": "pnpm run lint",
|
|
26
|
+
"version": "pnpm run format && git add -A src"
|
|
27
27
|
},
|
|
28
28
|
"keywords": [
|
|
29
29
|
"pyth",
|
|
@@ -45,8 +45,8 @@
|
|
|
45
45
|
"@coral-xyz/anchor": "^0.29.0",
|
|
46
46
|
"@noble/hashes": "^1.4.0",
|
|
47
47
|
"@pythnetwork/price-service-sdk": ">=1.6.0",
|
|
48
|
-
"@pythnetwork/solana-utils": "
|
|
48
|
+
"@pythnetwork/solana-utils": "0.4.2",
|
|
49
49
|
"@solana/web3.js": "^1.90.0"
|
|
50
50
|
},
|
|
51
|
-
"gitHead": "
|
|
51
|
+
"gitHead": "b089c8a82c3898e86777bce190996173c0273592"
|
|
52
52
|
}
|