@streamflow/distributor 8.0.0 → 8.0.1-alpha.p287.54fe41f

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,13 +1,17 @@
1
- import { Keypair, PublicKey, TransactionInstruction, Connection, Commitment, ConnectionConfig, Transaction, VersionedTransaction } from '@solana/web3.js';
1
+ import { Keypair, PublicKey, TransactionInstruction, Connection, Commitment, ConnectionConfig } from '@solana/web3.js';
2
2
  import { SignerWalletAdapter } from '@solana/wallet-adapter-base';
3
3
  import { ITransactionResult, ICluster } from '@streamflow/common';
4
- import { ITransactionSolanaExt, IProgramAccount, ConfirmationParams, ThrottleParams } from '@streamflow/common/solana';
4
+ import { ITransactionSolanaExt, ITransactionSolanaExtResolved, IProgramAccount, unwrapExecutionParams, signAndExecuteTransaction } from '@streamflow/common/solana';
5
5
  import BN from 'bn.js';
6
6
  import { IdlTypes, Program } from '@coral-xyz/anchor';
7
7
  import { AlignedDistributor } from './descriptor/aligned_distributor.cjs';
8
+ import { MerkleDistributor as MerkleDistributor$1 } from './descriptor/merkle_distributor.cjs';
8
9
  import PQueue from 'p-queue';
9
10
  import { TransferFeeConfig } from '@solana/spl-token';
10
11
 
12
+ type MerkleDistributorAccountTypes = IdlTypes<MerkleDistributor$1>;
13
+ type ClaimStatus = MerkleDistributorAccountTypes["claimStatus"];
14
+ type CompressedClaimStatus = MerkleDistributorAccountTypes["compressedClaimStatus"];
11
15
  type OracleType = IdlTypes<AlignedDistributor>["oracleType"];
12
16
  type OracleTypeName = "none" | "pyth" | "switchboard" | "test";
