@streamflow/distributor 11.0.0-alpha.p334.45cbb4e → 11.0.0-alpha.p334.ea83918
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/dist/cjs/index.cjs +10 -4
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/solana/index.cjs +10 -4
- package/dist/cjs/solana/index.cjs.map +1 -1
- package/dist/cjs/solana/index.d.cts +12 -17
- package/dist/esm/index.js +10 -4
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/solana/index.d.ts +12 -17
- package/dist/esm/solana/index.js +10 -4
- package/dist/esm/solana/index.js.map +1 -1
- package/package.json +4 -4
|
@@ -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 {
|
|
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
|
|
29
|
-
|
|
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 =
|
|
38
|
-
type ClaimLockedAccounts =
|
|
39
|
-
type ClawbackAccounts =
|
|
40
|
-
type CloseClaimAccounts =
|
|
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
|
}
|
package/dist/esm/solana/index.js
CHANGED
|
@@ -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
|
-
|
|
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({
|
|
@@ -4836,7 +4842,7 @@ var SolanaDistributorClient = class extends BaseDistributorClient {
|
|
|
4836
4842
|
// total_amount_locked
|
|
4837
4843
|
data.claimsClosableByClaimant ?? null,
|
|
4838
4844
|
data.claimsLimit ?? null
|
|
4839
|
-
).accounts(accounts).instruction();
|
|
4845
|
+
).accounts(accounts).accountsPartial({ partnerOracle: this.partnerOracleProgramId, partnerOracleConfig: this.feeConfigPublicKey }).instruction();
|
|
4840
4846
|
}
|
|
4841
4847
|
async getClawbackInstruction(accounts) {
|
|
4842
4848
|
return this.merkleDistributorProgram.methods.clawback().accounts(accounts).instruction();
|
|
@@ -4913,7 +4919,7 @@ var SolanaAlignedDistributorClient = class extends BaseDistributorClient {
|
|
|
4913
4919
|
mint,
|
|
4914
4920
|
tokenProgram,
|
|
4915
4921
|
priceOracle: oracle
|
|
4916
|
-
}).instruction();
|
|
4922
|
+
}).accountsPartial({ partnerOracle: this.partnerOracleProgramId, partnerOracleConfig: this.feeConfigPublicKey }).instruction();
|
|
4917
4923
|
}
|
|
4918
4924
|
async getClawbackInstruction(accounts) {
|
|
4919
4925
|
const { distributor, from, to, mint, tokenProgram, admin } = accounts;
|