@zkp2p/sdk 0.2.1 → 0.2.3
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/README.md +2 -2
- package/dist/{chunk-J33LUXNA.mjs → chunk-AXX3QCRW.mjs} +10 -52
- package/dist/chunk-AXX3QCRW.mjs.map +1 -0
- package/dist/index.cjs +162 -295
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +3 -4
- package/dist/index.d.ts +3 -4
- package/dist/index.mjs +159 -252
- package/dist/index.mjs.map +1 -1
- package/dist/protocolViewerParsers-TPB47QOH.mjs +4 -0
- package/dist/{protocolViewerParsers-VVASNOXW.mjs.map → protocolViewerParsers-TPB47QOH.mjs.map} +1 -1
- package/dist/react.d.mts +2 -2
- package/dist/react.d.ts +2 -2
- package/dist/{vaultUtils-zw4Xgu-G.d.mts → vaultUtils-DiAumiXp.d.mts} +6 -33
- package/dist/{vaultUtils-zw4Xgu-G.d.ts → vaultUtils-DiAumiXp.d.ts} +6 -33
- package/package.json +17 -17
- package/dist/chunk-J33LUXNA.mjs.map +0 -1
- package/dist/protocolViewerParsers-VVASNOXW.mjs +0 -4
package/dist/index.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
export { ZERO_RATE_MANAGER_ID, classifyDelegationState, getDelegationRoute, isZeroRateManagerId, normalizeRateManagerId, normalizeRegistry } from './chunk-LPJE2MN7.mjs';
|
|
2
2
|
import { ValidationError, NetworkError, APIError } from './chunk-GHQK65J2.mjs';
|
|
3
3
|
export { APIError, ContractError, ErrorCode, NetworkError, ValidationError, ZKP2PError } from './chunk-GHQK65J2.mjs';
|
|
4
|
-
import { getContracts, getRateManagerContracts, getPaymentMethodsCatalog, resolvePaymentMethodHashFromCatalog, getGatingServiceAddress, parseBigIntLike, resolveFiatCurrencyBytes32, resolvePaymentMethodNameFromHash } from './chunk-
|
|
5
|
-
export {
|
|
4
|
+
import { getContracts, getRateManagerContracts, getPaymentMethodsCatalog, resolvePaymentMethodHashFromCatalog, getGatingServiceAddress, parseBigIntLike, resolveFiatCurrencyBytes32, resolvePaymentMethodNameFromHash } from './chunk-AXX3QCRW.mjs';
|
|
5
|
+
export { asciiToBytes32, enrichPvDepositView, enrichPvIntentView, ensureBytes32, getContracts, getGatingServiceAddress, getPaymentMethodsCatalog, getRateManagerContracts, parseDepositView, parseIntentView, resolveFiatCurrencyBytes32, resolvePaymentMethodHash, resolvePaymentMethodHashFromCatalog, resolvePaymentMethodNameFromHash } from './chunk-AXX3QCRW.mjs';
|
|
6
6
|
import { Currency, currencyKeccak256 } from './chunk-ZFBH4HD7.mjs';
|
|
7
7
|
export { Currency, currencyInfo, getCurrencyCodeFromHash, getCurrencyInfoFromCountryCode, getCurrencyInfoFromHash, isSupportedCurrencyHash, mapConversionRatesToOnchainMinRate } from './chunk-ZFBH4HD7.mjs';
|
|
8
8
|
import { concatHex, encodeFunctionData, encodeAbiParameters, createPublicClient, http, formatUnits } from 'viem';
|
|
@@ -262,7 +262,7 @@ var ContractRouter = class {
|
|
|
262
262
|
}
|
|
263
263
|
];
|
|
264
264
|
}
|
|
265
|
-
resolveOrchestratorForEscrow(escrowAddress
|
|
265
|
+
resolveOrchestratorForEscrow(escrowAddress) {
|
|
266
266
|
if (escrowAddress) {
|
|
267
267
|
const escrowContext = this.getEscrowContextByAddress(escrowAddress);
|
|
268
268
|
const fromEscrow = this.getOrchestratorContextByAddress(escrowContext?.orchestratorAddress);
|
|
@@ -318,9 +318,6 @@ var ContractRouter = class {
|
|
|
318
318
|
}
|
|
319
319
|
return contexts;
|
|
320
320
|
}
|
|
321
|
-
get defaultPreferV2() {
|
|
322
|
-
return true;
|
|
323
|
-
}
|
|
324
321
|
};
|
|
325
322
|
|
|
326
323
|
// src/errors/utils.ts
|
|
@@ -370,9 +367,9 @@ function createHeaders(apiKey, authorizationToken) {
|
|
|
370
367
|
headers2["Authorization"] = authorizationToken.startsWith("Bearer ") ? authorizationToken : `Bearer ${authorizationToken}`;
|
|
371
368
|
return headers2;
|
|
372
369
|
}
|
|
373
|
-
async function
|
|
374
|
-
const url = `${opts.baseApiUrl.replace(/\/$/, "")}
|
|
375
|
-
|
|
370
|
+
async function apiSignIntentV3(request, opts) {
|
|
371
|
+
const url = `${opts.baseApiUrl.replace(/\/$/, "")}/v3/intent`;
|
|
372
|
+
const json = await withRetry(
|
|
376
373
|
async () => {
|
|
377
374
|
let res;
|
|
378
375
|
try {
|
|
@@ -382,7 +379,10 @@ async function postSignIntentWithRetry(endpoint, request, opts) {
|
|
|
382
379
|
body: JSON.stringify(request)
|
|
383
380
|
});
|
|
384
381
|
} catch (error) {
|
|
385
|
-
throw new NetworkError("Failed to connect to API server", {
|
|
382
|
+
throw new NetworkError("Failed to connect to API server", {
|
|
383
|
+
endpoint: "/v3/intent",
|
|
384
|
+
error
|
|
385
|
+
});
|
|
386
386
|
}
|
|
387
387
|
if (!res.ok) {
|
|
388
388
|
const text = await res.text().catch(() => "");
|
|
@@ -394,9 +394,6 @@ async function postSignIntentWithRetry(endpoint, request, opts) {
|
|
|
394
394
|
1e3,
|
|
395
395
|
opts.timeoutMs
|
|
396
396
|
);
|
|
397
|
-
}
|
|
398
|
-
async function apiSignIntentV3(request, opts) {
|
|
399
|
-
const json = await postSignIntentWithRetry("/v3/intent", request, opts);
|
|
400
397
|
const sig = json?.responseObject?.signedIntent;
|
|
401
398
|
const expStr = json?.responseObject?.intentData?.signatureExpiration ?? json?.responseObject?.signatureExpiration;
|
|
402
399
|
const preIntentHookData = json?.responseObject?.intentData?.preIntentHookData ?? json?.responseObject?.preIntentHookData;
|
|
@@ -407,22 +404,6 @@ async function apiSignIntentV3(request, opts) {
|
|
|
407
404
|
preIntentHookData
|
|
408
405
|
};
|
|
409
406
|
}
|
|
410
|
-
async function apiSignIntentV2(request, opts) {
|
|
411
|
-
const json = await postSignIntentWithRetry(
|
|
412
|
-
"/v2/verify/intent",
|
|
413
|
-
request,
|
|
414
|
-
opts
|
|
415
|
-
);
|
|
416
|
-
const sig = json?.responseObject?.signedIntent;
|
|
417
|
-
const expStr = json?.responseObject?.intentData?.signatureExpiration ?? json?.responseObject?.signatureExpiration;
|
|
418
|
-
const preIntentHookData = json?.responseObject?.intentData?.preIntentHookData ?? json?.responseObject?.preIntentHookData;
|
|
419
|
-
if (!sig || !expStr) throw new Error("verify/intent missing signature or expiration");
|
|
420
|
-
return {
|
|
421
|
-
signature: sig,
|
|
422
|
-
signatureExpiration: BigInt(expStr),
|
|
423
|
-
preIntentHookData
|
|
424
|
-
};
|
|
425
|
-
}
|
|
426
407
|
|
|
427
408
|
// src/adapters/attestation.ts
|
|
428
409
|
function headers() {
|
|
@@ -810,59 +791,7 @@ function resolvePlatformAttestationConfig(platformName) {
|
|
|
810
791
|
return config;
|
|
811
792
|
}
|
|
812
793
|
|
|
813
|
-
// src/utils/logger.ts
|
|
814
|
-
var currentLevel = "info";
|
|
815
|
-
function setLogLevel(level) {
|
|
816
|
-
currentLevel = level;
|
|
817
|
-
}
|
|
818
|
-
function shouldLog(level) {
|
|
819
|
-
switch (currentLevel) {
|
|
820
|
-
case "debug":
|
|
821
|
-
return true;
|
|
822
|
-
case "info":
|
|
823
|
-
return level !== "debug";
|
|
824
|
-
case "error":
|
|
825
|
-
return level === "error";
|
|
826
|
-
default:
|
|
827
|
-
return true;
|
|
828
|
-
}
|
|
829
|
-
}
|
|
830
|
-
var logger = {
|
|
831
|
-
debug: (...args) => {
|
|
832
|
-
if (shouldLog("debug")) {
|
|
833
|
-
console.log("[DEBUG]", ...args);
|
|
834
|
-
}
|
|
835
|
-
},
|
|
836
|
-
info: (...args) => {
|
|
837
|
-
if (shouldLog("info")) {
|
|
838
|
-
console.log("[INFO]", ...args);
|
|
839
|
-
}
|
|
840
|
-
},
|
|
841
|
-
warn: (...args) => {
|
|
842
|
-
if (shouldLog("info")) {
|
|
843
|
-
console.warn("[WARN]", ...args);
|
|
844
|
-
}
|
|
845
|
-
},
|
|
846
|
-
error: (...args) => {
|
|
847
|
-
console.error("[ERROR]", ...args);
|
|
848
|
-
}
|
|
849
|
-
};
|
|
850
|
-
|
|
851
794
|
// 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
|
-
}
|
|
866
795
|
var IntentOperations = class {
|
|
867
796
|
constructor(config) {
|
|
868
797
|
this.config = config;
|
|
@@ -877,18 +806,14 @@ var IntentOperations = class {
|
|
|
877
806
|
"signalIntent referrerFeeConfig cannot be combined with referralFees, referrer, or referrerFee."
|
|
878
807
|
);
|
|
879
808
|
}
|
|
880
|
-
const preferV2 = this.config.getDefaultPreferV2();
|
|
881
809
|
const escrowContext = this.config.host.resolveEscrowContext({
|
|
882
810
|
escrowAddress: params.escrowAddress,
|
|
883
|
-
depositId: params.depositId
|
|
884
|
-
preferV2
|
|
811
|
+
depositId: params.depositId
|
|
885
812
|
});
|
|
886
813
|
const orchestratorContext = await this.config.host.resolveOrchestratorContext({
|
|
887
814
|
orchestratorAddress: params.orchestratorAddress,
|
|
888
|
-
escrowAddress: escrowContext.address
|
|
889
|
-
preferV2
|
|
815
|
+
escrowAddress: escrowContext.address
|
|
890
816
|
});
|
|
891
|
-
const useV2Encoding = isV2SignalIntentAbi(orchestratorContext.abi);
|
|
892
817
|
const catalog = getPaymentMethodsCatalog(this.config.getChainId(), this.config.getRuntimeEnv());
|
|
893
818
|
const paymentMethod = resolvePaymentMethodHashFromCatalog(params.processorName, catalog);
|
|
894
819
|
const fiatCurrency = resolveFiatCurrencyBytes32(params.fiatCurrencyCode);
|
|
@@ -907,28 +832,25 @@ var IntentOperations = class {
|
|
|
907
832
|
const apiKey = this.config.getApiKey();
|
|
908
833
|
const authorizationToken = this.config.getAuthorizationToken();
|
|
909
834
|
if ((!gatingServiceSignature || !signatureExpiration) && baseApiUrl && (apiKey || authorizationToken)) {
|
|
910
|
-
const baseRequest = {
|
|
911
|
-
processorName: params.processorName,
|
|
912
|
-
payeeDetails: params.payeeDetails,
|
|
913
|
-
depositId: depositId.toString(),
|
|
914
|
-
amount: amount.toString(),
|
|
915
|
-
toAddress: params.toAddress,
|
|
916
|
-
paymentMethod,
|
|
917
|
-
fiatCurrency,
|
|
918
|
-
conversionRate: conversionRate.toString(),
|
|
919
|
-
chainId: this.config.getChainId().toString(),
|
|
920
|
-
orchestratorAddress: orchestratorContext.address,
|
|
921
|
-
escrowAddress: escrowContext.address
|
|
922
|
-
};
|
|
923
835
|
const apiOpts = {
|
|
924
836
|
baseApiUrl,
|
|
925
837
|
apiKey,
|
|
926
838
|
authorizationToken,
|
|
927
839
|
timeoutMs: this.config.getApiTimeoutMs()
|
|
928
840
|
};
|
|
929
|
-
const response =
|
|
841
|
+
const response = await apiSignIntentV3(
|
|
930
842
|
{
|
|
931
|
-
|
|
843
|
+
processorName: params.processorName,
|
|
844
|
+
payeeDetails: params.payeeDetails,
|
|
845
|
+
depositId: depositId.toString(),
|
|
846
|
+
amount: amount.toString(),
|
|
847
|
+
toAddress: params.toAddress,
|
|
848
|
+
paymentMethod,
|
|
849
|
+
fiatCurrency,
|
|
850
|
+
conversionRate: conversionRate.toString(),
|
|
851
|
+
chainId: this.config.getChainId().toString(),
|
|
852
|
+
orchestratorAddress: orchestratorContext.address,
|
|
853
|
+
escrowAddress: escrowContext.address,
|
|
932
854
|
callerAddress: this.config.getWalletClient().account.address,
|
|
933
855
|
referralFees: referralFees.map((referralFee) => ({
|
|
934
856
|
recipient: referralFee.recipient,
|
|
@@ -936,7 +858,7 @@ var IntentOperations = class {
|
|
|
936
858
|
}))
|
|
937
859
|
},
|
|
938
860
|
apiOpts
|
|
939
|
-
)
|
|
861
|
+
);
|
|
940
862
|
gatingServiceSignature = response.signature;
|
|
941
863
|
signatureExpiration = response.signatureExpiration;
|
|
942
864
|
preIntentHookData = response.preIntentHookData ?? preIntentHookData;
|
|
@@ -944,31 +866,22 @@ var IntentOperations = class {
|
|
|
944
866
|
if (!gatingServiceSignature || !signatureExpiration) {
|
|
945
867
|
throw new Error("Missing gatingServiceSignature/signatureExpiration");
|
|
946
868
|
}
|
|
947
|
-
const
|
|
948
|
-
escrow: escrowContext.address,
|
|
949
|
-
depositId,
|
|
950
|
-
amount,
|
|
951
|
-
to: params.toAddress,
|
|
952
|
-
paymentMethod,
|
|
953
|
-
fiatCurrency,
|
|
954
|
-
conversionRate,
|
|
955
|
-
gatingServiceSignature,
|
|
956
|
-
signatureExpiration: typeof signatureExpiration === "bigint" ? signatureExpiration : BigInt(signatureExpiration),
|
|
957
|
-
postIntentHook: params.postIntentHook ?? ZERO_ADDRESS,
|
|
958
|
-
data: params.data ?? "0x"
|
|
959
|
-
};
|
|
960
|
-
const args = useV2Encoding ? [
|
|
869
|
+
const args = [
|
|
961
870
|
{
|
|
962
|
-
|
|
871
|
+
escrow: escrowContext.address,
|
|
872
|
+
depositId,
|
|
873
|
+
amount,
|
|
874
|
+
to: params.toAddress,
|
|
875
|
+
paymentMethod,
|
|
876
|
+
fiatCurrency,
|
|
877
|
+
conversionRate,
|
|
878
|
+
gatingServiceSignature,
|
|
879
|
+
signatureExpiration: typeof signatureExpiration === "bigint" ? signatureExpiration : BigInt(signatureExpiration),
|
|
880
|
+
postIntentHook: params.postIntentHook ?? ZERO_ADDRESS,
|
|
881
|
+
data: params.data ?? "0x",
|
|
963
882
|
referralFees,
|
|
964
883
|
preIntentHookData: preIntentHookData ?? "0x"
|
|
965
884
|
}
|
|
966
|
-
] : [
|
|
967
|
-
{
|
|
968
|
-
...commonFields,
|
|
969
|
-
referrer: referralFees[0]?.recipient ?? ZERO_ADDRESS,
|
|
970
|
-
referrerFee: referralFees[0]?.fee ?? 0n
|
|
971
|
-
}
|
|
972
885
|
];
|
|
973
886
|
const { referrer } = params.txOverrides ?? {};
|
|
974
887
|
const data = encodeWithAttribution(
|
|
@@ -992,8 +905,7 @@ var IntentOperations = class {
|
|
|
992
905
|
async prepareCancelIntent(params) {
|
|
993
906
|
const orchestratorContext = await this.config.host.resolveOrchestratorContext({
|
|
994
907
|
orchestratorAddress: params.orchestratorAddress,
|
|
995
|
-
intentHash: params.intentHash
|
|
996
|
-
preferV2: this.config.getDefaultPreferV2()
|
|
908
|
+
intentHash: params.intentHash
|
|
997
909
|
});
|
|
998
910
|
const args = [params.intentHash];
|
|
999
911
|
const { referrer } = params.txOverrides ?? {};
|
|
@@ -1018,8 +930,7 @@ var IntentOperations = class {
|
|
|
1018
930
|
async prepareReleaseFundsToPayer(params) {
|
|
1019
931
|
const orchestratorContext = await this.config.host.resolveOrchestratorContext({
|
|
1020
932
|
orchestratorAddress: params.orchestratorAddress,
|
|
1021
|
-
intentHash: params.intentHash
|
|
1022
|
-
preferV2: this.config.getDefaultPreferV2()
|
|
933
|
+
intentHash: params.intentHash
|
|
1023
934
|
});
|
|
1024
935
|
const args = [params.intentHash];
|
|
1025
936
|
const { referrer } = params.txOverrides ?? {};
|
|
@@ -1045,13 +956,11 @@ var IntentOperations = class {
|
|
|
1045
956
|
const escrowAddress = this.config.host.resolveEscrowAddressOrThrow(
|
|
1046
957
|
params.escrowAddress,
|
|
1047
958
|
params.depositId,
|
|
1048
|
-
"setDepositPreIntentHook"
|
|
1049
|
-
{ preferV2: this.config.getDefaultPreferV2() }
|
|
959
|
+
"setDepositPreIntentHook"
|
|
1050
960
|
);
|
|
1051
961
|
const orchestratorContext = await this.config.host.resolveOrchestratorContext({
|
|
1052
962
|
orchestratorAddress: params.orchestratorAddress,
|
|
1053
|
-
escrowAddress
|
|
1054
|
-
preferV2: this.config.getDefaultPreferV2()
|
|
963
|
+
escrowAddress
|
|
1055
964
|
});
|
|
1056
965
|
return this.config.host.prepareResolvedOrchestratorTransaction({
|
|
1057
966
|
orchestrator: orchestratorContext,
|
|
@@ -1064,13 +973,11 @@ var IntentOperations = class {
|
|
|
1064
973
|
const escrowAddress = this.config.host.resolveEscrowAddressOrThrow(
|
|
1065
974
|
params.escrowAddress,
|
|
1066
975
|
params.depositId,
|
|
1067
|
-
"setDepositWhitelistHook"
|
|
1068
|
-
{ preferV2: this.config.getDefaultPreferV2() }
|
|
976
|
+
"setDepositWhitelistHook"
|
|
1069
977
|
);
|
|
1070
978
|
const orchestratorContext = await this.config.host.resolveOrchestratorContext({
|
|
1071
979
|
orchestratorAddress: params.orchestratorAddress,
|
|
1072
|
-
escrowAddress
|
|
1073
|
-
preferV2: this.config.getDefaultPreferV2()
|
|
980
|
+
escrowAddress
|
|
1074
981
|
});
|
|
1075
982
|
return this.config.host.prepareResolvedOrchestratorTransaction({
|
|
1076
983
|
orchestrator: orchestratorContext,
|
|
@@ -1082,8 +989,7 @@ var IntentOperations = class {
|
|
|
1082
989
|
async prepareCleanupOrphanedIntents(params) {
|
|
1083
990
|
const orchestratorContext = await this.config.host.resolveOrchestratorContext({
|
|
1084
991
|
orchestratorAddress: params.orchestratorAddress,
|
|
1085
|
-
escrowAddress: params.escrowAddress
|
|
1086
|
-
preferV2: this.config.getDefaultPreferV2()
|
|
992
|
+
escrowAddress: params.escrowAddress
|
|
1087
993
|
});
|
|
1088
994
|
return this.config.host.prepareResolvedOrchestratorTransaction({
|
|
1089
995
|
orchestrator: orchestratorContext,
|
|
@@ -1096,13 +1002,11 @@ var IntentOperations = class {
|
|
|
1096
1002
|
const escrowAddress = this.config.host.resolveEscrowAddressOrThrow(
|
|
1097
1003
|
options?.escrowAddress,
|
|
1098
1004
|
depositId,
|
|
1099
|
-
"getDepositPreIntentHook"
|
|
1100
|
-
{ preferV2: this.config.getDefaultPreferV2() }
|
|
1005
|
+
"getDepositPreIntentHook"
|
|
1101
1006
|
);
|
|
1102
1007
|
const orchestratorContext = await this.config.host.resolveOrchestratorContext({
|
|
1103
1008
|
orchestratorAddress: options?.orchestratorAddress,
|
|
1104
|
-
escrowAddress
|
|
1105
|
-
preferV2: this.config.getDefaultPreferV2()
|
|
1009
|
+
escrowAddress
|
|
1106
1010
|
});
|
|
1107
1011
|
const functionName = resolveAbiFunctionName(orchestratorContext.abi, [
|
|
1108
1012
|
"getDepositPreIntentHook"
|
|
@@ -1118,13 +1022,11 @@ var IntentOperations = class {
|
|
|
1118
1022
|
const escrowAddress = this.config.host.resolveEscrowAddressOrThrow(
|
|
1119
1023
|
options?.escrowAddress,
|
|
1120
1024
|
depositId,
|
|
1121
|
-
"getDepositWhitelistHook"
|
|
1122
|
-
{ preferV2: this.config.getDefaultPreferV2() }
|
|
1025
|
+
"getDepositWhitelistHook"
|
|
1123
1026
|
);
|
|
1124
1027
|
const orchestratorContext = await this.config.host.resolveOrchestratorContext({
|
|
1125
1028
|
orchestratorAddress: options?.orchestratorAddress,
|
|
1126
|
-
escrowAddress
|
|
1127
|
-
preferV2: this.config.getDefaultPreferV2()
|
|
1029
|
+
escrowAddress
|
|
1128
1030
|
});
|
|
1129
1031
|
const functionName = resolveAbiFunctionName(orchestratorContext.abi, [
|
|
1130
1032
|
"getDepositWhitelistHook"
|
|
@@ -1140,8 +1042,7 @@ var IntentOperations = class {
|
|
|
1140
1042
|
const intentHash = params.intentHash;
|
|
1141
1043
|
const orchestratorContext = await this.config.host.resolveOrchestratorContext({
|
|
1142
1044
|
orchestratorAddress: params.orchestratorAddress,
|
|
1143
|
-
intentHash
|
|
1144
|
-
preferV2: this.config.getDefaultPreferV2()
|
|
1045
|
+
intentHash
|
|
1145
1046
|
});
|
|
1146
1047
|
const precomputed = params.precomputedAttestation;
|
|
1147
1048
|
let paymentProof;
|
|
@@ -1154,7 +1055,9 @@ var IntentOperations = class {
|
|
|
1154
1055
|
verificationData = precomputed.verificationData;
|
|
1155
1056
|
} else {
|
|
1156
1057
|
const attestationServiceUrl = params.attestationServiceUrl ?? this.defaultAttestationService();
|
|
1157
|
-
const inputs = await this.config.host.getFulfillIntentInputs(intentHash
|
|
1058
|
+
const inputs = await this.config.host.getFulfillIntentInputs(intentHash, {
|
|
1059
|
+
orchestratorAddress: orchestratorContext.address
|
|
1060
|
+
});
|
|
1158
1061
|
const paymentMethodHash = inputs.paymentMethodHash || "0x";
|
|
1159
1062
|
const catalog = getPaymentMethodsCatalog(
|
|
1160
1063
|
this.config.getChainId(),
|
|
@@ -1224,31 +1127,30 @@ var IntentOperations = class {
|
|
|
1224
1127
|
defaultAttestationService() {
|
|
1225
1128
|
return this.config.getRuntimeEnv() === "staging" ? "https://attestation-service-staging.zkp2p.xyz" : "https://attestation-service.zkp2p.xyz";
|
|
1226
1129
|
}
|
|
1227
|
-
async getFulfillIntentInputs(intentHash) {
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1130
|
+
async getFulfillIntentInputs(intentHash, options) {
|
|
1131
|
+
const isCurrentOrchestrator = !options?.orchestratorAddress || options.orchestratorAddress.toLowerCase() === this.config.getOrchestratorV2Address()?.toLowerCase();
|
|
1132
|
+
if (isCurrentOrchestrator) {
|
|
1133
|
+
try {
|
|
1134
|
+
if (this.config.getProtocolViewerAddress() && this.config.getProtocolViewerAbi()) {
|
|
1135
|
+
const view = await this.config.host.getPvIntent(intentHash);
|
|
1136
|
+
const paymentMethodHash = view.intent.paymentMethod.toLowerCase();
|
|
1137
|
+
const matched = (view.deposit.paymentMethods || []).find(
|
|
1138
|
+
(pm) => pm.paymentMethod?.toLowerCase?.() === paymentMethodHash
|
|
1139
|
+
);
|
|
1140
|
+
const payee2 = matched?.verificationData?.payeeDetails;
|
|
1141
|
+
if (payee2) {
|
|
1142
|
+
return {
|
|
1143
|
+
amount: view.intent.amount.toString(),
|
|
1144
|
+
fiatCurrency: view.intent.fiatCurrency,
|
|
1145
|
+
conversionRate: view.intent.conversionRate.toString(),
|
|
1146
|
+
payeeDetails: payee2,
|
|
1147
|
+
intentTimestampMs: (BigInt(view.intent.timestamp) * 1000n).toString(),
|
|
1148
|
+
paymentMethodHash: view.intent.paymentMethod
|
|
1149
|
+
};
|
|
1150
|
+
}
|
|
1245
1151
|
}
|
|
1152
|
+
} catch {
|
|
1246
1153
|
}
|
|
1247
|
-
} catch (error) {
|
|
1248
|
-
logger.debug("ProtocolViewer lookup failed, falling back to indexer", {
|
|
1249
|
-
intentHash,
|
|
1250
|
-
error: error instanceof Error ? error.message : String(error)
|
|
1251
|
-
});
|
|
1252
1154
|
}
|
|
1253
1155
|
const response = await this.config.getIndexerClient().query({
|
|
1254
1156
|
query: (
|
|
@@ -1537,7 +1439,7 @@ var ProtocolViewerReader = class {
|
|
|
1537
1439
|
if (inputCount === null) {
|
|
1538
1440
|
throw new Error("Configured ProtocolViewer ABI does not expose getDeposit");
|
|
1539
1441
|
}
|
|
1540
|
-
const { parseDepositView: parseDepositView2 } = await import('./protocolViewerParsers-
|
|
1442
|
+
const { parseDepositView: parseDepositView2 } = await import('./protocolViewerParsers-TPB47QOH.mjs');
|
|
1541
1443
|
if (inputCount >= 3) {
|
|
1542
1444
|
return tryContexts(
|
|
1543
1445
|
protocolViewerContexts,
|
|
@@ -1616,7 +1518,7 @@ var ProtocolViewerReader = class {
|
|
|
1616
1518
|
return Promise.all(ids.map((id) => this.config.host.getPvDepositById(id)));
|
|
1617
1519
|
}
|
|
1618
1520
|
const bn = ids.map((id) => typeof id === "bigint" ? id : parseRawDepositId(id));
|
|
1619
|
-
const { parseDepositView: parseDepositView2 } = await import('./protocolViewerParsers-
|
|
1521
|
+
const { parseDepositView: parseDepositView2 } = await import('./protocolViewerParsers-TPB47QOH.mjs');
|
|
1620
1522
|
if (inputCount >= 2) {
|
|
1621
1523
|
const requests = ids.map((id, index) => ({
|
|
1622
1524
|
index,
|
|
@@ -1721,7 +1623,7 @@ var ProtocolViewerReader = class {
|
|
|
1721
1623
|
if (!protocolViewerAddress || !protocolViewerAbi || inputCount === null) {
|
|
1722
1624
|
return this.config.host.getPvAccountDepositsFromIndexer(owner);
|
|
1723
1625
|
}
|
|
1724
|
-
const { parseDepositView: parseDepositView2 } = await import('./protocolViewerParsers-
|
|
1626
|
+
const { parseDepositView: parseDepositView2 } = await import('./protocolViewerParsers-TPB47QOH.mjs');
|
|
1725
1627
|
const { address, abi } = this.config.host.requireProtocolViewer();
|
|
1726
1628
|
if (inputCount >= 2) {
|
|
1727
1629
|
const readAndFilter = async (raw2) => {
|
|
@@ -1792,7 +1694,7 @@ var ProtocolViewerReader = class {
|
|
|
1792
1694
|
if (protocolViewerEntries.length === 0) {
|
|
1793
1695
|
throw new Error("ProtocolViewer not available for this network");
|
|
1794
1696
|
}
|
|
1795
|
-
const { parseIntentView: parseIntentView2 } = await import('./protocolViewerParsers-
|
|
1697
|
+
const { parseIntentView: parseIntentView2 } = await import('./protocolViewerParsers-TPB47QOH.mjs');
|
|
1796
1698
|
const intentsByHash = /* @__PURE__ */ new Map();
|
|
1797
1699
|
let attemptedRead = false;
|
|
1798
1700
|
let hadSuccessfulRead = false;
|
|
@@ -1900,7 +1802,7 @@ var ProtocolViewerReader = class {
|
|
|
1900
1802
|
if (protocolViewerEntries.length === 0) {
|
|
1901
1803
|
throw new Error("ProtocolViewer not available for this network");
|
|
1902
1804
|
}
|
|
1903
|
-
const { parseIntentView: parseIntentView2 } = await import('./protocolViewerParsers-
|
|
1805
|
+
const { parseIntentView: parseIntentView2 } = await import('./protocolViewerParsers-TPB47QOH.mjs');
|
|
1904
1806
|
let lastError;
|
|
1905
1807
|
for (const pvEntry of protocolViewerEntries) {
|
|
1906
1808
|
const inputCount = this.pvEntryFunctionInputCount(pvEntry, "getIntent");
|
|
@@ -1962,8 +1864,7 @@ var VaultOperations = class {
|
|
|
1962
1864
|
}
|
|
1963
1865
|
supportsInlineOracleRateConfig(params) {
|
|
1964
1866
|
const escrowContext = this.config.host.resolveEscrowContext({
|
|
1965
|
-
escrowAddress: params?.escrowAddress
|
|
1966
|
-
preferV2: params?.preferV2
|
|
1867
|
+
escrowAddress: params?.escrowAddress
|
|
1967
1868
|
});
|
|
1968
1869
|
return escrowCurrencyHasOracleConfig(escrowContext.abi);
|
|
1969
1870
|
}
|
|
@@ -2080,8 +1981,7 @@ var VaultOperations = class {
|
|
|
2080
1981
|
prepareSetOracleRateConfigTransaction(params) {
|
|
2081
1982
|
const escrowContext = this.config.host.resolveEscrowContext({
|
|
2082
1983
|
escrowAddress: params.escrowAddress,
|
|
2083
|
-
depositId: params.depositId
|
|
2084
|
-
preferV2: true
|
|
1984
|
+
depositId: params.depositId
|
|
2085
1985
|
});
|
|
2086
1986
|
if (escrowContext.version !== "v2") {
|
|
2087
1987
|
throw new Error("setOracleRateConfig requires EscrowV2");
|
|
@@ -2103,8 +2003,7 @@ var VaultOperations = class {
|
|
|
2103
2003
|
prepareRemoveOracleRateConfigTransaction(params) {
|
|
2104
2004
|
const escrowContext = this.config.host.resolveEscrowContext({
|
|
2105
2005
|
escrowAddress: params.escrowAddress,
|
|
2106
|
-
depositId: params.depositId
|
|
2107
|
-
preferV2: true
|
|
2006
|
+
depositId: params.depositId
|
|
2108
2007
|
});
|
|
2109
2008
|
if (escrowContext.version !== "v2") {
|
|
2110
2009
|
throw new Error("removeOracleRateConfig requires EscrowV2");
|
|
@@ -2121,8 +2020,7 @@ var VaultOperations = class {
|
|
|
2121
2020
|
prepareSetOracleRateConfigBatchTransaction(params) {
|
|
2122
2021
|
const escrowContext = this.config.host.resolveEscrowContext({
|
|
2123
2022
|
escrowAddress: params.escrowAddress,
|
|
2124
|
-
depositId: params.depositId
|
|
2125
|
-
preferV2: true
|
|
2023
|
+
depositId: params.depositId
|
|
2126
2024
|
});
|
|
2127
2025
|
if (escrowContext.version !== "v2") {
|
|
2128
2026
|
throw new Error("setOracleRateConfigBatch requires EscrowV2");
|
|
@@ -2144,8 +2042,7 @@ var VaultOperations = class {
|
|
|
2144
2042
|
prepareUpdateCurrencyConfigBatchTransaction(params) {
|
|
2145
2043
|
const escrowContext = this.config.host.resolveEscrowContext({
|
|
2146
2044
|
escrowAddress: params.escrowAddress,
|
|
2147
|
-
depositId: params.depositId
|
|
2148
|
-
preferV2: true
|
|
2045
|
+
depositId: params.depositId
|
|
2149
2046
|
});
|
|
2150
2047
|
if (escrowContext.version !== "v2") {
|
|
2151
2048
|
throw new Error("updateCurrencyConfigBatch requires EscrowV2");
|
|
@@ -2173,8 +2070,7 @@ var VaultOperations = class {
|
|
|
2173
2070
|
prepareDeactivateCurrenciesBatchTransaction(params) {
|
|
2174
2071
|
const escrowContext = this.config.host.resolveEscrowContext({
|
|
2175
2072
|
escrowAddress: params.escrowAddress,
|
|
2176
|
-
depositId: params.depositId
|
|
2177
|
-
preferV2: true
|
|
2073
|
+
depositId: params.depositId
|
|
2178
2074
|
});
|
|
2179
2075
|
if (escrowContext.version !== "v2") {
|
|
2180
2076
|
throw new Error("deactivateCurrenciesBatch requires EscrowV2");
|
|
@@ -3977,6 +3873,7 @@ var IndexerDepositService = class {
|
|
|
3977
3873
|
// src/indexer/rateManagerService.ts
|
|
3978
3874
|
var DEFAULT_LIMIT2 = 50;
|
|
3979
3875
|
var RATE_MANAGER_HISTORY_PAGE_SIZE = 250;
|
|
3876
|
+
var EVM_ADDRESS_REGEX = /^0x[a-f0-9]{40}$/;
|
|
3980
3877
|
function normalizeRateManagerId2(value) {
|
|
3981
3878
|
if (!value) return "";
|
|
3982
3879
|
return value.toLowerCase();
|
|
@@ -3985,6 +3882,9 @@ function normalizeAddress3(value) {
|
|
|
3985
3882
|
if (!value) return "";
|
|
3986
3883
|
return value.toLowerCase();
|
|
3987
3884
|
}
|
|
3885
|
+
function escapeLikePatternLiteral(value) {
|
|
3886
|
+
return value.replace(/\\/g, "\\\\").replace(/%/g, "\\%").replace(/_/g, "\\_");
|
|
3887
|
+
}
|
|
3988
3888
|
function parseScopedRateManagerFilterId(value) {
|
|
3989
3889
|
const trimmed = value.trim().toLowerCase();
|
|
3990
3890
|
if (!trimmed) return null;
|
|
@@ -3992,7 +3892,7 @@ function parseScopedRateManagerFilterId(value) {
|
|
|
3992
3892
|
if (separatorIndex <= 0) return null;
|
|
3993
3893
|
const rateManagerAddress = normalizeAddress3(trimmed.slice(0, separatorIndex));
|
|
3994
3894
|
const rateManagerId = normalizeRateManagerId2(trimmed.slice(separatorIndex + 1));
|
|
3995
|
-
if (!
|
|
3895
|
+
if (!EVM_ADDRESS_REGEX.test(rateManagerAddress) || !rateManagerId) {
|
|
3996
3896
|
return null;
|
|
3997
3897
|
}
|
|
3998
3898
|
return { rateManagerAddress, rateManagerId };
|
|
@@ -4010,12 +3910,14 @@ function extractRateManagerAddressFromScopedId(id) {
|
|
|
4010
3910
|
return rateManagerAddress.startsWith("0x") ? rateManagerAddress.toLowerCase() : null;
|
|
4011
3911
|
}
|
|
4012
3912
|
function buildRateManagerAddressScopedIdPattern(rateManagerId, rateManagerAddress) {
|
|
4013
|
-
const normalizedId = normalizeRateManagerId2(rateManagerId);
|
|
4014
|
-
const normalizedRateManagerAddress =
|
|
4015
|
-
|
|
3913
|
+
const normalizedId = escapeLikePatternLiteral(normalizeRateManagerId2(rateManagerId));
|
|
3914
|
+
const normalizedRateManagerAddress = escapeLikePatternLiteral(
|
|
3915
|
+
normalizeAddress3(rateManagerAddress)
|
|
3916
|
+
);
|
|
3917
|
+
return `%\\_${normalizedRateManagerAddress}\\_${normalizedId}`;
|
|
4016
3918
|
}
|
|
4017
3919
|
function buildRateManagerScopedIdPattern(rateManagerId, rateManagerAddress) {
|
|
4018
|
-
return `${buildRateManagerAddressScopedIdPattern(rateManagerId, rateManagerAddress)}_%`;
|
|
3920
|
+
return `${buildRateManagerAddressScopedIdPattern(rateManagerId, rateManagerAddress)}\\_%`;
|
|
4019
3921
|
}
|
|
4020
3922
|
function normalizeCompositeDepositId(depositId, escrowAddress) {
|
|
4021
3923
|
const normalizedDepositId = depositId.trim().toLowerCase();
|
|
@@ -4050,6 +3952,9 @@ function parseRateManagerFilterIds(rateManagerIds) {
|
|
|
4050
3952
|
);
|
|
4051
3953
|
continue;
|
|
4052
3954
|
}
|
|
3955
|
+
if (value.includes(":")) {
|
|
3956
|
+
continue;
|
|
3957
|
+
}
|
|
4053
3958
|
const normalizedRateManagerId = normalizeRateManagerId2(value);
|
|
4054
3959
|
if (normalizedRateManagerId) {
|
|
4055
3960
|
bare.add(normalizedRateManagerId);
|
|
@@ -4588,21 +4493,12 @@ var IndexerRateManagerService = class {
|
|
|
4588
4493
|
async fetchManualRateUpdates(rateManagerId, options) {
|
|
4589
4494
|
if (!rateManagerId) return [];
|
|
4590
4495
|
const normalizedId = normalizeRateManagerId2(rateManagerId);
|
|
4591
|
-
const normalizedRateManagerAddress = normalizeAddress3(options?.rateManagerAddress);
|
|
4592
4496
|
try {
|
|
4593
4497
|
const result = await this.client.query({
|
|
4594
4498
|
query: MANUAL_RATE_UPDATES_QUERY,
|
|
4595
4499
|
variables: {
|
|
4596
4500
|
where: {
|
|
4597
|
-
rateManagerId: { _eq: normalizedId }
|
|
4598
|
-
...normalizedRateManagerAddress ? {
|
|
4599
|
-
id: {
|
|
4600
|
-
_ilike: buildRateManagerScopedIdPattern(
|
|
4601
|
-
normalizedId,
|
|
4602
|
-
normalizedRateManagerAddress
|
|
4603
|
-
)
|
|
4604
|
-
}
|
|
4605
|
-
} : {}
|
|
4501
|
+
rateManagerId: { _eq: normalizedId }
|
|
4606
4502
|
},
|
|
4607
4503
|
order_by: [{ id: "desc" }],
|
|
4608
4504
|
limit: options?.limit ?? 100
|
|
@@ -4676,15 +4572,7 @@ var IndexerRateManagerService = class {
|
|
|
4676
4572
|
query: LEGACY_ORACLE_CONFIG_UPDATES_QUERY,
|
|
4677
4573
|
variables: {
|
|
4678
4574
|
where: {
|
|
4679
|
-
rateManagerId: { _eq: normalizedId }
|
|
4680
|
-
...normalizedRateManagerAddress ? {
|
|
4681
|
-
id: {
|
|
4682
|
-
_ilike: buildRateManagerScopedIdPattern(
|
|
4683
|
-
normalizedId,
|
|
4684
|
-
normalizedRateManagerAddress
|
|
4685
|
-
)
|
|
4686
|
-
}
|
|
4687
|
-
} : {}
|
|
4575
|
+
rateManagerId: { _eq: normalizedId }
|
|
4688
4576
|
},
|
|
4689
4577
|
order_by: [{ id: "desc" }],
|
|
4690
4578
|
limit
|
|
@@ -6080,13 +5968,13 @@ var Zkp2pClient = class {
|
|
|
6080
5968
|
getProtocolViewerAbi: () => this.protocolViewerAbi,
|
|
6081
5969
|
getIndexerClient: () => this._indexerClient,
|
|
6082
5970
|
getIndexerService: () => this._indexerService,
|
|
6083
|
-
|
|
5971
|
+
getOrchestratorV2Address: () => this.orchestratorV2Address,
|
|
6084
5972
|
host: {
|
|
6085
5973
|
resolveEscrowContext: (options) => this.resolveEscrowContext(options),
|
|
6086
5974
|
resolveOrchestratorContext: (options) => this.resolveOrchestratorContext(options),
|
|
6087
|
-
resolveEscrowAddressOrThrow: (escrowAddress, depositId, methodName
|
|
5975
|
+
resolveEscrowAddressOrThrow: (escrowAddress, depositId, methodName) => this.resolveEscrowAddressOrThrow(escrowAddress, depositId, methodName),
|
|
6088
5976
|
prepareResolvedOrchestratorTransaction: (tx) => this.prepareResolvedOrchestratorTransaction(tx),
|
|
6089
|
-
getFulfillIntentInputs: (intentHash) => this.getFulfillIntentInputs(intentHash),
|
|
5977
|
+
getFulfillIntentInputs: (intentHash, options) => this.getFulfillIntentInputs(intentHash, options),
|
|
6090
5978
|
getPvIntent: (intentHash) => this.getPvIntent(intentHash)
|
|
6091
5979
|
}
|
|
6092
5980
|
});
|
|
@@ -6118,8 +6006,7 @@ var Zkp2pClient = class {
|
|
|
6118
6006
|
}
|
|
6119
6007
|
supportsInlineOracleRateConfig(params) {
|
|
6120
6008
|
return this._vaultOps.supportsInlineOracleRateConfig({
|
|
6121
|
-
escrowAddress: params?.escrowAddress
|
|
6122
|
-
preferV2: params?.preferV2 ?? this._router.defaultPreferV2
|
|
6009
|
+
escrowAddress: params?.escrowAddress
|
|
6123
6010
|
});
|
|
6124
6011
|
}
|
|
6125
6012
|
parseManagerFeeFromRead(result) {
|
|
@@ -6137,13 +6024,10 @@ var Zkp2pClient = class {
|
|
|
6137
6024
|
abiFunctionHasInput(abi, functionName, inputName) {
|
|
6138
6025
|
return abiFunctionHasInput(abi, functionName, inputName);
|
|
6139
6026
|
}
|
|
6140
|
-
resolveEscrowAddressOrThrow(escrowAddress, depositId,
|
|
6027
|
+
resolveEscrowAddressOrThrow(escrowAddress, depositId, _methodName) {
|
|
6141
6028
|
const resolved = escrowAddress ?? this.parseEscrowAddressFromCompositeDepositId(depositId);
|
|
6142
6029
|
if (resolved) return resolved;
|
|
6143
|
-
|
|
6144
|
-
return this.resolveEscrowContext().address;
|
|
6145
|
-
}
|
|
6146
|
-
throw new Error(`${methodName} requires escrowAddress or composite depositId`);
|
|
6030
|
+
return this.resolveEscrowContext().address;
|
|
6147
6031
|
}
|
|
6148
6032
|
prepareCreateRateManagerTransaction(params) {
|
|
6149
6033
|
return this._vaultOps.prepareCreateRateManagerTransaction(params);
|
|
@@ -6231,8 +6115,8 @@ var Zkp2pClient = class {
|
|
|
6231
6115
|
getEscrowContexts() {
|
|
6232
6116
|
return this._router.getEscrowContexts();
|
|
6233
6117
|
}
|
|
6234
|
-
resolveOrchestratorForEscrow(escrowAddress
|
|
6235
|
-
return this._router.resolveOrchestratorForEscrow(escrowAddress
|
|
6118
|
+
resolveOrchestratorForEscrow(escrowAddress) {
|
|
6119
|
+
return this._router.resolveOrchestratorForEscrow(escrowAddress);
|
|
6236
6120
|
}
|
|
6237
6121
|
async lookupIntentRouting(intentHash) {
|
|
6238
6122
|
try {
|
|
@@ -6266,12 +6150,8 @@ var Zkp2pClient = class {
|
|
|
6266
6150
|
try {
|
|
6267
6151
|
const view = await this.getPvIntent(intentHash);
|
|
6268
6152
|
return this.normalizeAddress(view?.intent?.escrow);
|
|
6269
|
-
} catch
|
|
6270
|
-
|
|
6271
|
-
return void 0;
|
|
6272
|
-
}
|
|
6273
|
-
const message = error instanceof Error ? error.message : "Unknown on-chain routing error";
|
|
6274
|
-
throw new Error(`Failed to resolve intent escrow on-chain for ${intentHash}: ${message}`);
|
|
6153
|
+
} catch {
|
|
6154
|
+
return void 0;
|
|
6275
6155
|
}
|
|
6276
6156
|
}
|
|
6277
6157
|
warnOrchestratorFallback(intentHash, source, error) {
|
|
@@ -6295,10 +6175,7 @@ var Zkp2pClient = class {
|
|
|
6295
6175
|
const fromIntent = this.getOrchestratorContextByAddress(routing.orchestratorAddress);
|
|
6296
6176
|
if (fromIntent) return fromIntent;
|
|
6297
6177
|
if (routing.escrowAddress) {
|
|
6298
|
-
const fromIntentEscrow = this.resolveOrchestratorForEscrow(
|
|
6299
|
-
routing.escrowAddress,
|
|
6300
|
-
options.preferV2
|
|
6301
|
-
);
|
|
6178
|
+
const fromIntentEscrow = this.resolveOrchestratorForEscrow(routing.escrowAddress);
|
|
6302
6179
|
if (fromIntentEscrow) return fromIntentEscrow;
|
|
6303
6180
|
}
|
|
6304
6181
|
} catch (error) {
|
|
@@ -6307,10 +6184,7 @@ var Zkp2pClient = class {
|
|
|
6307
6184
|
try {
|
|
6308
6185
|
const onchainEscrow = await this.lookupIntentEscrowOnchain(options.intentHash);
|
|
6309
6186
|
if (onchainEscrow) {
|
|
6310
|
-
const fromOnchainEscrow = this.resolveOrchestratorForEscrow(
|
|
6311
|
-
onchainEscrow,
|
|
6312
|
-
options.preferV2
|
|
6313
|
-
);
|
|
6187
|
+
const fromOnchainEscrow = this.resolveOrchestratorForEscrow(onchainEscrow);
|
|
6314
6188
|
if (fromOnchainEscrow) return fromOnchainEscrow;
|
|
6315
6189
|
}
|
|
6316
6190
|
} catch (error) {
|
|
@@ -6318,7 +6192,7 @@ var Zkp2pClient = class {
|
|
|
6318
6192
|
}
|
|
6319
6193
|
}
|
|
6320
6194
|
if (options?.escrowAddress) {
|
|
6321
|
-
const fromEscrow = this.resolveOrchestratorForEscrow(options.escrowAddress
|
|
6195
|
+
const fromEscrow = this.resolveOrchestratorForEscrow(options.escrowAddress);
|
|
6322
6196
|
if (fromEscrow) return fromEscrow;
|
|
6323
6197
|
}
|
|
6324
6198
|
if (options?.intentHash) {
|
|
@@ -6336,7 +6210,7 @@ var Zkp2pClient = class {
|
|
|
6336
6210
|
}
|
|
6337
6211
|
}
|
|
6338
6212
|
}
|
|
6339
|
-
const fallback = this.resolveOrchestratorForEscrow(
|
|
6213
|
+
const fallback = this.resolveOrchestratorForEscrow();
|
|
6340
6214
|
if (fallback) return fallback;
|
|
6341
6215
|
throw new Error("Orchestrator not available");
|
|
6342
6216
|
}
|
|
@@ -6556,8 +6430,7 @@ var Zkp2pClient = class {
|
|
|
6556
6430
|
async (params) => {
|
|
6557
6431
|
const orchestratorContext = await this.resolveOrchestratorContext({
|
|
6558
6432
|
orchestratorAddress: params.orchestratorAddress,
|
|
6559
|
-
escrowAddress: params.escrowAddress
|
|
6560
|
-
preferV2: params.preferV2
|
|
6433
|
+
escrowAddress: params.escrowAddress
|
|
6561
6434
|
});
|
|
6562
6435
|
const prepared = this.prepareOrchestratorTransaction({
|
|
6563
6436
|
functionName,
|
|
@@ -6573,8 +6446,7 @@ var Zkp2pClient = class {
|
|
|
6573
6446
|
prepare: async (params) => {
|
|
6574
6447
|
const orchestratorContext = await this.resolveOrchestratorContext({
|
|
6575
6448
|
orchestratorAddress: params.orchestratorAddress,
|
|
6576
|
-
escrowAddress: params.escrowAddress
|
|
6577
|
-
preferV2: params.preferV2
|
|
6449
|
+
escrowAddress: params.escrowAddress
|
|
6578
6450
|
});
|
|
6579
6451
|
const prepared = this.prepareOrchestratorTransaction({
|
|
6580
6452
|
functionName,
|
|
@@ -6909,7 +6781,6 @@ var Zkp2pClient = class {
|
|
|
6909
6781
|
* @param params.amount - Minimum required allowance amount
|
|
6910
6782
|
* @param params.spender - Spender address override
|
|
6911
6783
|
* @param params.escrowAddress - Escrow context used for default spender resolution
|
|
6912
|
-
* @param params.preferV2 - Prefer EscrowV2 for default spender resolution
|
|
6913
6784
|
* @param params.maxApprove - If true, approves MaxUint256 instead of exact amount
|
|
6914
6785
|
* @param params.txOverrides - Optional viem transaction overrides
|
|
6915
6786
|
* @returns Object with `hadAllowance` (true if no approval needed) and optional `hash`
|
|
@@ -6932,8 +6803,7 @@ var Zkp2pClient = class {
|
|
|
6932
6803
|
const owner = this.walletClient.account?.address;
|
|
6933
6804
|
if (!owner) throw new Error("Wallet client is missing account");
|
|
6934
6805
|
const spender = params.spender ?? this.resolveEscrowContext({
|
|
6935
|
-
escrowAddress: params.escrowAddress
|
|
6936
|
-
preferV2: params.preferV2 ?? this._router.defaultPreferV2
|
|
6806
|
+
escrowAddress: params.escrowAddress
|
|
6937
6807
|
}).address;
|
|
6938
6808
|
const allowance = await this.publicClient.readContract({
|
|
6939
6809
|
address: params.token,
|
|
@@ -7167,8 +7037,7 @@ var Zkp2pClient = class {
|
|
|
7167
7037
|
currencies = mapConversionRatesToOnchainMinRate2(normalized, paymentMethods.length);
|
|
7168
7038
|
}
|
|
7169
7039
|
const escrowContext = this.resolveEscrowContext({
|
|
7170
|
-
escrowAddress: params.escrowAddress
|
|
7171
|
-
preferV2: this._router.defaultPreferV2
|
|
7040
|
+
escrowAddress: params.escrowAddress
|
|
7172
7041
|
});
|
|
7173
7042
|
const normalizedCurrencies = currencies.map(
|
|
7174
7043
|
(group) => this.normalizeCurrencyTuples(group, escrowContext.abi)
|
|
@@ -7488,8 +7357,8 @@ var Zkp2pClient = class {
|
|
|
7488
7357
|
* @returns Intent parameters needed for fulfillment
|
|
7489
7358
|
* @throws Error if intent not found or payee details cannot be resolved
|
|
7490
7359
|
*/
|
|
7491
|
-
async getFulfillIntentInputs(intentHash) {
|
|
7492
|
-
return this._intentOps.getFulfillIntentInputs(intentHash);
|
|
7360
|
+
async getFulfillIntentInputs(intentHash, options) {
|
|
7361
|
+
return this._intentOps.getFulfillIntentInputs(intentHash, options);
|
|
7493
7362
|
}
|
|
7494
7363
|
};
|
|
7495
7364
|
|
|
@@ -7685,6 +7554,44 @@ var createPeerExtensionSdk = (options = {}) => ({
|
|
|
7685
7554
|
});
|
|
7686
7555
|
var peerExtensionSdk = createPeerExtensionSdk();
|
|
7687
7556
|
|
|
7557
|
+
// src/utils/logger.ts
|
|
7558
|
+
var currentLevel = "info";
|
|
7559
|
+
function setLogLevel(level) {
|
|
7560
|
+
currentLevel = level;
|
|
7561
|
+
}
|
|
7562
|
+
function shouldLog(level) {
|
|
7563
|
+
switch (currentLevel) {
|
|
7564
|
+
case "debug":
|
|
7565
|
+
return true;
|
|
7566
|
+
case "info":
|
|
7567
|
+
return level !== "debug";
|
|
7568
|
+
case "error":
|
|
7569
|
+
return level === "error";
|
|
7570
|
+
default:
|
|
7571
|
+
return true;
|
|
7572
|
+
}
|
|
7573
|
+
}
|
|
7574
|
+
var logger = {
|
|
7575
|
+
debug: (...args) => {
|
|
7576
|
+
if (shouldLog("debug")) {
|
|
7577
|
+
console.log("[DEBUG]", ...args);
|
|
7578
|
+
}
|
|
7579
|
+
},
|
|
7580
|
+
info: (...args) => {
|
|
7581
|
+
if (shouldLog("info")) {
|
|
7582
|
+
console.log("[INFO]", ...args);
|
|
7583
|
+
}
|
|
7584
|
+
},
|
|
7585
|
+
warn: (...args) => {
|
|
7586
|
+
if (shouldLog("info")) {
|
|
7587
|
+
console.warn("[WARN]", ...args);
|
|
7588
|
+
}
|
|
7589
|
+
},
|
|
7590
|
+
error: (...args) => {
|
|
7591
|
+
console.error("[ERROR]", ...args);
|
|
7592
|
+
}
|
|
7593
|
+
};
|
|
7594
|
+
|
|
7688
7595
|
export { BASE_BUILDER_CODE, CHAINLINK_ORACLE_ADAPTER, CHAINLINK_ORACLE_FEEDS, ContractRouter, DEFAULT_ORACLE_MAX_STALENESS_SECONDS, IndexerClient, IndexerDepositService, IndexerRateManagerService, Zkp2pClient as OfframpClient, PAYMENT_PLATFORMS, PEER_EXTENSION_CHROME_URL, PLATFORM_METADATA, PYTH_CONTRACT_BASE, PYTH_ORACLE_ADAPTER, PYTH_ORACLE_FEEDS, SPREAD_ORACLE_FEEDS, SUPPORTED_CHAIN_IDS, TOKEN_METADATA, ZKP2P_ANDROID_REFERRER, ZKP2P_IOS_REFERRER, Zkp2pClient, apiGetOwnerDeposits, apiGetPayeeDetails, apiGetTakerTier, apiPostDepositDetails, apiValidatePayeeDetails, appendAttributionToCalldata, assertValidReferrerFeeConfig, compareEventCursorIdsByRecency, convertDepositsForLiquidity, convertIndexerDepositToEscrowView, convertIndexerIntentsToEscrowViews, createCompositeDepositId, createPeerExtensionSdk, defaultIndexerEndpoint, encodePythAdapterConfig, encodeSpreadOracleAdapterConfig, encodeWithAttribution, fetchFulfillmentAndPayment as fetchIndexerFulfillmentAndPayment, getAttributionDataSuffix, getPeerExtensionState, getSpreadOracleConfig, isPeerExtensionAvailable, isValidReferrerFeeBps, isValidReferrerFeeRecipient, logger, openPeerExtensionInstallPage, parseReferrerFeeConfig, peerExtensionSdk, referrerFeeConfigToPreciseUnits, sendTransactionWithAttribution, setLogLevel, validateOracleFeedsOnChain };
|
|
7689
7596
|
//# sourceMappingURL=index.mjs.map
|
|
7690
7597
|
//# sourceMappingURL=index.mjs.map
|