@xyo-network/react-wallet 2.77.0 → 2.77.2

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 (68) hide show
  1. package/dist/browser/components/SeedPhrase/dialog/components/fields/SavedPhraseTextField.d.cts +1 -0
  2. package/dist/browser/components/SeedPhrase/dialog/components/fields/SavedPhraseTextField.d.cts.map +1 -1
  3. package/dist/browser/components/SeedPhrase/dialog/components/fields/SavedPhraseTextField.d.mts +1 -0
  4. package/dist/browser/components/SeedPhrase/dialog/components/fields/SavedPhraseTextField.d.mts.map +1 -1
  5. package/dist/browser/components/SeedPhrase/dialog/components/fields/SavedPhraseTextField.d.ts +1 -0
  6. package/dist/browser/components/SeedPhrase/dialog/components/fields/SavedPhraseTextField.d.ts.map +1 -1
  7. package/dist/browser/contexts/Wallet/State.d.cts +0 -4
  8. package/dist/browser/contexts/Wallet/State.d.cts.map +1 -1
  9. package/dist/browser/contexts/Wallet/State.d.mts +0 -4
  10. package/dist/browser/contexts/Wallet/State.d.mts.map +1 -1
  11. package/dist/browser/contexts/Wallet/State.d.ts +0 -4
  12. package/dist/browser/contexts/Wallet/State.d.ts.map +1 -1
  13. package/dist/browser/contexts/Wallet/usePromise.d.cts +0 -3
  14. package/dist/browser/contexts/Wallet/usePromise.d.cts.map +1 -1
  15. package/dist/browser/contexts/Wallet/usePromise.d.mts +0 -3
  16. package/dist/browser/contexts/Wallet/usePromise.d.mts.map +1 -1
  17. package/dist/browser/contexts/Wallet/usePromise.d.ts +0 -3
  18. package/dist/browser/contexts/Wallet/usePromise.d.ts.map +1 -1
  19. package/dist/browser/index.cjs +1 -814
  20. package/dist/browser/index.cjs.map +1 -1
  21. package/dist/browser/index.js +1 -802
  22. package/dist/browser/index.js.map +1 -1
  23. package/dist/neutral/components/SeedPhrase/dialog/components/fields/SavedPhraseTextField.d.cts +1 -0
  24. package/dist/neutral/components/SeedPhrase/dialog/components/fields/SavedPhraseTextField.d.cts.map +1 -1
  25. package/dist/neutral/components/SeedPhrase/dialog/components/fields/SavedPhraseTextField.d.mts +1 -0
  26. package/dist/neutral/components/SeedPhrase/dialog/components/fields/SavedPhraseTextField.d.mts.map +1 -1
  27. package/dist/neutral/components/SeedPhrase/dialog/components/fields/SavedPhraseTextField.d.ts +1 -0
  28. package/dist/neutral/components/SeedPhrase/dialog/components/fields/SavedPhraseTextField.d.ts.map +1 -1
  29. package/dist/neutral/contexts/Wallet/State.d.cts +0 -4
  30. package/dist/neutral/contexts/Wallet/State.d.cts.map +1 -1
  31. package/dist/neutral/contexts/Wallet/State.d.mts +0 -4
  32. package/dist/neutral/contexts/Wallet/State.d.mts.map +1 -1
  33. package/dist/neutral/contexts/Wallet/State.d.ts +0 -4
  34. package/dist/neutral/contexts/Wallet/State.d.ts.map +1 -1
  35. package/dist/neutral/contexts/Wallet/usePromise.d.cts +0 -3
  36. package/dist/neutral/contexts/Wallet/usePromise.d.cts.map +1 -1
  37. package/dist/neutral/contexts/Wallet/usePromise.d.mts +0 -3
  38. package/dist/neutral/contexts/Wallet/usePromise.d.mts.map +1 -1
  39. package/dist/neutral/contexts/Wallet/usePromise.d.ts +0 -3
  40. package/dist/neutral/contexts/Wallet/usePromise.d.ts.map +1 -1
  41. package/dist/neutral/index.cjs +1 -814
  42. package/dist/neutral/index.cjs.map +1 -1
  43. package/dist/neutral/index.js +1 -802
  44. package/dist/neutral/index.js.map +1 -1
  45. package/dist/node/components/SeedPhrase/dialog/components/fields/SavedPhraseTextField.d.cts +1 -0
  46. package/dist/node/components/SeedPhrase/dialog/components/fields/SavedPhraseTextField.d.cts.map +1 -1
  47. package/dist/node/components/SeedPhrase/dialog/components/fields/SavedPhraseTextField.d.mts +1 -0
  48. package/dist/node/components/SeedPhrase/dialog/components/fields/SavedPhraseTextField.d.mts.map +1 -1
  49. package/dist/node/components/SeedPhrase/dialog/components/fields/SavedPhraseTextField.d.ts +1 -0
  50. package/dist/node/components/SeedPhrase/dialog/components/fields/SavedPhraseTextField.d.ts.map +1 -1
  51. package/dist/node/contexts/Wallet/State.d.cts +0 -4
  52. package/dist/node/contexts/Wallet/State.d.cts.map +1 -1
  53. package/dist/node/contexts/Wallet/State.d.mts +0 -4
  54. package/dist/node/contexts/Wallet/State.d.mts.map +1 -1
  55. package/dist/node/contexts/Wallet/State.d.ts +0 -4
  56. package/dist/node/contexts/Wallet/State.d.ts.map +1 -1
  57. package/dist/node/contexts/Wallet/usePromise.d.cts +0 -3
  58. package/dist/node/contexts/Wallet/usePromise.d.cts.map +1 -1
  59. package/dist/node/contexts/Wallet/usePromise.d.mts +0 -3
  60. package/dist/node/contexts/Wallet/usePromise.d.mts.map +1 -1
  61. package/dist/node/contexts/Wallet/usePromise.d.ts +0 -3
  62. package/dist/node/contexts/Wallet/usePromise.d.ts.map +1 -1
  63. package/dist/node/index.cjs +1 -853
  64. package/dist/node/index.cjs.map +1 -1
  65. package/dist/node/index.js +1 -807
  66. package/dist/node/index.js.map +1 -1
  67. package/package.json +7 -7
  68. package/src/components/SeedPhrase/dialog/components/fields/SavedPhraseTextField.tsx +4 -3
