@xyo-network/react-wallet 2.77.0-rc.1 → 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 +11 -12
- package/src/components/SeedPhrase/dialog/components/fields/SavedPhraseTextField.tsx +3 -2
package/dist/neutral/index.js
CHANGED
|
@@ -1,803 +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?.(false),
|
|
21
|
-
open: showSnackBar,
|
|
22
|
-
children: /* @__PURE__ */ jsxs(Alert, { severity: "error", onClose: () => setShowSnackBar?.(false), children: [
|
|
23
|
-
/* @__PURE__ */ jsx(AlertTitle, { children: "Maximum Accounts Error" }),
|
|
24
|
-
"Your currently selected account number (",
|
|
25
|
-
activeAccountIndex === void 0 ? "" : activeAccountIndex + 1,
|
|
26
|
-
") cannot be greater than the desired Maximum Accounts (",
|
|
27
|
-
desiredMaximumAccounts,
|
|
28
|
-
")."
|
|
29
|
-
] })
|
|
30
|
-
}
|
|
31
|
-
);
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
// src/components/MaxAccounts/MaxAccountsTableRow.tsx
|
|
35
|
-
import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
36
|
-
var MaxAccountsTableRow = ({ activeAccountIndex, changeMaxAccounts, maxAccounts }) => {
|
|
37
|
-
const [desiredMaximumAccounts, setDesiredMaximumAccounts] = useState();
|
|
38
|
-
const [showSnackBar, setShowSnackBar] = useState(false);
|
|
39
|
-
const handleChangeMaxAccounts = (change) => {
|
|
40
|
-
if (maxAccounts !== void 0 && activeAccountIndex !== void 0) {
|
|
41
|
-
switch (change) {
|
|
42
|
-
case "decrease": {
|
|
43
|
-
const desiredMaximumAccounts2 = maxAccounts - 1;
|
|
44
|
-
const validMaximumAccounts = desiredMaximumAccounts2 > 0;
|
|
45
|
-
const maxAccountsWithinRange = activeAccountIndex + 1 <= desiredMaximumAccounts2;
|
|
46
|
-
if (validMaximumAccounts && maxAccountsWithinRange) {
|
|
47
|
-
changeMaxAccounts?.(desiredMaximumAccounts2);
|
|
48
|
-
}
|
|
49
|
-
if (!maxAccountsWithinRange)
|
|
50
|
-
setShowSnackBar(true);
|
|
51
|
-
setDesiredMaximumAccounts(desiredMaximumAccounts2);
|
|
52
|
-
return;
|
|
53
|
-
}
|
|
54
|
-
case "increase": {
|
|
55
|
-
changeMaxAccounts?.(maxAccounts + 1);
|
|
56
|
-
return;
|
|
57
|
-
}
|
|
58
|
-
default: {
|
|
59
|
-
console.error(change, "is not a recognized value");
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
} else {
|
|
63
|
-
throw new Error("Max Accounts is unset and needs a default");
|
|
64
|
-
}
|
|
65
|
-
};
|
|
66
|
-
return /* @__PURE__ */ jsxs2(TableRow, { children: [
|
|
67
|
-
/* @__PURE__ */ jsx2(TableCell, { children: "Maximum Accounts" }),
|
|
68
|
-
/* @__PURE__ */ jsx2(TableCell, { align: "center", children: /* @__PURE__ */ jsx2(Typography, { variant: "caption", children: maxAccounts }) }),
|
|
69
|
-
/* @__PURE__ */ jsxs2(TableCell, { align: "center", children: [
|
|
70
|
-
/* @__PURE__ */ jsxs2(ButtonGroup, { children: [
|
|
71
|
-
/* @__PURE__ */ jsx2(ButtonEx, { onClick: () => handleChangeMaxAccounts("decrease"), variant: "contained", size: "small", children: "-" }),
|
|
72
|
-
/* @__PURE__ */ jsx2(ButtonEx, { onClick: () => handleChangeMaxAccounts("increase"), variant: "contained", size: "small", children: "+" })
|
|
73
|
-
] }),
|
|
74
|
-
/* @__PURE__ */ jsx2(
|
|
75
|
-
OutOfBoundsSnackBar,
|
|
76
|
-
{
|
|
77
|
-
desiredMaximumAccounts,
|
|
78
|
-
activeAccountIndex,
|
|
79
|
-
setShowSnackBar,
|
|
80
|
-
showSnackBar
|
|
81
|
-
}
|
|
82
|
-
)
|
|
83
|
-
] })
|
|
84
|
-
] });
|
|
85
|
-
};
|
|
86
|
-
|
|
87
|
-
// src/components/SeedPhrase/_shared/SeedPhraseIconButton.tsx
|
|
88
|
-
import { HelpOutline as HelpOutlineIcon } from "@mui/icons-material";
|
|
89
|
-
import {
|
|
90
|
-
Button,
|
|
91
|
-
Dialog,
|
|
92
|
-
DialogActions,
|
|
93
|
-
DialogContent,
|
|
94
|
-
DialogTitle,
|
|
95
|
-
IconButton,
|
|
96
|
-
Link,
|
|
97
|
-
List,
|
|
98
|
-
ListItem,
|
|
99
|
-
Typography as Typography2
|
|
100
|
-
} from "@mui/material";
|
|
101
|
-
import { useState as useState2 } from "react";
|
|
102
|
-
import { Fragment, jsx as jsx3, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
103
|
-
var SeedPhraseIconButton = (props) => {
|
|
104
|
-
const [open, setOpen] = useState2(false);
|
|
105
|
-
const onClose = () => setOpen(false);
|
|
106
|
-
return /* @__PURE__ */ jsxs3(Fragment, { children: [
|
|
107
|
-
/* @__PURE__ */ jsx3(IconButton, { onClick: () => setOpen(true), ...props, children: /* @__PURE__ */ jsx3(HelpOutlineIcon, { fontSize: "small" }) }),
|
|
108
|
-
/* @__PURE__ */ jsxs3(Dialog, { open, children: [
|
|
109
|
-
/* @__PURE__ */ jsx3(DialogTitle, { children: "Understanding your Seed Phrase" }),
|
|
110
|
-
/* @__PURE__ */ jsxs3(DialogContent, { children: [
|
|
111
|
-
/* @__PURE__ */ jsxs3(Typography2, { children: [
|
|
112
|
-
"Your Seed Phrase should adhere to the",
|
|
113
|
-
" ",
|
|
114
|
-
/* @__PURE__ */ jsx3(Link, { target: "_blank", href: "https://github.com/bitcoin/bips/blob/master/bip-0039.mediawiki", children: "bip39 specification" }),
|
|
115
|
-
" ",
|
|
116
|
-
"and is used to generate accounts which identify your data on the XYO Network."
|
|
117
|
-
] }),
|
|
118
|
-
/* @__PURE__ */ jsxs3(List, { children: [
|
|
119
|
-
/* @__PURE__ */ jsx3(ListItem, { children: "Do not share this phrase with anyone." }),
|
|
120
|
-
/* @__PURE__ */ jsx3(ListItem, { children: "Do not save it to a public computer." }),
|
|
121
|
-
/* @__PURE__ */ jsx3(ListItem, { children: "Do not use a existing phrase from another wallet (i.e. Metamask)." }),
|
|
122
|
-
/* @__PURE__ */ jsx3(ListItem, { children: "Do not use before copying it down somewhere safe." })
|
|
123
|
-
] })
|
|
124
|
-
] }),
|
|
125
|
-
/* @__PURE__ */ jsx3(DialogActions, { children: /* @__PURE__ */ jsx3(Button, { onClick: onClose, variant: "outlined", children: "OK" }) })
|
|
126
|
-
] })
|
|
127
|
-
] });
|
|
128
|
-
};
|
|
129
|
-
|
|
130
|
-
// src/components/SeedPhrase/DefaultSeedPhrase.tsx
|
|
131
|
-
import { Alert as Alert2, AlertTitle as AlertTitle2, Snackbar as Snackbar2 } from "@mui/material";
|
|
132
|
-
import { generateMnemonic } 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?.(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?.(seedPhrase ?? "");
|
|
197
|
-
}
|
|
198
|
-
}, [seedPhrase, open, setPhrase]);
|
|
199
|
-
const handleGenerate = useCallback(() => {
|
|
200
|
-
const mnemonic = generateMnemonic2(wordlist2, 256);
|
|
201
|
-
setPhrase?.(mnemonic);
|
|
202
|
-
setOverwriteWarning?.(false);
|
|
203
|
-
}, []);
|
|
204
|
-
const handleCancelOverwrite = useCallback(() => {
|
|
205
|
-
setOverwriteWarning?.(false);
|
|
206
|
-
}, []);
|
|
207
|
-
const handleClear = useCallback(() => {
|
|
208
|
-
setPhrase?.("");
|
|
209
|
-
setOverwriteWarning?.(false);
|
|
210
|
-
}, []);
|
|
211
|
-
const handleSave = useCallback(() => {
|
|
212
|
-
if (!overwriteWarning && seedPhrase && seedPhrase !== phrase) {
|
|
213
|
-
setOverwriteWarning?.(true);
|
|
214
|
-
} else {
|
|
215
|
-
handleChangeSeedPhrase?.(phrase ?? "");
|
|
216
|
-
saveCallback?.();
|
|
217
|
-
}
|
|
218
|
-
}, [handleChangeSeedPhrase, overwriteWarning, phrase, saveCallback, seedPhrase]);
|
|
219
|
-
useEffect2(() => {
|
|
220
|
-
if (!open) {
|
|
221
|
-
handleCancelOverwrite();
|
|
222
|
-
}
|
|
223
|
-
}, [handleCancelOverwrite, open]);
|
|
224
|
-
const validSeedPhrase = useMemo(() => validate?.(seedPhrase), [seedPhrase]);
|
|
225
|
-
const validPhrase = useMemo(() => 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?.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?.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?.("");
|
|
321
|
-
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?.(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: () => props.onClose?.({}, "escapeKeyDown"),
|
|
488
|
-
children: /* @__PURE__ */ jsx14(SeedPhraseDialogInner, { ...props })
|
|
489
|
-
}
|
|
490
|
-
);
|
|
491
|
-
};
|
|
492
|
-
var SeedPhraseDialogInner = (props) => {
|
|
493
|
-
const { overwriteWarning, seedPhrase, validPhrase } = useSeedPhrase();
|
|
494
|
-
return /* @__PURE__ */ jsxs12(Dialog2, { "aria-labelledby": "alert-dialog-title", "aria-describedby": "alert-dialog-description", fullWidth: true, maxWidth: "sm", ...props, children: [
|
|
495
|
-
/* @__PURE__ */ jsxs12(DialogTitle2, { id: "alert-dialog-title", children: [
|
|
496
|
-
"Update Your Seed Phrase ",
|
|
497
|
-
/* @__PURE__ */ jsx14(SeedPhraseIconButton, {})
|
|
498
|
-
] }),
|
|
499
|
-
/* @__PURE__ */ jsxs12(DialogContent2, { sx: { display: "flex", flexDirection: "column", rowGap: 2 }, children: [
|
|
500
|
-
/* @__PURE__ */ jsx14(NewPhraseTextField, { children: /* @__PURE__ */ jsx14(FormLabel2, { children: /* @__PURE__ */ jsx14(PhraseHeaderBox, { conditional: validPhrase, children: "New Seed Phrase" }) }) }),
|
|
501
|
-
/* @__PURE__ */ jsx14(PhraseDialogActions, {}),
|
|
502
|
-
seedPhrase ? /* @__PURE__ */ jsx14(SavedPhraseTextField, {}) : null,
|
|
503
|
-
overwriteWarning ? /* @__PURE__ */ jsx14(OverwriteWarning, {}) : null
|
|
504
|
-
] }),
|
|
505
|
-
/* @__PURE__ */ jsx14(DialogActionButtons, { onClose: props.onClose })
|
|
506
|
-
] });
|
|
507
|
-
};
|
|
508
|
-
|
|
509
|
-
// src/components/SeedPhrase/settings/SeedPhraseTableRow.tsx
|
|
510
|
-
import { Cancel as CancelIcon, RadioButtonChecked as RadioButtonCheckedIcon } from "@mui/icons-material";
|
|
511
|
-
import { Button as Button5, ButtonGroup as ButtonGroup2, TableCell as TableCell2, TableRow as TableRow2 } from "@mui/material";
|
|
512
|
-
import { useState as useState7 } from "react";
|
|
513
|
-
import { jsx as jsx15, jsxs as jsxs13 } from "react/jsx-runtime";
|
|
514
|
-
var SeedPhraseTableRow = ({ changeSeedPhrase, seedPhrase, ...props }) => {
|
|
515
|
-
const [open, setOpen] = useState7(false);
|
|
516
|
-
const handleOpen = () => {
|
|
517
|
-
setOpen(true);
|
|
518
|
-
};
|
|
519
|
-
return /* @__PURE__ */ jsxs13(TableRow2, { ...props, children: [
|
|
520
|
-
/* @__PURE__ */ jsxs13(TableCell2, { children: [
|
|
521
|
-
"Seed Phrase ",
|
|
522
|
-
/* @__PURE__ */ jsx15(SeedPhraseIconButton, {})
|
|
523
|
-
] }),
|
|
524
|
-
/* @__PURE__ */ jsx15(TableCell2, { align: "center", children: seedPhrase ? /* @__PURE__ */ jsx15(RadioButtonCheckedIcon, { color: "success" }) : /* @__PURE__ */ jsx15(CancelIcon, { color: "error" }) }),
|
|
525
|
-
/* @__PURE__ */ jsxs13(TableCell2, { children: [
|
|
526
|
-
/* @__PURE__ */ jsx15(SeedPhraseDialog, { changeSeedPhrase, open, onClose: () => setOpen(false), seedPhrase }),
|
|
527
|
-
/* @__PURE__ */ jsx15(ButtonGroup2, { fullWidth: true, children: /* @__PURE__ */ jsx15(Button5, { variant: "contained", size: "small", onClick: handleOpen, children: "Update" }) })
|
|
528
|
-
] })
|
|
529
|
-
] });
|
|
530
|
-
};
|
|
531
|
-
|
|
532
|
-
// src/components/WalletAccountDetails/WalletAccountDetails.tsx
|
|
533
|
-
import { EthAddress } from "@xylabs/eth-address";
|
|
534
|
-
import { EthAccountButton } from "@xylabs/react-crypto";
|
|
535
|
-
import { FlexCol, FlexRow as FlexRow3 } from "@xylabs/react-flexbox";
|
|
536
|
-
import { NumberStatus } from "@xylabs/react-number-status";
|
|
537
|
-
import { useNetwork } from "@xyo-network/react-network";
|
|
538
|
-
|
|
539
|
-
// src/hooks/useAccount.ts
|
|
540
|
-
import { usePromise as usePromise3 } from "@xylabs/react-promise";
|
|
541
|
-
import { useState as useState8 } from "react";
|
|
542
|
-
var useAccount = ({ wallet, account, index, required = false } = {}) => {
|
|
543
|
-
const walletContextProvided = useWalletProvided();
|
|
544
|
-
const [validationError, setValidationError] = useState8();
|
|
545
|
-
if (wallet && account && !validationError) {
|
|
546
|
-
setValidationError(new Error("useAccount can not have both a wallet and an account in the parameters"));
|
|
547
|
-
}
|
|
548
|
-
if (index && account && !validationError) {
|
|
549
|
-
setValidationError(new Error("useAccount can not have both a index and an account in the parameters"));
|
|
550
|
-
}
|
|
551
|
-
const [error, setError] = useState8();
|
|
552
|
-
const [rootWallet] = useRootWallet(!wallet && required);
|
|
553
|
-
const { activeAccountIndex } = useWalletContext(false);
|
|
554
|
-
const [activeAccount] = usePromise3(async () => {
|
|
555
|
-
try {
|
|
556
|
-
if (!validationError) {
|
|
557
|
-
if (wallet) {
|
|
558
|
-
return await wallet?.derivePath?.(`${index ?? 0}'\0`);
|
|
559
|
-
} else if (rootWallet) {
|
|
560
|
-
return await rootWallet?.derivePath?.(`${index ?? activeAccountIndex ?? 0}'\0`);
|
|
561
|
-
}
|
|
562
|
-
}
|
|
563
|
-
} catch (ex) {
|
|
564
|
-
const error2 = ex;
|
|
565
|
-
console.error(error2.message);
|
|
566
|
-
setError(error2);
|
|
567
|
-
}
|
|
568
|
-
}, [index, wallet, rootWallet, activeAccountIndex, validationError]);
|
|
569
|
-
if (validationError && !error) {
|
|
570
|
-
console.error(validationError.message);
|
|
571
|
-
setError(validationError);
|
|
572
|
-
}
|
|
573
|
-
return [
|
|
574
|
-
error ? void 0 : account ?? activeAccount ?? walletContextProvided ? null : void 0,
|
|
575
|
-
error
|
|
576
|
-
];
|
|
577
|
-
};
|
|
578
|
-
|
|
579
|
-
// src/hooks/useWallet.ts
|
|
580
|
-
import { usePromise as usePromise4 } from "@xylabs/react-promise";
|
|
581
|
-
import { HDWallet } from "@xyo-network/account";
|
|
582
|
-
import { useState as useState9 } from "react";
|
|
583
|
-
var useWallet = ({ mnemonic, wallet, path, required = false, seed } = {}) => {
|
|
584
|
-
const walletContextProvided = useWalletContext(false);
|
|
585
|
-
const [error, setError] = useState9();
|
|
586
|
-
const [contextAccount] = useSelectedWalletAccount(!wallet && required);
|
|
587
|
-
const [activeAccount] = usePromise4(async () => {
|
|
588
|
-
try {
|
|
589
|
-
const newAccount = await (() => {
|
|
590
|
-
if (wallet) {
|
|
591
|
-
return wallet;
|
|
592
|
-
} else if (mnemonic) {
|
|
593
|
-
return HDWallet.fromPhrase(mnemonic);
|
|
594
|
-
} else if (seed) {
|
|
595
|
-
return HDWallet.fromSeed(seed);
|
|
596
|
-
}
|
|
597
|
-
return contextAccount;
|
|
598
|
-
})();
|
|
599
|
-
return path ? newAccount?.derivePath?.(path) : newAccount ?? wallet;
|
|
600
|
-
} catch (ex) {
|
|
601
|
-
setError(ex);
|
|
602
|
-
}
|
|
603
|
-
}, [mnemonic, contextAccount, seed, path, wallet]);
|
|
604
|
-
return [activeAccount ?? (walletContextProvided ? null : activeAccount), error];
|
|
605
|
-
};
|
|
606
|
-
|
|
607
|
-
// src/hooks/useWallets.ts
|
|
608
|
-
import { usePromise as usePromise5 } from "@xylabs/react-promise";
|
|
609
|
-
var useWallets = ({ wallet, paths }) => {
|
|
610
|
-
const walletContextProvided = useWalletContext(false);
|
|
611
|
-
const [foundWallet] = useWallet({ wallet });
|
|
612
|
-
const [wallets, error] = usePromise5(
|
|
613
|
-
async () => foundWallet ? await Promise.all(paths.map((path) => foundWallet.derivePath(path))) : void 0,
|
|
614
|
-
[foundWallet, paths]
|
|
615
|
-
);
|
|
616
|
-
return [wallets ?? (walletContextProvided ? null : wallets), error];
|
|
617
|
-
};
|
|
618
|
-
|
|
619
|
-
// src/hooks/useWrapperAccount.ts
|
|
620
|
-
import { usePromise as usePromise6 } from "@xylabs/react-promise";
|
|
621
|
-
import { HDWallet as HDWallet2 } from "@xyo-network/account";
|
|
622
|
-
import { Mutex } from "async-mutex";
|
|
623
|
-
var globalWrapperWallet;
|
|
624
|
-
var globalWrapperWalletMutex = new Mutex();
|
|
625
|
-
var useWrapperAccount = (account) => {
|
|
626
|
-
return usePromise6(async () => {
|
|
627
|
-
return await globalWrapperWalletMutex.runExclusive(async () => {
|
|
628
|
-
if (account !== void 0) {
|
|
629
|
-
return account;
|
|
630
|
-
}
|
|
631
|
-
if (globalWrapperWallet) {
|
|
632
|
-
return globalWrapperWallet;
|
|
633
|
-
}
|
|
634
|
-
try {
|
|
635
|
-
globalWrapperWallet = await HDWallet2.random();
|
|
636
|
-
console.log(`Global Wrapper Wallet Creation Success: ${globalWrapperWallet.address}`);
|
|
637
|
-
} catch (ex) {
|
|
638
|
-
const error = ex;
|
|
639
|
-
console.error(`Global Wrapper Wallet Creation Failed: ${error.message}`);
|
|
640
|
-
}
|
|
641
|
-
return globalWrapperWallet;
|
|
642
|
-
});
|
|
643
|
-
}, [account]);
|
|
644
|
-
};
|
|
645
|
-
|
|
646
|
-
// src/components/WalletAccountDetails/WalletAccountDetails.tsx
|
|
647
|
-
import { jsx as jsx16, jsxs as jsxs14 } from "react/jsx-runtime";
|
|
648
|
-
var WalletAccountDetails = ({ exploreUrl = "https://explore.xyo.network", account, ...props }) => {
|
|
649
|
-
const [accountToUse] = useAccount({ account });
|
|
650
|
-
const { network } = useNetwork();
|
|
651
|
-
const exploreAddressUrl = `${exploreUrl}/recent?account=${accountToUse?.address}&network=${network?.name ?? "main"}`;
|
|
652
|
-
return /* @__PURE__ */ jsxs14(FlexCol, { ...props, children: [
|
|
653
|
-
/* @__PURE__ */ jsx16(EthAccountButton, { address: EthAddress.fromString(accountToUse?.address) }),
|
|
654
|
-
/* @__PURE__ */ jsxs14(FlexRow3, { gap: 1, children: [
|
|
655
|
-
/* @__PURE__ */ jsx16(NumberStatus, { rounded: true, title: "Tokens", value: 0, to: `${exploreAddressUrl}&schema=network.xyo.account.tokens`, target: "_blank" }),
|
|
656
|
-
/* @__PURE__ */ jsx16(NumberStatus, { rounded: true, title: "NFTs", value: 0, to: `${exploreAddressUrl}&schema=network.xyo.account.nfts`, target: "_blank" }),
|
|
657
|
-
/* @__PURE__ */ jsx16(NumberStatus, { rounded: true, title: "Signatures", value: 0, to: `${exploreAddressUrl}&schema=network.xyo.account.signatures`, target: "_blank" }),
|
|
658
|
-
/* @__PURE__ */ jsx16(NumberStatus, { rounded: true, title: "Signins", value: 0, to: `${exploreAddressUrl}&schema=network.xyo.account.signins`, target: "_blank" })
|
|
659
|
-
] })
|
|
660
|
-
] });
|
|
661
|
-
};
|
|
662
|
-
|
|
663
|
-
// src/components/WalletAccountSelect/Select.tsx
|
|
664
|
-
import { CircularProgress, MenuItem } from "@mui/material";
|
|
665
|
-
import { SelectEx } from "@xylabs/react-select";
|
|
666
|
-
import { AddressRenderRowBox } from "@xyo-network/react-address-render";
|
|
667
|
-
import { Fragment as Fragment5, jsx as jsx17 } from "react/jsx-runtime";
|
|
668
|
-
var arrayRange = (length, start = 0) => {
|
|
669
|
-
return [...Array.from({ length }).keys()].map((x) => x + start);
|
|
670
|
-
};
|
|
671
|
-
var WalletAccountSelect = ({
|
|
672
|
-
addressNames = {},
|
|
673
|
-
iconOnly,
|
|
674
|
-
iconSize = 24,
|
|
675
|
-
icons,
|
|
676
|
-
maxAccounts = 1,
|
|
677
|
-
showFavorite = false,
|
|
678
|
-
size,
|
|
679
|
-
variant = "outlined",
|
|
680
|
-
...props
|
|
681
|
-
}) => {
|
|
682
|
-
const { activeAccountIndex = 0, setActiveAccountIndex, rootWallet } = useWalletContext();
|
|
683
|
-
const disabled = !rootWallet || activeAccountIndex === void 0;
|
|
684
|
-
return /* @__PURE__ */ jsx17(Fragment5, { children: rootWallet ? /* @__PURE__ */ jsx17(
|
|
685
|
-
SelectEx,
|
|
686
|
-
{
|
|
687
|
-
margin: "dense",
|
|
688
|
-
disabled,
|
|
689
|
-
renderValue: (selectedAccountIndex) => {
|
|
690
|
-
const Item = () => {
|
|
691
|
-
const [selectedAccount] = useWallet({ path: selectedAccountIndex.toString(), wallet: rootWallet });
|
|
692
|
-
const customName = selectedAccount ? addressNames[selectedAccount.address] : void 0;
|
|
693
|
-
const favorite = !!selectedAccount && selectedAccount.address in addressNames;
|
|
694
|
-
return /* @__PURE__ */ jsx17(MenuItem, { value: selectedAccountIndex, sx: { minHeight: 0, paddingBottom: 0, paddingTop: 0 }, children: /* @__PURE__ */ jsx17(
|
|
695
|
-
AddressRenderRowBox,
|
|
696
|
-
{
|
|
697
|
-
disableSharedRef: true,
|
|
698
|
-
flexGrow: 1,
|
|
699
|
-
address: selectedAccount?.address,
|
|
700
|
-
iconOnly,
|
|
701
|
-
iconSize,
|
|
702
|
-
icons,
|
|
703
|
-
name: customName,
|
|
704
|
-
favorite,
|
|
705
|
-
showFavorite
|
|
706
|
-
}
|
|
707
|
-
) });
|
|
708
|
-
};
|
|
709
|
-
return /* @__PURE__ */ jsx17(Item, {});
|
|
710
|
-
},
|
|
711
|
-
value: activeAccountIndex,
|
|
712
|
-
onChange: (event) => setActiveAccountIndex?.(Number.parseInt(`${event.target.value}`)),
|
|
713
|
-
size,
|
|
714
|
-
variant,
|
|
715
|
-
...props,
|
|
716
|
-
children: arrayRange(maxAccounts).map((index) => {
|
|
717
|
-
const Item = () => {
|
|
718
|
-
const [account] = useWallet({ path: index.toString(), wallet: rootWallet });
|
|
719
|
-
const customName = account ? addressNames[account.address] : void 0;
|
|
720
|
-
const favorite = !!account && account.address in addressNames;
|
|
721
|
-
return /* @__PURE__ */ jsx17(MenuItem, { value: index, sx: { minHeight: 0, paddingBottom: 0, paddingTop: 0 }, children: /* @__PURE__ */ jsx17(
|
|
722
|
-
AddressRenderRowBox,
|
|
723
|
-
{
|
|
724
|
-
disableSharedRef: true,
|
|
725
|
-
flexGrow: 1,
|
|
726
|
-
address: account?.address,
|
|
727
|
-
favorite,
|
|
728
|
-
iconOnly,
|
|
729
|
-
iconSize,
|
|
730
|
-
icons,
|
|
731
|
-
name: customName,
|
|
732
|
-
showFavorite
|
|
733
|
-
}
|
|
734
|
-
) }, account?.address);
|
|
735
|
-
};
|
|
736
|
-
return /* @__PURE__ */ jsx17(Item, {}, index);
|
|
737
|
-
})
|
|
738
|
-
}
|
|
739
|
-
) : /* @__PURE__ */ jsx17(CircularProgress, { size: 24 }) });
|
|
740
|
-
};
|
|
741
|
-
|
|
742
|
-
// src/components/WalletAccountSelect/SelectBar.tsx
|
|
743
|
-
import { FlexCol as FlexCol2 } from "@xylabs/react-flexbox";
|
|
744
|
-
import { jsx as jsx18 } from "react/jsx-runtime";
|
|
745
|
-
var WalletAccountSelectBar = ({
|
|
746
|
-
addressNames = {},
|
|
747
|
-
iconOnly,
|
|
748
|
-
iconSize,
|
|
749
|
-
icons,
|
|
750
|
-
maxAccounts = 1,
|
|
751
|
-
showFavorite = false,
|
|
752
|
-
size = "small",
|
|
753
|
-
...props
|
|
754
|
-
}) => {
|
|
755
|
-
return /* @__PURE__ */ jsx18(FlexCol2, { alignItems: "stretch", ...props, children: /* @__PURE__ */ jsx18(
|
|
756
|
-
WalletAccountSelect,
|
|
757
|
-
{
|
|
758
|
-
addressNames,
|
|
759
|
-
fullWidth: true,
|
|
760
|
-
showFavorite,
|
|
761
|
-
iconSize,
|
|
762
|
-
iconOnly,
|
|
763
|
-
icons,
|
|
764
|
-
maxAccounts,
|
|
765
|
-
size: size ?? "small",
|
|
766
|
-
variant: "outlined"
|
|
767
|
-
}
|
|
768
|
-
) });
|
|
769
|
-
};
|
|
770
|
-
export {
|
|
771
|
-
DefaultSeedPhrase,
|
|
772
|
-
DialogActionButtons,
|
|
773
|
-
InvalidPhraseTypography,
|
|
774
|
-
MaxAccountsTableRow,
|
|
775
|
-
NewPhraseTextField,
|
|
776
|
-
OverwriteWarning,
|
|
777
|
-
PhraseDialogActions,
|
|
778
|
-
PhraseHeaderBox,
|
|
779
|
-
SavedPhraseTextField,
|
|
780
|
-
SeedPhraseContext,
|
|
781
|
-
SeedPhraseDialog,
|
|
782
|
-
SeedPhraseDialogInner,
|
|
783
|
-
SeedPhraseIconButton,
|
|
784
|
-
SeedPhraseProvider,
|
|
785
|
-
SeedPhraseTableRow,
|
|
786
|
-
WalletAccountDetails,
|
|
787
|
-
WalletAccountSelect,
|
|
788
|
-
WalletAccountSelectBar,
|
|
789
|
-
WalletContext,
|
|
790
|
-
WalletProvider,
|
|
791
|
-
colorParser,
|
|
792
|
-
useAccount,
|
|
793
|
-
useIndexedWalletFromContext,
|
|
794
|
-
useRootWallet,
|
|
795
|
-
useSeedPhrase,
|
|
796
|
-
useSelectedWalletAccount,
|
|
797
|
-
useWallet,
|
|
798
|
-
useWalletContext,
|
|
799
|
-
useWalletProvided,
|
|
800
|
-
useWallets,
|
|
801
|
-
useWrapperAccount
|
|
802
|
-
};
|
|
1
|
+
import{ButtonGroup as De,TableCell as z,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 ye,AlertTitle as Te,Snackbar as Fe}from"@mui/material";import{jsx as K,jsxs as Re}from"react/jsx-runtime";var q=({activeAccountIndex:e,desiredMaximumAccounts:t,setShowSnackBar:o,showSnackBar:r})=>K(Fe,{anchorOrigin:{horizontal:"center",vertical:"top"},autoHideDuration:5e3,onClose:()=>o?.(!1),open:r,children:Re(ye,{severity:"error",onClose:()=>o?.(!1),children:[K(Te,{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 v,jsxs as N}from"react/jsx-runtime";var Bo=({activeAccountIndex:e,changeMaxAccounts:t,maxAccounts:o})=>{let[r,a]=J(),[n,s]=J(!1),i=c=>{if(o!==void 0&&e!==void 0)switch(c){case"decrease":{let l=o-1,u=l>0,m=e+1<=l;u&&m&&t?.(l),m||s(!0),a(l);return}case"increase":{t?.(o+1);return}default:console.error(c,"is not a recognized value")}else throw new Error("Max Accounts is unset and needs a default")};return N(Ee,{children:[v(z,{children:"Maximum Accounts"}),v(z,{align:"center",children:v(Oe,{variant:"caption",children:o})}),N(z,{align:"center",children:[N(De,{children:[v(X,{onClick:()=>i("decrease"),variant:"contained",size:"small",children:"-"}),v(X,{onClick:()=>i("increase"),variant:"contained",size:"small",children:"+"})]}),v(q,{desiredMaximumAccounts:r,activeAccountIndex:e,setShowSnackBar:s,showSnackBar:n})]})]})};import{HelpOutline as Me}from"@mui/icons-material";import{Button as He,Dialog as ze,DialogActions as Ne,DialogContent as Ge,DialogTitle as Le,IconButton as $e,Link as _e,List as Ue,ListItem as y,Typography as Ve}from"@mui/material";import{useState as Ye}from"react";import{Fragment as Ke,jsx as P,jsxs as b}from"react/jsx-runtime";var T=e=>{let[t,o]=Ye(!1),r=()=>o(!1);return b(Ke,{children:[P($e,{onClick:()=>o(!0),...e,children:P(Me,{fontSize:"small"})}),b(ze,{open:t,children:[P(Le,{children:"Understanding your Seed Phrase"}),b(Ge,{children:[b(Ve,{children:["Your Seed Phrase should adhere to the"," ",P(_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."]}),b(Ue,{children:[P(y,{children:"Do not share this phrase with anyone."}),P(y,{children:"Do not save it to a public computer."}),P(y,{children:"Do not use a existing phrase from another wallet (i.e. Metamask)."}),P(y,{children:"Do not use before copying it down somewhere safe."})]})]}),P(Ne,{children:P(He,{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:t,hideDefaultSeedPhraseMessage:o,seedPhrase:r})=>{let[a,n]=et(!1);return je(()=>{if(!r){let s=Qe(Ze,256);e?.(s),n(!0)}},[e,r]),Z(tt,{children:[o?null:Q(Je,{open:a,autoHideDuration:5e3,onClose:()=>n(!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 Pt}from"@mui/material";import{createContextEx as ot}from"@xyo-network/react-shared";var F=ot();import{generateMnemonic as rt,validateMnemonic as nt}from"@scure/bip39";import{wordlist as te}from"@scure/bip39/wordlists/english";import{useCallback as R,useEffect as G,useMemo as j,useState as ee}from"react";import{jsx as at}from"react/jsx-runtime";var L=e=>e?nt(e,te):null,oe=({children:e,defaultPhrase:t,handleChangeSeedPhrase:o,saveCallback:r,seedPhrase:a,open:n})=>{let[s,i]=ee(),[c,l]=ee(!1);G(()=>{i(t)},[t]),G(()=>{(a||n)&&i?.(a??"")},[a,n,i]);let u=R(()=>{let C=rt(te,256);i?.(C),l?.(!1)},[]),m=R(()=>{l?.(!1)},[]),k=R(()=>{i?.(""),l?.(!1)},[]),p=R(()=>{!c&&a&&a!==s?l?.(!0):(o?.(s??""),r?.())},[o,c,s,r,a]);G(()=>{n||m()},[m,n]);let M=j(()=>L?.(a),[a]),d=j(()=>L?.(s),[s]);return at(F.Provider,{value:{handleCancelOverwrite:m,handleChangeSeedPhrase:o,handleClear:k,handleGenerate:u,handleSave:p,overwriteWarning:c,phrase:s,provided:!0,seedPhrase:a,setOverwriteWarning:l,setPhrase:i,validPhrase:d,validSeedPhrase:M,validate:L},children:e})};import{useContextEx as st}from"@xyo-network/react-shared";var f=()=>st(F,"SeedPhrase",!0);import{createContextEx as lt}from"@xyo-network/react-shared";var w=lt();import{usePromise as it}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:t=0,rootWallet:o=null,...r})=>{let[a,n]=dt(t);ct(()=>{t!==void 0&&n(t)},[t]);let[s=null]=it(async()=>await o?.derivePath(a.toString()),[a,o]);return ut(w.Provider,{value:{activeAccount:s,activeAccountIndex:a,provided:!0,rootWallet:o,setActiveAccountIndex:n},...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(w,"Wallet",e),re=()=>ft(w),ne=(e=!0)=>{let{rootWallet:t}=h(e);return[t,void 0]},ht=(e,t=!0)=>{let{rootWallet:o}=h(t),[r]=mt(async()=>await o?.derivePath(e.toString())??o,[o,e]);return[r,void 0]},ae=(e=!0)=>{let{activeAccountIndex:t}=h(e),[o]=ht(t??0,e);return t===void 0&&o===null?[null,void 0]:[o,void 0]};import{jsx as le,jsxs as xt}from"react/jsx-runtime";var ie=({onClose:e,...t})=>{let{handleSave:o,setPhrase:r}=f();return xt(Pt,{...t,children:[le(se,{variant:"outlined",onClick:n=>{r?.(""),e?.(n,"escapeKeyDown")},children:"Cancel"}),le(se,{variant:"outlined",onClick:o,children:"Save"})]})};import{FormControl as Bt,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 vt,jsxs as Ct}from"react/jsx-runtime";var D=e=>Ct(gt,{variant:"caption",color:"error",...e,children:["Invalid seed phrase. See -"," ",vt(St,{target:"_blank",href:"https://github.com/bitcoin/bips/blob/master/bip-0039.mediawiki",children:"bip39 Proposal"})]});import{CheckCircleOutline as bt,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 E=({children:e,conditional:t,...o})=>{let r=de(()=>{switch(t){case!0:return"success";case!1:return"error";default:return null}},[t]),a=de(()=>{switch(r){case"success":return ue(bt,{fontSize:"small",color:"success"});case"error":return ue(wt,{fontSize:"small",color:"error"});default:return null}},[r]);return At(Wt,{justifyContent:"start",columnGap:1,...o,children:[a,e]})};import{Fragment as yt,jsx as $,jsxs as kt}from"react/jsx-runtime";var me=({children:e,disableColor:t,...o})=>{let{phrase:r,setPhrase:a,validPhrase:n}=f();return $(yt,{children:kt(Bt,{fullWidth:!0,size:"small",sx:{display:"flex",flexDirection:"column",rowGap:1},children:[e,$(It,{focused:!0,color:t?void 0:ce(n),error:n===!1,helperText:n===!1?$(D,{}):null,fullWidth:!0,maxRows:Number.POSITIVE_INFINITY,multiline:!0,onChange:s=>a?.(s.target.value),value:r,...o})]})})};import{Button as pe,DialogActions as Tt}from"@mui/material";import{jsx as fe,jsxs as Ft}from"react/jsx-runtime";var he=()=>{let{handleClear:e,handleGenerate:t,overwriteWarning:o}=f();return Ft(Tt,{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 Rt,FormControl as Dt,FormLabel as Et,TextField as Ot}from"@mui/material";import{useState as Mt}from"react";import{Fragment as Ht,jsx as W,jsxs as Pe}from"react/jsx-runtime";var xe=({fullWidth:e,showPhraseHeader:t,...o})=>{let{validSeedPhrase:r,seedPhrase:a}=f(),[n,s]=Mt(!1);return Pe(Dt,{fullWidth:e,size:"small",sx:{display:"flex",flexDirection:"column",rowGap:1},children:[W(Rt,{label:n?"Hide Saved Seed Phrase":"Reveal Saved Seed Phrase",onClick:()=>s(!n)}),n?Pe(Ht,{children:[t?W(Et,{children:W(E,{conditional:r,children:"Saved Seed Phrase"})}):null,W(Ot,{defaultValue:a,disabled:!0,error:r===!1,helperText:r===!1?W(D,{}):null,fullWidth:!0,maxRows:Number.POSITIVE_INFINITY,multiline:!0,...o})]}):null]})};import{Alert as zt,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:t}=f();return _(zt,{variant:"outlined",severity:"warning",action:Gt(Nt,{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 Lt,DialogContent as $t,DialogTitle as _t,FormLabel as Ut}from"@mui/material";import{jsx as x,jsxs as U}from"react/jsx-runtime";var ve=({changeSeedPhrase:e,seedPhrase:t,...o})=>x(oe,{seedPhrase:t,handleChangeSeedPhrase:e,open:o.open,saveCallback:()=>o.onClose?.({},"escapeKeyDown"),children:x(Vt,{...o})}),Vt=e=>{let{overwriteWarning:t,seedPhrase:o,validPhrase:r}=f();return U(Lt,{"aria-labelledby":"alert-dialog-title","aria-describedby":"alert-dialog-description",fullWidth:!0,maxWidth:"sm",...e,children:[U(_t,{id:"alert-dialog-title",children:["Update Your Seed Phrase ",x(T,{})]}),U($t,{sx:{display:"flex",flexDirection:"column",rowGap:2},children:[x(me,{children:x(Ut,{children:x(E,{conditional:r,children:"New Seed Phrase"})})}),x(he,{}),o?x(xe,{}):null,t?x(ge,{}):null]}),x(ie,{onClose:e.onClose})]})};import{Cancel as Yt,RadioButtonChecked as Kt}from"@mui/icons-material";import{Button as qt,ButtonGroup as Xt,TableCell as V,TableRow as Jt}from"@mui/material";import{useState as Qt}from"react";import{jsx as g,jsxs as Y}from"react/jsx-runtime";var dn=({changeSeedPhrase:e,seedPhrase:t,...o})=>{let[r,a]=Qt(!1);return Y(Jt,{...o,children:[Y(V,{children:["Seed Phrase ",g(T,{})]}),g(V,{align:"center",children:t?g(Kt,{color:"success"}):g(Yt,{color:"error"})}),Y(V,{children:[g(ve,{changeSeedPhrase:e,open:r,onClose:()=>a(!1),seedPhrase:t}),g(Xt,{fullWidth:!0,children:g(qt,{variant:"contained",size:"small",onClick:()=>{a(!0)},children:"Update"})})]})]})};import{EthAddress as so}from"@xylabs/eth-address";import{EthAccountButton as lo}from"@xylabs/react-crypto";import{FlexCol as io,FlexRow as co}from"@xylabs/react-flexbox";import{NumberStatus as O}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 Ce}from"react";var be=({wallet:e,account:t,index:o,required:r=!1}={})=>{let a=re(),[n,s]=Ce();e&&t&&!n&&s(new Error("useAccount can not have both a wallet and an account in the parameters")),o&&t&&!n&&s(new Error("useAccount can not have both a index and an account in the parameters"));let[i,c]=Ce(),[l]=ne(!e&&r),{activeAccountIndex:u}=h(!1),[m]=Zt(async()=>{try{if(!n){if(e)return await e?.derivePath?.(`${o??0}'\0`);if(l)return await l?.derivePath?.(`${o??u??0}'\0`)}}catch(k){let p=k;console.error(p.message),c(p)}},[o,e,l,u,n]);return n&&!i&&(console.error(n.message),c(n)),[i?void 0:t??m??a?null:void 0,i]};import{usePromise as jt}from"@xylabs/react-promise";import{HDWallet as we}from"@xyo-network/account";import{useState as eo}from"react";var A=({mnemonic:e,wallet:t,path:o,required:r=!1,seed:a}={})=>{let n=h(!1),[s,i]=eo(),[c]=ae(!t&&r),[l]=jt(async()=>{try{let u=await(t||(e?we.fromPhrase(e):a?we.fromSeed(a):c));return o?u?.derivePath?.(o):u??t}catch(u){i(u)}},[e,c,a,o,t]);return[l??(n?null:l),s]};import{usePromise as to}from"@xylabs/react-promise";var An=({wallet:e,paths:t})=>{let o=h(!1),[r]=A({wallet:e}),[a,n]=to(async()=>r?await Promise.all(t.map(s=>r.derivePath(s))):void 0,[r,t]);return[a??(o?null:a),n]};import{usePromise as oo}from"@xylabs/react-promise";import{HDWallet as ro}from"@xyo-network/account";import{Mutex as no}from"async-mutex";var B,ao=new no,Fn=e=>oo(async()=>await ao.runExclusive(async()=>{if(e!==void 0)return e;if(B)return B;try{B=await ro.random(),console.log(`Global Wrapper Wallet Creation Success: ${B.address}`)}catch(t){console.error(`Global Wrapper Wallet Creation Failed: ${t.message}`)}return B}),[e]);import{jsx as I,jsxs as We}from"react/jsx-runtime";var Gn=({exploreUrl:e="https://explore.xyo.network",account:t,...o})=>{let[r]=be({account:t}),{network:a}=uo(),n=`${e}/recent?account=${r?.address}&network=${a?.name??"main"}`;return We(io,{...o,children:[I(lo,{address:so.fromString(r?.address)}),We(co,{gap:1,children:[I(O,{rounded:!0,title:"Tokens",value:0,to:`${n}&schema=network.xyo.account.tokens`,target:"_blank"}),I(O,{rounded:!0,title:"NFTs",value:0,to:`${n}&schema=network.xyo.account.nfts`,target:"_blank"}),I(O,{rounded:!0,title:"Signatures",value:0,to:`${n}&schema=network.xyo.account.signatures`,target:"_blank"}),I(O,{rounded:!0,title:"Signins",value:0,to:`${n}&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 Be}from"@xyo-network/react-address-render";import{Fragment as ho,jsx as S}from"react/jsx-runtime";var fo=(e,t=0)=>[...Array.from({length:e}).keys()].map(o=>o+t),Ie=({addressNames:e={},iconOnly:t,iconSize:o=24,icons:r,maxAccounts:a=1,showFavorite:n=!1,size:s,variant:i="outlined",...c})=>{let{activeAccountIndex:l=0,setActiveAccountIndex:u,rootWallet:m}=h();return S(ho,{children:m?S(po,{margin:"dense",disabled:!m||l===void 0,renderValue:p=>S(()=>{let[d]=A({path:p.toString(),wallet:m}),C=d?e[d.address]:void 0,H=!!d&&d.address in e;return S(Ae,{value:p,sx:{minHeight:0,paddingBottom:0,paddingTop:0},children:S(Be,{disableSharedRef:!0,flexGrow:1,address:d?.address,iconOnly:t,iconSize:o,icons:r,name:C,favorite:H,showFavorite:n})})},{}),value:l,onChange:p=>u?.(Number.parseInt(`${p.target.value}`)),size:s,variant:i,...c,children:fo(a).map(p=>S(()=>{let[d]=A({path:p.toString(),wallet:m}),C=d?e[d.address]:void 0,H=!!d&&d.address in e;return S(Ae,{value:p,sx:{minHeight:0,paddingBottom:0,paddingTop:0},children:S(Be,{disableSharedRef:!0,flexGrow:1,address:d?.address,favorite:H,iconOnly:t,iconSize:o,icons:r,name:C,showFavorite:n})},d?.address)},{},p))}):S(mo,{size:24})})};import{FlexCol as Po}from"@xylabs/react-flexbox";import{jsx as ke}from"react/jsx-runtime";var ta=({addressNames:e={},iconOnly:t,iconSize:o,icons:r,maxAccounts:a=1,showFavorite:n=!1,size:s="small",...i})=>ke(Po,{alignItems:"stretch",...i,children:ke(Ie,{addressNames:e,fullWidth:!0,showFavorite:n,iconSize:o,iconOnly:t,icons:r,maxAccounts:a,size:s??"small",variant:"outlined"})});export{No as DefaultSeedPhrase,ie as DialogActionButtons,D as InvalidPhraseTypography,Bo as MaxAccountsTableRow,me as NewPhraseTextField,ge as OverwriteWarning,he as PhraseDialogActions,E as PhraseHeaderBox,xe as SavedPhraseTextField,F as SeedPhraseContext,ve as SeedPhraseDialog,Vt as SeedPhraseDialogInner,T as SeedPhraseIconButton,oe as SeedPhraseProvider,dn as SeedPhraseTableRow,Gn as WalletAccountDetails,Ie as WalletAccountSelect,ta as WalletAccountSelectBar,w as WalletContext,nr as WalletProvider,ce as colorParser,be as useAccount,ht as useIndexedWalletFromContext,ne as useRootWallet,f as useSeedPhrase,ae as useSelectedWalletAccount,A as useWallet,h as useWalletContext,re as useWalletProvided,An as useWallets,Fn as useWrapperAccount};
|
|
803
2
|
//# sourceMappingURL=index.js.map
|