@unifold/connect-react 0.1.6 → 0.1.7

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/dist/index.mjs CHANGED
@@ -1222,6 +1222,145 @@ function useUnifold() {
1222
1222
 
1223
1223
  // ../ui-react/dist/index.mjs
1224
1224
  import { useState as useState52, useEffect as useEffect52 } from "react";
1225
+
1226
+ // ../../node_modules/.pnpm/lucide-react@0.294.0_react@18.3.1/node_modules/lucide-react/dist/esm/createLucideIcon.js
1227
+ import { forwardRef, createElement } from "react";
1228
+
1229
+ // ../../node_modules/.pnpm/lucide-react@0.294.0_react@18.3.1/node_modules/lucide-react/dist/esm/defaultAttributes.js
1230
+ var defaultAttributes = {
1231
+ xmlns: "http://www.w3.org/2000/svg",
1232
+ width: 24,
1233
+ height: 24,
1234
+ viewBox: "0 0 24 24",
1235
+ fill: "none",
1236
+ stroke: "currentColor",
1237
+ strokeWidth: 2,
1238
+ strokeLinecap: "round",
1239
+ strokeLinejoin: "round"
1240
+ };
1241
+
1242
+ // ../../node_modules/.pnpm/lucide-react@0.294.0_react@18.3.1/node_modules/lucide-react/dist/esm/createLucideIcon.js
1243
+ var toKebabCase = (string) => string.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase().trim();
1244
+ var createLucideIcon = (iconName, iconNode) => {
1245
+ const Component = forwardRef(
1246
+ ({ color = "currentColor", size: size4 = 24, strokeWidth = 2, absoluteStrokeWidth, className = "", children, ...rest }, ref) => createElement(
1247
+ "svg",
1248
+ {
1249
+ ref,
1250
+ ...defaultAttributes,
1251
+ width: size4,
1252
+ height: size4,
1253
+ stroke: color,
1254
+ strokeWidth: absoluteStrokeWidth ? Number(strokeWidth) * 24 / Number(size4) : strokeWidth,
1255
+ className: ["lucide", `lucide-${toKebabCase(iconName)}`, className].join(" "),
1256
+ ...rest
1257
+ },
1258
+ [
1259
+ ...iconNode.map(([tag, attrs]) => createElement(tag, attrs)),
1260
+ ...Array.isArray(children) ? children : [children]
1261
+ ]
1262
+ )
1263
+ );
1264
+ Component.displayName = `${iconName}`;
1265
+ return Component;
1266
+ };
1267
+
1268
+ // ../../node_modules/.pnpm/lucide-react@0.294.0_react@18.3.1/node_modules/lucide-react/dist/esm/icons/arrow-left.js
1269
+ var ArrowLeft = createLucideIcon("ArrowLeft", [
1270
+ ["path", { d: "m12 19-7-7 7-7", key: "1l729n" }],
1271
+ ["path", { d: "M19 12H5", key: "x3x0zl" }]
1272
+ ]);
1273
+
1274
+ // ../../node_modules/.pnpm/lucide-react@0.294.0_react@18.3.1/node_modules/lucide-react/dist/esm/icons/check.js
1275
+ var Check = createLucideIcon("Check", [["path", { d: "M20 6 9 17l-5-5", key: "1gmf2c" }]]);
1276
+
1277
+ // ../../node_modules/.pnpm/lucide-react@0.294.0_react@18.3.1/node_modules/lucide-react/dist/esm/icons/chevron-down.js
1278
+ var ChevronDown = createLucideIcon("ChevronDown", [
1279
+ ["path", { d: "m6 9 6 6 6-6", key: "qrunsl" }]
1280
+ ]);
1281
+
1282
+ // ../../node_modules/.pnpm/lucide-react@0.294.0_react@18.3.1/node_modules/lucide-react/dist/esm/icons/chevron-right.js
1283
+ var ChevronRight = createLucideIcon("ChevronRight", [
1284
+ ["path", { d: "m9 18 6-6-6-6", key: "mthhwq" }]
1285
+ ]);
1286
+
1287
+ // ../../node_modules/.pnpm/lucide-react@0.294.0_react@18.3.1/node_modules/lucide-react/dist/esm/icons/chevron-up.js
1288
+ var ChevronUp = createLucideIcon("ChevronUp", [["path", { d: "m18 15-6-6-6 6", key: "153udz" }]]);
1289
+
1290
+ // ../../node_modules/.pnpm/lucide-react@0.294.0_react@18.3.1/node_modules/lucide-react/dist/esm/icons/clock.js
1291
+ var Clock = createLucideIcon("Clock", [
1292
+ ["circle", { cx: "12", cy: "12", r: "10", key: "1mglay" }],
1293
+ ["polyline", { points: "12 6 12 12 16 14", key: "68esgv" }]
1294
+ ]);
1295
+
1296
+ // ../../node_modules/.pnpm/lucide-react@0.294.0_react@18.3.1/node_modules/lucide-react/dist/esm/icons/copy.js
1297
+ var Copy = createLucideIcon("Copy", [
1298
+ ["rect", { width: "14", height: "14", x: "8", y: "8", rx: "2", ry: "2", key: "17jyea" }],
1299
+ ["path", { d: "M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2", key: "zix9uf" }]
1300
+ ]);
1301
+
1302
+ // ../../node_modules/.pnpm/lucide-react@0.294.0_react@18.3.1/node_modules/lucide-react/dist/esm/icons/credit-card.js
1303
+ var CreditCard = createLucideIcon("CreditCard", [
1304
+ ["rect", { width: "20", height: "14", x: "2", y: "5", rx: "2", key: "ynyp8z" }],
1305
+ ["line", { x1: "2", x2: "22", y1: "10", y2: "10", key: "1b3vmo" }]
1306
+ ]);
1307
+
1308
+ // ../../node_modules/.pnpm/lucide-react@0.294.0_react@18.3.1/node_modules/lucide-react/dist/esm/icons/dollar-sign.js
1309
+ var DollarSign = createLucideIcon("DollarSign", [
1310
+ ["line", { x1: "12", x2: "12", y1: "2", y2: "22", key: "7eqyqh" }],
1311
+ ["path", { d: "M17 5H9.5a3.5 3.5 0 0 0 0 7h5a3.5 3.5 0 0 1 0 7H6", key: "1b0p4s" }]
1312
+ ]);
1313
+
1314
+ // ../../node_modules/.pnpm/lucide-react@0.294.0_react@18.3.1/node_modules/lucide-react/dist/esm/icons/external-link.js
1315
+ var ExternalLink = createLucideIcon("ExternalLink", [
1316
+ ["path", { d: "M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6", key: "a6xqqp" }],
1317
+ ["polyline", { points: "15 3 21 3 21 9", key: "mznyad" }],
1318
+ ["line", { x1: "10", x2: "21", y1: "14", y2: "3", key: "18c3s4" }]
1319
+ ]);
1320
+
1321
+ // ../../node_modules/.pnpm/lucide-react@0.294.0_react@18.3.1/node_modules/lucide-react/dist/esm/icons/file-text.js
1322
+ var FileText = createLucideIcon("FileText", [
1323
+ [
1324
+ "path",
1325
+ { d: "M14.5 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7.5L14.5 2z", key: "1nnpy2" }
1326
+ ],
1327
+ ["polyline", { points: "14 2 14 8 20 8", key: "1ew0cm" }],
1328
+ ["line", { x1: "16", x2: "8", y1: "13", y2: "13", key: "14keom" }],
1329
+ ["line", { x1: "16", x2: "8", y1: "17", y2: "17", key: "17nazh" }],
1330
+ ["line", { x1: "10", x2: "8", y1: "9", y2: "9", key: "1a5vjj" }]
1331
+ ]);
1332
+
1333
+ // ../../node_modules/.pnpm/lucide-react@0.294.0_react@18.3.1/node_modules/lucide-react/dist/esm/icons/info.js
1334
+ var Info = createLucideIcon("Info", [
1335
+ ["circle", { cx: "12", cy: "12", r: "10", key: "1mglay" }],
1336
+ ["path", { d: "M12 16v-4", key: "1dtifu" }],
1337
+ ["path", { d: "M12 8h.01", key: "e9boi3" }]
1338
+ ]);
1339
+
1340
+ // ../../node_modules/.pnpm/lucide-react@0.294.0_react@18.3.1/node_modules/lucide-react/dist/esm/icons/search.js
1341
+ var Search = createLucideIcon("Search", [
1342
+ ["circle", { cx: "11", cy: "11", r: "8", key: "4ej97u" }],
1343
+ ["path", { d: "m21 21-4.3-4.3", key: "1qie3q" }]
1344
+ ]);
1345
+
1346
+ // ../../node_modules/.pnpm/lucide-react@0.294.0_react@18.3.1/node_modules/lucide-react/dist/esm/icons/shield-check.js
1347
+ var ShieldCheck = createLucideIcon("ShieldCheck", [
1348
+ ["path", { d: "M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10", key: "1irkt0" }],
1349
+ ["path", { d: "m9 12 2 2 4-4", key: "dzmm74" }]
1350
+ ]);
1351
+
1352
+ // ../../node_modules/.pnpm/lucide-react@0.294.0_react@18.3.1/node_modules/lucide-react/dist/esm/icons/x.js
1353
+ var X = createLucideIcon("X", [
1354
+ ["path", { d: "M18 6 6 18", key: "1bl5f8" }],
1355
+ ["path", { d: "m6 6 12 12", key: "d8bk6v" }]
1356
+ ]);
1357
+
1358
+ // ../../node_modules/.pnpm/lucide-react@0.294.0_react@18.3.1/node_modules/lucide-react/dist/esm/icons/zap.js
1359
+ var Zap = createLucideIcon("Zap", [
1360
+ ["polygon", { points: "13 2 3 14 12 14 11 22 21 10 12 10 13 2", key: "45s27k" }]
1361
+ ]);
1362
+
1363
+ // ../ui-react/dist/index.mjs
1225
1364
  import * as React210 from "react";
1226
1365
 
1227
1366
  // ../../node_modules/.pnpm/@radix-ui+react-dialog@1.1.15_@types+react-dom@18.3.7_@types+react@18.3.27__@types+react@18.3_bwdzsrsjkenptt5ry5km67dkui/node_modules/@radix-ui/react-dialog/dist/index.mjs
@@ -3326,143 +3465,6 @@ var Title = DialogTitle;
3326
3465
  var Description = DialogDescription;
3327
3466
  var Close = DialogClose;
3328
3467
 
3329
- // ../../node_modules/.pnpm/lucide-react@0.294.0_react@18.3.1/node_modules/lucide-react/dist/esm/createLucideIcon.js
3330
- import { forwardRef as forwardRef9, createElement as createElement6 } from "react";
3331
-
3332
- // ../../node_modules/.pnpm/lucide-react@0.294.0_react@18.3.1/node_modules/lucide-react/dist/esm/defaultAttributes.js
3333
- var defaultAttributes = {
3334
- xmlns: "http://www.w3.org/2000/svg",
3335
- width: 24,
3336
- height: 24,
3337
- viewBox: "0 0 24 24",
3338
- fill: "none",
3339
- stroke: "currentColor",
3340
- strokeWidth: 2,
3341
- strokeLinecap: "round",
3342
- strokeLinejoin: "round"
3343
- };
3344
-
3345
- // ../../node_modules/.pnpm/lucide-react@0.294.0_react@18.3.1/node_modules/lucide-react/dist/esm/createLucideIcon.js
3346
- var toKebabCase = (string) => string.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase().trim();
3347
- var createLucideIcon = (iconName, iconNode) => {
3348
- const Component = forwardRef9(
3349
- ({ color = "currentColor", size: size4 = 24, strokeWidth = 2, absoluteStrokeWidth, className = "", children, ...rest }, ref) => createElement6(
3350
- "svg",
3351
- {
3352
- ref,
3353
- ...defaultAttributes,
3354
- width: size4,
3355
- height: size4,
3356
- stroke: color,
3357
- strokeWidth: absoluteStrokeWidth ? Number(strokeWidth) * 24 / Number(size4) : strokeWidth,
3358
- className: ["lucide", `lucide-${toKebabCase(iconName)}`, className].join(" "),
3359
- ...rest
3360
- },
3361
- [
3362
- ...iconNode.map(([tag, attrs]) => createElement6(tag, attrs)),
3363
- ...Array.isArray(children) ? children : [children]
3364
- ]
3365
- )
3366
- );
3367
- Component.displayName = `${iconName}`;
3368
- return Component;
3369
- };
3370
-
3371
- // ../../node_modules/.pnpm/lucide-react@0.294.0_react@18.3.1/node_modules/lucide-react/dist/esm/icons/arrow-left.js
3372
- var ArrowLeft = createLucideIcon("ArrowLeft", [
3373
- ["path", { d: "m12 19-7-7 7-7", key: "1l729n" }],
3374
- ["path", { d: "M19 12H5", key: "x3x0zl" }]
3375
- ]);
3376
-
3377
- // ../../node_modules/.pnpm/lucide-react@0.294.0_react@18.3.1/node_modules/lucide-react/dist/esm/icons/check.js
3378
- var Check = createLucideIcon("Check", [["path", { d: "M20 6 9 17l-5-5", key: "1gmf2c" }]]);
3379
-
3380
- // ../../node_modules/.pnpm/lucide-react@0.294.0_react@18.3.1/node_modules/lucide-react/dist/esm/icons/chevron-down.js
3381
- var ChevronDown = createLucideIcon("ChevronDown", [
3382
- ["path", { d: "m6 9 6 6 6-6", key: "qrunsl" }]
3383
- ]);
3384
-
3385
- // ../../node_modules/.pnpm/lucide-react@0.294.0_react@18.3.1/node_modules/lucide-react/dist/esm/icons/chevron-right.js
3386
- var ChevronRight = createLucideIcon("ChevronRight", [
3387
- ["path", { d: "m9 18 6-6-6-6", key: "mthhwq" }]
3388
- ]);
3389
-
3390
- // ../../node_modules/.pnpm/lucide-react@0.294.0_react@18.3.1/node_modules/lucide-react/dist/esm/icons/chevron-up.js
3391
- var ChevronUp = createLucideIcon("ChevronUp", [["path", { d: "m18 15-6-6-6 6", key: "153udz" }]]);
3392
-
3393
- // ../../node_modules/.pnpm/lucide-react@0.294.0_react@18.3.1/node_modules/lucide-react/dist/esm/icons/clock.js
3394
- var Clock = createLucideIcon("Clock", [
3395
- ["circle", { cx: "12", cy: "12", r: "10", key: "1mglay" }],
3396
- ["polyline", { points: "12 6 12 12 16 14", key: "68esgv" }]
3397
- ]);
3398
-
3399
- // ../../node_modules/.pnpm/lucide-react@0.294.0_react@18.3.1/node_modules/lucide-react/dist/esm/icons/copy.js
3400
- var Copy = createLucideIcon("Copy", [
3401
- ["rect", { width: "14", height: "14", x: "8", y: "8", rx: "2", ry: "2", key: "17jyea" }],
3402
- ["path", { d: "M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2", key: "zix9uf" }]
3403
- ]);
3404
-
3405
- // ../../node_modules/.pnpm/lucide-react@0.294.0_react@18.3.1/node_modules/lucide-react/dist/esm/icons/credit-card.js
3406
- var CreditCard = createLucideIcon("CreditCard", [
3407
- ["rect", { width: "20", height: "14", x: "2", y: "5", rx: "2", key: "ynyp8z" }],
3408
- ["line", { x1: "2", x2: "22", y1: "10", y2: "10", key: "1b3vmo" }]
3409
- ]);
3410
-
3411
- // ../../node_modules/.pnpm/lucide-react@0.294.0_react@18.3.1/node_modules/lucide-react/dist/esm/icons/dollar-sign.js
3412
- var DollarSign = createLucideIcon("DollarSign", [
3413
- ["line", { x1: "12", x2: "12", y1: "2", y2: "22", key: "7eqyqh" }],
3414
- ["path", { d: "M17 5H9.5a3.5 3.5 0 0 0 0 7h5a3.5 3.5 0 0 1 0 7H6", key: "1b0p4s" }]
3415
- ]);
3416
-
3417
- // ../../node_modules/.pnpm/lucide-react@0.294.0_react@18.3.1/node_modules/lucide-react/dist/esm/icons/external-link.js
3418
- var ExternalLink = createLucideIcon("ExternalLink", [
3419
- ["path", { d: "M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6", key: "a6xqqp" }],
3420
- ["polyline", { points: "15 3 21 3 21 9", key: "mznyad" }],
3421
- ["line", { x1: "10", x2: "21", y1: "14", y2: "3", key: "18c3s4" }]
3422
- ]);
3423
-
3424
- // ../../node_modules/.pnpm/lucide-react@0.294.0_react@18.3.1/node_modules/lucide-react/dist/esm/icons/file-text.js
3425
- var FileText = createLucideIcon("FileText", [
3426
- [
3427
- "path",
3428
- { d: "M14.5 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7.5L14.5 2z", key: "1nnpy2" }
3429
- ],
3430
- ["polyline", { points: "14 2 14 8 20 8", key: "1ew0cm" }],
3431
- ["line", { x1: "16", x2: "8", y1: "13", y2: "13", key: "14keom" }],
3432
- ["line", { x1: "16", x2: "8", y1: "17", y2: "17", key: "17nazh" }],
3433
- ["line", { x1: "10", x2: "8", y1: "9", y2: "9", key: "1a5vjj" }]
3434
- ]);
3435
-
3436
- // ../../node_modules/.pnpm/lucide-react@0.294.0_react@18.3.1/node_modules/lucide-react/dist/esm/icons/info.js
3437
- var Info = createLucideIcon("Info", [
3438
- ["circle", { cx: "12", cy: "12", r: "10", key: "1mglay" }],
3439
- ["path", { d: "M12 16v-4", key: "1dtifu" }],
3440
- ["path", { d: "M12 8h.01", key: "e9boi3" }]
3441
- ]);
3442
-
3443
- // ../../node_modules/.pnpm/lucide-react@0.294.0_react@18.3.1/node_modules/lucide-react/dist/esm/icons/search.js
3444
- var Search = createLucideIcon("Search", [
3445
- ["circle", { cx: "11", cy: "11", r: "8", key: "4ej97u" }],
3446
- ["path", { d: "m21 21-4.3-4.3", key: "1qie3q" }]
3447
- ]);
3448
-
3449
- // ../../node_modules/.pnpm/lucide-react@0.294.0_react@18.3.1/node_modules/lucide-react/dist/esm/icons/shield-check.js
3450
- var ShieldCheck = createLucideIcon("ShieldCheck", [
3451
- ["path", { d: "M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10", key: "1irkt0" }],
3452
- ["path", { d: "m9 12 2 2 4-4", key: "dzmm74" }]
3453
- ]);
3454
-
3455
- // ../../node_modules/.pnpm/lucide-react@0.294.0_react@18.3.1/node_modules/lucide-react/dist/esm/icons/x.js
3456
- var X = createLucideIcon("X", [
3457
- ["path", { d: "M18 6 6 18", key: "1bl5f8" }],
3458
- ["path", { d: "m6 6 12 12", key: "d8bk6v" }]
3459
- ]);
3460
-
3461
- // ../../node_modules/.pnpm/lucide-react@0.294.0_react@18.3.1/node_modules/lucide-react/dist/esm/icons/zap.js
3462
- var Zap = createLucideIcon("Zap", [
3463
- ["polygon", { points: "13 2 3 14 12 14 11 22 21 10 12 10 13 2", key: "45s27k" }]
3464
- ]);
3465
-
3466
3468
  // ../../node_modules/.pnpm/clsx@2.1.1/node_modules/clsx/dist/clsx.mjs
3467
3469
  function r(e) {
3468
3470
  var t4, f, n = "";
@@ -10455,6 +10457,20 @@ async function getFiatCurrencies(publishableKey) {
10455
10457
  }
10456
10458
  return response.json();
10457
10459
  }
10460
+ async function getProjectConfig(publishableKey) {
10461
+ const pk = publishableKey || DEFAULT_PUBLISHABLE_KEY;
10462
+ const response = await fetch(`${API_BASE_URL}/v1/public/projects/config`, {
10463
+ method: "GET",
10464
+ headers: {
10465
+ accept: "application/json",
10466
+ "x-publishable-key": pk
10467
+ }
10468
+ });
10469
+ if (!response.ok) {
10470
+ throw new Error(`Failed to fetch project config: ${response.statusText}`);
10471
+ }
10472
+ return response.json();
10473
+ }
10458
10474
  function DepositExecutionItem({
10459
10475
  execution,
10460
10476
  showCloseButton = false,
@@ -10895,15 +10911,17 @@ function TransferCryptoBase({
10895
10911
  showDetailedDropdowns = false,
10896
10912
  onExecutionsChange,
10897
10913
  onDepositSuccess,
10898
- onDepositError
10914
+ onDepositError,
10915
+ wallets: externalWallets
10899
10916
  }) {
10900
10917
  const { themeClass } = useTheme();
10901
10918
  const isDarkMode = themeClass.includes("uf-dark");
10902
10919
  const [token, setToken] = useState22("USDC");
10903
10920
  const [chain, setChain] = useState22("solana:mainnet");
10904
10921
  const [copied, setCopied] = useState22(false);
10905
- const [wallets, setWallets] = useState22([]);
10906
- const [loading, setLoading] = useState22(true);
10922
+ const [internalWallets, setInternalWallets] = useState22([]);
10923
+ const [loading, setLoading] = useState22(!externalWallets?.length);
10924
+ const wallets = externalWallets?.length ? externalWallets : internalWallets;
10907
10925
  const [error, setError] = useState22(null);
10908
10926
  const [depositExecutions, setDepositExecutions] = useState22([]);
10909
10927
  const [trackedExecutions, setTrackedExecutions] = useState22(/* @__PURE__ */ new Map());
@@ -10967,9 +10985,16 @@ function TransferCryptoBase({
10967
10985
  }
10968
10986
  }, [depositExecutions, onExecutionsChange]);
10969
10987
  useEffect32(() => {
10970
- async function fetchWallets() {
10988
+ if (externalWallets?.length) {
10989
+ setLoading(false);
10990
+ return;
10991
+ }
10992
+ let retryTimeout = null;
10993
+ let isCancelled = false;
10994
+ const fetchWallets = async () => {
10995
+ if (isCancelled) return;
10996
+ setLoading(true);
10971
10997
  try {
10972
- setLoading(true);
10973
10998
  const response = await createEOA(
10974
10999
  {
10975
11000
  user_id: userId,
@@ -10980,23 +11005,35 @@ function TransferCryptoBase({
10980
11005
  },
10981
11006
  publishableKey
10982
11007
  );
10983
- setWallets(response.data);
10984
- setError(null);
11008
+ if (!isCancelled) {
11009
+ setInternalWallets(response.data);
11010
+ setError(null);
11011
+ setLoading(false);
11012
+ }
10985
11013
  } catch (err) {
10986
- setError(err instanceof Error ? err.message : "Failed to load wallets");
10987
- console.error("Error fetching wallets:", err);
10988
- } finally {
10989
- setLoading(false);
11014
+ console.error("Error fetching wallets, retrying in 5s:", err);
11015
+ if (!isCancelled) {
11016
+ setError(err instanceof Error ? err.message : "Failed to load wallets");
11017
+ setLoading(false);
11018
+ retryTimeout = setTimeout(fetchWallets, 5e3);
11019
+ }
10990
11020
  }
10991
- }
11021
+ };
10992
11022
  fetchWallets();
11023
+ return () => {
11024
+ isCancelled = true;
11025
+ if (retryTimeout) {
11026
+ clearTimeout(retryTimeout);
11027
+ }
11028
+ };
10993
11029
  }, [
10994
11030
  userId,
10995
11031
  recipientAddress,
10996
11032
  destinationChainType,
10997
11033
  destinationChainId,
10998
11034
  destinationTokenAddress,
10999
- publishableKey
11035
+ publishableKey,
11036
+ externalWallets
11000
11037
  ]);
11001
11038
  useEffect32(() => {
11002
11039
  if (!supportedTokens.length) return;
@@ -11248,7 +11285,7 @@ function TransferCryptoBase({
11248
11285
  {
11249
11286
  value: depositAddress,
11250
11287
  size: 180,
11251
- imageUrl: currentChainData?.icon_url || currentChainFromBackend?.icon_url || getIconUrl("/icons/networks/ethereum.svg"),
11288
+ imageUrl: currentChainData?.icon_url || currentChainFromBackend?.icon_url,
11252
11289
  imageSize: 45,
11253
11290
  darkMode: isDarkMode
11254
11291
  },
@@ -11465,7 +11502,7 @@ function TransferCryptoBase({
11465
11502
  orderSubmittedAt: depositExecutions[0].created_at || (/* @__PURE__ */ new Date()).toISOString(),
11466
11503
  orderFilledAt: depositExecutions[0].updated_at || (/* @__PURE__ */ new Date()).toISOString(),
11467
11504
  explorerUrl: depositExecutions[0].explorer_url,
11468
- completionExplorerUrl: depositExecutions[0].destination_transaction_hashes?.[0] ? `https://polygonscan.com/tx/${depositExecutions[0].destination_transaction_hashes[0]}` : depositExecutions[0].status === "succeeded" ? depositExecutions[0].explorer_url : void 0,
11505
+ completionExplorerUrl: depositExecutions[0].destination_explorer_url ?? void 0,
11469
11506
  status: depositExecutions[0].status,
11470
11507
  tokenIconUrl: depositExecutions[0].source_token_metadata?.icon_url,
11471
11508
  onClose: () => setDepositExecutions([])
@@ -11500,6 +11537,7 @@ function CurrencyListItem({
11500
11537
  isSelected,
11501
11538
  onSelect
11502
11539
  }) {
11540
+ const iconUrl = currency.icon_url;
11503
11541
  return /* @__PURE__ */ jsxs7(
11504
11542
  "button",
11505
11543
  {
@@ -11507,14 +11545,14 @@ function CurrencyListItem({
11507
11545
  className: "uf-w-full uf-bg-secondary hover:uf-bg-accent uf-transition-colors uf-rounded-xl uf-p-3 uf-flex uf-items-center uf-justify-between uf-group",
11508
11546
  children: [
11509
11547
  /* @__PURE__ */ jsxs7("div", { className: "uf-flex uf-items-center uf-gap-3", children: [
11510
- /* @__PURE__ */ jsx132("div", { className: "uf-w-10 uf-h-10 uf-flex uf-items-center uf-justify-center uf-flex-shrink-0 uf-rounded-full uf-overflow-hidden uf-bg-card", children: /* @__PURE__ */ jsx132(
11548
+ /* @__PURE__ */ jsx132("div", { className: "uf-w-10 uf-h-10 uf-flex-shrink-0 uf-rounded-full uf-overflow-hidden uf-bg-card", children: /* @__PURE__ */ jsx132(
11511
11549
  "img",
11512
11550
  {
11513
- src: currency.icon_url,
11551
+ src: iconUrl,
11514
11552
  alt: currency.name,
11515
11553
  width: 40,
11516
11554
  height: 40,
11517
- className: "uf-w-full uf-h-full uf-object-cover uf-rounded-full"
11555
+ className: "uf-w-full uf-h-full uf-object-cover"
11518
11556
  }
11519
11557
  ) }),
11520
11558
  /* @__PURE__ */ jsxs7("div", { className: "uf-text-left", children: [
@@ -11630,18 +11668,6 @@ function CurrencyModal({
11630
11668
  ] }) })
11631
11669
  ] }) });
11632
11670
  }
11633
- async function getIpViaMoonpay(moonpayApiKey) {
11634
- const url = `https://api.moonpay.com/v3/ip_address?apiKey=${moonpayApiKey}`;
11635
- const response = await fetch(url);
11636
- if (!response.ok) {
11637
- throw new Error(`Moonpay IP API failed: ${response.statusText}`);
11638
- }
11639
- const data = await response.json();
11640
- return {
11641
- alpha2: data.alpha2.toLowerCase(),
11642
- state: data.state?.toLowerCase()
11643
- };
11644
- }
11645
11671
  async function getIpViaIpApi() {
11646
11672
  const url = "https://ipapi.co/json";
11647
11673
  const response = await fetch(url);
@@ -11654,7 +11680,7 @@ async function getIpViaIpApi() {
11654
11680
  state: data.region_code?.toLowerCase()
11655
11681
  };
11656
11682
  }
11657
- function useUserIp(moonpayApiKey) {
11683
+ function useUserIp() {
11658
11684
  const {
11659
11685
  data: userIpInfo,
11660
11686
  isLoading,
@@ -11662,21 +11688,12 @@ function useUserIp(moonpayApiKey) {
11662
11688
  } = useQuery({
11663
11689
  queryKey: ["getUserIpInfo"],
11664
11690
  queryFn: async () => {
11665
- if (moonpayApiKey) {
11666
- try {
11667
- const moonpayIpData = await getIpViaMoonpay(moonpayApiKey);
11668
- console.log("IP detected via Moonpay:", moonpayIpData);
11669
- return moonpayIpData;
11670
- } catch (error2) {
11671
- console.warn("Moonpay IP API failed, trying fallback:", error2);
11672
- }
11673
- }
11674
11691
  try {
11675
11692
  const ipApiData = await getIpViaIpApi();
11676
11693
  console.log("IP detected via ipapi.co:", ipApiData);
11677
11694
  return ipApiData;
11678
11695
  } catch (ipApiError) {
11679
- console.error("All IP detection methods failed:", ipApiError);
11696
+ console.error("IP detection failed:", ipApiError);
11680
11697
  throw ipApiError;
11681
11698
  }
11682
11699
  },
@@ -11722,7 +11739,8 @@ function BuyWithCard({
11722
11739
  destinationChainType,
11723
11740
  destinationChainId,
11724
11741
  destinationTokenAddress,
11725
- themeClass = ""
11742
+ themeClass = "",
11743
+ wallets: externalWallets
11726
11744
  }) {
11727
11745
  const [amount, setAmount] = useState42("500.00");
11728
11746
  const [currency, setCurrency] = useState42("usd");
@@ -11757,8 +11775,9 @@ function BuyWithCard({
11757
11775
  const [isAutoSelected, setIsAutoSelected] = useState42(true);
11758
11776
  const [autoSelectedProvider, setAutoSelectedProvider] = useState42(null);
11759
11777
  const [hasManualSelection, setHasManualSelection] = useState42(false);
11760
- const [wallets, setWallets] = useState42([]);
11761
- const [walletsLoading, setWalletsLoading] = useState42(true);
11778
+ const [internalWallets, setInternalWallets] = useState42([]);
11779
+ const [walletsLoading, setWalletsLoading] = useState42(!externalWallets?.length);
11780
+ const wallets = externalWallets?.length ? externalWallets : internalWallets;
11762
11781
  const [countdown, setCountdown] = useState42(60);
11763
11782
  const [fiatCurrencies, setFiatCurrencies] = useState42([]);
11764
11783
  const [preferredCurrencyCodes, setPreferredCurrencyCodes] = useState42([]);
@@ -11787,7 +11806,15 @@ function BuyWithCard({
11787
11806
  fetchFiatCurrencies();
11788
11807
  }, [publishableKey]);
11789
11808
  useEffect42(() => {
11790
- async function fetchWallets() {
11809
+ if (externalWallets?.length) {
11810
+ setWalletsLoading(false);
11811
+ return;
11812
+ }
11813
+ let retryTimeout = null;
11814
+ let isCancelled = false;
11815
+ const fetchWallets = async () => {
11816
+ if (isCancelled) return;
11817
+ setWalletsLoading(true);
11791
11818
  try {
11792
11819
  const response = await createEOA(
11793
11820
  {
@@ -11799,16 +11826,26 @@ function BuyWithCard({
11799
11826
  },
11800
11827
  publishableKey
11801
11828
  );
11802
- setWallets(response.data);
11829
+ if (!isCancelled) {
11830
+ setInternalWallets(response.data);
11831
+ setWalletsLoading(false);
11832
+ }
11803
11833
  } catch (err) {
11804
- console.error("Error fetching wallets:", err);
11805
- setQuotesError("Failed to load wallet addresses");
11806
- } finally {
11807
- setWalletsLoading(false);
11834
+ console.error("Error fetching wallets, retrying in 5s:", err);
11835
+ if (!isCancelled) {
11836
+ setWalletsLoading(false);
11837
+ retryTimeout = setTimeout(fetchWallets, 5e3);
11838
+ }
11808
11839
  }
11809
- }
11840
+ };
11810
11841
  fetchWallets();
11811
- }, [userId, recipientAddress, destinationChainType, destinationChainId, destinationTokenAddress, publishableKey]);
11842
+ return () => {
11843
+ isCancelled = true;
11844
+ if (retryTimeout) {
11845
+ clearTimeout(retryTimeout);
11846
+ }
11847
+ };
11848
+ }, [userId, recipientAddress, destinationChainType, destinationChainId, destinationTokenAddress, publishableKey, externalWallets]);
11812
11849
  useEffect42(() => {
11813
11850
  async function fetchSupportedTokens() {
11814
11851
  try {
@@ -12298,8 +12335,10 @@ function BuyWithCard({
12298
12335
  function TransferCryptoButton({
12299
12336
  onClick,
12300
12337
  title,
12301
- subtitle
12338
+ subtitle,
12339
+ featuredTokens
12302
12340
  }) {
12341
+ const sortedTokens = featuredTokens ? [...featuredTokens].sort((a, b) => a.position - b.position) : [];
12303
12342
  return /* @__PURE__ */ jsxs11(
12304
12343
  "button",
12305
12344
  {
@@ -12314,88 +12353,20 @@ function TransferCryptoButton({
12314
12353
  ] })
12315
12354
  ] }),
12316
12355
  /* @__PURE__ */ jsxs11("div", { className: "uf-flex uf-items-center uf-gap-2", children: [
12317
- /* @__PURE__ */ jsxs11("div", { className: "uf-flex uf--space-x-1", children: [
12318
- /* @__PURE__ */ jsx172(
12319
- "img",
12320
- {
12321
- src: getIconUrl("/icons/networks/ethereum.svg"),
12322
- alt: "ETH",
12323
- width: 20,
12324
- height: 20,
12325
- className: "uf-rounded-full uf-border-2 uf-border-secondary"
12326
- }
12327
- ),
12328
- /* @__PURE__ */ jsx172(
12329
- "img",
12330
- {
12331
- src: getIconUrl("/icons/networks/optimism.svg"),
12332
- alt: "OP",
12333
- width: 20,
12334
- height: 20,
12335
- className: "uf-rounded-full uf-border-2 uf-border-secondary"
12336
- }
12337
- ),
12338
- /* @__PURE__ */ jsx172(
12339
- "img",
12340
- {
12341
- src: getIconUrl("/icons/networks/polygon.svg"),
12342
- alt: "MATIC",
12343
- width: 20,
12344
- height: 20,
12345
- className: "uf-rounded-full uf-border-2 uf-border-secondary"
12346
- }
12347
- ),
12348
- /* @__PURE__ */ jsx172(
12349
- "img",
12350
- {
12351
- src: getIconUrl("/icons/networks/arbitrum.svg"),
12352
- alt: "ARB",
12353
- width: 20,
12354
- height: 20,
12355
- className: "uf-rounded-full uf-border-2 uf-border-secondary"
12356
- }
12357
- ),
12358
- /* @__PURE__ */ jsx172(
12359
- "img",
12360
- {
12361
- src: getIconUrl("/icons/tokens/usdc.svg"),
12362
- alt: "USDC",
12363
- width: 20,
12364
- height: 20,
12365
- className: "uf-rounded-full uf-border-2 uf-border-secondary"
12366
- }
12367
- ),
12368
- /* @__PURE__ */ jsx172(
12369
- "img",
12370
- {
12371
- src: getIconUrl("/icons/networks/solana.svg"),
12372
- alt: "SOL",
12373
- width: 20,
12374
- height: 20,
12375
- className: "uf-rounded-full uf-border-2 uf-border-secondary"
12376
- }
12377
- ),
12378
- /* @__PURE__ */ jsx172(
12379
- "img",
12380
- {
12381
- src: getIconUrl("/icons/tokens/avax.svg"),
12382
- alt: "AVAX",
12383
- width: 20,
12384
- height: 20,
12385
- className: "uf-rounded-full uf-border-2 uf-border-secondary"
12386
- }
12387
- ),
12388
- /* @__PURE__ */ jsx172(
12356
+ /* @__PURE__ */ jsx172("div", { className: "uf-flex uf--space-x-2", children: sortedTokens.map((token) => {
12357
+ const iconUrl = token.icon_urls.find((u) => u.format === "svg")?.url || token.icon_urls.find((u) => u.format === "png")?.url;
12358
+ return /* @__PURE__ */ jsx172(
12389
12359
  "img",
12390
12360
  {
12391
- src: getIconUrl("/icons/networks/bitcoin.svg"),
12392
- alt: "BTC",
12361
+ src: iconUrl,
12362
+ alt: token.name,
12393
12363
  width: 20,
12394
12364
  height: 20,
12395
12365
  className: "uf-rounded-full uf-border-2 uf-border-secondary"
12396
- }
12397
- )
12398
- ] }),
12366
+ },
12367
+ token.name
12368
+ );
12369
+ }) }),
12399
12370
  /* @__PURE__ */ jsx172(ChevronRight, { className: "uf-w-4 uf-h-4 uf-text-muted-foreground group-hover:uf-text-foreground uf-transition-colors" })
12400
12371
  ] })
12401
12372
  ]
@@ -12405,7 +12376,8 @@ function TransferCryptoButton({
12405
12376
  function DepositWithCardButton({
12406
12377
  onClick,
12407
12378
  title,
12408
- subtitle
12379
+ subtitle,
12380
+ paymentNetworks
12409
12381
  }) {
12410
12382
  return /* @__PURE__ */ jsxs12(
12411
12383
  "button",
@@ -12421,28 +12393,20 @@ function DepositWithCardButton({
12421
12393
  ] })
12422
12394
  ] }),
12423
12395
  /* @__PURE__ */ jsxs12("div", { className: "uf-flex uf-items-center uf-gap-2", children: [
12424
- /* @__PURE__ */ jsxs12("div", { className: "uf-flex uf-items-center uf-gap-1.5", children: [
12425
- /* @__PURE__ */ jsx18(
12426
- "img",
12427
- {
12428
- src: getIconUrl("/icons/networks/mastercard.svg"),
12429
- alt: "Mastercard",
12430
- width: 32,
12431
- height: 32,
12432
- className: "uf-rounded"
12433
- }
12434
- ),
12435
- /* @__PURE__ */ jsx18(
12396
+ /* @__PURE__ */ jsx18("div", { className: "uf-flex uf-items-center uf-gap-1.5", children: paymentNetworks?.map((network) => {
12397
+ const iconUrl = network.icon_urls.find((u) => u.format === "svg")?.url || network.icon_urls.find((u) => u.format === "png")?.url;
12398
+ return /* @__PURE__ */ jsx18(
12436
12399
  "img",
12437
12400
  {
12438
- src: getIconUrl("/icons/networks/visa.svg"),
12439
- alt: "Visa",
12401
+ src: iconUrl,
12402
+ alt: network.name,
12440
12403
  width: 32,
12441
12404
  height: 32,
12442
12405
  className: "uf-rounded"
12443
- }
12444
- )
12445
- ] }),
12406
+ },
12407
+ network.name
12408
+ );
12409
+ }) }),
12446
12410
  /* @__PURE__ */ jsx18(ChevronRight, { className: "uf-w-4 uf-h-4 uf-text-muted-foreground group-hover:uf-text-foreground uf-transition-colors" })
12447
12411
  ] })
12448
12412
  ]
@@ -12476,6 +12440,21 @@ function DepositTrackerButton({
12476
12440
  }
12477
12441
  );
12478
12442
  }
12443
+ function SkeletonButton({ variant = "default" }) {
12444
+ return /* @__PURE__ */ jsxs14("div", { className: "uf-w-full uf-bg-secondary uf-rounded-xl uf-p-3 uf-flex uf-items-center uf-justify-between uf-animate-pulse", children: [
12445
+ /* @__PURE__ */ jsxs14("div", { className: "uf-flex uf-items-center uf-gap-3", children: [
12446
+ /* @__PURE__ */ jsx20("div", { className: "uf-bg-muted uf-rounded-lg uf-w-9 uf-h-9" }),
12447
+ /* @__PURE__ */ jsxs14("div", { className: "uf-space-y-1.5", children: [
12448
+ /* @__PURE__ */ jsx20("div", { className: "uf-h-3.5 uf-w-24 uf-bg-muted uf-rounded" }),
12449
+ /* @__PURE__ */ jsx20("div", { className: "uf-h-3 uf-w-32 uf-bg-muted uf-rounded" })
12450
+ ] })
12451
+ ] }),
12452
+ /* @__PURE__ */ jsxs14("div", { className: "uf-flex uf-items-center uf-gap-2", children: [
12453
+ variant === "with-icons" && /* @__PURE__ */ jsx20("div", { className: "uf-flex uf--space-x-1", children: [1, 2, 3].map((i) => /* @__PURE__ */ jsx20("div", { className: "uf-w-5 uf-h-5 uf-rounded-full uf-bg-muted uf-border-2 uf-border-secondary" }, i)) }),
12454
+ /* @__PURE__ */ jsx20(ChevronRight, { className: "uf-w-4 uf-h-4 uf-text-muted" })
12455
+ ] })
12456
+ ] });
12457
+ }
12479
12458
  var t3 = i18n.depositModal;
12480
12459
  function DepositModal({
12481
12460
  open,
@@ -12500,6 +12479,15 @@ function DepositModal({
12500
12479
  const [quotesCount, setQuotesCount] = useState52(0);
12501
12480
  const [depositsModalOpen, setDepositsModalOpen] = useState52(false);
12502
12481
  const [depositExecutions, setDepositExecutions] = useState52([]);
12482
+ const [projectConfig, setProjectConfig] = useState52(null);
12483
+ const [wallets, setWallets] = useState52([]);
12484
+ const [walletsLoading, setWalletsLoading] = useState52(false);
12485
+ useEffect52(() => {
12486
+ setProjectConfig(null);
12487
+ }, [publishableKey]);
12488
+ useEffect52(() => {
12489
+ setWallets([]);
12490
+ }, [userId, recipientAddress, destinationChainType, destinationChainId, destinationTokenAddress, publishableKey]);
12503
12491
  const [resolvedTheme, setResolvedTheme] = useState52(theme === "auto" ? "dark" : theme);
12504
12492
  useEffect52(() => {
12505
12493
  if (theme === "auto") {
@@ -12514,6 +12502,49 @@ function DepositModal({
12514
12502
  setResolvedTheme(theme);
12515
12503
  }
12516
12504
  }, [theme]);
12505
+ useEffect52(() => {
12506
+ if (open && !projectConfig) {
12507
+ getProjectConfig(publishableKey).then(setProjectConfig).catch(console.error);
12508
+ }
12509
+ }, [open, publishableKey, projectConfig]);
12510
+ useEffect52(() => {
12511
+ if (!open || wallets.length > 0) return;
12512
+ let retryTimeout = null;
12513
+ let isCancelled = false;
12514
+ const fetchWallets = async () => {
12515
+ if (isCancelled) return;
12516
+ setWalletsLoading(true);
12517
+ try {
12518
+ const response = await createEOA(
12519
+ {
12520
+ user_id: userId,
12521
+ recipient_address: recipientAddress,
12522
+ destination_chain_type: destinationChainType,
12523
+ destination_chain_id: destinationChainId,
12524
+ destination_token_address: destinationTokenAddress
12525
+ },
12526
+ publishableKey
12527
+ );
12528
+ if (!isCancelled) {
12529
+ setWallets(response.data);
12530
+ setWalletsLoading(false);
12531
+ }
12532
+ } catch (error) {
12533
+ console.error("Error fetching wallets, retrying in 5s:", error);
12534
+ if (!isCancelled) {
12535
+ setWalletsLoading(false);
12536
+ retryTimeout = setTimeout(fetchWallets, 5e3);
12537
+ }
12538
+ }
12539
+ };
12540
+ fetchWallets();
12541
+ return () => {
12542
+ isCancelled = true;
12543
+ if (retryTimeout) {
12544
+ clearTimeout(retryTimeout);
12545
+ }
12546
+ };
12547
+ }, [open, userId, recipientAddress, destinationChainType, destinationChainId, destinationTokenAddress, publishableKey, wallets.length]);
12517
12548
  const themeClass = resolvedTheme === "dark" ? "uf-dark" : "";
12518
12549
  const handleClose = () => {
12519
12550
  onOpenChange(false);
@@ -12553,13 +12584,18 @@ function DepositModal({
12553
12584
  onClose: handleClose
12554
12585
  }
12555
12586
  ),
12556
- /* @__PURE__ */ jsxs14("div", { className: "uf-pb-4 uf-space-y-3", children: [
12587
+ /* @__PURE__ */ jsx20("div", { className: "uf-pb-4 uf-space-y-3", children: !projectConfig ? /* @__PURE__ */ jsxs14(Fragment42, { children: [
12588
+ /* @__PURE__ */ jsx20(SkeletonButton, { variant: "with-icons" }),
12589
+ /* @__PURE__ */ jsx20(SkeletonButton, { variant: "with-icons" }),
12590
+ !hideDepositTracker && /* @__PURE__ */ jsx20(SkeletonButton, {})
12591
+ ] }) : /* @__PURE__ */ jsxs14(Fragment42, { children: [
12557
12592
  /* @__PURE__ */ jsx20(
12558
12593
  TransferCryptoButton,
12559
12594
  {
12560
12595
  onClick: () => setView("transfer"),
12561
12596
  title: t3.transferCrypto.title,
12562
- subtitle: t3.transferCrypto.subtitle
12597
+ subtitle: t3.transferCrypto.subtitle,
12598
+ featuredTokens: projectConfig.transfer_crypto.networks
12563
12599
  }
12564
12600
  ),
12565
12601
  /* @__PURE__ */ jsx20(
@@ -12567,7 +12603,8 @@ function DepositModal({
12567
12603
  {
12568
12604
  onClick: () => setView("card"),
12569
12605
  title: t3.depositWithCard.title,
12570
- subtitle: t3.depositWithCard.subtitle
12606
+ subtitle: t3.depositWithCard.subtitle,
12607
+ paymentNetworks: projectConfig.payment_networks.networks
12571
12608
  }
12572
12609
  ),
12573
12610
  !hideDepositTracker && /* @__PURE__ */ jsx20(
@@ -12579,7 +12616,7 @@ function DepositModal({
12579
12616
  badge: depositExecutions.length > 0 ? depositExecutions.length : void 0
12580
12617
  }
12581
12618
  )
12582
- ] })
12619
+ ] }) })
12583
12620
  ] }) : view === "transfer" ? /* @__PURE__ */ jsxs14(Fragment42, { children: [
12584
12621
  /* @__PURE__ */ jsx20(
12585
12622
  DepositHeader,
@@ -12601,7 +12638,8 @@ function DepositModal({
12601
12638
  destinationTokenAddress,
12602
12639
  onExecutionsChange: setDepositExecutions,
12603
12640
  onDepositSuccess,
12604
- onDepositError
12641
+ onDepositError,
12642
+ wallets
12605
12643
  }
12606
12644
  )
12607
12645
  ] }) : /* @__PURE__ */ jsxs14(Fragment42, { children: [
@@ -12629,7 +12667,8 @@ function DepositModal({
12629
12667
  destinationTokenAddress,
12630
12668
  onDepositSuccess,
12631
12669
  onDepositError,
12632
- themeClass
12670
+ themeClass,
12671
+ wallets
12633
12672
  }
12634
12673
  )
12635
12674
  ] })