@zkp2p/sdk 0.0.5 → 0.0.7
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 +80 -1
- package/dist/{Zkp2pClient-CIMGTCFg.d.mts → Zkp2pClient-w5Pzlea6.d.mts} +285 -71
- package/dist/{Zkp2pClient-CIMGTCFg.d.ts → Zkp2pClient-w5Pzlea6.d.ts} +285 -71
- package/dist/chunk-3QS3WKRC.mjs +29 -0
- package/dist/chunk-3QS3WKRC.mjs.map +1 -0
- package/dist/{chunk-P3NOBRQB.mjs → chunk-GYYD6SSA.mjs} +2 -2
- package/dist/chunk-GYYD6SSA.mjs.map +1 -0
- package/dist/{chunk-CM3RH5VZ.mjs → chunk-NZ53KYLT.mjs} +42 -2
- package/dist/chunk-NZ53KYLT.mjs.map +1 -0
- package/dist/{chunk-PYEJ4L76.mjs → chunk-W247BDNW.mjs} +3 -3
- package/dist/{chunk-PYEJ4L76.mjs.map → chunk-W247BDNW.mjs.map} +1 -1
- package/dist/constants-ZICRSYZM.mjs +5 -0
- package/dist/{constants-Y2IWTA6H.mjs.map → constants-ZICRSYZM.mjs.map} +1 -1
- package/dist/{currency-RSSHQOM3.mjs → currency-UVK4OKUR.mjs} +4 -3
- package/dist/{currency-RSSHQOM3.mjs.map → currency-UVK4OKUR.mjs.map} +1 -1
- package/dist/index.cjs +1169 -440
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +92 -4
- package/dist/index.d.ts +92 -4
- package/dist/index.mjs +916 -442
- package/dist/index.mjs.map +1 -1
- package/dist/{paymentResolution-4AAJVIIC.mjs → paymentResolution-2FP3NLM3.mjs} +3 -2
- package/dist/{paymentResolution-4AAJVIIC.mjs.map → paymentResolution-2FP3NLM3.mjs.map} +1 -1
- package/dist/protocolViewerParsers-EH5DGVSU.mjs +6 -0
- package/dist/{protocolViewerParsers-3QIR3XMT.mjs.map → protocolViewerParsers-EH5DGVSU.mjs.map} +1 -1
- package/dist/react.cjs +62 -2
- package/dist/react.cjs.map +1 -1
- package/dist/react.d.mts +58 -4
- package/dist/react.d.ts +58 -4
- package/dist/react.mjs +63 -3
- package/dist/react.mjs.map +1 -1
- package/dist/{timeout-QB7K5SOB.mjs → timeout-7HCFGU6P.mjs} +3 -2
- package/dist/timeout-7HCFGU6P.mjs.map +1 -0
- package/package.json +4 -3
- package/dist/chunk-CM3RH5VZ.mjs.map +0 -1
- package/dist/chunk-P3NOBRQB.mjs.map +0 -1
- package/dist/constants-Y2IWTA6H.mjs +0 -4
- package/dist/protocolViewerParsers-3QIR3XMT.mjs +0 -5
- package/dist/timeout-QB7K5SOB.mjs.map +0 -1
package/dist/index.mjs
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { ValidationError, APIError, NetworkError } from './chunk-GHQK65J2.mjs';
|
|
2
2
|
export { APIError, ContractError, ErrorCode, NetworkError, ValidationError, ZKP2PError } from './chunk-GHQK65J2.mjs';
|
|
3
|
-
export { PAYMENT_PLATFORMS, PLATFORM_METADATA, SUPPORTED_CHAIN_IDS, TOKEN_METADATA } from './chunk-
|
|
4
|
-
import { getContracts, getPaymentMethodsCatalog, getGatingServiceAddress } from './chunk-
|
|
5
|
-
export { enrichPvDepositView, enrichPvIntentView, getContracts, getGatingServiceAddress, getPaymentMethodsCatalog, parseDepositView, parseIntentView } from './chunk-
|
|
3
|
+
export { PAYMENT_PLATFORMS, PLATFORM_METADATA, SUPPORTED_CHAIN_IDS, TOKEN_METADATA } from './chunk-GYYD6SSA.mjs';
|
|
4
|
+
import { getContracts, getPaymentMethodsCatalog, getGatingServiceAddress } from './chunk-W247BDNW.mjs';
|
|
5
|
+
export { enrichPvDepositView, enrichPvIntentView, getContracts, getGatingServiceAddress, getPaymentMethodsCatalog, parseDepositView, parseIntentView } from './chunk-W247BDNW.mjs';
|
|
6
6
|
import { resolvePaymentMethodHashFromCatalog, resolveFiatCurrencyBytes32 } from './chunk-GDKCACWH.mjs';
|
|
7
7
|
export { asciiToBytes32, ensureBytes32, resolveFiatCurrencyBytes32, resolvePaymentMethodHash, resolvePaymentMethodHashFromCatalog, resolvePaymentMethodNameFromHash } from './chunk-GDKCACWH.mjs';
|
|
8
|
-
import { currencyKeccak256 } from './chunk-
|
|
9
|
-
export { Currency, currencyInfo, getCurrencyCodeFromHash, getCurrencyInfoFromCountryCode, getCurrencyInfoFromHash, isSupportedCurrencyHash, mapConversionRatesToOnchainMinRate } from './chunk-
|
|
8
|
+
import { currencyKeccak256 } from './chunk-NZ53KYLT.mjs';
|
|
9
|
+
export { Currency, currencyInfo, getCurrencyCodeFromHash, getCurrencyInfoFromCountryCode, getCurrencyInfoFromHash, isSupportedCurrencyHash, mapConversionRatesToOnchainMinRate } from './chunk-NZ53KYLT.mjs';
|
|
10
|
+
import './chunk-3QS3WKRC.mjs';
|
|
10
11
|
import { concatHex, encodeFunctionData, createPublicClient, http } from 'viem';
|
|
11
12
|
import { hardhat, baseSepolia, base } from 'viem/chains';
|
|
12
13
|
import { AbiCoder } from 'ethers';
|
|
@@ -649,7 +650,7 @@ async function withRetry(fn, maxRetries = 3, delayMs = 1e3, timeoutMs) {
|
|
|
649
650
|
for (let i = 0; i < maxRetries; i++) {
|
|
650
651
|
try {
|
|
651
652
|
if (timeoutMs) {
|
|
652
|
-
const { withTimeout } = await import('./timeout-
|
|
653
|
+
const { withTimeout } = await import('./timeout-7HCFGU6P.mjs');
|
|
653
654
|
return await withTimeout(fn(), timeoutMs, `Operation timed out after ${timeoutMs}ms`);
|
|
654
655
|
}
|
|
655
656
|
return await fn();
|
|
@@ -767,6 +768,17 @@ async function apiFetch({
|
|
|
767
768
|
return res.json();
|
|
768
769
|
}, retryCount, retryDelayMs, timeoutMs);
|
|
769
770
|
}
|
|
771
|
+
function processApiResponse(data, transformDates = true) {
|
|
772
|
+
if (!transformDates) return data;
|
|
773
|
+
if (data.responseObject) {
|
|
774
|
+
if (Array.isArray(data.responseObject)) {
|
|
775
|
+
data.responseObject = data.responseObject.map((item) => transformDatesToObjects(item));
|
|
776
|
+
} else {
|
|
777
|
+
data.responseObject = transformDatesToObjects(data.responseObject);
|
|
778
|
+
}
|
|
779
|
+
}
|
|
780
|
+
return data;
|
|
781
|
+
}
|
|
770
782
|
async function apiPostDepositDetails(req, baseApiUrl, timeoutMs) {
|
|
771
783
|
return apiFetch({
|
|
772
784
|
url: `${baseApiUrl.replace(/\/$/, "")}/v1/makers/create`,
|
|
@@ -826,6 +838,34 @@ async function apiValidatePayeeDetails(req, baseApiUrl, timeoutMs) {
|
|
|
826
838
|
}
|
|
827
839
|
return data;
|
|
828
840
|
}
|
|
841
|
+
function transformDatesToObjects(obj) {
|
|
842
|
+
const dateFields = ["createdAt", "updatedAt", "signalTimestamp", "fulfillTimestamp", "prunedTimestamp"];
|
|
843
|
+
const transformed = { ...obj };
|
|
844
|
+
for (const key in transformed) {
|
|
845
|
+
const value = transformed[key];
|
|
846
|
+
if (dateFields.includes(key) && typeof value === "string") {
|
|
847
|
+
transformed[key] = new Date(value);
|
|
848
|
+
} else if (Array.isArray(value)) {
|
|
849
|
+
transformed[key] = value.map(
|
|
850
|
+
(item) => typeof item === "object" && item !== null ? transformDatesToObjects(item) : item
|
|
851
|
+
);
|
|
852
|
+
} else if (typeof value === "object" && value !== null) {
|
|
853
|
+
transformed[key] = transformDatesToObjects(value);
|
|
854
|
+
}
|
|
855
|
+
}
|
|
856
|
+
return transformed;
|
|
857
|
+
}
|
|
858
|
+
async function apiGetOwnerDeposits(req, apiKey, baseApiUrl, authToken, timeoutMs) {
|
|
859
|
+
const statusQuery = req.status ? `?status=${encodeURIComponent(req.status)}` : "";
|
|
860
|
+
const data = await apiFetch({
|
|
861
|
+
url: `${withApiBase(baseApiUrl)}/v1/deposits/maker/${req.ownerAddress}${statusQuery}`,
|
|
862
|
+
method: "GET",
|
|
863
|
+
apiKey,
|
|
864
|
+
authToken,
|
|
865
|
+
timeoutMs
|
|
866
|
+
});
|
|
867
|
+
return processApiResponse(data);
|
|
868
|
+
}
|
|
829
869
|
async function apiGetTakerTier(req, apiKey, baseApiUrl, authToken, timeoutMs) {
|
|
830
870
|
const normalizedOwner = req.owner.toLowerCase();
|
|
831
871
|
const query = new URLSearchParams({
|
|
@@ -884,6 +924,14 @@ function appendAttributionToCalldata(calldata, referrer) {
|
|
|
884
924
|
const suffix = getAttributionDataSuffix(referrer);
|
|
885
925
|
return concatHex([calldata, suffix]);
|
|
886
926
|
}
|
|
927
|
+
function encodeWithAttribution(request, referrer) {
|
|
928
|
+
const functionData = encodeFunctionData({
|
|
929
|
+
abi: request.abi,
|
|
930
|
+
functionName: request.functionName,
|
|
931
|
+
args: request.args || []
|
|
932
|
+
});
|
|
933
|
+
return appendAttributionToCalldata(functionData, referrer);
|
|
934
|
+
}
|
|
887
935
|
async function sendTransactionWithAttribution(walletClient, request, referrer, overrides) {
|
|
888
936
|
const functionData = encodeFunctionData({
|
|
889
937
|
abi: request.abi,
|
|
@@ -929,6 +977,413 @@ var Zkp2pClient = class {
|
|
|
929
977
|
* @throws Error if walletClient is missing an account
|
|
930
978
|
*/
|
|
931
979
|
constructor(opts) {
|
|
980
|
+
// ╔═══════════════════════════════════════════════════════════════════════════╗
|
|
981
|
+
// ║ CORE: DEPOSIT MANAGEMENT ║
|
|
982
|
+
// ╚═══════════════════════════════════════════════════════════════════════════╝
|
|
983
|
+
/**
|
|
984
|
+
* Enables or disables a deposit from accepting new intents.
|
|
985
|
+
*
|
|
986
|
+
* @param params.depositId - The deposit ID
|
|
987
|
+
* @param params.accepting - Whether to accept new intents
|
|
988
|
+
* @param params.txOverrides - Optional viem transaction overrides
|
|
989
|
+
* @returns Transaction hash
|
|
990
|
+
*/
|
|
991
|
+
this.setAcceptingIntents = this.buildEscrowMethod(
|
|
992
|
+
"setAcceptingIntents",
|
|
993
|
+
(params) => [params.depositId, params.accepting]
|
|
994
|
+
);
|
|
995
|
+
/**
|
|
996
|
+
* Updates the min/max intent amount range for a deposit.
|
|
997
|
+
*
|
|
998
|
+
* @param params.depositId - The deposit ID
|
|
999
|
+
* @param params.min - Minimum intent amount
|
|
1000
|
+
* @param params.max - Maximum intent amount
|
|
1001
|
+
* @param params.txOverrides - Optional viem transaction overrides
|
|
1002
|
+
* @returns Transaction hash
|
|
1003
|
+
*/
|
|
1004
|
+
this.setIntentRange = this.buildEscrowMethod(
|
|
1005
|
+
"setIntentRange",
|
|
1006
|
+
(params) => [params.depositId, { min: params.min, max: params.max }]
|
|
1007
|
+
);
|
|
1008
|
+
/**
|
|
1009
|
+
* Updates the minimum conversion rate for a specific currency on a payment method.
|
|
1010
|
+
*
|
|
1011
|
+
* @param params.depositId - The deposit ID
|
|
1012
|
+
* @param params.paymentMethod - Payment method hash (bytes32)
|
|
1013
|
+
* @param params.fiatCurrency - Fiat currency hash (bytes32)
|
|
1014
|
+
* @param params.minConversionRate - New minimum conversion rate (18 decimals)
|
|
1015
|
+
* @param params.txOverrides - Optional viem transaction overrides
|
|
1016
|
+
* @returns Transaction hash
|
|
1017
|
+
*/
|
|
1018
|
+
this.setCurrencyMinRate = this.buildEscrowMethod("setCurrencyMinRate", (params) => [
|
|
1019
|
+
params.depositId,
|
|
1020
|
+
params.paymentMethod,
|
|
1021
|
+
params.fiatCurrency,
|
|
1022
|
+
params.minConversionRate
|
|
1023
|
+
]);
|
|
1024
|
+
/**
|
|
1025
|
+
* Adds additional funds to an existing deposit.
|
|
1026
|
+
* Requires prior approval of the token amount.
|
|
1027
|
+
*
|
|
1028
|
+
* @param params.depositId - The deposit ID to add funds to
|
|
1029
|
+
* @param params.amount - Amount to add (in token units)
|
|
1030
|
+
* @param params.txOverrides - Optional viem transaction overrides
|
|
1031
|
+
* @returns Transaction hash
|
|
1032
|
+
*/
|
|
1033
|
+
this.addFunds = this.buildEscrowMethod(
|
|
1034
|
+
"addFunds",
|
|
1035
|
+
(params) => [params.depositId, params.amount]
|
|
1036
|
+
);
|
|
1037
|
+
/**
|
|
1038
|
+
* Removes funds from a deposit (partial withdrawal).
|
|
1039
|
+
* Can only withdraw available (non-locked) funds.
|
|
1040
|
+
*
|
|
1041
|
+
* @param params.depositId - The deposit ID
|
|
1042
|
+
* @param params.amount - Amount to remove (in token units)
|
|
1043
|
+
* @param params.txOverrides - Optional viem transaction overrides
|
|
1044
|
+
* @returns Transaction hash
|
|
1045
|
+
*/
|
|
1046
|
+
this.removeFunds = this.buildEscrowMethod(
|
|
1047
|
+
"removeFunds",
|
|
1048
|
+
(params) => [params.depositId, params.amount]
|
|
1049
|
+
);
|
|
1050
|
+
/**
|
|
1051
|
+
* Fully withdraws a deposit, returning all available funds to the owner.
|
|
1052
|
+
* The deposit must have no active intents.
|
|
1053
|
+
*
|
|
1054
|
+
* @param params.depositId - The deposit ID to withdraw
|
|
1055
|
+
* @param params.txOverrides - Optional viem transaction overrides
|
|
1056
|
+
* @returns Transaction hash
|
|
1057
|
+
*/
|
|
1058
|
+
this.withdrawDeposit = this.buildEscrowMethod(
|
|
1059
|
+
"withdrawDeposit",
|
|
1060
|
+
(params) => [params.depositId]
|
|
1061
|
+
);
|
|
1062
|
+
// ╔═══════════════════════════════════════════════════════════════════════════╗
|
|
1063
|
+
// ║ CORE: ADVANCED DEPOSIT CONFIGURATION ║
|
|
1064
|
+
// ╚═══════════════════════════════════════════════════════════════════════════╝
|
|
1065
|
+
/**
|
|
1066
|
+
* Sets whether a deposit should remain active when its balance reaches zero.
|
|
1067
|
+
*
|
|
1068
|
+
* @param params.depositId - The deposit ID
|
|
1069
|
+
* @param params.retain - If true, deposit stays active when empty
|
|
1070
|
+
* @param params.txOverrides - Optional viem transaction overrides
|
|
1071
|
+
* @returns Transaction hash
|
|
1072
|
+
*/
|
|
1073
|
+
this.setRetainOnEmpty = this.buildEscrowMethod(
|
|
1074
|
+
"setRetainOnEmpty",
|
|
1075
|
+
(params) => [params.depositId, params.retain]
|
|
1076
|
+
);
|
|
1077
|
+
/**
|
|
1078
|
+
* Assigns a delegate address that can manage the deposit on behalf of the owner.
|
|
1079
|
+
*
|
|
1080
|
+
* @param params.depositId - The deposit ID
|
|
1081
|
+
* @param params.delegate - Address to delegate management to
|
|
1082
|
+
* @param params.txOverrides - Optional viem transaction overrides
|
|
1083
|
+
* @returns Transaction hash
|
|
1084
|
+
*/
|
|
1085
|
+
this.setDelegate = this.buildEscrowMethod(
|
|
1086
|
+
"setDelegate",
|
|
1087
|
+
(params) => [params.depositId, params.delegate]
|
|
1088
|
+
);
|
|
1089
|
+
/**
|
|
1090
|
+
* Removes the delegate from a deposit.
|
|
1091
|
+
*
|
|
1092
|
+
* @param params.depositId - The deposit ID
|
|
1093
|
+
* @param params.txOverrides - Optional viem transaction overrides
|
|
1094
|
+
* @returns Transaction hash
|
|
1095
|
+
*/
|
|
1096
|
+
this.removeDelegate = this.buildEscrowMethod(
|
|
1097
|
+
"removeDelegate",
|
|
1098
|
+
(params) => [params.depositId]
|
|
1099
|
+
);
|
|
1100
|
+
/**
|
|
1101
|
+
* Adds new payment methods to an existing deposit.
|
|
1102
|
+
*
|
|
1103
|
+
* @param params.depositId - The deposit ID
|
|
1104
|
+
* @param params.paymentMethods - Array of payment method hashes to add
|
|
1105
|
+
* @param params.paymentMethodData - Corresponding payment method configuration
|
|
1106
|
+
* @param params.txOverrides - Optional viem transaction overrides
|
|
1107
|
+
* @returns Transaction hash
|
|
1108
|
+
*/
|
|
1109
|
+
this.addPaymentMethods = this.buildEscrowMethod("addPaymentMethods", (params) => [params.depositId, params.paymentMethods, params.paymentMethodData, params.currencies]);
|
|
1110
|
+
/**
|
|
1111
|
+
* Activates or deactivates a payment method on a deposit.
|
|
1112
|
+
*
|
|
1113
|
+
* @param params.depositId - The deposit ID
|
|
1114
|
+
* @param params.paymentMethod - Payment method hash to modify
|
|
1115
|
+
* @param params.isActive - Whether the payment method should accept intents
|
|
1116
|
+
* @param params.txOverrides - Optional viem transaction overrides
|
|
1117
|
+
* @returns Transaction hash
|
|
1118
|
+
*/
|
|
1119
|
+
this.setPaymentMethodActive = this.buildEscrowMethod("setPaymentMethodActive", (params) => [params.depositId, params.paymentMethod, params.isActive]);
|
|
1120
|
+
/**
|
|
1121
|
+
* Deactivates a payment method on a deposit (convenience alias for setPaymentMethodActive).
|
|
1122
|
+
*
|
|
1123
|
+
* @param params.depositId - The deposit ID
|
|
1124
|
+
* @param params.paymentMethod - Payment method hash to deactivate
|
|
1125
|
+
* @param params.txOverrides - Optional viem transaction overrides
|
|
1126
|
+
* @returns Transaction hash
|
|
1127
|
+
*/
|
|
1128
|
+
this.removePaymentMethod = this.buildEscrowMethod(
|
|
1129
|
+
"setPaymentMethodActive",
|
|
1130
|
+
(params) => [params.depositId, params.paymentMethod, false]
|
|
1131
|
+
);
|
|
1132
|
+
/**
|
|
1133
|
+
* Adds new currencies to a payment method on a deposit.
|
|
1134
|
+
*
|
|
1135
|
+
* @param params.depositId - The deposit ID
|
|
1136
|
+
* @param params.paymentMethod - Payment method hash to add currencies to
|
|
1137
|
+
* @param params.currencies - Array of currency configurations with code and min rate
|
|
1138
|
+
* @param params.txOverrides - Optional viem transaction overrides
|
|
1139
|
+
* @returns Transaction hash
|
|
1140
|
+
*/
|
|
1141
|
+
this.addCurrencies = this.buildEscrowMethod("addCurrencies", (params) => [params.depositId, params.paymentMethod, params.currencies]);
|
|
1142
|
+
/**
|
|
1143
|
+
* Deactivates a currency for a payment method on a deposit.
|
|
1144
|
+
*
|
|
1145
|
+
* @param params.depositId - The deposit ID
|
|
1146
|
+
* @param params.paymentMethod - Payment method hash
|
|
1147
|
+
* @param params.currencyCode - Currency code hash to deactivate
|
|
1148
|
+
* @param params.txOverrides - Optional viem transaction overrides
|
|
1149
|
+
* @returns Transaction hash
|
|
1150
|
+
*/
|
|
1151
|
+
this.deactivateCurrency = this.buildEscrowMethod("deactivateCurrency", (params) => [params.depositId, params.paymentMethod, params.currencyCode]);
|
|
1152
|
+
/**
|
|
1153
|
+
* Removes (deactivates) a currency from a payment method.
|
|
1154
|
+
* Alias for deactivateCurrency.
|
|
1155
|
+
*
|
|
1156
|
+
* @param params.depositId - The deposit ID
|
|
1157
|
+
* @param params.paymentMethod - Payment method hash
|
|
1158
|
+
* @param params.currencyCode - Currency code hash to remove
|
|
1159
|
+
* @param params.txOverrides - Optional viem transaction overrides
|
|
1160
|
+
* @returns Transaction hash
|
|
1161
|
+
*/
|
|
1162
|
+
this.removeCurrency = this.buildEscrowMethod(
|
|
1163
|
+
"deactivateCurrency",
|
|
1164
|
+
(params) => [params.depositId, params.paymentMethod, params.currencyCode]
|
|
1165
|
+
);
|
|
1166
|
+
/**
|
|
1167
|
+
* Removes expired intents from a deposit, freeing up locked funds.
|
|
1168
|
+
* Can be called by anyone (permissionless cleanup).
|
|
1169
|
+
*
|
|
1170
|
+
* @param params.depositId - The deposit ID to prune
|
|
1171
|
+
* @param params.txOverrides - Optional viem transaction overrides
|
|
1172
|
+
* @returns Transaction hash
|
|
1173
|
+
*/
|
|
1174
|
+
this.pruneExpiredIntents = this.buildEscrowMethod(
|
|
1175
|
+
"pruneExpiredIntents",
|
|
1176
|
+
(params) => [params.depositId]
|
|
1177
|
+
);
|
|
1178
|
+
// ───────────────────────────────────────────────────────────────────────────
|
|
1179
|
+
// SUPPORTING: INTENT OPERATIONS
|
|
1180
|
+
// (Used by takers/buyers - not primary SDK functionality)
|
|
1181
|
+
// ───────────────────────────────────────────────────────────────────────────
|
|
1182
|
+
/**
|
|
1183
|
+
* **Supporting Method** - Signals intent to use a deposit.
|
|
1184
|
+
*
|
|
1185
|
+
* > **Note**: This method is typically used by takers/buyers who want to
|
|
1186
|
+
* > purchase crypto by paying fiat. Liquidity providers generally don't
|
|
1187
|
+
* > need to call this method directly.
|
|
1188
|
+
*
|
|
1189
|
+
* This reserves funds from a deposit and creates an intent that must be
|
|
1190
|
+
* fulfilled (via `fulfillIntent`) or will expire. The taker commits to
|
|
1191
|
+
* sending fiat payment to the deposit's payee.
|
|
1192
|
+
*
|
|
1193
|
+
* If `gatingServiceSignature` is not provided, the SDK will automatically
|
|
1194
|
+
* fetch one from the API (requires `apiKey` or `authorizationToken`).
|
|
1195
|
+
*
|
|
1196
|
+
* **Prepare Mode**: Use `.prepare()` to get the transaction calldata without sending:
|
|
1197
|
+
* ```typescript
|
|
1198
|
+
* const prepared = await client.signalIntent.prepare(params);
|
|
1199
|
+
* // Submit via relayer or inspect calldata
|
|
1200
|
+
* await relayer.submit({ to: prepared.to, data: prepared.data });
|
|
1201
|
+
* ```
|
|
1202
|
+
*
|
|
1203
|
+
* @param params.depositId - The deposit to use
|
|
1204
|
+
* @param params.amount - Amount of tokens to claim (in token units)
|
|
1205
|
+
* @param params.toAddress - Address to receive the tokens when fulfilled
|
|
1206
|
+
* @param params.processorName - Payment platform (e.g., 'wise', 'revolut')
|
|
1207
|
+
* @param params.payeeDetails - Hashed payee details (from deposit)
|
|
1208
|
+
* @param params.fiatCurrencyCode - Fiat currency code (e.g., 'USD', 'EUR')
|
|
1209
|
+
* @param params.conversionRate - Agreed conversion rate (18 decimals)
|
|
1210
|
+
* @param params.referrer - Optional referrer address for fee sharing
|
|
1211
|
+
* @param params.referrerFee - Optional referrer fee amount
|
|
1212
|
+
* @param params.postIntentHook - Optional hook contract to call after signaling
|
|
1213
|
+
* @param params.data - Optional data to pass to the hook
|
|
1214
|
+
* @param params.gatingServiceSignature - Pre-obtained signature (if not auto-fetching)
|
|
1215
|
+
* @param params.signatureExpiration - Signature expiration timestamp
|
|
1216
|
+
* @param params.txOverrides - Optional viem transaction overrides
|
|
1217
|
+
* @returns Transaction hash
|
|
1218
|
+
*
|
|
1219
|
+
* @example
|
|
1220
|
+
* ```typescript
|
|
1221
|
+
* // Execute directly
|
|
1222
|
+
* const hash = await client.signalIntent({
|
|
1223
|
+
* depositId: 42n,
|
|
1224
|
+
* amount: 100_000000n, // 100 USDC
|
|
1225
|
+
* toAddress: '0x...',
|
|
1226
|
+
* processorName: 'wise',
|
|
1227
|
+
* payeeDetails: '0x...',
|
|
1228
|
+
* fiatCurrencyCode: 'USD',
|
|
1229
|
+
* conversionRate: 1_020000000000000000n, // 1.02
|
|
1230
|
+
* });
|
|
1231
|
+
*
|
|
1232
|
+
* // Or prepare for relayer submission
|
|
1233
|
+
* const prepared = await client.signalIntent.prepare({
|
|
1234
|
+
* depositId: 42n,
|
|
1235
|
+
* amount: 100_000000n,
|
|
1236
|
+
* toAddress: '0x...',
|
|
1237
|
+
* processorName: 'wise',
|
|
1238
|
+
* payeeDetails: '0x...',
|
|
1239
|
+
* fiatCurrencyCode: 'USD',
|
|
1240
|
+
* conversionRate: 1_020000000000000000n,
|
|
1241
|
+
* });
|
|
1242
|
+
* // prepared.to, prepared.data, prepared.value, prepared.chainId
|
|
1243
|
+
* ```
|
|
1244
|
+
*/
|
|
1245
|
+
this.signalIntent = Object.assign(
|
|
1246
|
+
async (params) => {
|
|
1247
|
+
const prepared = await this.prepareSignalIntent(params);
|
|
1248
|
+
return this.executePreparedTransaction(prepared, params.txOverrides);
|
|
1249
|
+
},
|
|
1250
|
+
{
|
|
1251
|
+
prepare: async (params) => {
|
|
1252
|
+
const prepared = await this.prepareSignalIntent(params);
|
|
1253
|
+
return {
|
|
1254
|
+
to: prepared.to,
|
|
1255
|
+
data: prepared.data,
|
|
1256
|
+
value: prepared.value,
|
|
1257
|
+
chainId: prepared.chainId
|
|
1258
|
+
};
|
|
1259
|
+
}
|
|
1260
|
+
}
|
|
1261
|
+
);
|
|
1262
|
+
/**
|
|
1263
|
+
* **Supporting Method** - Cancels a signaled intent before fulfillment.
|
|
1264
|
+
*
|
|
1265
|
+
* Only the intent owner can cancel. Releases reserved funds back to the deposit.
|
|
1266
|
+
*
|
|
1267
|
+
* **Prepare Mode**: Use `.prepare()` to get the transaction calldata without sending:
|
|
1268
|
+
* ```typescript
|
|
1269
|
+
* const prepared = await client.cancelIntent.prepare({ intentHash });
|
|
1270
|
+
* await relayer.submit({ to: prepared.to, data: prepared.data });
|
|
1271
|
+
* ```
|
|
1272
|
+
*
|
|
1273
|
+
* @param params.intentHash - The intent hash to cancel (0x-prefixed, 32 bytes)
|
|
1274
|
+
* @param params.txOverrides - Optional viem transaction overrides
|
|
1275
|
+
* @returns Transaction hash
|
|
1276
|
+
*
|
|
1277
|
+
* @example
|
|
1278
|
+
* ```typescript
|
|
1279
|
+
* // Execute directly
|
|
1280
|
+
* const hash = await client.cancelIntent({ intentHash: '0x...' });
|
|
1281
|
+
*
|
|
1282
|
+
* // Or prepare for relayer submission
|
|
1283
|
+
* const prepared = await client.cancelIntent.prepare({ intentHash: '0x...' });
|
|
1284
|
+
* ```
|
|
1285
|
+
*/
|
|
1286
|
+
this.cancelIntent = Object.assign(
|
|
1287
|
+
async (params) => {
|
|
1288
|
+
const prepared = await this.prepareCancelIntent(params);
|
|
1289
|
+
return this.executePreparedTransaction(prepared, params.txOverrides);
|
|
1290
|
+
},
|
|
1291
|
+
{
|
|
1292
|
+
prepare: async (params) => {
|
|
1293
|
+
const prepared = await this.prepareCancelIntent(params);
|
|
1294
|
+
return {
|
|
1295
|
+
to: prepared.to,
|
|
1296
|
+
data: prepared.data,
|
|
1297
|
+
value: prepared.value,
|
|
1298
|
+
chainId: prepared.chainId
|
|
1299
|
+
};
|
|
1300
|
+
}
|
|
1301
|
+
}
|
|
1302
|
+
);
|
|
1303
|
+
/**
|
|
1304
|
+
* **Supporting Method** - Releases funds back to the deposit owner.
|
|
1305
|
+
*
|
|
1306
|
+
* Called by the deposit owner when they want to reject an intent
|
|
1307
|
+
* (e.g., payment verification failed or intent expired).
|
|
1308
|
+
*
|
|
1309
|
+
* @param params.intentHash - The intent hash (0x-prefixed, 32 bytes)
|
|
1310
|
+
* @param params.txOverrides - Optional viem transaction overrides
|
|
1311
|
+
* @returns Transaction hash
|
|
1312
|
+
*/
|
|
1313
|
+
this.releaseFundsToPayer = this.buildOrchestratorMethod(
|
|
1314
|
+
"releaseFundsToPayer",
|
|
1315
|
+
(params) => [params.intentHash]
|
|
1316
|
+
);
|
|
1317
|
+
/**
|
|
1318
|
+
* **Supporting Method** - Fulfills an intent by submitting a payment proof.
|
|
1319
|
+
*
|
|
1320
|
+
* > **Note**: This method is typically used by takers/buyers after they've
|
|
1321
|
+
* > sent fiat payment. Liquidity providers generally don't call this directly.
|
|
1322
|
+
*
|
|
1323
|
+
* This is the final step in the off-ramp flow. After the taker has sent
|
|
1324
|
+
* fiat payment, they generate a proof (via the browser extension) and
|
|
1325
|
+
* submit it here. The SDK handles attestation service calls automatically.
|
|
1326
|
+
*
|
|
1327
|
+
* **Flow:**
|
|
1328
|
+
* 1. Intent parameters are derived from the indexer/ProtocolViewer
|
|
1329
|
+
* 2. Proof is sent to the attestation service for verification
|
|
1330
|
+
* 3. Attestation response is encoded and submitted on-chain
|
|
1331
|
+
* 4. Funds are released to the intent's `toAddress`
|
|
1332
|
+
*
|
|
1333
|
+
* **Prepare Mode**: Use `.prepare()` to get the transaction calldata without sending:
|
|
1334
|
+
* ```typescript
|
|
1335
|
+
* const prepared = await client.fulfillIntent.prepare(params);
|
|
1336
|
+
* // Submit via relayer or inspect calldata
|
|
1337
|
+
* await relayer.submit({ to: prepared.to, data: prepared.data });
|
|
1338
|
+
* ```
|
|
1339
|
+
*
|
|
1340
|
+
* @param params.intentHash - The intent hash to fulfill (0x-prefixed, 32 bytes)
|
|
1341
|
+
* @param params.proof - Payment proof from Reclaim (object or JSON string)
|
|
1342
|
+
* @param params.timestampBufferMs - Allowed timestamp variance (default: 300000ms)
|
|
1343
|
+
* @param params.attestationServiceUrl - Override attestation service URL
|
|
1344
|
+
* @param params.verifyingContract - Override verifier contract address
|
|
1345
|
+
* @param params.postIntentHookData - Data to pass to post-intent hook
|
|
1346
|
+
* @param params.txOverrides - Optional viem transaction overrides
|
|
1347
|
+
* @param params.callbacks - Lifecycle callbacks for UI updates
|
|
1348
|
+
* @returns Transaction hash
|
|
1349
|
+
*
|
|
1350
|
+
* @example
|
|
1351
|
+
* ```typescript
|
|
1352
|
+
* // Execute directly
|
|
1353
|
+
* const hash = await client.fulfillIntent({
|
|
1354
|
+
* intentHash: '0x...',
|
|
1355
|
+
* proof: proofFromExtension,
|
|
1356
|
+
* });
|
|
1357
|
+
*
|
|
1358
|
+
* // Or prepare for relayer submission
|
|
1359
|
+
* const prepared = await client.fulfillIntent.prepare({
|
|
1360
|
+
* intentHash: '0x...',
|
|
1361
|
+
* proof: proofFromExtension,
|
|
1362
|
+
* });
|
|
1363
|
+
* // prepared.to, prepared.data, prepared.value, prepared.chainId
|
|
1364
|
+
* ```
|
|
1365
|
+
*/
|
|
1366
|
+
this.fulfillIntent = Object.assign(
|
|
1367
|
+
async (params) => {
|
|
1368
|
+
params?.callbacks?.onAttestationStart?.();
|
|
1369
|
+
const prepared = await this.prepareFulfillIntent(params);
|
|
1370
|
+
const txHash = await this.executePreparedTransaction(prepared, params.txOverrides);
|
|
1371
|
+
params?.callbacks?.onTxSent?.(txHash);
|
|
1372
|
+
return txHash;
|
|
1373
|
+
},
|
|
1374
|
+
{
|
|
1375
|
+
prepare: async (params) => {
|
|
1376
|
+
params?.callbacks?.onAttestationStart?.();
|
|
1377
|
+
const prepared = await this.prepareFulfillIntent(params);
|
|
1378
|
+
return {
|
|
1379
|
+
to: prepared.to,
|
|
1380
|
+
data: prepared.data,
|
|
1381
|
+
value: prepared.value,
|
|
1382
|
+
chainId: prepared.chainId
|
|
1383
|
+
};
|
|
1384
|
+
}
|
|
1385
|
+
}
|
|
1386
|
+
);
|
|
932
1387
|
this.walletClient = opts.walletClient;
|
|
933
1388
|
this.chainId = opts.chainId;
|
|
934
1389
|
this.runtimeEnv = opts.runtimeEnv ?? "production";
|
|
@@ -991,6 +1446,129 @@ var Zkp2pClient = class {
|
|
|
991
1446
|
txOverrides
|
|
992
1447
|
);
|
|
993
1448
|
}
|
|
1449
|
+
/**
|
|
1450
|
+
* Execute a prepared transaction (simulation + send).
|
|
1451
|
+
* Used internally by prepareable methods after preparation.
|
|
1452
|
+
*/
|
|
1453
|
+
async executePreparedTransaction(prepared, txOverrides) {
|
|
1454
|
+
const { referrer, ...overrides } = txOverrides ?? {};
|
|
1455
|
+
await this.publicClient.simulateContract({
|
|
1456
|
+
address: prepared.to,
|
|
1457
|
+
abi: prepared.abi,
|
|
1458
|
+
functionName: prepared.functionName,
|
|
1459
|
+
args: prepared.args,
|
|
1460
|
+
account: this.walletClient.account,
|
|
1461
|
+
...overrides
|
|
1462
|
+
});
|
|
1463
|
+
return this.walletClient.sendTransaction({
|
|
1464
|
+
to: prepared.to,
|
|
1465
|
+
data: prepared.data,
|
|
1466
|
+
value: prepared.value,
|
|
1467
|
+
account: this.walletClient.account,
|
|
1468
|
+
chain: this.walletClient.chain,
|
|
1469
|
+
...overrides
|
|
1470
|
+
});
|
|
1471
|
+
}
|
|
1472
|
+
prepareEscrowTransaction(opts) {
|
|
1473
|
+
if (!this.escrowAddress || !this.escrowAbi) throw new Error("Escrow not available");
|
|
1474
|
+
const { referrer, value } = opts.txOverrides ?? {};
|
|
1475
|
+
const data = encodeWithAttribution(
|
|
1476
|
+
{
|
|
1477
|
+
abi: this.escrowAbi,
|
|
1478
|
+
functionName: opts.functionName,
|
|
1479
|
+
args: opts.args ?? []
|
|
1480
|
+
},
|
|
1481
|
+
referrer
|
|
1482
|
+
);
|
|
1483
|
+
return {
|
|
1484
|
+
to: this.escrowAddress,
|
|
1485
|
+
data,
|
|
1486
|
+
value: opts.value ?? value ?? 0n,
|
|
1487
|
+
chainId: this.chainId,
|
|
1488
|
+
abi: this.escrowAbi,
|
|
1489
|
+
functionName: opts.functionName,
|
|
1490
|
+
args: opts.args ?? []
|
|
1491
|
+
};
|
|
1492
|
+
}
|
|
1493
|
+
prepareOrchestratorTransaction(opts) {
|
|
1494
|
+
if (!this.orchestratorAddress || !this.orchestratorAbi) throw new Error("Orchestrator not available");
|
|
1495
|
+
const { referrer, value } = opts.txOverrides ?? {};
|
|
1496
|
+
const data = encodeWithAttribution(
|
|
1497
|
+
{
|
|
1498
|
+
abi: this.orchestratorAbi,
|
|
1499
|
+
functionName: opts.functionName,
|
|
1500
|
+
args: opts.args ?? []
|
|
1501
|
+
},
|
|
1502
|
+
referrer
|
|
1503
|
+
);
|
|
1504
|
+
return {
|
|
1505
|
+
to: this.orchestratorAddress,
|
|
1506
|
+
data,
|
|
1507
|
+
value: opts.value ?? value ?? 0n,
|
|
1508
|
+
chainId: this.chainId,
|
|
1509
|
+
abi: this.orchestratorAbi,
|
|
1510
|
+
functionName: opts.functionName,
|
|
1511
|
+
args: opts.args ?? []
|
|
1512
|
+
};
|
|
1513
|
+
}
|
|
1514
|
+
buildEscrowMethod(functionName, buildArgs, buildValue) {
|
|
1515
|
+
return Object.assign(
|
|
1516
|
+
async (params) => {
|
|
1517
|
+
const prepared = this.prepareEscrowTransaction({
|
|
1518
|
+
functionName,
|
|
1519
|
+
args: buildArgs(params),
|
|
1520
|
+
txOverrides: params.txOverrides,
|
|
1521
|
+
value: buildValue?.(params)
|
|
1522
|
+
});
|
|
1523
|
+
return this.executePreparedTransaction(prepared, params.txOverrides);
|
|
1524
|
+
},
|
|
1525
|
+
{
|
|
1526
|
+
prepare: async (params) => {
|
|
1527
|
+
const prepared = this.prepareEscrowTransaction({
|
|
1528
|
+
functionName,
|
|
1529
|
+
args: buildArgs(params),
|
|
1530
|
+
txOverrides: params.txOverrides,
|
|
1531
|
+
value: buildValue?.(params)
|
|
1532
|
+
});
|
|
1533
|
+
return {
|
|
1534
|
+
to: prepared.to,
|
|
1535
|
+
data: prepared.data,
|
|
1536
|
+
value: prepared.value,
|
|
1537
|
+
chainId: prepared.chainId
|
|
1538
|
+
};
|
|
1539
|
+
}
|
|
1540
|
+
}
|
|
1541
|
+
);
|
|
1542
|
+
}
|
|
1543
|
+
buildOrchestratorMethod(functionName, buildArgs, buildValue) {
|
|
1544
|
+
return Object.assign(
|
|
1545
|
+
async (params) => {
|
|
1546
|
+
const prepared = this.prepareOrchestratorTransaction({
|
|
1547
|
+
functionName,
|
|
1548
|
+
args: buildArgs(params),
|
|
1549
|
+
txOverrides: params.txOverrides,
|
|
1550
|
+
value: buildValue?.(params)
|
|
1551
|
+
});
|
|
1552
|
+
return this.executePreparedTransaction(prepared, params.txOverrides);
|
|
1553
|
+
},
|
|
1554
|
+
{
|
|
1555
|
+
prepare: async (params) => {
|
|
1556
|
+
const prepared = this.prepareOrchestratorTransaction({
|
|
1557
|
+
functionName,
|
|
1558
|
+
args: buildArgs(params),
|
|
1559
|
+
txOverrides: params.txOverrides,
|
|
1560
|
+
value: buildValue?.(params)
|
|
1561
|
+
});
|
|
1562
|
+
return {
|
|
1563
|
+
to: prepared.to,
|
|
1564
|
+
data: prepared.data,
|
|
1565
|
+
value: prepared.value,
|
|
1566
|
+
chainId: prepared.chainId
|
|
1567
|
+
};
|
|
1568
|
+
}
|
|
1569
|
+
}
|
|
1570
|
+
);
|
|
1571
|
+
}
|
|
994
1572
|
// ╔═══════════════════════════════════════════════════════════════════════════╗
|
|
995
1573
|
// ║ CORE: DEPOSIT QUERIES (RPC-first via ProtocolViewer) ║
|
|
996
1574
|
// ╚═══════════════════════════════════════════════════════════════════════════╝
|
|
@@ -1314,7 +1892,29 @@ var Zkp2pClient = class {
|
|
|
1314
1892
|
* ```
|
|
1315
1893
|
*/
|
|
1316
1894
|
async createDeposit(params) {
|
|
1317
|
-
const
|
|
1895
|
+
const { depositDetails, prepared } = await this.prepareCreateDepositInternal(params);
|
|
1896
|
+
const hash = await this.executePreparedTransaction(prepared, params.txOverrides);
|
|
1897
|
+
return { depositDetails, hash };
|
|
1898
|
+
}
|
|
1899
|
+
/**
|
|
1900
|
+
* Prepares a createDeposit transaction without sending it.
|
|
1901
|
+
*
|
|
1902
|
+
* Returns both the prepared transaction calldata and the posted deposit details
|
|
1903
|
+
* (including hashed on-chain IDs) needed for tracking.
|
|
1904
|
+
*/
|
|
1905
|
+
async prepareCreateDeposit(params) {
|
|
1906
|
+
const { depositDetails, prepared } = await this.prepareCreateDepositInternal(params);
|
|
1907
|
+
return {
|
|
1908
|
+
depositDetails,
|
|
1909
|
+
prepared: {
|
|
1910
|
+
to: prepared.to,
|
|
1911
|
+
data: prepared.data,
|
|
1912
|
+
value: prepared.value,
|
|
1913
|
+
chainId: prepared.chainId
|
|
1914
|
+
}
|
|
1915
|
+
};
|
|
1916
|
+
}
|
|
1917
|
+
async prepareCreateDepositInternal(params) {
|
|
1318
1918
|
if (!Array.isArray(params.processorNames) || params.processorNames.length === 0) {
|
|
1319
1919
|
throw new Error("processorNames must be a non-empty array");
|
|
1320
1920
|
}
|
|
@@ -1324,40 +1924,59 @@ var Zkp2pClient = class {
|
|
|
1324
1924
|
if (params.processorNames.length !== params.depositData.length) {
|
|
1325
1925
|
throw new Error("processorNames and depositData length mismatch");
|
|
1326
1926
|
}
|
|
1327
|
-
const paymentMethods = params.processorNames.map((name) => resolvePaymentMethodHashFromCatalog(name, methods));
|
|
1328
|
-
const intentGatingService = getGatingServiceAddress(this.chainId, this.runtimeEnv);
|
|
1329
|
-
const baseApiUrl = (this.baseApiUrl ?? "https://api.zkp2p.xyz").replace(/\/$/, "");
|
|
1330
|
-
if (!this.apiKey && !this.authorizationToken) {
|
|
1331
|
-
throw new Error("createDeposit requires apiKey or authorizationToken to post deposit details");
|
|
1332
|
-
}
|
|
1333
1927
|
const depositDetails = params.processorNames.map((processorName, index) => ({
|
|
1334
1928
|
processorName,
|
|
1335
1929
|
depositData: params.depositData[index] || {}
|
|
1336
1930
|
}));
|
|
1337
|
-
const
|
|
1338
|
-
|
|
1931
|
+
const hasOverrides = Boolean(
|
|
1932
|
+
params.paymentMethodsOverride || params.paymentMethodDataOverride || params.currenciesOverride
|
|
1339
1933
|
);
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1934
|
+
let paymentMethods;
|
|
1935
|
+
let paymentMethodData;
|
|
1936
|
+
let currencies;
|
|
1937
|
+
if (hasOverrides) {
|
|
1938
|
+
if (!params.paymentMethodsOverride || !params.paymentMethodDataOverride || !params.currenciesOverride) {
|
|
1939
|
+
throw new Error("paymentMethodsOverride, paymentMethodDataOverride, and currenciesOverride must be provided together");
|
|
1940
|
+
}
|
|
1941
|
+
if (params.paymentMethodsOverride.length !== params.paymentMethodDataOverride.length || params.paymentMethodsOverride.length !== params.currenciesOverride.length) {
|
|
1942
|
+
throw new Error("paymentMethodsOverride, paymentMethodDataOverride, and currenciesOverride length mismatch");
|
|
1943
|
+
}
|
|
1944
|
+
paymentMethods = params.paymentMethodsOverride;
|
|
1945
|
+
paymentMethodData = params.paymentMethodDataOverride;
|
|
1946
|
+
currencies = params.currenciesOverride;
|
|
1947
|
+
} else {
|
|
1948
|
+
const methods = getPaymentMethodsCatalog(this.chainId, this.runtimeEnv);
|
|
1949
|
+
paymentMethods = params.processorNames.map((name) => resolvePaymentMethodHashFromCatalog(name, methods));
|
|
1950
|
+
const intentGatingService = getGatingServiceAddress(this.chainId, this.runtimeEnv);
|
|
1951
|
+
const baseApiUrl = (this.baseApiUrl ?? "https://api.zkp2p.xyz").replace(/\/$/, "");
|
|
1952
|
+
if (!this.apiKey && !this.authorizationToken) {
|
|
1953
|
+
throw new Error("createDeposit requires apiKey or authorizationToken to post deposit details");
|
|
1954
|
+
}
|
|
1955
|
+
const apiResponses = await Promise.all(
|
|
1956
|
+
depositDetails.map((req) => apiPostDepositDetails(req, baseApiUrl, this.apiTimeoutMs))
|
|
1957
|
+
);
|
|
1958
|
+
if (!apiResponses.every((r) => r?.success)) {
|
|
1959
|
+
const failed = apiResponses.find((r) => !r?.success);
|
|
1960
|
+
throw new Error(failed?.message || "Failed to create deposit details");
|
|
1961
|
+
}
|
|
1962
|
+
const hashedOnchainIds = apiResponses.map((r) => r.responseObject?.hashedOnchainId);
|
|
1963
|
+
paymentMethodData = hashedOnchainIds.map((hid) => ({ intentGatingService, payeeDetails: hid, data: "0x" }));
|
|
1964
|
+
params.conversionRates.forEach((group, i) => {
|
|
1965
|
+
const key = params.processorNames[i]?.toLowerCase();
|
|
1966
|
+
const allowed = methods[key]?.currencies?.map((c) => c.toLowerCase());
|
|
1967
|
+
if (allowed && allowed.length) {
|
|
1968
|
+
for (const { currency } of group) {
|
|
1969
|
+
const codeHash = currencyKeccak256(String(currency).toUpperCase()).toLowerCase();
|
|
1970
|
+
if (!allowed.includes(codeHash)) {
|
|
1971
|
+
throw new Error(`Currency ${currency} not supported by ${params.processorNames[i]}. Allowed: ${allowed.join(", ")}`);
|
|
1972
|
+
}
|
|
1354
1973
|
}
|
|
1355
1974
|
}
|
|
1356
|
-
}
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1975
|
+
});
|
|
1976
|
+
const { mapConversionRatesToOnchainMinRate: mapConversionRatesToOnchainMinRate2 } = await import('./currency-UVK4OKUR.mjs');
|
|
1977
|
+
const normalized = params.conversionRates.map((group) => group.map((r) => ({ currency: r.currency, conversionRate: r.conversionRate })));
|
|
1978
|
+
currencies = mapConversionRatesToOnchainMinRate2(normalized, paymentMethods.length);
|
|
1979
|
+
}
|
|
1361
1980
|
const args = [{
|
|
1362
1981
|
token: params.token,
|
|
1363
1982
|
amount: params.amount,
|
|
@@ -1369,339 +1988,18 @@ var Zkp2pClient = class {
|
|
|
1369
1988
|
intentGuardian: params.intentGuardian ?? "0x0000000000000000000000000000000000000000",
|
|
1370
1989
|
retainOnEmpty: Boolean(params.retainOnEmpty ?? false)
|
|
1371
1990
|
}];
|
|
1372
|
-
const
|
|
1373
|
-
address: this.escrowAddress,
|
|
1374
|
-
abi: this.escrowAbi,
|
|
1991
|
+
const prepared = this.prepareEscrowTransaction({
|
|
1375
1992
|
functionName: "createDeposit",
|
|
1376
1993
|
args,
|
|
1377
1994
|
txOverrides: params.txOverrides
|
|
1378
1995
|
});
|
|
1379
|
-
return { depositDetails,
|
|
1380
|
-
}
|
|
1381
|
-
// ╔═══════════════════════════════════════════════════════════════════════════╗
|
|
1382
|
-
// ║ CORE: DEPOSIT MANAGEMENT ║
|
|
1383
|
-
// ╚═══════════════════════════════════════════════════════════════════════════╝
|
|
1384
|
-
/**
|
|
1385
|
-
* Enables or disables a deposit from accepting new intents.
|
|
1386
|
-
*
|
|
1387
|
-
* @param params.depositId - The deposit ID
|
|
1388
|
-
* @param params.accepting - Whether to accept new intents
|
|
1389
|
-
* @param params.txOverrides - Optional viem transaction overrides
|
|
1390
|
-
* @returns Transaction hash
|
|
1391
|
-
*/
|
|
1392
|
-
async setAcceptingIntents(params) {
|
|
1393
|
-
return this.simulateAndSendWithAttribution({
|
|
1394
|
-
address: this.escrowAddress,
|
|
1395
|
-
abi: this.escrowAbi,
|
|
1396
|
-
functionName: "setAcceptingIntents",
|
|
1397
|
-
args: [params.depositId, params.accepting],
|
|
1398
|
-
txOverrides: params.txOverrides
|
|
1399
|
-
});
|
|
1400
|
-
}
|
|
1401
|
-
/**
|
|
1402
|
-
* Updates the min/max intent amount range for a deposit.
|
|
1403
|
-
*
|
|
1404
|
-
* @param params.depositId - The deposit ID
|
|
1405
|
-
* @param params.min - Minimum intent amount
|
|
1406
|
-
* @param params.max - Maximum intent amount
|
|
1407
|
-
* @param params.txOverrides - Optional viem transaction overrides
|
|
1408
|
-
* @returns Transaction hash
|
|
1409
|
-
*/
|
|
1410
|
-
async setIntentRange(params) {
|
|
1411
|
-
return this.simulateAndSendWithAttribution({
|
|
1412
|
-
address: this.escrowAddress,
|
|
1413
|
-
abi: this.escrowAbi,
|
|
1414
|
-
functionName: "setIntentRange",
|
|
1415
|
-
args: [params.depositId, { min: params.min, max: params.max }],
|
|
1416
|
-
txOverrides: params.txOverrides
|
|
1417
|
-
});
|
|
1418
|
-
}
|
|
1419
|
-
/**
|
|
1420
|
-
* Updates the minimum conversion rate for a specific currency on a payment method.
|
|
1421
|
-
*
|
|
1422
|
-
* @param params.depositId - The deposit ID
|
|
1423
|
-
* @param params.paymentMethod - Payment method hash (bytes32)
|
|
1424
|
-
* @param params.fiatCurrency - Fiat currency hash (bytes32)
|
|
1425
|
-
* @param params.minConversionRate - New minimum conversion rate (18 decimals)
|
|
1426
|
-
* @param params.txOverrides - Optional viem transaction overrides
|
|
1427
|
-
* @returns Transaction hash
|
|
1428
|
-
*/
|
|
1429
|
-
async setCurrencyMinRate(params) {
|
|
1430
|
-
return this.simulateAndSendWithAttribution({
|
|
1431
|
-
address: this.escrowAddress,
|
|
1432
|
-
abi: this.escrowAbi,
|
|
1433
|
-
functionName: "setCurrencyMinRate",
|
|
1434
|
-
args: [params.depositId, params.paymentMethod, params.fiatCurrency, params.minConversionRate],
|
|
1435
|
-
txOverrides: params.txOverrides
|
|
1436
|
-
});
|
|
1437
|
-
}
|
|
1438
|
-
/**
|
|
1439
|
-
* Adds additional funds to an existing deposit.
|
|
1440
|
-
* Requires prior approval of the token amount.
|
|
1441
|
-
*
|
|
1442
|
-
* @param params.depositId - The deposit ID to add funds to
|
|
1443
|
-
* @param params.amount - Amount to add (in token units)
|
|
1444
|
-
* @param params.txOverrides - Optional viem transaction overrides
|
|
1445
|
-
* @returns Transaction hash
|
|
1446
|
-
*/
|
|
1447
|
-
async addFunds(params) {
|
|
1448
|
-
return this.simulateAndSendWithAttribution({
|
|
1449
|
-
address: this.escrowAddress,
|
|
1450
|
-
abi: this.escrowAbi,
|
|
1451
|
-
functionName: "addFunds",
|
|
1452
|
-
args: [params.depositId, params.amount],
|
|
1453
|
-
txOverrides: params.txOverrides
|
|
1454
|
-
});
|
|
1455
|
-
}
|
|
1456
|
-
/**
|
|
1457
|
-
* Removes funds from a deposit (partial withdrawal).
|
|
1458
|
-
* Can only withdraw available (non-locked) funds.
|
|
1459
|
-
*
|
|
1460
|
-
* @param params.depositId - The deposit ID
|
|
1461
|
-
* @param params.amount - Amount to remove (in token units)
|
|
1462
|
-
* @param params.txOverrides - Optional viem transaction overrides
|
|
1463
|
-
* @returns Transaction hash
|
|
1464
|
-
*/
|
|
1465
|
-
async removeFunds(params) {
|
|
1466
|
-
return this.simulateAndSendWithAttribution({
|
|
1467
|
-
address: this.escrowAddress,
|
|
1468
|
-
abi: this.escrowAbi,
|
|
1469
|
-
functionName: "removeFunds",
|
|
1470
|
-
args: [params.depositId, params.amount],
|
|
1471
|
-
txOverrides: params.txOverrides
|
|
1472
|
-
});
|
|
1473
|
-
}
|
|
1474
|
-
/**
|
|
1475
|
-
* Fully withdraws a deposit, returning all available funds to the owner.
|
|
1476
|
-
* The deposit must have no active intents.
|
|
1477
|
-
*
|
|
1478
|
-
* @param params.depositId - The deposit ID to withdraw
|
|
1479
|
-
* @param params.txOverrides - Optional viem transaction overrides
|
|
1480
|
-
* @returns Transaction hash
|
|
1481
|
-
*/
|
|
1482
|
-
async withdrawDeposit(params) {
|
|
1483
|
-
return this.simulateAndSendWithAttribution({
|
|
1484
|
-
address: this.escrowAddress,
|
|
1485
|
-
abi: this.escrowAbi,
|
|
1486
|
-
functionName: "withdrawDeposit",
|
|
1487
|
-
args: [params.depositId],
|
|
1488
|
-
txOverrides: params.txOverrides
|
|
1489
|
-
});
|
|
1490
|
-
}
|
|
1491
|
-
// ╔═══════════════════════════════════════════════════════════════════════════╗
|
|
1492
|
-
// ║ CORE: ADVANCED DEPOSIT CONFIGURATION ║
|
|
1493
|
-
// ╚═══════════════════════════════════════════════════════════════════════════╝
|
|
1494
|
-
/**
|
|
1495
|
-
* Sets whether a deposit should remain active when its balance reaches zero.
|
|
1496
|
-
*
|
|
1497
|
-
* @param params.depositId - The deposit ID
|
|
1498
|
-
* @param params.retain - If true, deposit stays active when empty
|
|
1499
|
-
* @param params.txOverrides - Optional viem transaction overrides
|
|
1500
|
-
* @returns Transaction hash
|
|
1501
|
-
*/
|
|
1502
|
-
async setRetainOnEmpty(params) {
|
|
1503
|
-
return this.simulateAndSendWithAttribution({
|
|
1504
|
-
address: this.escrowAddress,
|
|
1505
|
-
abi: this.escrowAbi,
|
|
1506
|
-
functionName: "setRetainOnEmpty",
|
|
1507
|
-
args: [params.depositId, params.retain],
|
|
1508
|
-
txOverrides: params.txOverrides
|
|
1509
|
-
});
|
|
1510
|
-
}
|
|
1511
|
-
/**
|
|
1512
|
-
* Assigns a delegate address that can manage the deposit on behalf of the owner.
|
|
1513
|
-
*
|
|
1514
|
-
* @param params.depositId - The deposit ID
|
|
1515
|
-
* @param params.delegate - Address to delegate management to
|
|
1516
|
-
* @param params.txOverrides - Optional viem transaction overrides
|
|
1517
|
-
* @returns Transaction hash
|
|
1518
|
-
*/
|
|
1519
|
-
async setDelegate(params) {
|
|
1520
|
-
return this.simulateAndSendWithAttribution({
|
|
1521
|
-
address: this.escrowAddress,
|
|
1522
|
-
abi: this.escrowAbi,
|
|
1523
|
-
functionName: "setDelegate",
|
|
1524
|
-
args: [params.depositId, params.delegate],
|
|
1525
|
-
txOverrides: params.txOverrides
|
|
1526
|
-
});
|
|
1527
|
-
}
|
|
1528
|
-
/**
|
|
1529
|
-
* Removes the delegate from a deposit.
|
|
1530
|
-
*
|
|
1531
|
-
* @param params.depositId - The deposit ID
|
|
1532
|
-
* @param params.txOverrides - Optional viem transaction overrides
|
|
1533
|
-
* @returns Transaction hash
|
|
1534
|
-
*/
|
|
1535
|
-
async removeDelegate(params) {
|
|
1536
|
-
return this.simulateAndSendWithAttribution({
|
|
1537
|
-
address: this.escrowAddress,
|
|
1538
|
-
abi: this.escrowAbi,
|
|
1539
|
-
functionName: "removeDelegate",
|
|
1540
|
-
args: [params.depositId],
|
|
1541
|
-
txOverrides: params.txOverrides
|
|
1542
|
-
});
|
|
1543
|
-
}
|
|
1544
|
-
/**
|
|
1545
|
-
* Adds new payment methods to an existing deposit.
|
|
1546
|
-
*
|
|
1547
|
-
* @param params.depositId - The deposit ID
|
|
1548
|
-
* @param params.paymentMethods - Array of payment method hashes to add
|
|
1549
|
-
* @param params.paymentMethodData - Corresponding payment method configuration
|
|
1550
|
-
* @param params.txOverrides - Optional viem transaction overrides
|
|
1551
|
-
* @returns Transaction hash
|
|
1552
|
-
*/
|
|
1553
|
-
async addPaymentMethods(params) {
|
|
1554
|
-
return this.simulateAndSendWithAttribution({
|
|
1555
|
-
address: this.escrowAddress,
|
|
1556
|
-
abi: this.escrowAbi,
|
|
1557
|
-
functionName: "addPaymentMethods",
|
|
1558
|
-
args: [params.depositId, params.paymentMethods, params.paymentMethodData],
|
|
1559
|
-
txOverrides: params.txOverrides
|
|
1560
|
-
});
|
|
1996
|
+
return { depositDetails, prepared };
|
|
1561
1997
|
}
|
|
1562
1998
|
/**
|
|
1563
|
-
*
|
|
1564
|
-
*
|
|
1565
|
-
* @param params.depositId - The deposit ID
|
|
1566
|
-
* @param params.paymentMethod - Payment method hash to modify
|
|
1567
|
-
* @param params.isActive - Whether the payment method should accept intents
|
|
1568
|
-
* @param params.txOverrides - Optional viem transaction overrides
|
|
1569
|
-
* @returns Transaction hash
|
|
1999
|
+
* Prepare signalIntent transaction (all logic except simulation/send).
|
|
2000
|
+
* Returns the prepared transaction with encoded calldata.
|
|
1570
2001
|
*/
|
|
1571
|
-
async
|
|
1572
|
-
return this.simulateAndSendWithAttribution({
|
|
1573
|
-
address: this.escrowAddress,
|
|
1574
|
-
abi: this.escrowAbi,
|
|
1575
|
-
functionName: "setPaymentMethodActive",
|
|
1576
|
-
args: [params.depositId, params.paymentMethod, params.isActive],
|
|
1577
|
-
txOverrides: params.txOverrides
|
|
1578
|
-
});
|
|
1579
|
-
}
|
|
1580
|
-
/**
|
|
1581
|
-
* Deactivates a payment method on a deposit (convenience alias for setPaymentMethodActive).
|
|
1582
|
-
*
|
|
1583
|
-
* @param params.depositId - The deposit ID
|
|
1584
|
-
* @param params.paymentMethod - Payment method hash to deactivate
|
|
1585
|
-
* @param params.txOverrides - Optional viem transaction overrides
|
|
1586
|
-
* @returns Transaction hash
|
|
1587
|
-
*/
|
|
1588
|
-
async removePaymentMethod(params) {
|
|
1589
|
-
return this.setPaymentMethodActive({ depositId: params.depositId, paymentMethod: params.paymentMethod, isActive: false, txOverrides: params.txOverrides });
|
|
1590
|
-
}
|
|
1591
|
-
/**
|
|
1592
|
-
* Adds new currencies to a payment method on a deposit.
|
|
1593
|
-
*
|
|
1594
|
-
* @param params.depositId - The deposit ID
|
|
1595
|
-
* @param params.paymentMethod - Payment method hash to add currencies to
|
|
1596
|
-
* @param params.currencies - Array of currency configurations with code and min rate
|
|
1597
|
-
* @param params.txOverrides - Optional viem transaction overrides
|
|
1598
|
-
* @returns Transaction hash
|
|
1599
|
-
*/
|
|
1600
|
-
async addCurrencies(params) {
|
|
1601
|
-
return this.simulateAndSendWithAttribution({
|
|
1602
|
-
address: this.escrowAddress,
|
|
1603
|
-
abi: this.escrowAbi,
|
|
1604
|
-
functionName: "addCurrencies",
|
|
1605
|
-
args: [params.depositId, params.paymentMethod, params.currencies],
|
|
1606
|
-
txOverrides: params.txOverrides
|
|
1607
|
-
});
|
|
1608
|
-
}
|
|
1609
|
-
/**
|
|
1610
|
-
* Deactivates a currency for a payment method on a deposit.
|
|
1611
|
-
*
|
|
1612
|
-
* @param params.depositId - The deposit ID
|
|
1613
|
-
* @param params.paymentMethod - Payment method hash
|
|
1614
|
-
* @param params.currencyCode - Currency code hash to deactivate
|
|
1615
|
-
* @param params.txOverrides - Optional viem transaction overrides
|
|
1616
|
-
* @returns Transaction hash
|
|
1617
|
-
*/
|
|
1618
|
-
async deactivateCurrency(params) {
|
|
1619
|
-
return this.simulateAndSendWithAttribution({
|
|
1620
|
-
address: this.escrowAddress,
|
|
1621
|
-
abi: this.escrowAbi,
|
|
1622
|
-
functionName: "deactivateCurrency",
|
|
1623
|
-
args: [params.depositId, params.paymentMethod, params.currencyCode],
|
|
1624
|
-
txOverrides: params.txOverrides
|
|
1625
|
-
});
|
|
1626
|
-
}
|
|
1627
|
-
/**
|
|
1628
|
-
* Removes (deactivates) a currency from a payment method.
|
|
1629
|
-
* Alias for deactivateCurrency.
|
|
1630
|
-
*
|
|
1631
|
-
* @param params.depositId - The deposit ID
|
|
1632
|
-
* @param params.paymentMethod - Payment method hash
|
|
1633
|
-
* @param params.currencyCode - Currency code hash to remove
|
|
1634
|
-
* @param params.txOverrides - Optional viem transaction overrides
|
|
1635
|
-
* @returns Transaction hash
|
|
1636
|
-
*/
|
|
1637
|
-
async removeCurrency(params) {
|
|
1638
|
-
return this.deactivateCurrency(params);
|
|
1639
|
-
}
|
|
1640
|
-
/**
|
|
1641
|
-
* Removes expired intents from a deposit, freeing up locked funds.
|
|
1642
|
-
* Can be called by anyone (permissionless cleanup).
|
|
1643
|
-
*
|
|
1644
|
-
* @param params.depositId - The deposit ID to prune
|
|
1645
|
-
* @param params.txOverrides - Optional viem transaction overrides
|
|
1646
|
-
* @returns Transaction hash
|
|
1647
|
-
*/
|
|
1648
|
-
async pruneExpiredIntents(params) {
|
|
1649
|
-
return this.simulateAndSendWithAttribution({
|
|
1650
|
-
address: this.escrowAddress,
|
|
1651
|
-
abi: this.escrowAbi,
|
|
1652
|
-
functionName: "pruneExpiredIntents",
|
|
1653
|
-
args: [params.depositId],
|
|
1654
|
-
txOverrides: params.txOverrides
|
|
1655
|
-
});
|
|
1656
|
-
}
|
|
1657
|
-
// ───────────────────────────────────────────────────────────────────────────
|
|
1658
|
-
// SUPPORTING: INTENT OPERATIONS
|
|
1659
|
-
// (Used by takers/buyers - not primary SDK functionality)
|
|
1660
|
-
// ───────────────────────────────────────────────────────────────────────────
|
|
1661
|
-
/**
|
|
1662
|
-
* **Supporting Method** - Signals intent to use a deposit.
|
|
1663
|
-
*
|
|
1664
|
-
* > **Note**: This method is typically used by takers/buyers who want to
|
|
1665
|
-
* > purchase crypto by paying fiat. Liquidity providers generally don't
|
|
1666
|
-
* > need to call this method directly.
|
|
1667
|
-
*
|
|
1668
|
-
* This reserves funds from a deposit and creates an intent that must be
|
|
1669
|
-
* fulfilled (via `fulfillIntent`) or will expire. The taker commits to
|
|
1670
|
-
* sending fiat payment to the deposit's payee.
|
|
1671
|
-
*
|
|
1672
|
-
* If `gatingServiceSignature` is not provided, the SDK will automatically
|
|
1673
|
-
* fetch one from the API (requires `apiKey` or `authorizationToken`).
|
|
1674
|
-
*
|
|
1675
|
-
* @param params.depositId - The deposit to use
|
|
1676
|
-
* @param params.amount - Amount of tokens to claim (in token units)
|
|
1677
|
-
* @param params.toAddress - Address to receive the tokens when fulfilled
|
|
1678
|
-
* @param params.processorName - Payment platform (e.g., 'wise', 'revolut')
|
|
1679
|
-
* @param params.payeeDetails - Hashed payee details (from deposit)
|
|
1680
|
-
* @param params.fiatCurrencyCode - Fiat currency code (e.g., 'USD', 'EUR')
|
|
1681
|
-
* @param params.conversionRate - Agreed conversion rate (18 decimals)
|
|
1682
|
-
* @param params.referrer - Optional referrer address for fee sharing
|
|
1683
|
-
* @param params.referrerFee - Optional referrer fee amount
|
|
1684
|
-
* @param params.postIntentHook - Optional hook contract to call after signaling
|
|
1685
|
-
* @param params.data - Optional data to pass to the hook
|
|
1686
|
-
* @param params.gatingServiceSignature - Pre-obtained signature (if not auto-fetching)
|
|
1687
|
-
* @param params.signatureExpiration - Signature expiration timestamp
|
|
1688
|
-
* @param params.txOverrides - Optional viem transaction overrides
|
|
1689
|
-
* @returns Transaction hash
|
|
1690
|
-
*
|
|
1691
|
-
* @example
|
|
1692
|
-
* ```typescript
|
|
1693
|
-
* const hash = await client.signalIntent({
|
|
1694
|
-
* depositId: 42n,
|
|
1695
|
-
* amount: 100_000000n, // 100 USDC
|
|
1696
|
-
* toAddress: '0x...',
|
|
1697
|
-
* processorName: 'wise',
|
|
1698
|
-
* payeeDetails: '0x...',
|
|
1699
|
-
* fiatCurrencyCode: 'USD',
|
|
1700
|
-
* conversionRate: 1_020000000000000000n, // 1.02
|
|
1701
|
-
* });
|
|
1702
|
-
* ```
|
|
1703
|
-
*/
|
|
1704
|
-
async signalIntent(params) {
|
|
2002
|
+
async prepareSignalIntent(params) {
|
|
1705
2003
|
if (!this.orchestratorAddress || !this.orchestratorAbi) throw new Error("Orchestrator not available");
|
|
1706
2004
|
const catalog = getPaymentMethodsCatalog(this.chainId, this.runtimeEnv);
|
|
1707
2005
|
const paymentMethod = resolvePaymentMethodHashFromCatalog(params.processorName, catalog);
|
|
@@ -1747,80 +2045,55 @@ var Zkp2pClient = class {
|
|
|
1747
2045
|
postIntentHook: params.postIntentHook ?? "0x0000000000000000000000000000000000000000",
|
|
1748
2046
|
data: params.data ?? "0x"
|
|
1749
2047
|
}];
|
|
1750
|
-
|
|
1751
|
-
|
|
2048
|
+
const { referrer } = params.txOverrides ?? {};
|
|
2049
|
+
const data = encodeWithAttribution(
|
|
2050
|
+
{
|
|
2051
|
+
abi: this.orchestratorAbi,
|
|
2052
|
+
functionName: "signalIntent",
|
|
2053
|
+
args
|
|
2054
|
+
},
|
|
2055
|
+
referrer
|
|
2056
|
+
);
|
|
2057
|
+
return {
|
|
2058
|
+
to: this.orchestratorAddress,
|
|
2059
|
+
data,
|
|
2060
|
+
value: 0n,
|
|
2061
|
+
chainId: this.chainId,
|
|
1752
2062
|
abi: this.orchestratorAbi,
|
|
1753
2063
|
functionName: "signalIntent",
|
|
1754
|
-
args
|
|
1755
|
-
|
|
1756
|
-
});
|
|
2064
|
+
args
|
|
2065
|
+
};
|
|
1757
2066
|
}
|
|
1758
2067
|
/**
|
|
1759
|
-
*
|
|
1760
|
-
*
|
|
1761
|
-
* Only the intent owner can cancel. Releases reserved funds back to the deposit.
|
|
1762
|
-
*
|
|
1763
|
-
* @param params.intentHash - The intent hash to cancel (0x-prefixed, 32 bytes)
|
|
1764
|
-
* @param params.txOverrides - Optional viem transaction overrides
|
|
1765
|
-
* @returns Transaction hash
|
|
2068
|
+
* Prepare cancelIntent transaction (all logic except simulation/send).
|
|
1766
2069
|
*/
|
|
1767
|
-
async
|
|
2070
|
+
async prepareCancelIntent(params) {
|
|
1768
2071
|
if (!this.orchestratorAddress || !this.orchestratorAbi) throw new Error("Orchestrator not available");
|
|
1769
|
-
|
|
1770
|
-
|
|
2072
|
+
const args = [params.intentHash];
|
|
2073
|
+
const { referrer } = params.txOverrides ?? {};
|
|
2074
|
+
const data = encodeWithAttribution(
|
|
2075
|
+
{
|
|
2076
|
+
abi: this.orchestratorAbi,
|
|
2077
|
+
functionName: "cancelIntent",
|
|
2078
|
+
args
|
|
2079
|
+
},
|
|
2080
|
+
referrer
|
|
2081
|
+
);
|
|
2082
|
+
return {
|
|
2083
|
+
to: this.orchestratorAddress,
|
|
2084
|
+
data,
|
|
2085
|
+
value: 0n,
|
|
2086
|
+
chainId: this.chainId,
|
|
1771
2087
|
abi: this.orchestratorAbi,
|
|
1772
2088
|
functionName: "cancelIntent",
|
|
1773
|
-
args
|
|
1774
|
-
|
|
1775
|
-
});
|
|
1776
|
-
}
|
|
1777
|
-
/**
|
|
1778
|
-
* **Supporting Method** - Releases funds back to the deposit owner.
|
|
1779
|
-
*
|
|
1780
|
-
* Called by the deposit owner when they want to reject an intent
|
|
1781
|
-
* (e.g., payment verification failed or intent expired).
|
|
1782
|
-
*
|
|
1783
|
-
* @param params.intentHash - The intent hash (0x-prefixed, 32 bytes)
|
|
1784
|
-
* @param params.txOverrides - Optional viem transaction overrides
|
|
1785
|
-
* @returns Transaction hash
|
|
1786
|
-
*/
|
|
1787
|
-
async releaseFundsToPayer(params) {
|
|
1788
|
-
if (!this.orchestratorAddress || !this.orchestratorAbi) throw new Error("Orchestrator not available");
|
|
1789
|
-
return this.simulateAndSendWithAttribution({
|
|
1790
|
-
address: this.orchestratorAddress,
|
|
1791
|
-
abi: this.orchestratorAbi,
|
|
1792
|
-
functionName: "releaseFundsToPayer",
|
|
1793
|
-
args: [params.intentHash],
|
|
1794
|
-
txOverrides: params.txOverrides
|
|
1795
|
-
});
|
|
2089
|
+
args
|
|
2090
|
+
};
|
|
1796
2091
|
}
|
|
1797
2092
|
/**
|
|
1798
|
-
*
|
|
1799
|
-
*
|
|
1800
|
-
* > **Note**: This method is typically used by takers/buyers after they've
|
|
1801
|
-
* > sent fiat payment. Liquidity providers generally don't call this directly.
|
|
1802
|
-
*
|
|
1803
|
-
* This is the final step in the off-ramp flow. After the taker has sent
|
|
1804
|
-
* fiat payment, they generate a proof (via the browser extension) and
|
|
1805
|
-
* submit it here. The SDK handles attestation service calls automatically.
|
|
1806
|
-
*
|
|
1807
|
-
* **Flow:**
|
|
1808
|
-
* 1. Intent parameters are derived from the indexer/ProtocolViewer
|
|
1809
|
-
* 2. Proof is sent to the attestation service for verification
|
|
1810
|
-
* 3. Attestation response is encoded and submitted on-chain
|
|
1811
|
-
* 4. Funds are released to the intent's `toAddress`
|
|
1812
|
-
*
|
|
1813
|
-
* @param params.intentHash - The intent hash to fulfill (0x-prefixed, 32 bytes)
|
|
1814
|
-
* @param params.proof - Payment proof from Reclaim (object or JSON string)
|
|
1815
|
-
* @param params.timestampBufferMs - Allowed timestamp variance (default: 300000ms)
|
|
1816
|
-
* @param params.attestationServiceUrl - Override attestation service URL
|
|
1817
|
-
* @param params.verifyingContract - Override verifier contract address
|
|
1818
|
-
* @param params.postIntentHookData - Data to pass to post-intent hook
|
|
1819
|
-
* @param params.txOverrides - Optional viem transaction overrides
|
|
1820
|
-
* @param params.callbacks - Lifecycle callbacks for UI updates
|
|
1821
|
-
* @returns Transaction hash
|
|
2093
|
+
* Prepare fulfillIntent transaction (all logic except simulation/send).
|
|
2094
|
+
* Includes fetching intent inputs and calling attestation service.
|
|
1822
2095
|
*/
|
|
1823
|
-
async
|
|
2096
|
+
async prepareFulfillIntent(params) {
|
|
1824
2097
|
if (!this.orchestratorAddress || !this.orchestratorAbi) throw new Error("Orchestrator not available");
|
|
1825
2098
|
const intentHash = params.intentHash;
|
|
1826
2099
|
const attUrl = params.attestationServiceUrl ?? this.defaultAttestationService();
|
|
@@ -1834,10 +2107,10 @@ var Zkp2pClient = class {
|
|
|
1834
2107
|
const paymentMethodHash = inputs.paymentMethodHash || "0x";
|
|
1835
2108
|
const timestampBufferMs = params.timestampBufferMs ?? "300000";
|
|
1836
2109
|
const catalog = getPaymentMethodsCatalog(this.chainId, this.runtimeEnv);
|
|
1837
|
-
const { resolvePaymentMethodNameFromHash: resolvePaymentMethodNameFromHash2 } = await import('./paymentResolution-
|
|
2110
|
+
const { resolvePaymentMethodNameFromHash: resolvePaymentMethodNameFromHash2 } = await import('./paymentResolution-2FP3NLM3.mjs');
|
|
1838
2111
|
const platformName = resolvePaymentMethodNameFromHash2(paymentMethodHash, catalog);
|
|
1839
2112
|
if (!platformName) throw new Error("Unknown paymentMethodHash for this network/env; update SDK catalogs.");
|
|
1840
|
-
const { resolvePlatformAttestationConfig } = await import('./constants-
|
|
2113
|
+
const { resolvePlatformAttestationConfig } = await import('./constants-ZICRSYZM.mjs');
|
|
1841
2114
|
const cfg = resolvePlatformAttestationConfig(platformName);
|
|
1842
2115
|
const platform = cfg.actionPlatform;
|
|
1843
2116
|
const actionType = cfg.actionType;
|
|
@@ -1858,7 +2131,6 @@ var Zkp2pClient = class {
|
|
|
1858
2131
|
timestampBufferMs
|
|
1859
2132
|
}
|
|
1860
2133
|
};
|
|
1861
|
-
params?.callbacks?.onAttestationStart?.();
|
|
1862
2134
|
const att = await apiCreatePaymentAttestation(payload, attUrl, platform, actionType);
|
|
1863
2135
|
const paymentProof = encodePaymentAttestation(att);
|
|
1864
2136
|
const verificationData = encodeVerifyPaymentData({
|
|
@@ -1872,15 +2144,24 @@ var Zkp2pClient = class {
|
|
|
1872
2144
|
verificationData,
|
|
1873
2145
|
postIntentHookData: params.postIntentHookData ?? "0x"
|
|
1874
2146
|
}];
|
|
1875
|
-
const
|
|
1876
|
-
|
|
2147
|
+
const { referrer } = params.txOverrides ?? {};
|
|
2148
|
+
const data = encodeWithAttribution(
|
|
2149
|
+
{
|
|
2150
|
+
abi: this.orchestratorAbi,
|
|
2151
|
+
functionName: "fulfillIntent",
|
|
2152
|
+
args
|
|
2153
|
+
},
|
|
2154
|
+
referrer
|
|
2155
|
+
);
|
|
2156
|
+
return {
|
|
2157
|
+
to: this.orchestratorAddress,
|
|
2158
|
+
data,
|
|
2159
|
+
value: 0n,
|
|
2160
|
+
chainId: this.chainId,
|
|
1877
2161
|
abi: this.orchestratorAbi,
|
|
1878
2162
|
functionName: "fulfillIntent",
|
|
1879
|
-
args
|
|
1880
|
-
|
|
1881
|
-
});
|
|
1882
|
-
params?.callbacks?.onTxSent?.(txHash);
|
|
1883
|
-
return txHash;
|
|
2163
|
+
args
|
|
2164
|
+
};
|
|
1884
2165
|
}
|
|
1885
2166
|
defaultAttestationService() {
|
|
1886
2167
|
return this.runtimeEnv === "staging" ? "https://attestation-service-staging.zkp2p.xyz" : "https://attestation-service.zkp2p.xyz";
|
|
@@ -1991,11 +2272,11 @@ var Zkp2pClient = class {
|
|
|
1991
2272
|
try {
|
|
1992
2273
|
const { address, abi } = this.requireProtocolViewer();
|
|
1993
2274
|
const raw = await this.publicClient.readContract({ address, abi, functionName: "getDeposit", args: [id] });
|
|
1994
|
-
const { parseDepositView: parseDepositView2 } = await import('./protocolViewerParsers-
|
|
2275
|
+
const { parseDepositView: parseDepositView2 } = await import('./protocolViewerParsers-EH5DGVSU.mjs');
|
|
1995
2276
|
return parseDepositView2(raw);
|
|
1996
2277
|
} catch (e) {
|
|
1997
2278
|
const raw = await this.publicClient.readContract({ address: this.escrowAddress, abi: this.escrowAbi, functionName: "getDeposit", args: [id] });
|
|
1998
|
-
const { parseDepositView: parseDepositView2 } = await import('./protocolViewerParsers-
|
|
2279
|
+
const { parseDepositView: parseDepositView2 } = await import('./protocolViewerParsers-EH5DGVSU.mjs');
|
|
1999
2280
|
return parseDepositView2(raw);
|
|
2000
2281
|
}
|
|
2001
2282
|
}
|
|
@@ -2007,7 +2288,7 @@ var Zkp2pClient = class {
|
|
|
2007
2288
|
*/
|
|
2008
2289
|
async getPvDepositsFromIds(ids) {
|
|
2009
2290
|
if (!this.protocolViewerAddress || !this.protocolViewerAbi) {
|
|
2010
|
-
const { parseDepositView: parseDepositView3 } = await import('./protocolViewerParsers-
|
|
2291
|
+
const { parseDepositView: parseDepositView3 } = await import('./protocolViewerParsers-EH5DGVSU.mjs');
|
|
2011
2292
|
const results = [];
|
|
2012
2293
|
for (const id of ids) {
|
|
2013
2294
|
const raw2 = await this.publicClient.readContract({
|
|
@@ -2027,7 +2308,7 @@ var Zkp2pClient = class {
|
|
|
2027
2308
|
functionName: "getDepositFromIds",
|
|
2028
2309
|
args: [bn]
|
|
2029
2310
|
});
|
|
2030
|
-
const { parseDepositView: parseDepositView2 } = await import('./protocolViewerParsers-
|
|
2311
|
+
const { parseDepositView: parseDepositView2 } = await import('./protocolViewerParsers-EH5DGVSU.mjs');
|
|
2031
2312
|
return raw.map(parseDepositView2);
|
|
2032
2313
|
}
|
|
2033
2314
|
/**
|
|
@@ -2040,11 +2321,11 @@ var Zkp2pClient = class {
|
|
|
2040
2321
|
try {
|
|
2041
2322
|
const { address, abi } = this.requireProtocolViewer();
|
|
2042
2323
|
const raw = await this.publicClient.readContract({ address, abi, functionName: "getAccountDeposits", args: [owner] });
|
|
2043
|
-
const { parseDepositView: parseDepositView2 } = await import('./protocolViewerParsers-
|
|
2324
|
+
const { parseDepositView: parseDepositView2 } = await import('./protocolViewerParsers-EH5DGVSU.mjs');
|
|
2044
2325
|
return raw.map(parseDepositView2);
|
|
2045
2326
|
} catch (e) {
|
|
2046
2327
|
const raw = await this.publicClient.readContract({ address: this.escrowAddress, abi: this.escrowAbi, functionName: "getAccountDeposits", args: [owner] });
|
|
2047
|
-
const { parseDepositView: parseDepositView2 } = await import('./protocolViewerParsers-
|
|
2328
|
+
const { parseDepositView: parseDepositView2 } = await import('./protocolViewerParsers-EH5DGVSU.mjs');
|
|
2048
2329
|
return raw.map(parseDepositView2);
|
|
2049
2330
|
}
|
|
2050
2331
|
}
|
|
@@ -2063,7 +2344,7 @@ var Zkp2pClient = class {
|
|
|
2063
2344
|
functionName: "getAccountIntents",
|
|
2064
2345
|
args: [owner]
|
|
2065
2346
|
});
|
|
2066
|
-
const { parseIntentView: parseIntentView2 } = await import('./protocolViewerParsers-
|
|
2347
|
+
const { parseIntentView: parseIntentView2 } = await import('./protocolViewerParsers-EH5DGVSU.mjs');
|
|
2067
2348
|
return raw.map(parseIntentView2);
|
|
2068
2349
|
}
|
|
2069
2350
|
/**
|
|
@@ -2080,7 +2361,7 @@ var Zkp2pClient = class {
|
|
|
2080
2361
|
functionName: "getIntent",
|
|
2081
2362
|
args: [intentHash]
|
|
2082
2363
|
});
|
|
2083
|
-
const { parseIntentView: parseIntentView2 } = await import('./protocolViewerParsers-
|
|
2364
|
+
const { parseIntentView: parseIntentView2 } = await import('./protocolViewerParsers-EH5DGVSU.mjs');
|
|
2084
2365
|
return parseIntentView2(raw);
|
|
2085
2366
|
}
|
|
2086
2367
|
// ╔═══════════════════════════════════════════════════════════════════════════╗
|
|
@@ -2182,6 +2463,199 @@ var Zkp2pClient = class {
|
|
|
2182
2463
|
}
|
|
2183
2464
|
};
|
|
2184
2465
|
|
|
2466
|
+
// src/extension.ts
|
|
2467
|
+
var PEER_EXTENSION_CHROME_URL = "https://chromewebstore.google.com/detail/peerauth-authenticate-and/ijpgccednehjpeclfcllnjjcmiohdjih";
|
|
2468
|
+
var resolveWindow = (options) => {
|
|
2469
|
+
if (options?.window) {
|
|
2470
|
+
return options.window;
|
|
2471
|
+
}
|
|
2472
|
+
if (typeof window === "undefined") {
|
|
2473
|
+
return void 0;
|
|
2474
|
+
}
|
|
2475
|
+
return window;
|
|
2476
|
+
};
|
|
2477
|
+
var requirePeer = (options) => {
|
|
2478
|
+
const resolvedWindow = resolveWindow(options);
|
|
2479
|
+
if (!resolvedWindow) {
|
|
2480
|
+
throw new Error("Peer extension SDK requires a browser window.");
|
|
2481
|
+
}
|
|
2482
|
+
if (!resolvedWindow.peer) {
|
|
2483
|
+
throw new Error("Peer extension not available. Install or enable the Peer extension.");
|
|
2484
|
+
}
|
|
2485
|
+
return resolvedWindow.peer;
|
|
2486
|
+
};
|
|
2487
|
+
var isPeerExtensionAvailable = (options) => {
|
|
2488
|
+
const resolvedWindow = resolveWindow(options);
|
|
2489
|
+
return Boolean(resolvedWindow?.peer);
|
|
2490
|
+
};
|
|
2491
|
+
var openPeerExtensionInstallPage = (options) => {
|
|
2492
|
+
const resolvedWindow = resolveWindow(options);
|
|
2493
|
+
if (!resolvedWindow) {
|
|
2494
|
+
throw new Error("Peer extension SDK requires a browser window.");
|
|
2495
|
+
}
|
|
2496
|
+
resolvedWindow.open(PEER_EXTENSION_CHROME_URL, "_blank", "noopener,noreferrer");
|
|
2497
|
+
};
|
|
2498
|
+
var getPeerExtensionState = async (options) => {
|
|
2499
|
+
if (!isPeerExtensionAvailable(options)) {
|
|
2500
|
+
return "needs_install";
|
|
2501
|
+
}
|
|
2502
|
+
try {
|
|
2503
|
+
const status = await requirePeer(options).checkConnectionStatus();
|
|
2504
|
+
return status === "connected" ? "ready" : "needs_connection";
|
|
2505
|
+
} catch (error) {
|
|
2506
|
+
return "needs_connection";
|
|
2507
|
+
}
|
|
2508
|
+
};
|
|
2509
|
+
var fiatAmountRegex = /^-?\d*(\.\d{0,6})?$/;
|
|
2510
|
+
var usdcAmountRegex = /^\d+$/;
|
|
2511
|
+
var assertObjectInput = (params) => {
|
|
2512
|
+
if (params === void 0) {
|
|
2513
|
+
return {};
|
|
2514
|
+
}
|
|
2515
|
+
if (params === null || typeof params !== "object" || Array.isArray(params)) {
|
|
2516
|
+
throw new Error("Peer extension onramp expects an object of query params.");
|
|
2517
|
+
}
|
|
2518
|
+
return params;
|
|
2519
|
+
};
|
|
2520
|
+
var normalizeOptionalString = (value, label) => {
|
|
2521
|
+
if (value === void 0) {
|
|
2522
|
+
return void 0;
|
|
2523
|
+
}
|
|
2524
|
+
if (typeof value !== "string") {
|
|
2525
|
+
throw new Error(`Peer extension onramp ${label} must be a non-empty string.`);
|
|
2526
|
+
}
|
|
2527
|
+
const trimmed = value.trim();
|
|
2528
|
+
if (!trimmed) {
|
|
2529
|
+
throw new Error(`Peer extension onramp ${label} must be a non-empty string.`);
|
|
2530
|
+
}
|
|
2531
|
+
return trimmed;
|
|
2532
|
+
};
|
|
2533
|
+
var normalizeOptionalUrl = (value, label) => {
|
|
2534
|
+
const trimmed = normalizeOptionalString(value, label);
|
|
2535
|
+
if (trimmed === void 0) {
|
|
2536
|
+
return void 0;
|
|
2537
|
+
}
|
|
2538
|
+
let parsed;
|
|
2539
|
+
try {
|
|
2540
|
+
parsed = new URL(trimmed);
|
|
2541
|
+
} catch (error) {
|
|
2542
|
+
throw new Error(`Peer extension onramp ${label} must be a valid URL.`);
|
|
2543
|
+
}
|
|
2544
|
+
if (parsed.protocol !== "http:" && parsed.protocol !== "https:") {
|
|
2545
|
+
throw new Error(`Peer extension onramp ${label} must use http or https.`);
|
|
2546
|
+
}
|
|
2547
|
+
return trimmed;
|
|
2548
|
+
};
|
|
2549
|
+
var normalizeFiatAmount = (value) => {
|
|
2550
|
+
if (value === void 0) {
|
|
2551
|
+
return void 0;
|
|
2552
|
+
}
|
|
2553
|
+
const normalized = typeof value === "number" ? String(value) : value;
|
|
2554
|
+
if (typeof normalized !== "string") {
|
|
2555
|
+
throw new Error("Peer extension onramp inputAmount must be a string or number.");
|
|
2556
|
+
}
|
|
2557
|
+
const trimmed = normalized.trim();
|
|
2558
|
+
if (!trimmed) {
|
|
2559
|
+
throw new Error("Peer extension onramp inputAmount must be a non-empty value.");
|
|
2560
|
+
}
|
|
2561
|
+
if (!fiatAmountRegex.test(trimmed)) {
|
|
2562
|
+
throw new Error(
|
|
2563
|
+
"Peer extension onramp inputAmount must be a non-negative number with up to 6 decimals."
|
|
2564
|
+
);
|
|
2565
|
+
}
|
|
2566
|
+
if (Number.isNaN(Number(trimmed)) || Number(trimmed) < 0) {
|
|
2567
|
+
throw new Error(
|
|
2568
|
+
"Peer extension onramp inputAmount must be a non-negative number with up to 6 decimals."
|
|
2569
|
+
);
|
|
2570
|
+
}
|
|
2571
|
+
return trimmed;
|
|
2572
|
+
};
|
|
2573
|
+
var normalizeUsdcAmount = (value) => {
|
|
2574
|
+
if (value === void 0) {
|
|
2575
|
+
return void 0;
|
|
2576
|
+
}
|
|
2577
|
+
if (typeof value === "bigint") {
|
|
2578
|
+
if (value < 0n) {
|
|
2579
|
+
throw new Error("Peer extension onramp amountUsdc must be a non-negative integer.");
|
|
2580
|
+
}
|
|
2581
|
+
return value.toString();
|
|
2582
|
+
}
|
|
2583
|
+
if (typeof value === "number") {
|
|
2584
|
+
if (!Number.isFinite(value) || value < 0 || !Number.isInteger(value)) {
|
|
2585
|
+
throw new Error("Peer extension onramp amountUsdc must be a non-negative integer.");
|
|
2586
|
+
}
|
|
2587
|
+
return String(value);
|
|
2588
|
+
}
|
|
2589
|
+
if (typeof value !== "string") {
|
|
2590
|
+
throw new Error("Peer extension onramp amountUsdc must be a string, number, or bigint.");
|
|
2591
|
+
}
|
|
2592
|
+
const trimmed = value.trim();
|
|
2593
|
+
if (!trimmed) {
|
|
2594
|
+
throw new Error("Peer extension onramp amountUsdc must be a non-empty value.");
|
|
2595
|
+
}
|
|
2596
|
+
if (!usdcAmountRegex.test(trimmed)) {
|
|
2597
|
+
throw new Error("Peer extension onramp amountUsdc must be a non-negative integer.");
|
|
2598
|
+
}
|
|
2599
|
+
return trimmed;
|
|
2600
|
+
};
|
|
2601
|
+
var intentHashRegex = /^0x[a-fA-F0-9]{64}$/;
|
|
2602
|
+
var normalizeIntentHash = (value) => {
|
|
2603
|
+
if (value === void 0) {
|
|
2604
|
+
return void 0;
|
|
2605
|
+
}
|
|
2606
|
+
if (typeof value !== "string") {
|
|
2607
|
+
throw new Error("Peer extension onramp intentHash must be a string.");
|
|
2608
|
+
}
|
|
2609
|
+
const trimmed = value.trim();
|
|
2610
|
+
if (!trimmed) {
|
|
2611
|
+
throw new Error("Peer extension onramp intentHash must be a non-empty string.");
|
|
2612
|
+
}
|
|
2613
|
+
if (!intentHashRegex.test(trimmed)) {
|
|
2614
|
+
throw new Error(
|
|
2615
|
+
"Peer extension onramp intentHash must be a valid bytes32 hex string (0x + 64 hex characters)."
|
|
2616
|
+
);
|
|
2617
|
+
}
|
|
2618
|
+
return trimmed.toLowerCase();
|
|
2619
|
+
};
|
|
2620
|
+
var buildOnrampQueryString = (params) => {
|
|
2621
|
+
const validated = assertObjectInput(params);
|
|
2622
|
+
const searchParams = new URLSearchParams();
|
|
2623
|
+
const setParam = (key, value) => {
|
|
2624
|
+
if (value !== void 0) {
|
|
2625
|
+
searchParams.set(key, value);
|
|
2626
|
+
}
|
|
2627
|
+
};
|
|
2628
|
+
setParam("referrer", normalizeOptionalString(validated.referrer, "referrer"));
|
|
2629
|
+
setParam("referrerLogo", normalizeOptionalUrl(validated.referrerLogo, "referrerLogo"));
|
|
2630
|
+
setParam("inputCurrency", normalizeOptionalString(validated.inputCurrency, "inputCurrency"));
|
|
2631
|
+
setParam("inputAmount", normalizeFiatAmount(validated.inputAmount));
|
|
2632
|
+
setParam(
|
|
2633
|
+
"paymentPlatform",
|
|
2634
|
+
normalizeOptionalString(validated.paymentPlatform, "paymentPlatform")
|
|
2635
|
+
);
|
|
2636
|
+
setParam("toToken", normalizeOptionalString(validated.toToken, "toToken"));
|
|
2637
|
+
setParam("amountUsdc", normalizeUsdcAmount(validated.amountUsdc));
|
|
2638
|
+
setParam(
|
|
2639
|
+
"recipientAddress",
|
|
2640
|
+
normalizeOptionalString(validated.recipientAddress, "recipientAddress")
|
|
2641
|
+
);
|
|
2642
|
+
setParam("callbackUrl", normalizeOptionalUrl(validated.callbackUrl, "callbackUrl"));
|
|
2643
|
+
setParam("intentHash", normalizeIntentHash(validated.intentHash));
|
|
2644
|
+
return searchParams.toString();
|
|
2645
|
+
};
|
|
2646
|
+
var createPeerExtensionSdk = (options = {}) => ({
|
|
2647
|
+
isAvailable: () => isPeerExtensionAvailable(options),
|
|
2648
|
+
requestConnection: () => requirePeer(options).requestConnection(),
|
|
2649
|
+
checkConnectionStatus: () => requirePeer(options).checkConnectionStatus(),
|
|
2650
|
+
openSidebar: (route) => requirePeer(options).openSidebar(route),
|
|
2651
|
+
onramp: (params) => requirePeer(options).onramp(buildOnrampQueryString(params)),
|
|
2652
|
+
onProofComplete: (callback) => requirePeer(options).onProofComplete(callback),
|
|
2653
|
+
getVersion: () => requirePeer(options).getVersion(),
|
|
2654
|
+
openInstallPage: () => openPeerExtensionInstallPage(options),
|
|
2655
|
+
getState: () => getPeerExtensionState(options)
|
|
2656
|
+
});
|
|
2657
|
+
var peerExtensionSdk = createPeerExtensionSdk();
|
|
2658
|
+
|
|
2185
2659
|
// src/utils/logger.ts
|
|
2186
2660
|
var currentLevel = "info";
|
|
2187
2661
|
function setLogLevel(level) {
|
|
@@ -2220,6 +2694,6 @@ var logger = {
|
|
|
2220
2694
|
}
|
|
2221
2695
|
};
|
|
2222
2696
|
|
|
2223
|
-
export { BASE_BUILDER_CODE, IndexerClient, IndexerDepositService, Zkp2pClient as OfframpClient, ZKP2P_ANDROID_REFERRER, ZKP2P_IOS_REFERRER, Zkp2pClient, apiGetPayeeDetails, apiGetTakerTier, apiPostDepositDetails, apiValidatePayeeDetails, appendAttributionToCalldata, convertDepositsForLiquidity, convertIndexerDepositToEscrowView, convertIndexerIntentsToEscrowViews, createCompositeDepositId, defaultIndexerEndpoint, fetchFulfillmentAndPayment as fetchIndexerFulfillmentAndPayment, getAttributionDataSuffix, logger, sendTransactionWithAttribution, setLogLevel };
|
|
2697
|
+
export { BASE_BUILDER_CODE, IndexerClient, IndexerDepositService, Zkp2pClient as OfframpClient, PEER_EXTENSION_CHROME_URL, ZKP2P_ANDROID_REFERRER, ZKP2P_IOS_REFERRER, Zkp2pClient, apiGetOwnerDeposits, apiGetPayeeDetails, apiGetTakerTier, apiPostDepositDetails, apiValidatePayeeDetails, appendAttributionToCalldata, convertDepositsForLiquidity, convertIndexerDepositToEscrowView, convertIndexerIntentsToEscrowViews, createCompositeDepositId, createPeerExtensionSdk, defaultIndexerEndpoint, encodeWithAttribution, fetchFulfillmentAndPayment as fetchIndexerFulfillmentAndPayment, getAttributionDataSuffix, getPeerExtensionState, isPeerExtensionAvailable, logger, openPeerExtensionInstallPage, peerExtensionSdk, sendTransactionWithAttribution, setLogLevel };
|
|
2224
2698
|
//# sourceMappingURL=index.mjs.map
|
|
2225
2699
|
//# sourceMappingURL=index.mjs.map
|