@xyo-network/react-wallet 2.77.0 → 2.77.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser/components/SeedPhrase/dialog/components/fields/SavedPhraseTextField.d.cts +1 -0
- package/dist/browser/components/SeedPhrase/dialog/components/fields/SavedPhraseTextField.d.cts.map +1 -1
- package/dist/browser/components/SeedPhrase/dialog/components/fields/SavedPhraseTextField.d.mts +1 -0
- package/dist/browser/components/SeedPhrase/dialog/components/fields/SavedPhraseTextField.d.mts.map +1 -1
- package/dist/browser/components/SeedPhrase/dialog/components/fields/SavedPhraseTextField.d.ts +1 -0
- package/dist/browser/components/SeedPhrase/dialog/components/fields/SavedPhraseTextField.d.ts.map +1 -1
- package/dist/browser/contexts/Wallet/State.d.cts +0 -4
- package/dist/browser/contexts/Wallet/State.d.cts.map +1 -1
- package/dist/browser/contexts/Wallet/State.d.mts +0 -4
- package/dist/browser/contexts/Wallet/State.d.mts.map +1 -1
- package/dist/browser/contexts/Wallet/State.d.ts +0 -4
- package/dist/browser/contexts/Wallet/State.d.ts.map +1 -1
- package/dist/browser/contexts/Wallet/usePromise.d.cts +0 -3
- package/dist/browser/contexts/Wallet/usePromise.d.cts.map +1 -1
- package/dist/browser/contexts/Wallet/usePromise.d.mts +0 -3
- package/dist/browser/contexts/Wallet/usePromise.d.mts.map +1 -1
- package/dist/browser/contexts/Wallet/usePromise.d.ts +0 -3
- package/dist/browser/contexts/Wallet/usePromise.d.ts.map +1 -1
- package/dist/browser/index.cjs +1 -814
- package/dist/browser/index.cjs.map +1 -1
- package/dist/browser/index.js +1 -802
- package/dist/browser/index.js.map +1 -1
- package/dist/neutral/components/SeedPhrase/dialog/components/fields/SavedPhraseTextField.d.cts +1 -0
- package/dist/neutral/components/SeedPhrase/dialog/components/fields/SavedPhraseTextField.d.cts.map +1 -1
- package/dist/neutral/components/SeedPhrase/dialog/components/fields/SavedPhraseTextField.d.mts +1 -0
- package/dist/neutral/components/SeedPhrase/dialog/components/fields/SavedPhraseTextField.d.mts.map +1 -1
- package/dist/neutral/components/SeedPhrase/dialog/components/fields/SavedPhraseTextField.d.ts +1 -0
- package/dist/neutral/components/SeedPhrase/dialog/components/fields/SavedPhraseTextField.d.ts.map +1 -1
- package/dist/neutral/contexts/Wallet/State.d.cts +0 -4
- package/dist/neutral/contexts/Wallet/State.d.cts.map +1 -1
- package/dist/neutral/contexts/Wallet/State.d.mts +0 -4
- package/dist/neutral/contexts/Wallet/State.d.mts.map +1 -1
- package/dist/neutral/contexts/Wallet/State.d.ts +0 -4
- package/dist/neutral/contexts/Wallet/State.d.ts.map +1 -1
- package/dist/neutral/contexts/Wallet/usePromise.d.cts +0 -3
- package/dist/neutral/contexts/Wallet/usePromise.d.cts.map +1 -1
- package/dist/neutral/contexts/Wallet/usePromise.d.mts +0 -3
- package/dist/neutral/contexts/Wallet/usePromise.d.mts.map +1 -1
- package/dist/neutral/contexts/Wallet/usePromise.d.ts +0 -3
- package/dist/neutral/contexts/Wallet/usePromise.d.ts.map +1 -1
- package/dist/neutral/index.cjs +1 -814
- package/dist/neutral/index.cjs.map +1 -1
- package/dist/neutral/index.js +1 -802
- package/dist/neutral/index.js.map +1 -1
- package/dist/node/components/SeedPhrase/dialog/components/fields/SavedPhraseTextField.d.cts +1 -0
- package/dist/node/components/SeedPhrase/dialog/components/fields/SavedPhraseTextField.d.cts.map +1 -1
- package/dist/node/components/SeedPhrase/dialog/components/fields/SavedPhraseTextField.d.mts +1 -0
- package/dist/node/components/SeedPhrase/dialog/components/fields/SavedPhraseTextField.d.mts.map +1 -1
- package/dist/node/components/SeedPhrase/dialog/components/fields/SavedPhraseTextField.d.ts +1 -0
- package/dist/node/components/SeedPhrase/dialog/components/fields/SavedPhraseTextField.d.ts.map +1 -1
- package/dist/node/contexts/Wallet/State.d.cts +0 -4
- package/dist/node/contexts/Wallet/State.d.cts.map +1 -1
- package/dist/node/contexts/Wallet/State.d.mts +0 -4
- package/dist/node/contexts/Wallet/State.d.mts.map +1 -1
- package/dist/node/contexts/Wallet/State.d.ts +0 -4
- package/dist/node/contexts/Wallet/State.d.ts.map +1 -1
- package/dist/node/contexts/Wallet/usePromise.d.cts +0 -3
- package/dist/node/contexts/Wallet/usePromise.d.cts.map +1 -1
- package/dist/node/contexts/Wallet/usePromise.d.mts +0 -3
- package/dist/node/contexts/Wallet/usePromise.d.mts.map +1 -1
- package/dist/node/contexts/Wallet/usePromise.d.ts +0 -3
- package/dist/node/contexts/Wallet/usePromise.d.ts.map +1 -1
- package/dist/node/index.cjs +1 -853
- package/dist/node/index.cjs.map +1 -1
- package/dist/node/index.js +1 -807
- package/dist/node/index.js.map +1 -1
- package/package.json +7 -7
- package/src/components/SeedPhrase/dialog/components/fields/SavedPhraseTextField.tsx +3 -2
package/dist/node/index.js
CHANGED
|
@@ -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:t,setShowSnackBar:o,showSnackBar:r})=>U(Re,{anchorOrigin:{horizontal:"center",vertical:"top"},autoHideDuration:5e3,onClose:()=>o==null?void 0:o(!1),open:r,children:De(Te,{severity:"error",onClose:()=>o==null?void 0:o(!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 (",t,")."]})});import{jsx as b,jsxs as G}from"react/jsx-runtime";var yt=({activeAccountIndex:e,changeMaxAccounts:t,maxAccounts:o})=>{let[r,n]=J(),[a,i]=J(!1),l=u=>{if(o!==void 0&&e!==void 0)switch(u){case"decrease":{let s=o-1,m=s>0,d=e+1<=s;m&&d&&(t==null||t(s)),d||i(!0),n(s);return}case"increase":{t==null||t(o+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:o})}),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[t,o]=Ke(!1),r=()=>o(!1);return A(Ue,{children:[x($e,{onClick:()=>o(!0),...e,children:x(He,{fontSize:"small"})}),A(Me,{open:t,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 eo}from"react";import{Fragment as oo,jsx as Q,jsxs as Z}from"react/jsx-runtime";var Nt=({changeSeedPhrase:e,children:t,hideDefaultSeedPhraseMessage:o,seedPhrase:r})=>{let[n,a]=eo(!1);return je(()=>{if(!r){let i=Qe(Ze,256);e==null||e(i),a(!0)}},[e,r]),Z(oo,{children:[o?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."]})}),t]})};import{Button as se,DialogActions as Po}from"@mui/material";import{createContextEx as to}from"@xyo-network/react-shared";var k=to();import{generateMnemonic as ro,validateMnemonic as no}from"@scure/bip39";import{wordlist as oe}from"@scure/bip39/wordlists/english";import{useCallback as E,useEffect as L,useMemo as j,useState as ee}from"react";import{jsx as ao}from"react/jsx-runtime";var g=e=>e?no(e,oe):null,te=({children:e,defaultPhrase:t,handleChangeSeedPhrase:o,saveCallback:r,seedPhrase:n,open:a})=>{let[i,l]=ee(),[u,s]=ee(!1);L(()=>{l(t)},[t]),L(()=>{(n||a)&&(l==null||l(n??""))},[n,a,l]);let m=E(()=>{let w=ro(oe,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):(o==null||o(i??""),r==null||r())},[o,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 ao(k.Provider,{value:{handleCancelOverwrite:d,handleChangeSeedPhrase:o,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 so}from"@xyo-network/react-shared";var f=()=>so(k,"SeedPhrase",!0);import{createContextEx as io}from"@xyo-network/react-shared";var y=io();import{usePromise as lo}from"@xylabs/react-promise";import{useEffect as co,useState as uo}from"react";import{jsx as mo}from"react/jsx-runtime";var nr=({children:e,defaultActiveAccountIndex:t=0,rootWallet:o=null,...r})=>{let[n,a]=uo(t);co(()=>{t!==void 0&&a(t)},[t]);let[i=null]=lo(async()=>await(o==null?void 0:o.derivePath(n.toString())),[n,o]);return mo(y.Provider,{value:{activeAccount:i,activeAccountIndex:n,provided:!0,rootWallet:o,setActiveAccountIndex:a},...r,children:e})};import{usePromise as po}from"@xylabs/react-promise";import{useContextEx as fo,useProvided as ho}from"@xyo-network/react-shared";var h=(e=!0)=>fo(y,"Wallet",e),re=()=>ho(y),ne=(e=!0)=>{let{rootWallet:t}=h(e);return[t,void 0]},xo=(e,t=!0)=>{let{rootWallet:o}=h(t),[r]=po(async()=>await(o==null?void 0:o.derivePath(e.toString()))??o,[o,e]);return[r,void 0]},ae=(e=!0)=>{let{activeAccountIndex:t}=h(e),[o]=xo(t??0,e);return t===void 0&&o===null?[null,void 0]:[o,void 0]};import{jsx as ie,jsxs as So}from"react/jsx-runtime";var le=({onClose:e,...t})=>{let{handleSave:o,setPhrase:r}=f();return So(Po,{...t,children:[ie(se,{variant:"outlined",onClick:a=>{r==null||r(""),e==null||e(a,"escapeKeyDown")},children:"Cancel"}),ie(se,{variant:"outlined",onClick:o,children:"Save"})]})};import{FormControl as Io,TextField as Fo}from"@mui/material";var ce=e=>{switch(e){case!0:return"success";case!1:return"error";default:return}};import{Link as go,Typography as Co}from"@mui/material";import{jsx as bo,jsxs as vo}from"react/jsx-runtime";var O=e=>vo(Co,{variant:"caption",color:"error",...e,children:["Invalid seed phrase. See -"," ",bo(go,{target:"_blank",href:"https://github.com/bitcoin/bips/blob/master/bip-0039.mediawiki",children:"bip39 Proposal"})]});import{CheckCircleOutline as Wo,HighlightOff as wo}from"@mui/icons-material";import{FlexRow as Ao}from"@xylabs/react-flexbox";import{useMemo as de}from"react";import{jsx as ue,jsxs as yo}from"react/jsx-runtime";var H=({children:e,conditional:t,...o})=>{let r=de(()=>{switch(t){case!0:return"success";case!1:return"error";default:return null}},[t]),n=de(()=>{switch(r){case"success":return ue(Wo,{fontSize:"small",color:"success"});case"error":return ue(wo,{fontSize:"small",color:"error"});default:return null}},[r]);return yo(Ao,{justifyContent:"start",columnGap:1,...o,children:[n,e]})};import{Fragment as Bo,jsx as $,jsxs as To}from"react/jsx-runtime";var me=({children:e,disableColor:t,...o})=>{let{phrase:r,setPhrase:n,validPhrase:a}=f();return $(Bo,{children:To(Io,{fullWidth:!0,size:"small",sx:{display:"flex",flexDirection:"column",rowGap:1},children:[e,$(Fo,{focused:!0,color:t?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,...o})]})})};import{Button as pe,DialogActions as Ro}from"@mui/material";import{jsx as fe,jsxs as Do}from"react/jsx-runtime";var he=()=>{let{handleClear:e,handleGenerate:t,overwriteWarning:o}=f();return Do(Ro,{sx:{justifyContent:"center"},children:[fe(pe,{disabled:o,variant:"outlined",onClick:t,children:"Generate"}),fe(pe,{variant:"outlined",onClick:e,children:"Clear"})]})};import{Chip as ko,FormControl as Eo,FormLabel as Oo,TextField as Ho}from"@mui/material";import{useState as zo}from"react";import{Fragment as Mo,jsx as I,jsxs as xe}from"react/jsx-runtime";var Pe=({fullWidth:e,showPhraseHeader:t,...o})=>{let{validSeedPhrase:r,seedPhrase:n}=f(),[a,i]=zo(!1);return xe(Eo,{fullWidth:e,size:"small",sx:{display:"flex",flexDirection:"column",rowGap:1},children:[I(ko,{label:a?"Hide Saved Seed Phrase":"Reveal Saved Seed Phrase",onClick:()=>i(!a)}),a?xe(Mo,{children:[t?I(Oo,{children:I(H,{conditional:r,children:"Saved Seed Phrase"})}):null,I(Ho,{defaultValue:n,disabled:!0,error:r===!1,helperText:r===!1?I(O,{}):null,fullWidth:!0,maxRows:Number.POSITIVE_INFINITY,multiline:!0,...o})]}):null]})};import{Alert as No,Button as Se}from"@mui/material";import{FlexRow as Go}from"@xylabs/react-flexbox";import{jsx as _,jsxs as Lo}from"react/jsx-runtime";var ge=()=>{let{handleCancelOverwrite:e,handleSave:t}=f();return _(No,{variant:"outlined",severity:"warning",action:Lo(Go,{sx:{columnGap:1},children:[_(Se,{variant:"outlined",color:"inherit",size:"small",onClick:t,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 $o,DialogContent as _o,DialogTitle as Vo,FormLabel as Yo}from"@mui/material";import{jsx as P,jsxs as V}from"react/jsx-runtime";var Ce=({changeSeedPhrase:e,seedPhrase:t,...o})=>P(te,{seedPhrase:t,handleChangeSeedPhrase:e,open:o.open,saveCallback:()=>{var r;return(r=o.onClose)==null?void 0:r.call(o,{},"escapeKeyDown")},children:P(Ko,{...o})}),Ko=e=>{let{overwriteWarning:t,seedPhrase:o,validPhrase:r}=f();return V($o,{"aria-labelledby":"alert-dialog-title","aria-describedby":"alert-dialog-description",fullWidth:!0,maxWidth:"sm",...e,children:[V(Vo,{id:"alert-dialog-title",children:["Update Your Seed Phrase ",P(D,{})]}),V(_o,{sx:{display:"flex",flexDirection:"column",rowGap:2},children:[P(me,{children:P(Yo,{children:P(H,{conditional:r,children:"New Seed Phrase"})})}),P(he,{}),o?P(Pe,{}):null,t?P(ge,{}):null]}),P(le,{onClose:e.onClose})]})};import{Cancel as Uo,RadioButtonChecked as qo}from"@mui/icons-material";import{Button as Xo,ButtonGroup as Jo,TableCell as Y,TableRow as Qo}from"@mui/material";import{useState as Zo}from"react";import{jsx as C,jsxs as K}from"react/jsx-runtime";var dn=({changeSeedPhrase:e,seedPhrase:t,...o})=>{let[r,n]=Zo(!1);return K(Qo,{...o,children:[K(Y,{children:["Seed Phrase ",C(D,{})]}),C(Y,{align:"center",children:t?C(qo,{color:"success"}):C(Uo,{color:"error"})}),K(Y,{children:[C(Ce,{changeSeedPhrase:e,open:r,onClose:()=>n(!1),seedPhrase:t}),C(Jo,{fullWidth:!0,children:C(Xo,{variant:"contained",size:"small",onClick:()=>{n(!0)},children:"Update"})})]})]})};import{EthAddress as it}from"@xylabs/eth-address";import{EthAccountButton as lt}from"@xylabs/react-crypto";import{FlexCol as ct,FlexRow as dt}from"@xylabs/react-flexbox";import{NumberStatus as z}from"@xylabs/react-number-status";import{useNetwork as ut}from"@xyo-network/react-network";import{usePromise as jo}from"@xylabs/react-promise";import{useState as be}from"react";var ve=({wallet:e,account:t,index:o,required:r=!1}={})=>{let n=re(),[a,i]=be();e&&t&&!a&&i(new Error("useAccount can not have both a wallet and an account in the parameters")),o&&t&&!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]=jo(async()=>{var v,p;try{if(!a){if(e)return await((v=e==null?void 0:e.derivePath)==null?void 0:v.call(e,`${o??0}'\0`));if(s)return await((p=s==null?void 0:s.derivePath)==null?void 0:p.call(s,`${o??m??0}'\0`))}}catch(W){let c=W;console.error(c.message),u(c)}},[o,e,s,m,a]);return a&&!l&&(console.error(a.message),u(a)),[l?void 0:t??d??n?null:void 0,l]};import{usePromise as et}from"@xylabs/react-promise";import{HDWallet as We}from"@xyo-network/account";import{useState as ot}from"react";var F=({mnemonic:e,wallet:t,path:o,required:r=!1,seed:n}={})=>{let a=h(!1),[i,l]=ot(),[u]=ae(!t&&r),[s]=et(async()=>{var m;try{let d=await(t||(e?We.fromPhrase(e):n?We.fromSeed(n):u));return o?(m=d==null?void 0:d.derivePath)==null?void 0:m.call(d,o):d??t}catch(d){l(d)}},[e,u,n,o,t]);return[s??(a?null:s),i]};import{usePromise as tt}from"@xylabs/react-promise";var An=({wallet:e,paths:t})=>{let o=h(!1),[r]=F({wallet:e}),[n,a]=tt(async()=>r?await Promise.all(t.map(i=>r.derivePath(i))):void 0,[r,t]);return[n??(o?null:n),a]};import{usePromise as rt}from"@xylabs/react-promise";import{HDWallet as nt}from"@xyo-network/account";import{Mutex as at}from"async-mutex";var T,st=new at,Rn=e=>rt(async()=>await st.runExclusive(async()=>{if(e!==void 0)return e;if(T)return T;try{T=await nt.random(),console.log(`Global Wrapper Wallet Creation Success: ${T.address}`)}catch(t){console.error(`Global Wrapper Wallet Creation Failed: ${t.message}`)}return T}),[e]);import{jsx as B,jsxs as we}from"react/jsx-runtime";var Gn=({exploreUrl:e="https://explore.xyo.network",account:t,...o})=>{let[r]=ve({account:t}),{network:n}=ut(),a=`${e}/recent?account=${r==null?void 0:r.address}&network=${(n==null?void 0:n.name)??"main"}`;return we(ct,{...o,children:[B(lt,{address:it.fromString(r==null?void 0:r.address)}),we(dt,{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 mt,MenuItem as Ae}from"@mui/material";import{SelectEx as pt}from"@xylabs/react-select";import{AddressRenderRowBox as ye}from"@xyo-network/react-address-render";import{Fragment as ht,jsx as S}from"react/jsx-runtime";var ft=(e,t=0)=>[...Array.from({length:e}).keys()].map(o=>o+t),Ie=({addressNames:e={},iconOnly:t,iconSize:o=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(ht,{children:d?S(pt,{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:t,iconSize:o,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:ft(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:t,iconSize:o,icons:r,name:w,showFavorite:a})},c==null?void 0:c.address)},{},p))}):S(mt,{size:24})})};import{FlexCol as xt}from"@xylabs/react-flexbox";import{jsx as Fe}from"react/jsx-runtime";var oa=({addressNames:e={},iconOnly:t,iconSize:o,icons:r,maxAccounts:n=1,showFavorite:a=!1,size:i="small",...l})=>Fe(xt,{alignItems:"stretch",...l,children:Fe(Ie,{addressNames:e,fullWidth:!0,showFavorite:a,iconSize:o,iconOnly:t,icons:r,maxAccounts:n,size:i??"small",variant:"outlined"})});export{Nt as DefaultSeedPhrase,le as DialogActionButtons,O as InvalidPhraseTypography,yt as MaxAccountsTableRow,me as NewPhraseTextField,ge as OverwriteWarning,he as PhraseDialogActions,H as PhraseHeaderBox,Pe as SavedPhraseTextField,k as SeedPhraseContext,Ce as SeedPhraseDialog,Ko as SeedPhraseDialogInner,D as SeedPhraseIconButton,te as SeedPhraseProvider,dn as SeedPhraseTableRow,Gn as WalletAccountDetails,Ie as WalletAccountSelect,oa as WalletAccountSelectBar,y as WalletContext,nr as WalletProvider,ce as colorParser,ve as useAccount,xo 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
|