@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/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";
|
|
@@ -76,6 +89,7 @@ var GATING_SERVICE_ADDRESS = (0, import_sdk.getGatingServiceAddress)(
|
|
|
76
89
|
var DELEGATE_RATE_MANAGER_ID = "0x8666d6fb0f6797c56e95339fd7ca82fdd348b9db200e10a4c4aa0a0b879fc41c";
|
|
77
90
|
var RATE_MANAGER_REGISTRY_ADDRESS = "0xeed7db23e724ac4590d6db6f78fda6db203535f3";
|
|
78
91
|
var DELEGATE_MANAGER_FEE_BPS = 10;
|
|
92
|
+
var DEFAULT_INTENT_GUARDIAN_ADDRESS = "0xe29a5BD4D0CEbA6C125A0361E7D20ab4eA275C2f";
|
|
79
93
|
var REFERRER = "galleonlabs";
|
|
80
94
|
var MIN_DEPOSIT_USDC = 1;
|
|
81
95
|
var MIN_ORDER_USDC = 1;
|
|
@@ -155,7 +169,8 @@ var FALLBACK_CURRENCIES = {
|
|
|
155
169
|
zelle: ["USD"],
|
|
156
170
|
paypal: ["USD", "EUR", "GBP", "SGD", "NZD", "AUD", "CAD"],
|
|
157
171
|
monzo: ["GBP"],
|
|
158
|
-
n26: ["EUR"]
|
|
172
|
+
n26: ["EUR"],
|
|
173
|
+
luxon: ["USD", "EUR", "GBP"]
|
|
159
174
|
};
|
|
160
175
|
function gatherCatalogHashes(platform) {
|
|
161
176
|
if (platform === "zelle") {
|
|
@@ -179,13 +194,39 @@ function resolveSupportedCurrencies(platform) {
|
|
|
179
194
|
function normalizePaypalMeUsername(value) {
|
|
180
195
|
const trimmed = value.trim();
|
|
181
196
|
if (!trimmed) return "";
|
|
182
|
-
const withoutProtocol = trimmed.replace(/^https?:\/\//i, "")
|
|
183
|
-
|
|
184
|
-
const withoutDomain = withoutProtocol.replace(/^paypal\.me\//i, "");
|
|
185
|
-
const [pathWithoutQuery] = withoutDomain.split(/[?#]/, 1);
|
|
197
|
+
const withoutProtocol = trimmed.replace(/^https?:\/\//i, "");
|
|
198
|
+
const [pathWithoutQuery] = withoutProtocol.split(/[?#]/, 1);
|
|
186
199
|
const sanitizedPath = pathWithoutQuery.replace(/^\/+/, "");
|
|
187
|
-
const [
|
|
188
|
-
|
|
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;
|
|
189
230
|
}
|
|
190
231
|
var BLUEPRINTS = {
|
|
191
232
|
venmo: {
|
|
@@ -237,9 +278,9 @@ var BLUEPRINTS = {
|
|
|
237
278
|
transform: (v) => v.replace(/^@+/, "").trim(),
|
|
238
279
|
extensionRegistration: {
|
|
239
280
|
providerId: "wise",
|
|
240
|
-
requiredPrompt: "This Wisetag is not registered yet.
|
|
241
|
-
ctaLabel: "
|
|
242
|
-
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"
|
|
243
284
|
}
|
|
244
285
|
},
|
|
245
286
|
mercadopago: {
|
|
@@ -256,7 +297,11 @@ var BLUEPRINTS = {
|
|
|
256
297
|
identifierLabel: "Email",
|
|
257
298
|
placeholder: "email",
|
|
258
299
|
helperText: "Registered Zelle email",
|
|
259
|
-
|
|
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()
|
|
260
305
|
},
|
|
261
306
|
paypal: {
|
|
262
307
|
id: "paypal",
|
|
@@ -264,14 +309,17 @@ var BLUEPRINTS = {
|
|
|
264
309
|
identifierLabel: "PayPal.me Username",
|
|
265
310
|
placeholder: "paypal.me/your-username",
|
|
266
311
|
helperText: "Your PayPal.me username, not your email",
|
|
267
|
-
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
|
+
),
|
|
268
316
|
transform: normalizePaypalMeUsername,
|
|
269
317
|
extensionRegistration: {
|
|
270
318
|
providerId: "paypal",
|
|
271
|
-
requiredPrompt: "This PayPal username is not registered yet.
|
|
272
|
-
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",
|
|
273
321
|
ctaSubtext: "PayPal Business accounts are not supported at this time.",
|
|
274
|
-
minExtensionVersion: "0.
|
|
322
|
+
minExtensionVersion: "0.5.0"
|
|
275
323
|
}
|
|
276
324
|
},
|
|
277
325
|
monzo: {
|
|
@@ -288,8 +336,20 @@ var BLUEPRINTS = {
|
|
|
288
336
|
identifierLabel: "IBAN",
|
|
289
337
|
placeholder: "IBAN (e.g. DE89...)",
|
|
290
338
|
helperText: "Your IBAN (spaces will be removed)",
|
|
291
|
-
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"),
|
|
292
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()
|
|
293
353
|
}
|
|
294
354
|
};
|
|
295
355
|
function buildPlatformEntry(bp) {
|
|
@@ -328,8 +388,18 @@ var PLATFORMS = {
|
|
|
328
388
|
ZELLE: buildPlatformEntry(BLUEPRINTS.zelle),
|
|
329
389
|
PAYPAL: buildPlatformEntry(BLUEPRINTS.paypal),
|
|
330
390
|
MONZO: buildPlatformEntry(BLUEPRINTS.monzo),
|
|
331
|
-
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" }
|
|
332
398
|
};
|
|
399
|
+
function getPlatformLimits(platform) {
|
|
400
|
+
const id = platform.trim().toLowerCase();
|
|
401
|
+
return PLATFORM_LIMITS[id] ?? null;
|
|
402
|
+
}
|
|
333
403
|
function getPlatformById(id) {
|
|
334
404
|
return Object.values(PLATFORMS).find((p) => p.id === id) ?? null;
|
|
335
405
|
}
|
|
@@ -438,349 +508,7 @@ function isUserCancellation(error) {
|
|
|
438
508
|
// src/otc.ts
|
|
439
509
|
var import_viem = require("viem");
|
|
440
510
|
var import_chains = require("viem/chains");
|
|
441
|
-
|
|
442
|
-
// ../../node_modules/@zkp2p/contracts-v2/abis/base/WhitelistPreIntentHook.json
|
|
443
|
-
var WhitelistPreIntentHook_default = [
|
|
444
|
-
{
|
|
445
|
-
inputs: [
|
|
446
|
-
{
|
|
447
|
-
internalType: "address",
|
|
448
|
-
name: "_orchestratorRegistry",
|
|
449
|
-
type: "address"
|
|
450
|
-
}
|
|
451
|
-
],
|
|
452
|
-
stateMutability: "nonpayable",
|
|
453
|
-
type: "constructor"
|
|
454
|
-
},
|
|
455
|
-
{
|
|
456
|
-
inputs: [],
|
|
457
|
-
name: "EmptyArray",
|
|
458
|
-
type: "error"
|
|
459
|
-
},
|
|
460
|
-
{
|
|
461
|
-
inputs: [
|
|
462
|
-
{
|
|
463
|
-
internalType: "address",
|
|
464
|
-
name: "taker",
|
|
465
|
-
type: "address"
|
|
466
|
-
},
|
|
467
|
-
{
|
|
468
|
-
internalType: "address",
|
|
469
|
-
name: "escrow",
|
|
470
|
-
type: "address"
|
|
471
|
-
},
|
|
472
|
-
{
|
|
473
|
-
internalType: "uint256",
|
|
474
|
-
name: "depositId",
|
|
475
|
-
type: "uint256"
|
|
476
|
-
}
|
|
477
|
-
],
|
|
478
|
-
name: "TakerNotInWhitelist",
|
|
479
|
-
type: "error"
|
|
480
|
-
},
|
|
481
|
-
{
|
|
482
|
-
inputs: [
|
|
483
|
-
{
|
|
484
|
-
internalType: "address",
|
|
485
|
-
name: "taker",
|
|
486
|
-
type: "address"
|
|
487
|
-
},
|
|
488
|
-
{
|
|
489
|
-
internalType: "address",
|
|
490
|
-
name: "escrow",
|
|
491
|
-
type: "address"
|
|
492
|
-
},
|
|
493
|
-
{
|
|
494
|
-
internalType: "uint256",
|
|
495
|
-
name: "depositId",
|
|
496
|
-
type: "uint256"
|
|
497
|
-
}
|
|
498
|
-
],
|
|
499
|
-
name: "TakerNotWhitelisted",
|
|
500
|
-
type: "error"
|
|
501
|
-
},
|
|
502
|
-
{
|
|
503
|
-
inputs: [
|
|
504
|
-
{
|
|
505
|
-
internalType: "address",
|
|
506
|
-
name: "caller",
|
|
507
|
-
type: "address"
|
|
508
|
-
},
|
|
509
|
-
{
|
|
510
|
-
internalType: "address",
|
|
511
|
-
name: "owner",
|
|
512
|
-
type: "address"
|
|
513
|
-
},
|
|
514
|
-
{
|
|
515
|
-
internalType: "address",
|
|
516
|
-
name: "delegate",
|
|
517
|
-
type: "address"
|
|
518
|
-
}
|
|
519
|
-
],
|
|
520
|
-
name: "UnauthorizedCallerOrDelegate",
|
|
521
|
-
type: "error"
|
|
522
|
-
},
|
|
523
|
-
{
|
|
524
|
-
inputs: [
|
|
525
|
-
{
|
|
526
|
-
internalType: "address",
|
|
527
|
-
name: "caller",
|
|
528
|
-
type: "address"
|
|
529
|
-
}
|
|
530
|
-
],
|
|
531
|
-
name: "UnauthorizedOrchestratorCaller",
|
|
532
|
-
type: "error"
|
|
533
|
-
},
|
|
534
|
-
{
|
|
535
|
-
inputs: [],
|
|
536
|
-
name: "ZeroAddress",
|
|
537
|
-
type: "error"
|
|
538
|
-
},
|
|
539
|
-
{
|
|
540
|
-
anonymous: false,
|
|
541
|
-
inputs: [
|
|
542
|
-
{
|
|
543
|
-
indexed: true,
|
|
544
|
-
internalType: "address",
|
|
545
|
-
name: "escrow",
|
|
546
|
-
type: "address"
|
|
547
|
-
},
|
|
548
|
-
{
|
|
549
|
-
indexed: true,
|
|
550
|
-
internalType: "uint256",
|
|
551
|
-
name: "depositId",
|
|
552
|
-
type: "uint256"
|
|
553
|
-
},
|
|
554
|
-
{
|
|
555
|
-
indexed: true,
|
|
556
|
-
internalType: "address",
|
|
557
|
-
name: "taker",
|
|
558
|
-
type: "address"
|
|
559
|
-
}
|
|
560
|
-
],
|
|
561
|
-
name: "TakerRemovedFromWhitelist",
|
|
562
|
-
type: "event"
|
|
563
|
-
},
|
|
564
|
-
{
|
|
565
|
-
anonymous: false,
|
|
566
|
-
inputs: [
|
|
567
|
-
{
|
|
568
|
-
indexed: true,
|
|
569
|
-
internalType: "address",
|
|
570
|
-
name: "escrow",
|
|
571
|
-
type: "address"
|
|
572
|
-
},
|
|
573
|
-
{
|
|
574
|
-
indexed: true,
|
|
575
|
-
internalType: "uint256",
|
|
576
|
-
name: "depositId",
|
|
577
|
-
type: "uint256"
|
|
578
|
-
},
|
|
579
|
-
{
|
|
580
|
-
indexed: true,
|
|
581
|
-
internalType: "address",
|
|
582
|
-
name: "taker",
|
|
583
|
-
type: "address"
|
|
584
|
-
}
|
|
585
|
-
],
|
|
586
|
-
name: "TakerWhitelisted",
|
|
587
|
-
type: "event"
|
|
588
|
-
},
|
|
589
|
-
{
|
|
590
|
-
inputs: [
|
|
591
|
-
{
|
|
592
|
-
internalType: "address",
|
|
593
|
-
name: "_escrow",
|
|
594
|
-
type: "address"
|
|
595
|
-
},
|
|
596
|
-
{
|
|
597
|
-
internalType: "uint256",
|
|
598
|
-
name: "_depositId",
|
|
599
|
-
type: "uint256"
|
|
600
|
-
},
|
|
601
|
-
{
|
|
602
|
-
internalType: "address[]",
|
|
603
|
-
name: "_takers",
|
|
604
|
-
type: "address[]"
|
|
605
|
-
}
|
|
606
|
-
],
|
|
607
|
-
name: "addToWhitelist",
|
|
608
|
-
outputs: [],
|
|
609
|
-
stateMutability: "nonpayable",
|
|
610
|
-
type: "function"
|
|
611
|
-
},
|
|
612
|
-
{
|
|
613
|
-
inputs: [
|
|
614
|
-
{
|
|
615
|
-
internalType: "address",
|
|
616
|
-
name: "_escrow",
|
|
617
|
-
type: "address"
|
|
618
|
-
},
|
|
619
|
-
{
|
|
620
|
-
internalType: "uint256",
|
|
621
|
-
name: "_depositId",
|
|
622
|
-
type: "uint256"
|
|
623
|
-
},
|
|
624
|
-
{
|
|
625
|
-
internalType: "address",
|
|
626
|
-
name: "_taker",
|
|
627
|
-
type: "address"
|
|
628
|
-
}
|
|
629
|
-
],
|
|
630
|
-
name: "isWhitelisted",
|
|
631
|
-
outputs: [
|
|
632
|
-
{
|
|
633
|
-
internalType: "bool",
|
|
634
|
-
name: "",
|
|
635
|
-
type: "bool"
|
|
636
|
-
}
|
|
637
|
-
],
|
|
638
|
-
stateMutability: "view",
|
|
639
|
-
type: "function"
|
|
640
|
-
},
|
|
641
|
-
{
|
|
642
|
-
inputs: [],
|
|
643
|
-
name: "orchestratorRegistry",
|
|
644
|
-
outputs: [
|
|
645
|
-
{
|
|
646
|
-
internalType: "contract IOrchestratorRegistry",
|
|
647
|
-
name: "",
|
|
648
|
-
type: "address"
|
|
649
|
-
}
|
|
650
|
-
],
|
|
651
|
-
stateMutability: "view",
|
|
652
|
-
type: "function"
|
|
653
|
-
},
|
|
654
|
-
{
|
|
655
|
-
inputs: [
|
|
656
|
-
{
|
|
657
|
-
internalType: "address",
|
|
658
|
-
name: "_escrow",
|
|
659
|
-
type: "address"
|
|
660
|
-
},
|
|
661
|
-
{
|
|
662
|
-
internalType: "uint256",
|
|
663
|
-
name: "_depositId",
|
|
664
|
-
type: "uint256"
|
|
665
|
-
},
|
|
666
|
-
{
|
|
667
|
-
internalType: "address[]",
|
|
668
|
-
name: "_takers",
|
|
669
|
-
type: "address[]"
|
|
670
|
-
}
|
|
671
|
-
],
|
|
672
|
-
name: "removeFromWhitelist",
|
|
673
|
-
outputs: [],
|
|
674
|
-
stateMutability: "nonpayable",
|
|
675
|
-
type: "function"
|
|
676
|
-
},
|
|
677
|
-
{
|
|
678
|
-
inputs: [
|
|
679
|
-
{
|
|
680
|
-
components: [
|
|
681
|
-
{
|
|
682
|
-
internalType: "address",
|
|
683
|
-
name: "taker",
|
|
684
|
-
type: "address"
|
|
685
|
-
},
|
|
686
|
-
{
|
|
687
|
-
internalType: "address",
|
|
688
|
-
name: "escrow",
|
|
689
|
-
type: "address"
|
|
690
|
-
},
|
|
691
|
-
{
|
|
692
|
-
internalType: "uint256",
|
|
693
|
-
name: "depositId",
|
|
694
|
-
type: "uint256"
|
|
695
|
-
},
|
|
696
|
-
{
|
|
697
|
-
internalType: "uint256",
|
|
698
|
-
name: "amount",
|
|
699
|
-
type: "uint256"
|
|
700
|
-
},
|
|
701
|
-
{
|
|
702
|
-
internalType: "address",
|
|
703
|
-
name: "to",
|
|
704
|
-
type: "address"
|
|
705
|
-
},
|
|
706
|
-
{
|
|
707
|
-
internalType: "bytes32",
|
|
708
|
-
name: "paymentMethod",
|
|
709
|
-
type: "bytes32"
|
|
710
|
-
},
|
|
711
|
-
{
|
|
712
|
-
internalType: "bytes32",
|
|
713
|
-
name: "fiatCurrency",
|
|
714
|
-
type: "bytes32"
|
|
715
|
-
},
|
|
716
|
-
{
|
|
717
|
-
internalType: "uint256",
|
|
718
|
-
name: "conversionRate",
|
|
719
|
-
type: "uint256"
|
|
720
|
-
},
|
|
721
|
-
{
|
|
722
|
-
components: [
|
|
723
|
-
{
|
|
724
|
-
internalType: "address",
|
|
725
|
-
name: "recipient",
|
|
726
|
-
type: "address"
|
|
727
|
-
},
|
|
728
|
-
{
|
|
729
|
-
internalType: "uint256",
|
|
730
|
-
name: "fee",
|
|
731
|
-
type: "uint256"
|
|
732
|
-
}
|
|
733
|
-
],
|
|
734
|
-
internalType: "struct IReferralFee.ReferralFee[]",
|
|
735
|
-
name: "referralFees",
|
|
736
|
-
type: "tuple[]"
|
|
737
|
-
},
|
|
738
|
-
{
|
|
739
|
-
internalType: "bytes",
|
|
740
|
-
name: "preIntentHookData",
|
|
741
|
-
type: "bytes"
|
|
742
|
-
}
|
|
743
|
-
],
|
|
744
|
-
internalType: "struct IPreIntentHook.PreIntentContext",
|
|
745
|
-
name: "_ctx",
|
|
746
|
-
type: "tuple"
|
|
747
|
-
}
|
|
748
|
-
],
|
|
749
|
-
name: "validateSignalIntent",
|
|
750
|
-
outputs: [],
|
|
751
|
-
stateMutability: "view",
|
|
752
|
-
type: "function"
|
|
753
|
-
},
|
|
754
|
-
{
|
|
755
|
-
inputs: [
|
|
756
|
-
{
|
|
757
|
-
internalType: "address",
|
|
758
|
-
name: "",
|
|
759
|
-
type: "address"
|
|
760
|
-
},
|
|
761
|
-
{
|
|
762
|
-
internalType: "uint256",
|
|
763
|
-
name: "",
|
|
764
|
-
type: "uint256"
|
|
765
|
-
},
|
|
766
|
-
{
|
|
767
|
-
internalType: "address",
|
|
768
|
-
name: "",
|
|
769
|
-
type: "address"
|
|
770
|
-
}
|
|
771
|
-
],
|
|
772
|
-
name: "whitelist",
|
|
773
|
-
outputs: [
|
|
774
|
-
{
|
|
775
|
-
internalType: "bool",
|
|
776
|
-
name: "",
|
|
777
|
-
type: "bool"
|
|
778
|
-
}
|
|
779
|
-
],
|
|
780
|
-
stateMutability: "view",
|
|
781
|
-
type: "function"
|
|
782
|
-
}
|
|
783
|
-
];
|
|
511
|
+
var import_WhitelistPreIntentHook = __toESM(require("@zkp2p/contracts-v2/abis/base/WhitelistPreIntentHook.json"), 1);
|
|
784
512
|
|
|
785
513
|
// src/sdk-client.ts
|
|
786
514
|
var import_sdk3 = require("@zkp2p/sdk");
|
|
@@ -796,7 +524,7 @@ function createSdkClient(walletClient) {
|
|
|
796
524
|
|
|
797
525
|
// src/otc.ts
|
|
798
526
|
var WHITELIST_HOOK_ADDRESS = "0xda023Ea0d789A41BcF5866F7B6BBd2CaDF9b79B8";
|
|
799
|
-
var OTC_BASE_URL = "https://usdctofiat.xyz";
|
|
527
|
+
var OTC_BASE_URL = "https://otc.usdctofiat.xyz";
|
|
800
528
|
async function enableOtc(walletClient, depositId, takerAddress, escrowAddress) {
|
|
801
529
|
if (!(0, import_viem.isAddress)(takerAddress)) {
|
|
802
530
|
throw new OfframpError("Invalid taker address", "VALIDATION");
|
|
@@ -868,7 +596,7 @@ async function disableOtc(walletClient, depositId, escrowAddress) {
|
|
|
868
596
|
}
|
|
869
597
|
function getOtcLink(depositId, escrowAddress) {
|
|
870
598
|
const escrow = escrowAddress || ESCROW_ADDRESS;
|
|
871
|
-
return `${OTC_BASE_URL}/
|
|
599
|
+
return `${OTC_BASE_URL}/d/${escrow}/${depositId}`;
|
|
872
600
|
}
|
|
873
601
|
async function writeContract(walletClient, functionName, args) {
|
|
874
602
|
const wc = walletClient;
|
|
@@ -877,7 +605,7 @@ async function writeContract(walletClient, functionName, args) {
|
|
|
877
605
|
}
|
|
878
606
|
await wc.writeContract({
|
|
879
607
|
address: WHITELIST_HOOK_ADDRESS,
|
|
880
|
-
abi:
|
|
608
|
+
abi: import_WhitelistPreIntentHook.default,
|
|
881
609
|
functionName,
|
|
882
610
|
args
|
|
883
611
|
});
|
|
@@ -886,7 +614,7 @@ async function readIsWhitelisted(escrow, depositId, taker) {
|
|
|
886
614
|
const publicClient = (0, import_viem.createPublicClient)({ chain: import_chains.base, transport: (0, import_viem.http)(BASE_RPC_URL) });
|
|
887
615
|
return publicClient.readContract({
|
|
888
616
|
address: WHITELIST_HOOK_ADDRESS,
|
|
889
|
-
abi:
|
|
617
|
+
abi: import_WhitelistPreIntentHook.default,
|
|
890
618
|
functionName: "isWhitelisted",
|
|
891
619
|
args: [escrow, depositId, taker]
|
|
892
620
|
});
|
|
@@ -1240,6 +968,28 @@ async function registerPayeeDetails(processorName, payload) {
|
|
|
1240
968
|
clearTimeout(timeout);
|
|
1241
969
|
}
|
|
1242
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
|
+
}
|
|
1243
993
|
function attachOracleConfig(entries, conversionRates) {
|
|
1244
994
|
return entries.map(
|
|
1245
995
|
(group, gi) => group.map((entry, ci) => {
|
|
@@ -1411,6 +1161,17 @@ async function offramp(walletClient, params, onProgress, telemetryContext) {
|
|
|
1411
1161
|
} catch (err) {
|
|
1412
1162
|
if (err instanceof OfframpError) throw err;
|
|
1413
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
|
+
}
|
|
1414
1175
|
const client = createSdkClient(walletClient);
|
|
1415
1176
|
const txOverrides = { referrer: [REFERRER] };
|
|
1416
1177
|
emitProgress({ step: "approving" });
|
|
@@ -1435,7 +1196,6 @@ async function offramp(walletClient, params, onProgress, telemetryContext) {
|
|
|
1435
1196
|
}
|
|
1436
1197
|
emitProgress({ step: "registering" });
|
|
1437
1198
|
let hashedOnchainId;
|
|
1438
|
-
const canonicalName = platformId.startsWith("zelle") ? "zelle" : platformId;
|
|
1439
1199
|
try {
|
|
1440
1200
|
const payeePayload = buildDepositData(canonicalName, normalizedIdentifier);
|
|
1441
1201
|
hashedOnchainId = await registerPayeeDetails(canonicalName, payeePayload);
|
|
@@ -1485,6 +1245,7 @@ async function offramp(walletClient, params, onProgress, telemetryContext) {
|
|
|
1485
1245
|
data: "0x"
|
|
1486
1246
|
})),
|
|
1487
1247
|
currenciesOverride,
|
|
1248
|
+
intentGuardian: DEFAULT_INTENT_GUARDIAN_ADDRESS,
|
|
1488
1249
|
escrowAddress: ESCROW_ADDRESS,
|
|
1489
1250
|
txOverrides
|
|
1490
1251
|
});
|
|
@@ -1818,6 +1579,7 @@ var import_sdk7 = require("@zkp2p/sdk");
|
|
|
1818
1579
|
OfframpError,
|
|
1819
1580
|
PEER_EXTENSION_CHROME_URL,
|
|
1820
1581
|
PLATFORMS,
|
|
1582
|
+
PLATFORM_LIMITS,
|
|
1821
1583
|
close,
|
|
1822
1584
|
createOfframp,
|
|
1823
1585
|
createPeerExtensionSdk,
|
|
@@ -1830,8 +1592,10 @@ var import_sdk7 = require("@zkp2p/sdk");
|
|
|
1830
1592
|
getOtcLink,
|
|
1831
1593
|
getPeerExtensionRegistrationInfo,
|
|
1832
1594
|
getPeerExtensionState,
|
|
1595
|
+
getPlatformLimits,
|
|
1833
1596
|
isPeerExtensionAvailable,
|
|
1834
1597
|
isPeerExtensionRegistrationError,
|
|
1598
|
+
isValidIBAN,
|
|
1835
1599
|
normalizePaypalMeUsername,
|
|
1836
1600
|
offramp,
|
|
1837
1601
|
openPeerExtensionInstallPage,
|