@streamflow/staking 7.0.0-alpha.14 → 7.0.0-alpha.15

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.
@@ -277,6 +277,18 @@ class SolanaStakingClient {
277
277
  .instruction();
278
278
  return { ixs: [instruction] };
279
279
  }
280
+ decode(programKey, accountName, accInfo) {
281
+ const decodingProgram = this.programs[programKey];
282
+ (0, common_1.invariant)(decodingProgram, `Decoding program with key ${programKey} is not available`);
283
+ return decodingProgram.coder.accounts.decode(accountName.toString(), accInfo);
284
+ }
285
+ getDiscriminator(programKey, accountName) {
286
+ const decodingProgram = this.programs[programKey];
287
+ (0, common_1.invariant)(decodingProgram, `Decoding program with key ${programKey} is not available`);
288
+ const accountEntity = decodingProgram.idl.accounts.find((acc) => acc.name === accountName);
289
+ (0, common_1.invariant)(accountEntity, `Decoding program with key ${programKey} doesn't specify account with name ${accountName.toString()}`);
290
+ return accountEntity.discriminator;
291
+ }
280
292
  async execute(ixs, extParams) {
281
293
  const { tx, hash, context } = await (0, solana_1.prepareTransaction)(this.connection, ixs, extParams.invoker.publicKey);
282
294
  try {
@@ -1,4 +1,4 @@
1
- import { Program, ProgramAccount } from "@coral-xyz/anchor";
1
+ import { AccountsCoder, Idl, IdlTypes, Program, ProgramAccount } from "@coral-xyz/anchor";
2
2
  import { Commitment, Connection, ConnectionConfig, PublicKey, TransactionInstruction } from "@solana/web3.js";
3
3
  import { ICluster, ITransactionResult } from "@streamflow/common";
4
4
  import PQueue from "p-queue";
@@ -74,6 +74,8 @@ export declare class SolanaStakingClient {
74
74
  prepareCreateRewardEntryInstructions({ stakePoolMint, stakePool, rewardPoolNonce, depositNonce }: CreateRewardEntryArgs, extParams: IInteractSolanaExt): Promise<{
75
75
  ixs: TransactionInstruction[];
76
76
  }>;
77
+ decode<ProgramName extends keyof Programs = keyof Programs, DecodingProgram = Programs[ProgramName], DerivedIdl extends Idl = DecodingProgram extends Program<infer IDLType> ? IDLType : never, AccountName extends keyof IdlTypes<DerivedIdl> = keyof IdlTypes<DerivedIdl>, DecodedAccount = IdlTypes<DerivedIdl>[AccountName]>(programKey: ProgramName, accountName: AccountName, accInfo: Parameters<AccountsCoder["decode"]>[1]): DecodedAccount;
78
+ getDiscriminator<ProgramName extends keyof Programs = keyof Programs, DecodingProgram = Programs[ProgramName], DerivedIdl extends Idl = DecodingProgram extends Program<infer IDLType> ? IDLType : never, AccountName extends keyof IdlTypes<DerivedIdl> = keyof IdlTypes<DerivedIdl>>(programKey: ProgramName, accountName: AccountName): number[];
77
79
  private execute;
78
80
  }
79
81
  export {};
@@ -1,4 +1,4 @@
1
- import { Program, parseIdlErrors, translateError } from "@coral-xyz/anchor";
1
+ import { Program, parseIdlErrors, translateError, } from "@coral-xyz/anchor";
2
2
  import { TOKEN_PROGRAM_ID, getAssociatedTokenAddressSync } from "@solana/spl-token";
3
3
  import { Connection, PublicKey } from "@solana/web3.js";
4
4
  import { ContractError, ICluster, invariant } from "@streamflow/common";
@@ -275,6 +275,18 @@ export class SolanaStakingClient {
275
275
  .instruction();
276
276
  return { ixs: [instruction] };
277
277
  }
278
+ decode(programKey, accountName, accInfo) {
279
+ const decodingProgram = this.programs[programKey];
280
+ invariant(decodingProgram, `Decoding program with key ${programKey} is not available`);
281
+ return decodingProgram.coder.accounts.decode(accountName.toString(), accInfo);
282
+ }
283
+ getDiscriminator(programKey, accountName) {
284
+ const decodingProgram = this.programs[programKey];
285
+ invariant(decodingProgram, `Decoding program with key ${programKey} is not available`);
286
+ const accountEntity = decodingProgram.idl.accounts.find((acc) => acc.name === accountName);
287
+ invariant(accountEntity, `Decoding program with key ${programKey} doesn't specify account with name ${accountName.toString()}`);
288
+ return accountEntity.discriminator;
289
+ }
278
290
  async execute(ixs, extParams) {
279
291
  const { tx, hash, context } = await prepareTransaction(this.connection, ixs, extParams.invoker.publicKey);
280
292
  try {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@streamflow/staking",
3
- "version": "7.0.0-alpha.14",
3
+ "version": "7.0.0-alpha.15",
4
4
  "description": "JavaScript SDK to interact with Streamflow Staking protocol.",
5
5
  "homepage": "https://github.com/streamflow-finance/js-sdk/",
6
6
  "main": "dist/esm/index.js",
@@ -26,9 +26,9 @@
26
26
  "lint": "eslint --fix .",
27
27
  "prepublishOnly": "npm run lint && npm run build"
28
28
  },
29
- "gitHead": "ce9df65df6f69ceac7a2ae4f3404060659ada89b",
29
+ "gitHead": "04676451f16e1bed8f195651eabe4b3558143ee3",
30
30
  "devDependencies": {
31
- "@streamflow/eslint-config": "7.0.0-alpha.14",
31
+ "@streamflow/eslint-config": "7.0.0-alpha.15",
32
32
  "@types/bn.js": "5.1.1",
33
33
  "typescript": "^4.9.5"
34
34
  },
@@ -39,7 +39,7 @@
39
39
  "@solana/spl-token": "0.3.6",
40
40
  "@solana/wallet-adapter-base": "0.9.19",
41
41
  "@solana/web3.js": "1.70.1",
42
- "@streamflow/common": "7.0.0-alpha.14",
42
+ "@streamflow/common": "7.0.0-alpha.15",
43
43
  "bn.js": "5.2.1",
44
44
  "borsh": "^2.0.0",
45
45
  "bs58": "5.0.0",