@streamflow/distributor 11.0.0-alpha.p334.45cbb4e → 11.0.0-alpha.p334.7c3dbf7

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.
@@ -1,8 +1,8 @@
1
1
  import { Keypair, PublicKey, Connection, Commitment, ConnectionConfig, TransactionInstruction } from '@solana/web3.js';
2
2
  import { SignerWalletAdapter } from '@solana/wallet-adapter-base';
3
- import { ITransactionExt, ITransactionResult, PartnerOracleTypes, PartnerOracle, ICluster, ITransactionExtResolved, IProgramAccount, unwrapExecutionParams, signAndExecuteTransaction } from '@streamflow/common';
3
+ import { IdlAccountsOfMethod, ITransactionExt, ITransactionResult, PartnerOracleTypes, IdlArgsOfMethod, IdlInstruction, PartnerOracle, ICluster, ITransactionExtResolved, IProgramAccount, unwrapExecutionParams, signAndExecuteTransaction } from '@streamflow/common';
4
4
  import BN from 'bn.js';
5
- import { Program, IdlTypes, IdlAccounts, Idl } from '@coral-xyz/anchor';
5
+ import { IdlTypes, IdlAccounts, Program } from '@coral-xyz/anchor';
6
6
  import { AlignedDistributor } from './descriptor/aligned_distributor.js';
7
7
  import { MerkleDistributor as MerkleDistributor$1 } from './descriptor/merkle_distributor.js';
8
8
  import PQueue from 'p-queue';
