@zkp2p/sdk 0.2.0 → 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 +163 -281
- 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 +160 -238
- 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,44 +791,6 @@ 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
795
|
var IntentOperations = class {
|
|
853
796
|
constructor(config) {
|
|
@@ -863,16 +806,13 @@ var IntentOperations = class {
|
|
|
863
806
|
"signalIntent referrerFeeConfig cannot be combined with referralFees, referrer, or referrerFee."
|
|
864
807
|
);
|
|
865
808
|
}
|
|
866
|
-
const preferV2 = this.config.getDefaultPreferV2();
|
|
867
809
|
const escrowContext = this.config.host.resolveEscrowContext({
|
|
868
810
|
escrowAddress: params.escrowAddress,
|
|
869
|
-
depositId: params.depositId
|
|
870
|
-
preferV2
|
|
811
|
+
depositId: params.depositId
|
|
871
812
|
});
|
|
872
813
|
const orchestratorContext = await this.config.host.resolveOrchestratorContext({
|
|
873
814
|
orchestratorAddress: params.orchestratorAddress,
|
|
874
|
-
escrowAddress: escrowContext.address
|
|
875
|
-
preferV2
|
|
815
|
+
escrowAddress: escrowContext.address
|
|
876
816
|
});
|
|
877
817
|
const catalog = getPaymentMethodsCatalog(this.config.getChainId(), this.config.getRuntimeEnv());
|
|
878
818
|
const paymentMethod = resolvePaymentMethodHashFromCatalog(params.processorName, catalog);
|
|
@@ -892,28 +832,25 @@ var IntentOperations = class {
|
|
|
892
832
|
const apiKey = this.config.getApiKey();
|
|
893
833
|
const authorizationToken = this.config.getAuthorizationToken();
|
|
894
834
|
if ((!gatingServiceSignature || !signatureExpiration) && baseApiUrl && (apiKey || authorizationToken)) {
|
|
895
|
-
const baseRequest = {
|
|
896
|
-
processorName: params.processorName,
|
|
897
|
-
payeeDetails: params.payeeDetails,
|
|
898
|
-
depositId: depositId.toString(),
|
|
899
|
-
amount: amount.toString(),
|
|
900
|
-
toAddress: params.toAddress,
|
|
901
|
-
paymentMethod,
|
|
902
|
-
fiatCurrency,
|
|
903
|
-
conversionRate: conversionRate.toString(),
|
|
904
|
-
chainId: this.config.getChainId().toString(),
|
|
905
|
-
orchestratorAddress: orchestratorContext.address,
|
|
906
|
-
escrowAddress: escrowContext.address
|
|
907
|
-
};
|
|
908
835
|
const apiOpts = {
|
|
909
836
|
baseApiUrl,
|
|
910
837
|
apiKey,
|
|
911
838
|
authorizationToken,
|
|
912
839
|
timeoutMs: this.config.getApiTimeoutMs()
|
|
913
840
|
};
|
|
914
|
-
const response =
|
|
841
|
+
const response = await apiSignIntentV3(
|
|
915
842
|
{
|
|
916
|
-
|
|
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,
|
|
917
854
|
callerAddress: this.config.getWalletClient().account.address,
|
|
918
855
|
referralFees: referralFees.map((referralFee) => ({
|
|
919
856
|
recipient: referralFee.recipient,
|
|
@@ -921,7 +858,7 @@ var IntentOperations = class {
|
|
|
921
858
|
}))
|
|
922
859
|
},
|
|
923
860
|
apiOpts
|
|
924
|
-
)
|
|
861
|
+
);
|
|
925
862
|
gatingServiceSignature = response.signature;
|
|
926
863
|
signatureExpiration = response.signatureExpiration;
|
|
927
864
|
preIntentHookData = response.preIntentHookData ?? preIntentHookData;
|
|
@@ -929,31 +866,22 @@ var IntentOperations = class {
|
|
|
929
866
|
if (!gatingServiceSignature || !signatureExpiration) {
|
|
930
867
|
throw new Error("Missing gatingServiceSignature/signatureExpiration");
|
|
931
868
|
}
|
|
932
|
-
const
|
|
933
|
-
escrow: escrowContext.address,
|
|
934
|
-
depositId,
|
|
935
|
-
amount,
|
|
936
|
-
to: params.toAddress,
|
|
937
|
-
paymentMethod,
|
|
938
|
-
fiatCurrency,
|
|
939
|
-
conversionRate,
|
|
940
|
-
gatingServiceSignature,
|
|
941
|
-
signatureExpiration: typeof signatureExpiration === "bigint" ? signatureExpiration : BigInt(signatureExpiration),
|
|
942
|
-
postIntentHook: params.postIntentHook ?? ZERO_ADDRESS,
|
|
943
|
-
data: params.data ?? "0x"
|
|
944
|
-
};
|
|
945
|
-
const args = orchestratorContext.version === "v2" ? [
|
|
869
|
+
const args = [
|
|
946
870
|
{
|
|
947
|
-
|
|
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",
|
|
948
882
|
referralFees,
|
|
949
883
|
preIntentHookData: preIntentHookData ?? "0x"
|
|
950
884
|
}
|
|
951
|
-
] : [
|
|
952
|
-
{
|
|
953
|
-
...commonFields,
|
|
954
|
-
referrer: referralFees[0]?.recipient ?? ZERO_ADDRESS,
|
|
955
|
-
referrerFee: referralFees[0]?.fee ?? 0n
|
|
956
|
-
}
|
|
957
885
|
];
|
|
958
886
|
const { referrer } = params.txOverrides ?? {};
|
|
959
887
|
const data = encodeWithAttribution(
|
|
@@ -977,8 +905,7 @@ var IntentOperations = class {
|
|
|
977
905
|
async prepareCancelIntent(params) {
|
|
978
906
|
const orchestratorContext = await this.config.host.resolveOrchestratorContext({
|
|
979
907
|
orchestratorAddress: params.orchestratorAddress,
|
|
980
|
-
intentHash: params.intentHash
|
|
981
|
-
preferV2: this.config.getDefaultPreferV2()
|
|
908
|
+
intentHash: params.intentHash
|
|
982
909
|
});
|
|
983
910
|
const args = [params.intentHash];
|
|
984
911
|
const { referrer } = params.txOverrides ?? {};
|
|
@@ -1003,8 +930,7 @@ var IntentOperations = class {
|
|
|
1003
930
|
async prepareReleaseFundsToPayer(params) {
|
|
1004
931
|
const orchestratorContext = await this.config.host.resolveOrchestratorContext({
|
|
1005
932
|
orchestratorAddress: params.orchestratorAddress,
|
|
1006
|
-
intentHash: params.intentHash
|
|
1007
|
-
preferV2: this.config.getDefaultPreferV2()
|
|
933
|
+
intentHash: params.intentHash
|
|
1008
934
|
});
|
|
1009
935
|
const args = [params.intentHash];
|
|
1010
936
|
const { referrer } = params.txOverrides ?? {};
|
|
@@ -1030,13 +956,11 @@ var IntentOperations = class {
|
|
|
1030
956
|
const escrowAddress = this.config.host.resolveEscrowAddressOrThrow(
|
|
1031
957
|
params.escrowAddress,
|
|
1032
958
|
params.depositId,
|
|
1033
|
-
"setDepositPreIntentHook"
|
|
1034
|
-
{ preferV2: this.config.getDefaultPreferV2() }
|
|
959
|
+
"setDepositPreIntentHook"
|
|
1035
960
|
);
|
|
1036
961
|
const orchestratorContext = await this.config.host.resolveOrchestratorContext({
|
|
1037
962
|
orchestratorAddress: params.orchestratorAddress,
|
|
1038
|
-
escrowAddress
|
|
1039
|
-
preferV2: this.config.getDefaultPreferV2()
|
|
963
|
+
escrowAddress
|
|
1040
964
|
});
|
|
1041
965
|
return this.config.host.prepareResolvedOrchestratorTransaction({
|
|
1042
966
|
orchestrator: orchestratorContext,
|
|
@@ -1049,13 +973,11 @@ var IntentOperations = class {
|
|
|
1049
973
|
const escrowAddress = this.config.host.resolveEscrowAddressOrThrow(
|
|
1050
974
|
params.escrowAddress,
|
|
1051
975
|
params.depositId,
|
|
1052
|
-
"setDepositWhitelistHook"
|
|
1053
|
-
{ preferV2: this.config.getDefaultPreferV2() }
|
|
976
|
+
"setDepositWhitelistHook"
|
|
1054
977
|
);
|
|
1055
978
|
const orchestratorContext = await this.config.host.resolveOrchestratorContext({
|
|
1056
979
|
orchestratorAddress: params.orchestratorAddress,
|
|
1057
|
-
escrowAddress
|
|
1058
|
-
preferV2: this.config.getDefaultPreferV2()
|
|
980
|
+
escrowAddress
|
|
1059
981
|
});
|
|
1060
982
|
return this.config.host.prepareResolvedOrchestratorTransaction({
|
|
1061
983
|
orchestrator: orchestratorContext,
|
|
@@ -1067,8 +989,7 @@ var IntentOperations = class {
|
|
|
1067
989
|
async prepareCleanupOrphanedIntents(params) {
|
|
1068
990
|
const orchestratorContext = await this.config.host.resolveOrchestratorContext({
|
|
1069
991
|
orchestratorAddress: params.orchestratorAddress,
|
|
1070
|
-
escrowAddress: params.escrowAddress
|
|
1071
|
-
preferV2: this.config.getDefaultPreferV2()
|
|
992
|
+
escrowAddress: params.escrowAddress
|
|
1072
993
|
});
|
|
1073
994
|
return this.config.host.prepareResolvedOrchestratorTransaction({
|
|
1074
995
|
orchestrator: orchestratorContext,
|
|
@@ -1081,13 +1002,11 @@ var IntentOperations = class {
|
|
|
1081
1002
|
const escrowAddress = this.config.host.resolveEscrowAddressOrThrow(
|
|
1082
1003
|
options?.escrowAddress,
|
|
1083
1004
|
depositId,
|
|
1084
|
-
"getDepositPreIntentHook"
|
|
1085
|
-
{ preferV2: this.config.getDefaultPreferV2() }
|
|
1005
|
+
"getDepositPreIntentHook"
|
|
1086
1006
|
);
|
|
1087
1007
|
const orchestratorContext = await this.config.host.resolveOrchestratorContext({
|
|
1088
1008
|
orchestratorAddress: options?.orchestratorAddress,
|
|
1089
|
-
escrowAddress
|
|
1090
|
-
preferV2: this.config.getDefaultPreferV2()
|
|
1009
|
+
escrowAddress
|
|
1091
1010
|
});
|
|
1092
1011
|
const functionName = resolveAbiFunctionName(orchestratorContext.abi, [
|
|
1093
1012
|
"getDepositPreIntentHook"
|
|
@@ -1103,13 +1022,11 @@ var IntentOperations = class {
|
|
|
1103
1022
|
const escrowAddress = this.config.host.resolveEscrowAddressOrThrow(
|
|
1104
1023
|
options?.escrowAddress,
|
|
1105
1024
|
depositId,
|
|
1106
|
-
"getDepositWhitelistHook"
|
|
1107
|
-
{ preferV2: this.config.getDefaultPreferV2() }
|
|
1025
|
+
"getDepositWhitelistHook"
|
|
1108
1026
|
);
|
|
1109
1027
|
const orchestratorContext = await this.config.host.resolveOrchestratorContext({
|
|
1110
1028
|
orchestratorAddress: options?.orchestratorAddress,
|
|
1111
|
-
escrowAddress
|
|
1112
|
-
preferV2: this.config.getDefaultPreferV2()
|
|
1029
|
+
escrowAddress
|
|
1113
1030
|
});
|
|
1114
1031
|
const functionName = resolveAbiFunctionName(orchestratorContext.abi, [
|
|
1115
1032
|
"getDepositWhitelistHook"
|
|
@@ -1125,8 +1042,7 @@ var IntentOperations = class {
|
|
|
1125
1042
|
const intentHash = params.intentHash;
|
|
1126
1043
|
const orchestratorContext = await this.config.host.resolveOrchestratorContext({
|
|
1127
1044
|
orchestratorAddress: params.orchestratorAddress,
|
|
1128
|
-
intentHash
|
|
1129
|
-
preferV2: this.config.getDefaultPreferV2()
|
|
1045
|
+
intentHash
|
|
1130
1046
|
});
|
|
1131
1047
|
const precomputed = params.precomputedAttestation;
|
|
1132
1048
|
let paymentProof;
|
|
@@ -1139,7 +1055,9 @@ var IntentOperations = class {
|
|
|
1139
1055
|
verificationData = precomputed.verificationData;
|
|
1140
1056
|
} else {
|
|
1141
1057
|
const attestationServiceUrl = params.attestationServiceUrl ?? this.defaultAttestationService();
|
|
1142
|
-
const inputs = await this.config.host.getFulfillIntentInputs(intentHash
|
|
1058
|
+
const inputs = await this.config.host.getFulfillIntentInputs(intentHash, {
|
|
1059
|
+
orchestratorAddress: orchestratorContext.address
|
|
1060
|
+
});
|
|
1143
1061
|
const paymentMethodHash = inputs.paymentMethodHash || "0x";
|
|
1144
1062
|
const catalog = getPaymentMethodsCatalog(
|
|
1145
1063
|
this.config.getChainId(),
|
|
@@ -1209,31 +1127,30 @@ var IntentOperations = class {
|
|
|
1209
1127
|
defaultAttestationService() {
|
|
1210
1128
|
return this.config.getRuntimeEnv() === "staging" ? "https://attestation-service-staging.zkp2p.xyz" : "https://attestation-service.zkp2p.xyz";
|
|
1211
1129
|
}
|
|
1212
|
-
async getFulfillIntentInputs(intentHash) {
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
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
|
+
}
|
|
1230
1151
|
}
|
|
1152
|
+
} catch {
|
|
1231
1153
|
}
|
|
1232
|
-
} catch (error) {
|
|
1233
|
-
logger.debug("ProtocolViewer lookup failed, falling back to indexer", {
|
|
1234
|
-
intentHash,
|
|
1235
|
-
error: error instanceof Error ? error.message : String(error)
|
|
1236
|
-
});
|
|
1237
1154
|
}
|
|
1238
1155
|
const response = await this.config.getIndexerClient().query({
|
|
1239
1156
|
query: (
|
|
@@ -1522,7 +1439,7 @@ var ProtocolViewerReader = class {
|
|
|
1522
1439
|
if (inputCount === null) {
|
|
1523
1440
|
throw new Error("Configured ProtocolViewer ABI does not expose getDeposit");
|
|
1524
1441
|
}
|
|
1525
|
-
const { parseDepositView: parseDepositView2 } = await import('./protocolViewerParsers-
|
|
1442
|
+
const { parseDepositView: parseDepositView2 } = await import('./protocolViewerParsers-TPB47QOH.mjs');
|
|
1526
1443
|
if (inputCount >= 3) {
|
|
1527
1444
|
return tryContexts(
|
|
1528
1445
|
protocolViewerContexts,
|
|
@@ -1601,7 +1518,7 @@ var ProtocolViewerReader = class {
|
|
|
1601
1518
|
return Promise.all(ids.map((id) => this.config.host.getPvDepositById(id)));
|
|
1602
1519
|
}
|
|
1603
1520
|
const bn = ids.map((id) => typeof id === "bigint" ? id : parseRawDepositId(id));
|
|
1604
|
-
const { parseDepositView: parseDepositView2 } = await import('./protocolViewerParsers-
|
|
1521
|
+
const { parseDepositView: parseDepositView2 } = await import('./protocolViewerParsers-TPB47QOH.mjs');
|
|
1605
1522
|
if (inputCount >= 2) {
|
|
1606
1523
|
const requests = ids.map((id, index) => ({
|
|
1607
1524
|
index,
|
|
@@ -1706,7 +1623,7 @@ var ProtocolViewerReader = class {
|
|
|
1706
1623
|
if (!protocolViewerAddress || !protocolViewerAbi || inputCount === null) {
|
|
1707
1624
|
return this.config.host.getPvAccountDepositsFromIndexer(owner);
|
|
1708
1625
|
}
|
|
1709
|
-
const { parseDepositView: parseDepositView2 } = await import('./protocolViewerParsers-
|
|
1626
|
+
const { parseDepositView: parseDepositView2 } = await import('./protocolViewerParsers-TPB47QOH.mjs');
|
|
1710
1627
|
const { address, abi } = this.config.host.requireProtocolViewer();
|
|
1711
1628
|
if (inputCount >= 2) {
|
|
1712
1629
|
const readAndFilter = async (raw2) => {
|
|
@@ -1777,7 +1694,7 @@ var ProtocolViewerReader = class {
|
|
|
1777
1694
|
if (protocolViewerEntries.length === 0) {
|
|
1778
1695
|
throw new Error("ProtocolViewer not available for this network");
|
|
1779
1696
|
}
|
|
1780
|
-
const { parseIntentView: parseIntentView2 } = await import('./protocolViewerParsers-
|
|
1697
|
+
const { parseIntentView: parseIntentView2 } = await import('./protocolViewerParsers-TPB47QOH.mjs');
|
|
1781
1698
|
const intentsByHash = /* @__PURE__ */ new Map();
|
|
1782
1699
|
let attemptedRead = false;
|
|
1783
1700
|
let hadSuccessfulRead = false;
|
|
@@ -1885,7 +1802,7 @@ var ProtocolViewerReader = class {
|
|
|
1885
1802
|
if (protocolViewerEntries.length === 0) {
|
|
1886
1803
|
throw new Error("ProtocolViewer not available for this network");
|
|
1887
1804
|
}
|
|
1888
|
-
const { parseIntentView: parseIntentView2 } = await import('./protocolViewerParsers-
|
|
1805
|
+
const { parseIntentView: parseIntentView2 } = await import('./protocolViewerParsers-TPB47QOH.mjs');
|
|
1889
1806
|
let lastError;
|
|
1890
1807
|
for (const pvEntry of protocolViewerEntries) {
|
|
1891
1808
|
const inputCount = this.pvEntryFunctionInputCount(pvEntry, "getIntent");
|
|
@@ -1947,8 +1864,7 @@ var VaultOperations = class {
|
|
|
1947
1864
|
}
|
|
1948
1865
|
supportsInlineOracleRateConfig(params) {
|
|
1949
1866
|
const escrowContext = this.config.host.resolveEscrowContext({
|
|
1950
|
-
escrowAddress: params?.escrowAddress
|
|
1951
|
-
preferV2: params?.preferV2
|
|
1867
|
+
escrowAddress: params?.escrowAddress
|
|
1952
1868
|
});
|
|
1953
1869
|
return escrowCurrencyHasOracleConfig(escrowContext.abi);
|
|
1954
1870
|
}
|
|
@@ -2065,8 +1981,7 @@ var VaultOperations = class {
|
|
|
2065
1981
|
prepareSetOracleRateConfigTransaction(params) {
|
|
2066
1982
|
const escrowContext = this.config.host.resolveEscrowContext({
|
|
2067
1983
|
escrowAddress: params.escrowAddress,
|
|
2068
|
-
depositId: params.depositId
|
|
2069
|
-
preferV2: true
|
|
1984
|
+
depositId: params.depositId
|
|
2070
1985
|
});
|
|
2071
1986
|
if (escrowContext.version !== "v2") {
|
|
2072
1987
|
throw new Error("setOracleRateConfig requires EscrowV2");
|
|
@@ -2088,8 +2003,7 @@ var VaultOperations = class {
|
|
|
2088
2003
|
prepareRemoveOracleRateConfigTransaction(params) {
|
|
2089
2004
|
const escrowContext = this.config.host.resolveEscrowContext({
|
|
2090
2005
|
escrowAddress: params.escrowAddress,
|
|
2091
|
-
depositId: params.depositId
|
|
2092
|
-
preferV2: true
|
|
2006
|
+
depositId: params.depositId
|
|
2093
2007
|
});
|
|
2094
2008
|
if (escrowContext.version !== "v2") {
|
|
2095
2009
|
throw new Error("removeOracleRateConfig requires EscrowV2");
|
|
@@ -2106,8 +2020,7 @@ var VaultOperations = class {
|
|
|
2106
2020
|
prepareSetOracleRateConfigBatchTransaction(params) {
|
|
2107
2021
|
const escrowContext = this.config.host.resolveEscrowContext({
|
|
2108
2022
|
escrowAddress: params.escrowAddress,
|
|
2109
|
-
depositId: params.depositId
|
|
2110
|
-
preferV2: true
|
|
2023
|
+
depositId: params.depositId
|
|
2111
2024
|
});
|
|
2112
2025
|
if (escrowContext.version !== "v2") {
|
|
2113
2026
|
throw new Error("setOracleRateConfigBatch requires EscrowV2");
|
|
@@ -2129,8 +2042,7 @@ var VaultOperations = class {
|
|
|
2129
2042
|
prepareUpdateCurrencyConfigBatchTransaction(params) {
|
|
2130
2043
|
const escrowContext = this.config.host.resolveEscrowContext({
|
|
2131
2044
|
escrowAddress: params.escrowAddress,
|
|
2132
|
-
depositId: params.depositId
|
|
2133
|
-
preferV2: true
|
|
2045
|
+
depositId: params.depositId
|
|
2134
2046
|
});
|
|
2135
2047
|
if (escrowContext.version !== "v2") {
|
|
2136
2048
|
throw new Error("updateCurrencyConfigBatch requires EscrowV2");
|
|
@@ -2158,8 +2070,7 @@ var VaultOperations = class {
|
|
|
2158
2070
|
prepareDeactivateCurrenciesBatchTransaction(params) {
|
|
2159
2071
|
const escrowContext = this.config.host.resolveEscrowContext({
|
|
2160
2072
|
escrowAddress: params.escrowAddress,
|
|
2161
|
-
depositId: params.depositId
|
|
2162
|
-
preferV2: true
|
|
2073
|
+
depositId: params.depositId
|
|
2163
2074
|
});
|
|
2164
2075
|
if (escrowContext.version !== "v2") {
|
|
2165
2076
|
throw new Error("deactivateCurrenciesBatch requires EscrowV2");
|
|
@@ -3962,6 +3873,7 @@ var IndexerDepositService = class {
|
|
|
3962
3873
|
// src/indexer/rateManagerService.ts
|
|
3963
3874
|
var DEFAULT_LIMIT2 = 50;
|
|
3964
3875
|
var RATE_MANAGER_HISTORY_PAGE_SIZE = 250;
|
|
3876
|
+
var EVM_ADDRESS_REGEX = /^0x[a-f0-9]{40}$/;
|
|
3965
3877
|
function normalizeRateManagerId2(value) {
|
|
3966
3878
|
if (!value) return "";
|
|
3967
3879
|
return value.toLowerCase();
|
|
@@ -3970,6 +3882,9 @@ function normalizeAddress3(value) {
|
|
|
3970
3882
|
if (!value) return "";
|
|
3971
3883
|
return value.toLowerCase();
|
|
3972
3884
|
}
|
|
3885
|
+
function escapeLikePatternLiteral(value) {
|
|
3886
|
+
return value.replace(/\\/g, "\\\\").replace(/%/g, "\\%").replace(/_/g, "\\_");
|
|
3887
|
+
}
|
|
3973
3888
|
function parseScopedRateManagerFilterId(value) {
|
|
3974
3889
|
const trimmed = value.trim().toLowerCase();
|
|
3975
3890
|
if (!trimmed) return null;
|
|
@@ -3977,7 +3892,7 @@ function parseScopedRateManagerFilterId(value) {
|
|
|
3977
3892
|
if (separatorIndex <= 0) return null;
|
|
3978
3893
|
const rateManagerAddress = normalizeAddress3(trimmed.slice(0, separatorIndex));
|
|
3979
3894
|
const rateManagerId = normalizeRateManagerId2(trimmed.slice(separatorIndex + 1));
|
|
3980
|
-
if (!
|
|
3895
|
+
if (!EVM_ADDRESS_REGEX.test(rateManagerAddress) || !rateManagerId) {
|
|
3981
3896
|
return null;
|
|
3982
3897
|
}
|
|
3983
3898
|
return { rateManagerAddress, rateManagerId };
|
|
@@ -3995,12 +3910,14 @@ function extractRateManagerAddressFromScopedId(id) {
|
|
|
3995
3910
|
return rateManagerAddress.startsWith("0x") ? rateManagerAddress.toLowerCase() : null;
|
|
3996
3911
|
}
|
|
3997
3912
|
function buildRateManagerAddressScopedIdPattern(rateManagerId, rateManagerAddress) {
|
|
3998
|
-
const normalizedId = normalizeRateManagerId2(rateManagerId);
|
|
3999
|
-
const normalizedRateManagerAddress =
|
|
4000
|
-
|
|
3913
|
+
const normalizedId = escapeLikePatternLiteral(normalizeRateManagerId2(rateManagerId));
|
|
3914
|
+
const normalizedRateManagerAddress = escapeLikePatternLiteral(
|
|
3915
|
+
normalizeAddress3(rateManagerAddress)
|
|
3916
|
+
);
|
|
3917
|
+
return `%\\_${normalizedRateManagerAddress}\\_${normalizedId}`;
|
|
4001
3918
|
}
|
|
4002
3919
|
function buildRateManagerScopedIdPattern(rateManagerId, rateManagerAddress) {
|
|
4003
|
-
return `${buildRateManagerAddressScopedIdPattern(rateManagerId, rateManagerAddress)}_%`;
|
|
3920
|
+
return `${buildRateManagerAddressScopedIdPattern(rateManagerId, rateManagerAddress)}\\_%`;
|
|
4004
3921
|
}
|
|
4005
3922
|
function normalizeCompositeDepositId(depositId, escrowAddress) {
|
|
4006
3923
|
const normalizedDepositId = depositId.trim().toLowerCase();
|
|
@@ -4035,6 +3952,9 @@ function parseRateManagerFilterIds(rateManagerIds) {
|
|
|
4035
3952
|
);
|
|
4036
3953
|
continue;
|
|
4037
3954
|
}
|
|
3955
|
+
if (value.includes(":")) {
|
|
3956
|
+
continue;
|
|
3957
|
+
}
|
|
4038
3958
|
const normalizedRateManagerId = normalizeRateManagerId2(value);
|
|
4039
3959
|
if (normalizedRateManagerId) {
|
|
4040
3960
|
bare.add(normalizedRateManagerId);
|
|
@@ -4573,21 +4493,12 @@ var IndexerRateManagerService = class {
|
|
|
4573
4493
|
async fetchManualRateUpdates(rateManagerId, options) {
|
|
4574
4494
|
if (!rateManagerId) return [];
|
|
4575
4495
|
const normalizedId = normalizeRateManagerId2(rateManagerId);
|
|
4576
|
-
const normalizedRateManagerAddress = normalizeAddress3(options?.rateManagerAddress);
|
|
4577
4496
|
try {
|
|
4578
4497
|
const result = await this.client.query({
|
|
4579
4498
|
query: MANUAL_RATE_UPDATES_QUERY,
|
|
4580
4499
|
variables: {
|
|
4581
4500
|
where: {
|
|
4582
|
-
rateManagerId: { _eq: normalizedId }
|
|
4583
|
-
...normalizedRateManagerAddress ? {
|
|
4584
|
-
id: {
|
|
4585
|
-
_ilike: buildRateManagerScopedIdPattern(
|
|
4586
|
-
normalizedId,
|
|
4587
|
-
normalizedRateManagerAddress
|
|
4588
|
-
)
|
|
4589
|
-
}
|
|
4590
|
-
} : {}
|
|
4501
|
+
rateManagerId: { _eq: normalizedId }
|
|
4591
4502
|
},
|
|
4592
4503
|
order_by: [{ id: "desc" }],
|
|
4593
4504
|
limit: options?.limit ?? 100
|
|
@@ -4661,15 +4572,7 @@ var IndexerRateManagerService = class {
|
|
|
4661
4572
|
query: LEGACY_ORACLE_CONFIG_UPDATES_QUERY,
|
|
4662
4573
|
variables: {
|
|
4663
4574
|
where: {
|
|
4664
|
-
rateManagerId: { _eq: normalizedId }
|
|
4665
|
-
...normalizedRateManagerAddress ? {
|
|
4666
|
-
id: {
|
|
4667
|
-
_ilike: buildRateManagerScopedIdPattern(
|
|
4668
|
-
normalizedId,
|
|
4669
|
-
normalizedRateManagerAddress
|
|
4670
|
-
)
|
|
4671
|
-
}
|
|
4672
|
-
} : {}
|
|
4575
|
+
rateManagerId: { _eq: normalizedId }
|
|
4673
4576
|
},
|
|
4674
4577
|
order_by: [{ id: "desc" }],
|
|
4675
4578
|
limit
|
|
@@ -5948,7 +5851,7 @@ var Zkp2pClient = class {
|
|
|
5948
5851
|
...configuredOrchestratorAddresses
|
|
5949
5852
|
]);
|
|
5950
5853
|
this.orchestratorAddress = this.orchestratorV2Address ?? toAddress(addresses.orchestrator) ?? this.orchestratorAddresses[0];
|
|
5951
|
-
this.orchestratorAbi =
|
|
5854
|
+
this.orchestratorAbi = abis.orchestrator ?? this.orchestratorV2Abi;
|
|
5952
5855
|
this.unifiedPaymentVerifier = toAddress(
|
|
5953
5856
|
addresses.unifiedPaymentVerifierV2 ?? addresses.unifiedPaymentVerifier
|
|
5954
5857
|
);
|
|
@@ -6065,13 +5968,13 @@ var Zkp2pClient = class {
|
|
|
6065
5968
|
getProtocolViewerAbi: () => this.protocolViewerAbi,
|
|
6066
5969
|
getIndexerClient: () => this._indexerClient,
|
|
6067
5970
|
getIndexerService: () => this._indexerService,
|
|
6068
|
-
|
|
5971
|
+
getOrchestratorV2Address: () => this.orchestratorV2Address,
|
|
6069
5972
|
host: {
|
|
6070
5973
|
resolveEscrowContext: (options) => this.resolveEscrowContext(options),
|
|
6071
5974
|
resolveOrchestratorContext: (options) => this.resolveOrchestratorContext(options),
|
|
6072
|
-
resolveEscrowAddressOrThrow: (escrowAddress, depositId, methodName
|
|
5975
|
+
resolveEscrowAddressOrThrow: (escrowAddress, depositId, methodName) => this.resolveEscrowAddressOrThrow(escrowAddress, depositId, methodName),
|
|
6073
5976
|
prepareResolvedOrchestratorTransaction: (tx) => this.prepareResolvedOrchestratorTransaction(tx),
|
|
6074
|
-
getFulfillIntentInputs: (intentHash) => this.getFulfillIntentInputs(intentHash),
|
|
5977
|
+
getFulfillIntentInputs: (intentHash, options) => this.getFulfillIntentInputs(intentHash, options),
|
|
6075
5978
|
getPvIntent: (intentHash) => this.getPvIntent(intentHash)
|
|
6076
5979
|
}
|
|
6077
5980
|
});
|
|
@@ -6103,8 +6006,7 @@ var Zkp2pClient = class {
|
|
|
6103
6006
|
}
|
|
6104
6007
|
supportsInlineOracleRateConfig(params) {
|
|
6105
6008
|
return this._vaultOps.supportsInlineOracleRateConfig({
|
|
6106
|
-
escrowAddress: params?.escrowAddress
|
|
6107
|
-
preferV2: params?.preferV2 ?? this._router.defaultPreferV2
|
|
6009
|
+
escrowAddress: params?.escrowAddress
|
|
6108
6010
|
});
|
|
6109
6011
|
}
|
|
6110
6012
|
parseManagerFeeFromRead(result) {
|
|
@@ -6122,13 +6024,10 @@ var Zkp2pClient = class {
|
|
|
6122
6024
|
abiFunctionHasInput(abi, functionName, inputName) {
|
|
6123
6025
|
return abiFunctionHasInput(abi, functionName, inputName);
|
|
6124
6026
|
}
|
|
6125
|
-
resolveEscrowAddressOrThrow(escrowAddress, depositId,
|
|
6027
|
+
resolveEscrowAddressOrThrow(escrowAddress, depositId, _methodName) {
|
|
6126
6028
|
const resolved = escrowAddress ?? this.parseEscrowAddressFromCompositeDepositId(depositId);
|
|
6127
6029
|
if (resolved) return resolved;
|
|
6128
|
-
|
|
6129
|
-
return this.resolveEscrowContext().address;
|
|
6130
|
-
}
|
|
6131
|
-
throw new Error(`${methodName} requires escrowAddress or composite depositId`);
|
|
6030
|
+
return this.resolveEscrowContext().address;
|
|
6132
6031
|
}
|
|
6133
6032
|
prepareCreateRateManagerTransaction(params) {
|
|
6134
6033
|
return this._vaultOps.prepareCreateRateManagerTransaction(params);
|
|
@@ -6216,8 +6115,8 @@ var Zkp2pClient = class {
|
|
|
6216
6115
|
getEscrowContexts() {
|
|
6217
6116
|
return this._router.getEscrowContexts();
|
|
6218
6117
|
}
|
|
6219
|
-
resolveOrchestratorForEscrow(escrowAddress
|
|
6220
|
-
return this._router.resolveOrchestratorForEscrow(escrowAddress
|
|
6118
|
+
resolveOrchestratorForEscrow(escrowAddress) {
|
|
6119
|
+
return this._router.resolveOrchestratorForEscrow(escrowAddress);
|
|
6221
6120
|
}
|
|
6222
6121
|
async lookupIntentRouting(intentHash) {
|
|
6223
6122
|
try {
|
|
@@ -6251,12 +6150,8 @@ var Zkp2pClient = class {
|
|
|
6251
6150
|
try {
|
|
6252
6151
|
const view = await this.getPvIntent(intentHash);
|
|
6253
6152
|
return this.normalizeAddress(view?.intent?.escrow);
|
|
6254
|
-
} catch
|
|
6255
|
-
|
|
6256
|
-
return void 0;
|
|
6257
|
-
}
|
|
6258
|
-
const message = error instanceof Error ? error.message : "Unknown on-chain routing error";
|
|
6259
|
-
throw new Error(`Failed to resolve intent escrow on-chain for ${intentHash}: ${message}`);
|
|
6153
|
+
} catch {
|
|
6154
|
+
return void 0;
|
|
6260
6155
|
}
|
|
6261
6156
|
}
|
|
6262
6157
|
warnOrchestratorFallback(intentHash, source, error) {
|
|
@@ -6280,10 +6175,7 @@ var Zkp2pClient = class {
|
|
|
6280
6175
|
const fromIntent = this.getOrchestratorContextByAddress(routing.orchestratorAddress);
|
|
6281
6176
|
if (fromIntent) return fromIntent;
|
|
6282
6177
|
if (routing.escrowAddress) {
|
|
6283
|
-
const fromIntentEscrow = this.resolveOrchestratorForEscrow(
|
|
6284
|
-
routing.escrowAddress,
|
|
6285
|
-
options.preferV2
|
|
6286
|
-
);
|
|
6178
|
+
const fromIntentEscrow = this.resolveOrchestratorForEscrow(routing.escrowAddress);
|
|
6287
6179
|
if (fromIntentEscrow) return fromIntentEscrow;
|
|
6288
6180
|
}
|
|
6289
6181
|
} catch (error) {
|
|
@@ -6292,10 +6184,7 @@ var Zkp2pClient = class {
|
|
|
6292
6184
|
try {
|
|
6293
6185
|
const onchainEscrow = await this.lookupIntentEscrowOnchain(options.intentHash);
|
|
6294
6186
|
if (onchainEscrow) {
|
|
6295
|
-
const fromOnchainEscrow = this.resolveOrchestratorForEscrow(
|
|
6296
|
-
onchainEscrow,
|
|
6297
|
-
options.preferV2
|
|
6298
|
-
);
|
|
6187
|
+
const fromOnchainEscrow = this.resolveOrchestratorForEscrow(onchainEscrow);
|
|
6299
6188
|
if (fromOnchainEscrow) return fromOnchainEscrow;
|
|
6300
6189
|
}
|
|
6301
6190
|
} catch (error) {
|
|
@@ -6303,7 +6192,7 @@ var Zkp2pClient = class {
|
|
|
6303
6192
|
}
|
|
6304
6193
|
}
|
|
6305
6194
|
if (options?.escrowAddress) {
|
|
6306
|
-
const fromEscrow = this.resolveOrchestratorForEscrow(options.escrowAddress
|
|
6195
|
+
const fromEscrow = this.resolveOrchestratorForEscrow(options.escrowAddress);
|
|
6307
6196
|
if (fromEscrow) return fromEscrow;
|
|
6308
6197
|
}
|
|
6309
6198
|
if (options?.intentHash) {
|
|
@@ -6321,7 +6210,7 @@ var Zkp2pClient = class {
|
|
|
6321
6210
|
}
|
|
6322
6211
|
}
|
|
6323
6212
|
}
|
|
6324
|
-
const fallback = this.resolveOrchestratorForEscrow(
|
|
6213
|
+
const fallback = this.resolveOrchestratorForEscrow();
|
|
6325
6214
|
if (fallback) return fallback;
|
|
6326
6215
|
throw new Error("Orchestrator not available");
|
|
6327
6216
|
}
|
|
@@ -6541,8 +6430,7 @@ var Zkp2pClient = class {
|
|
|
6541
6430
|
async (params) => {
|
|
6542
6431
|
const orchestratorContext = await this.resolveOrchestratorContext({
|
|
6543
6432
|
orchestratorAddress: params.orchestratorAddress,
|
|
6544
|
-
escrowAddress: params.escrowAddress
|
|
6545
|
-
preferV2: params.preferV2
|
|
6433
|
+
escrowAddress: params.escrowAddress
|
|
6546
6434
|
});
|
|
6547
6435
|
const prepared = this.prepareOrchestratorTransaction({
|
|
6548
6436
|
functionName,
|
|
@@ -6558,8 +6446,7 @@ var Zkp2pClient = class {
|
|
|
6558
6446
|
prepare: async (params) => {
|
|
6559
6447
|
const orchestratorContext = await this.resolveOrchestratorContext({
|
|
6560
6448
|
orchestratorAddress: params.orchestratorAddress,
|
|
6561
|
-
escrowAddress: params.escrowAddress
|
|
6562
|
-
preferV2: params.preferV2
|
|
6449
|
+
escrowAddress: params.escrowAddress
|
|
6563
6450
|
});
|
|
6564
6451
|
const prepared = this.prepareOrchestratorTransaction({
|
|
6565
6452
|
functionName,
|
|
@@ -6894,7 +6781,6 @@ var Zkp2pClient = class {
|
|
|
6894
6781
|
* @param params.amount - Minimum required allowance amount
|
|
6895
6782
|
* @param params.spender - Spender address override
|
|
6896
6783
|
* @param params.escrowAddress - Escrow context used for default spender resolution
|
|
6897
|
-
* @param params.preferV2 - Prefer EscrowV2 for default spender resolution
|
|
6898
6784
|
* @param params.maxApprove - If true, approves MaxUint256 instead of exact amount
|
|
6899
6785
|
* @param params.txOverrides - Optional viem transaction overrides
|
|
6900
6786
|
* @returns Object with `hadAllowance` (true if no approval needed) and optional `hash`
|
|
@@ -6917,8 +6803,7 @@ var Zkp2pClient = class {
|
|
|
6917
6803
|
const owner = this.walletClient.account?.address;
|
|
6918
6804
|
if (!owner) throw new Error("Wallet client is missing account");
|
|
6919
6805
|
const spender = params.spender ?? this.resolveEscrowContext({
|
|
6920
|
-
escrowAddress: params.escrowAddress
|
|
6921
|
-
preferV2: params.preferV2 ?? this._router.defaultPreferV2
|
|
6806
|
+
escrowAddress: params.escrowAddress
|
|
6922
6807
|
}).address;
|
|
6923
6808
|
const allowance = await this.publicClient.readContract({
|
|
6924
6809
|
address: params.token,
|
|
@@ -7152,8 +7037,7 @@ var Zkp2pClient = class {
|
|
|
7152
7037
|
currencies = mapConversionRatesToOnchainMinRate2(normalized, paymentMethods.length);
|
|
7153
7038
|
}
|
|
7154
7039
|
const escrowContext = this.resolveEscrowContext({
|
|
7155
|
-
escrowAddress: params.escrowAddress
|
|
7156
|
-
preferV2: this._router.defaultPreferV2
|
|
7040
|
+
escrowAddress: params.escrowAddress
|
|
7157
7041
|
});
|
|
7158
7042
|
const normalizedCurrencies = currencies.map(
|
|
7159
7043
|
(group) => this.normalizeCurrencyTuples(group, escrowContext.abi)
|
|
@@ -7473,8 +7357,8 @@ var Zkp2pClient = class {
|
|
|
7473
7357
|
* @returns Intent parameters needed for fulfillment
|
|
7474
7358
|
* @throws Error if intent not found or payee details cannot be resolved
|
|
7475
7359
|
*/
|
|
7476
|
-
async getFulfillIntentInputs(intentHash) {
|
|
7477
|
-
return this._intentOps.getFulfillIntentInputs(intentHash);
|
|
7360
|
+
async getFulfillIntentInputs(intentHash, options) {
|
|
7361
|
+
return this._intentOps.getFulfillIntentInputs(intentHash, options);
|
|
7478
7362
|
}
|
|
7479
7363
|
};
|
|
7480
7364
|
|
|
@@ -7670,6 +7554,44 @@ var createPeerExtensionSdk = (options = {}) => ({
|
|
|
7670
7554
|
});
|
|
7671
7555
|
var peerExtensionSdk = createPeerExtensionSdk();
|
|
7672
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
|
+
|
|
7673
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 };
|
|
7674
7596
|
//# sourceMappingURL=index.mjs.map
|
|
7675
7597
|
//# sourceMappingURL=index.mjs.map
|