@streamflow/distributor 10.0.0-alpha.p313.fe3720a → 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.
@@ -337,13 +337,15 @@ var DISTRIBUTOR_PROGRAM_ID = {
337
337
  [common.ICluster.Testnet]: "MErKy6nZVoVAkryxAejJz2juifQ4ArgLgHmaJCQkU7N",
338
338
  [common.ICluster.Local]: "MErKy6nZVoVAkryxAejJz2juifQ4ArgLgHmaJCQkU7N"
339
339
  };
340
- var fetchAirdropFee = async (distributorId, cluster = common.ICluster.Mainnet, fetchFn = fetch) => {
341
- const baseUrl = cluster === common.ICluster.Mainnet ? "https://api.streamflow.finance" : "https://staging-api.streamflow.finance";
342
- const url = `${baseUrl}/v2/api/airdrops/${encodeURIComponent(distributorId)}/fees`;
340
+
341
+ // solana/fetchAirdropFee.ts
342
+ var fetchAirdropFee = async (distributorId, apiUrl, apiKey, fetchFn = fetch) => {
343
+ const url = `${apiUrl}/v2/api/airdrops/${encodeURIComponent(distributorId)}/fees`;
343
344
  const res = await fetchFn(url, {
344
345
  method: "GET",
345
346
  headers: {
346
- "Content-Type": "application/json"
347
+ "Content-Type": "application/json",
348
+ ...apiKey ? { "x-api-key": apiKey } : {}
347
349
  }
348
350
  });
349
351
  if (!res.ok) {
@@ -453,10 +455,10 @@ function calculateDynamicFeeFromSolParams(params) {
453
455
  return raw;
454
456
  }
455
457
  async function resolveAirdropFeeLamportsUsingApi(params) {
456
- const { distributorAddress, mintAccount, claimableAmount, cluster } = params;
458
+ const { distributorAddress, mintAccount, claimableAmount, cluster, apiUrl, apiKey } = params;
457
459
  let apiFeesResponse = void 0;
458
460
  try {
459
- apiFeesResponse = await fetchAirdropFee(distributorAddress, cluster);
461
+ apiFeesResponse = await fetchAirdropFee(distributorAddress, apiUrl, apiKey);
460
462
  } catch (_) {
461
463
  }
462
464
  let solPrice = null;
@@ -469,7 +471,7 @@ async function resolveAirdropFeeLamportsUsingApi(params) {
469
471
  } catch (_) {
470
472
  }
471
473
  const response = apiFeesResponse ?? defaultAPIFeesResponse;
472
- if (response?.isCustom && response.claimFee !== void 0) {
474
+ if (response?.isCustom && response.claimFee !== void 0 && response.claimFee !== null) {
473
475
  return toLamportsSOL(response.claimFee);
474
476
  }
475
477
  const claimFeeDynamic = response?.claimFeeDynamic ?? defaultAPIFeesResponse.claimFeeDynamic;
@@ -3561,7 +3563,9 @@ var BaseDistributorClient = class {
3561
3563
  commitment = "confirmed",
3562
3564
  programId = "",
3563
3565
  sendRate = 1,
3564
- sendThrottler
3566
+ sendThrottler,
3567
+ apiUrl,
3568
+ apiKey
3565
3569
  }) {
3566
3570
  this.commitment = commitment;
3567
3571
  this.cluster = cluster;
@@ -3572,6 +3576,8 @@ var BaseDistributorClient = class {
3572
3576
  ...merkle_distributor_default
3573
3577
  };
3574
3578
  this.merkleDistributorProgram = new anchor.Program(merkleDistributorProgram, { connection: this.connection });
3579
+ this.apiUrl = apiUrl;
3580
+ this.apiKey = apiKey;
3575
3581
  }
3576
3582
  getConnection() {
3577
3583
  return this.connection;
@@ -3763,7 +3769,9 @@ var BaseDistributorClient = class {
3763
3769
  distributorAddress: distributorPublicKey.toBase58(),
3764
3770
  mintAccount,
3765
3771
  claimableAmount,
3766
- cluster: this.cluster
3772
+ cluster: this.cluster,
3773
+ apiUrl: this.apiUrl,
3774
+ apiKey: this.apiKey
3767
3775
  });
3768
3776
  } catch (_) {
3769
3777
  feeLamports = MINIMUM_FEE_FALLBACK;
@@ -5528,8 +5536,8 @@ var aligned_distributor_default = {
5528
5536
 
5529
5537
  // solana/clients/SolanaAlignedDistributorClient.ts
5530
5538
  var SolanaAlignedDistributorClient = class extends BaseDistributorClient {
5531
- constructor({ clusterUrl, cluster, commitment, programId, sendRate, sendThrottler }) {
5532
- super({ clusterUrl, cluster, commitment, programId, sendRate, sendThrottler });
5539
+ constructor({ clusterUrl, cluster, commitment, programId, sendRate, sendThrottler, apiUrl, apiKey }) {
5540
+ super({ clusterUrl, cluster, commitment, programId, sendRate, sendThrottler, apiUrl, apiKey });
5533
5541
  const alignedAirdropsProgram = {
5534
5542
  ...aligned_distributor_default
5535
5543
  };