@exponent-labs/pyth-idl 0.0.10

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.
@@ -0,0 +1,32 @@
1
+ /// <reference types="bn.js" />
2
+ /// <reference types="node" />
3
+ /// <reference types="node" />
4
+ import { IdlAccounts, web3 } from "@coral-xyz/anchor";
5
+ import { PythSolanaReceiver as PythSolanaReceiverProgram } from "./pyth_solana_receiver";
6
+ export type PriceUpdateAccount = IdlAccounts<PythSolanaReceiverProgram>["priceUpdateV2"];
7
+ export declare const decodePriceUpdateAccount: (connection: web3.Connection, accountPubkey: web3.PublicKey) => Promise<{
8
+ writeAuthority: web3.PublicKey;
9
+ verificationLevel: ({
10
+ full?: never;
11
+ } & {
12
+ partial: {
13
+ numSignatures: number;
14
+ };
15
+ }) | ({
16
+ partial?: never;
17
+ } & {
18
+ full: Record<string, never>;
19
+ });
20
+ priceMessage: {
21
+ feedId: number[];
22
+ price: import("bn.js");
23
+ conf: import("bn.js");
24
+ exponent: number;
25
+ publishTime: import("bn.js");
26
+ prevPublishTime: import("bn.js");
27
+ emaPrice: import("bn.js");
28
+ emaConf: import("bn.js");
29
+ };
30
+ postedSlot: import("bn.js");
31
+ }>;
32
+ export declare const encodePriceUpdateAccount: (connection: web3.Connection, accountInfo: PriceUpdateAccount, accountPubkey: web3.PublicKey) => Promise<web3.AccountInfo<Buffer>>;
package/build/index.js ADDED
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.encodePriceUpdateAccount = exports.decodePriceUpdateAccount = void 0;
4
+ const anchor_1 = require("@coral-xyz/anchor");
5
+ const pyth_solana_receiver_1 = require("./pyth_solana_receiver");
6
+ const decodePriceUpdateAccount = async (connection, accountPubkey) => {
7
+ const account = await connection.getAccountInfo(accountPubkey);
8
+ const coder = new anchor_1.BorshCoder(pyth_solana_receiver_1.IDL);
9
+ return coder.accounts.decode("priceUpdateV2", account.data);
10
+ };
11
+ exports.decodePriceUpdateAccount = decodePriceUpdateAccount;
12
+ const encodePriceUpdateAccount = async (connection, accountInfo, accountPubkey) => {
13
+ let account = await connection.getAccountInfo(accountPubkey);
14
+ const coder = new anchor_1.BorshCoder(pyth_solana_receiver_1.IDL);
15
+ const encodedData = await coder.accounts.encode("priceUpdateV2", account);
16
+ account.data = encodedData;
17
+ return account;
18
+ };
19
+ exports.encodePriceUpdateAccount = encodePriceUpdateAccount;
20
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,8CAAiE;AAEjE,iEAAoG;AAI7F,MAAM,wBAAwB,GAAG,KAAK,EAAE,UAA2B,EAAE,aAA6B,EAAE,EAAE;IAC3G,MAAM,OAAO,GAAG,MAAM,UAAU,CAAC,cAAc,CAAC,aAAa,CAAC,CAAA;IAC9D,MAAM,KAAK,GAAG,IAAI,mBAAU,CAAC,0BAAG,CAAC,CAAA;IACjC,OAAO,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC,eAAe,EAAE,OAAO,CAAC,IAAI,CAAuB,CAAA;AACnF,CAAC,CAAA;AAJY,QAAA,wBAAwB,4BAIpC;AAEM,MAAM,wBAAwB,GAAG,KAAK,EAC3C,UAA2B,EAC3B,WAA+B,EAC/B,aAA6B,EAC7B,EAAE;IACF,IAAI,OAAO,GAAG,MAAM,UAAU,CAAC,cAAc,CAAC,aAAa,CAAC,CAAA;IAE5D,MAAM,KAAK,GAAG,IAAI,mBAAU,CAAC,0BAAG,CAAC,CAAA;IACjC,MAAM,WAAW,GAAG,MAAM,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC,eAAe,EAAE,OAAO,CAAC,CAAA;IAEzE,OAAO,CAAC,IAAI,GAAG,WAAW,CAAA;IAE1B,OAAO,OAAO,CAAA;AAChB,CAAC,CAAA;AAbY,QAAA,wBAAwB,4BAapC"}