@zkp2p/sdk 0.5.2 → 0.5.5
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 +4 -4
- package/dist/{chunk-L526MKG3.mjs → chunk-NKTSEXJB.mjs} +37 -5
- package/dist/{chunk-L526MKG3.mjs.map → chunk-NKTSEXJB.mjs.map} +1 -1
- package/dist/{chunk-LPJE2MN7.mjs → chunk-TGMRXUP2.mjs} +28 -3
- package/dist/chunk-TGMRXUP2.mjs.map +1 -0
- package/dist/index.cjs +194 -85
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +42 -11
- package/dist/index.d.ts +42 -11
- package/dist/index.mjs +153 -90
- package/dist/index.mjs.map +1 -1
- package/dist/protocolViewerParsers-3JGPLQGP.mjs +5 -0
- package/dist/{protocolViewerParsers-GGSM2243.mjs.map → protocolViewerParsers-3JGPLQGP.mjs.map} +1 -1
- package/dist/react.cjs +31 -16
- package/dist/react.cjs.map +1 -1
- package/dist/react.d.mts +2 -2
- package/dist/react.d.ts +2 -2
- package/dist/react.mjs +6 -18
- package/dist/react.mjs.map +1 -1
- package/dist/{vaultUtils-CtNcKlpg.d.mts → vaultUtils-DOOl9QUP.d.mts} +15 -17
- package/dist/{vaultUtils-CtNcKlpg.d.ts → vaultUtils-DOOl9QUP.d.ts} +15 -17
- package/package.json +3 -3
- package/dist/chunk-LPJE2MN7.mjs.map +0 -1
- package/dist/protocolViewerParsers-GGSM2243.mjs +0 -5
|
@@ -1,3 +1,28 @@
|
|
|
1
|
+
// src/takerTiers.ts
|
|
2
|
+
var TAKER_TIER_SCHEDULE = [
|
|
3
|
+
{ tier: "PLATINUM", perIntentCapUsd: 5e3, minVolumeUsd: 25e3, maxVolumeUsd: Infinity },
|
|
4
|
+
{ tier: "PRO", perIntentCapUsd: 2500, minVolumeUsd: 1e4, maxVolumeUsd: 24999 },
|
|
5
|
+
{ tier: "PLUS", perIntentCapUsd: 1e3, minVolumeUsd: 2e3, maxVolumeUsd: 9999 },
|
|
6
|
+
{ tier: "PEER", perIntentCapUsd: 250, minVolumeUsd: 500, maxVolumeUsd: 1999 },
|
|
7
|
+
{ tier: "PEASANT", perIntentCapUsd: 100, minVolumeUsd: 0, maxVolumeUsd: 499 }
|
|
8
|
+
];
|
|
9
|
+
var TAKER_TIER_ORDER = [
|
|
10
|
+
"PEASANT",
|
|
11
|
+
"PEER",
|
|
12
|
+
"PLUS",
|
|
13
|
+
"PRO",
|
|
14
|
+
"PLATINUM"
|
|
15
|
+
];
|
|
16
|
+
var TAKER_TIER_CAPS = Object.fromEntries(
|
|
17
|
+
TAKER_TIER_SCHEDULE.map((entry) => [entry.tier, entry.perIntentCapUsd])
|
|
18
|
+
);
|
|
19
|
+
function getNextTakerTier(currentTier) {
|
|
20
|
+
if (!currentTier) return null;
|
|
21
|
+
const index = TAKER_TIER_ORDER.indexOf(currentTier);
|
|
22
|
+
if (index === -1 || index >= TAKER_TIER_ORDER.length - 1) return null;
|
|
23
|
+
return TAKER_TIER_ORDER[index + 1];
|
|
24
|
+
}
|
|
25
|
+
|
|
1
26
|
// src/react/hooks/vaultUtils.ts
|
|
2
27
|
var ZERO_ADDRESS = "0x0000000000000000000000000000000000000000";
|
|
3
28
|
var ZERO_RATE_MANAGER_ID = "0x0000000000000000000000000000000000000000000000000000000000000000";
|
|
@@ -70,6 +95,6 @@ var prepareSetDelegationTx = async (client, params, referrer) => {
|
|
|
70
95
|
});
|
|
71
96
|
};
|
|
72
97
|
|
|
73
|
-
export { ZERO_ADDRESS, ZERO_RATE_MANAGER_ID, asErrorMessage, assertAtomicDelegationSwitchSupport, assertDelegationMethodSupport, classifyDelegationState, getDelegationRoute, isZeroRateManagerId, normalizeRateManagerId, normalizeRegistry, prepareClearDelegationTx, prepareSetDelegationTx };
|
|
74
|
-
//# sourceMappingURL=chunk-
|
|
75
|
-
//# sourceMappingURL=chunk-
|
|
98
|
+
export { TAKER_TIER_CAPS, TAKER_TIER_ORDER, TAKER_TIER_SCHEDULE, ZERO_ADDRESS, ZERO_RATE_MANAGER_ID, asErrorMessage, assertAtomicDelegationSwitchSupport, assertDelegationMethodSupport, classifyDelegationState, getDelegationRoute, getNextTakerTier, isZeroRateManagerId, normalizeRateManagerId, normalizeRegistry, prepareClearDelegationTx, prepareSetDelegationTx };
|
|
99
|
+
//# sourceMappingURL=chunk-TGMRXUP2.mjs.map
|
|
100
|
+
//# sourceMappingURL=chunk-TGMRXUP2.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/takerTiers.ts","../src/react/hooks/vaultUtils.ts"],"names":[],"mappings":"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","file":"chunk-TGMRXUP2.mjs","sourcesContent":["import type { TakerTierLevel } from './types';\n\n/**\n * Canonical taker tier schedule — the single client-side source of truth for\n * per-intent caps and volume thresholds. Mirrors the curator's authoritative\n * tier engine (curator `src/common/services/tier/tierConstants.ts`), which is\n * what the backend actually enforces.\n *\n * A user's *live* cap (after lock-score penalties and per-platform risk\n * multipliers) always comes from the taker-tier API payload\n * (`TakerTier.perIntentCapBaseUnits` / `nextTierMaxOrderSizeDisplay`). This\n * static schedule is for reference displays that must show every tier at once —\n * the Fees & Tiers ladder — and the forward-looking \"next tier cap\" hint.\n *\n * Ordered highest tier → lowest (PLATINUM first) to match UI display order.\n * PEER_PRESIDENT is invite-only and excluded from the volume ladder.\n */\nexport interface TakerTierScheduleEntry {\n tier: TakerTierLevel;\n /** Per-intent order cap in whole USD (base, before platform risk multipliers). */\n perIntentCapUsd: number;\n /** Inclusive lower bound of lifetime volume (USD) that qualifies for this tier. */\n minVolumeUsd: number;\n /** Inclusive upper bound of lifetime volume (USD); `Infinity` for the top tier. */\n maxVolumeUsd: number;\n}\n\nexport const TAKER_TIER_SCHEDULE: readonly TakerTierScheduleEntry[] = [\n { tier: 'PLATINUM', perIntentCapUsd: 5000, minVolumeUsd: 25000, maxVolumeUsd: Infinity },\n { tier: 'PRO', perIntentCapUsd: 2500, minVolumeUsd: 10000, maxVolumeUsd: 24999 },\n { tier: 'PLUS', perIntentCapUsd: 1000, minVolumeUsd: 2000, maxVolumeUsd: 9999 },\n { tier: 'PEER', perIntentCapUsd: 250, minVolumeUsd: 500, maxVolumeUsd: 1999 },\n { tier: 'PEASANT', perIntentCapUsd: 100, minVolumeUsd: 0, maxVolumeUsd: 499 },\n];\n\n/** Volume-based tier order, lowest → highest, for next-tier progression. */\nexport const TAKER_TIER_ORDER: readonly TakerTierLevel[] = [\n 'PEASANT',\n 'PEER',\n 'PLUS',\n 'PRO',\n 'PLATINUM',\n];\n\n/** Per-intent caps (whole USD) keyed by tier, derived from the schedule. */\nexport const TAKER_TIER_CAPS: Readonly<Record<string, number>> = Object.fromEntries(\n TAKER_TIER_SCHEDULE.map((entry) => [entry.tier, entry.perIntentCapUsd]),\n);\n\n/** The next tier up from `currentTier`, or `null` at the top / for unknown tiers. */\nexport function getNextTakerTier(currentTier: string | undefined): TakerTierLevel | null {\n if (!currentTier) return null;\n const index = TAKER_TIER_ORDER.indexOf(currentTier as TakerTierLevel);\n if (index === -1 || index >= TAKER_TIER_ORDER.length - 1) return null;\n return TAKER_TIER_ORDER[index + 1];\n}\n","import type { Address, Hex } from 'viem';\nimport type { PreparedTransaction } from '../../types/prepared';\n\n// ---------------------------------------------------------------------------\n// Constants\n// ---------------------------------------------------------------------------\n\nexport const ZERO_ADDRESS = '0x0000000000000000000000000000000000000000' as const;\nexport const ZERO_RATE_MANAGER_ID =\n '0x0000000000000000000000000000000000000000000000000000000000000000' as const;\n\n// ---------------------------------------------------------------------------\n// Normalizers\n// ---------------------------------------------------------------------------\n\nexport const normalizeRateManagerId = (value?: string | null): string =>\n (value ?? ZERO_RATE_MANAGER_ID).toLowerCase();\n\nexport const normalizeRegistry = (value?: string | null): string =>\n (value ?? ZERO_ADDRESS).toLowerCase();\n\nexport const isZeroRateManagerId = (value?: string | null): boolean => {\n if (!value) return true;\n const normalized = value.toLowerCase();\n return normalized === ZERO_ADDRESS || normalized === ZERO_RATE_MANAGER_ID;\n};\n\n// ---------------------------------------------------------------------------\n// Error helper\n// ---------------------------------------------------------------------------\n\nexport const asErrorMessage = (error: unknown): string => {\n if (!error) return 'Unknown error';\n if (error instanceof Error) return error.message;\n if (typeof error === 'string') return error;\n\n const anyErr = error as Record<string, unknown>;\n if (typeof anyErr.shortMessage === 'string') return anyErr.shortMessage;\n if (typeof anyErr.details === 'string') return anyErr.details;\n if (typeof anyErr.message === 'string') return anyErr.message;\n\n try {\n return JSON.stringify(error);\n } catch {\n return String(error);\n }\n};\n\n// ---------------------------------------------------------------------------\n// Delegation state classification\n// ---------------------------------------------------------------------------\n\nexport type DelegationState = 'delegated_here' | 'delegated_elsewhere' | 'not_delegated';\n\n/**\n * Classify whether a deposit is delegated to the target vault, delegated\n * elsewhere, or not delegated at all.\n *\n * @param currentRateManagerId The deposit's current rateManagerId (from indexer)\n * @param currentRegistry The deposit's current rateManagerAddress / registry (from indexer)\n * @param targetRateManagerId The vault's rateManagerId we're comparing against\n * @param targetRegistry The vault's registry address we're comparing against\n */\nexport const classifyDelegationState = (\n currentRateManagerId: string | null | undefined,\n currentRegistry: string | null | undefined,\n targetRateManagerId: string,\n targetRegistry: string | null | undefined,\n): DelegationState => {\n if (isZeroRateManagerId(currentRateManagerId)) {\n return 'not_delegated';\n }\n\n const normalizedCurrent = normalizeRateManagerId(currentRateManagerId);\n const normalizedTarget = targetRateManagerId.toLowerCase();\n const normalizedCurrentRegistry = normalizeRegistry(currentRegistry);\n const normalizedTargetRegistry = targetRegistry ? targetRegistry.toLowerCase() : '';\n\n const idsMatch = normalizedCurrent === normalizedTarget;\n const registryMatches = normalizedTargetRegistry\n ? normalizedCurrentRegistry === normalizedTargetRegistry\n : true;\n\n if (idsMatch && registryMatches) {\n return 'delegated_here';\n }\n\n return 'delegated_elsewhere';\n};\n\nexport const assertAtomicDelegationSwitchSupport = (\n requiresSwitch: boolean,\n canBatch: boolean,\n): void => {\n if (!requiresSwitch || canBatch) return;\n throw new Error(\n 'Switching delegation targets requires smart-account batching. Clear the existing delegation first.',\n );\n};\n\n// ---------------------------------------------------------------------------\n// Contract routing\n// ---------------------------------------------------------------------------\n\nexport type DelegationRoute = 'v2';\n\nexport const getDelegationRoute = (_client: unknown, _escrow: Address): DelegationRoute => 'v2';\n\ntype DelegationMethodSupportClient = Partial<\n Record<'setRateManager' | 'clearRateManager', { prepare?: unknown }>\n>;\n\nexport const assertDelegationMethodSupport = (\n client: DelegationMethodSupportClient,\n _route: DelegationRoute,\n action: 'set' | 'clear',\n): void => {\n const method = action === 'set' ? 'setRateManager' : 'clearRateManager';\n if (client?.[method]?.prepare) return;\n throw new Error(`Delegation requires SDK ${method} support`);\n};\n\n// ---------------------------------------------------------------------------\n// Types\n// ---------------------------------------------------------------------------\n\nexport interface DelegationDepositTarget {\n compositeDepositId: string;\n escrow: Address;\n depositId: bigint;\n currentRateManagerId?: string | null;\n currentRateManagerRegistry?: string | null;\n}\n\nexport interface BatchResult {\n hashes: string[];\n failed: Array<{ compositeDepositId: string; error: string }>;\n}\n\n/**\n * Callback the consumer provides for sending a single prepared transaction.\n * Returns the transaction hash.\n */\nexport type SendTransactionFn = (tx: { to: Address; data: Hex; value?: bigint }) => Promise<string>;\n\n/**\n * Optional callback for batching multiple calls in a single user operation\n * (e.g. via a smart account). If not provided, transactions are sent\n * sequentially via sendTransaction.\n */\nexport type SendBatchFn = (\n txs: Array<{ to: Address; data: Hex; value?: bigint }>,\n) => Promise<string>;\n\n// ---------------------------------------------------------------------------\n// Prepare helpers (used internally by hooks)\n// ---------------------------------------------------------------------------\n\nexport const prepareClearDelegationTx = async (\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n client: any,\n params: { escrow: Address; depositId: bigint },\n referrer?: string | string[],\n): Promise<PreparedTransaction> => {\n const route = getDelegationRoute(client, params.escrow);\n assertDelegationMethodSupport(client, route, 'clear');\n return client.clearRateManager.prepare({\n escrowAddress: params.escrow,\n depositId: params.depositId,\n ...(referrer ? { txOverrides: { referrer } } : {}),\n });\n};\n\nexport const prepareSetDelegationTx = async (\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n client: any,\n params: {\n escrow: Address;\n depositId: bigint;\n registry: Address;\n rateManagerId: Hex;\n },\n referrer?: string | string[],\n): Promise<PreparedTransaction> => {\n const route = getDelegationRoute(client, params.escrow);\n assertDelegationMethodSupport(client, route, 'set');\n return client.setRateManager.prepare({\n escrowAddress: params.escrow,\n depositId: params.depositId,\n rateManagerAddress: params.registry,\n rateManagerId: params.rateManagerId,\n ...(referrer ? { txOverrides: { referrer } } : {}),\n });\n};\n"]}
|
package/dist/index.cjs
CHANGED
|
@@ -41200,11 +41200,25 @@ var init_lookups = __esm({
|
|
|
41200
41200
|
});
|
|
41201
41201
|
|
|
41202
41202
|
// src/utils/paymentMethodHashes.ts
|
|
41203
|
-
var METHOD_NAME_TO_HASH;
|
|
41203
|
+
var METHOD_NAME_TO_HASH, HASH_TO_METHOD_NAME;
|
|
41204
41204
|
var init_paymentMethodHashes = __esm({
|
|
41205
41205
|
"src/utils/paymentMethodHashes.ts"() {
|
|
41206
41206
|
init_lookups();
|
|
41207
|
-
METHOD_NAME_TO_HASH =
|
|
41207
|
+
METHOD_NAME_TO_HASH = {
|
|
41208
|
+
...lookups_default.nameToHash,
|
|
41209
|
+
zelle: lookups_default.zelleUnspecifiedHash
|
|
41210
|
+
};
|
|
41211
|
+
HASH_TO_METHOD_NAME = Object.entries(
|
|
41212
|
+
lookups_default.hashToName
|
|
41213
|
+
).reduce(
|
|
41214
|
+
(acc, [hash, name]) => {
|
|
41215
|
+
acc[hash.toLowerCase()] = name;
|
|
41216
|
+
return acc;
|
|
41217
|
+
},
|
|
41218
|
+
{
|
|
41219
|
+
[lookups_default.zelleUnspecifiedHash.toLowerCase()]: "zelle"
|
|
41220
|
+
}
|
|
41221
|
+
);
|
|
41208
41222
|
}
|
|
41209
41223
|
});
|
|
41210
41224
|
|
|
@@ -41441,7 +41455,7 @@ function resolvePaymentMethodNameFromHash(hash, catalog) {
|
|
|
41441
41455
|
for (const [name, entry] of Object.entries(catalog || {})) {
|
|
41442
41456
|
if (entry?.paymentMethodHash?.toLowerCase() === target.toLowerCase()) return name;
|
|
41443
41457
|
}
|
|
41444
|
-
return
|
|
41458
|
+
return HASH_TO_METHOD_NAME[target.toLowerCase()];
|
|
41445
41459
|
}
|
|
41446
41460
|
var init_paymentResolution = __esm({
|
|
41447
41461
|
"src/utils/paymentResolution.ts"() {
|
|
@@ -42322,13 +42336,6 @@ async function withRetry(fn, maxRetries = 3, delayMs = 1e3, timeoutMs) {
|
|
|
42322
42336
|
}
|
|
42323
42337
|
|
|
42324
42338
|
// src/adapters/verification.ts
|
|
42325
|
-
function createHeaders(apiKey, authorizationToken) {
|
|
42326
|
-
const headers2 = { "Content-Type": "application/json" };
|
|
42327
|
-
if (apiKey) headers2["x-api-key"] = apiKey;
|
|
42328
|
-
if (authorizationToken)
|
|
42329
|
-
headers2["Authorization"] = authorizationToken.startsWith("Bearer ") ? authorizationToken : `Bearer ${authorizationToken}`;
|
|
42330
|
-
return headers2;
|
|
42331
|
-
}
|
|
42332
42339
|
async function apiSignIntentV3(request, opts) {
|
|
42333
42340
|
const url = `${opts.baseApiUrl.replace(/\/$/, "")}/v3/intent/sign`;
|
|
42334
42341
|
const json = await withRetry(
|
|
@@ -42337,7 +42344,7 @@ async function apiSignIntentV3(request, opts) {
|
|
|
42337
42344
|
try {
|
|
42338
42345
|
res = await fetch(url, {
|
|
42339
42346
|
method: "POST",
|
|
42340
|
-
headers:
|
|
42347
|
+
headers: { "Content-Type": "application/json" },
|
|
42341
42348
|
body: JSON.stringify(request)
|
|
42342
42349
|
});
|
|
42343
42350
|
} catch (error) {
|
|
@@ -42540,6 +42547,9 @@ async function apiCreateSellerCredentialBundle(payload, attestationServiceUrl, p
|
|
|
42540
42547
|
timeoutMs
|
|
42541
42548
|
);
|
|
42542
42549
|
}
|
|
42550
|
+
|
|
42551
|
+
// src/client/IntentOperations.ts
|
|
42552
|
+
init_errors();
|
|
42543
42553
|
var abiCoder = ethers.AbiCoder.defaultAbiCoder();
|
|
42544
42554
|
function encodeVerifyPaymentData(params) {
|
|
42545
42555
|
return abiCoder.encode(
|
|
@@ -42973,13 +42983,15 @@ var PLATFORM_ATTESTATION_CONFIG = {
|
|
|
42973
42983
|
chime: { actionType: "transfer_chime", actionPlatform: "chime" },
|
|
42974
42984
|
luxon: { actionType: "transfer_luxon", actionPlatform: "luxon" },
|
|
42975
42985
|
n26: { actionType: "transfer_n26", actionPlatform: "n26" },
|
|
42976
|
-
alipay: { actionType: "transfer_alipay", actionPlatform: "alipay" }
|
|
42977
|
-
"zelle-chase": { actionType: "transfer_zelle", actionPlatform: "chase" },
|
|
42978
|
-
"zelle-bofa": { actionType: "transfer_zelle", actionPlatform: "bankofamerica" },
|
|
42979
|
-
"zelle-citi": { actionType: "transfer_zelle", actionPlatform: "citi" }
|
|
42986
|
+
alipay: { actionType: "transfer_alipay", actionPlatform: "alipay" }
|
|
42980
42987
|
};
|
|
42981
42988
|
function resolvePlatformAttestationConfig(platformName) {
|
|
42982
42989
|
const normalized = platformName.toLowerCase();
|
|
42990
|
+
if (normalized === "zelle") {
|
|
42991
|
+
throw new Error(
|
|
42992
|
+
"Generic Zelle buyer TEE fulfillment requires a bank-specific actionType override."
|
|
42993
|
+
);
|
|
42994
|
+
}
|
|
42983
42995
|
const config = PLATFORM_ATTESTATION_CONFIG[normalized];
|
|
42984
42996
|
if (!config) {
|
|
42985
42997
|
throw new Error(`Unknown payment platform: ${platformName}`);
|
|
@@ -42988,6 +43000,48 @@ function resolvePlatformAttestationConfig(platformName) {
|
|
|
42988
43000
|
}
|
|
42989
43001
|
|
|
42990
43002
|
// src/client/IntentOperations.ts
|
|
43003
|
+
var INTENT_MIN_AT_SIGNAL_ABI = [
|
|
43004
|
+
{
|
|
43005
|
+
type: "function",
|
|
43006
|
+
name: "getIntentMinAtSignal",
|
|
43007
|
+
stateMutability: "view",
|
|
43008
|
+
inputs: [{ name: "_intentHash", type: "bytes32" }],
|
|
43009
|
+
outputs: [{ name: "", type: "uint256" }]
|
|
43010
|
+
}
|
|
43011
|
+
];
|
|
43012
|
+
var GENERIC_ZELLE_ATTESTATION_ACTION_TYPES = /* @__PURE__ */ new Set([
|
|
43013
|
+
"transfer_zelle_bofa",
|
|
43014
|
+
"transfer_zelle_chase",
|
|
43015
|
+
"transfer_zelle_citi"
|
|
43016
|
+
]);
|
|
43017
|
+
function hasBuyerTeeRouteOverrides(buyerTeeProof) {
|
|
43018
|
+
return Boolean(buyerTeeProof.actionPlatform && buyerTeeProof.actionType);
|
|
43019
|
+
}
|
|
43020
|
+
function resolveBuyerTeeAttestationRoute(platformName, buyerTeeProof) {
|
|
43021
|
+
const normalizedPlatformName = platformName.toLowerCase();
|
|
43022
|
+
if (normalizedPlatformName === "zelle") {
|
|
43023
|
+
if (buyerTeeProof.actionPlatform !== "zelle" || !buyerTeeProof.actionType || !GENERIC_ZELLE_ATTESTATION_ACTION_TYPES.has(buyerTeeProof.actionType)) {
|
|
43024
|
+
throw new Error(
|
|
43025
|
+
'Generic Zelle buyer TEE fulfillment requires actionPlatform "zelle" and a bank-specific transfer_zelle_* actionType.'
|
|
43026
|
+
);
|
|
43027
|
+
}
|
|
43028
|
+
return {
|
|
43029
|
+
actionPlatform: buyerTeeProof.actionPlatform,
|
|
43030
|
+
actionType: buyerTeeProof.actionType
|
|
43031
|
+
};
|
|
43032
|
+
}
|
|
43033
|
+
if (hasBuyerTeeRouteOverrides(buyerTeeProof)) {
|
|
43034
|
+
return {
|
|
43035
|
+
actionPlatform: buyerTeeProof.actionPlatform,
|
|
43036
|
+
actionType: buyerTeeProof.actionType
|
|
43037
|
+
};
|
|
43038
|
+
}
|
|
43039
|
+
const platformConfig = resolvePlatformAttestationConfig(platformName);
|
|
43040
|
+
return {
|
|
43041
|
+
actionPlatform: platformConfig.actionPlatform,
|
|
43042
|
+
actionType: platformConfig.actionType
|
|
43043
|
+
};
|
|
43044
|
+
}
|
|
42991
43045
|
var IntentOperations = class {
|
|
42992
43046
|
constructor(config) {
|
|
42993
43047
|
this.config = config;
|
|
@@ -43032,13 +43086,9 @@ var IntentOperations = class {
|
|
|
43032
43086
|
let { gatingServiceSignature, signatureExpiration } = params;
|
|
43033
43087
|
let preIntentHookData = params.preIntentHookData;
|
|
43034
43088
|
const baseApiUrl = this.config.getBaseApiUrl();
|
|
43035
|
-
|
|
43036
|
-
const authorizationToken = this.config.getAuthorizationToken();
|
|
43037
|
-
if ((!gatingServiceSignature || !signatureExpiration) && baseApiUrl && (apiKey || authorizationToken)) {
|
|
43089
|
+
if ((!gatingServiceSignature || !signatureExpiration) && baseApiUrl) {
|
|
43038
43090
|
const apiOpts = {
|
|
43039
43091
|
baseApiUrl,
|
|
43040
|
-
apiKey,
|
|
43041
|
-
authorizationToken,
|
|
43042
43092
|
timeoutMs: this.config.getApiTimeoutMs()
|
|
43043
43093
|
};
|
|
43044
43094
|
const response = await apiSignIntentV3(
|
|
@@ -43288,7 +43338,7 @@ var IntentOperations = class {
|
|
|
43288
43338
|
if (!platformName) {
|
|
43289
43339
|
throw new Error("Unknown paymentMethodHash for this network/env; update SDK catalogs.");
|
|
43290
43340
|
}
|
|
43291
|
-
const
|
|
43341
|
+
const attestationRoute = resolveBuyerTeeAttestationRoute(platformName, buyerTeeProof);
|
|
43292
43342
|
const intent = {
|
|
43293
43343
|
intentHash,
|
|
43294
43344
|
amount: inputs.amount,
|
|
@@ -43307,9 +43357,10 @@ var IntentOperations = class {
|
|
|
43307
43357
|
intent
|
|
43308
43358
|
},
|
|
43309
43359
|
attestationServiceUrl,
|
|
43310
|
-
|
|
43311
|
-
|
|
43360
|
+
attestationRoute.actionPlatform,
|
|
43361
|
+
attestationRoute.actionType
|
|
43312
43362
|
);
|
|
43363
|
+
assertReleaseAmountMeetsMinimum(attestation, inputs.minimumReleaseAmount);
|
|
43313
43364
|
paymentProof = encodePaymentAttestation(attestation);
|
|
43314
43365
|
verificationData = encodeVerifyPaymentData({
|
|
43315
43366
|
intentHash,
|
|
@@ -43360,13 +43411,19 @@ var IntentOperations = class {
|
|
|
43360
43411
|
);
|
|
43361
43412
|
const payee2 = matched?.verificationData?.payeeDetails;
|
|
43362
43413
|
if (payee2) {
|
|
43414
|
+
const minimumReleaseAmount2 = await this.resolveIntentMinimumReleaseAmount(
|
|
43415
|
+
intentHash,
|
|
43416
|
+
options?.orchestratorAddress,
|
|
43417
|
+
view.deposit.deposit.intentAmountRange.min
|
|
43418
|
+
);
|
|
43363
43419
|
return {
|
|
43364
43420
|
amount: view.intent.amount.toString(),
|
|
43365
43421
|
fiatCurrency: view.intent.fiatCurrency,
|
|
43366
43422
|
conversionRate: view.intent.conversionRate.toString(),
|
|
43367
43423
|
payeeDetails: payee2,
|
|
43368
43424
|
intentTimestampMs: (BigInt(view.intent.timestamp) * 1000n).toString(),
|
|
43369
|
-
paymentMethodHash: view.intent.paymentMethod
|
|
43425
|
+
paymentMethodHash: view.intent.paymentMethod,
|
|
43426
|
+
...minimumReleaseAmount2 ? { minimumReleaseAmount: minimumReleaseAmount2 } : {}
|
|
43370
43427
|
};
|
|
43371
43428
|
}
|
|
43372
43429
|
}
|
|
@@ -43386,6 +43443,8 @@ var IntentOperations = class {
|
|
|
43386
43443
|
depositId
|
|
43387
43444
|
signalTimestamp
|
|
43388
43445
|
verifier
|
|
43446
|
+
status
|
|
43447
|
+
isExpired
|
|
43389
43448
|
}
|
|
43390
43449
|
}
|
|
43391
43450
|
`
|
|
@@ -43394,6 +43453,18 @@ var IntentOperations = class {
|
|
|
43394
43453
|
});
|
|
43395
43454
|
const record = response?.Intent?.[0];
|
|
43396
43455
|
if (!record) throw new Error("Intent not found on indexer");
|
|
43456
|
+
if (record.status && record.status !== "SIGNALED") {
|
|
43457
|
+
throw new exports.ValidationError(
|
|
43458
|
+
`Intent not found or no longer fulfillable (status: ${record.status})`,
|
|
43459
|
+
"intentHash",
|
|
43460
|
+
{ intentHash, status: record.status }
|
|
43461
|
+
);
|
|
43462
|
+
}
|
|
43463
|
+
if (record.isExpired) {
|
|
43464
|
+
throw new exports.ValidationError("Intent expired and can no longer be fulfilled", "intentHash", {
|
|
43465
|
+
intentHash
|
|
43466
|
+
});
|
|
43467
|
+
}
|
|
43397
43468
|
if (!record.signalTimestamp) throw new Error("Intent signal timestamp not found on indexer");
|
|
43398
43469
|
const deposit = await this.config.getIndexerService().fetchDepositWithRelations(record.depositId, {
|
|
43399
43470
|
includeIntents: false
|
|
@@ -43410,6 +43481,11 @@ var IntentOperations = class {
|
|
|
43410
43481
|
}
|
|
43411
43482
|
}
|
|
43412
43483
|
if (!payee) throw new Error("Payee details not found for intent");
|
|
43484
|
+
const minimumReleaseAmount = await this.resolveIntentMinimumReleaseAmount(
|
|
43485
|
+
intentHash,
|
|
43486
|
+
options?.orchestratorAddress,
|
|
43487
|
+
deposit.intentAmountMin
|
|
43488
|
+
);
|
|
43413
43489
|
return {
|
|
43414
43490
|
amount: record.amount,
|
|
43415
43491
|
fiatCurrency: record.fiatCurrency,
|
|
@@ -43417,10 +43493,51 @@ var IntentOperations = class {
|
|
|
43417
43493
|
payeeDetails: payee,
|
|
43418
43494
|
intentTimestampMs: (BigInt(record.signalTimestamp) * 1000n).toString(),
|
|
43419
43495
|
paymentMethodHash: record.paymentMethodHash || "0x0000000000000000000000000000000000000000000000000000000000000000",
|
|
43420
|
-
paymentVerifier: record.verifier || void 0
|
|
43496
|
+
paymentVerifier: record.verifier || void 0,
|
|
43497
|
+
...minimumReleaseAmount ? { minimumReleaseAmount } : {}
|
|
43421
43498
|
};
|
|
43422
43499
|
}
|
|
43500
|
+
async resolveIntentMinimumReleaseAmount(intentHash, orchestratorAddress, fallbackMinimum) {
|
|
43501
|
+
const snapshotMinimum = await this.readIntentMinAtSignal(intentHash, orchestratorAddress);
|
|
43502
|
+
if (snapshotMinimum && snapshotMinimum !== "0") {
|
|
43503
|
+
return snapshotMinimum;
|
|
43504
|
+
}
|
|
43505
|
+
if (fallbackMinimum === void 0 || fallbackMinimum === null) {
|
|
43506
|
+
return snapshotMinimum;
|
|
43507
|
+
}
|
|
43508
|
+
return BigInt(fallbackMinimum).toString();
|
|
43509
|
+
}
|
|
43510
|
+
async readIntentMinAtSignal(intentHash, orchestratorAddress) {
|
|
43511
|
+
const address = orchestratorAddress ?? this.config.getOrchestratorV2Address();
|
|
43512
|
+
if (!address) return void 0;
|
|
43513
|
+
try {
|
|
43514
|
+
const value = await this.config.getPublicClient().readContract({
|
|
43515
|
+
address,
|
|
43516
|
+
abi: INTENT_MIN_AT_SIGNAL_ABI,
|
|
43517
|
+
functionName: "getIntentMinAtSignal",
|
|
43518
|
+
args: [intentHash]
|
|
43519
|
+
});
|
|
43520
|
+
return value.toString();
|
|
43521
|
+
} catch {
|
|
43522
|
+
return void 0;
|
|
43523
|
+
}
|
|
43524
|
+
}
|
|
43423
43525
|
};
|
|
43526
|
+
function assertReleaseAmountMeetsMinimum(attestation, minimumReleaseAmount) {
|
|
43527
|
+
if (!minimumReleaseAmount) return;
|
|
43528
|
+
const minimum = BigInt(minimumReleaseAmount);
|
|
43529
|
+
if (minimum === 0n) return;
|
|
43530
|
+
const releaseAmount = BigInt(attestation.responseObject.typedDataValue.releaseAmount);
|
|
43531
|
+
if (releaseAmount >= minimum) return;
|
|
43532
|
+
throw new exports.ValidationError(
|
|
43533
|
+
`Payment amount is below the minimum required for this intent. Release amount ${releaseAmount.toString()} is below minimum ${minimum.toString()}.`,
|
|
43534
|
+
"releaseAmount",
|
|
43535
|
+
{
|
|
43536
|
+
releaseAmount: releaseAmount.toString(),
|
|
43537
|
+
minimumReleaseAmount: minimum.toString()
|
|
43538
|
+
}
|
|
43539
|
+
);
|
|
43540
|
+
}
|
|
43424
43541
|
function isRecord(value) {
|
|
43425
43542
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
43426
43543
|
}
|
|
@@ -46957,11 +47074,9 @@ var logger = {
|
|
|
46957
47074
|
};
|
|
46958
47075
|
|
|
46959
47076
|
// src/adapters/api.ts
|
|
46960
|
-
function
|
|
47077
|
+
function createHeaders(apiKey) {
|
|
46961
47078
|
const headers2 = { "Content-Type": "application/json" };
|
|
46962
47079
|
if (apiKey) headers2["x-api-key"] = apiKey;
|
|
46963
|
-
if (authToken)
|
|
46964
|
-
headers2["Authorization"] = authToken.startsWith("Bearer ") ? authToken : `Bearer ${authToken}`;
|
|
46965
47080
|
return headers2;
|
|
46966
47081
|
}
|
|
46967
47082
|
function withApiBase(baseApiUrl) {
|
|
@@ -46976,7 +47091,6 @@ async function apiFetch({
|
|
|
46976
47091
|
method = "GET",
|
|
46977
47092
|
body,
|
|
46978
47093
|
apiKey,
|
|
46979
|
-
authToken,
|
|
46980
47094
|
timeoutMs,
|
|
46981
47095
|
retryCount = 3,
|
|
46982
47096
|
retryDelayMs = 1e3
|
|
@@ -46988,7 +47102,7 @@ async function apiFetch({
|
|
|
46988
47102
|
try {
|
|
46989
47103
|
const options = {
|
|
46990
47104
|
method,
|
|
46991
|
-
headers:
|
|
47105
|
+
headers: createHeaders(apiKey)
|
|
46992
47106
|
};
|
|
46993
47107
|
if (body && method !== "GET") {
|
|
46994
47108
|
options.body = JSON.stringify(body);
|
|
@@ -47125,7 +47239,7 @@ function convertIndexerDepositToLegacyApiDeposit(deposit) {
|
|
|
47125
47239
|
verifiers
|
|
47126
47240
|
};
|
|
47127
47241
|
}
|
|
47128
|
-
async function apiPostDepositDetails(req, baseApiUrl, timeoutMs
|
|
47242
|
+
async function apiPostDepositDetails(req, baseApiUrl, timeoutMs) {
|
|
47129
47243
|
return apiFetch({
|
|
47130
47244
|
url: `${withApiBase(baseApiUrl)}/v2/makers/create`,
|
|
47131
47245
|
method: "POST",
|
|
@@ -47133,7 +47247,7 @@ async function apiPostDepositDetails(req, baseApiUrl, timeoutMs, _apiKey, _authT
|
|
|
47133
47247
|
timeoutMs
|
|
47134
47248
|
});
|
|
47135
47249
|
}
|
|
47136
|
-
async function apiGetQuote(req, baseApiUrl, timeoutMs
|
|
47250
|
+
async function apiGetQuote(req, baseApiUrl, timeoutMs) {
|
|
47137
47251
|
if (req.quotesToReturn !== void 0) {
|
|
47138
47252
|
if (!Number.isInteger(req.quotesToReturn) || req.quotesToReturn < 1) {
|
|
47139
47253
|
throw new exports.ValidationError("quotesToReturn must be a positive integer", "quotesToReturn");
|
|
@@ -47168,12 +47282,10 @@ async function apiGetQuote(req, baseApiUrl, timeoutMs, apiKey, authToken) {
|
|
|
47168
47282
|
url,
|
|
47169
47283
|
method: "POST",
|
|
47170
47284
|
body: requestBody,
|
|
47171
|
-
apiKey,
|
|
47172
|
-
authToken,
|
|
47173
47285
|
timeoutMs
|
|
47174
47286
|
});
|
|
47175
47287
|
}
|
|
47176
|
-
async function apiGetQuotesBestByPlatform(req, baseApiUrl, timeoutMs
|
|
47288
|
+
async function apiGetQuotesBestByPlatform(req, baseApiUrl, timeoutMs) {
|
|
47177
47289
|
const isExactFiat = req.isExactFiat !== false;
|
|
47178
47290
|
const endpoint = isExactFiat ? "best-by-platform" : "best-by-platform-exact-token";
|
|
47179
47291
|
const url = `${withApiBase(baseApiUrl)}/v2/quote/${endpoint}`;
|
|
@@ -47191,17 +47303,13 @@ async function apiGetQuotesBestByPlatform(req, baseApiUrl, timeoutMs, apiKey, au
|
|
|
47191
47303
|
url,
|
|
47192
47304
|
method: "POST",
|
|
47193
47305
|
body: requestBody,
|
|
47194
|
-
apiKey,
|
|
47195
|
-
authToken,
|
|
47196
47306
|
timeoutMs
|
|
47197
47307
|
});
|
|
47198
47308
|
}
|
|
47199
|
-
async function apiGetPayeeDetails(req,
|
|
47309
|
+
async function apiGetPayeeDetails(req, baseApiUrl, timeoutMs) {
|
|
47200
47310
|
return apiFetch({
|
|
47201
47311
|
url: `${baseApiUrl.replace(/\/$/, "")}/v2/makers/${req.processorName}/${req.hashedOnchainId}`,
|
|
47202
47312
|
method: "GET",
|
|
47203
|
-
apiKey,
|
|
47204
|
-
authToken,
|
|
47205
47313
|
timeoutMs
|
|
47206
47314
|
});
|
|
47207
47315
|
}
|
|
@@ -47252,7 +47360,7 @@ async function apiGetOwnerDeposits(req, apiKey, baseApiUrl, authToken, timeoutMs
|
|
|
47252
47360
|
statusCode: 200
|
|
47253
47361
|
};
|
|
47254
47362
|
}
|
|
47255
|
-
async function apiGetTakerTier(req,
|
|
47363
|
+
async function apiGetTakerTier(req, baseApiUrl, timeoutMs) {
|
|
47256
47364
|
const normalizedOwner = req.owner.toLowerCase();
|
|
47257
47365
|
const query = new URLSearchParams({
|
|
47258
47366
|
owner: normalizedOwner,
|
|
@@ -47284,8 +47392,6 @@ async function apiUploadGoogleOAuthSellerCredential(processorName, payeeDetails,
|
|
|
47284
47392
|
url: `${withApiBase(baseApiUrl)}${endpoint}`,
|
|
47285
47393
|
method: "POST",
|
|
47286
47394
|
body,
|
|
47287
|
-
apiKey: opts?.apiKey,
|
|
47288
|
-
authToken: opts?.authToken,
|
|
47289
47395
|
timeoutMs: opts?.timeoutMs
|
|
47290
47396
|
});
|
|
47291
47397
|
}
|
|
@@ -47299,7 +47405,7 @@ async function apiGetSellerCredentialStatus(processorName, payeeDetails, baseApi
|
|
|
47299
47405
|
timeoutMs
|
|
47300
47406
|
});
|
|
47301
47407
|
}
|
|
47302
|
-
async function apiVerifySellerPayment(platform, req, baseApiUrl, timeoutMs, apiKey
|
|
47408
|
+
async function apiVerifySellerPayment(platform, req, baseApiUrl, timeoutMs, apiKey) {
|
|
47303
47409
|
const body = {
|
|
47304
47410
|
txId: req.txId,
|
|
47305
47411
|
chainId: req.chainId,
|
|
@@ -47311,15 +47417,13 @@ async function apiVerifySellerPayment(platform, req, baseApiUrl, timeoutMs, apiK
|
|
|
47311
47417
|
method: "POST",
|
|
47312
47418
|
body,
|
|
47313
47419
|
apiKey,
|
|
47314
|
-
authToken,
|
|
47315
47420
|
timeoutMs
|
|
47316
47421
|
});
|
|
47317
47422
|
}
|
|
47318
|
-
async function apiGetOrderbook(params, optsOrBaseApiUrl, timeoutMs
|
|
47423
|
+
async function apiGetOrderbook(params, optsOrBaseApiUrl, timeoutMs) {
|
|
47319
47424
|
const opts = typeof optsOrBaseApiUrl === "string" ? {
|
|
47320
47425
|
baseApiUrl: optsOrBaseApiUrl,
|
|
47321
|
-
timeoutMs
|
|
47322
|
-
apiKey
|
|
47426
|
+
timeoutMs
|
|
47323
47427
|
} : optsOrBaseApiUrl;
|
|
47324
47428
|
const query = new URLSearchParams();
|
|
47325
47429
|
Object.entries(params).forEach(([key, value]) => {
|
|
@@ -47329,17 +47433,14 @@ async function apiGetOrderbook(params, optsOrBaseApiUrl, timeoutMs, apiKey) {
|
|
|
47329
47433
|
const response = await apiFetch({
|
|
47330
47434
|
url: `${withApiBase(opts.baseApiUrl)}/v2/orderbook?${query.toString()}`,
|
|
47331
47435
|
method: "GET",
|
|
47332
|
-
apiKey: opts.apiKey,
|
|
47333
|
-
authToken: opts.authToken,
|
|
47334
47436
|
timeoutMs: opts.timeoutMs
|
|
47335
47437
|
});
|
|
47336
47438
|
return response.responseObject;
|
|
47337
47439
|
}
|
|
47338
|
-
async function apiGetDepositBundle(params, optsOrBaseApiUrl, timeoutMs
|
|
47440
|
+
async function apiGetDepositBundle(params, optsOrBaseApiUrl, timeoutMs) {
|
|
47339
47441
|
const opts = typeof optsOrBaseApiUrl === "string" ? {
|
|
47340
47442
|
baseApiUrl: optsOrBaseApiUrl,
|
|
47341
|
-
timeoutMs
|
|
47342
|
-
apiKey
|
|
47443
|
+
timeoutMs
|
|
47343
47444
|
} : optsOrBaseApiUrl;
|
|
47344
47445
|
const escrowAddress = requireEscrowAddress(
|
|
47345
47446
|
params.escrowAddress,
|
|
@@ -47352,8 +47453,6 @@ async function apiGetDepositBundle(params, optsOrBaseApiUrl, timeoutMs, apiKey)
|
|
|
47352
47453
|
const response = await apiFetch({
|
|
47353
47454
|
url: `${withApiBase(opts.baseApiUrl)}/v2/deposits/${params.depositId}/bundle?${query.toString()}`,
|
|
47354
47455
|
method: "GET",
|
|
47355
|
-
apiKey: opts.apiKey,
|
|
47356
|
-
authToken: opts.authToken,
|
|
47357
47456
|
timeoutMs: opts.timeoutMs
|
|
47358
47457
|
});
|
|
47359
47458
|
return response.responseObject;
|
|
@@ -48194,9 +48293,9 @@ var Zkp2pClient = class {
|
|
|
48194
48293
|
* sending fiat payment to the deposit's payee.
|
|
48195
48294
|
*
|
|
48196
48295
|
* If `gatingServiceSignature` is not provided, the SDK will automatically
|
|
48197
|
-
* fetch one from curator `/v3/intent/sign` when `
|
|
48198
|
-
*
|
|
48199
|
-
*
|
|
48296
|
+
* fetch one from curator `/v3/intent/sign` when `baseApiUrl` is configured.
|
|
48297
|
+
* Otherwise you must provide `gatingServiceSignature` and `signatureExpiration`
|
|
48298
|
+
* yourself.
|
|
48200
48299
|
*
|
|
48201
48300
|
* **Prepare Mode**: Use `.prepare()` to get the transaction calldata without sending:
|
|
48202
48301
|
* ```typescript
|
|
@@ -48626,8 +48725,6 @@ var Zkp2pClient = class {
|
|
|
48626
48725
|
getChainId: () => this.chainId,
|
|
48627
48726
|
getRuntimeEnv: () => this.runtimeEnv,
|
|
48628
48727
|
getBaseApiUrl: () => this.baseApiUrl,
|
|
48629
|
-
getApiKey: () => this.apiKey,
|
|
48630
|
-
getAuthorizationToken: () => this.authorizationToken,
|
|
48631
48728
|
getApiTimeoutMs: () => this.apiTimeoutMs,
|
|
48632
48729
|
getProtocolViewerAddress: () => this.protocolViewerAddress,
|
|
48633
48730
|
getProtocolViewerAbi: () => this.protocolViewerAbi,
|
|
@@ -49883,13 +49980,7 @@ var Zkp2pClient = class {
|
|
|
49883
49980
|
reqWithEscrow.escrowAddresses = configuredEscrows;
|
|
49884
49981
|
}
|
|
49885
49982
|
}
|
|
49886
|
-
const quote = await apiGetQuote(
|
|
49887
|
-
reqWithEscrow,
|
|
49888
|
-
baseApiUrl,
|
|
49889
|
-
timeoutMs,
|
|
49890
|
-
this.apiKey,
|
|
49891
|
-
this.authorizationToken
|
|
49892
|
-
);
|
|
49983
|
+
const quote = await apiGetQuote(reqWithEscrow, baseApiUrl, timeoutMs);
|
|
49893
49984
|
const quotes = quote?.responseObject?.quotes ?? [];
|
|
49894
49985
|
for (const q of quotes) {
|
|
49895
49986
|
const maker = q?.maker;
|
|
@@ -49903,8 +49994,8 @@ var Zkp2pClient = class {
|
|
|
49903
49994
|
/**
|
|
49904
49995
|
* **Supporting Method** - Fetches the best available quote per supported payment platform.
|
|
49905
49996
|
*
|
|
49906
|
-
* Returns one quote per platform when available.
|
|
49907
|
-
*
|
|
49997
|
+
* Returns one quote per platform when available. The API returns payee details
|
|
49998
|
+
* in each platform's best quote when available.
|
|
49908
49999
|
*
|
|
49909
50000
|
* @param req - Best-by-platform quote request parameters
|
|
49910
50001
|
* @param opts - Optional overrides for API URL and timeout
|
|
@@ -49927,13 +50018,7 @@ var Zkp2pClient = class {
|
|
|
49927
50018
|
reqWithEscrow.escrowAddresses = configuredEscrows;
|
|
49928
50019
|
}
|
|
49929
50020
|
}
|
|
49930
|
-
const quote = await apiGetQuotesBestByPlatform(
|
|
49931
|
-
reqWithEscrow,
|
|
49932
|
-
baseApiUrl,
|
|
49933
|
-
timeoutMs,
|
|
49934
|
-
this.apiKey,
|
|
49935
|
-
this.authorizationToken
|
|
49936
|
-
);
|
|
50021
|
+
const quote = await apiGetQuotesBestByPlatform(reqWithEscrow, baseApiUrl, timeoutMs);
|
|
49937
50022
|
const enrichedQuote = quote ? {
|
|
49938
50023
|
...quote,
|
|
49939
50024
|
responseObject: {
|
|
@@ -49970,7 +50055,7 @@ var Zkp2pClient = class {
|
|
|
49970
50055
|
""
|
|
49971
50056
|
);
|
|
49972
50057
|
const timeoutMs = opts?.timeoutMs ?? this.apiTimeoutMs;
|
|
49973
|
-
return apiGetTakerTier(req,
|
|
50058
|
+
return apiGetTakerTier(req, baseApiUrl, timeoutMs);
|
|
49974
50059
|
}
|
|
49975
50060
|
/**
|
|
49976
50061
|
* The signed `credentialValidatedAt` field is an upload-time freshness witness minted by
|
|
@@ -50070,8 +50155,6 @@ var Zkp2pClient = class {
|
|
|
50070
50155
|
},
|
|
50071
50156
|
baseApiUrl,
|
|
50072
50157
|
{
|
|
50073
|
-
apiKey: this.apiKey,
|
|
50074
|
-
authToken: this.authorizationToken,
|
|
50075
50158
|
timeoutMs
|
|
50076
50159
|
}
|
|
50077
50160
|
);
|
|
@@ -50086,8 +50169,6 @@ var Zkp2pClient = class {
|
|
|
50086
50169
|
},
|
|
50087
50170
|
baseApiUrl,
|
|
50088
50171
|
{
|
|
50089
|
-
apiKey: this.apiKey,
|
|
50090
|
-
authToken: this.authorizationToken,
|
|
50091
50172
|
timeoutMs
|
|
50092
50173
|
}
|
|
50093
50174
|
);
|
|
@@ -50114,8 +50195,8 @@ var Zkp2pClient = class {
|
|
|
50114
50195
|
);
|
|
50115
50196
|
}
|
|
50116
50197
|
/**
|
|
50117
|
-
* Internal-use endpoint. The curator route requires an internal `x-api-key`;
|
|
50118
|
-
* API keys will be rejected
|
|
50198
|
+
* Internal-use endpoint. The curator route requires an internal `x-api-key`; non-internal
|
|
50199
|
+
* API keys will be rejected. Returns 410 GONE when curator has marked the credential inactive
|
|
50119
50200
|
* or a stale credential fails its synchronous re-probe.
|
|
50120
50201
|
*
|
|
50121
50202
|
* Verify a seller payment via curator's seller-credential proxy.
|
|
@@ -50135,8 +50216,7 @@ var Zkp2pClient = class {
|
|
|
50135
50216
|
},
|
|
50136
50217
|
baseApiUrl,
|
|
50137
50218
|
timeoutMs,
|
|
50138
|
-
this.apiKey
|
|
50139
|
-
this.authorizationToken
|
|
50219
|
+
this.apiKey
|
|
50140
50220
|
);
|
|
50141
50221
|
}
|
|
50142
50222
|
// ╔═══════════════════════════════════════════════════════════════════════════╗
|
|
@@ -50331,6 +50411,31 @@ var createPeerExtensionSdk = (options = {}) => ({
|
|
|
50331
50411
|
});
|
|
50332
50412
|
var peerExtensionSdk = createPeerExtensionSdk();
|
|
50333
50413
|
|
|
50414
|
+
// src/takerTiers.ts
|
|
50415
|
+
var TAKER_TIER_SCHEDULE = [
|
|
50416
|
+
{ tier: "PLATINUM", perIntentCapUsd: 5e3, minVolumeUsd: 25e3, maxVolumeUsd: Infinity },
|
|
50417
|
+
{ tier: "PRO", perIntentCapUsd: 2500, minVolumeUsd: 1e4, maxVolumeUsd: 24999 },
|
|
50418
|
+
{ tier: "PLUS", perIntentCapUsd: 1e3, minVolumeUsd: 2e3, maxVolumeUsd: 9999 },
|
|
50419
|
+
{ tier: "PEER", perIntentCapUsd: 250, minVolumeUsd: 500, maxVolumeUsd: 1999 },
|
|
50420
|
+
{ tier: "PEASANT", perIntentCapUsd: 100, minVolumeUsd: 0, maxVolumeUsd: 499 }
|
|
50421
|
+
];
|
|
50422
|
+
var TAKER_TIER_ORDER = [
|
|
50423
|
+
"PEASANT",
|
|
50424
|
+
"PEER",
|
|
50425
|
+
"PLUS",
|
|
50426
|
+
"PRO",
|
|
50427
|
+
"PLATINUM"
|
|
50428
|
+
];
|
|
50429
|
+
var TAKER_TIER_CAPS = Object.fromEntries(
|
|
50430
|
+
TAKER_TIER_SCHEDULE.map((entry) => [entry.tier, entry.perIntentCapUsd])
|
|
50431
|
+
);
|
|
50432
|
+
function getNextTakerTier(currentTier) {
|
|
50433
|
+
if (!currentTier) return null;
|
|
50434
|
+
const index = TAKER_TIER_ORDER.indexOf(currentTier);
|
|
50435
|
+
if (index === -1 || index >= TAKER_TIER_ORDER.length - 1) return null;
|
|
50436
|
+
return TAKER_TIER_ORDER[index + 1];
|
|
50437
|
+
}
|
|
50438
|
+
|
|
50334
50439
|
// src/index.ts
|
|
50335
50440
|
init_currency();
|
|
50336
50441
|
init_paymentResolution();
|
|
@@ -50387,6 +50492,9 @@ exports.PYTH_ORACLE_ADAPTER = PYTH_ORACLE_ADAPTER;
|
|
|
50387
50492
|
exports.PYTH_ORACLE_FEEDS = PYTH_ORACLE_FEEDS;
|
|
50388
50493
|
exports.SPREAD_ORACLE_FEEDS = SPREAD_ORACLE_FEEDS;
|
|
50389
50494
|
exports.SUPPORTED_CHAIN_IDS = SUPPORTED_CHAIN_IDS;
|
|
50495
|
+
exports.TAKER_TIER_CAPS = TAKER_TIER_CAPS;
|
|
50496
|
+
exports.TAKER_TIER_ORDER = TAKER_TIER_ORDER;
|
|
50497
|
+
exports.TAKER_TIER_SCHEDULE = TAKER_TIER_SCHEDULE;
|
|
50390
50498
|
exports.TOKEN_METADATA = TOKEN_METADATA;
|
|
50391
50499
|
exports.ZERO_RATE_MANAGER_ID = ZERO_RATE_MANAGER_ID;
|
|
50392
50500
|
exports.ZKP2P_ANDROID_REFERRER = ZKP2P_ANDROID_REFERRER;
|
|
@@ -50430,6 +50538,7 @@ exports.getCurrencyInfoFromCountryCode = getCurrencyInfoFromCountryCode;
|
|
|
50430
50538
|
exports.getCurrencyInfoFromHash = getCurrencyInfoFromHash;
|
|
50431
50539
|
exports.getDelegationRoute = getDelegationRoute;
|
|
50432
50540
|
exports.getGatingServiceAddress = getGatingServiceAddress;
|
|
50541
|
+
exports.getNextTakerTier = getNextTakerTier;
|
|
50433
50542
|
exports.getPaymentMethodsCatalog = getPaymentMethodsCatalog;
|
|
50434
50543
|
exports.getPeerExtensionState = getPeerExtensionState;
|
|
50435
50544
|
exports.getRateManagerContracts = getRateManagerContracts;
|