@usdctofiat/offramp 3.0.1 → 3.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +24 -0
- package/README.md +1 -1
- package/dist/{chunk-5KJ4DFWK.js → chunk-4KKKDDES.js} +118 -367
- package/dist/chunk-4KKKDDES.js.map +1 -0
- package/dist/{errors-DKQ2N_ih.d.cts → errors-D9bV_DWE.d.cts} +42 -5
- package/dist/{errors-DKQ2N_ih.d.ts → errors-D9bV_DWE.d.ts} +42 -5
- package/dist/index.cjs +130 -366
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +7 -1
- package/dist/index.js.map +1 -1
- package/dist/react.cjs +115 -366
- package/dist/react.cjs.map +1 -1
- package/dist/react.d.cts +1 -1
- package/dist/react.d.ts +1 -1
- package/dist/react.js +1 -1
- package/package.json +5 -3
- package/dist/chunk-5KJ4DFWK.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,30 @@ and this project adheres to [Semantic Versioning](https://semver.org/).
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
### Fixed
|
|
11
|
+
|
|
12
|
+
- Reject shortened or non-PayPal URLs in the PayPal.me username normalizer so
|
|
13
|
+
inputs like `t.co/...` cannot be converted into a fake PayPal username.
|
|
14
|
+
|
|
15
|
+
### Changed
|
|
16
|
+
|
|
17
|
+
- Bump `@zkp2p/sdk` to `0.4.1`.
|
|
18
|
+
|
|
19
|
+
## [3.0.3] - 2026-05-20
|
|
20
|
+
|
|
21
|
+
### Fixed
|
|
22
|
+
|
|
23
|
+
- Return canonical OTC share links from `getOtcLink()` and `enableOtc()` using
|
|
24
|
+
`https://otc.usdctofiat.xyz/d/<escrow>/<depositId>`.
|
|
25
|
+
|
|
26
|
+
## [3.0.2] - 2026-05-19
|
|
27
|
+
|
|
28
|
+
### Fixed
|
|
29
|
+
|
|
30
|
+
- Pass the canonical `DEFAULT_INTENT_GUARDIAN_ADDRESS` on `createDeposit` so
|
|
31
|
+
SDK-created deposits share the same guardian as the zkp2p-clients web flow
|
|
32
|
+
instead of falling back to `ZERO_ADDRESS` at the contract.
|
|
33
|
+
|
|
10
34
|
## [3.0.1] - 2026-05-10
|
|
11
35
|
|
|
12
36
|
### Fixed
|
package/README.md
CHANGED
|
@@ -102,7 +102,7 @@ const { depositId, otcLink } = await offramp(walletClient, {
|
|
|
102
102
|
identifier: "alice",
|
|
103
103
|
otcTaker: "0xBuyerAddress",
|
|
104
104
|
});
|
|
105
|
-
// otcLink = "https://usdctofiat.xyz/
|
|
105
|
+
// otcLink = "https://otc.usdctofiat.xyz/d/0x.../362"
|
|
106
106
|
// Share otcLink with the buyer — they open it, connect their wallet, and fill the order.
|
|
107
107
|
```
|
|
108
108
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// src/config.ts
|
|
2
2
|
import { getContracts, getGatingServiceAddress } from "@zkp2p/sdk";
|
|
3
|
-
var SDK_VERSION = "3.0.
|
|
3
|
+
var SDK_VERSION = "3.0.3";
|
|
4
4
|
var BASE_CHAIN_ID = 8453;
|
|
5
5
|
var RUNTIME_ENV = "production";
|
|
6
6
|
var API_BASE_URL = "https://api.zkp2p.xyz";
|
|
@@ -17,6 +17,7 @@ var GATING_SERVICE_ADDRESS = getGatingServiceAddress(
|
|
|
17
17
|
var DELEGATE_RATE_MANAGER_ID = "0x8666d6fb0f6797c56e95339fd7ca82fdd348b9db200e10a4c4aa0a0b879fc41c";
|
|
18
18
|
var RATE_MANAGER_REGISTRY_ADDRESS = "0xeed7db23e724ac4590d6db6f78fda6db203535f3";
|
|
19
19
|
var DELEGATE_MANAGER_FEE_BPS = 10;
|
|
20
|
+
var DEFAULT_INTENT_GUARDIAN_ADDRESS = "0xe29a5BD4D0CEbA6C125A0361E7D20ab4eA275C2f";
|
|
20
21
|
var REFERRER = "galleonlabs";
|
|
21
22
|
var MIN_DEPOSIT_USDC = 1;
|
|
22
23
|
var MIN_ORDER_USDC = 1;
|
|
@@ -101,7 +102,8 @@ var FALLBACK_CURRENCIES = {
|
|
|
101
102
|
zelle: ["USD"],
|
|
102
103
|
paypal: ["USD", "EUR", "GBP", "SGD", "NZD", "AUD", "CAD"],
|
|
103
104
|
monzo: ["GBP"],
|
|
104
|
-
n26: ["EUR"]
|
|
105
|
+
n26: ["EUR"],
|
|
106
|
+
luxon: ["USD", "EUR", "GBP"]
|
|
105
107
|
};
|
|
106
108
|
function gatherCatalogHashes(platform) {
|
|
107
109
|
if (platform === "zelle") {
|
|
@@ -125,13 +127,39 @@ function resolveSupportedCurrencies(platform) {
|
|
|
125
127
|
function normalizePaypalMeUsername(value) {
|
|
126
128
|
const trimmed = value.trim();
|
|
127
129
|
if (!trimmed) return "";
|
|
128
|
-
const withoutProtocol = trimmed.replace(/^https?:\/\//i, "")
|
|
129
|
-
|
|
130
|
-
const withoutDomain = withoutProtocol.replace(/^paypal\.me\//i, "");
|
|
131
|
-
const [pathWithoutQuery] = withoutDomain.split(/[?#]/, 1);
|
|
130
|
+
const withoutProtocol = trimmed.replace(/^https?:\/\//i, "");
|
|
131
|
+
const [pathWithoutQuery] = withoutProtocol.split(/[?#]/, 1);
|
|
132
132
|
const sanitizedPath = pathWithoutQuery.replace(/^\/+/, "");
|
|
133
|
-
const [
|
|
134
|
-
|
|
133
|
+
const [host = "", ...pathSegments] = sanitizedPath.split("/");
|
|
134
|
+
const normalizedHost = host.toLowerCase().replace(/^www\./i, "");
|
|
135
|
+
if (normalizedHost === "paypal.me") {
|
|
136
|
+
const [username = ""] = pathSegments;
|
|
137
|
+
return username.replace(/^@+/, "").trim().toLowerCase();
|
|
138
|
+
}
|
|
139
|
+
if (normalizedHost === "paypal.com") {
|
|
140
|
+
const [paypalMePath = "", username = ""] = pathSegments;
|
|
141
|
+
if (paypalMePath.toLowerCase() !== "paypalme") return "";
|
|
142
|
+
return username.replace(/^@+/, "").trim().toLowerCase();
|
|
143
|
+
}
|
|
144
|
+
if (/^https?:\/\//i.test(trimmed) || trimmed.includes("/")) {
|
|
145
|
+
return trimmed;
|
|
146
|
+
}
|
|
147
|
+
return trimmed.replace(/^@+/, "").toLowerCase();
|
|
148
|
+
}
|
|
149
|
+
function isValidIBAN(iban) {
|
|
150
|
+
const upper = iban.toUpperCase();
|
|
151
|
+
if (!/^[A-Z]{2}[0-9]{2}[A-Z0-9]{11,30}$/.test(upper)) return false;
|
|
152
|
+
const rearranged = upper.slice(4) + upper.slice(0, 4);
|
|
153
|
+
const numeric = rearranged.split("").map((ch) => {
|
|
154
|
+
const code = ch.charCodeAt(0);
|
|
155
|
+
return code >= 65 && code <= 90 ? (code - 55).toString() : ch;
|
|
156
|
+
}).join("");
|
|
157
|
+
let remainder = numeric;
|
|
158
|
+
while (remainder.length > 2) {
|
|
159
|
+
const block = remainder.slice(0, 9);
|
|
160
|
+
remainder = (parseInt(block, 10) % 97).toString() + remainder.slice(block.length);
|
|
161
|
+
}
|
|
162
|
+
return parseInt(remainder, 10) % 97 === 1;
|
|
135
163
|
}
|
|
136
164
|
var BLUEPRINTS = {
|
|
137
165
|
venmo: {
|
|
@@ -183,9 +211,9 @@ var BLUEPRINTS = {
|
|
|
183
211
|
transform: (v) => v.replace(/^@+/, "").trim(),
|
|
184
212
|
extensionRegistration: {
|
|
185
213
|
providerId: "wise",
|
|
186
|
-
requiredPrompt: "This Wisetag is not registered yet.
|
|
187
|
-
ctaLabel: "
|
|
188
|
-
minExtensionVersion: "0.
|
|
214
|
+
requiredPrompt: "This Wisetag is not registered yet. Register it with PeerAuth, then retry with the same Wisetag.",
|
|
215
|
+
ctaLabel: "Register Wisetag",
|
|
216
|
+
minExtensionVersion: "0.5.0"
|
|
189
217
|
}
|
|
190
218
|
},
|
|
191
219
|
mercadopago: {
|
|
@@ -202,7 +230,11 @@ var BLUEPRINTS = {
|
|
|
202
230
|
identifierLabel: "Email",
|
|
203
231
|
placeholder: "email",
|
|
204
232
|
helperText: "Registered Zelle email",
|
|
205
|
-
|
|
233
|
+
// Curator's ZelleProcessor rejects any non-lowercase email outright, so
|
|
234
|
+
// canonicalize to lowercase here rather than letting /v2/makers/create
|
|
235
|
+
// reject after the maker has already approved USDC + paid gas.
|
|
236
|
+
validation: z.string().email(),
|
|
237
|
+
transform: (v) => v.trim().toLowerCase()
|
|
206
238
|
},
|
|
207
239
|
paypal: {
|
|
208
240
|
id: "paypal",
|
|
@@ -210,14 +242,17 @@ var BLUEPRINTS = {
|
|
|
210
242
|
identifierLabel: "PayPal.me Username",
|
|
211
243
|
placeholder: "paypal.me/your-username",
|
|
212
244
|
helperText: "Your PayPal.me username, not your email",
|
|
213
|
-
validation: z.string().min(1, "PayPal.me username is required").regex(
|
|
245
|
+
validation: z.string().min(1, "PayPal.me username is required").regex(
|
|
246
|
+
/^[a-z0-9._-]+$/i,
|
|
247
|
+
"Use your PayPal.me username or paypal.me link, not a shortened URL."
|
|
248
|
+
),
|
|
214
249
|
transform: normalizePaypalMeUsername,
|
|
215
250
|
extensionRegistration: {
|
|
216
251
|
providerId: "paypal",
|
|
217
|
-
requiredPrompt: "This PayPal username is not registered yet.
|
|
218
|
-
ctaLabel: "
|
|
252
|
+
requiredPrompt: "This PayPal username is not registered yet. Register it with PeerAuth, then retry with the same PayPal username.",
|
|
253
|
+
ctaLabel: "Register PayPal Username",
|
|
219
254
|
ctaSubtext: "PayPal Business accounts are not supported at this time.",
|
|
220
|
-
minExtensionVersion: "0.
|
|
255
|
+
minExtensionVersion: "0.5.0"
|
|
221
256
|
}
|
|
222
257
|
},
|
|
223
258
|
monzo: {
|
|
@@ -234,8 +269,20 @@ var BLUEPRINTS = {
|
|
|
234
269
|
identifierLabel: "IBAN",
|
|
235
270
|
placeholder: "IBAN (e.g. DE89...)",
|
|
236
271
|
helperText: "Your IBAN (spaces will be removed)",
|
|
237
|
-
validation
|
|
272
|
+
// transform runs before validation, so the schema sees a spaceless,
|
|
273
|
+
// uppercased IBAN. The MOD-97 refine mirrors curator's N26Processor so a
|
|
274
|
+
// typo'd-but-well-formed IBAN fails here, not after USDC approval + gas.
|
|
275
|
+
validation: z.string().regex(/^[A-Z]{2}[0-9]{2}[A-Z0-9]{11,30}$/, "Enter a valid IBAN").refine(isValidIBAN, "That IBAN looks wrong \u2014 its checksum doesn't match"),
|
|
238
276
|
transform: (v) => v.replace(/\s/g, "").toUpperCase()
|
|
277
|
+
},
|
|
278
|
+
luxon: {
|
|
279
|
+
id: "luxon",
|
|
280
|
+
name: "Luxon",
|
|
281
|
+
identifierLabel: "Email",
|
|
282
|
+
placeholder: "your-luxon-email@example.com",
|
|
283
|
+
helperText: "Email address registered with Luxon",
|
|
284
|
+
validation: z.string().email(),
|
|
285
|
+
transform: (v) => v.trim()
|
|
239
286
|
}
|
|
240
287
|
};
|
|
241
288
|
function buildPlatformEntry(bp) {
|
|
@@ -274,8 +321,18 @@ var PLATFORMS = {
|
|
|
274
321
|
ZELLE: buildPlatformEntry(BLUEPRINTS.zelle),
|
|
275
322
|
PAYPAL: buildPlatformEntry(BLUEPRINTS.paypal),
|
|
276
323
|
MONZO: buildPlatformEntry(BLUEPRINTS.monzo),
|
|
277
|
-
N26: buildPlatformEntry(BLUEPRINTS.n26)
|
|
324
|
+
N26: buildPlatformEntry(BLUEPRINTS.n26),
|
|
325
|
+
LUXON: buildPlatformEntry(BLUEPRINTS.luxon)
|
|
326
|
+
};
|
|
327
|
+
var PLATFORM_LIMITS = {
|
|
328
|
+
venmo: { platformCapUsd: 5e3 },
|
|
329
|
+
n26: { platformCapUsd: 1e4 },
|
|
330
|
+
paypal: { minTier: "PLUS" }
|
|
278
331
|
};
|
|
332
|
+
function getPlatformLimits(platform) {
|
|
333
|
+
const id = platform.trim().toLowerCase();
|
|
334
|
+
return PLATFORM_LIMITS[id] ?? null;
|
|
335
|
+
}
|
|
279
336
|
function getPlatformById(id) {
|
|
280
337
|
return Object.values(PLATFORMS).find((p) => p.id === id) ?? null;
|
|
281
338
|
}
|
|
@@ -384,349 +441,7 @@ function isUserCancellation(error) {
|
|
|
384
441
|
// src/otc.ts
|
|
385
442
|
import { createPublicClient, http, isAddress, zeroAddress } from "viem";
|
|
386
443
|
import { base } from "viem/chains";
|
|
387
|
-
|
|
388
|
-
// ../../node_modules/@zkp2p/contracts-v2/abis/base/WhitelistPreIntentHook.json
|
|
389
|
-
var WhitelistPreIntentHook_default = [
|
|
390
|
-
{
|
|
391
|
-
inputs: [
|
|
392
|
-
{
|
|
393
|
-
internalType: "address",
|
|
394
|
-
name: "_orchestratorRegistry",
|
|
395
|
-
type: "address"
|
|
396
|
-
}
|
|
397
|
-
],
|
|
398
|
-
stateMutability: "nonpayable",
|
|
399
|
-
type: "constructor"
|
|
400
|
-
},
|
|
401
|
-
{
|
|
402
|
-
inputs: [],
|
|
403
|
-
name: "EmptyArray",
|
|
404
|
-
type: "error"
|
|
405
|
-
},
|
|
406
|
-
{
|
|
407
|
-
inputs: [
|
|
408
|
-
{
|
|
409
|
-
internalType: "address",
|
|
410
|
-
name: "taker",
|
|
411
|
-
type: "address"
|
|
412
|
-
},
|
|
413
|
-
{
|
|
414
|
-
internalType: "address",
|
|
415
|
-
name: "escrow",
|
|
416
|
-
type: "address"
|
|
417
|
-
},
|
|
418
|
-
{
|
|
419
|
-
internalType: "uint256",
|
|
420
|
-
name: "depositId",
|
|
421
|
-
type: "uint256"
|
|
422
|
-
}
|
|
423
|
-
],
|
|
424
|
-
name: "TakerNotInWhitelist",
|
|
425
|
-
type: "error"
|
|
426
|
-
},
|
|
427
|
-
{
|
|
428
|
-
inputs: [
|
|
429
|
-
{
|
|
430
|
-
internalType: "address",
|
|
431
|
-
name: "taker",
|
|
432
|
-
type: "address"
|
|
433
|
-
},
|
|
434
|
-
{
|
|
435
|
-
internalType: "address",
|
|
436
|
-
name: "escrow",
|
|
437
|
-
type: "address"
|
|
438
|
-
},
|
|
439
|
-
{
|
|
440
|
-
internalType: "uint256",
|
|
441
|
-
name: "depositId",
|
|
442
|
-
type: "uint256"
|
|
443
|
-
}
|
|
444
|
-
],
|
|
445
|
-
name: "TakerNotWhitelisted",
|
|
446
|
-
type: "error"
|
|
447
|
-
},
|
|
448
|
-
{
|
|
449
|
-
inputs: [
|
|
450
|
-
{
|
|
451
|
-
internalType: "address",
|
|
452
|
-
name: "caller",
|
|
453
|
-
type: "address"
|
|
454
|
-
},
|
|
455
|
-
{
|
|
456
|
-
internalType: "address",
|
|
457
|
-
name: "owner",
|
|
458
|
-
type: "address"
|
|
459
|
-
},
|
|
460
|
-
{
|
|
461
|
-
internalType: "address",
|
|
462
|
-
name: "delegate",
|
|
463
|
-
type: "address"
|
|
464
|
-
}
|
|
465
|
-
],
|
|
466
|
-
name: "UnauthorizedCallerOrDelegate",
|
|
467
|
-
type: "error"
|
|
468
|
-
},
|
|
469
|
-
{
|
|
470
|
-
inputs: [
|
|
471
|
-
{
|
|
472
|
-
internalType: "address",
|
|
473
|
-
name: "caller",
|
|
474
|
-
type: "address"
|
|
475
|
-
}
|
|
476
|
-
],
|
|
477
|
-
name: "UnauthorizedOrchestratorCaller",
|
|
478
|
-
type: "error"
|
|
479
|
-
},
|
|
480
|
-
{
|
|
481
|
-
inputs: [],
|
|
482
|
-
name: "ZeroAddress",
|
|
483
|
-
type: "error"
|
|
484
|
-
},
|
|
485
|
-
{
|
|
486
|
-
anonymous: false,
|
|
487
|
-
inputs: [
|
|
488
|
-
{
|
|
489
|
-
indexed: true,
|
|
490
|
-
internalType: "address",
|
|
491
|
-
name: "escrow",
|
|
492
|
-
type: "address"
|
|
493
|
-
},
|
|
494
|
-
{
|
|
495
|
-
indexed: true,
|
|
496
|
-
internalType: "uint256",
|
|
497
|
-
name: "depositId",
|
|
498
|
-
type: "uint256"
|
|
499
|
-
},
|
|
500
|
-
{
|
|
501
|
-
indexed: true,
|
|
502
|
-
internalType: "address",
|
|
503
|
-
name: "taker",
|
|
504
|
-
type: "address"
|
|
505
|
-
}
|
|
506
|
-
],
|
|
507
|
-
name: "TakerRemovedFromWhitelist",
|
|
508
|
-
type: "event"
|
|
509
|
-
},
|
|
510
|
-
{
|
|
511
|
-
anonymous: false,
|
|
512
|
-
inputs: [
|
|
513
|
-
{
|
|
514
|
-
indexed: true,
|
|
515
|
-
internalType: "address",
|
|
516
|
-
name: "escrow",
|
|
517
|
-
type: "address"
|
|
518
|
-
},
|
|
519
|
-
{
|
|
520
|
-
indexed: true,
|
|
521
|
-
internalType: "uint256",
|
|
522
|
-
name: "depositId",
|
|
523
|
-
type: "uint256"
|
|
524
|
-
},
|
|
525
|
-
{
|
|
526
|
-
indexed: true,
|
|
527
|
-
internalType: "address",
|
|
528
|
-
name: "taker",
|
|
529
|
-
type: "address"
|
|
530
|
-
}
|
|
531
|
-
],
|
|
532
|
-
name: "TakerWhitelisted",
|
|
533
|
-
type: "event"
|
|
534
|
-
},
|
|
535
|
-
{
|
|
536
|
-
inputs: [
|
|
537
|
-
{
|
|
538
|
-
internalType: "address",
|
|
539
|
-
name: "_escrow",
|
|
540
|
-
type: "address"
|
|
541
|
-
},
|
|
542
|
-
{
|
|
543
|
-
internalType: "uint256",
|
|
544
|
-
name: "_depositId",
|
|
545
|
-
type: "uint256"
|
|
546
|
-
},
|
|
547
|
-
{
|
|
548
|
-
internalType: "address[]",
|
|
549
|
-
name: "_takers",
|
|
550
|
-
type: "address[]"
|
|
551
|
-
}
|
|
552
|
-
],
|
|
553
|
-
name: "addToWhitelist",
|
|
554
|
-
outputs: [],
|
|
555
|
-
stateMutability: "nonpayable",
|
|
556
|
-
type: "function"
|
|
557
|
-
},
|
|
558
|
-
{
|
|
559
|
-
inputs: [
|
|
560
|
-
{
|
|
561
|
-
internalType: "address",
|
|
562
|
-
name: "_escrow",
|
|
563
|
-
type: "address"
|
|
564
|
-
},
|
|
565
|
-
{
|
|
566
|
-
internalType: "uint256",
|
|
567
|
-
name: "_depositId",
|
|
568
|
-
type: "uint256"
|
|
569
|
-
},
|
|
570
|
-
{
|
|
571
|
-
internalType: "address",
|
|
572
|
-
name: "_taker",
|
|
573
|
-
type: "address"
|
|
574
|
-
}
|
|
575
|
-
],
|
|
576
|
-
name: "isWhitelisted",
|
|
577
|
-
outputs: [
|
|
578
|
-
{
|
|
579
|
-
internalType: "bool",
|
|
580
|
-
name: "",
|
|
581
|
-
type: "bool"
|
|
582
|
-
}
|
|
583
|
-
],
|
|
584
|
-
stateMutability: "view",
|
|
585
|
-
type: "function"
|
|
586
|
-
},
|
|
587
|
-
{
|
|
588
|
-
inputs: [],
|
|
589
|
-
name: "orchestratorRegistry",
|
|
590
|
-
outputs: [
|
|
591
|
-
{
|
|
592
|
-
internalType: "contract IOrchestratorRegistry",
|
|
593
|
-
name: "",
|
|
594
|
-
type: "address"
|
|
595
|
-
}
|
|
596
|
-
],
|
|
597
|
-
stateMutability: "view",
|
|
598
|
-
type: "function"
|
|
599
|
-
},
|
|
600
|
-
{
|
|
601
|
-
inputs: [
|
|
602
|
-
{
|
|
603
|
-
internalType: "address",
|
|
604
|
-
name: "_escrow",
|
|
605
|
-
type: "address"
|
|
606
|
-
},
|
|
607
|
-
{
|
|
608
|
-
internalType: "uint256",
|
|
609
|
-
name: "_depositId",
|
|
610
|
-
type: "uint256"
|
|
611
|
-
},
|
|
612
|
-
{
|
|
613
|
-
internalType: "address[]",
|
|
614
|
-
name: "_takers",
|
|
615
|
-
type: "address[]"
|
|
616
|
-
}
|
|
617
|
-
],
|
|
618
|
-
name: "removeFromWhitelist",
|
|
619
|
-
outputs: [],
|
|
620
|
-
stateMutability: "nonpayable",
|
|
621
|
-
type: "function"
|
|
622
|
-
},
|
|
623
|
-
{
|
|
624
|
-
inputs: [
|
|
625
|
-
{
|
|
626
|
-
components: [
|
|
627
|
-
{
|
|
628
|
-
internalType: "address",
|
|
629
|
-
name: "taker",
|
|
630
|
-
type: "address"
|
|
631
|
-
},
|
|
632
|
-
{
|
|
633
|
-
internalType: "address",
|
|
634
|
-
name: "escrow",
|
|
635
|
-
type: "address"
|
|
636
|
-
},
|
|
637
|
-
{
|
|
638
|
-
internalType: "uint256",
|
|
639
|
-
name: "depositId",
|
|
640
|
-
type: "uint256"
|
|
641
|
-
},
|
|
642
|
-
{
|
|
643
|
-
internalType: "uint256",
|
|
644
|
-
name: "amount",
|
|
645
|
-
type: "uint256"
|
|
646
|
-
},
|
|
647
|
-
{
|
|
648
|
-
internalType: "address",
|
|
649
|
-
name: "to",
|
|
650
|
-
type: "address"
|
|
651
|
-
},
|
|
652
|
-
{
|
|
653
|
-
internalType: "bytes32",
|
|
654
|
-
name: "paymentMethod",
|
|
655
|
-
type: "bytes32"
|
|
656
|
-
},
|
|
657
|
-
{
|
|
658
|
-
internalType: "bytes32",
|
|
659
|
-
name: "fiatCurrency",
|
|
660
|
-
type: "bytes32"
|
|
661
|
-
},
|
|
662
|
-
{
|
|
663
|
-
internalType: "uint256",
|
|
664
|
-
name: "conversionRate",
|
|
665
|
-
type: "uint256"
|
|
666
|
-
},
|
|
667
|
-
{
|
|
668
|
-
components: [
|
|
669
|
-
{
|
|
670
|
-
internalType: "address",
|
|
671
|
-
name: "recipient",
|
|
672
|
-
type: "address"
|
|
673
|
-
},
|
|
674
|
-
{
|
|
675
|
-
internalType: "uint256",
|
|
676
|
-
name: "fee",
|
|
677
|
-
type: "uint256"
|
|
678
|
-
}
|
|
679
|
-
],
|
|
680
|
-
internalType: "struct IReferralFee.ReferralFee[]",
|
|
681
|
-
name: "referralFees",
|
|
682
|
-
type: "tuple[]"
|
|
683
|
-
},
|
|
684
|
-
{
|
|
685
|
-
internalType: "bytes",
|
|
686
|
-
name: "preIntentHookData",
|
|
687
|
-
type: "bytes"
|
|
688
|
-
}
|
|
689
|
-
],
|
|
690
|
-
internalType: "struct IPreIntentHook.PreIntentContext",
|
|
691
|
-
name: "_ctx",
|
|
692
|
-
type: "tuple"
|
|
693
|
-
}
|
|
694
|
-
],
|
|
695
|
-
name: "validateSignalIntent",
|
|
696
|
-
outputs: [],
|
|
697
|
-
stateMutability: "view",
|
|
698
|
-
type: "function"
|
|
699
|
-
},
|
|
700
|
-
{
|
|
701
|
-
inputs: [
|
|
702
|
-
{
|
|
703
|
-
internalType: "address",
|
|
704
|
-
name: "",
|
|
705
|
-
type: "address"
|
|
706
|
-
},
|
|
707
|
-
{
|
|
708
|
-
internalType: "uint256",
|
|
709
|
-
name: "",
|
|
710
|
-
type: "uint256"
|
|
711
|
-
},
|
|
712
|
-
{
|
|
713
|
-
internalType: "address",
|
|
714
|
-
name: "",
|
|
715
|
-
type: "address"
|
|
716
|
-
}
|
|
717
|
-
],
|
|
718
|
-
name: "whitelist",
|
|
719
|
-
outputs: [
|
|
720
|
-
{
|
|
721
|
-
internalType: "bool",
|
|
722
|
-
name: "",
|
|
723
|
-
type: "bool"
|
|
724
|
-
}
|
|
725
|
-
],
|
|
726
|
-
stateMutability: "view",
|
|
727
|
-
type: "function"
|
|
728
|
-
}
|
|
729
|
-
];
|
|
444
|
+
import WhitelistPreIntentHookABI from "@zkp2p/contracts-v2/abis/base/WhitelistPreIntentHook.json";
|
|
730
445
|
|
|
731
446
|
// src/sdk-client.ts
|
|
732
447
|
import { OfframpClient } from "@zkp2p/sdk";
|
|
@@ -742,7 +457,7 @@ function createSdkClient(walletClient) {
|
|
|
742
457
|
|
|
743
458
|
// src/otc.ts
|
|
744
459
|
var WHITELIST_HOOK_ADDRESS = "0xda023Ea0d789A41BcF5866F7B6BBd2CaDF9b79B8";
|
|
745
|
-
var OTC_BASE_URL = "https://usdctofiat.xyz";
|
|
460
|
+
var OTC_BASE_URL = "https://otc.usdctofiat.xyz";
|
|
746
461
|
async function enableOtc(walletClient, depositId, takerAddress, escrowAddress) {
|
|
747
462
|
if (!isAddress(takerAddress)) {
|
|
748
463
|
throw new OfframpError("Invalid taker address", "VALIDATION");
|
|
@@ -814,7 +529,7 @@ async function disableOtc(walletClient, depositId, escrowAddress) {
|
|
|
814
529
|
}
|
|
815
530
|
function getOtcLink(depositId, escrowAddress) {
|
|
816
531
|
const escrow = escrowAddress || ESCROW_ADDRESS;
|
|
817
|
-
return `${OTC_BASE_URL}/
|
|
532
|
+
return `${OTC_BASE_URL}/d/${escrow}/${depositId}`;
|
|
818
533
|
}
|
|
819
534
|
async function writeContract(walletClient, functionName, args) {
|
|
820
535
|
const wc = walletClient;
|
|
@@ -823,7 +538,7 @@ async function writeContract(walletClient, functionName, args) {
|
|
|
823
538
|
}
|
|
824
539
|
await wc.writeContract({
|
|
825
540
|
address: WHITELIST_HOOK_ADDRESS,
|
|
826
|
-
abi:
|
|
541
|
+
abi: WhitelistPreIntentHookABI,
|
|
827
542
|
functionName,
|
|
828
543
|
args
|
|
829
544
|
});
|
|
@@ -832,7 +547,7 @@ async function readIsWhitelisted(escrow, depositId, taker) {
|
|
|
832
547
|
const publicClient = createPublicClient({ chain: base, transport: http(BASE_RPC_URL) });
|
|
833
548
|
return publicClient.readContract({
|
|
834
549
|
address: WHITELIST_HOOK_ADDRESS,
|
|
835
|
-
abi:
|
|
550
|
+
abi: WhitelistPreIntentHookABI,
|
|
836
551
|
functionName: "isWhitelisted",
|
|
837
552
|
args: [escrow, depositId, taker]
|
|
838
553
|
});
|
|
@@ -1199,6 +914,28 @@ async function registerPayeeDetails(processorName, payload) {
|
|
|
1199
914
|
clearTimeout(timeout);
|
|
1200
915
|
}
|
|
1201
916
|
}
|
|
917
|
+
async function validatePayeeDetails(processorName, offchainId) {
|
|
918
|
+
const controller = new AbortController();
|
|
919
|
+
const timeout = setTimeout(() => controller.abort(), PAYEE_REGISTRATION_TIMEOUT_MS);
|
|
920
|
+
try {
|
|
921
|
+
const res = await fetch(`${API_BASE_URL}/v2/makers/validate`, {
|
|
922
|
+
method: "POST",
|
|
923
|
+
headers: { "Content-Type": "application/json" },
|
|
924
|
+
body: JSON.stringify({ processorName, offchainId }),
|
|
925
|
+
signal: controller.signal
|
|
926
|
+
});
|
|
927
|
+
if (!res.ok) return "unknown";
|
|
928
|
+
const json = await res.json();
|
|
929
|
+
if (typeof json.responseObject === "boolean") {
|
|
930
|
+
return json.responseObject ? "valid" : "invalid";
|
|
931
|
+
}
|
|
932
|
+
return "unknown";
|
|
933
|
+
} catch {
|
|
934
|
+
return "unknown";
|
|
935
|
+
} finally {
|
|
936
|
+
clearTimeout(timeout);
|
|
937
|
+
}
|
|
938
|
+
}
|
|
1202
939
|
function attachOracleConfig(entries, conversionRates) {
|
|
1203
940
|
return entries.map(
|
|
1204
941
|
(group, gi) => group.map((entry, ci) => {
|
|
@@ -1370,6 +1107,17 @@ async function offramp(walletClient, params, onProgress, telemetryContext) {
|
|
|
1370
1107
|
} catch (err) {
|
|
1371
1108
|
if (err instanceof OfframpError) throw err;
|
|
1372
1109
|
}
|
|
1110
|
+
const canonicalName = platformId.startsWith("zelle") ? "zelle" : platformId;
|
|
1111
|
+
if (!getPeerExtensionRegistrationInfo(platformId)) {
|
|
1112
|
+
const outcome = await validatePayeeDetails(canonicalName, normalizedIdentifier);
|
|
1113
|
+
if (outcome === "invalid") {
|
|
1114
|
+
throw new OfframpError(
|
|
1115
|
+
`Couldn't verify that ${platform.name} ${platform.identifier.label.toLowerCase()}. Double-check it and try again.`,
|
|
1116
|
+
"VALIDATION",
|
|
1117
|
+
"registering"
|
|
1118
|
+
);
|
|
1119
|
+
}
|
|
1120
|
+
}
|
|
1373
1121
|
const client = createSdkClient(walletClient);
|
|
1374
1122
|
const txOverrides = { referrer: [REFERRER] };
|
|
1375
1123
|
emitProgress({ step: "approving" });
|
|
@@ -1394,7 +1142,6 @@ async function offramp(walletClient, params, onProgress, telemetryContext) {
|
|
|
1394
1142
|
}
|
|
1395
1143
|
emitProgress({ step: "registering" });
|
|
1396
1144
|
let hashedOnchainId;
|
|
1397
|
-
const canonicalName = platformId.startsWith("zelle") ? "zelle" : platformId;
|
|
1398
1145
|
try {
|
|
1399
1146
|
const payeePayload = buildDepositData(canonicalName, normalizedIdentifier);
|
|
1400
1147
|
hashedOnchainId = await registerPayeeDetails(canonicalName, payeePayload);
|
|
@@ -1444,6 +1191,7 @@ async function offramp(walletClient, params, onProgress, telemetryContext) {
|
|
|
1444
1191
|
data: "0x"
|
|
1445
1192
|
})),
|
|
1446
1193
|
currenciesOverride,
|
|
1194
|
+
intentGuardian: DEFAULT_INTENT_GUARDIAN_ADDRESS,
|
|
1447
1195
|
escrowAddress: ESCROW_ADDRESS,
|
|
1448
1196
|
txOverrides
|
|
1449
1197
|
});
|
|
@@ -1757,7 +1505,10 @@ import {
|
|
|
1757
1505
|
export {
|
|
1758
1506
|
ESCROW_ADDRESS,
|
|
1759
1507
|
normalizePaypalMeUsername,
|
|
1508
|
+
isValidIBAN,
|
|
1760
1509
|
PLATFORMS,
|
|
1510
|
+
PLATFORM_LIMITS,
|
|
1511
|
+
getPlatformLimits,
|
|
1761
1512
|
getPeerExtensionRegistrationInfo,
|
|
1762
1513
|
isPeerExtensionRegistrationError,
|
|
1763
1514
|
MakersCreateError,
|
|
@@ -1784,4 +1535,4 @@ export {
|
|
|
1784
1535
|
openPeerExtensionInstallPage,
|
|
1785
1536
|
getPeerExtensionState
|
|
1786
1537
|
};
|
|
1787
|
-
//# sourceMappingURL=chunk-
|
|
1538
|
+
//# sourceMappingURL=chunk-4KKKDDES.js.map
|