@zkp2p/sdk 0.7.2 → 0.8.0
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 +14 -3
- package/dist/{chunk-BQINCOSO.mjs → chunk-EIOXBVXP.mjs} +3 -4
- package/dist/chunk-EIOXBVXP.mjs.map +1 -0
- package/dist/index.cjs +40 -11
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +4 -4
- package/dist/index.d.ts +4 -4
- package/dist/index.mjs +40 -10
- package/dist/index.mjs.map +1 -1
- 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 +2 -2
- package/dist/{vaultUtils-CdYaZr3f.d.mts → vaultUtils-BGDsoxAv.d.mts} +13 -3
- package/dist/{vaultUtils-CdYaZr3f.d.ts → vaultUtils-BGDsoxAv.d.ts} +13 -3
- package/package.json +1 -1
- package/dist/chunk-BQINCOSO.mjs.map +0 -1
package/README.md
CHANGED
|
@@ -169,8 +169,8 @@ const result = await client.createDeposit({
|
|
|
169
169
|
token: '0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913',
|
|
170
170
|
amount: 10_000_000n,
|
|
171
171
|
intentAmountRange: { min: 100_000n, max: 5_000_000n },
|
|
172
|
-
processorNames: ['
|
|
173
|
-
|
|
172
|
+
processorNames: ['revolut'],
|
|
173
|
+
payeeData: [{ offchainId: 'maker-revtag' }],
|
|
174
174
|
conversionRates: [[{ currency: Currency.USD, conversionRate: '1020000000000000000' }]],
|
|
175
175
|
});
|
|
176
176
|
|
|
@@ -185,9 +185,20 @@ If you do not pass `payeeDetailsHashes`, `createDeposit()` can register the paye
|
|
|
185
185
|
```ts
|
|
186
186
|
import { resolvePaymentMethodHash } from '@zkp2p/sdk';
|
|
187
187
|
|
|
188
|
+
// App-specific: request this from the ZKP2P attestation service after capturing
|
|
189
|
+
// Wise registration material through PeerAuth / Buyer TEE.
|
|
190
|
+
const identityAttestation = await getWiseIdentityAttestation();
|
|
191
|
+
|
|
188
192
|
const { hashedOnchainIds } = await client.registerPayeeDetails({
|
|
189
193
|
processorNames: ['wise'],
|
|
190
|
-
|
|
194
|
+
payeeData: [
|
|
195
|
+
{
|
|
196
|
+
offchainId: 'maker-wisetag',
|
|
197
|
+
// Wise maker registration requires an identity attestation from the
|
|
198
|
+
// attestation service. Pass it directly or inside metadata.identityAttestation.
|
|
199
|
+
identityAttestation,
|
|
200
|
+
},
|
|
201
|
+
],
|
|
191
202
|
});
|
|
192
203
|
|
|
193
204
|
const quote = await client.getQuote({
|
|
@@ -21,8 +21,7 @@ var TAKER_TIER_FEE_DISCOUNT_BPS = {
|
|
|
21
21
|
PEER: 5,
|
|
22
22
|
PLUS: 10,
|
|
23
23
|
PRO: 20,
|
|
24
|
-
PLATINUM: 30
|
|
25
|
-
PEER_PRESIDENT: 30
|
|
24
|
+
PLATINUM: 30
|
|
26
25
|
};
|
|
27
26
|
function getTakerTierFeeDiscountBps(tier) {
|
|
28
27
|
if (!tier) return 0;
|
|
@@ -108,5 +107,5 @@ var prepareSetDelegationTx = async (client, params, referrer) => {
|
|
|
108
107
|
};
|
|
109
108
|
|
|
110
109
|
export { TAKER_TIER_CAPS, TAKER_TIER_FEE_DISCOUNT_BPS, TAKER_TIER_ORDER, TAKER_TIER_SCHEDULE, ZERO_ADDRESS, ZERO_RATE_MANAGER_ID, asErrorMessage, assertAtomicDelegationSwitchSupport, assertDelegationMethodSupport, classifyDelegationState, getDelegationRoute, getNextTakerTier, getTakerTierFeeDiscountBps, isZeroRateManagerId, normalizeRateManagerId, normalizeRegistry, prepareClearDelegationTx, prepareSetDelegationTx };
|
|
111
|
-
//# sourceMappingURL=chunk-
|
|
112
|
-
//# sourceMappingURL=chunk-
|
|
110
|
+
//# sourceMappingURL=chunk-EIOXBVXP.mjs.map
|
|
111
|
+
//# sourceMappingURL=chunk-EIOXBVXP.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version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,MAAA,EACA,QAAA,KACiC;AACjC,EAAA,MAAM,KAAA,GAAQ,kBAAA,CAAmB,MAAA,EAAQ,MAAA,CAAO,MAAM,CAAA;AACtD,EAAA,6BAAA,CAA8B,MAAA,EAAQ,OAAO,OAAO,CAAA;AACpD,EAAA,OAAO,MAAA,CAAO,iBAAiB,OAAA,CAAQ;AAAA,IACrC,eAAe,MAAA,CAAO,MAAA;AAAA,IACtB,WAAW,MAAA,CAAO,SAAA;AAAA,IAClB,GAAI,WAAW,EAAE,WAAA,EAAa,EAAE,QAAA,EAAS,KAAM;AAAC,GACjD,CAAA;AACH;AAEO,IAAM,sBAAA,GAAyB,OAEpC,MAAA,EACA,MAAA,EAMA,QAAA,KACiC;AACjC,EAAA,MAAM,KAAA,GAAQ,kBAAA,CAAmB,MAAA,EAAQ,MAAA,CAAO,MAAM,CAAA;AACtD,EAAA,6BAAA,CAA8B,MAAA,EAAQ,OAAO,KAAK,CAAA;AAClD,EAAA,OAAO,MAAA,CAAO,eAAe,OAAA,CAAQ;AAAA,IACnC,eAAe,MAAA,CAAO,MAAA;AAAA,IACtB,WAAW,MAAA,CAAO,SAAA;AAAA,IAClB,oBAAoB,MAAA,CAAO,QAAA;AAAA,IAC3B,eAAe,MAAA,CAAO,aAAA;AAAA,IACtB,GAAI,WAAW,EAAE,WAAA,EAAa,EAAE,QAAA,EAAS,KAAM;AAAC,GACjD,CAAA;AACH","file":"chunk-EIOXBVXP.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 * The live qualification signal is Peer Pay volume. Historical maker tiers\n * earned before July 1, 2026 UTC are preserved; after that cutoff, only Peer\n * Pay volume moves the tier. Curator keeps the response field name\n * `peerPayVolume` for compatibility.\n *\n * A user's *live* tier, cap, and progression always come from the taker-tier\n * API payload (`TakerTier.perIntentCapBaseUnits`, `minVolumeForTier`,\n * `volumeToNextTier`, `peerPayVolume`). Those values are DB-backed and\n * server-authoritative — they vary per environment (e.g. preprod runs\n * different thresholds than these). This static schedule is ONLY a\n * documented-default reference for displays that must show every tier at once\n * (the Fees & Tiers ladder) when no live payload is available; never gate or\n * compute a user's real cap from it.\n *\n * Volume bands track the live tuned qualification thresholds — PEER $1k,\n * PLUS $10k, PRO $50k, PLATINUM $100k. Caps ($100/$250/$1k/$2.5k/$5k) are unchanged.\n * Read the live per-user values from the API: curator can change qualification\n * inputs behind the compatibility fields without changing this reference table.\n *\n * Ordered highest tier → lowest (PLATINUM first) to match UI display order.\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 Peer Pay volume (USD) that qualifies for this tier. */\n minVolumeUsd: number;\n /** Inclusive upper bound of Peer Pay 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: 100000, maxVolumeUsd: Infinity },\n { tier: 'PRO', perIntentCapUsd: 2500, minVolumeUsd: 50000, maxVolumeUsd: 99999 },\n { tier: 'PLUS', perIntentCapUsd: 1000, minVolumeUsd: 10000, maxVolumeUsd: 49999 },\n { tier: 'PEER', perIntentCapUsd: 250, minVolumeUsd: 1000, maxVolumeUsd: 9999 },\n { tier: 'PEASANT', perIntentCapUsd: 100, minVolumeUsd: 0, maxVolumeUsd: 999 },\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/**\n * Default take-fee discount (in basis points) applied per tier, mirroring\n * curator `TIER_FEE_DISCOUNT_BPS`. The discount is subtracted from the base\n * service fee server-side at quote and sign time — it is NOT returned by the\n * tier endpoint. These are documented defaults for reference fee displays only;\n * the curator DB control-plane can override them, so prefer the fee shown on a\n * live quote when one is available.\n */\nexport const TAKER_TIER_FEE_DISCOUNT_BPS: Readonly<Record<TakerTierLevel, number>> = {\n PEASANT: 0,\n PEER: 5,\n PLUS: 10,\n PRO: 20,\n PLATINUM: 30,\n};\n\n/** The default fee-discount (bps) for a tier, or 0 for unknown tiers. */\nexport function getTakerTierFeeDiscountBps(tier: string | undefined): number {\n if (!tier) return 0;\n return TAKER_TIER_FEE_DISCOUNT_BPS[tier as TakerTierLevel] ?? 0;\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
|
@@ -42469,6 +42469,7 @@ async function createEncryptedSellerCredentialUploadForPlatform({
|
|
|
42469
42469
|
return zkp2pAttestation.createEncryptedSellerCredentialUpload({
|
|
42470
42470
|
attestationServiceUrl,
|
|
42471
42471
|
platform: "wise",
|
|
42472
|
+
...payload.callerAddress ? { callerAddress: payload.callerAddress } : {},
|
|
42472
42473
|
sessionMaterial: payload.sessionMaterial,
|
|
42473
42474
|
...typeof timeoutMs === "number" ? { timeoutMs } : {},
|
|
42474
42475
|
fetch: attestationTransport.fetch,
|
|
@@ -42482,6 +42483,7 @@ async function createEncryptedSellerCredentialUploadForPlatform({
|
|
|
42482
42483
|
return zkp2pAttestation.createEncryptedSellerCredentialUpload({
|
|
42483
42484
|
attestationServiceUrl,
|
|
42484
42485
|
platform,
|
|
42486
|
+
...payload.callerAddress ? { callerAddress: payload.callerAddress } : {},
|
|
42485
42487
|
payeeId: payload.payeeId,
|
|
42486
42488
|
sessionMaterial: payload.sessionMaterial,
|
|
42487
42489
|
...typeof timeoutMs === "number" ? { timeoutMs } : {},
|
|
@@ -42610,7 +42612,10 @@ async function apiCreateSellerCredentialBundle(payload, attestationServiceUrl, p
|
|
|
42610
42612
|
res = await attestationTransport.fetch(`${activeBaseUrl}${endpoint}`, {
|
|
42611
42613
|
method: "POST",
|
|
42612
42614
|
headers: headers(),
|
|
42613
|
-
body: JSON.stringify({
|
|
42615
|
+
body: JSON.stringify({
|
|
42616
|
+
encryptedUpload,
|
|
42617
|
+
...payload.callerAddress ? { callerAddress: payload.callerAddress } : {}
|
|
42618
|
+
})
|
|
42614
42619
|
});
|
|
42615
42620
|
} catch (error) {
|
|
42616
42621
|
throw new exports.NetworkError("Failed to connect to Attestation Service", {
|
|
@@ -46579,7 +46584,7 @@ async function apiUpdateReferralCode(req, opts) {
|
|
|
46579
46584
|
});
|
|
46580
46585
|
return unwrapResponseObject(response);
|
|
46581
46586
|
}
|
|
46582
|
-
async function apiUploadSellerCredential(processorName, payeeDetails, bundle, baseApiUrl, timeoutMs) {
|
|
46587
|
+
async function apiUploadSellerCredential(processorName, payeeDetails, bundle, baseApiUrl, timeoutMs, authorizationToken) {
|
|
46583
46588
|
const endpoint = `/v2/makers/${encodeURIComponent(processorName)}/${encodeURIComponent(
|
|
46584
46589
|
payeeDetails
|
|
46585
46590
|
)}/seller-credential`;
|
|
@@ -46587,7 +46592,8 @@ async function apiUploadSellerCredential(processorName, payeeDetails, bundle, ba
|
|
|
46587
46592
|
url: `${withApiBase(baseApiUrl)}${endpoint}`,
|
|
46588
46593
|
method: "POST",
|
|
46589
46594
|
body: bundle,
|
|
46590
|
-
timeoutMs
|
|
46595
|
+
timeoutMs,
|
|
46596
|
+
authorizationToken
|
|
46591
46597
|
});
|
|
46592
46598
|
}
|
|
46593
46599
|
async function apiUploadGoogleOAuthSellerCredential(processorName, payeeDetails, body, baseApiUrl, opts) {
|
|
@@ -47916,7 +47922,7 @@ function assertBundlePlatformMatches(params) {
|
|
|
47916
47922
|
throw new Error("Seller credential bundle platform does not match upload platform");
|
|
47917
47923
|
}
|
|
47918
47924
|
}
|
|
47919
|
-
async function apiUploadSellerCredentialBundle(params, baseApiUrl, timeoutMs) {
|
|
47925
|
+
async function apiUploadSellerCredentialBundle(params, baseApiUrl, timeoutMs, authorizationToken) {
|
|
47920
47926
|
assertBundlePlatformMatches(params);
|
|
47921
47927
|
const normalizedBaseApiUrl = normalizeBaseApiUrl(baseApiUrl);
|
|
47922
47928
|
if (params.platform === "wise") {
|
|
@@ -47925,7 +47931,8 @@ async function apiUploadSellerCredentialBundle(params, baseApiUrl, timeoutMs) {
|
|
|
47925
47931
|
params.bundle.payeeIdHash,
|
|
47926
47932
|
params.bundle,
|
|
47927
47933
|
normalizedBaseApiUrl,
|
|
47928
|
-
timeoutMs
|
|
47934
|
+
timeoutMs,
|
|
47935
|
+
authorizationToken
|
|
47929
47936
|
);
|
|
47930
47937
|
}
|
|
47931
47938
|
const registeredPayeePayload = {
|
|
@@ -47955,7 +47962,8 @@ async function apiUploadSellerCredentialBundle(params, baseApiUrl, timeoutMs) {
|
|
|
47955
47962
|
registeredPayee.hashedOnchainId,
|
|
47956
47963
|
params.bundle,
|
|
47957
47964
|
normalizedBaseApiUrl,
|
|
47958
|
-
timeoutMs
|
|
47965
|
+
timeoutMs,
|
|
47966
|
+
authorizationToken
|
|
47959
47967
|
);
|
|
47960
47968
|
}
|
|
47961
47969
|
|
|
@@ -48164,10 +48172,23 @@ function normalizePayeeDataInputItem(raw) {
|
|
|
48164
48172
|
if (!legacy) {
|
|
48165
48173
|
return null;
|
|
48166
48174
|
}
|
|
48175
|
+
const metadata = legacy.metadata && isObjectRecord(legacy.metadata) ? { ...legacy.metadata } : {};
|
|
48176
|
+
if (candidate.identityAttestation !== void 0 && candidate.identityAttestation !== null) {
|
|
48177
|
+
metadata.identityAttestation = candidate.identityAttestation;
|
|
48178
|
+
}
|
|
48167
48179
|
return {
|
|
48168
48180
|
offchainId: legacy.offchainId,
|
|
48169
48181
|
telegramUsername: legacy.telegramUsername,
|
|
48170
|
-
metadata:
|
|
48182
|
+
metadata: Object.keys(metadata).length > 0 ? metadata : null
|
|
48183
|
+
};
|
|
48184
|
+
}
|
|
48185
|
+
function getPayeeRegistrationMetadata(payeeData) {
|
|
48186
|
+
if (payeeData.identityAttestation === void 0 || payeeData.identityAttestation === null) {
|
|
48187
|
+
return payeeData.metadata;
|
|
48188
|
+
}
|
|
48189
|
+
return {
|
|
48190
|
+
...isObjectRecord(payeeData.metadata) ? payeeData.metadata : {},
|
|
48191
|
+
identityAttestation: payeeData.identityAttestation
|
|
48171
48192
|
};
|
|
48172
48193
|
}
|
|
48173
48194
|
function resolvePayeeDataInput(params, methodName) {
|
|
@@ -48194,7 +48215,7 @@ function toPostDepositDetailsRequest(processorName, payeeData, index) {
|
|
|
48194
48215
|
processorName,
|
|
48195
48216
|
offchainId: payeeData.offchainId,
|
|
48196
48217
|
telegramUsername: payeeData.telegramUsername,
|
|
48197
|
-
metadata: payeeData
|
|
48218
|
+
metadata: getPayeeRegistrationMetadata(payeeData)
|
|
48198
48219
|
};
|
|
48199
48220
|
}
|
|
48200
48221
|
var Zkp2pClient = class {
|
|
@@ -49240,6 +49261,12 @@ var Zkp2pClient = class {
|
|
|
49240
49261
|
`attestationServiceUrl is required when baseApiUrl is not a supported zkp2p API host: ${baseApiUrl}`
|
|
49241
49262
|
);
|
|
49242
49263
|
}
|
|
49264
|
+
async resolveAuthorizationToken() {
|
|
49265
|
+
if (this.getAuthorizationToken) {
|
|
49266
|
+
return await this.getAuthorizationToken() ?? void 0;
|
|
49267
|
+
}
|
|
49268
|
+
return this.authorizationToken;
|
|
49269
|
+
}
|
|
49243
49270
|
/**
|
|
49244
49271
|
* Normalizes currency tuples by appending an empty `oracleRateConfig` when the ABI
|
|
49245
49272
|
* requires it and the caller hasn't provided one.
|
|
@@ -50595,6 +50622,7 @@ var Zkp2pClient = class {
|
|
|
50595
50622
|
);
|
|
50596
50623
|
if (params.platform === "wise") {
|
|
50597
50624
|
const bundleResponse2 = await createBundle({
|
|
50625
|
+
...params.callerAddress ? { callerAddress: params.callerAddress } : {},
|
|
50598
50626
|
sessionMaterial: params.sessionMaterial
|
|
50599
50627
|
});
|
|
50600
50628
|
if (!bundleResponse2.success || !bundleResponse2.responseObject) {
|
|
@@ -50609,6 +50637,7 @@ var Zkp2pClient = class {
|
|
|
50609
50637
|
);
|
|
50610
50638
|
}
|
|
50611
50639
|
const bundlePayload = {
|
|
50640
|
+
...params.callerAddress ? { callerAddress: params.callerAddress } : {},
|
|
50612
50641
|
payeeId: params.payeeId,
|
|
50613
50642
|
sessionMaterial: params.sessionMaterial
|
|
50614
50643
|
};
|
|
@@ -50635,7 +50664,8 @@ var Zkp2pClient = class {
|
|
|
50635
50664
|
opts?.baseApiUrl ?? this.baseApiUrl ?? DEFAULT_BASE_API_URL
|
|
50636
50665
|
);
|
|
50637
50666
|
const timeoutMs = opts?.timeoutMs ?? this.apiTimeoutMs;
|
|
50638
|
-
|
|
50667
|
+
const authorizationToken = await this.resolveAuthorizationToken();
|
|
50668
|
+
return apiUploadSellerCredentialBundle(params, baseApiUrl, timeoutMs, authorizationToken);
|
|
50639
50669
|
}
|
|
50640
50670
|
/**
|
|
50641
50671
|
* Upload a seller Gmail OAuth authorization code through curator.
|
|
@@ -50928,8 +50958,7 @@ var TAKER_TIER_FEE_DISCOUNT_BPS = {
|
|
|
50928
50958
|
PEER: 5,
|
|
50929
50959
|
PLUS: 10,
|
|
50930
50960
|
PRO: 20,
|
|
50931
|
-
PLATINUM: 30
|
|
50932
|
-
PEER_PRESIDENT: 30
|
|
50961
|
+
PLATINUM: 30
|
|
50933
50962
|
};
|
|
50934
50963
|
function getTakerTierFeeDiscountBps(tier) {
|
|
50935
50964
|
if (!tier) return 0;
|