@@ -1,808 +1,2 @@
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 == null ? void 0 : setShowSnackBar(false),
21
- open: showSnackBar,
22
- children: /* @__PURE__ */ jsxs(Alert, { severity: "error", onClose: () => setShowSnackBar == null ? void 0 : 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 == null ? void 0 : changeMaxAccounts(desiredMaximumAccounts2);
48
- }
49
- if (!maxAccountsWithinRange)
50
- setShowSnackBar(true);
51
- setDesiredMaximumAccounts(desiredMaximumAccounts2);
52
- return;
53
- }
54
- case "increase": {
55
- changeMaxAccounts == null ? void 0 : 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 } from "@scure/bip39";
133
- import { wordlist } from "@scure/bip39/wordlists/english";
134
- import { useEffect, useState as useState3 } from "react";
135
- import { Fragment as Fragment2, jsx as jsx4, jsxs as jsxs4 } from "react/jsx-runtime";
136
- var DefaultSeedPhrase = ({ changeSeedPhrase, children, hideDefaultSeedPhraseMessage, seedPhrase }) => {
137
- const [showSnackBar, setShowSnackBar] = useState3(false);
138
- useEffect(() => {
139
- if (!seedPhrase) {
140
- const mnemonic = generateMnemonic(wordlist, 256);
141
- changeSeedPhrase == null ? void 0 : changeSeedPhrase(mnemonic);
142
- setShowSnackBar(true);
143
- }
144
- }, [changeSeedPhrase, seedPhrase]);
145
- return /* @__PURE__ */ jsxs4(Fragment2, { children: [
146
- hideDefaultSeedPhraseMessage ? null : /* @__PURE__ */ jsx4(
147
- Snackbar2,
148
- {
149
- open: showSnackBar,
150
- autoHideDuration: 5e3,
151
- onClose: () => setShowSnackBar(false),
152
- anchorOrigin: { horizontal: "center", vertical: "top" },
153
- children: /* @__PURE__ */ jsxs4(Alert2, { severity: "success", children: [
154
- /* @__PURE__ */ jsx4(AlertTitle2, { children: "Default Seed Phrase Generated" }),
155
- "Go to application settings to save it."
156
- ] })
157
- }
158
- ),
159
- children
160
- ] });
161
- };
162
-
163
- // src/components/SeedPhrase/dialog/components/DialogActionButtons.tsx
164
- import { Button as Button2, DialogActions as DialogActions2 } from "@mui/material";
165
-
166
- // src/contexts/SeedPhrase/Context.ts
167
- import { createContextEx } from "@xyo-network/react-shared";
168
- var SeedPhraseContext = createContextEx();
169
-
170
- // src/contexts/SeedPhrase/Provider.tsx
171
- import { generateMnemonic as generateMnemonic2, validateMnemonic } from "@scure/bip39";
172
- import { wordlist as wordlist2 } from "@scure/bip39/wordlists/english";
173
- import { useCallback, useEffect as useEffect2, useMemo, useState as useState4 } from "react";
174
- import { jsx as jsx5 } from "react/jsx-runtime";
175
- var validate = (passedPhrase) => {
176
- if (!passedPhrase) {
177
- return null;
178
- }
179
- return validateMnemonic(passedPhrase, wordlist2);
180
- };
181
- var SeedPhraseProvider = ({
182
- children,
183
- defaultPhrase,
184
- handleChangeSeedPhrase,
185
- saveCallback,
186
- seedPhrase,
187
- open
188
- }) => {
189
- const [phrase, setPhrase] = useState4();
190
- const [overwriteWarning, setOverwriteWarning] = useState4(false);
191
- useEffect2(() => {
192
- setPhrase(defaultPhrase);
193
- }, [defaultPhrase]);
194
- useEffect2(() => {
195
- if (seedPhrase || open) {
196
- setPhrase == null ? void 0 : setPhrase(seedPhrase ?? "");
197
- }
198
- }, [seedPhrase, open, setPhrase]);
199
- const handleGenerate = useCallback(() => {
200
- const mnemonic = generateMnemonic2(wordlist2, 256);
201
- setPhrase == null ? void 0 : setPhrase(mnemonic);
202
- setOverwriteWarning == null ? void 0 : setOverwriteWarning(false);
203
- }, []);
204
- const handleCancelOverwrite = useCallback(() => {
205
- setOverwriteWarning == null ? void 0 : setOverwriteWarning(false);
206
- }, []);
207
- const handleClear = useCallback(() => {
208
- setPhrase == null ? void 0 : setPhrase("");
209
- setOverwriteWarning == null ? void 0 : setOverwriteWarning(false);
210
- }, []);
211
- const handleSave = useCallback(() => {
212
- if (!overwriteWarning && seedPhrase && seedPhrase !== phrase) {
213
- setOverwriteWarning == null ? void 0 : setOverwriteWarning(true);
214
- } else {
215
- handleChangeSeedPhrase == null ? void 0 : handleChangeSeedPhrase(phrase ?? "");
216
- saveCallback == null ? void 0 : saveCallback();
217
- }
218
- }, [handleChangeSeedPhrase, overwriteWarning, phrase, saveCallback, seedPhrase]);
219
- useEffect2(() => {
220
- if (!open) {
221
- handleCancelOverwrite();
222
- }
223
- }, [handleCancelOverwrite, open]);
224
- const validSeedPhrase = useMemo(() => validate == null ? void 0 : validate(seedPhrase), [seedPhrase]);
225
- const validPhrase = useMemo(() => validate == null ? void 0 : validate(phrase), [phrase]);
226
- return /* @__PURE__ */ jsx5(
227
- SeedPhraseContext.Provider,
228
- {
229
- value: {
230
- handleCancelOverwrite,
231
- handleChangeSeedPhrase,
232
- handleClear,
233
- handleGenerate,
234
- handleSave,
235
- overwriteWarning,
236
- phrase,
237
- provided: true,
238
- seedPhrase,
239
- setOverwriteWarning,
240
- setPhrase,
241
- validPhrase,
242
- validSeedPhrase,
243
- validate
244
- },
245
- children
246
- }
247
- );
248
- };
249
-
250
- // src/contexts/SeedPhrase/use.tsx
251
- import { useContextEx } from "@xyo-network/react-shared";
252
- var useSeedPhrase = () => useContextEx(SeedPhraseContext, "SeedPhrase", true);
253
-
254
- // src/contexts/Wallet/Context.ts
255
- import { createContextEx as createContextEx2 } from "@xyo-network/react-shared";
256
- var WalletContext = createContextEx2();
257
-
258
- // src/contexts/Wallet/Provider.tsx
259
- import { usePromise } from "@xylabs/react-promise";
260
- import { useEffect as useEffect3, useState as useState5 } from "react";
261
- import { jsx as jsx6 } from "react/jsx-runtime";
262
- var WalletProvider = ({
263
- children,
264
- defaultActiveAccountIndex = 0,
265
- rootWallet = null,
266
- ...props
267
- }) => {
268
- const [activeAccountIndex, setActiveAccountIndex] = useState5(defaultActiveAccountIndex);
269
- useEffect3(() => {
270
- if (defaultActiveAccountIndex !== void 0) {
271
- setActiveAccountIndex(defaultActiveAccountIndex);
272
- }
273
- }, [defaultActiveAccountIndex]);
274
- const [activeAccount = null] = usePromise(async () => await (rootWallet == null ? void 0 : rootWallet.derivePath(activeAccountIndex.toString())), [activeAccountIndex, rootWallet]);
275
- return /* @__PURE__ */ jsx6(
276
- WalletContext.Provider,
277
- {
278
- value: {
279
- activeAccount,
280
- activeAccountIndex,
281
- provided: true,
282
- rootWallet,
283
- setActiveAccountIndex
284
- },
285
- ...props,
286
- children
287
- }
288
- );
289
- };
290
-
291
- // src/contexts/Wallet/use.ts
292
- import { usePromise as usePromise2 } from "@xylabs/react-promise";
293
- import { useContextEx as useContextEx2, useProvided } from "@xyo-network/react-shared";
294
- var useWalletContext = (required = true) => {
295
- return useContextEx2(WalletContext, "Wallet", required);
296
- };
297
- var useWalletProvided = () => {
298
- return useProvided(WalletContext);
299
- };
300
- var useRootWallet = (required = true) => {
301
- const { rootWallet } = useWalletContext(required);
302
- return [rootWallet, void 0];
303
- };
304
- var useIndexedWalletFromContext = (index, required = true) => {
305
- const { rootWallet } = useWalletContext(required);
306
- const [wallet] = usePromise2(async () => await (rootWallet == null ? void 0 : rootWallet.derivePath(index.toString())) ?? rootWallet, [rootWallet, index]);
307
- return [wallet, void 0];
308
- };
309
- var useSelectedWalletAccount = (required = true) => {
310
- const { activeAccountIndex } = useWalletContext(required);
311
- const [account] = useIndexedWalletFromContext(activeAccountIndex ?? 0, required);
312
- return activeAccountIndex === void 0 && account === null ? [null, void 0] : [account, void 0];
313
- };
314
-
315
- // src/components/SeedPhrase/dialog/components/DialogActionButtons.tsx
316
- import { jsx as jsx7, jsxs as jsxs5 } from "react/jsx-runtime";
317
- var DialogActionButtons = ({ onClose, ...props }) => {
318
- const { handleSave, setPhrase } = useSeedPhrase();
319
- const wrappedOnClose = (e) => {
320
- setPhrase == null ? void 0 : setPhrase("");
321
- onClose == null ? void 0 : onClose(e, "escapeKeyDown");
322
- };
323
- return /* @__PURE__ */ jsxs5(DialogActions2, { ...props, children: [
324
- /* @__PURE__ */ jsx7(Button2, { variant: "outlined", onClick: wrappedOnClose, children: "Cancel" }),
325
- /* @__PURE__ */ jsx7(Button2, { variant: "outlined", onClick: handleSave, children: "Save" })
326
- ] });
327
- };
328
-
329
- // src/components/SeedPhrase/dialog/components/fields/NewPhraseTextField.tsx
330
- import { FormControl, TextField } from "@mui/material";
331
-
332
- // src/components/SeedPhrase/dialog/components/fields/validation-messages/colorParser.ts
333
- var colorParser = (conditional) => {
334
- switch (conditional) {
335
- case true: {
336
- return "success";
337
- }
338
- case false: {
339
- return "error";
340
- }
341
- default: {
342
- return;
343
- }
344
- }
345
- };
346
-
347
- // src/components/SeedPhrase/dialog/components/fields/validation-messages/InvalidPhrase.tsx
348
- import { Link as Link2, Typography as Typography3 } from "@mui/material";
349
- import { jsx as jsx8, jsxs as jsxs6 } from "react/jsx-runtime";
350
- var InvalidPhraseTypography = (props) => /* @__PURE__ */ jsxs6(Typography3, { variant: "caption", color: "error", ...props, children: [
351
- "Invalid seed phrase. See -",
352
- " ",
353
- /* @__PURE__ */ jsx8(Link2, { target: "_blank", href: "https://github.com/bitcoin/bips/blob/master/bip-0039.mediawiki", children: "bip39 Proposal" })
354
- ] });
355
-
356
- // src/components/SeedPhrase/dialog/components/fields/validation-messages/PhraseHeaderBox.tsx
357
- import { CheckCircleOutline as CheckCircleOutlineIcon, HighlightOff as HighlightOffIcon } from "@mui/icons-material";
358
- import { FlexRow } from "@xylabs/react-flexbox";
359
- import { useMemo as useMemo2 } from "react";
360
- import { jsx as jsx9, jsxs as jsxs7 } from "react/jsx-runtime";
361
- var PhraseHeaderBox = ({ children, conditional, ...props }) => {
362
- const state = useMemo2(() => {
363
- switch (conditional) {
364
- case true: {
365
- return "success";
366
- }
367
- case false: {
368
- return "error";
369
- }
370
- default: {
371
- return null;
372
- }
373
- }
374
- }, [conditional]);
375
- const Icon = useMemo2(() => {
376
- switch (state) {
377
- case "success": {
378
- return /* @__PURE__ */ jsx9(CheckCircleOutlineIcon, { fontSize: "small", color: "success" });
379
- }
380
- case "error": {
381
- return /* @__PURE__ */ jsx9(HighlightOffIcon, { fontSize: "small", color: "error" });
382
- }
383
- default: {
384
- return null;
385
- }
386
- }
387
- }, [state]);
388
- return /* @__PURE__ */ jsxs7(FlexRow, { justifyContent: "start", columnGap: 1, ...props, children: [
389
- Icon,
390
- children
391
- ] });
392
- };
393
-
394
- // src/components/SeedPhrase/dialog/components/fields/NewPhraseTextField.tsx
395
- import { Fragment as Fragment3, jsx as jsx10, jsxs as jsxs8 } from "react/jsx-runtime";
396
- var NewPhraseTextField = ({ children, disableColor, ...props }) => {
397
- const { phrase, setPhrase, validPhrase } = useSeedPhrase();
398
- return /* @__PURE__ */ jsx10(Fragment3, { children: /* @__PURE__ */ jsxs8(FormControl, { fullWidth: true, size: "small", sx: { display: "flex", flexDirection: "column", rowGap: 1 }, children: [
399
- children,
400
- /* @__PURE__ */ jsx10(
401
- TextField,
402
- {
403
- focused: true,
404
- color: disableColor ? void 0 : colorParser(validPhrase),
405
- error: validPhrase === false,
406
- helperText: validPhrase === false ? /* @__PURE__ */ jsx10(InvalidPhraseTypography, {}) : null,
407
- fullWidth: true,
408
- maxRows: Number.POSITIVE_INFINITY,
409
- multiline: true,
410
- onChange: (e) => setPhrase == null ? void 0 : setPhrase(e.target.value),
411
- value: phrase,
412
- ...props
413
- }
414
- )
415
- ] }) });
416
- };
417
-
418
- // src/components/SeedPhrase/dialog/components/fields/PhraseDialogActions.tsx
419
- import { Button as Button3, DialogActions as DialogActions3 } from "@mui/material";
420
- import { jsx as jsx11, jsxs as jsxs9 } from "react/jsx-runtime";
421
- var PhraseDialogActions = () => {
422
- const { handleClear, handleGenerate, overwriteWarning } = useSeedPhrase();
423
- return /* @__PURE__ */ jsxs9(DialogActions3, { sx: { justifyContent: "center" }, children: [
424
- /* @__PURE__ */ jsx11(Button3, { disabled: overwriteWarning, variant: "outlined", onClick: handleGenerate, children: "Generate" }),
425
- /* @__PURE__ */ jsx11(Button3, { variant: "outlined", onClick: handleClear, children: "Clear" })
426
- ] });
427
- };
428
-
429
- // src/components/SeedPhrase/dialog/components/fields/SavedPhraseTextField.tsx
430
- import { Chip, FormControl as FormControl2, FormLabel, TextField as TextField2 } from "@mui/material";
431
- import { useState as useState6 } from "react";
432
- import { Fragment as Fragment4, jsx as jsx12, jsxs as jsxs10 } from "react/jsx-runtime";
433
- var SavedPhraseTextField = ({ showPhraseHeader, ...props }) => {
434
- const { validSeedPhrase, seedPhrase } = useSeedPhrase();
435
- const [visible, setVisible] = useState6(false);
436
- return /* @__PURE__ */ jsxs10(FormControl2, { fullWidth: true, size: "small", sx: { display: "flex", flexDirection: "column", rowGap: 1 }, children: [
437
- /* @__PURE__ */ jsx12(Chip, { label: visible ? "Hide Saved Seed Phrase" : "Reveal Saved Seed Phrase", onClick: () => setVisible(!visible) }),
438
- visible ? /* @__PURE__ */ jsxs10(Fragment4, { children: [
439
- showPhraseHeader ? /* @__PURE__ */ jsx12(FormLabel, { children: /* @__PURE__ */ jsx12(PhraseHeaderBox, { conditional: validSeedPhrase, children: "Saved Seed Phrase" }) }) : null,
440
- /* @__PURE__ */ jsx12(
441
- TextField2,
442
- {
443
- defaultValue: seedPhrase,
444
- disabled: true,
445
- error: validSeedPhrase === false,
446
- helperText: validSeedPhrase === false ? /* @__PURE__ */ jsx12(InvalidPhraseTypography, {}) : null,
447
- fullWidth: true,
448
- maxRows: Number.POSITIVE_INFINITY,
449
- multiline: true,
450
- ...props
451
- }
452
- )
453
- ] }) : null
454
- ] });
455
- };
456
-
457
- // src/components/SeedPhrase/dialog/components/OverwriteWarning.tsx
458
- import { Alert as Alert3, Button as Button4 } from "@mui/material";
459
- import { FlexRow as FlexRow2 } from "@xylabs/react-flexbox";
460
- import { jsx as jsx13, jsxs as jsxs11 } from "react/jsx-runtime";
461
- var OverwriteWarning = () => {
462
- const { handleCancelOverwrite, handleSave } = useSeedPhrase();
463
- return /* @__PURE__ */ jsx13(
464
- Alert3,
465
- {
466
- variant: "outlined",
467
- severity: "warning",
468
- action: /* @__PURE__ */ jsxs11(FlexRow2, { sx: { columnGap: 1 }, children: [
469
- /* @__PURE__ */ jsx13(Button4, { variant: "outlined", color: "inherit", size: "small", onClick: handleSave, children: "Overwrite" }),
470
- /* @__PURE__ */ jsx13(Button4, { variant: "outlined", color: "inherit", size: "small", onClick: handleCancelOverwrite, children: "Cancel" })
471
- ] }),
472
- children: "Are you sure you want to overwrite existing seed phrase? This action cannot be undone."
473
- }
474
- );
475
- };
476
-
477
- // src/components/SeedPhrase/dialog/SeedPhraseDialog.tsx
478
- import { Dialog as Dialog2, DialogContent as DialogContent2, DialogTitle as DialogTitle2, FormLabel as FormLabel2 } from "@mui/material";
479
- import { jsx as jsx14, jsxs as jsxs12 } from "react/jsx-runtime";
480
- var SeedPhraseDialog = ({ changeSeedPhrase, seedPhrase, ...props }) => {
481
- return /* @__PURE__ */ jsx14(
482
- SeedPhraseProvider,
483
- {
484
- seedPhrase,
485
- handleChangeSeedPhrase: changeSeedPhrase,
486
- open: props.open,
487
- saveCallback: () => {
488
- var _a;
489
- return (_a = props.onClose) == null ? void 0 : _a.call(props, {}, "escapeKeyDown");
490
- },
491
- children: /* @__PURE__ */ jsx14(SeedPhraseDialogInner, { ...props })
492
- }
493
- );
494
- };
495
- var SeedPhraseDialogInner = (props) => {
496
- const { overwriteWarning, seedPhrase, validPhrase } = useSeedPhrase();
497
- return /* @__PURE__ */ jsxs12(Dialog2, { "aria-labelledby": "alert-dialog-title", "aria-describedby": "alert-dialog-description", fullWidth: true, maxWidth: "sm", ...props, children: [
498
- /* @__PURE__ */ jsxs12(DialogTitle2, { id: "alert-dialog-title", children: [
499
- "Update Your Seed Phrase ",
500
- /* @__PURE__ */ jsx14(SeedPhraseIconButton, {})
501
- ] }),
502
- /* @__PURE__ */ jsxs12(DialogContent2, { sx: { display: "flex", flexDirection: "column", rowGap: 2 }, children: [
503
- /* @__PURE__ */ jsx14(NewPhraseTextField, { children: /* @__PURE__ */ jsx14(FormLabel2, { children: /* @__PURE__ */ jsx14(PhraseHeaderBox, { conditional: validPhrase, children: "New Seed Phrase" }) }) }),
504
- /* @__PURE__ */ jsx14(PhraseDialogActions, {}),
505
- seedPhrase ? /* @__PURE__ */ jsx14(SavedPhraseTextField, {}) : null,
506
- overwriteWarning ? /* @__PURE__ */ jsx14(OverwriteWarning, {}) : null
507
- ] }),
508
- /* @__PURE__ */ jsx14(DialogActionButtons, { onClose: props.onClose })
509
- ] });
510
- };
511
-
512
- // src/components/SeedPhrase/settings/SeedPhraseTableRow.tsx
513
- import { Cancel as CancelIcon, RadioButtonChecked as RadioButtonCheckedIcon } from "@mui/icons-material";
514
- import { Button as Button5, ButtonGroup as ButtonGroup2, TableCell as TableCell2, TableRow as TableRow2 } from "@mui/material";
515
- import { useState as useState7 } from "react";
516
- import { jsx as jsx15, jsxs as jsxs13 } from "react/jsx-runtime";
517
- var SeedPhraseTableRow = ({ changeSeedPhrase, seedPhrase, ...props }) => {
518
- const [open, setOpen] = useState7(false);
519
- const handleOpen = () => {
520
- setOpen(true);
521
- };
522
- return /* @__PURE__ */ jsxs13(TableRow2, { ...props, children: [
523
- /* @__PURE__ */ jsxs13(TableCell2, { children: [
524
- "Seed Phrase ",
525
- /* @__PURE__ */ jsx15(SeedPhraseIconButton, {})
526
- ] }),
527
- /* @__PURE__ */ jsx15(TableCell2, { align: "center", children: seedPhrase ? /* @__PURE__ */ jsx15(RadioButtonCheckedIcon, { color: "success" }) : /* @__PURE__ */ jsx15(CancelIcon, { color: "error" }) }),
528
- /* @__PURE__ */ jsxs13(TableCell2, { children: [
529
- /* @__PURE__ */ jsx15(SeedPhraseDialog, { changeSeedPhrase, open, onClose: () => setOpen(false), seedPhrase }),
530
- /* @__PURE__ */ jsx15(ButtonGroup2, { fullWidth: true, children: /* @__PURE__ */ jsx15(Button5, { variant: "contained", size: "small", onClick: handleOpen, children: "Update" }) })
531
- ] })
532
- ] });
533
- };
534
-
535
- // src/components/WalletAccountDetails/WalletAccountDetails.tsx
536
- import { EthAddress } from "@xylabs/eth-address";
537
- import { EthAccountButton } from "@xylabs/react-crypto";
538
- import { FlexCol, FlexRow as FlexRow3 } from "@xylabs/react-flexbox";
539
- import { NumberStatus } from "@xylabs/react-number-status";
540
- import { useNetwork } from "@xyo-network/react-network";
541
-
542
- // src/hooks/useAccount.ts
543
- import { usePromise as usePromise3 } from "@xylabs/react-promise";
544
- import { useState as useState8 } from "react";
545
- var useAccount = ({ wallet, account, index, required = false } = {}) => {
546
- const walletContextProvided = useWalletProvided();
547
- const [validationError, setValidationError] = useState8();
548
- if (wallet && account && !validationError) {
549
- setValidationError(new Error("useAccount can not have both a wallet and an account in the parameters"));
550
- }
551
- if (index && account && !validationError) {
552
- setValidationError(new Error("useAccount can not have both a index and an account in the parameters"));
553
- }
554
- const [error, setError] = useState8();
555
- const [rootWallet] = useRootWallet(!wallet && required);
556
- const { activeAccountIndex } = useWalletContext(false);
557
- const [activeAccount] = usePromise3(async () => {
558
- var _a, _b;
559
- try {
560
- if (!validationError) {
561
- if (wallet) {
562
- return await ((_a = wallet == null ? void 0 : wallet.derivePath) == null ? void 0 : _a.call(wallet, `${index ?? 0}'\0`));
563
- } else if (rootWallet) {
564
- return await ((_b = rootWallet == null ? void 0 : rootWallet.derivePath) == null ? void 0 : _b.call(rootWallet, `${index ?? activeAccountIndex ?? 0}'\0`));
565
- }
566
- }
567
- } catch (ex) {
568
- const error2 = ex;
569
- console.error(error2.message);
570
- setError(error2);
571
- }
572
- }, [index, wallet, rootWallet, activeAccountIndex, validationError]);
573
- if (validationError && !error) {
574
- console.error(validationError.message);
575
- setError(validationError);
576
- }
577
- return [
578
- error ? void 0 : account ?? activeAccount ?? walletContextProvided ? null : void 0,
579
- error
580
- ];
581
- };
582
-
583
- // src/hooks/useWallet.ts
584
- import { usePromise as usePromise4 } from "@xylabs/react-promise";
585
- import { HDWallet } from "@xyo-network/account";
586
- import { useState as useState9 } from "react";
587
- var useWallet = ({ mnemonic, wallet, path, required = false, seed } = {}) => {
588
- const walletContextProvided = useWalletContext(false);
589
- const [error, setError] = useState9();
590
- const [contextAccount] = useSelectedWalletAccount(!wallet && required);
591
- const [activeAccount] = usePromise4(async () => {
592
- var _a;
593
- try {
594
- const newAccount = await (() => {
595
- if (wallet) {
596
- return wallet;
597
- } else if (mnemonic) {
598
- return HDWallet.fromPhrase(mnemonic);
599
- } else if (seed) {
600
- return HDWallet.fromSeed(seed);
601
- }
602
- return contextAccount;
603
- })();
604
- return path ? (_a = newAccount == null ? void 0 : newAccount.derivePath) == null ? void 0 : _a.call(newAccount, path) : newAccount ?? wallet;
605
- } catch (ex) {
606
- setError(ex);
607
- }
608
- }, [mnemonic, contextAccount, seed, path, wallet]);
609
- return [activeAccount ?? (walletContextProvided ? null : activeAccount), error];
610
- };
611
-
612
- // src/hooks/useWallets.ts
613
- import { usePromise as usePromise5 } from "@xylabs/react-promise";
614
- var useWallets = ({ wallet, paths }) => {
615
- const walletContextProvided = useWalletContext(false);
616
- const [foundWallet] = useWallet({ wallet });
617
- const [wallets, error] = usePromise5(
618
- async () => foundWallet ? await Promise.all(paths.map((path) => foundWallet.derivePath(path))) : void 0,
619
- [foundWallet, paths]
620
- );
621
- return [wallets ?? (walletContextProvided ? null : wallets), error];
622
- };
623
-
624
- // src/hooks/useWrapperAccount.ts
625
- import { usePromise as usePromise6 } from "@xylabs/react-promise";
626
- import { HDWallet as HDWallet2 } from "@xyo-network/account";
627
- import { Mutex } from "async-mutex";
628
- var globalWrapperWallet;
629
- var globalWrapperWalletMutex = new Mutex();
630
- var useWrapperAccount = (account) => {
631
- return usePromise6(async () => {
632
- return await globalWrapperWalletMutex.runExclusive(async () => {
633
- if (account !== void 0) {
634
- return account;
635
- }
636
- if (globalWrapperWallet) {
637
- return globalWrapperWallet;
638
- }
639
- try {
640
- globalWrapperWallet = await HDWallet2.random();
641
- console.log(`Global Wrapper Wallet Creation Success: ${globalWrapperWallet.address}`);
642
- } catch (ex) {
643
- const error = ex;
644
- console.error(`Global Wrapper Wallet Creation Failed: ${error.message}`);
645
- }
646
- return globalWrapperWallet;
647
- });
648
- }, [account]);
649
- };
650
-
651
- // src/components/WalletAccountDetails/WalletAccountDetails.tsx
652
- import { jsx as jsx16, jsxs as jsxs14 } from "react/jsx-runtime";
653
- var WalletAccountDetails = ({ exploreUrl = "https://explore.xyo.network", account, ...props }) => {
654
- const [accountToUse] = useAccount({ account });
655
- const { network } = useNetwork();
656
- const exploreAddressUrl = `${exploreUrl}/recent?account=${accountToUse == null ? void 0 : accountToUse.address}&network=${(network == null ? void 0 : network.name) ?? "main"}`;
657
- return /* @__PURE__ */ jsxs14(FlexCol, { ...props, children: [
658
- /* @__PURE__ */ jsx16(EthAccountButton, { address: EthAddress.fromString(accountToUse == null ? void 0 : accountToUse.address) }),
659
- /* @__PURE__ */ jsxs14(FlexRow3, { gap: 1, children: [
660
- /* @__PURE__ */ jsx16(NumberStatus, { rounded: true, title: "Tokens", value: 0, to: `${exploreAddressUrl}&schema=network.xyo.account.tokens`, target: "_blank" }),
661
- /* @__PURE__ */ jsx16(NumberStatus, { rounded: true, title: "NFTs", value: 0, to: `${exploreAddressUrl}&schema=network.xyo.account.nfts`, target: "_blank" }),
662
- /* @__PURE__ */ jsx16(NumberStatus, { rounded: true, title: "Signatures", value: 0, to: `${exploreAddressUrl}&schema=network.xyo.account.signatures`, target: "_blank" }),
663
- /* @__PURE__ */ jsx16(NumberStatus, { rounded: true, title: "Signins", value: 0, to: `${exploreAddressUrl}&schema=network.xyo.account.signins`, target: "_blank" })
664
- ] })
665
- ] });
666
- };
667
-
668
- // src/components/WalletAccountSelect/Select.tsx
669
- import { CircularProgress, MenuItem } from "@mui/material";
670
- import { SelectEx } from "@xylabs/react-select";
671
- import { AddressRenderRowBox } from "@xyo-network/react-address-render";
672
- import { Fragment as Fragment5, jsx as jsx17 } from "react/jsx-runtime";
673
- var arrayRange = (length, start = 0) => {
674
- return [...Array.from({ length }).keys()].map((x) => x + start);
675
- };
676
- var WalletAccountSelect = ({
677
- addressNames = {},
678
- iconOnly,
679
- iconSize = 24,
680
- icons,
681
- maxAccounts = 1,
682
- showFavorite = false,
683
- size,
684
- variant = "outlined",
685
- ...props
686
- }) => {
687
- const { activeAccountIndex = 0, setActiveAccountIndex, rootWallet } = useWalletContext();
688
- const disabled = !rootWallet || activeAccountIndex === void 0;
689
- return /* @__PURE__ */ jsx17(Fragment5, { children: rootWallet ? /* @__PURE__ */ jsx17(
690
- SelectEx,
691
- {
692
- margin: "dense",
693
- disabled,
694
- renderValue: (selectedAccountIndex) => {
695
- const Item = () => {
696
- const [selectedAccount] = useWallet({ path: selectedAccountIndex.toString(), wallet: rootWallet });
697
- const customName = selectedAccount ? addressNames[selectedAccount.address] : void 0;
698
- const favorite = !!selectedAccount && selectedAccount.address in addressNames;
699
- return /* @__PURE__ */ jsx17(MenuItem, { value: selectedAccountIndex, sx: { minHeight: 0, paddingBottom: 0, paddingTop: 0 }, children: /* @__PURE__ */ jsx17(
700
- AddressRenderRowBox,
701
- {
702
- disableSharedRef: true,
703
- flexGrow: 1,
704
- address: selectedAccount == null ? void 0 : selectedAccount.address,
705
- iconOnly,
706
- iconSize,
707
- icons,
708
- name: customName,
709
- favorite,
710
- showFavorite
711
- }
712
- ) });
713
- };
714
- return /* @__PURE__ */ jsx17(Item, {});
715
- },
716
- value: activeAccountIndex,
717
- onChange: (event) => setActiveAccountIndex == null ? void 0 : setActiveAccountIndex(Number.parseInt(`${event.target.value}`)),
718
- size,
719
- variant,
720
- ...props,
721
- children: arrayRange(maxAccounts).map((index) => {
722
- const Item = () => {
723
- const [account] = useWallet({ path: index.toString(), wallet: rootWallet });
724
- const customName = account ? addressNames[account.address] : void 0;
725
- const favorite = !!account && account.address in addressNames;
726
- return /* @__PURE__ */ jsx17(MenuItem, { value: index, sx: { minHeight: 0, paddingBottom: 0, paddingTop: 0 }, children: /* @__PURE__ */ jsx17(
727
- AddressRenderRowBox,
728
- {
729
- disableSharedRef: true,
730
- flexGrow: 1,
731
- address: account == null ? void 0 : account.address,
732
- favorite,
733
- iconOnly,
734
- iconSize,
735
- icons,
736
- name: customName,
737
- showFavorite
738
- }
739
- ) }, account == null ? void 0 : account.address);
740
- };
741
- return /* @__PURE__ */ jsx17(Item, {}, index);
742
- })
743
- }
744
- ) : /* @__PURE__ */ jsx17(CircularProgress, { size: 24 }) });
745
- };
746
-
747
- // src/components/WalletAccountSelect/SelectBar.tsx
748
- import { FlexCol as FlexCol2 } from "@xylabs/react-flexbox";
749
- import { jsx as jsx18 } from "react/jsx-runtime";
750
- var WalletAccountSelectBar = ({
751
- addressNames = {},
752
- iconOnly,
753
- iconSize,
754
- icons,
755
- maxAccounts = 1,
756
- showFavorite = false,
757
- size = "small",
758
- ...props
759
- }) => {
760
- return /* @__PURE__ */ jsx18(FlexCol2, { alignItems: "stretch", ...props, children: /* @__PURE__ */ jsx18(
761
- WalletAccountSelect,
762
- {
763
- addressNames,
764
- fullWidth: true,
765
- showFavorite,
766
- iconSize,
767
- iconOnly,
768
- icons,
769
- maxAccounts,
770
- size: size ?? "small",
771
- variant: "outlined"
772
- }
773
- ) });
774
- };
775
- export {
776
- DefaultSeedPhrase,
777
- DialogActionButtons,
778
- InvalidPhraseTypography,
779
- MaxAccountsTableRow,
780
- NewPhraseTextField,
781
- OverwriteWarning,
782
- PhraseDialogActions,
783
- PhraseHeaderBox,
784
- SavedPhraseTextField,
785
- SeedPhraseContext,
786
- SeedPhraseDialog,
787
- SeedPhraseDialogInner,
788
- SeedPhraseIconButton,
789
- SeedPhraseProvider,
790
- SeedPhraseTableRow,
791
- WalletAccountDetails,
792
- WalletAccountSelect,
793
- WalletAccountSelectBar,
794
- WalletContext,
795
- WalletProvider,
796
- colorParser,
797
- useAccount,
798
- useIndexedWalletFromContext,
799
- useRootWallet,
800
- useSeedPhrase,
801
- useSelectedWalletAccount,
802
- useWallet,
803
- useWalletContext,
804
- useWalletProvided,
805
- useWallets,
806
- useWrapperAccount
807
- };
1
+ import{ButtonGroup as ke,TableCell as N,TableRow as Ee,Typography as Oe}from"@mui/material";import{ButtonEx as X}from"@xylabs/react-button";import{useState as J}from"react";import{Alert as Te,AlertTitle as Be,Snackbar as Re}from"@mui/material";import{jsx as U,jsxs as De}from"react/jsx-runtime";var q=({activeAccountIndex:e,desiredMaximumAccounts:o,setShowSnackBar:t,showSnackBar:r})=>U(Re,{anchorOrigin:{horizontal:"center",vertical:"top"},autoHideDuration:5e3,onClose:()=>t==null?void 0:t(!1),open:r,children:De(Te,{severity:"error",onClose:()=>t==null?void 0:t(!1),children:[U(Be,{children:"Maximum Accounts Error"}),"Your currently selected account number (",e===void 0?"":e+1,") cannot be greater than the desired Maximum Accounts (",o,")."]})});import{jsx as b,jsxs as G}from"react/jsx-runtime";var yo=({activeAccountIndex:e,changeMaxAccounts:o,maxAccounts:t})=>{let[r,n]=J(),[a,i]=J(!1),l=u=>{if(t!==void 0&&e!==void 0)switch(u){case"decrease":{let s=t-1,m=s>0,d=e+1<=s;m&&d&&(o==null||o(s)),d||i(!0),n(s);return}case"increase":{o==null||o(t+1);return}default:console.error(u,"is not a recognized value")}else throw new Error("Max Accounts is unset and needs a default")};return G(Ee,{children:[b(N,{children:"Maximum Accounts"}),b(N,{align:"center",children:b(Oe,{variant:"caption",children:t})}),G(N,{align:"center",children:[G(ke,{children:[b(X,{onClick:()=>l("decrease"),variant:"contained",size:"small",children:"-"}),b(X,{onClick:()=>l("increase"),variant:"contained",size:"small",children:"+"})]}),b(q,{desiredMaximumAccounts:r,activeAccountIndex:e,setShowSnackBar:i,showSnackBar:a})]})]})};import{HelpOutline as He}from"@mui/icons-material";import{Button as ze,Dialog as Me,DialogActions as Ne,DialogContent as Ge,DialogTitle as Le,IconButton as $e,Link as _e,List as Ve,ListItem as R,Typography as Ye}from"@mui/material";import{useState as Ke}from"react";import{Fragment as Ue,jsx as x,jsxs as A}from"react/jsx-runtime";var D=e=>{let[o,t]=Ke(!1),r=()=>t(!1);return A(Ue,{children:[x($e,{onClick:()=>t(!0),...e,children:x(He,{fontSize:"small"})}),A(Me,{open:o,children:[x(Le,{children:"Understanding your Seed Phrase"}),A(Ge,{children:[A(Ye,{children:["Your Seed Phrase should adhere to the"," ",x(_e,{target:"_blank",href:"https://github.com/bitcoin/bips/blob/master/bip-0039.mediawiki",children:"bip39 specification"})," ","and is used to generate accounts which identify your data on the XYO Network."]}),A(Ve,{children:[x(R,{children:"Do not share this phrase with anyone."}),x(R,{children:"Do not save it to a public computer."}),x(R,{children:"Do not use a existing phrase from another wallet (i.e. Metamask)."}),x(R,{children:"Do not use before copying it down somewhere safe."})]})]}),x(Ne,{children:x(ze,{onClick:r,variant:"outlined",children:"OK"})})]})]})};import{Alert as qe,AlertTitle as Xe,Snackbar as Je}from"@mui/material";import{generateMnemonic as Qe}from"@scure/bip39";import{wordlist as Ze}from"@scure/bip39/wordlists/english";import{useEffect as je,useState as et}from"react";import{Fragment as tt,jsx as Q,jsxs as Z}from"react/jsx-runtime";var No=({changeSeedPhrase:e,children:o,hideDefaultSeedPhraseMessage:t,seedPhrase:r})=>{let[n,a]=et(!1);return je(()=>{if(!r){let i=Qe(Ze,256);e==null||e(i),a(!0)}},[e,r]),Z(tt,{children:[t?null:Q(Je,{open:n,autoHideDuration:5e3,onClose:()=>a(!1),anchorOrigin:{horizontal:"center",vertical:"top"},children:Z(qe,{severity:"success",children:[Q(Xe,{children:"Default Seed Phrase Generated"}),"Go to application settings to save it."]})}),o]})};import{Button as se,DialogActions as xt}from"@mui/material";import{createContextEx as ot}from"@xyo-network/react-shared";var k=ot();import{generateMnemonic as rt,validateMnemonic as nt}from"@scure/bip39";import{wordlist as te}from"@scure/bip39/wordlists/english";import{useCallback as E,useEffect as L,useMemo as j,useState as ee}from"react";import{jsx as at}from"react/jsx-runtime";var g=e=>e?nt(e,te):null,oe=({children:e,defaultPhrase:o,handleChangeSeedPhrase:t,saveCallback:r,seedPhrase:n,open:a})=>{let[i,l]=ee(),[u,s]=ee(!1);L(()=>{l(o)},[o]),L(()=>{(n||a)&&(l==null||l(n??""))},[n,a,l]);let m=E(()=>{let w=rt(te,256);l==null||l(w),s==null||s(!1)},[]),d=E(()=>{s==null||s(!1)},[]),v=E(()=>{l==null||l(""),s==null||s(!1)},[]),p=E(()=>{!u&&n&&n!==i?s==null||s(!0):(t==null||t(i??""),r==null||r())},[t,u,i,r,n]);L(()=>{a||d()},[d,a]);let W=j(()=>g==null?void 0:g(n),[n]),c=j(()=>g==null?void 0:g(i),[i]);return at(k.Provider,{value:{handleCancelOverwrite:d,handleChangeSeedPhrase:t,handleClear:v,handleGenerate:m,handleSave:p,overwriteWarning:u,phrase:i,provided:!0,seedPhrase:n,setOverwriteWarning:s,setPhrase:l,validPhrase:c,validSeedPhrase:W,validate:g},children:e})};import{useContextEx as st}from"@xyo-network/react-shared";var f=()=>st(k,"SeedPhrase",!0);import{createContextEx as it}from"@xyo-network/react-shared";var y=it();import{usePromise as lt}from"@xylabs/react-promise";import{useEffect as ct,useState as dt}from"react";import{jsx as ut}from"react/jsx-runtime";var nr=({children:e,defaultActiveAccountIndex:o=0,rootWallet:t=null,...r})=>{let[n,a]=dt(o);ct(()=>{o!==void 0&&a(o)},[o]);let[i=null]=lt(async()=>await(t==null?void 0:t.derivePath(n.toString())),[n,t]);return ut(y.Provider,{value:{activeAccount:i,activeAccountIndex:n,provided:!0,rootWallet:t,setActiveAccountIndex:a},...r,children:e})};import{usePromise as mt}from"@xylabs/react-promise";import{useContextEx as pt,useProvided as ft}from"@xyo-network/react-shared";var h=(e=!0)=>pt(y,"Wallet",e),re=()=>ft(y),ne=(e=!0)=>{let{rootWallet:o}=h(e);return[o,void 0]},ht=(e,o=!0)=>{let{rootWallet:t}=h(o),[r]=mt(async()=>await(t==null?void 0:t.derivePath(e.toString()))??t,[t,e]);return[r,void 0]},ae=(e=!0)=>{let{activeAccountIndex:o}=h(e),[t]=ht(o??0,e);return o===void 0&&t===null?[null,void 0]:[t,void 0]};import{jsx as ie,jsxs as Pt}from"react/jsx-runtime";var le=({onClose:e,...o})=>{let{handleSave:t,setPhrase:r}=f();return Pt(xt,{...o,children:[ie(se,{variant:"outlined",onClick:a=>{r==null||r(""),e==null||e(a,"escapeKeyDown")},children:"Cancel"}),ie(se,{variant:"outlined",onClick:t,children:"Save"})]})};import{FormControl as yt,TextField as It}from"@mui/material";var ce=e=>{switch(e){case!0:return"success";case!1:return"error";default:return}};import{Link as St,Typography as gt}from"@mui/material";import{jsx as Ct,jsxs as bt}from"react/jsx-runtime";var O=e=>bt(gt,{variant:"caption",color:"error",...e,children:["Invalid seed phrase. See -"," ",Ct(St,{target:"_blank",href:"https://github.com/bitcoin/bips/blob/master/bip-0039.mediawiki",children:"bip39 Proposal"})]});import{CheckCircleOutline as vt,HighlightOff as Wt}from"@mui/icons-material";import{FlexRow as wt}from"@xylabs/react-flexbox";import{useMemo as de}from"react";import{jsx as ue,jsxs as At}from"react/jsx-runtime";var H=({children:e,conditional:o,...t})=>{let r=de(()=>{switch(o){case!0:return"success";case!1:return"error";default:return null}},[o]),n=de(()=>{switch(r){case"success":return ue(vt,{fontSize:"small",color:"success"});case"error":return ue(Wt,{fontSize:"small",color:"error"});default:return null}},[r]);return At(wt,{justifyContent:"start",columnGap:1,...t,children:[n,e]})};import{Fragment as Tt,jsx as $,jsxs as Ft}from"react/jsx-runtime";var me=({children:e,disableColor:o,...t})=>{let{phrase:r,setPhrase:n,validPhrase:a}=f();return $(Tt,{children:Ft(yt,{fullWidth:!0,size:"small",sx:{display:"flex",flexDirection:"column",rowGap:1},children:[e,$(It,{focused:!0,color:o?void 0:ce(a),error:a===!1,helperText:a===!1?$(O,{}):null,fullWidth:!0,maxRows:Number.POSITIVE_INFINITY,multiline:!0,onChange:i=>n==null?void 0:n(i.target.value),value:r,...t})]})})};import{Button as pe,DialogActions as Bt}from"@mui/material";import{jsx as fe,jsxs as Rt}from"react/jsx-runtime";var he=()=>{let{handleClear:e,handleGenerate:o,overwriteWarning:t}=f();return Rt(Bt,{sx:{justifyContent:"center"},children:[fe(pe,{disabled:t,variant:"outlined",onClick:o,children:"Generate"}),fe(pe,{variant:"outlined",onClick:e,children:"Clear"})]})};import{Chip as Dt,FormControl as kt,FormLabel as Et,TextField as Ot}from"@mui/material";import{useState as Ht}from"react";import{Fragment as zt,jsx as I,jsxs as xe}from"react/jsx-runtime";var Pe=({fullWidth:e,showPhraseHeader:o,...t})=>{let{validSeedPhrase:r,seedPhrase:n}=f(),[a,i]=Ht(!1);return xe(kt,{fullWidth:e,size:"small",sx:{display:"flex",flexDirection:"column",rowGap:1},children:[I(Dt,{label:a?"Hide Saved Seed Phrase":"Reveal Saved Seed Phrase",onClick:()=>i(!a),sx:{alignSelf:"center"}}),a?xe(zt,{children:[o?I(Et,{children:I(H,{conditional:r,children:"Saved Seed Phrase"})}):null,I(Ot,{defaultValue:n,disabled:!0,error:r===!1,helperText:r===!1?I(O,{}):null,fullWidth:!0,maxRows:Number.POSITIVE_INFINITY,multiline:!0,...t})]}):null]})};import{Alert as Mt,Button as Se}from"@mui/material";import{FlexRow as Nt}from"@xylabs/react-flexbox";import{jsx as _,jsxs as Gt}from"react/jsx-runtime";var ge=()=>{let{handleCancelOverwrite:e,handleSave:o}=f();return _(Mt,{variant:"outlined",severity:"warning",action:Gt(Nt,{sx:{columnGap:1},children:[_(Se,{variant:"outlined",color:"inherit",size:"small",onClick:o,children:"Overwrite"}),_(Se,{variant:"outlined",color:"inherit",size:"small",onClick:e,children:"Cancel"})]}),children:"Are you sure you want to overwrite existing seed phrase? This action cannot be undone."})};import{Dialog as Lt,DialogContent as $t,DialogTitle as _t,FormLabel as Vt}from"@mui/material";import{jsx as P,jsxs as V}from"react/jsx-runtime";var Ce=({changeSeedPhrase:e,seedPhrase:o,...t})=>P(oe,{seedPhrase:o,handleChangeSeedPhrase:e,open:t.open,saveCallback:()=>{var r;return(r=t.onClose)==null?void 0:r.call(t,{},"escapeKeyDown")},children:P(Yt,{...t})}),Yt=e=>{let{overwriteWarning:o,seedPhrase:t,validPhrase:r}=f();return V(Lt,{"aria-labelledby":"alert-dialog-title","aria-describedby":"alert-dialog-description",fullWidth:!0,maxWidth:"sm",...e,children:[V(_t,{id:"alert-dialog-title",children:["Update Your Seed Phrase ",P(D,{})]}),V($t,{sx:{display:"flex",flexDirection:"column",rowGap:2},children:[P(me,{children:P(Vt,{children:P(H,{conditional:r,children:"New Seed Phrase"})})}),P(he,{}),t?P(Pe,{}):null,o?P(ge,{}):null]}),P(le,{onClose:e.onClose})]})};import{Cancel as Kt,RadioButtonChecked as Ut}from"@mui/icons-material";import{Button as qt,ButtonGroup as Xt,TableCell as Y,TableRow as Jt}from"@mui/material";import{useState as Qt}from"react";import{jsx as C,jsxs as K}from"react/jsx-runtime";var dn=({changeSeedPhrase:e,seedPhrase:o,...t})=>{let[r,n]=Qt(!1);return K(Jt,{...t,children:[K(Y,{children:["Seed Phrase ",C(D,{})]}),C(Y,{align:"center",children:o?C(Ut,{color:"success"}):C(Kt,{color:"error"})}),K(Y,{children:[C(Ce,{changeSeedPhrase:e,open:r,onClose:()=>n(!1),seedPhrase:o}),C(Xt,{fullWidth:!0,children:C(qt,{variant:"contained",size:"small",onClick:()=>{n(!0)},children:"Update"})})]})]})};import{EthAddress as so}from"@xylabs/eth-address";import{EthAccountButton as io}from"@xylabs/react-crypto";import{FlexCol as lo,FlexRow as co}from"@xylabs/react-flexbox";import{NumberStatus as z}from"@xylabs/react-number-status";import{useNetwork as uo}from"@xyo-network/react-network";import{usePromise as Zt}from"@xylabs/react-promise";import{useState as be}from"react";var ve=({wallet:e,account:o,index:t,required:r=!1}={})=>{let n=re(),[a,i]=be();e&&o&&!a&&i(new Error("useAccount can not have both a wallet and an account in the parameters")),t&&o&&!a&&i(new Error("useAccount can not have both a index and an account in the parameters"));let[l,u]=be(),[s]=ne(!e&&r),{activeAccountIndex:m}=h(!1),[d]=Zt(async()=>{var v,p;try{if(!a){if(e)return await((v=e==null?void 0:e.derivePath)==null?void 0:v.call(e,`${t??0}'\0`));if(s)return await((p=s==null?void 0:s.derivePath)==null?void 0:p.call(s,`${t??m??0}'\0`))}}catch(W){let c=W;console.error(c.message),u(c)}},[t,e,s,m,a]);return a&&!l&&(console.error(a.message),u(a)),[l?void 0:o??d??n?null:void 0,l]};import{usePromise as jt}from"@xylabs/react-promise";import{HDWallet as We}from"@xyo-network/account";import{useState as eo}from"react";var F=({mnemonic:e,wallet:o,path:t,required:r=!1,seed:n}={})=>{let a=h(!1),[i,l]=eo(),[u]=ae(!o&&r),[s]=jt(async()=>{var m;try{let d=await(o||(e?We.fromPhrase(e):n?We.fromSeed(n):u));return t?(m=d==null?void 0:d.derivePath)==null?void 0:m.call(d,t):d??o}catch(d){l(d)}},[e,u,n,t,o]);return[s??(a?null:s),i]};import{usePromise as to}from"@xylabs/react-promise";var An=({wallet:e,paths:o})=>{let t=h(!1),[r]=F({wallet:e}),[n,a]=to(async()=>r?await Promise.all(o.map(i=>r.derivePath(i))):void 0,[r,o]);return[n??(t?null:n),a]};import{usePromise as oo}from"@xylabs/react-promise";import{HDWallet as ro}from"@xyo-network/account";import{Mutex as no}from"async-mutex";var T,ao=new no,Rn=e=>oo(async()=>await ao.runExclusive(async()=>{if(e!==void 0)return e;if(T)return T;try{T=await ro.random(),console.log(`Global Wrapper Wallet Creation Success: ${T.address}`)}catch(o){console.error(`Global Wrapper Wallet Creation Failed: ${o.message}`)}return T}),[e]);import{jsx as B,jsxs as we}from"react/jsx-runtime";var Gn=({exploreUrl:e="https://explore.xyo.network",account:o,...t})=>{let[r]=ve({account:o}),{network:n}=uo(),a=`${e}/recent?account=${r==null?void 0:r.address}&network=${(n==null?void 0:n.name)??"main"}`;return we(lo,{...t,children:[B(io,{address:so.fromString(r==null?void 0:r.address)}),we(co,{gap:1,children:[B(z,{rounded:!0,title:"Tokens",value:0,to:`${a}&schema=network.xyo.account.tokens`,target:"_blank"}),B(z,{rounded:!0,title:"NFTs",value:0,to:`${a}&schema=network.xyo.account.nfts`,target:"_blank"}),B(z,{rounded:!0,title:"Signatures",value:0,to:`${a}&schema=network.xyo.account.signatures`,target:"_blank"}),B(z,{rounded:!0,title:"Signins",value:0,to:`${a}&schema=network.xyo.account.signins`,target:"_blank"})]})]})};import{CircularProgress as mo,MenuItem as Ae}from"@mui/material";import{SelectEx as po}from"@xylabs/react-select";import{AddressRenderRowBox as ye}from"@xyo-network/react-address-render";import{Fragment as ho,jsx as S}from"react/jsx-runtime";var fo=(e,o=0)=>[...Array.from({length:e}).keys()].map(t=>t+o),Ie=({addressNames:e={},iconOnly:o,iconSize:t=24,icons:r,maxAccounts:n=1,showFavorite:a=!1,size:i,variant:l="outlined",...u})=>{let{activeAccountIndex:s=0,setActiveAccountIndex:m,rootWallet:d}=h();return S(ho,{children:d?S(po,{margin:"dense",disabled:!d||s===void 0,renderValue:p=>S(()=>{let[c]=F({path:p.toString(),wallet:d}),w=c?e[c.address]:void 0,M=!!c&&c.address in e;return S(Ae,{value:p,sx:{minHeight:0,paddingBottom:0,paddingTop:0},children:S(ye,{disableSharedRef:!0,flexGrow:1,address:c==null?void 0:c.address,iconOnly:o,iconSize:t,icons:r,name:w,favorite:M,showFavorite:a})})},{}),value:s,onChange:p=>m==null?void 0:m(Number.parseInt(`${p.target.value}`)),size:i,variant:l,...u,children:fo(n).map(p=>S(()=>{let[c]=F({path:p.toString(),wallet:d}),w=c?e[c.address]:void 0,M=!!c&&c.address in e;return S(Ae,{value:p,sx:{minHeight:0,paddingBottom:0,paddingTop:0},children:S(ye,{disableSharedRef:!0,flexGrow:1,address:c==null?void 0:c.address,favorite:M,iconOnly:o,iconSize:t,icons:r,name:w,showFavorite:a})},c==null?void 0:c.address)},{},p))}):S(mo,{size:24})})};import{FlexCol as xo}from"@xylabs/react-flexbox";import{jsx as Fe}from"react/jsx-runtime";var ta=({addressNames:e={},iconOnly:o,iconSize:t,icons:r,maxAccounts:n=1,showFavorite:a=!1,size:i="small",...l})=>Fe(xo,{alignItems:"stretch",...l,children:Fe(Ie,{addressNames:e,fullWidth:!0,showFavorite:a,iconSize:t,iconOnly:o,icons:r,maxAccounts:n,size:i??"small",variant:"outlined"})});export{No as DefaultSeedPhrase,le as DialogActionButtons,O as InvalidPhraseTypography,yo as MaxAccountsTableRow,me as NewPhraseTextField,ge as OverwriteWarning,he as PhraseDialogActions,H as PhraseHeaderBox,Pe as SavedPhraseTextField,k as SeedPhraseContext,Ce as SeedPhraseDialog,Yt as SeedPhraseDialogInner,D as SeedPhraseIconButton,oe as SeedPhraseProvider,dn as SeedPhraseTableRow,Gn as WalletAccountDetails,Ie as WalletAccountSelect,ta as WalletAccountSelectBar,y as WalletContext,nr as WalletProvider,ce as colorParser,ve as useAccount,ht as useIndexedWalletFromContext,ne as useRootWallet,f as useSeedPhrase,ae as useSelectedWalletAccount,F as useWallet,h as useWalletContext,re as useWalletProvided,An as useWallets,Rn as useWrapperAccount};
808
2
  //# sourceMappingURL=index.js.map