@zkp2p/sdk 0.0.14 → 0.0.15

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/index.cjs CHANGED
@@ -1106,7 +1106,7 @@ var init_utils = __esm({
1106
1106
  useCustomQRCode: true,
1107
1107
  troubleScanningQRCodeLink: () => "https://web.luxon.com/dashboard",
1108
1108
  getFormattedSendLink: (_recipientId, _sendCurrency, _amountFiatToSend) => "https://web.luxon.com/dashboard",
1109
- supportsSendingPaymentOnWeb: false,
1109
+ supportsSendingPaymentOnWeb: true,
1110
1110
  showTroubleScanningQRCodeLink: true,
1111
1111
  sendPaymentWarning: (sendCurrency, amountFiatToSend) => {
1112
1112
  return `Send exactly ${amountFiatToSend} ${currencyInfo[sendCurrency].currencyCode} in a single payment.`;
@@ -3568,10 +3568,7 @@ var DEPOSIT_RELATIONS_QUERY = (
3568
3568
  var PAYMENT_METHODS_BY_PAYEE_HASH_QUERY = (
3569
3569
  /* GraphQL */
3570
3570
  `
3571
- query GetPaymentMethodsByPayeeHash(
3572
- $where: DepositPaymentMethod_bool_exp!
3573
- $limit: Int
3574
- ) {
3571
+ query GetPaymentMethodsByPayeeHash($where: DepositPaymentMethod_bool_exp!, $limit: Int) {
3575
3572
  DepositPaymentMethod(where: $where, limit: $limit) {
3576
3573
  id
3577
3574
  chainId
@@ -3660,11 +3657,7 @@ var INTENTS_QUERY = (
3660
3657
  var EXPIRED_INTENTS_QUERY = (
3661
3658
  /* GraphQL */
3662
3659
  `
3663
- query GetExpiredIntents(
3664
- $now: numeric!
3665
- $limit: Int
3666
- $depositIds: [String!]
3667
- ) {
3660
+ query GetExpiredIntents($now: numeric!, $limit: Int, $depositIds: [String!]) {
3668
3661
  Intent(
3669
3662
  where: {
3670
3663
  status: { _eq: "SIGNALED" }
@@ -3692,9 +3685,7 @@ var INTENT_FULFILLMENTS_QUERY = (
3692
3685
  /* GraphQL */
3693
3686
  `
3694
3687
  query GetFulfilledIntents($intentHashes: [String!]) {
3695
- Orchestrator_V21_IntentFulfilled(
3696
- where: { intentHash: { _in: $intentHashes } }
3697
- ) {
3688
+ Orchestrator_V21_IntentFulfilled(where: { intentHash: { _in: $intentHashes } }) {
3698
3689
  intentHash
3699
3690
  isManualRelease
3700
3691
  fundsTransferredTo
@@ -3702,22 +3693,30 @@ var INTENT_FULFILLMENTS_QUERY = (
3702
3693
  }
3703
3694
  `
3704
3695
  );
3696
+ var INTENT_FULFILLMENT_AMOUNTS_QUERY = (
3697
+ /* GraphQL */
3698
+ `
3699
+ query GetFulfillmentAmounts($intentHash: String!) {
3700
+ Intent(where: { intentHash: { _eq: $intentHash } }, limit: 1) {
3701
+ intentHash
3702
+ releasedAmount
3703
+ takerAmountNetFees
3704
+ }
3705
+ }
3706
+ `
3707
+ );
3705
3708
  var FULFILLMENT_AND_PAYMENT_QUERY = (
3706
3709
  /* GraphQL */
3707
3710
  `
3708
3711
  query PaymentVerificationForFulfilledIntent($intentHash: String!) {
3709
- Orchestrator_V21_IntentFulfilled(
3710
- where: { intentHash: { _eq: $intentHash } }
3711
- ) {
3712
+ Orchestrator_V21_IntentFulfilled(where: { intentHash: { _eq: $intentHash } }) {
3712
3713
  id
3713
3714
  intentHash
3714
3715
  amount
3715
3716
  isManualRelease
3716
3717
  fundsTransferredTo
3717
3718
  }
3718
- UnifiedVerifier_V21_PaymentVerified(
3719
- where: { intentHash: { _eq: $intentHash } }
3720
- ) {
3719
+ UnifiedVerifier_V21_PaymentVerified(where: { intentHash: { _eq: $intentHash } }) {
3721
3720
  id
3722
3721
  intentHash
3723
3722
  method
@@ -3855,7 +3854,8 @@ var IndexerDepositService = class {
3855
3854
  } else if (filter.escrowAddress) {
3856
3855
  where.escrowAddress = { _ilike: filter.escrowAddress };
3857
3856
  }
3858
- if (filter.acceptingIntents !== void 0) where.acceptingIntents = { _eq: filter.acceptingIntents };
3857
+ if (filter.acceptingIntents !== void 0)
3858
+ where.acceptingIntents = { _eq: filter.acceptingIntents };
3859
3859
  if (filter.minLiquidity) where.remainingDeposits = { _gte: filter.minLiquidity };
3860
3860
  return Object.keys(where).length ? where : void 0;
3861
3861
  }
@@ -3884,7 +3884,12 @@ var IndexerDepositService = class {
3884
3884
  if (!Object.keys(where).length) return [];
3885
3885
  const result = await this.client.query({
3886
3886
  query: INTENTS_QUERY,
3887
- variables: { where, order_by: [{ signalTimestamp: "desc" }], limit: params.limit, offset: params.offset }
3887
+ variables: {
3888
+ where,
3889
+ order_by: [{ signalTimestamp: "desc" }],
3890
+ limit: params.limit,
3891
+ offset: params.offset
3892
+ }
3888
3893
  });
3889
3894
  return result.Intent ?? [];
3890
3895
  }
@@ -3924,7 +3929,10 @@ var IndexerDepositService = class {
3924
3929
  }
3925
3930
  async fetchDepositsByIds(ids) {
3926
3931
  if (!ids.length) return [];
3927
- const result = await this.client.query({ query: DEPOSITS_BY_IDS_QUERY, variables: { ids } });
3932
+ const result = await this.client.query({
3933
+ query: DEPOSITS_BY_IDS_QUERY,
3934
+ variables: { ids }
3935
+ });
3928
3936
  return result.Deposit ?? [];
3929
3937
  }
3930
3938
  async fetchDepositsByIdsWithRelations(ids, options = {}) {
@@ -3943,9 +3951,16 @@ var IndexerDepositService = class {
3943
3951
  const result = await this.client.query({ query: DEPOSIT_WITH_RELATIONS_QUERY, variables: { id } });
3944
3952
  const deposit = result.Deposit_by_pk;
3945
3953
  if (!deposit) return null;
3946
- const base2 = { ...deposit, paymentMethods: result.DepositPaymentMethod ?? [], currencies: result.MethodCurrency ?? [] };
3954
+ const base2 = {
3955
+ ...deposit,
3956
+ paymentMethods: result.DepositPaymentMethod ?? [],
3957
+ currencies: result.MethodCurrency ?? []
3958
+ };
3947
3959
  if (!options.includeIntents) return base2;
3948
- const intents = await this.fetchIntents({ depositIds: [deposit.id], statuses: options.intentStatuses });
3960
+ const intents = await this.fetchIntents({
3961
+ depositIds: [deposit.id],
3962
+ statuses: options.intentStatuses
3963
+ });
3949
3964
  return { ...base2, intents };
3950
3965
  }
3951
3966
  async fetchExpiredIntents(params) {
@@ -3971,10 +3986,20 @@ var IndexerDepositService = class {
3971
3986
  });
3972
3987
  return result.Orchestrator_V21_IntentFulfilled ?? [];
3973
3988
  }
3989
+ async fetchIntentFulfillmentAmounts(intentHash) {
3990
+ if (!intentHash) return null;
3991
+ const normalizedIntentHash = intentHash.toLowerCase();
3992
+ const result = await this.client.query({
3993
+ query: INTENT_FULFILLMENT_AMOUNTS_QUERY,
3994
+ variables: { intentHash: normalizedIntentHash }
3995
+ });
3996
+ return result.Intent?.[0] ?? null;
3997
+ }
3974
3998
  async resolvePayeeHash(params) {
3975
3999
  try {
3976
4000
  const { escrowAddress, depositId, paymentMethodHash } = params;
3977
- if (!escrowAddress || depositId === null || depositId === void 0 || !paymentMethodHash) return null;
4001
+ if (!escrowAddress || depositId === null || depositId === void 0 || !paymentMethodHash)
4002
+ return null;
3978
4003
  const compositeId = createCompositeDepositId(
3979
4004
  escrowAddress,
3980
4005
  typeof depositId === "bigint" ? depositId : depositId?.toString() ?? ""
@@ -3982,7 +4007,9 @@ var IndexerDepositService = class {
3982
4007
  const detail = await this.fetchDepositWithRelations(compositeId, { includeIntents: false });
3983
4008
  if (!detail?.paymentMethods?.length) return null;
3984
4009
  const target = paymentMethodHash.toLowerCase();
3985
- const match = detail.paymentMethods.find((pm) => (pm.paymentMethodHash ?? "").toLowerCase() === target);
4010
+ const match = detail.paymentMethods.find(
4011
+ (pm) => (pm.paymentMethodHash ?? "").toLowerCase() === target
4012
+ );
3986
4013
  return match?.payeeDetailsHash ?? null;
3987
4014
  } catch {
3988
4015
  return null;
@@ -3995,12 +4022,16 @@ var IndexerDepositService = class {
3995
4022
  payeeDetailsHash: { _ilike: normalizedHash }
3996
4023
  };
3997
4024
  if (options.paymentMethodHash) {
3998
- where.paymentMethodHash = { _eq: options.paymentMethodHash.toLowerCase?.() ?? options.paymentMethodHash };
4025
+ where.paymentMethodHash = {
4026
+ _eq: options.paymentMethodHash.toLowerCase?.() ?? options.paymentMethodHash
4027
+ };
3999
4028
  }
4000
- const result = await this.client.query({
4001
- query: PAYMENT_METHODS_BY_PAYEE_HASH_QUERY,
4002
- variables: { where, limit: options.limit }
4003
- });
4029
+ const result = await this.client.query(
4030
+ {
4031
+ query: PAYMENT_METHODS_BY_PAYEE_HASH_QUERY,
4032
+ variables: { where, limit: options.limit }
4033
+ }
4034
+ );
4004
4035
  const seen = /* @__PURE__ */ new Set();
4005
4036
  const depositIds = [];
4006
4037
  for (const pm of result.DepositPaymentMethod ?? []) {
@@ -5211,6 +5242,12 @@ var Zkp2pClient = class {
5211
5242
  getFulfilledIntentEvents: (intentHashes) => {
5212
5243
  return service.fetchFulfilledIntentEvents(intentHashes);
5213
5244
  },
5245
+ /**
5246
+ * Fetches gross and net fulfillment amounts for an intent.
5247
+ */
5248
+ getIntentFulfillmentAmounts: (intentHash) => {
5249
+ return service.fetchIntentFulfillmentAmounts(intentHash);
5250
+ },
5214
5251
  /**
5215
5252
  * Fetches both the fulfillment record and payment verification for an intent.
5216
5253
  */