@xyo-network/react-wallet 2.64.0 → 2.64.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.
Files changed (94) hide show
  1. package/dist/browser/components/MaxAccounts/MaxAccountsTableRow.js +41 -11
  2. package/dist/browser/components/MaxAccounts/MaxAccountsTableRow.js.map +1 -1
  3. package/dist/browser/components/MaxAccounts/OutOfBoundsSnackBar.js +3 -2
  4. package/dist/browser/components/MaxAccounts/OutOfBoundsSnackBar.js.map +1 -1
  5. package/dist/browser/components/MaxAccounts/index.js +88 -1
  6. package/dist/browser/components/MaxAccounts/index.js.map +1 -1
  7. package/dist/browser/components/SeedPhrase/DefaultSeedPhrase.js +3 -2
  8. package/dist/browser/components/SeedPhrase/DefaultSeedPhrase.js.map +1 -1
  9. package/dist/browser/components/SeedPhrase/_shared/SeedPhraseIconButton.js +3 -2
  10. package/dist/browser/components/SeedPhrase/_shared/SeedPhraseIconButton.js.map +1 -1
  11. package/dist/browser/components/SeedPhrase/_shared/index.js +45 -1
  12. package/dist/browser/components/SeedPhrase/_shared/index.js.map +1 -1
  13. package/dist/browser/components/SeedPhrase/dialog/SeedPhraseDialog.js +295 -16
  14. package/dist/browser/components/SeedPhrase/dialog/SeedPhraseDialog.js.map +1 -1
  15. package/dist/browser/components/SeedPhrase/dialog/components/DialogActionButtons.js +13 -3
  16. package/dist/browser/components/SeedPhrase/dialog/components/DialogActionButtons.js.map +1 -1
  17. package/dist/browser/components/SeedPhrase/dialog/components/OverwriteWarning.js +13 -3
  18. package/dist/browser/components/SeedPhrase/dialog/components/OverwriteWarning.js.map +1 -1
  19. package/dist/browser/components/SeedPhrase/dialog/components/fields/NewPhraseTextField.js +74 -12
  20. package/dist/browser/components/SeedPhrase/dialog/components/fields/NewPhraseTextField.js.map +1 -1
  21. package/dist/browser/components/SeedPhrase/dialog/components/fields/SavedPhraseTextField.js +60 -10
  22. package/dist/browser/components/SeedPhrase/dialog/components/fields/SavedPhraseTextField.js.map +1 -1
  23. package/dist/browser/components/SeedPhrase/dialog/components/fields/index.js +125 -2
  24. package/dist/browser/components/SeedPhrase/dialog/components/fields/index.js.map +1 -1
  25. package/dist/browser/components/SeedPhrase/dialog/components/fields/validation-messages/InvalidPhrase.js +3 -2
  26. package/dist/browser/components/SeedPhrase/dialog/components/fields/validation-messages/InvalidPhrase.js.map +1 -1
  27. package/dist/browser/components/SeedPhrase/dialog/components/fields/validation-messages/PhraseHeaderBox.js +3 -2
  28. package/dist/browser/components/SeedPhrase/dialog/components/fields/validation-messages/PhraseHeaderBox.js.map +1 -1
  29. package/dist/browser/components/SeedPhrase/dialog/components/fields/validation-messages/colorParser.js +2 -1
  30. package/dist/browser/components/SeedPhrase/dialog/components/fields/validation-messages/colorParser.js.map +1 -1
  31. package/dist/browser/components/SeedPhrase/dialog/components/fields/validation-messages/index.js +57 -3
  32. package/dist/browser/components/SeedPhrase/dialog/components/fields/validation-messages/index.js.map +1 -1
  33. package/dist/browser/components/SeedPhrase/dialog/components/index.js +164 -3
  34. package/dist/browser/components/SeedPhrase/dialog/components/index.js.map +1 -1
  35. package/dist/browser/components/SeedPhrase/dialog/index.js +315 -1
  36. package/dist/browser/components/SeedPhrase/dialog/index.js.map +1 -1
  37. package/dist/browser/components/SeedPhrase/index.js +373 -4
  38. package/dist/browser/components/SeedPhrase/index.js.map +1 -1
  39. package/dist/browser/components/SeedPhrase/settings/SeedPhraseTableRow.js +325 -12
  40. package/dist/browser/components/SeedPhrase/settings/SeedPhraseTableRow.js.map +1 -1
  41. package/dist/browser/components/SeedPhrase/settings/index.js +339 -1
  42. package/dist/browser/components/SeedPhrase/settings/index.js.map +1 -1
  43. package/dist/browser/components/WalletAccountDetails/WalletAccountDetails.js +62 -3
  44. package/dist/browser/components/WalletAccountDetails/WalletAccountDetails.js.map +1 -1
  45. package/dist/browser/components/WalletAccountDetails/index.js +83 -1
  46. package/dist/browser/components/WalletAccountDetails/index.js.map +1 -1
  47. package/dist/browser/components/WalletAccountSelect/Select.js +70 -5
  48. package/dist/browser/components/WalletAccountSelect/Select.js.map +1 -1
  49. package/dist/browser/components/WalletAccountSelect/SelectBar.js +150 -4
  50. package/dist/browser/components/WalletAccountSelect/SelectBar.js.map +1 -1
  51. package/dist/browser/components/WalletAccountSelect/WalletInfo.js +116 -10
  52. package/dist/browser/components/WalletAccountSelect/WalletInfo.js.map +1 -1
  53. package/dist/browser/components/WalletAccountSelect/index.js +175 -2
  54. package/dist/browser/components/WalletAccountSelect/index.js.map +1 -1
  55. package/dist/browser/components/index.js +694 -4
  56. package/dist/browser/components/index.js.map +1 -1
  57. package/dist/browser/contexts/SeedPhrase/Context.js +2 -1
  58. package/dist/browser/contexts/SeedPhrase/Context.js.map +1 -1
  59. package/dist/browser/contexts/SeedPhrase/Provider.js +9 -3
  60. package/dist/browser/contexts/SeedPhrase/Provider.js.map +1 -1
  61. package/dist/browser/contexts/SeedPhrase/index.js +91 -4
  62. package/dist/browser/contexts/SeedPhrase/index.js.map +1 -1
  63. package/dist/browser/contexts/SeedPhrase/use.js +8 -2
  64. package/dist/browser/contexts/SeedPhrase/use.js.map +1 -1
  65. package/dist/browser/contexts/Wallet/Context.js +2 -1
  66. package/dist/browser/contexts/Wallet/Context.js.map +1 -1
  67. package/dist/browser/contexts/Wallet/Provider.js +90 -7
  68. package/dist/browser/contexts/Wallet/Provider.js.map +1 -1
  69. package/dist/browser/contexts/Wallet/index.js +183 -5
  70. package/dist/browser/contexts/Wallet/index.js.map +1 -1
  71. package/dist/browser/contexts/Wallet/lib/WalletPath.js +4 -3
  72. package/dist/browser/contexts/Wallet/lib/WalletPath.js.map +1 -1
  73. package/dist/browser/contexts/Wallet/lib/index.js +21 -1
  74. package/dist/browser/contexts/Wallet/lib/index.js.map +1 -1
  75. package/dist/browser/contexts/Wallet/use.js +13 -7
  76. package/dist/browser/contexts/Wallet/use.js.map +1 -1
  77. package/dist/browser/contexts/Wallet/usePromise.js +2 -1
  78. package/dist/browser/contexts/Wallet/usePromise.js.map +1 -1
  79. package/dist/browser/contexts/index.js +273 -2
  80. package/dist/browser/contexts/index.js.map +1 -1
  81. package/dist/browser/hooks/index.js +147 -4
  82. package/dist/browser/hooks/index.js.map +1 -1
  83. package/dist/browser/hooks/useAccount.js +24 -4
  84. package/dist/browser/hooks/useAccount.js.map +1 -1
  85. package/dist/browser/hooks/useWallet.js +38 -4
  86. package/dist/browser/hooks/useWallet.js.map +1 -1
  87. package/dist/browser/hooks/useWallets.js +69 -4
  88. package/dist/browser/hooks/useWallets.js.map +1 -1
  89. package/dist/browser/hooks/useWrapperAccount.js +4 -3
  90. package/dist/browser/hooks/useWrapperAccount.js.map +1 -1
  91. package/dist/browser/index.js +890 -3
  92. package/dist/browser/index.js.map +1 -1
  93. package/dist/docs.json +147 -147
  94. package/package.json +22 -22
