@zkp2p/sdk 0.2.0 → 0.2.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.
package/dist/index.mjs CHANGED
@@ -849,6 +849,20 @@ var logger = {
849
849
  };
850
850
 
851
851
  // src/client/IntentOperations.ts
852
+ function isV2SignalIntentAbi(abi) {
853
+ for (const item of abi) {
854
+ if (item.type === "function" && item.name === "signalIntent" && Array.isArray(item.inputs)) {
855
+ const inputs = item.inputs;
856
+ for (const input of inputs) {
857
+ if (input.components) {
858
+ if (input.components.some((c) => c.name === "referralFees")) return true;
859
+ if (input.components.some((c) => c.name === "referrerFee")) return false;
860
+ }
861
+ }
862
+ }
863
+ }
864
+ return true;
865
+ }
852
866
  var IntentOperations = class {
853
867
  constructor(config) {
854
868
  this.config = config;
@@ -874,6 +888,7 @@ var IntentOperations = class {
874
888
  escrowAddress: escrowContext.address,
875
889
  preferV2
876
890
  });
891
+ const useV2Encoding = isV2SignalIntentAbi(orchestratorContext.abi);
877
892
  const catalog = getPaymentMethodsCatalog(this.config.getChainId(), this.config.getRuntimeEnv());
878
893
  const paymentMethod = resolvePaymentMethodHashFromCatalog(params.processorName, catalog);
879
894
  const fiatCurrency = resolveFiatCurrencyBytes32(params.fiatCurrencyCode);
@@ -911,7 +926,7 @@ var IntentOperations = class {
911
926
  authorizationToken,
912
927
  timeoutMs: this.config.getApiTimeoutMs()
913
928
  };
914
- const response = orchestratorContext.version === "v2" ? await apiSignIntentV3(
929
+ const response = useV2Encoding ? await apiSignIntentV3(
915
930
  {
916
931
  ...baseRequest,
917
932
  callerAddress: this.config.getWalletClient().account.address,
@@ -942,7 +957,7 @@ var IntentOperations = class {
942
957
  postIntentHook: params.postIntentHook ?? ZERO_ADDRESS,
943
958
  data: params.data ?? "0x"
944
959
  };
945
- const args = orchestratorContext.version === "v2" ? [
960
+ const args = useV2Encoding ? [
946
961
  {
947
962
  ...commonFields,
948
963
  referralFees,
@@ -5948,7 +5963,7 @@ var Zkp2pClient = class {
5948
5963
  ...configuredOrchestratorAddresses
5949
5964
  ]);
5950
5965
  this.orchestratorAddress = this.orchestratorV2Address ?? toAddress(addresses.orchestrator) ?? this.orchestratorAddresses[0];
5951
- this.orchestratorAbi = this.orchestratorV2Abi ?? abis.orchestrator;
5966
+ this.orchestratorAbi = abis.orchestrator ?? this.orchestratorV2Abi;
5952
5967
  this.unifiedPaymentVerifier = toAddress(
5953
5968
  addresses.unifiedPaymentVerifierV2 ?? addresses.unifiedPaymentVerifier
5954
5969
  );