@usdctofiat/offramp 3.0.2 → 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 +16 -0
- package/README.md +1 -1
- package/dist/{chunk-F7DVUBMT.js → chunk-4KKKDDES.js} +116 -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 +128 -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 +113 -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-F7DVUBMT.js.map +0 -1
package/dist/index.cjs
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
2
3
|
var __defProp = Object.defineProperty;
|
|
3
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
5
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
8
|
var __export = (target, all) => {
|
|
7
9
|
for (var name in all)
|
|
@@ -15,6 +17,14 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
15
17
|
}
|
|
16
18
|
return to;
|
|
17
19
|
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
18
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
29
|
|
|
20
30
|
// src/index.ts
|
|
@@ -28,6 +38,7 @@ __export(index_exports, {
|
|
|
28
38
|
OfframpError: () => OfframpError,
|
|
29
39
|
PEER_EXTENSION_CHROME_URL: () => import_sdk7.PEER_EXTENSION_CHROME_URL,
|
|
30
40
|
PLATFORMS: () => PLATFORMS,
|
|
41
|
+
PLATFORM_LIMITS: () => PLATFORM_LIMITS,
|
|
31
42
|
close: () => close,
|
|
32
43
|
createOfframp: () => createOfframp,
|
|
33
44
|
createPeerExtensionSdk: () => import_sdk7.createPeerExtensionSdk,
|
|
@@ -40,8 +51,10 @@ __export(index_exports, {
|
|
|
40
51
|
getOtcLink: () => getOtcLink,
|
|
41
52
|
getPeerExtensionRegistrationInfo: () => getPeerExtensionRegistrationInfo,
|
|
42
53
|
getPeerExtensionState: () => import_sdk7.getPeerExtensionState,
|
|
54
|
+
getPlatformLimits: () => getPlatformLimits,
|
|
43
55
|
isPeerExtensionAvailable: () => import_sdk7.isPeerExtensionAvailable,
|
|
44
56
|
isPeerExtensionRegistrationError: () => isPeerExtensionRegistrationError,
|
|
57
|
+
isValidIBAN: () => isValidIBAN,
|
|
45
58
|
normalizePaypalMeUsername: () => normalizePaypalMeUsername,
|
|
46
59
|
offramp: () => offramp,
|
|
47
60
|
openPeerExtensionInstallPage: () => import_sdk7.openPeerExtensionInstallPage,
|
|
@@ -59,7 +72,7 @@ var import_sdk5 = require("@zkp2p/sdk");
|
|
|
59
72
|
|
|
60
73
|
// src/config.ts
|
|
61
74
|
var import_sdk = require("@zkp2p/sdk");
|
|
62
|
-
var SDK_VERSION = "3.0.
|
|
75
|
+
var SDK_VERSION = "3.0.3";
|
|
63
76
|
var BASE_CHAIN_ID = 8453;
|
|
64
77
|
var RUNTIME_ENV = "production";
|
|
65
78
|
var API_BASE_URL = "https://api.zkp2p.xyz";
|
|
@@ -156,7 +169,8 @@ var FALLBACK_CURRENCIES = {
|
|
|
156
169
|
zelle: ["USD"],
|
|
157
170
|
paypal: ["USD", "EUR", "GBP", "SGD", "NZD", "AUD", "CAD"],
|
|
158
171
|
monzo: ["GBP"],
|
|
159
|
-
n26: ["EUR"]
|
|
172
|
+
n26: ["EUR"],
|
|
173
|
+
luxon: ["USD", "EUR", "GBP"]
|
|
160
174
|
};
|
|
161
175
|
function gatherCatalogHashes(platform) {
|
|
162
176
|
if (platform === "zelle") {
|
|
@@ -180,13 +194,39 @@ function resolveSupportedCurrencies(platform) {
|
|
|
180
194
|
function normalizePaypalMeUsername(value) {
|
|
181
195
|
const trimmed = value.trim();
|
|
182
196
|
if (!trimmed) return "";
|
|
183
|
-
const withoutProtocol = trimmed.replace(/^https?:\/\//i, "")
|
|
184
|
-
|
|
185
|
-
const withoutDomain = withoutProtocol.replace(/^paypal\.me\//i, "");
|
|
186
|
-
const [pathWithoutQuery] = withoutDomain.split(/[?#]/, 1);
|
|
197
|
+
const withoutProtocol = trimmed.replace(/^https?:\/\//i, "");
|
|
198
|
+
const [pathWithoutQuery] = withoutProtocol.split(/[?#]/, 1);
|
|
187
199
|
const sanitizedPath = pathWithoutQuery.replace(/^\/+/, "");
|
|
188
|
-
const [
|
|
189
|
-
|
|
200
|
+
const [host = "", ...pathSegments] = sanitizedPath.split("/");
|
|
201
|
+
const normalizedHost = host.toLowerCase().replace(/^www\./i, "");
|
|
202
|
+
if (normalizedHost === "paypal.me") {
|
|
203
|
+
const [username = ""] = pathSegments;
|
|
204
|
+
return username.replace(/^@+/, "").trim().toLowerCase();
|
|
205
|
+
}
|
|
206
|
+
if (normalizedHost === "paypal.com") {
|
|
207
|
+
const [paypalMePath = "", username = ""] = pathSegments;
|
|
208
|
+
if (paypalMePath.toLowerCase() !== "paypalme") return "";
|
|
209
|
+
return username.replace(/^@+/, "").trim().toLowerCase();
|
|
210
|
+
}
|
|
211
|
+
if (/^https?:\/\//i.test(trimmed) || trimmed.includes("/")) {
|
|
212
|
+
return trimmed;
|
|
213
|
+
}
|
|
214
|
+
return trimmed.replace(/^@+/, "").toLowerCase();
|
|
215
|
+
}
|
|
216
|
+
function isValidIBAN(iban) {
|
|
217
|
+
const upper = iban.toUpperCase();
|
|
218
|
+
if (!/^[A-Z]{2}[0-9]{2}[A-Z0-9]{11,30}$/.test(upper)) return false;
|
|
219
|
+
const rearranged = upper.slice(4) + upper.slice(0, 4);
|
|
220
|
+
const numeric = rearranged.split("").map((ch) => {
|
|
221
|
+
const code = ch.charCodeAt(0);
|
|
222
|
+
return code >= 65 && code <= 90 ? (code - 55).toString() : ch;
|
|
223
|
+
}).join("");
|
|
224
|
+
let remainder = numeric;
|
|
225
|
+
while (remainder.length > 2) {
|
|
226
|
+
const block = remainder.slice(0, 9);
|
|
227
|
+
remainder = (parseInt(block, 10) % 97).toString() + remainder.slice(block.length);
|
|
228
|
+
}
|
|
229
|
+
return parseInt(remainder, 10) % 97 === 1;
|
|
190
230
|
}
|
|
191
231
|
var BLUEPRINTS = {
|
|
192
232
|
venmo: {
|
|
@@ -238,9 +278,9 @@ var BLUEPRINTS = {
|
|
|
238
278
|
transform: (v) => v.replace(/^@+/, "").trim(),
|
|
239
279
|
extensionRegistration: {
|
|
240
280
|
providerId: "wise",
|
|
241
|
-
requiredPrompt: "This Wisetag is not registered yet.
|
|
242
|
-
ctaLabel: "
|
|
243
|
-
minExtensionVersion: "0.
|
|
281
|
+
requiredPrompt: "This Wisetag is not registered yet. Register it with PeerAuth, then retry with the same Wisetag.",
|
|
282
|
+
ctaLabel: "Register Wisetag",
|
|
283
|
+
minExtensionVersion: "0.5.0"
|
|
244
284
|
}
|
|
245
285
|
},
|
|
246
286
|
mercadopago: {
|
|
@@ -257,7 +297,11 @@ var BLUEPRINTS = {
|
|
|
257
297
|
identifierLabel: "Email",
|
|
258
298
|
placeholder: "email",
|
|
259
299
|
helperText: "Registered Zelle email",
|
|
260
|
-
|
|
300
|
+
// Curator's ZelleProcessor rejects any non-lowercase email outright, so
|
|
301
|
+
// canonicalize to lowercase here rather than letting /v2/makers/create
|
|
302
|
+
// reject after the maker has already approved USDC + paid gas.
|
|
303
|
+
validation: import_zod.z.string().email(),
|
|
304
|
+
transform: (v) => v.trim().toLowerCase()
|
|
261
305
|
},
|
|
262
306
|
paypal: {
|
|
263
307
|
id: "paypal",
|
|
@@ -265,14 +309,17 @@ var BLUEPRINTS = {
|
|
|
265
309
|
identifierLabel: "PayPal.me Username",
|
|
266
310
|
placeholder: "paypal.me/your-username",
|
|
267
311
|
helperText: "Your PayPal.me username, not your email",
|
|
268
|
-
validation: import_zod.z.string().min(1, "PayPal.me username is required").regex(
|
|
312
|
+
validation: import_zod.z.string().min(1, "PayPal.me username is required").regex(
|
|
313
|
+
/^[a-z0-9._-]+$/i,
|
|
314
|
+
"Use your PayPal.me username or paypal.me link, not a shortened URL."
|
|
315
|
+
),
|
|
269
316
|
transform: normalizePaypalMeUsername,
|
|
270
317
|
extensionRegistration: {
|
|
271
318
|
providerId: "paypal",
|
|
272
|
-
requiredPrompt: "This PayPal username is not registered yet.
|
|
273
|
-
ctaLabel: "
|
|
319
|
+
requiredPrompt: "This PayPal username is not registered yet. Register it with PeerAuth, then retry with the same PayPal username.",
|
|
320
|
+
ctaLabel: "Register PayPal Username",
|
|
274
321
|
ctaSubtext: "PayPal Business accounts are not supported at this time.",
|
|
275
|
-
minExtensionVersion: "0.
|
|
322
|
+
minExtensionVersion: "0.5.0"
|
|
276
323
|
}
|
|
277
324
|
},
|
|
278
325
|
monzo: {
|
|
@@ -289,8 +336,20 @@ var BLUEPRINTS = {
|
|
|
289
336
|
identifierLabel: "IBAN",
|
|
290
337
|
placeholder: "IBAN (e.g. DE89...)",
|
|
291
338
|
helperText: "Your IBAN (spaces will be removed)",
|
|
292
|
-
validation
|
|
339
|
+
// transform runs before validation, so the schema sees a spaceless,
|
|
340
|
+
// uppercased IBAN. The MOD-97 refine mirrors curator's N26Processor so a
|
|
341
|
+
// typo'd-but-well-formed IBAN fails here, not after USDC approval + gas.
|
|
342
|
+
validation: import_zod.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"),
|
|
293
343
|
transform: (v) => v.replace(/\s/g, "").toUpperCase()
|
|
344
|
+
},
|
|
345
|
+
luxon: {
|
|
346
|
+
id: "luxon",
|
|
347
|
+
name: "Luxon",
|
|
348
|
+
identifierLabel: "Email",
|
|
349
|
+
placeholder: "your-luxon-email@example.com",
|
|
350
|
+
helperText: "Email address registered with Luxon",
|
|
351
|
+
validation: import_zod.z.string().email(),
|
|
352
|
+
transform: (v) => v.trim()
|
|
294
353
|
}
|
|
295
354
|
};
|
|
296
355
|
function buildPlatformEntry(bp) {
|
|
@@ -329,8 +388,18 @@ var PLATFORMS = {
|
|
|
329
388
|
ZELLE: buildPlatformEntry(BLUEPRINTS.zelle),
|
|
330
389
|
PAYPAL: buildPlatformEntry(BLUEPRINTS.paypal),
|
|
331
390
|
MONZO: buildPlatformEntry(BLUEPRINTS.monzo),
|
|
332
|
-
N26: buildPlatformEntry(BLUEPRINTS.n26)
|
|
391
|
+
N26: buildPlatformEntry(BLUEPRINTS.n26),
|
|
392
|
+
LUXON: buildPlatformEntry(BLUEPRINTS.luxon)
|
|
393
|
+
};
|
|
394
|
+
var PLATFORM_LIMITS = {
|
|
395
|
+
venmo: { platformCapUsd: 5e3 },
|
|
396
|
+
n26: { platformCapUsd: 1e4 },
|
|
397
|
+
paypal: { minTier: "PLUS" }
|
|
333
398
|
};
|
|
399
|
+
function getPlatformLimits(platform) {
|
|
400
|
+
const id = platform.trim().toLowerCase();
|
|
401
|
+
return PLATFORM_LIMITS[id] ?? null;
|
|
402
|
+
}
|
|
334
403
|
function getPlatformById(id) {
|
|
335
404
|
return Object.values(PLATFORMS).find((p) => p.id === id) ?? null;
|
|
336
405
|
}
|
|
@@ -439,349 +508,7 @@ function isUserCancellation(error) {
|
|
|
439
508
|
// src/otc.ts
|
|
440
509
|
var import_viem = require("viem");
|
|
441
510
|
var import_chains = require("viem/chains");
|
|
442
|
-
|
|
443
|
-
// ../../node_modules/@zkp2p/contracts-v2/abis/base/WhitelistPreIntentHook.json
|
|
444
|
-
var WhitelistPreIntentHook_default = [
|
|
445
|
-
{
|
|
446
|
-
inputs: [
|
|
447
|
-
{
|
|
448
|
-
internalType: "address",
|
|
449
|
-
name: "_orchestratorRegistry",
|
|
450
|
-
type: "address"
|
|
451
|
-
}
|
|
452
|
-
],
|
|
453
|
-
stateMutability: "nonpayable",
|
|
454
|
-
type: "constructor"
|
|
455
|
-
},
|
|
456
|
-
{
|
|
457
|
-
inputs: [],
|
|
458
|
-
name: "EmptyArray",
|
|
459
|
-
type: "error"
|
|
460
|
-
},
|
|
461
|
-
{
|
|
462
|
-
inputs: [
|
|
463
|
-
{
|
|
464
|
-
internalType: "address",
|
|
465
|
-
name: "taker",
|
|
466
|
-
type: "address"
|
|
467
|
-
},
|
|
468
|
-
{
|
|
469
|
-
internalType: "address",
|
|
470
|
-
name: "escrow",
|
|
471
|
-
type: "address"
|
|
472
|
-
},
|
|
473
|
-
{
|
|
474
|
-
internalType: "uint256",
|
|
475
|
-
name: "depositId",
|
|
476
|
-
type: "uint256"
|
|
477
|
-
}
|
|
478
|
-
],
|
|
479
|
-
name: "TakerNotInWhitelist",
|
|
480
|
-
type: "error"
|
|
481
|
-
},
|
|
482
|
-
{
|
|
483
|
-
inputs: [
|
|
484
|
-
{
|
|
485
|
-
internalType: "address",
|
|
486
|
-
name: "taker",
|
|
487
|
-
type: "address"
|
|
488
|
-
},
|
|
489
|
-
{
|
|
490
|
-
internalType: "address",
|
|
491
|
-
name: "escrow",
|
|
492
|
-
type: "address"
|
|
493
|
-
},
|
|
494
|
-
{
|
|
495
|
-
internalType: "uint256",
|
|
496
|
-
name: "depositId",
|
|
497
|
-
type: "uint256"
|
|
498
|
-
}
|
|
499
|
-
],
|
|
500
|
-
name: "TakerNotWhitelisted",
|
|
501
|
-
type: "error"
|
|
502
|
-
},
|
|
503
|
-
{
|
|
504
|
-
inputs: [
|
|
505
|
-
{
|
|
506
|
-
internalType: "address",
|
|
507
|
-
name: "caller",
|
|
508
|
-
type: "address"
|
|
509
|
-
},
|
|
510
|
-
{
|
|
511
|
-
internalType: "address",
|
|
512
|
-
name: "owner",
|
|
513
|
-
type: "address"
|
|
514
|
-
},
|
|
515
|
-
{
|
|
516
|
-
internalType: "address",
|
|
517
|
-
name: "delegate",
|
|
518
|
-
type: "address"
|
|
519
|
-
}
|
|
520
|
-
],
|
|
521
|
-
name: "UnauthorizedCallerOrDelegate",
|
|
522
|
-
type: "error"
|
|
523
|
-
},
|
|
524
|
-
{
|
|
525
|
-
inputs: [
|
|
526
|
-
{
|
|
527
|
-
internalType: "address",
|
|
528
|
-
name: "caller",
|
|
529
|
-
type: "address"
|
|
530
|
-
}
|
|
531
|
-
],
|
|
532
|
-
name: "UnauthorizedOrchestratorCaller",
|
|
533
|
-
type: "error"
|
|
534
|
-
},
|
|
535
|
-
{
|
|
536
|
-
inputs: [],
|
|
537
|
-
name: "ZeroAddress",
|
|
538
|
-
type: "error"
|
|
539
|
-
},
|
|
540
|
-
{
|
|
541
|
-
anonymous: false,
|
|
542
|
-
inputs: [
|
|
543
|
-
{
|
|
544
|
-
indexed: true,
|
|
545
|
-
internalType: "address",
|
|
546
|
-
name: "escrow",
|
|
547
|
-
type: "address"
|
|
548
|
-
},
|
|
549
|
-
{
|
|
550
|
-
indexed: true,
|
|
551
|
-
internalType: "uint256",
|
|
552
|
-
name: "depositId",
|
|
553
|
-
type: "uint256"
|
|
554
|
-
},
|
|
555
|
-
{
|
|
556
|
-
indexed: true,
|
|
557
|
-
internalType: "address",
|
|
558
|
-
name: "taker",
|
|
559
|
-
type: "address"
|
|
560
|
-
}
|
|
561
|
-
],
|
|
562
|
-
name: "TakerRemovedFromWhitelist",
|
|
563
|
-
type: "event"
|
|
564
|
-
},
|
|
565
|
-
{
|
|
566
|
-
anonymous: false,
|
|
567
|
-
inputs: [
|
|
568
|
-
{
|
|
569
|
-
indexed: true,
|
|
570
|
-
internalType: "address",
|
|
571
|
-
name: "escrow",
|
|
572
|
-
type: "address"
|
|
573
|
-
},
|
|
574
|
-
{
|
|
575
|
-
indexed: true,
|
|
576
|
-
internalType: "uint256",
|
|
577
|
-
name: "depositId",
|
|
578
|
-
type: "uint256"
|
|
579
|
-
},
|
|
580
|
-
{
|
|
581
|
-
indexed: true,
|
|
582
|
-
internalType: "address",
|
|
583
|
-
name: "taker",
|
|
584
|
-
type: "address"
|
|
585
|
-
}
|
|
586
|
-
],
|
|
587
|
-
name: "TakerWhitelisted",
|
|
588
|
-
type: "event"
|
|
589
|
-
},
|
|
590
|
-
{
|
|
591
|
-
inputs: [
|
|
592
|
-
{
|
|
593
|
-
internalType: "address",
|
|
594
|
-
name: "_escrow",
|
|
595
|
-
type: "address"
|
|
596
|
-
},
|
|
597
|
-
{
|
|
598
|
-
internalType: "uint256",
|
|
599
|
-
name: "_depositId",
|
|
600
|
-
type: "uint256"
|
|
601
|
-
},
|
|
602
|
-
{
|
|
603
|
-
internalType: "address[]",
|
|
604
|
-
name: "_takers",
|
|
605
|
-
type: "address[]"
|
|
606
|
-
}
|
|
607
|
-
],
|
|
608
|
-
name: "addToWhitelist",
|
|
609
|
-
outputs: [],
|
|
610
|
-
stateMutability: "nonpayable",
|
|
611
|
-
type: "function"
|
|
612
|
-
},
|
|
613
|
-
{
|
|
614
|
-
inputs: [
|
|
615
|
-
{
|
|
616
|
-
internalType: "address",
|
|
617
|
-
name: "_escrow",
|
|
618
|
-
type: "address"
|
|
619
|
-
},
|
|
620
|
-
{
|
|
621
|
-
internalType: "uint256",
|
|
622
|
-
name: "_depositId",
|
|
623
|
-
type: "uint256"
|
|
624
|
-
},
|
|
625
|
-
{
|
|
626
|
-
internalType: "address",
|
|
627
|
-
name: "_taker",
|
|
628
|
-
type: "address"
|
|
629
|
-
}
|
|
630
|
-
],
|
|
631
|
-
name: "isWhitelisted",
|
|
632
|
-
outputs: [
|
|
633
|
-
{
|
|
634
|
-
internalType: "bool",
|
|
635
|
-
name: "",
|
|
636
|
-
type: "bool"
|
|
637
|
-
}
|
|
638
|
-
],
|
|
639
|
-
stateMutability: "view",
|
|
640
|
-
type: "function"
|
|
641
|
-
},
|
|
642
|
-
{
|
|
643
|
-
inputs: [],
|
|
644
|
-
name: "orchestratorRegistry",
|
|
645
|
-
outputs: [
|
|
646
|
-
{
|
|
647
|
-
internalType: "contract IOrchestratorRegistry",
|
|
648
|
-
name: "",
|
|
649
|
-
type: "address"
|
|
650
|
-
}
|
|
651
|
-
],
|
|
652
|
-
stateMutability: "view",
|
|
653
|
-
type: "function"
|
|
654
|
-
},
|
|
655
|
-
{
|
|
656
|
-
inputs: [
|
|
657
|
-
{
|
|
658
|
-
internalType: "address",
|
|
659
|
-
name: "_escrow",
|
|
660
|
-
type: "address"
|
|
661
|
-
},
|
|
662
|
-
{
|
|
663
|
-
internalType: "uint256",
|
|
664
|
-
name: "_depositId",
|
|
665
|
-
type: "uint256"
|
|
666
|
-
},
|
|
667
|
-
{
|
|
668
|
-
internalType: "address[]",
|
|
669
|
-
name: "_takers",
|
|
670
|
-
type: "address[]"
|
|
671
|
-
}
|
|
672
|
-
],
|
|
673
|
-
name: "removeFromWhitelist",
|
|
674
|
-
outputs: [],
|
|
675
|
-
stateMutability: "nonpayable",
|
|
676
|
-
type: "function"
|
|
677
|
-
},
|
|
678
|
-
{
|
|
679
|
-
inputs: [
|
|
680
|
-
{
|
|
681
|
-
components: [
|
|
682
|
-
{
|
|
683
|
-
internalType: "address",
|
|
684
|
-
name: "taker",
|
|
685
|
-
type: "address"
|
|
686
|
-
},
|
|
687
|
-
{
|
|
688
|
-
internalType: "address",
|
|
689
|
-
name: "escrow",
|
|
690
|
-
type: "address"
|
|
691
|
-
},
|
|
692
|
-
{
|
|
693
|
-
internalType: "uint256",
|
|
694
|
-
name: "depositId",
|
|
695
|
-
type: "uint256"
|
|
696
|
-
},
|
|
697
|
-
{
|
|
698
|
-
internalType: "uint256",
|
|
699
|
-
name: "amount",
|
|
700
|
-
type: "uint256"
|
|
701
|
-
},
|
|
702
|
-
{
|
|
703
|
-
internalType: "address",
|
|
704
|
-
name: "to",
|
|
705
|
-
type: "address"
|
|
706
|
-
},
|
|
707
|
-
{
|
|
708
|
-
internalType: "bytes32",
|
|
709
|
-
name: "paymentMethod",
|
|
710
|
-
type: "bytes32"
|
|
711
|
-
},
|
|
712
|
-
{
|
|
713
|
-
internalType: "bytes32",
|
|
714
|
-
name: "fiatCurrency",
|
|
715
|
-
type: "bytes32"
|
|
716
|
-
},
|
|
717
|
-
{
|
|
718
|
-
internalType: "uint256",
|
|
719
|
-
name: "conversionRate",
|
|
720
|
-
type: "uint256"
|
|
721
|
-
},
|
|
722
|
-
{
|
|
723
|
-
components: [
|
|
724
|
-
{
|
|
725
|
-
internalType: "address",
|
|
726
|
-
name: "recipient",
|
|
727
|
-
type: "address"
|
|
728
|
-
},
|
|
729
|
-
{
|
|
730
|
-
internalType: "uint256",
|
|
731
|
-
name: "fee",
|
|
732
|
-
type: "uint256"
|
|
733
|
-
}
|
|
734
|
-
],
|
|
735
|
-
internalType: "struct IReferralFee.ReferralFee[]",
|
|
736
|
-
name: "referralFees",
|
|
737
|
-
type: "tuple[]"
|
|
738
|
-
},
|
|
739
|
-
{
|
|
740
|
-
internalType: "bytes",
|
|
741
|
-
name: "preIntentHookData",
|
|
742
|
-
type: "bytes"
|
|
743
|
-
}
|
|
744
|
-
],
|
|
745
|
-
internalType: "struct IPreIntentHook.PreIntentContext",
|
|
746
|
-
name: "_ctx",
|
|
747
|
-
type: "tuple"
|
|
748
|
-
}
|
|
749
|
-
],
|
|
750
|
-
name: "validateSignalIntent",
|
|
751
|
-
outputs: [],
|
|
752
|
-
stateMutability: "view",
|
|
753
|
-
type: "function"
|
|
754
|
-
},
|
|
755
|
-
{
|
|
756
|
-
inputs: [
|
|
757
|
-
{
|
|
758
|
-
internalType: "address",
|
|
759
|
-
name: "",
|
|
760
|
-
type: "address"
|
|
761
|
-
},
|
|
762
|
-
{
|
|
763
|
-
internalType: "uint256",
|
|
764
|
-
name: "",
|
|
765
|
-
type: "uint256"
|
|
766
|
-
},
|
|
767
|
-
{
|
|
768
|
-
internalType: "address",
|
|
769
|
-
name: "",
|
|
770
|
-
type: "address"
|
|
771
|
-
}
|
|
772
|
-
],
|
|
773
|
-
name: "whitelist",
|
|
774
|
-
outputs: [
|
|
775
|
-
{
|
|
776
|
-
internalType: "bool",
|
|
777
|
-
name: "",
|
|
778
|
-
type: "bool"
|
|
779
|
-
}
|
|
780
|
-
],
|
|
781
|
-
stateMutability: "view",
|
|
782
|
-
type: "function"
|
|
783
|
-
}
|
|
784
|
-
];
|
|
511
|
+
var import_WhitelistPreIntentHook = __toESM(require("@zkp2p/contracts-v2/abis/base/WhitelistPreIntentHook.json"), 1);
|
|
785
512
|
|
|
786
513
|
// src/sdk-client.ts
|
|
787
514
|
var import_sdk3 = require("@zkp2p/sdk");
|
|
@@ -797,7 +524,7 @@ function createSdkClient(walletClient) {
|
|
|
797
524
|
|
|
798
525
|
// src/otc.ts
|
|
799
526
|
var WHITELIST_HOOK_ADDRESS = "0xda023Ea0d789A41BcF5866F7B6BBd2CaDF9b79B8";
|
|
800
|
-
var OTC_BASE_URL = "https://usdctofiat.xyz";
|
|
527
|
+
var OTC_BASE_URL = "https://otc.usdctofiat.xyz";
|
|
801
528
|
async function enableOtc(walletClient, depositId, takerAddress, escrowAddress) {
|
|
802
529
|
if (!(0, import_viem.isAddress)(takerAddress)) {
|
|
803
530
|
throw new OfframpError("Invalid taker address", "VALIDATION");
|
|
@@ -869,7 +596,7 @@ async function disableOtc(walletClient, depositId, escrowAddress) {
|
|
|
869
596
|
}
|
|
870
597
|
function getOtcLink(depositId, escrowAddress) {
|
|
871
598
|
const escrow = escrowAddress || ESCROW_ADDRESS;
|
|
872
|
-
return `${OTC_BASE_URL}/
|
|
599
|
+
return `${OTC_BASE_URL}/d/${escrow}/${depositId}`;
|
|
873
600
|
}
|
|
874
601
|
async function writeContract(walletClient, functionName, args) {
|
|
875
602
|
const wc = walletClient;
|
|
@@ -878,7 +605,7 @@ async function writeContract(walletClient, functionName, args) {
|
|
|
878
605
|
}
|
|
879
606
|
await wc.writeContract({
|
|
880
607
|
address: WHITELIST_HOOK_ADDRESS,
|
|
881
|
-
abi:
|
|
608
|
+
abi: import_WhitelistPreIntentHook.default,
|
|
882
609
|
functionName,
|
|
883
610
|
args
|
|
884
611
|
});
|
|
@@ -887,7 +614,7 @@ async function readIsWhitelisted(escrow, depositId, taker) {
|
|
|
887
614
|
const publicClient = (0, import_viem.createPublicClient)({ chain: import_chains.base, transport: (0, import_viem.http)(BASE_RPC_URL) });
|
|
888
615
|
return publicClient.readContract({
|
|
889
616
|
address: WHITELIST_HOOK_ADDRESS,
|
|
890
|
-
abi:
|
|
617
|
+
abi: import_WhitelistPreIntentHook.default,
|
|
891
618
|
functionName: "isWhitelisted",
|
|
892
619
|
args: [escrow, depositId, taker]
|
|
893
620
|
});
|
|
@@ -1241,6 +968,28 @@ async function registerPayeeDetails(processorName, payload) {
|
|
|
1241
968
|
clearTimeout(timeout);
|
|
1242
969
|
}
|
|
1243
970
|
}
|
|
971
|
+
async function validatePayeeDetails(processorName, offchainId) {
|
|
972
|
+
const controller = new AbortController();
|
|
973
|
+
const timeout = setTimeout(() => controller.abort(), PAYEE_REGISTRATION_TIMEOUT_MS);
|
|
974
|
+
try {
|
|
975
|
+
const res = await fetch(`${API_BASE_URL}/v2/makers/validate`, {
|
|
976
|
+
method: "POST",
|
|
977
|
+
headers: { "Content-Type": "application/json" },
|
|
978
|
+
body: JSON.stringify({ processorName, offchainId }),
|
|
979
|
+
signal: controller.signal
|
|
980
|
+
});
|
|
981
|
+
if (!res.ok) return "unknown";
|
|
982
|
+
const json = await res.json();
|
|
983
|
+
if (typeof json.responseObject === "boolean") {
|
|
984
|
+
return json.responseObject ? "valid" : "invalid";
|
|
985
|
+
}
|
|
986
|
+
return "unknown";
|
|
987
|
+
} catch {
|
|
988
|
+
return "unknown";
|
|
989
|
+
} finally {
|
|
990
|
+
clearTimeout(timeout);
|
|
991
|
+
}
|
|
992
|
+
}
|
|
1244
993
|
function attachOracleConfig(entries, conversionRates) {
|
|
1245
994
|
return entries.map(
|
|
1246
995
|
(group, gi) => group.map((entry, ci) => {
|
|
@@ -1412,6 +1161,17 @@ async function offramp(walletClient, params, onProgress, telemetryContext) {
|
|
|
1412
1161
|
} catch (err) {
|
|
1413
1162
|
if (err instanceof OfframpError) throw err;
|
|
1414
1163
|
}
|
|
1164
|
+
const canonicalName = platformId.startsWith("zelle") ? "zelle" : platformId;
|
|
1165
|
+
if (!getPeerExtensionRegistrationInfo(platformId)) {
|
|
1166
|
+
const outcome = await validatePayeeDetails(canonicalName, normalizedIdentifier);
|
|
1167
|
+
if (outcome === "invalid") {
|
|
1168
|
+
throw new OfframpError(
|
|
1169
|
+
`Couldn't verify that ${platform.name} ${platform.identifier.label.toLowerCase()}. Double-check it and try again.`,
|
|
1170
|
+
"VALIDATION",
|
|
1171
|
+
"registering"
|
|
1172
|
+
);
|
|
1173
|
+
}
|
|
1174
|
+
}
|
|
1415
1175
|
const client = createSdkClient(walletClient);
|
|
1416
1176
|
const txOverrides = { referrer: [REFERRER] };
|
|
1417
1177
|
emitProgress({ step: "approving" });
|
|
@@ -1436,7 +1196,6 @@ async function offramp(walletClient, params, onProgress, telemetryContext) {
|
|
|
1436
1196
|
}
|
|
1437
1197
|
emitProgress({ step: "registering" });
|
|
1438
1198
|
let hashedOnchainId;
|
|
1439
|
-
const canonicalName = platformId.startsWith("zelle") ? "zelle" : platformId;
|
|
1440
1199
|
try {
|
|
1441
1200
|
const payeePayload = buildDepositData(canonicalName, normalizedIdentifier);
|
|
1442
1201
|
hashedOnchainId = await registerPayeeDetails(canonicalName, payeePayload);
|
|
@@ -1820,6 +1579,7 @@ var import_sdk7 = require("@zkp2p/sdk");
|
|
|
1820
1579
|
OfframpError,
|
|
1821
1580
|
PEER_EXTENSION_CHROME_URL,
|
|
1822
1581
|
PLATFORMS,
|
|
1582
|
+
PLATFORM_LIMITS,
|
|
1823
1583
|
close,
|
|
1824
1584
|
createOfframp,
|
|
1825
1585
|
createPeerExtensionSdk,
|
|
@@ -1832,8 +1592,10 @@ var import_sdk7 = require("@zkp2p/sdk");
|
|
|
1832
1592
|
getOtcLink,
|
|
1833
1593
|
getPeerExtensionRegistrationInfo,
|
|
1834
1594
|
getPeerExtensionState,
|
|
1595
|
+
getPlatformLimits,
|
|
1835
1596
|
isPeerExtensionAvailable,
|
|
1836
1597
|
isPeerExtensionRegistrationError,
|
|
1598
|
+
isValidIBAN,
|
|
1837
1599
|
normalizePaypalMeUsername,
|
|
1838
1600
|
offramp,
|
|
1839
1601
|
openPeerExtensionInstallPage,
|