@streamflow/distributor 10.0.0-alpha.p317.e143b57 → 10.0.1

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.
@@ -627,6 +627,8 @@ interface IInitOptions {
627
627
  programId?: string;
628
628
  sendRate?: number;
629
629
  sendThrottler?: PQueue;
630
+ apiUrl: string;
631
+ apiKey?: string;
630
632
  }
631
633
  declare abstract class BaseDistributorClient {
632
634
  protected connection: Connection;
@@ -635,7 +637,9 @@ declare abstract class BaseDistributorClient {
635
637
  protected sendThrottler: PQueue;
636
638
  merkleDistributorProgram: Program<MerkleDistributor$1>;
637
639
  protected cluster: ICluster;
638
- constructor({ clusterUrl, cluster, commitment, programId, sendRate, sendThrottler, }: IInitOptions);
640
+ protected apiUrl: string;
641
+ protected apiKey?: string;
642
+ constructor({ clusterUrl, cluster, commitment, programId, sendRate, sendThrottler, apiUrl, apiKey, }: IInitOptions);
639
643
  protected abstract getNewDistributorInstruction(data: ICreateDistributorData | ICreateAlignedDistributorData, accounts: NewDistributorAccounts): Promise<TransactionInstruction>;
640
644
  protected abstract getClawbackInstruction(account: ClawbackAccounts): Promise<TransactionInstruction>;
641
645
  getConnection(): Connection;
@@ -685,7 +689,7 @@ declare class SolanaDistributorClient extends BaseDistributorClient {
685
689
 
686
690
  declare class SolanaAlignedDistributorClient extends BaseDistributorClient {
687
691
  alignedProxyProgram: Program<AlignedDistributor>;
688
- constructor({ clusterUrl, cluster, commitment, programId, sendRate, sendThrottler }: IInitOptions);
692
+ constructor({ clusterUrl, cluster, commitment, programId, sendRate, sendThrottler, apiUrl, apiKey }: IInitOptions);
689
693
  getAlignedDistributorProgramId(): PublicKey;
690
694
  getAlignedDistributorAddress(distributorAddress: string): PublicKey;
691
695
  getAlignedDistributorData(distributorAddress: string): Promise<AlignedDistributorData>;
@@ -1393,7 +1397,7 @@ interface AirdropFeeQueryOptionsOverrides {
1393
1397
  retry?: number | boolean;
1394
1398
  refetchOnWindowFocus?: boolean;
1395
1399
  }
1396
- declare const fetchAirdropFee: (distributorId: string, cluster?: ICluster, fetchFn?: typeof fetch) => Promise<AirdropFeeResponse>;
1400
+ declare const fetchAirdropFee: (distributorId: string, apiUrl: string, apiKey?: string, fetchFn?: typeof fetch) => Promise<AirdropFeeResponse>;
1397
1401
 
1398
1402
  type AirdropFeeDynamic = {
1399
1403
  minPrice: string;
@@ -1450,6 +1454,8 @@ declare function resolveAirdropFeeLamportsUsingApi(params: {
1450
1454
  mintAccount: Mint;
1451
1455
  claimableAmount: bigint;
1452
1456
  cluster: ICluster;
1457
+ apiUrl: string;
1458
+ apiKey?: string;
1453
1459
  }): Promise<bigint>;
1454
1460
 
1455
1461
  type index_AirdropFeeClient = AirdropFeeClient;
package/dist/esm/index.js CHANGED
@@ -350,13 +350,15 @@ var DISTRIBUTOR_PROGRAM_ID = {
350
350
  [ICluster.Testnet]: "MErKy6nZVoVAkryxAejJz2juifQ4ArgLgHmaJCQkU7N",
351
351
  [ICluster.Local]: "MErKy6nZVoVAkryxAejJz2juifQ4ArgLgHmaJCQkU7N"
352
352
  };
353
- var fetchAirdropFee = async (distributorId, cluster = ICluster.Mainnet, fetchFn = fetch) => {
354
- const baseUrl = cluster === ICluster.Mainnet ? "https://api.streamflow.finance" : "https://staging-api.streamflow.finance";
355
- const url = `${baseUrl}/v2/api/airdrops/${encodeURIComponent(distributorId)}/fees`;
353
+
354
+ // solana/fetchAirdropFee.ts
355
+ var fetchAirdropFee = async (distributorId, apiUrl, apiKey, fetchFn = fetch) => {
356
+ const url = `${apiUrl}/v2/api/airdrops/${encodeURIComponent(distributorId)}/fees`;
356
357
  const res = await fetchFn(url, {
357
358
  method: "GET",
358
359
  headers: {
359
- "Content-Type": "application/json"
360
+ "Content-Type": "application/json",
361
+ ...apiKey ? { "x-api-key": apiKey } : {}
360
362
  }
361
363
  });
362
364
  if (!res.ok) {
@@ -466,10 +468,10 @@ function calculateDynamicFeeFromSolParams(params) {
466
468
  return raw;
467
469
  }
468
470
  async function resolveAirdropFeeLamportsUsingApi(params) {
469
- const { distributorAddress, mintAccount, claimableAmount, cluster } = params;
471
+ const { distributorAddress, mintAccount, claimableAmount, cluster, apiUrl, apiKey } = params;
470
472
  let apiFeesResponse = void 0;
471
473
  try {
472
- apiFeesResponse = await fetchAirdropFee(distributorAddress, cluster);
474
+ apiFeesResponse = await fetchAirdropFee(distributorAddress, apiUrl, apiKey);
473
475
  } catch (_) {
474
476
  }
475
477
  let solPrice = null;
@@ -482,7 +484,7 @@ async function resolveAirdropFeeLamportsUsingApi(params) {
482
484
  } catch (_) {
483
485
  }
484
486
  const response = apiFeesResponse ?? defaultAPIFeesResponse;
485
- if (response?.isCustom && response.claimFee !== void 0) {
487
+ if (response?.isCustom && response.claimFee !== void 0 && response.claimFee !== null) {
486
488
  return toLamportsSOL(response.claimFee);
487
489
  }
488
490
  const claimFeeDynamic = response?.claimFeeDynamic ?? defaultAPIFeesResponse.claimFeeDynamic;
@@ -3574,7 +3576,9 @@ var BaseDistributorClient = class {
3574
3576
  commitment = "confirmed",
3575
3577
  programId = "",
3576
3578
  sendRate = 1,
3577
- sendThrottler
3579
+ sendThrottler,
3580
+ apiUrl,
3581
+ apiKey
3578
3582
  }) {
3579
3583
  this.commitment = commitment;
3580
3584
  this.cluster = cluster;
@@ -3585,6 +3589,8 @@ var BaseDistributorClient = class {
3585
3589
  ...merkle_distributor_default
3586
3590
  };
3587
3591
  this.merkleDistributorProgram = new Program(merkleDistributorProgram, { connection: this.connection });
3592
+ this.apiUrl = apiUrl;
3593
+ this.apiKey = apiKey;
3588
3594
  }
3589
3595
  getConnection() {
3590
3596
  return this.connection;
@@ -3776,7 +3782,9 @@ var BaseDistributorClient = class {
3776
3782
  distributorAddress: distributorPublicKey.toBase58(),
3777
3783
  mintAccount,
3778
3784
  claimableAmount,
3779
- cluster: this.cluster
3785
+ cluster: this.cluster,
3786
+ apiUrl: this.apiUrl,
3787
+ apiKey: this.apiKey
3780
3788
  });
3781
3789
  } catch (_) {
3782
3790
  feeLamports = MINIMUM_FEE_FALLBACK;
@@ -5541,8 +5549,8 @@ var aligned_distributor_default = {
5541
5549
 
5542
5550
  // solana/clients/SolanaAlignedDistributorClient.ts
5543
5551
  var SolanaAlignedDistributorClient = class extends BaseDistributorClient {
5544
- constructor({ clusterUrl, cluster, commitment, programId, sendRate, sendThrottler }) {
5545
- super({ clusterUrl, cluster, commitment, programId, sendRate, sendThrottler });
5552
+ constructor({ clusterUrl, cluster, commitment, programId, sendRate, sendThrottler, apiUrl, apiKey }) {
5553
+ super({ clusterUrl, cluster, commitment, programId, sendRate, sendThrottler, apiUrl, apiKey });
5546
5554
  const alignedAirdropsProgram = {
5547
5555
  ...aligned_distributor_default
5548
5556
  };