@iota/dapp-kit 0.5.3 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +52 -0
- package/dist/cjs/components/AccountDropdownMenu.d.ts +4 -2
- package/dist/cjs/components/AccountDropdownMenu.js +81 -15
- package/dist/cjs/components/AccountDropdownMenu.js.map +4 -4
- package/dist/cjs/components/ConnectButton.d.ts +6 -1
- package/dist/cjs/components/ConnectButton.js +177 -91
- package/dist/cjs/components/ConnectButton.js.map +4 -4
- package/dist/cjs/components/WalletProvider.d.ts +3 -1
- package/dist/cjs/components/WalletProvider.js +9 -3
- package/dist/cjs/components/WalletProvider.js.map +2 -2
- package/dist/cjs/components/connect-modal/ConnectModal.d.ts +5 -1
- package/dist/cjs/components/connect-modal/ConnectModal.js +12 -2
- package/dist/cjs/components/connect-modal/ConnectModal.js.map +2 -2
- package/dist/cjs/hooks/useGetDefaultIotaName.d.ts +1 -0
- package/dist/cjs/hooks/useGetDefaultIotaName.js +80 -0
- package/dist/cjs/hooks/useGetDefaultIotaName.js.map +7 -0
- package/dist/cjs/hooks/wallet/useAutoConnectWallet.js +2 -0
- package/dist/cjs/hooks/wallet/useAutoConnectWallet.js.map +2 -2
- package/dist/cjs/hooks/wallet/useConnectWallet.d.ts +6 -2
- package/dist/cjs/hooks/wallet/useConnectWallet.js +2 -0
- package/dist/cjs/hooks/wallet/useConnectWallet.js.map +2 -2
- package/dist/cjs/hooks/wallet/useCurrentChain.d.ts +5 -0
- package/dist/cjs/hooks/wallet/useCurrentChain.js +50 -0
- package/dist/cjs/hooks/wallet/useCurrentChain.js.map +7 -0
- package/dist/cjs/hooks/wallet/useSignAndExecuteTransaction.js +8 -2
- package/dist/cjs/hooks/wallet/useSignAndExecuteTransaction.js.map +3 -3
- package/dist/cjs/index.js +193 -120
- package/dist/cjs/index.js.map +4 -4
- package/dist/cjs/walletStore.d.ts +4 -1
- package/dist/cjs/walletStore.js +3 -1
- package/dist/cjs/walletStore.js.map +2 -2
- package/dist/esm/components/AccountDropdownMenu.d.ts +4 -2
- package/dist/esm/components/AccountDropdownMenu.js +79 -13
- package/dist/esm/components/AccountDropdownMenu.js.map +4 -4
- package/dist/esm/components/ConnectButton.d.ts +6 -1
- package/dist/esm/components/ConnectButton.js +159 -73
- package/dist/esm/components/ConnectButton.js.map +4 -4
- package/dist/esm/components/WalletProvider.d.ts +3 -1
- package/dist/esm/components/WalletProvider.js +9 -3
- package/dist/esm/components/WalletProvider.js.map +2 -2
- package/dist/esm/components/connect-modal/ConnectModal.d.ts +5 -1
- package/dist/esm/components/connect-modal/ConnectModal.js +12 -2
- package/dist/esm/components/connect-modal/ConnectModal.js.map +2 -2
- package/dist/esm/hooks/useGetDefaultIotaName.d.ts +1 -0
- package/dist/esm/hooks/useGetDefaultIotaName.js +59 -0
- package/dist/esm/hooks/useGetDefaultIotaName.js.map +7 -0
- package/dist/esm/hooks/wallet/useAutoConnectWallet.js +2 -0
- package/dist/esm/hooks/wallet/useAutoConnectWallet.js.map +2 -2
- package/dist/esm/hooks/wallet/useConnectWallet.d.ts +6 -2
- package/dist/esm/hooks/wallet/useConnectWallet.js +2 -0
- package/dist/esm/hooks/wallet/useConnectWallet.js.map +2 -2
- package/dist/esm/hooks/wallet/useCurrentChain.d.ts +5 -0
- package/dist/esm/hooks/wallet/useCurrentChain.js +27 -0
- package/dist/esm/hooks/wallet/useCurrentChain.js.map +7 -0
- package/dist/esm/hooks/wallet/useSignAndExecuteTransaction.js +8 -2
- package/dist/esm/hooks/wallet/useSignAndExecuteTransaction.js.map +3 -3
- package/dist/esm/index.js +164 -91
- package/dist/esm/index.js.map +4 -4
- package/dist/esm/walletStore.d.ts +4 -1
- package/dist/esm/walletStore.js +3 -1
- package/dist/esm/walletStore.js.map +2 -2
- package/dist/tsconfig.esm.tsbuildinfo +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +5 -3
- package/src/components/AccountDropdownMenu.tsx +17 -3
- package/src/components/ConnectButton.tsx +11 -1
- package/src/components/WalletProvider.tsx +5 -0
- package/src/components/connect-modal/ConnectModal.tsx +12 -2
- package/src/hooks/useGetDefaultIotaName.ts +43 -0
- package/src/hooks/wallet/useConnectWallet.ts +6 -1
- package/src/hooks/wallet/useCurrentChain.ts +12 -0
- package/src/hooks/wallet/useSignAndExecuteTransaction.ts +5 -2
- package/src/walletStore.ts +5 -0
|
@@ -320,27 +320,90 @@ var Text = (0, import_react5.forwardRef)(
|
|
|
320
320
|
);
|
|
321
321
|
Text.displayName = "Text";
|
|
322
322
|
|
|
323
|
-
// src/
|
|
323
|
+
// src/hooks/useGetDefaultIotaName.ts
|
|
324
|
+
var import_client2 = require("@iota/iota-sdk/client");
|
|
325
|
+
var import_react_query3 = require("@tanstack/react-query");
|
|
326
|
+
var import_iota_names_sdk = require("@iota/iota-names-sdk");
|
|
327
|
+
|
|
328
|
+
// src/hooks/useIotaClient.ts
|
|
329
|
+
var import_react7 = require("react");
|
|
330
|
+
|
|
331
|
+
// src/components/IotaClientProvider.tsx
|
|
332
|
+
var import_client = require("@iota/iota-sdk/client");
|
|
333
|
+
var import_react6 = require("react");
|
|
324
334
|
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
325
|
-
|
|
335
|
+
var IotaClientContext = (0, import_react6.createContext)(null);
|
|
336
|
+
var DEFAULT_NETWORKS = {
|
|
337
|
+
localnet: { url: (0, import_client.getNetwork)(import_client.Network.Localnet)?.url }
|
|
338
|
+
};
|
|
339
|
+
|
|
340
|
+
// src/hooks/useIotaClient.ts
|
|
341
|
+
function useIotaClientContext() {
|
|
342
|
+
const iotaClient = (0, import_react7.useContext)(IotaClientContext);
|
|
343
|
+
if (!iotaClient) {
|
|
344
|
+
throw new Error(
|
|
345
|
+
"Could not find IotaClientContext. Ensure that you have set up the IotaClientProvider"
|
|
346
|
+
);
|
|
347
|
+
}
|
|
348
|
+
return iotaClient;
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
// src/hooks/useGetDefaultIotaName.ts
|
|
352
|
+
var import_react8 = require("react");
|
|
353
|
+
var import_graphql = require("@iota/iota-sdk/graphql");
|
|
354
|
+
function useGetDefaultIotaName(address, iotaNamesEnabled) {
|
|
355
|
+
const iotaContext = useIotaClientContext();
|
|
356
|
+
const network = (0, import_client2.getNetwork)(iotaContext.network);
|
|
357
|
+
const iotaNamesClient = (0, import_react8.useMemo)(() => {
|
|
358
|
+
const iotaGraphQLClient = new import_graphql.IotaGraphQLClient({
|
|
359
|
+
url: network.graphql
|
|
360
|
+
});
|
|
361
|
+
return new import_iota_names_sdk.IotaNamesClient({
|
|
362
|
+
graphQlClient: iotaGraphQLClient,
|
|
363
|
+
network: network.id
|
|
364
|
+
});
|
|
365
|
+
}, [network.id]);
|
|
366
|
+
const iotaNamesSupported = !!iotaNamesClient.config;
|
|
367
|
+
return (0, import_react_query3.useQuery)({
|
|
368
|
+
queryKey: ["iota-name", "default-name", address],
|
|
369
|
+
queryFn: async () => {
|
|
370
|
+
if (!address) return null;
|
|
371
|
+
const name = await iotaNamesClient?.getDefaultName(address);
|
|
372
|
+
return name ? (0, import_iota_names_sdk.normalizeIotaName)(name) : name;
|
|
373
|
+
},
|
|
374
|
+
enabled: !!iotaNamesClient && !!address && iotaNamesEnabled && iotaNamesSupported,
|
|
375
|
+
staleTime: 1e3 * 60 * 10
|
|
376
|
+
});
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
// src/components/AccountDropdownMenu.tsx
|
|
380
|
+
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
381
|
+
function AccountDropdownMenu({
|
|
382
|
+
currentAccount,
|
|
383
|
+
size = "lg",
|
|
384
|
+
iotaNamesEnabled
|
|
385
|
+
}) {
|
|
326
386
|
const { mutate: disconnectWallet } = useDisconnectWallet();
|
|
327
387
|
const accounts = useAccounts();
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
388
|
+
const { data: iotaName } = useGetDefaultIotaName(currentAccount.address, iotaNamesEnabled);
|
|
389
|
+
const displayAccount = iotaName ?? currentAccount.label ?? (0, import_utils.formatAddress)(currentAccount.address);
|
|
390
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(DropdownMenu.Root, { modal: false, children: [
|
|
391
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(StyleMarker, { children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(DropdownMenu.Trigger, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(Button, { size, className: connectedAccount, children: [
|
|
392
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Text, { mono: true, weight: "bold", children: displayAccount }),
|
|
393
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(ChevronIcon, {})
|
|
332
394
|
] }) }) }),
|
|
333
|
-
/* @__PURE__ */ (0,
|
|
334
|
-
/* @__PURE__ */ (0,
|
|
395
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(DropdownMenu.Portal, { children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(StyleMarker, { className: menuContainer, children: /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(DropdownMenu.Content, { className: menuContent, children: [
|
|
396
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: scrollableContent, children: accounts.map((account) => /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
335
397
|
AccountDropdownMenuItem,
|
|
336
398
|
{
|
|
337
399
|
account,
|
|
338
|
-
active: currentAccount.address === account.address
|
|
400
|
+
active: currentAccount.address === account.address,
|
|
401
|
+
iotaNamesEnabled
|
|
339
402
|
},
|
|
340
403
|
account.address
|
|
341
404
|
)) }),
|
|
342
|
-
/* @__PURE__ */ (0,
|
|
343
|
-
/* @__PURE__ */ (0,
|
|
405
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(DropdownMenu.Separator, { className: separator }),
|
|
406
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
344
407
|
DropdownMenu.Item,
|
|
345
408
|
{
|
|
346
409
|
className: (0, import_clsx3.default)(menuItem),
|
|
@@ -353,17 +416,20 @@ function AccountDropdownMenu({ currentAccount, size = "lg" }) {
|
|
|
353
416
|
}
|
|
354
417
|
function AccountDropdownMenuItem({
|
|
355
418
|
account,
|
|
356
|
-
active
|
|
419
|
+
active,
|
|
420
|
+
iotaNamesEnabled
|
|
357
421
|
}) {
|
|
358
422
|
const { mutate: switchAccount } = useSwitchAccount();
|
|
359
|
-
|
|
423
|
+
const { data: iotaName } = useGetDefaultIotaName(account.address, iotaNamesEnabled);
|
|
424
|
+
const displayAccount = iotaName ?? account.label ?? (0, import_utils.formatAddress)(account.address);
|
|
425
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
|
|
360
426
|
DropdownMenu.Item,
|
|
361
427
|
{
|
|
362
428
|
className: (0, import_clsx3.default)(menuItem, switchAccountMenuItem),
|
|
363
429
|
onSelect: () => switchAccount({ account }),
|
|
364
430
|
children: [
|
|
365
|
-
/* @__PURE__ */ (0,
|
|
366
|
-
active ? /* @__PURE__ */ (0,
|
|
431
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Text, { mono: true, children: displayAccount }),
|
|
432
|
+
active ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(CheckIcon, {}) : null
|
|
367
433
|
]
|
|
368
434
|
}
|
|
369
435
|
);
|
|
@@ -372,18 +438,19 @@ function AccountDropdownMenuItem({
|
|
|
372
438
|
// src/components/connect-modal/ConnectModal.tsx
|
|
373
439
|
var Dialog = __toESM(require("@radix-ui/react-dialog"));
|
|
374
440
|
var import_clsx7 = __toESM(require("clsx"));
|
|
375
|
-
var
|
|
441
|
+
var import_react11 = require("react");
|
|
376
442
|
|
|
377
443
|
// src/hooks/wallet/useConnectWallet.ts
|
|
378
444
|
var import_wallet_standard = require("@iota/wallet-standard");
|
|
379
|
-
var
|
|
445
|
+
var import_react_query4 = require("@tanstack/react-query");
|
|
380
446
|
function useConnectWallet({
|
|
447
|
+
onConnected,
|
|
381
448
|
mutationKey,
|
|
382
449
|
...mutationOptions
|
|
383
450
|
} = {}) {
|
|
384
451
|
const setWalletConnected = useWalletStore((state) => state.setWalletConnected);
|
|
385
452
|
const setConnectionStatus = useWalletStore((state) => state.setConnectionStatus);
|
|
386
|
-
return (0,
|
|
453
|
+
return (0, import_react_query4.useMutation)({
|
|
387
454
|
mutationKey: walletMutationKeys.connectWallet(mutationKey),
|
|
388
455
|
mutationFn: async ({ wallet, accountAddress, ...connectArgs }) => {
|
|
389
456
|
try {
|
|
@@ -399,6 +466,7 @@ function useConnectWallet({
|
|
|
399
466
|
selectedAccount,
|
|
400
467
|
connectResult.supportedIntents
|
|
401
468
|
);
|
|
469
|
+
onConnected?.({ wallet });
|
|
402
470
|
return { accounts: connectedIotaAccounts };
|
|
403
471
|
} catch (error) {
|
|
404
472
|
setConnectionStatus("disconnected");
|
|
@@ -428,9 +496,9 @@ function getWalletUniqueIdentifier(wallet) {
|
|
|
428
496
|
}
|
|
429
497
|
|
|
430
498
|
// src/components/icons/BackIcon.tsx
|
|
431
|
-
var
|
|
499
|
+
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
432
500
|
function BackIcon(props) {
|
|
433
|
-
return /* @__PURE__ */ (0,
|
|
501
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("svg", { width: 24, height: 24, fill: "none", xmlns: "http://www.w3.org/2000/svg", ...props, children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
434
502
|
"path",
|
|
435
503
|
{
|
|
436
504
|
d: "M7.57 12.262c0 .341.13.629.403.895l5.175 5.059c.204.205.45.307.751.307.609 0 1.101-.485 1.101-1.087 0-.293-.123-.574-.349-.8L10.14 12.27l4.511-4.375A1.13 1.13 0 0 0 15 7.087C15 6.485 14.508 6 13.9 6c-.295 0-.54.103-.752.308l-5.175 5.058c-.28.28-.404.56-.404.896Z",
|
|
@@ -440,9 +508,9 @@ function BackIcon(props) {
|
|
|
440
508
|
}
|
|
441
509
|
|
|
442
510
|
// src/components/icons/CloseIcon.tsx
|
|
443
|
-
var
|
|
511
|
+
var import_jsx_runtime9 = require("react/jsx-runtime");
|
|
444
512
|
function CloseIcon(props) {
|
|
445
|
-
return /* @__PURE__ */ (0,
|
|
513
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("svg", { width: 10, height: 10, fill: "none", xmlns: "http://www.w3.org/2000/svg", ...props, children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
446
514
|
"path",
|
|
447
515
|
{
|
|
448
516
|
d: "M9.708.292a.999.999 0 0 0-1.413 0l-3.289 3.29L1.717.291A.999.999 0 0 0 .305 1.705l3.289 3.289-3.29 3.289a.999.999 0 1 0 1.413 1.412l3.29-3.289 3.288 3.29a.999.999 0 0 0 1.413-1.413l-3.29-3.29 3.29-3.288a.999.999 0 0 0 0-1.413Z",
|
|
@@ -454,15 +522,15 @@ function CloseIcon(props) {
|
|
|
454
522
|
// src/components/ui/Heading.tsx
|
|
455
523
|
var import_react_slot4 = require("@radix-ui/react-slot");
|
|
456
524
|
var import_clsx4 = __toESM(require("clsx"));
|
|
457
|
-
var
|
|
525
|
+
var import_react9 = require("react");
|
|
458
526
|
|
|
459
527
|
// src/components/ui/Heading.css.ts
|
|
460
528
|
var import_createRuntimeFn3 = require("@vanilla-extract/recipes/createRuntimeFn");
|
|
461
529
|
var headingVariants = (0, import_createRuntimeFn3.createRuntimeFn)({ defaultClassName: "Heading__12b5l8i0", variantClassNames: { size: { sm: "Heading_headingVariants_size_sm__12b5l8i1", md: "Heading_headingVariants_size_md__12b5l8i2", lg: "Heading_headingVariants_size_lg__12b5l8i3", xl: "Heading_headingVariants_size_xl__12b5l8i4" }, weight: { normal: "Heading_headingVariants_weight_normal__12b5l8i5", bold: "Heading_headingVariants_weight_bold__12b5l8i6" }, truncate: { true: "Heading_headingVariants_truncate_true__12b5l8i7" } }, defaultVariants: { size: "lg", weight: "bold" }, compoundVariants: [] });
|
|
462
530
|
|
|
463
531
|
// src/components/ui/Heading.tsx
|
|
464
|
-
var
|
|
465
|
-
var Heading = (0,
|
|
532
|
+
var import_jsx_runtime10 = require("react/jsx-runtime");
|
|
533
|
+
var Heading = (0, import_react9.forwardRef)(
|
|
466
534
|
({
|
|
467
535
|
children,
|
|
468
536
|
className,
|
|
@@ -473,13 +541,13 @@ var Heading = (0, import_react6.forwardRef)(
|
|
|
473
541
|
truncate,
|
|
474
542
|
...headingProps
|
|
475
543
|
}, forwardedRef) => {
|
|
476
|
-
return /* @__PURE__ */ (0,
|
|
544
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
477
545
|
import_react_slot4.Slot,
|
|
478
546
|
{
|
|
479
547
|
...headingProps,
|
|
480
548
|
ref: forwardedRef,
|
|
481
549
|
className: (0, import_clsx4.default)(headingVariants({ size, weight, truncate }), className),
|
|
482
|
-
children: asChild ? children : /* @__PURE__ */ (0,
|
|
550
|
+
children: asChild ? children : /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(Tag, { children })
|
|
483
551
|
}
|
|
484
552
|
);
|
|
485
553
|
}
|
|
@@ -489,17 +557,17 @@ Heading.displayName = "Heading";
|
|
|
489
557
|
// src/components/ui/IconButton.tsx
|
|
490
558
|
var import_react_slot5 = require("@radix-ui/react-slot");
|
|
491
559
|
var import_clsx5 = __toESM(require("clsx"));
|
|
492
|
-
var
|
|
560
|
+
var import_react10 = require("react");
|
|
493
561
|
|
|
494
562
|
// src/components/ui/IconButton.css.ts
|
|
495
563
|
var container = "IconButton_container__ap1qll0";
|
|
496
564
|
|
|
497
565
|
// src/components/ui/IconButton.tsx
|
|
498
|
-
var
|
|
499
|
-
var IconButton = (0,
|
|
566
|
+
var import_jsx_runtime11 = require("react/jsx-runtime");
|
|
567
|
+
var IconButton = (0, import_react10.forwardRef)(
|
|
500
568
|
({ className, asChild = false, ...props }, forwardedRef) => {
|
|
501
569
|
const Comp = asChild ? import_react_slot5.Slot : "button";
|
|
502
|
-
return /* @__PURE__ */ (0,
|
|
570
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(Comp, { ...props, className: (0, import_clsx5.default)(container, className), ref: forwardedRef });
|
|
503
571
|
}
|
|
504
572
|
);
|
|
505
573
|
IconButton.displayName = "Button";
|
|
@@ -525,14 +593,14 @@ var title2 = "ConnectionStatus_title__c5q1ll2";
|
|
|
525
593
|
var walletIcon = "ConnectionStatus_walletIcon__c5q1ll1";
|
|
526
594
|
|
|
527
595
|
// src/components/connect-modal/views/ConnectionStatus.tsx
|
|
528
|
-
var
|
|
596
|
+
var import_jsx_runtime12 = require("react/jsx-runtime");
|
|
529
597
|
function ConnectionStatus({
|
|
530
598
|
selectedWallet,
|
|
531
599
|
hadConnectionError,
|
|
532
600
|
onRetryConnection
|
|
533
601
|
}) {
|
|
534
|
-
return /* @__PURE__ */ (0,
|
|
535
|
-
/* @__PURE__ */ (0,
|
|
602
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: container2, children: [
|
|
603
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
536
604
|
"img",
|
|
537
605
|
{
|
|
538
606
|
className: walletIcon,
|
|
@@ -540,12 +608,12 @@ function ConnectionStatus({
|
|
|
540
608
|
alt: `${selectedWallet.name} logo`
|
|
541
609
|
}
|
|
542
610
|
),
|
|
543
|
-
/* @__PURE__ */ (0,
|
|
611
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: title2, children: /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(Heading, { as: "h2", size: "xl", children: [
|
|
544
612
|
"Opening ",
|
|
545
613
|
selectedWallet.name
|
|
546
614
|
] }) }),
|
|
547
|
-
/* @__PURE__ */ (0,
|
|
548
|
-
hadConnectionError ? /* @__PURE__ */ (0,
|
|
615
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: connectionStatus, children: hadConnectionError ? /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Text, { color: "danger", children: "Connection failed" }) : /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Text, { color: "muted", children: "Confirm connection in the wallet..." }) }),
|
|
616
|
+
hadConnectionError ? /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: retryButtonContainer, children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
549
617
|
Button,
|
|
550
618
|
{
|
|
551
619
|
type: "button",
|
|
@@ -561,11 +629,11 @@ function ConnectionStatus({
|
|
|
561
629
|
var container3 = "InfoSection_container__1d1nrmt0";
|
|
562
630
|
|
|
563
631
|
// src/components/connect-modal/InfoSection.tsx
|
|
564
|
-
var
|
|
632
|
+
var import_jsx_runtime13 = require("react/jsx-runtime");
|
|
565
633
|
function InfoSection({ title: title3, children }) {
|
|
566
|
-
return /* @__PURE__ */ (0,
|
|
567
|
-
/* @__PURE__ */ (0,
|
|
568
|
-
/* @__PURE__ */ (0,
|
|
634
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("section", { className: container3, children: [
|
|
635
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(Heading, { as: "h3", size: "sm", weight: "normal", children: title3 }),
|
|
636
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(Text, { weight: "medium", color: "muted", children })
|
|
569
637
|
] });
|
|
570
638
|
}
|
|
571
639
|
|
|
@@ -575,15 +643,15 @@ var content2 = "GettingStarted_content__qu36t91";
|
|
|
575
643
|
var installButtonContainer = "GettingStarted_installButtonContainer__qu36t92";
|
|
576
644
|
|
|
577
645
|
// src/components/connect-modal/views/GettingStarted.tsx
|
|
578
|
-
var
|
|
646
|
+
var import_jsx_runtime14 = require("react/jsx-runtime");
|
|
579
647
|
function GettingStarted() {
|
|
580
|
-
return /* @__PURE__ */ (0,
|
|
581
|
-
/* @__PURE__ */ (0,
|
|
582
|
-
/* @__PURE__ */ (0,
|
|
583
|
-
/* @__PURE__ */ (0,
|
|
584
|
-
/* @__PURE__ */ (0,
|
|
585
|
-
/* @__PURE__ */ (0,
|
|
586
|
-
/* @__PURE__ */ (0,
|
|
648
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: container4, children: [
|
|
649
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(Heading, { as: "h2", children: "Get Started with IOTA" }),
|
|
650
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: content2, children: [
|
|
651
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(InfoSection, { title: "Install the IOTA Wallet Extension", children: "We recommend pinning IOTA Wallet to your taskbar for quicker access." }),
|
|
652
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(InfoSection, { title: "Create or Import a Wallet", children: "Be sure to back up your wallet using a secure method. Never share your secret phrase with anyone." }),
|
|
653
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(InfoSection, { title: "Refresh Your Browser", children: "Once you set up your wallet, refresh this window browser to load up the extension." }),
|
|
654
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { className: installButtonContainer, children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(Button, { variant: "primary", asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
587
655
|
"a",
|
|
588
656
|
{
|
|
589
657
|
href: "https://chrome.google.com/webstore/detail/iota-wallet/iidjkmdceolghepehaaddojmnjnkkija",
|
|
@@ -601,13 +669,13 @@ var container5 = "WhatIsAWallet_container__1kdcimq0";
|
|
|
601
669
|
var content3 = "WhatIsAWallet_content__1kdcimq1";
|
|
602
670
|
|
|
603
671
|
// src/components/connect-modal/views/WhatIsAWallet.tsx
|
|
604
|
-
var
|
|
672
|
+
var import_jsx_runtime15 = require("react/jsx-runtime");
|
|
605
673
|
function WhatIsAWallet() {
|
|
606
|
-
return /* @__PURE__ */ (0,
|
|
607
|
-
/* @__PURE__ */ (0,
|
|
608
|
-
/* @__PURE__ */ (0,
|
|
609
|
-
/* @__PURE__ */ (0,
|
|
610
|
-
/* @__PURE__ */ (0,
|
|
674
|
+
return /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { className: container5, children: [
|
|
675
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(Heading, { as: "h2", children: "What is a Wallet" }),
|
|
676
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { className: content3, children: [
|
|
677
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(InfoSection, { title: "Easy Login", children: "No need to create new accounts and passwords for every website. Just connect your wallet and get going." }),
|
|
678
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(InfoSection, { title: "Store your Digital Assets", children: "Send, receive, store, and display your digital assets like NFTs & coins." })
|
|
611
679
|
] })
|
|
612
680
|
] });
|
|
613
681
|
}
|
|
@@ -618,9 +686,9 @@ function useWallets() {
|
|
|
618
686
|
}
|
|
619
687
|
|
|
620
688
|
// src/components/icons/IotaIcon.tsx
|
|
621
|
-
var
|
|
689
|
+
var import_jsx_runtime16 = require("react/jsx-runtime");
|
|
622
690
|
function IotaIcon(props) {
|
|
623
|
-
return /* @__PURE__ */ (0,
|
|
691
|
+
return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
624
692
|
"svg",
|
|
625
693
|
{
|
|
626
694
|
xmlns: "http://www.w3.org/2000/svg",
|
|
@@ -629,7 +697,7 @@ function IotaIcon(props) {
|
|
|
629
697
|
fill: "none",
|
|
630
698
|
viewBox: "0 0 24 24",
|
|
631
699
|
...props,
|
|
632
|
-
children: /* @__PURE__ */ (0,
|
|
700
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
633
701
|
"path",
|
|
634
702
|
{
|
|
635
703
|
fill: "#171d26",
|
|
@@ -654,27 +722,27 @@ var walletIcon2 = "WalletListItem_walletIcon__1vrvezk3";
|
|
|
654
722
|
var walletItem = "WalletListItem_walletItem__1vrvezk1";
|
|
655
723
|
|
|
656
724
|
// src/components/connect-modal/wallet-list/WalletListItem.tsx
|
|
657
|
-
var
|
|
725
|
+
var import_jsx_runtime17 = require("react/jsx-runtime");
|
|
658
726
|
function WalletListItem({ name, icon: icon2, onClick, isSelected = false }) {
|
|
659
|
-
return /* @__PURE__ */ (0,
|
|
727
|
+
return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("li", { className: container7, children: /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(
|
|
660
728
|
"button",
|
|
661
729
|
{
|
|
662
730
|
className: (0, import_clsx6.clsx)(walletItem, { [selectedWalletItem]: isSelected }),
|
|
663
731
|
type: "button",
|
|
664
732
|
onClick,
|
|
665
733
|
children: [
|
|
666
|
-
typeof icon2 === "string" ? /* @__PURE__ */ (0,
|
|
667
|
-
/* @__PURE__ */ (0,
|
|
734
|
+
typeof icon2 === "string" ? /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("img", { className: walletIcon2, src: icon2, alt: `${name} logo` }) : icon2,
|
|
735
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(Heading, { size: "md", truncate: true, asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", { children: name }) })
|
|
668
736
|
]
|
|
669
737
|
}
|
|
670
738
|
) });
|
|
671
739
|
}
|
|
672
740
|
|
|
673
741
|
// src/components/connect-modal/wallet-list/WalletList.tsx
|
|
674
|
-
var
|
|
742
|
+
var import_jsx_runtime18 = require("react/jsx-runtime");
|
|
675
743
|
function WalletList({ selectedWalletName, onPlaceholderClick, onSelect }) {
|
|
676
744
|
const wallets = useWallets();
|
|
677
|
-
return /* @__PURE__ */ (0,
|
|
745
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("ul", { className: container6, children: wallets.length > 0 ? wallets.map((wallet) => /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
678
746
|
WalletListItem,
|
|
679
747
|
{
|
|
680
748
|
name: wallet.name,
|
|
@@ -683,11 +751,11 @@ function WalletList({ selectedWalletName, onPlaceholderClick, onSelect }) {
|
|
|
683
751
|
onClick: () => onSelect(wallet)
|
|
684
752
|
},
|
|
685
753
|
getWalletUniqueIdentifier(wallet)
|
|
686
|
-
)) : /* @__PURE__ */ (0,
|
|
754
|
+
)) : /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
687
755
|
WalletListItem,
|
|
688
756
|
{
|
|
689
757
|
name: "IOTA Wallet",
|
|
690
|
-
icon: /* @__PURE__ */ (0,
|
|
758
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(IotaIcon, { className: icon }),
|
|
691
759
|
onClick: onPlaceholderClick,
|
|
692
760
|
isSelected: true
|
|
693
761
|
}
|
|
@@ -695,12 +763,20 @@ function WalletList({ selectedWalletName, onPlaceholderClick, onSelect }) {
|
|
|
695
763
|
}
|
|
696
764
|
|
|
697
765
|
// src/components/connect-modal/ConnectModal.tsx
|
|
698
|
-
var
|
|
699
|
-
function ConnectModal({
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
766
|
+
var import_jsx_runtime19 = require("react/jsx-runtime");
|
|
767
|
+
function ConnectModal({
|
|
768
|
+
trigger,
|
|
769
|
+
open,
|
|
770
|
+
defaultOpen,
|
|
771
|
+
onOpenChange,
|
|
772
|
+
onConnected
|
|
773
|
+
}) {
|
|
774
|
+
const [isModalOpen, setModalOpen] = (0, import_react11.useState)(open ?? defaultOpen);
|
|
775
|
+
const [currentView, setCurrentView] = (0, import_react11.useState)();
|
|
776
|
+
const [selectedWallet, setSelectedWallet] = (0, import_react11.useState)();
|
|
777
|
+
const { mutate, isError } = useConnectWallet({
|
|
778
|
+
onConnected
|
|
779
|
+
});
|
|
704
780
|
const resetSelection = () => {
|
|
705
781
|
setSelectedWallet(void 0);
|
|
706
782
|
setCurrentView(void 0);
|
|
@@ -724,13 +800,13 @@ function ConnectModal({ trigger, open, defaultOpen, onOpenChange }) {
|
|
|
724
800
|
let modalContent;
|
|
725
801
|
switch (currentView) {
|
|
726
802
|
case "what-is-a-wallet":
|
|
727
|
-
modalContent = /* @__PURE__ */ (0,
|
|
803
|
+
modalContent = /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(WhatIsAWallet, {});
|
|
728
804
|
break;
|
|
729
805
|
case "getting-started":
|
|
730
|
-
modalContent = /* @__PURE__ */ (0,
|
|
806
|
+
modalContent = /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(GettingStarted, {});
|
|
731
807
|
break;
|
|
732
808
|
case "connection-status":
|
|
733
|
-
modalContent = /* @__PURE__ */ (0,
|
|
809
|
+
modalContent = /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
|
734
810
|
ConnectionStatus,
|
|
735
811
|
{
|
|
736
812
|
selectedWallet,
|
|
@@ -740,21 +816,21 @@ function ConnectModal({ trigger, open, defaultOpen, onOpenChange }) {
|
|
|
740
816
|
);
|
|
741
817
|
break;
|
|
742
818
|
default:
|
|
743
|
-
modalContent = /* @__PURE__ */ (0,
|
|
819
|
+
modalContent = /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(WhatIsAWallet, {});
|
|
744
820
|
}
|
|
745
|
-
return /* @__PURE__ */ (0,
|
|
746
|
-
/* @__PURE__ */ (0,
|
|
747
|
-
/* @__PURE__ */ (0,
|
|
748
|
-
/* @__PURE__ */ (0,
|
|
821
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(Dialog.Root, { open: open ?? isModalOpen, onOpenChange: handleOpenChange, children: [
|
|
822
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(Dialog.Trigger, { asChild: true, children: trigger }),
|
|
823
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(Dialog.Portal, { children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(StyleMarker, { children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(Dialog.Overlay, { className: overlay, children: /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(Dialog.Content, { className: content, "aria-describedby": void 0, children: [
|
|
824
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(
|
|
749
825
|
"div",
|
|
750
826
|
{
|
|
751
827
|
className: (0, import_clsx7.default)(walletListContainer, {
|
|
752
828
|
[walletListContainerWithViewSelected]: !!currentView
|
|
753
829
|
}),
|
|
754
830
|
children: [
|
|
755
|
-
/* @__PURE__ */ (0,
|
|
756
|
-
/* @__PURE__ */ (0,
|
|
757
|
-
/* @__PURE__ */ (0,
|
|
831
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { className: walletListContent, children: [
|
|
832
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(Dialog.Title, { className: title, asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(Heading, { as: "h2", children: "Connect a Wallet" }) }),
|
|
833
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
|
758
834
|
WalletList,
|
|
759
835
|
{
|
|
760
836
|
selectedWalletName: getWalletUniqueIdentifier(
|
|
@@ -770,7 +846,7 @@ function ConnectModal({ trigger, open, defaultOpen, onOpenChange }) {
|
|
|
770
846
|
}
|
|
771
847
|
)
|
|
772
848
|
] }),
|
|
773
|
-
/* @__PURE__ */ (0,
|
|
849
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
|
774
850
|
"button",
|
|
775
851
|
{
|
|
776
852
|
className: whatIsAWalletButton,
|
|
@@ -782,43 +858,53 @@ function ConnectModal({ trigger, open, defaultOpen, onOpenChange }) {
|
|
|
782
858
|
]
|
|
783
859
|
}
|
|
784
860
|
),
|
|
785
|
-
/* @__PURE__ */ (0,
|
|
861
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(
|
|
786
862
|
"div",
|
|
787
863
|
{
|
|
788
864
|
className: (0, import_clsx7.default)(viewContainer, {
|
|
789
865
|
[selectedViewContainer]: !!currentView
|
|
790
866
|
}),
|
|
791
867
|
children: [
|
|
792
|
-
/* @__PURE__ */ (0,
|
|
868
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)("div", { className: backButtonContainer, children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
|
793
869
|
IconButton,
|
|
794
870
|
{
|
|
795
871
|
type: "button",
|
|
796
872
|
"aria-label": "Back",
|
|
797
873
|
onClick: () => resetSelection(),
|
|
798
|
-
children: /* @__PURE__ */ (0,
|
|
874
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(BackIcon, {})
|
|
799
875
|
}
|
|
800
876
|
) }),
|
|
801
877
|
modalContent
|
|
802
878
|
]
|
|
803
879
|
}
|
|
804
880
|
),
|
|
805
|
-
/* @__PURE__ */ (0,
|
|
881
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(Dialog.Close, { className: closeButtonContainer, asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(IconButton, { type: "button", "aria-label": "Close", children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(CloseIcon, {}) }) })
|
|
806
882
|
] }) }) }) })
|
|
807
883
|
] });
|
|
808
884
|
}
|
|
809
885
|
|
|
810
886
|
// src/components/ConnectButton.tsx
|
|
811
|
-
var
|
|
887
|
+
var import_jsx_runtime20 = require("react/jsx-runtime");
|
|
812
888
|
function ConnectButton({
|
|
813
889
|
connectText = "Connect Wallet",
|
|
814
890
|
size,
|
|
891
|
+
iotaNamesEnabled = true,
|
|
892
|
+
onConnected,
|
|
815
893
|
...buttonProps
|
|
816
894
|
}) {
|
|
817
895
|
const currentAccount = useCurrentAccount();
|
|
818
|
-
return currentAccount ? /* @__PURE__ */ (0,
|
|
896
|
+
return currentAccount ? /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
897
|
+
AccountDropdownMenu,
|
|
898
|
+
{
|
|
899
|
+
currentAccount,
|
|
900
|
+
size,
|
|
901
|
+
iotaNamesEnabled
|
|
902
|
+
}
|
|
903
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
819
904
|
ConnectModal,
|
|
820
905
|
{
|
|
821
|
-
|
|
906
|
+
onConnected,
|
|
907
|
+
trigger: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(StyleMarker, { children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(Button, { ...buttonProps, size, children: connectText }) })
|
|
822
908
|
}
|
|
823
909
|
);
|
|
824
910
|
}
|