@@ -1,5 +1,695 @@
1
- export * from "./MaxAccounts";
2
- export * from "./SeedPhrase";
3
- export * from "./WalletAccountDetails";
4
- export * from "./WalletAccountSelect";
1
+ // src/components/MaxAccounts/MaxAccountsTableRow.tsx
2
+ import { ButtonGroup, TableCell, TableRow, Typography } from "@mui/material";
3
+ import { ButtonEx } from "@xylabs/react-button";
4
+ import { useState } from "react";
5
+
6
+ // src/components/MaxAccounts/OutOfBoundsSnackBar.tsx
7
+ import { Alert, AlertTitle, Snackbar } from "@mui/material";
8
+ import { jsx, jsxs } from "react/jsx-runtime";
9
+ var OutOfBoundsSnackBar = ({
10
+ activeAccountIndex,
11
+ desiredMaximumAccounts,
12
+ setShowSnackBar,
13
+ showSnackBar
14
+ }) => {
15
+ return /* @__PURE__ */ jsx(
16
+ Snackbar,
17
+ {
18
+ anchorOrigin: { horizontal: "center", vertical: "top" },
19
+ autoHideDuration: 5e3,
20
+ onClose: () => setShowSnackBar?.(false),
21
+ open: showSnackBar,
22
+ children: /* @__PURE__ */ jsxs(Alert, { severity: "error", onClose: () => setShowSnackBar?.(false), children: [
23
+ /* @__PURE__ */ jsx(AlertTitle, { children: "Maximum Accounts Error" }),
24
+ "Your currently selected account number (",
25
+ activeAccountIndex !== void 0 ? activeAccountIndex + 1 : "",
26
+ ") cannot be greater than the desired Maximum Accounts (",
27
+ desiredMaximumAccounts,
28
+ ")."
29
+ ] })
30
+ }
31
+ );
32
+ };
33
+
34
+ // src/components/MaxAccounts/MaxAccountsTableRow.tsx
35
+ import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
36
+ var MaxAccountsTableRow = ({ activeAccountIndex, changeMaxAccounts, maxAccounts }) => {
37
+ const [desiredMaximumAccounts, setDesiredMaximumAccounts] = useState();
38
+ const [showSnackBar, setShowSnackBar] = useState(false);
39
+ const handleChangeMaxAccounts = (change) => {
40
+ if (maxAccounts !== void 0 && activeAccountIndex !== void 0) {
41
+ switch (change) {
42
+ case "decrease": {
43
+ const desiredMaximumAccounts2 = maxAccounts - 1;
44
+ const validMaximumAccounts = desiredMaximumAccounts2 > 0;
45
+ const maxAccountsWithinRange = activeAccountIndex + 1 <= desiredMaximumAccounts2;
46
+ if (validMaximumAccounts && maxAccountsWithinRange) {
47
+ changeMaxAccounts?.(desiredMaximumAccounts2);
48
+ }
49
+ if (!maxAccountsWithinRange)
50
+ setShowSnackBar(true);
51
+ setDesiredMaximumAccounts(desiredMaximumAccounts2);
52
+ return;
53
+ }
54
+ case "increase": {
55
+ changeMaxAccounts?.(maxAccounts + 1);
56
+ return;
57
+ }
58
+ default: {
59
+ console.error(change, "is not a recognized value");
60
+ }
61
+ }
62
+ } else {
63
+ throw new Error("Max Accounts is unset and needs a default");
64
+ }
65
+ };
66
+ return /* @__PURE__ */ jsxs2(TableRow, { children: [
67
+ /* @__PURE__ */ jsx2(TableCell, { children: "Maximum Accounts" }),
68
+ /* @__PURE__ */ jsx2(TableCell, { align: "center", children: /* @__PURE__ */ jsx2(Typography, { variant: "caption", children: maxAccounts }) }),
69
+ /* @__PURE__ */ jsxs2(TableCell, { align: "center", children: [
70
+ /* @__PURE__ */ jsxs2(ButtonGroup, { children: [
71
+ /* @__PURE__ */ jsx2(ButtonEx, { onClick: () => handleChangeMaxAccounts("decrease"), variant: "contained", size: "small", children: "-" }),
72
+ /* @__PURE__ */ jsx2(ButtonEx, { onClick: () => handleChangeMaxAccounts("increase"), variant: "contained", size: "small", children: "+" })
73
+ ] }),
74
+ /* @__PURE__ */ jsx2(
75
+ OutOfBoundsSnackBar,
76
+ {
77
+ desiredMaximumAccounts,
78
+ activeAccountIndex,
79
+ setShowSnackBar,
80
+ showSnackBar
81
+ }
82
+ )
83
+ ] })
84
+ ] });
85
+ };
86
+
87
+ // src/components/SeedPhrase/_shared/SeedPhraseIconButton.tsx
88
+ import { HelpOutline as HelpOutlineIcon } from "@mui/icons-material";
89
+ import {
90
+ Button,
91
+ Dialog,
92
+ DialogActions,
93
+ DialogContent,
94
+ DialogTitle,
95
+ IconButton,
96
+ Link,
97
+ List,
98
+ ListItem,
99
+ Typography as Typography2
100
+ } from "@mui/material";
101
+ import { useState as useState2 } from "react";
102
+ import { Fragment, jsx as jsx3, jsxs as jsxs3 } from "react/jsx-runtime";
103
+ var SeedPhraseIconButton = (props) => {
104
+ const [open, setOpen] = useState2(false);
105
+ const onClose = () => setOpen(false);
106
+ return /* @__PURE__ */ jsxs3(Fragment, { children: [
107
+ /* @__PURE__ */ jsx3(IconButton, { onClick: () => setOpen(true), ...props, children: /* @__PURE__ */ jsx3(HelpOutlineIcon, { fontSize: "small" }) }),
108
+ /* @__PURE__ */ jsxs3(Dialog, { open, children: [
109
+ /* @__PURE__ */ jsx3(DialogTitle, { children: "Understanding your Seed Phrase" }),
110
+ /* @__PURE__ */ jsxs3(DialogContent, { children: [
111
+ /* @__PURE__ */ jsxs3(Typography2, { children: [
112
+ "Your Seed Phrase should adhere to the",
113
+ " ",
114
+ /* @__PURE__ */ jsx3(Link, { target: "_blank", href: "https://github.com/bitcoin/bips/blob/master/bip-0039.mediawiki", children: "bip39 specification" }),
115
+ " ",
116
+ "and is used to generate accounts which identify your data on the XYO Network."
117
+ ] }),
118
+ /* @__PURE__ */ jsxs3(List, { children: [
119
+ /* @__PURE__ */ jsx3(ListItem, { children: "Do not share this phrase with anyone." }),
120
+ /* @__PURE__ */ jsx3(ListItem, { children: "Do not save it to a public computer." }),
121
+ /* @__PURE__ */ jsx3(ListItem, { children: "Do not use a existing phrase from another wallet (i.e. Metamask)." }),
122
+ /* @__PURE__ */ jsx3(ListItem, { children: "Do not use before copying it down somewhere safe." })
123
+ ] })
124
+ ] }),
125
+ /* @__PURE__ */ jsx3(DialogActions, { children: /* @__PURE__ */ jsx3(Button, { onClick: onClose, variant: "outlined", children: "OK" }) })
126
+ ] })
127
+ ] });
128
+ };
129
+
130
+ // src/components/SeedPhrase/DefaultSeedPhrase.tsx
131
+ import { Alert as Alert2, AlertTitle as AlertTitle2, Snackbar as Snackbar2 } from "@mui/material";
132
+ import { generateMnemonic, wordlists } from "@xyo-network/bip39";
133
+ import { useEffect, useState as useState3 } from "react";
134
+ import { Fragment as Fragment2, jsx as jsx4, jsxs as jsxs4 } from "react/jsx-runtime";
135
+ var DefaultSeedPhrase = ({ changeSeedPhrase, children, hideDefaultSeedPhraseMessage, seedPhrase }) => {
136
+ const [showSnackBar, setShowSnackBar] = useState3(false);
137
+ useEffect(() => {
138
+ if (!seedPhrase) {
139
+ const mnemonic = generateMnemonic(wordlists.english, 256);
140
+ changeSeedPhrase?.(mnemonic);
141
+ setShowSnackBar(true);
142
+ }
143
+ }, [changeSeedPhrase, seedPhrase]);
144
+ return /* @__PURE__ */ jsxs4(Fragment2, { children: [
145
+ hideDefaultSeedPhraseMessage ? null : /* @__PURE__ */ jsx4(
146
+ Snackbar2,
147
+ {
148
+ open: showSnackBar,
149
+ autoHideDuration: 5e3,
150
+ onClose: () => setShowSnackBar(false),
151
+ anchorOrigin: { horizontal: "center", vertical: "top" },
152
+ children: /* @__PURE__ */ jsxs4(Alert2, { severity: "success", children: [
153
+ /* @__PURE__ */ jsx4(AlertTitle2, { children: "Default Seed Phrase Generated" }),
154
+ "Go to application settings to save it."
155
+ ] })
156
+ }
157
+ ),
158
+ children
159
+ ] });
160
+ };
161
+
162
+ // src/components/SeedPhrase/dialog/SeedPhraseDialog.tsx
163
+ import { Dialog as Dialog2, DialogContent as DialogContent2, DialogTitle as DialogTitle2 } from "@mui/material";
164
+
165
+ // src/contexts/SeedPhrase/Context.ts
166
+ import { createContextEx } from "@xyo-network/react-shared";
167
+ var SeedPhraseContext = createContextEx();
168
+
169
+ // src/contexts/SeedPhrase/Provider.tsx
170
+ import { generateMnemonic as generateMnemonic2, validateMnemonic, wordlists as wordlists2 } from "@xyo-network/bip39";
171
+ import { useEffect as useEffect2, useMemo, useState as useState4 } from "react";
172
+ import { jsx as jsx5 } from "react/jsx-runtime";
173
+ var SeedPhraseProvider = ({
174
+ children,
175
+ defaultPhrase,
176
+ handleChangeSeedPhrase,
177
+ saveCallback,
178
+ seedPhrase,
179
+ open
180
+ }) => {
181
+ const [phrase, setPhrase] = useState4();
182
+ const [overwriteWarning, setOverwriteWarning] = useState4(false);
183
+ useEffect2(() => {
184
+ setPhrase(defaultPhrase);
185
+ }, [defaultPhrase]);
186
+ useEffect2(() => {
187
+ if (!open) {
188
+ handleCancelOverwrite();
189
+ }
190
+ }, [open]);
191
+ useEffect2(() => {
192
+ if (seedPhrase || open) {
193
+ setPhrase?.(seedPhrase ?? "");
194
+ }
195
+ }, [seedPhrase, open, setPhrase]);
196
+ const handleGenerate = () => {
197
+ const mnemonic = generateMnemonic2(wordlists2.english, 256);
198
+ setPhrase?.(mnemonic);
199
+ setOverwriteWarning?.(false);
200
+ };
201
+ const handleCancelOverwrite = () => {
202
+ setOverwriteWarning?.(false);
203
+ };
204
+ const handleClear = () => {
205
+ setPhrase?.("");
206
+ setOverwriteWarning?.(false);
207
+ };
208
+ const handleSave = () => {
209
+ if (!overwriteWarning && seedPhrase && seedPhrase !== phrase) {
210
+ setOverwriteWarning?.(true);
211
+ } else {
212
+ handleChangeSeedPhrase?.(phrase ?? "");
213
+ saveCallback?.();
214
+ }
215
+ };
216
+ const validate = (passedPhrase) => {
217
+ if (!passedPhrase) {
218
+ return null;
219
+ }
220
+ return validateMnemonic(passedPhrase, wordlists2.english);
221
+ };
222
+ const validSeedPhrase = useMemo(() => validate?.(seedPhrase), [seedPhrase]);
223
+ const validPhrase = useMemo(() => validate?.(phrase), [phrase]);
224
+ return /* @__PURE__ */ jsx5(
225
+ SeedPhraseContext.Provider,
226
+ {
227
+ value: {
228
+ handleCancelOverwrite,
229
+ handleChangeSeedPhrase,
230
+ handleClear,
231
+ handleGenerate,
232
+ handleSave,
233
+ overwriteWarning,
234
+ phrase,
235
+ provided: true,
236
+ seedPhrase,
237
+ setOverwriteWarning,
238
+ setPhrase,
239
+ validPhrase,
240
+ validSeedPhrase,
241
+ validate
242
+ },
243
+ children
244
+ }
245
+ );
246
+ };
247
+
248
+ // src/contexts/SeedPhrase/use.tsx
249
+ import { useContextEx } from "@xyo-network/react-shared";
250
+ var useSeedPhrase = () => useContextEx(SeedPhraseContext, "SeedPhrase", true);
251
+
252
+ // src/contexts/Wallet/Context.ts
253
+ import { createContextEx as createContextEx2 } from "@xyo-network/react-shared";
254
+ var WalletContext = createContextEx2();
255
+
256
+ // src/contexts/Wallet/use.ts
257
+ import { usePromise } from "@xylabs/react-promise";
258
+ import { useContextEx as useContextEx2, useProvided } from "@xyo-network/react-shared";
259
+ var useWalletContext = (required = true) => {
260
+ return useContextEx2(WalletContext, "Wallet", required);
261
+ };
262
+ var useWalletProvided = () => {
263
+ return useProvided(WalletContext);
264
+ };
265
+ var useCoinTypeWallet = (required = true) => {
266
+ const { coinTypeWallet } = useWalletContext(required);
267
+ return [coinTypeWallet, void 0];
268
+ };
269
+ var useIndexedWalletFromContext = (index, required = true) => {
270
+ const [coinTypeWallet] = useCoinTypeWallet(required);
271
+ const [wallet] = usePromise(async () => await coinTypeWallet?.derivePath(index.toString()) ?? coinTypeWallet, [coinTypeWallet, index]);
272
+ return [wallet, void 0];
273
+ };
274
+ var useSelectedWalletAccount = (required = true) => {
275
+ const { activeAccountIndex } = useWalletContext(required);
276
+ const [account] = useIndexedWalletFromContext(activeAccountIndex ?? 0, required);
277
+ if (activeAccountIndex === void 0 && account === null) {
278
+ return [null, void 0];
279
+ } else {
280
+ return [account, void 0];
281
+ }
282
+ };
283
+
284
+ // src/components/SeedPhrase/dialog/components/DialogActionButtons.tsx
285
+ import { Button as Button2, DialogActions as DialogActions2 } from "@mui/material";
286
+ import { jsx as jsx6, jsxs as jsxs5 } from "react/jsx-runtime";
287
+ var DialogActionButtons = ({ onClose, ...props }) => {
288
+ const { handleSave, setPhrase } = useSeedPhrase();
289
+ const wrappedOnClose = (e) => {
290
+ setPhrase?.("");
291
+ onClose?.(e, "escapeKeyDown");
292
+ };
293
+ return /* @__PURE__ */ jsxs5(DialogActions2, { ...props, children: [
294
+ /* @__PURE__ */ jsx6(Button2, { variant: "outlined", onClick: wrappedOnClose, children: "Cancel" }),
295
+ /* @__PURE__ */ jsx6(Button2, { variant: "outlined", onClick: handleSave, children: "Save" })
296
+ ] });
297
+ };
298
+
299
+ // src/components/SeedPhrase/dialog/components/fields/NewPhraseTextField.tsx
300
+ import { Button as Button3, DialogActions as DialogActions3, FormControl, FormLabel, TextField } from "@mui/material";
301
+
302
+ // src/components/SeedPhrase/dialog/components/fields/validation-messages/colorParser.ts
303
+ var colorParser = (conditional) => {
304
+ switch (conditional) {
305
+ case true:
306
+ return "success";
307
+ case false:
308
+ return "error";
309
+ default:
310
+ return void 0;
311
+ }
312
+ };
313
+
314
+ // src/components/SeedPhrase/dialog/components/fields/validation-messages/InvalidPhrase.tsx
315
+ import { Link as Link2, Typography as Typography3 } from "@mui/material";
316
+ import { jsx as jsx7, jsxs as jsxs6 } from "react/jsx-runtime";
317
+ var InvalidPhraseTypography = (props) => /* @__PURE__ */ jsxs6(Typography3, { variant: "caption", color: "error", ...props, children: [
318
+ "Invalid seed phrase. See -",
319
+ " ",
320
+ /* @__PURE__ */ jsx7(Link2, { target: "_blank", href: "https://github.com/bitcoin/bips/blob/master/bip-0039.mediawiki", children: "bip39 Proposal" })
321
+ ] });
322
+
323
+ // src/components/SeedPhrase/dialog/components/fields/validation-messages/PhraseHeaderBox.tsx
324
+ import { CheckCircleOutline as CheckCircleOutlineIcon, HighlightOff as HighlightOffIcon } from "@mui/icons-material";
325
+ import { FlexRow } from "@xylabs/react-flexbox";
326
+ import { useMemo as useMemo2 } from "react";
327
+ import { jsx as jsx8, jsxs as jsxs7 } from "react/jsx-runtime";
328
+ var PhraseHeaderBox = ({ children, conditional, ...props }) => {
329
+ const state = useMemo2(() => {
330
+ switch (conditional) {
331
+ case true:
332
+ return "success";
333
+ case false:
334
+ return "error";
335
+ default:
336
+ return null;
337
+ }
338
+ }, [conditional]);
339
+ const Icon = useMemo2(() => {
340
+ switch (state) {
341
+ case "success":
342
+ return /* @__PURE__ */ jsx8(CheckCircleOutlineIcon, { fontSize: "small", color: "success" });
343
+ case "error":
344
+ return /* @__PURE__ */ jsx8(HighlightOffIcon, { fontSize: "small", color: "error" });
345
+ default:
346
+ return null;
347
+ }
348
+ }, [state]);
349
+ return /* @__PURE__ */ jsxs7(FlexRow, { justifyContent: "start", columnGap: 1, ...props, children: [
350
+ Icon,
351
+ children
352
+ ] });
353
+ };
354
+
355
+ // src/components/SeedPhrase/dialog/components/fields/NewPhraseTextField.tsx
356
+ import { Fragment as Fragment3, jsx as jsx9, jsxs as jsxs8 } from "react/jsx-runtime";
357
+ var NewPhraseTextField = (props) => {
358
+ const { handleClear, handleGenerate, overwriteWarning, phrase, setPhrase, validPhrase } = useSeedPhrase();
359
+ return /* @__PURE__ */ jsxs8(Fragment3, { children: [
360
+ /* @__PURE__ */ jsxs8(FormControl, { fullWidth: true, size: "small", sx: { display: "flex", flexDirection: "column", rowGap: 1 }, children: [
361
+ /* @__PURE__ */ jsx9(FormLabel, { children: /* @__PURE__ */ jsx9(PhraseHeaderBox, { conditional: validPhrase, children: "New Seed Phrase" }) }),
362
+ /* @__PURE__ */ jsx9(
363
+ TextField,
364
+ {
365
+ focused: true,
366
+ color: colorParser(validPhrase),
367
+ error: validPhrase === false,
368
+ helperText: validPhrase === false ? /* @__PURE__ */ jsx9(InvalidPhraseTypography, {}) : null,
369
+ fullWidth: true,
370
+ maxRows: Infinity,
371
+ multiline: true,
372
+ onChange: (e) => setPhrase?.(e.target.value),
373
+ value: phrase,
374
+ ...props
375
+ }
376
+ )
377
+ ] }),
378
+ /* @__PURE__ */ jsxs8(DialogActions3, { sx: { justifyContent: "center" }, children: [
379
+ /* @__PURE__ */ jsx9(Button3, { disabled: overwriteWarning, variant: "outlined", onClick: handleGenerate, children: "Generate" }),
380
+ /* @__PURE__ */ jsx9(Button3, { variant: "outlined", onClick: handleClear, children: "Clear" })
381
+ ] })
382
+ ] });
383
+ };
384
+
385
+ // src/components/SeedPhrase/dialog/components/fields/SavedPhraseTextField.tsx
386
+ import { Chip, FormControl as FormControl2, FormLabel as FormLabel2, TextField as TextField2 } from "@mui/material";
387
+ import { useState as useState5 } from "react";
388
+ import { Fragment as Fragment4, jsx as jsx10, jsxs as jsxs9 } from "react/jsx-runtime";
389
+ var SavedPhraseTextField = (props) => {
390
+ const { validSeedPhrase, seedPhrase } = useSeedPhrase();
391
+ const [visible, setVisible] = useState5(false);
392
+ return /* @__PURE__ */ jsxs9(FormControl2, { fullWidth: true, size: "small", sx: { display: "flex", flexDirection: "column", rowGap: 1 }, children: [
393
+ /* @__PURE__ */ jsx10(Chip, { label: visible ? "Hide Saved Seed Phrase" : "Reveal Saved Seed Phrase", onClick: () => setVisible(!visible) }),
394
+ visible ? /* @__PURE__ */ jsxs9(Fragment4, { children: [
395
+ /* @__PURE__ */ jsx10(FormLabel2, { children: /* @__PURE__ */ jsx10(PhraseHeaderBox, { conditional: validSeedPhrase, children: "Saved Seed Phrase" }) }),
396
+ /* @__PURE__ */ jsx10(
397
+ TextField2,
398
+ {
399
+ defaultValue: seedPhrase,
400
+ disabled: true,
401
+ error: validSeedPhrase === false,
402
+ helperText: validSeedPhrase === false ? /* @__PURE__ */ jsx10(InvalidPhraseTypography, {}) : null,
403
+ fullWidth: true,
404
+ maxRows: Infinity,
405
+ multiline: true,
406
+ ...props
407
+ }
408
+ )
409
+ ] }) : null
410
+ ] });
411
+ };
412
+
413
+ // src/components/SeedPhrase/dialog/components/OverwriteWarning.tsx
414
+ import { Alert as Alert3, Button as Button4 } from "@mui/material";
415
+ import { FlexRow as FlexRow2 } from "@xylabs/react-flexbox";
416
+ import { jsx as jsx11, jsxs as jsxs10 } from "react/jsx-runtime";
417
+ var OverwriteWarning = () => {
418
+ const { handleCancelOverwrite, handleSave } = useSeedPhrase();
419
+ return /* @__PURE__ */ jsx11(
420
+ Alert3,
421
+ {
422
+ variant: "outlined",
423
+ severity: "warning",
424
+ action: /* @__PURE__ */ jsxs10(FlexRow2, { sx: { columnGap: 1 }, children: [
425
+ /* @__PURE__ */ jsx11(Button4, { variant: "outlined", color: "inherit", size: "small", onClick: handleSave, children: "Overwrite" }),
426
+ /* @__PURE__ */ jsx11(Button4, { variant: "outlined", color: "inherit", size: "small", onClick: handleCancelOverwrite, children: "Cancel" })
427
+ ] }),
428
+ children: "Are you sure you want to overwrite existing seed phrase? This action cannot be undone."
429
+ }
430
+ );
431
+ };
432
+
433
+ // src/components/SeedPhrase/dialog/SeedPhraseDialog.tsx
434
+ import { jsx as jsx12, jsxs as jsxs11 } from "react/jsx-runtime";
435
+ var SeedPhraseDialog = ({ changeSeedPhrase, seedPhrase, ...props }) => {
436
+ return /* @__PURE__ */ jsx12(
437
+ SeedPhraseProvider,
438
+ {
439
+ seedPhrase,
440
+ handleChangeSeedPhrase: changeSeedPhrase,
441
+ open: props.open,
442
+ saveCallback: () => props.onClose?.({}, "escapeKeyDown"),
443
+ children: /* @__PURE__ */ jsx12(SeedPhraseDialogInner, { ...props })
444
+ }
445
+ );
446
+ };
447
+ var SeedPhraseDialogInner = (props) => {
448
+ const { overwriteWarning, seedPhrase } = useSeedPhrase();
449
+ return /* @__PURE__ */ jsxs11(Dialog2, { "aria-labelledby": "alert-dialog-title", "aria-describedby": "alert-dialog-description", fullWidth: true, maxWidth: "sm", ...props, children: [
450
+ /* @__PURE__ */ jsxs11(DialogTitle2, { id: "alert-dialog-title", children: [
451
+ "Update Your Seed Phrase ",
452
+ /* @__PURE__ */ jsx12(SeedPhraseIconButton, {})
453
+ ] }),
454
+ /* @__PURE__ */ jsxs11(DialogContent2, { sx: { display: "flex", flexDirection: "column", rowGap: 2 }, children: [
455
+ /* @__PURE__ */ jsx12(NewPhraseTextField, {}),
456
+ seedPhrase ? /* @__PURE__ */ jsx12(SavedPhraseTextField, {}) : null,
457
+ overwriteWarning ? /* @__PURE__ */ jsx12(OverwriteWarning, {}) : null
458
+ ] }),
459
+ /* @__PURE__ */ jsx12(DialogActionButtons, { onClose: props.onClose })
460
+ ] });
461
+ };
462
+
463
+ // src/components/SeedPhrase/settings/SeedPhraseTableRow.tsx
464
+ import { Cancel as CancelIcon, RadioButtonChecked as RadioButtonCheckedIcon } from "@mui/icons-material";
465
+ import { Button as Button5, ButtonGroup as ButtonGroup2, TableCell as TableCell2, TableRow as TableRow2 } from "@mui/material";
466
+ import { useState as useState6 } from "react";
467
+ import { jsx as jsx13, jsxs as jsxs12 } from "react/jsx-runtime";
468
+ var SeedPhraseTableRow = ({ changeSeedPhrase, seedPhrase, ...props }) => {
469
+ const [open, setOpen] = useState6(false);
470
+ const handleOpen = () => {
471
+ setOpen(true);
472
+ };
473
+ return /* @__PURE__ */ jsxs12(TableRow2, { ...props, children: [
474
+ /* @__PURE__ */ jsxs12(TableCell2, { children: [
475
+ "Seed Phrase ",
476
+ /* @__PURE__ */ jsx13(SeedPhraseIconButton, {})
477
+ ] }),
478
+ /* @__PURE__ */ jsx13(TableCell2, { align: "center", children: seedPhrase ? /* @__PURE__ */ jsx13(RadioButtonCheckedIcon, { color: "success" }) : /* @__PURE__ */ jsx13(CancelIcon, { color: "error" }) }),
479
+ /* @__PURE__ */ jsxs12(TableCell2, { children: [
480
+ /* @__PURE__ */ jsx13(SeedPhraseDialog, { changeSeedPhrase, open, onClose: () => setOpen(false), seedPhrase }),
481
+ /* @__PURE__ */ jsx13(ButtonGroup2, { fullWidth: true, children: /* @__PURE__ */ jsx13(Button5, { variant: "contained", size: "small", onClick: handleOpen, children: "Update" }) })
482
+ ] })
483
+ ] });
484
+ };
485
+
486
+ // src/components/WalletAccountDetails/WalletAccountDetails.tsx
487
+ import { EthAddress } from "@xylabs/eth-address";
488
+ import { EthAccountButton } from "@xylabs/react-crypto";
489
+ import { FlexCol, FlexRow as FlexRow3 } from "@xylabs/react-flexbox";
490
+ import { NumberStatus } from "@xylabs/react-number-status";
491
+ import { useNetwork } from "@xyo-network/react-network";
492
+
493
+ // src/hooks/useAccount.ts
494
+ import { usePromise as usePromise2 } from "@xylabs/react-promise";
495
+ import { useState as useState7 } from "react";
496
+ var useAccount = ({ wallet, account, index, required = false } = {}) => {
497
+ const walletContextProvided = useWalletProvided();
498
+ const [validationError, setValidationError] = useState7();
499
+ if (wallet && account && !validationError) {
500
+ setValidationError(Error("useAccount can not have both a wallet and an account in the parameters"));
501
+ }
502
+ if (index && account && !validationError) {
503
+ setValidationError(Error("useAccount can not have both a index and an account in the parameters"));
504
+ }
505
+ const [error, setError] = useState7();
506
+ const [coinTypeWallet] = useCoinTypeWallet(!wallet && required);
507
+ const { activeAccountIndex } = useWalletContext(false);
508
+ const [activeAccount] = usePromise2(async () => {
509
+ try {
510
+ if (!validationError) {
511
+ if (wallet) {
512
+ return await wallet?.derivePath?.(`${index ?? 0}'\0`);
513
+ } else if (coinTypeWallet) {
514
+ return await coinTypeWallet?.derivePath?.(`${index ?? activeAccountIndex ?? 0}'\0`);
515
+ }
516
+ }
517
+ } catch (ex) {
518
+ const error2 = ex;
519
+ console.error(error2.message);
520
+ setError(error2);
521
+ }
522
+ }, [index, wallet, coinTypeWallet, activeAccountIndex, validationError]);
523
+ if (validationError && !error) {
524
+ console.error(validationError.message);
525
+ setError(validationError);
526
+ }
527
+ return [error ? void 0 : account ?? activeAccount ?? walletContextProvided ? null : void 0, error];
528
+ };
529
+
530
+ // src/hooks/useWallet.ts
531
+ import { usePromise as usePromise3 } from "@xylabs/react-promise";
532
+ import { HDWallet } from "@xyo-network/account";
533
+ import { useState as useState8 } from "react";
534
+ var useWallet = ({ mnemonic, wallet, path, required = false, seed } = {}) => {
535
+ const walletContextProvided = useWalletProvided();
536
+ const [error, setError] = useState8();
537
+ const [contextAccount] = useSelectedWalletAccount(!wallet && required);
538
+ const [activeAccount] = usePromise3(async () => {
539
+ try {
540
+ const newAccount = await (() => {
541
+ if (wallet) {
542
+ return wallet;
543
+ } else if (mnemonic) {
544
+ return HDWallet.fromMnemonic(mnemonic);
545
+ } else if (seed) {
546
+ return HDWallet.fromSeed(seed);
547
+ }
548
+ return contextAccount;
549
+ })();
550
+ if (path) {
551
+ return newAccount?.derivePath?.(path);
552
+ } else {
553
+ return newAccount ?? wallet;
554
+ }
555
+ } catch (ex) {
556
+ setError(ex);
557
+ }
558
+ }, [mnemonic, contextAccount, seed, path, wallet]);
559
+ return [activeAccount ?? (walletContextProvided ? null : activeAccount), error];
560
+ };
561
+
562
+ // src/components/WalletAccountDetails/WalletAccountDetails.tsx
563
+ import { jsx as jsx14, jsxs as jsxs13 } from "react/jsx-runtime";
564
+ var WalletAccountDetails = ({ exploreUrl = "https://explore.xyo.network", account, ...props }) => {
565
+ const [accountToUse] = useAccount({ account });
566
+ const { network } = useNetwork();
567
+ const exploreAddressUrl = `${exploreUrl}/recent?account=${accountToUse?.address}&network=${network?.name ?? "main"}`;
568
+ return /* @__PURE__ */ jsxs13(FlexCol, { ...props, children: [
569
+ /* @__PURE__ */ jsx14(EthAccountButton, { address: EthAddress.fromString(accountToUse?.address) }),
570
+ /* @__PURE__ */ jsxs13(FlexRow3, { gap: 1, children: [
571
+ /* @__PURE__ */ jsx14(NumberStatus, { rounded: true, title: "Tokens", value: 0, to: `${exploreAddressUrl}&schema=network.xyo.account.tokens`, target: "_blank" }),
572
+ /* @__PURE__ */ jsx14(NumberStatus, { rounded: true, title: "NFTs", value: 0, to: `${exploreAddressUrl}&schema=network.xyo.account.nfts`, target: "_blank" }),
573
+ /* @__PURE__ */ jsx14(NumberStatus, { rounded: true, title: "Signatures", value: 0, to: `${exploreAddressUrl}&schema=network.xyo.account.signatures`, target: "_blank" }),
574
+ /* @__PURE__ */ jsx14(NumberStatus, { rounded: true, title: "Signins", value: 0, to: `${exploreAddressUrl}&schema=network.xyo.account.signins`, target: "_blank" })
575
+ ] })
576
+ ] });
577
+ };
578
+
579
+ // src/components/WalletAccountSelect/Select.tsx
580
+ import { CircularProgress, MenuItem } from "@mui/material";
581
+ import { SelectEx } from "@xylabs/react-select";
582
+ import { AddressRenderRowBox } from "@xyo-network/react-address-render";
583
+ import { Fragment as Fragment5, jsx as jsx15 } from "react/jsx-runtime";
584
+ var arrayRange = (length, start = 0) => {
585
+ return Array.from(Array(length).keys()).map((x) => x + start);
586
+ };
587
+ var WalletAccountSelect = ({
588
+ addressNames = {},
589
+ iconOnly,
590
+ iconSize = 24,
591
+ icons,
592
+ maxAccounts = 1,
593
+ showFavorite = false,
594
+ size,
595
+ ...props
596
+ }) => {
597
+ const { activeAccountIndex = 0, setActiveAccountIndex, coinTypeWallet } = useWalletContext();
598
+ const disabled = !coinTypeWallet || activeAccountIndex === void 0;
599
+ return /* @__PURE__ */ jsx15(Fragment5, { children: coinTypeWallet ? /* @__PURE__ */ jsx15(
600
+ SelectEx,
601
+ {
602
+ margin: "dense",
603
+ disabled,
604
+ renderValue: (selectedAccountIndex) => {
605
+ const Item = () => {
606
+ const [selectedAccount] = useWallet({ path: selectedAccountIndex.toString(), wallet: coinTypeWallet });
607
+ const customName = selectedAccount ? addressNames[selectedAccount.address] : void 0;
608
+ const favorite = !!selectedAccount && selectedAccount.address in addressNames;
609
+ return /* @__PURE__ */ jsx15(MenuItem, { value: selectedAccountIndex, sx: { minHeight: 0, paddingBottom: 0, paddingTop: 0 }, children: /* @__PURE__ */ jsx15(
610
+ AddressRenderRowBox,
611
+ {
612
+ disableSharedRef: true,
613
+ flexGrow: 1,
614
+ address: selectedAccount?.address,
615
+ iconOnly,
616
+ iconSize,
617
+ icons,
618
+ name: customName,
619
+ favorite,
620
+ showFavorite
621
+ }
622
+ ) });
623
+ };
624
+ return /* @__PURE__ */ jsx15(Item, {});
625
+ },
626
+ value: activeAccountIndex,
627
+ onChange: (event) => setActiveAccountIndex?.(parseInt(`${event.target.value}`)),
628
+ size,
629
+ variant: "outlined",
630
+ ...props,
631
+ children: arrayRange(maxAccounts).map((index) => {
632
+ const Item = () => {
633
+ const [account] = useWallet({ path: index.toString(), wallet: coinTypeWallet });
634
+ const customName = account ? addressNames[account.address] : void 0;
635
+ const favorite = !!account && account.address in addressNames;
636
+ return /* @__PURE__ */ jsx15(MenuItem, { value: index, sx: { minHeight: 0, paddingBottom: 0, paddingTop: 0 }, children: /* @__PURE__ */ jsx15(
637
+ AddressRenderRowBox,
638
+ {
639
+ disableSharedRef: true,
640
+ flexGrow: 1,
641
+ address: account?.address,
642
+ favorite,
643
+ iconOnly,
644
+ iconSize,
645
+ icons,
646
+ name: customName,
647
+ showFavorite
648
+ }
649
+ ) }, account?.address);
650
+ };
651
+ return /* @__PURE__ */ jsx15(Item, {}, index);
652
+ })
653
+ }
654
+ ) : /* @__PURE__ */ jsx15(CircularProgress, { size: 24 }) });
655
+ };
656
+
657
+ // src/components/WalletAccountSelect/SelectBar.tsx
658
+ import { FlexCol as FlexCol2 } from "@xylabs/react-flexbox";
659
+ import { jsx as jsx16 } from "react/jsx-runtime";
660
+ var WalletAccountSelectBar = ({
661
+ addressNames = {},
662
+ iconOnly,
663
+ iconSize,
664
+ icons,
665
+ maxAccounts = 1,
666
+ showFavorite = false,
667
+ size = "small",
668
+ ...props
669
+ }) => {
670
+ return /* @__PURE__ */ jsx16(FlexCol2, { alignItems: "stretch", ...props, children: /* @__PURE__ */ jsx16(
671
+ WalletAccountSelect,
672
+ {
673
+ addressNames,
674
+ fullWidth: true,
675
+ showFavorite,
676
+ iconSize,
677
+ iconOnly,
678
+ icons,
679
+ maxAccounts,
680
+ size: size ?? "small"
681
+ }
682
+ ) });
683
+ };
684
+ export {
685
+ DefaultSeedPhrase,
686
+ MaxAccountsTableRow,
687
+ SeedPhraseDialog,
688
+ SeedPhraseDialogInner,
689
+ SeedPhraseIconButton,
690
+ SeedPhraseTableRow,
691
+ WalletAccountDetails,
692
+ WalletAccountSelect,
693
+ WalletAccountSelectBar
694
+ };
5
695
  //# sourceMappingURL=index.js.map