13
17
  interface IInteractSolanaExt extends ITransactionSolanaExt {
@@ -423,88 +427,6 @@ interface SetAdminAccounts {
423
427
  }
424
428
  declare function setAdmin(accounts: SetAdminAccounts, programId?: PublicKey): TransactionInstruction;
425
429
 
426
- interface ClaimStatusFields {
427
- /** Authority that claimed the tokens. */
428
- claimant: PublicKey;
429
- /** Locked amount */
430
- lockedAmount: BN;
431
- /** Locked amount withdrawn */
432
- lockedAmountWithdrawn: BN;
433
- /** Unlocked amount */
434
- unlockedAmount: BN;
435
- /** Last claim time */
436
- lastClaimTs: BN;
437
- /** Track amount per unlock, can be useful for non-linear vesting */
438
- lastAmountPerUnlock: BN;
439
- /** Whether claim is closed */
440
- closed: boolean;
441
- /** Distributor account for which ClaimStatus was created, useful to filter by in get_program_accounts */
442
- distributor: PublicKey;
443
- /** Number of time amount has been claimed */
444
- claimsCount: number;
445
- /** Time when claim was closed */
446
- closedTs: BN;
447
- /** Buffer for additional fields */
448
- buffer2: Array<number>;
449
- }
450
- interface ClaimStatusJSON {
451
- /** Authority that claimed the tokens. */
452
- claimant: string;
453
- /** Locked amount */
454
- lockedAmount: string;
455
- /** Locked amount withdrawn */
456
- lockedAmountWithdrawn: string;
457
- /** Unlocked amount */
458
- unlockedAmount: string;
459
- /** Last claim time */
460
- lastClaimTs: string;
461
- /** Track amount per unlock, can be useful for non-linear vesting */
462
- lastAmountPerUnlock: string;
463
- /** Whether claim is closed */
464
- closed: boolean;
465
- /** Distributor account for which ClaimStatus was created, useful to filter by in get_program_accounts */
466
- distributor: string;
467
- /** Number of time amount has been claimed */
468
- claimsCount: number;
469
- /** Time when claim was closed */
470
- closedTs: string;
471
- /** Buffer for additional fields */
472
- buffer2: Array<number>;
473
- }
474
- /** Holds whether or not a claimant has claimed tokens. */
475
- declare class ClaimStatus {
476
- /** Authority that claimed the tokens. */
477
- readonly claimant: PublicKey;
478
- /** Locked amount */
479
- readonly lockedAmount: BN;
480
- /** Locked amount withdrawn */
481
- readonly lockedAmountWithdrawn: BN;
482
- /** Unlocked amount */
483
- readonly unlockedAmount: BN;
484
- /** Last claim time */
485
- readonly lastClaimTs: BN;
486
- /** Track amount per unlock, can be useful for non-linear vesting */
487
- readonly lastAmountPerUnlock: BN;
488
- /** Whether claim is closed */
489
- readonly closed: boolean;
490
- /** Distributor account for which ClaimStatus was created, useful to filter by in get_program_accounts */
491
- readonly distributor: PublicKey;
492
- /** Number of time amount has been claimed */
493
- readonly claimsCount: number;
494
- /** Time when claim was closed */
495
- readonly closedTs: BN;
496
- /** Buffer for additional fields */
497
- readonly buffer2: Array<number>;
498
- static readonly discriminator: Buffer;
499
- static readonly layout: any;
500
- constructor(fields: ClaimStatusFields);
501
- static fetch(c: Connection, address: PublicKey, programId?: PublicKey): Promise<ClaimStatus | null>;
502
- static fetchMultiple(c: Connection, addresses: PublicKey[], programId?: PublicKey): Promise<Array<ClaimStatus | null>>;
503
- static decode(data: Buffer): ClaimStatus;
504
- toJSON(): ClaimStatusJSON;
505
- static fromJSON(obj: ClaimStatusJSON): ClaimStatus;
506
- }
507
-
508
430
  interface MerkleDistributorFields {
509
431
  /** Bump seed. */
510
432
  bump: number;
@@ -696,28 +618,48 @@ declare abstract class BaseDistributorClient {
696
618
  protected programId: PublicKey;
697
619
  protected commitment: Commitment | ConnectionConfig;
698
620
  protected sendThrottler: PQueue;
621
+ merkleDistributorProgram: Program<MerkleDistributor$1>;
699
622
  constructor({ clusterUrl, cluster, commitment, programId, sendRate, sendThrottler, }: IInitOptions);
700
623
  protected abstract getNewDistributorInstruction(data: ICreateDistributorData | ICreateAlignedDistributorData, accounts: NewDistributorAccounts): Promise<TransactionInstruction>;
701
624
  protected abstract getClawbackInstruction(account: ClawbackAccounts): Promise<TransactionInstruction>;
702
625
  getConnection(): Connection;
703
626
  getCommitment(): Commitment | undefined;
704
627
  getDistributorProgramId(): PublicKey;
705
- prepareCreateInstructions(data: ICreateDistributorData | ICreateAlignedDistributorData, extParams: ICreateSolanaExt): Promise<{
628
+ prepareCreateInstructions(data: ICreateDistributorData | ICreateAlignedDistributorData, extParams: ITransactionSolanaExtResolved<ICreateSolanaExt>): Promise<{
706
629
  distributorPublicKey: PublicKey;
707
630
  ixs: TransactionInstruction[];
708
631
  }>;
709
632
  create(data: ICreateDistributorData | ICreateAlignedDistributorData, extParams: ICreateSolanaExt): Promise<ICreateDistributorResult>;
633
+ /**
634
+ * @public
635
+ * @overload
636
+ */
710
637
  claim(data: IClaimData, extParams: IInteractSolanaExt): Promise<ITransactionResult>;
711
- prepareClaimInstructions(data: IClaimData, extParams: IInteractSolanaExt): Promise<TransactionInstruction[]>;
638
+ /**
639
+ * @internal
640
+ */
641
+ claim(data: IClaimData, extParams: IInteractSolanaExt, _serviceTransfer?: unknown): Promise<ITransactionResult>;
642
+ /**
643
+ * @public
644
+ * @overload
645
+ */
646
+ prepareClaimInstructions(data: IClaimData, extParams: ITransactionSolanaExtResolved<IInteractSolanaExt>): Promise<TransactionInstruction[]>;
647
+ /**
648
+ * @internal
649
+ */
650
+ prepareClaimInstructions(data: IClaimData, extParams: ITransactionSolanaExtResolved<IInteractSolanaExt>, _serviceTransfer?: unknown): Promise<TransactionInstruction[]>;
712
651
  closeClaim(data: ICloseClaimData, extParams: IInteractSolanaExt): Promise<ITransactionResult>;
713
- prepareCloseClaimInstructions(data: ICloseClaimData, extParams: IInteractSolanaExt): Promise<TransactionInstruction[]>;
714
- prepareClawbackInstructions(data: IClawbackData, extParams: IInteractSolanaExt): Promise<TransactionInstruction[]>;
652
+ prepareCloseClaimInstructions(data: ICloseClaimData, extParams: ITransactionSolanaExtResolved<IInteractSolanaExt>): Promise<TransactionInstruction[]>;
653
+ prepareClawbackInstructions(data: IClawbackData, extParams: ITransactionSolanaExtResolved<IInteractSolanaExt>): Promise<TransactionInstruction[]>;
715
654
  clawback(data: IClawbackData, extParams: IInteractSolanaExt): Promise<ITransactionResult>;
716
- getClaims(data: IGetClaimData[]): Promise<(ClaimStatus | null)[]>;
655
+ getClaim(claimStatus: string | PublicKey): Promise<MerkleDistributorAccountTypes["claimStatus"] | MerkleDistributorAccountTypes["compressedClaimStatus"] | null>;
656
+ getClaims(data: IGetClaimData[]): Promise<(MerkleDistributorAccountTypes["claimStatus"] | MerkleDistributorAccountTypes["compressedClaimStatus"] | null)[]>;
717
657
  getDistributors(data: IGetDistributors): Promise<(MerkleDistributor | null)[]>;
718
658
  searchDistributors(data: ISearchDistributors): Promise<IProgramAccount<MerkleDistributor>[]>;
719
- protected prepareClaimFeeInstruction(payer: PublicKey): TransactionInstruction;
659
+ protected prepareClaimFeeInstruction(payer: PublicKey, fee?: bigint): TransactionInstruction;
720
660
  protected getNewDistributorArgs(data: ICreateDistributorData): NewDistributorArgs;
661
+ protected unwrapExecutionParams<T extends IInteractSolanaExt>(extParams: T): ReturnType<typeof unwrapExecutionParams<T>>;
662
+ private decodeClaimStatus;
721
663
  }
722
664
 
723
665
  declare class SolanaDistributorClient extends BaseDistributorClient {
@@ -1372,7 +1314,7 @@ declare const getTestOraclePda: (programId: PublicKey, mint: PublicKey, creator:
1372
1314
  declare function getDistributorPda(programId: PublicKey, mint: PublicKey, version: number): PublicKey;
1373
1315
  declare function getClaimantStatusPda(programId: PublicKey, distributor: PublicKey, claimant: PublicKey): PublicKey;
1374
1316
  declare function getEventAuthorityPda(programId: PublicKey): PublicKey;
1375
- declare function wrappedSignAndExecuteTransaction(connection: Connection, invoker: Keypair | SignerWalletAdapter, tx: Transaction | VersionedTransaction, confirmationParams: ConfirmationParams, throttleParams: ThrottleParams): Promise<string>;
1317
+ declare function wrappedSignAndExecuteTransaction(...args: Parameters<typeof signAndExecuteTransaction>): Promise<string>;
1376
1318
  declare function calculateAmountWithTransferFees(connection: Connection, transferFeeConfig: TransferFeeConfig, transferAmount: bigint): Promise<{
1377
1319
  transferAmount: bigint;
1378
1320
  feeCharged: bigint;
@@ -1424,11 +1366,9 @@ type index_AnchorErrorCode = AnchorErrorCode;
1424
1366
  declare const index_AnchorErrorCode: typeof AnchorErrorCode;
1425
1367
  type index_ClaimLockedAccounts = ClaimLockedAccounts;
1426
1368
  type index_ClaimStatus = ClaimStatus;
1427
- declare const index_ClaimStatus: typeof ClaimStatus;
1428
- type index_ClaimStatusFields = ClaimStatusFields;
1429
- type index_ClaimStatusJSON = ClaimStatusJSON;
1430
1369
  type index_ClawbackAccounts = ClawbackAccounts;
1431
1370
  type index_CloseClaimAccounts = CloseClaimAccounts;
1371
+ type index_CompressedClaimStatus = CompressedClaimStatus;
1432
1372
  type index_ContractErrorCode = ContractErrorCode;
1433
1373
  declare const index_ContractErrorCode: typeof ContractErrorCode;
1434
1374
  type index_IClaimData = IClaimData;
@@ -1446,6 +1386,7 @@ type index_ISetClawbackReceiverData = ISetClawbackReceiverData;
1446
1386
  type index_ISetDataAdmin = ISetDataAdmin;
1447
1387
  type index_MerkleDistributor = MerkleDistributor;
1448
1388
  declare const index_MerkleDistributor: typeof MerkleDistributor;
1389
+ type index_MerkleDistributorAccountTypes = MerkleDistributorAccountTypes;
1449
1390
  type index_MerkleDistributorFields = MerkleDistributorFields;
1450
1391
  type index_MerkleDistributorJSON = MerkleDistributorJSON;
1451
1392
  type index_NewAlignedDistributorArgs = NewAlignedDistributorArgs;
@@ -1479,7 +1420,7 @@ declare const index_setAdmin: typeof setAdmin;
1479
1420
  declare const index_setClawbackReceiver: typeof setClawbackReceiver;
1480
1421
  declare const index_wrappedSignAndExecuteTransaction: typeof wrappedSignAndExecuteTransaction;
1481
1422
  declare namespace index {
1482
- export { type index_AlignedDistributorData as AlignedDistributorData, index_AnchorErrorCode as AnchorErrorCode, type index_ClaimLockedAccounts as ClaimLockedAccounts, index_ClaimStatus as ClaimStatus, type index_ClaimStatusFields as ClaimStatusFields, type index_ClaimStatusJSON as ClaimStatusJSON, type index_ClawbackAccounts as ClawbackAccounts, type index_CloseClaimAccounts as CloseClaimAccounts, index_ContractErrorCode as ContractErrorCode, type index_IClaimData as IClaimData, type index_IClawbackData as IClawbackData, type index_ICloseClaimData as ICloseClaimData, type index_ICreateAlignedDistributorData as ICreateAlignedDistributorData, type index_ICreateDistributorData as ICreateDistributorData, type index_ICreateDistributorResult as ICreateDistributorResult, type index_ICreateSolanaExt as ICreateSolanaExt, type index_IGetClaimData as IGetClaimData, type index_IGetDistributors as IGetDistributors, type index_IInteractSolanaExt as IInteractSolanaExt, type index_ISearchDistributors as ISearchDistributors, type index_ISetClawbackReceiverData as ISetClawbackReceiverData, type index_ISetDataAdmin as ISetDataAdmin, index_MerkleDistributor as MerkleDistributor, type index_MerkleDistributorFields as MerkleDistributorFields, type index_MerkleDistributorJSON as MerkleDistributorJSON, type index_NewAlignedDistributorArgs as NewAlignedDistributorArgs, type index_NewClaimAccounts as NewClaimAccounts, type index_NewClaimArgs as NewClaimArgs, type index_NewDistributorAccounts as NewDistributorAccounts, type index_NewDistributorArgs as NewDistributorArgs, type index_OracleType as OracleType, type index_OracleTypeName as OracleTypeName, type index_SetAdminAccounts as SetAdminAccounts, type index_SetClawbackReceiverAccounts as SetClawbackReceiverAccounts, index_SolanaAlignedDistributorClient as SolanaAlignedDistributorClient, index_SolanaDistributorClient as SolanaDistributorClient, index_calculateAmountWithTransferFees as calculateAmountWithTransferFees, index_claimLocked as claimLocked, index_clawback as clawback, index_closeClaim as closeClaim, index_constants as constants, index_fromCode as fromCode, index_fromTxError as fromTxError, index_getAlignedDistributorPda as getAlignedDistributorPda, index_getClaimantStatusPda as getClaimantStatusPda, index_getDistributorPda as getDistributorPda, index_getEventAuthorityPda as getEventAuthorityPda, index_getTestOraclePda as getTestOraclePda, index_newClaim as newClaim, index_newDistributor as newDistributor, index_setAdmin as setAdmin, index_setClawbackReceiver as setClawbackReceiver, index_wrappedSignAndExecuteTransaction as wrappedSignAndExecuteTransaction };
1423
+ export { type index_AlignedDistributorData as AlignedDistributorData, index_AnchorErrorCode as AnchorErrorCode, type index_ClaimLockedAccounts as ClaimLockedAccounts, type index_ClaimStatus as ClaimStatus, type index_ClawbackAccounts as ClawbackAccounts, type index_CloseClaimAccounts as CloseClaimAccounts, type index_CompressedClaimStatus as CompressedClaimStatus, index_ContractErrorCode as ContractErrorCode, type index_IClaimData as IClaimData, type index_IClawbackData as IClawbackData, type index_ICloseClaimData as ICloseClaimData, type index_ICreateAlignedDistributorData as ICreateAlignedDistributorData, type index_ICreateDistributorData as ICreateDistributorData, type index_ICreateDistributorResult as ICreateDistributorResult, type index_ICreateSolanaExt as ICreateSolanaExt, type index_IGetClaimData as IGetClaimData, type index_IGetDistributors as IGetDistributors, type index_IInteractSolanaExt as IInteractSolanaExt, type index_ISearchDistributors as ISearchDistributors, type index_ISetClawbackReceiverData as ISetClawbackReceiverData, type index_ISetDataAdmin as ISetDataAdmin, index_MerkleDistributor as MerkleDistributor, type index_MerkleDistributorAccountTypes as MerkleDistributorAccountTypes, type index_MerkleDistributorFields as MerkleDistributorFields, type index_MerkleDistributorJSON as MerkleDistributorJSON, type index_NewAlignedDistributorArgs as NewAlignedDistributorArgs, type index_NewClaimAccounts as NewClaimAccounts, type index_NewClaimArgs as NewClaimArgs, type index_NewDistributorAccounts as NewDistributorAccounts, type index_NewDistributorArgs as NewDistributorArgs, type index_OracleType as OracleType, type index_OracleTypeName as OracleTypeName, type index_SetAdminAccounts as SetAdminAccounts, type index_SetClawbackReceiverAccounts as SetClawbackReceiverAccounts, index_SolanaAlignedDistributorClient as SolanaAlignedDistributorClient, index_SolanaDistributorClient as SolanaDistributorClient, index_calculateAmountWithTransferFees as calculateAmountWithTransferFees, index_claimLocked as claimLocked, index_clawback as clawback, index_closeClaim as closeClaim, index_constants as constants, index_fromCode as fromCode, index_fromTxError as fromTxError, index_getAlignedDistributorPda as getAlignedDistributorPda, index_getClaimantStatusPda as getClaimantStatusPda, index_getDistributorPda as getDistributorPda, index_getEventAuthorityPda as getEventAuthorityPda, index_getTestOraclePda as getTestOraclePda, index_newClaim as newClaim, index_newDistributor as newDistributor, index_setAdmin as setAdmin, index_setClawbackReceiver as setClawbackReceiver, index_wrappedSignAndExecuteTransaction as wrappedSignAndExecuteTransaction };
1483
1424
  }
1484
1425
 
1485
- export { type AlignedDistributorData, AnchorErrorCode, type ClaimLockedAccounts, ClaimStatus, type ClaimStatusFields, type ClaimStatusJSON, type ClawbackAccounts, type CloseClaimAccounts, ContractErrorCode, type IClaimData, type IClawbackData, type ICloseClaimData, type ICreateAlignedDistributorData, type ICreateDistributorData, type ICreateDistributorResult, type ICreateSolanaExt, type IGetClaimData, type IGetDistributors, type IInteractSolanaExt, type ISearchDistributors, type ISetClawbackReceiverData, type ISetDataAdmin, MerkleDistributor, type MerkleDistributorFields, type MerkleDistributorJSON, type NewAlignedDistributorArgs, type NewClaimAccounts, type NewClaimArgs, type NewDistributorAccounts, type NewDistributorArgs, type OracleType, type OracleTypeName, type SetAdminAccounts, type SetClawbackReceiverAccounts, SolanaAlignedDistributorClient, SolanaDistributorClient, calculateAmountWithTransferFees, claimLocked, clawback, closeClaim, constants, fromCode, fromTxError, getAlignedDistributorPda, getClaimantStatusPda, getDistributorPda, getEventAuthorityPda, getTestOraclePda, index as i, newClaim, newDistributor, setAdmin, setClawbackReceiver, wrappedSignAndExecuteTransaction };
1426
+ export { type AlignedDistributorData, AnchorErrorCode, type ClaimLockedAccounts, type ClaimStatus, type ClawbackAccounts, type CloseClaimAccounts, type CompressedClaimStatus, ContractErrorCode, type IClaimData, type IClawbackData, type ICloseClaimData, type ICreateAlignedDistributorData, type ICreateDistributorData, type ICreateDistributorResult, type ICreateSolanaExt, type IGetClaimData, type IGetDistributors, type IInteractSolanaExt, type ISearchDistributors, type ISetClawbackReceiverData, type ISetDataAdmin, MerkleDistributor, type MerkleDistributorAccountTypes, type MerkleDistributorFields, type MerkleDistributorJSON, type NewAlignedDistributorArgs, type NewClaimAccounts, type NewClaimArgs, type NewDistributorAccounts, type NewDistributorArgs, type OracleType, type OracleTypeName, type SetAdminAccounts, type SetClawbackReceiverAccounts, SolanaAlignedDistributorClient, SolanaDistributorClient, calculateAmountWithTransferFees, claimLocked, clawback, closeClaim, constants, fromCode, fromTxError, getAlignedDistributorPda, getClaimantStatusPda, getDistributorPda, getEventAuthorityPda, getTestOraclePda, index as i, newClaim, newDistributor, setAdmin, setClawbackReceiver, wrappedSignAndExecuteTransaction };
@@ -6,5 +6,6 @@ import '@streamflow/common/solana';
6
6
  import 'bn.js';
7
7
  import '@coral-xyz/anchor';
8
8
  import './solana/descriptor/aligned_distributor.js';
9
+ import './solana/descriptor/merkle_distributor.js';
9
10
  import 'p-queue';
10
11
  import '@solana/spl-token';