@@ -25,19 +25,14 @@ type CompressedClaimStatus = MerkleDistributorAccountTypes["compressedClaimStatu
25
25
  * @inline
26
26
  */
27
27
  type MerkleDistributor = MerkleDistributorAccountTypes["merkleDistributor"];
28
- type IdlInstruction<IDL extends Idl, Name extends IDL["instructions"][number]["name"]> = Extract<IDL["instructions"][number], {
29
- name: Name;
30
- }>;
31
- type AccountsOfMethod<M extends keyof Program<MerkleDistributor$1>["methods"]> = Parameters<ReturnType<Program<MerkleDistributor$1>["methods"][M]>["accounts"]>[0];
32
- type ArgsOfMethod<M extends keyof Program<MerkleDistributor$1>["methods"]> = Parameters<Program<MerkleDistributor$1>["methods"][M]>;
33
- type NewDistributorAccounts = AccountsOfMethod<"newDistributor">;
34
- type NewDistributorArgs = ArgsOfMethod<"newDistributor">;
35
- type NewClaimAccounts = AccountsOfMethod<"newClaim">;
28
+ type NewDistributorAccounts = IdlAccountsOfMethod<MerkleDistributor$1, "newDistributor">;
29
+ type NewDistributorArgs = IdlArgsOfMethod<MerkleDistributor$1, "newDistributor">;
30
+ type NewClaimAccounts = IdlAccountsOfMethod<MerkleDistributor$1, "newClaim">;
36
31
  type NewClaimArgs = IdlInstruction<MerkleDistributor$1, "newClaim">["args"];
37
- type ClaimLockedV2Accounts = AccountsOfMethod<"claimLockedV2">;
38
- type ClaimLockedAccounts = AccountsOfMethod<"claimLocked">;
39
- type ClawbackAccounts = AccountsOfMethod<"clawback">;
40
- type CloseClaimAccounts = AccountsOfMethod<"closeClaim">;
32
+ type ClaimLockedV2Accounts = IdlAccountsOfMethod<MerkleDistributor$1, "claimLockedV2">;
33
+ type ClaimLockedAccounts = IdlAccountsOfMethod<MerkleDistributor$1, "claimLocked">;
34
+ type ClawbackAccounts = IdlAccountsOfMethod<MerkleDistributor$1, "clawback">;
35
+ type CloseClaimAccounts = IdlAccountsOfMethod<MerkleDistributor$1, "closeClaim">;
41
36
  type CloseClaimArgs = IdlInstruction<MerkleDistributor$1, "closeClaim">["args"];
42
37
  /**
43
38
  * @type
@@ -322,7 +317,7 @@ declare abstract class BaseDistributorClient {
322
317
  protected apiUrl: string;
323
318
  protected apiKey?: string;
324
319
  constructor({ clusterUrl, cluster, commitment, programId, sendRate, sendThrottler, apiUrl, apiKey, }: IInitOptions);
325
- protected abstract getNewDistributorInstruction(data: ICreateDistributorData | ICreateAlignedDistributorData, accounts: NewDistributorAccounts): Promise<TransactionInstruction>;
320
+ protected abstract getNewDistributorInstruction(data: ICreateDistributorData | ICreateAlignedDistributorData, accounts: Required<NewDistributorAccounts>): Promise<TransactionInstruction>;
326
321
  protected abstract getClawbackInstruction(account: ClawbackAccounts): Promise<TransactionInstruction>;
327
322
  getConnection(): Connection;
328
323
  getCommitment(): Commitment | undefined;
@@ -379,7 +374,7 @@ declare abstract class BaseDistributorClient {
379
374
  }
380
375
 
381
376
  declare class SolanaDistributorClient extends BaseDistributorClient {
382
- protected getNewDistributorInstruction(data: ICreateDistributorData, accounts: NewDistributorAccounts): Promise<TransactionInstruction>;
377
+ protected getNewDistributorInstruction(data: ICreateDistributorData, accounts: Required<NewDistributorAccounts>): Promise<TransactionInstruction>;
383
378
  protected getClawbackInstruction(accounts: ClawbackAccounts): Promise<TransactionInstruction>;
384
379
  }
385
380
 
@@ -389,7 +384,7 @@ declare class SolanaAlignedDistributorClient extends BaseDistributorClient {
389
384
  getAlignedDistributorProgramId(): PublicKey;
390
385
  getAlignedDistributorAddress(distributorAddress: string): PublicKey;
391
386
  getAlignedDistributorData(distributorAddress: string): Promise<AlignedDistributorData>;
392
- protected getNewDistributorInstruction(data: ICreateAlignedDistributorData, accounts: NewDistributorAccounts): Promise<TransactionInstruction>;
387
+ protected getNewDistributorInstruction(data: ICreateAlignedDistributorData, accounts: Required<NewDistributorAccounts>): Promise<TransactionInstruction>;
393
388
  protected getClawbackInstruction(accounts: ClawbackAccounts): Promise<TransactionInstruction>;
394
389
  protected getNewAlignedDistributorArgs(data: ICreateAlignedDistributorData): NewAlignedDistributorArgs;
395
390
  }
@@ -1,9 +1,9 @@
1
1
  import { PublicKey, Connection, SystemProgram } from '@solana/web3.js';
2
2
  import BN from 'bn.js';
3
3
  import '@solana/wallet-adapter-base';
4
- import { ICluster, multiplyBigIntByNumber, fetchTokenPrice, signAndExecuteTransaction, ContractError, divCeilN, invariant, getNumberFromBN, pk, getBN, buildPartnerOracle, buildSendThrottler, prepareBaseInstructions, getMintAndProgram, ata, prepareWrappedAccount, createAndEstimateTransaction, prepareTransaction, checkOrCreateAtaBatch, unwrapExecutionParams } from '@streamflow/common';
5
4
  import { parseIdlErrors, translateError, Program } from '@coral-xyz/anchor';
6
5
  import { NATIVE_MINT, getAssociatedTokenAddressSync, getTransferFeeConfig, createTransferCheckedWithFeeInstruction, createTransferCheckedInstruction } from '@solana/spl-token';
6
+ import { ICluster, multiplyBigIntByNumber, fetchTokenPrice, signAndExecuteTransaction, ContractError, divCeilN, invariant, getNumberFromBN, pk, getBN, buildPartnerOracle, buildSendThrottler, prepareBaseInstructions, getMintAndProgram, ata, prepareWrappedAccount, createAndEstimateTransaction, prepareTransaction, checkOrCreateAtaBatch, unwrapExecutionParams } from '@streamflow/common';
7
7
  import { Buffer as Buffer$1 } from 'buffer';
8
8
 
9
9
  var __defProp = Object.defineProperty;
@@ -4768,7 +4768,13 @@ var BaseDistributorClient = class {
4768
4768
  async getFees(pubkey) {
4769
4769
  const feeConfig = await this.getFeeConfig();
4770
4770
  const nowTs = new BN(Math.trunc(Date.now() / 1e3));
4771
- return feeConfig.partners.filter((partner) => partner.pubkey.equals(pubkey) && partner.expiryTs.gt(nowTs))[0] ?? null;
4771
+ const filteredPartners = feeConfig.partners.filter(
4772
+ (partner) => partner.pubkey.equals(pubkey) && (partner.expiryTs.eqn(0) || partner.expiryTs.gt(nowTs))
4773
+ );
4774
+ if (filteredPartners.length > 1) {
4775
+ throw new Error("More than one partner found, fees fetching is not possible.");
4776
+ }
4777
+ return filteredPartners[0] ?? null;
4772
4778
  }
4773
4779
  prepareClaimFeeInstruction(payer, fee = AIRDROP_CLAIM_FEE) {
4774
4780
  return SystemProgram.transfer({