@xyo-network/react-wallet 7.0.0 → 7.0.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/DefaultSeedPhrase.stories.d.ts +3 -3
- package/dist/browser/components/SeedPhrase/DefaultSeedPhrase.stories.d.ts.map +1 -1
- package/dist/browser/components/SeedPhrase/dialog/SeedPhraseDialog.stories.d.ts +1 -1
- package/dist/browser/components/SeedPhrase/dialog/SeedPhraseDialog.stories.d.ts.map +1 -1
- package/dist/browser/components/SeedPhrase/dialog/components/fields/PhraseDialogActions.stories.d.ts +3 -3
- package/dist/browser/components/SeedPhrase/dialog/components/fields/PhraseDialogActions.stories.d.ts.map +1 -1
- package/dist/browser/components/SeedPhrase/settings/SeedPhraseTableRow.stories.d.ts +2 -2
- package/dist/browser/components/SeedPhrase/settings/SeedPhraseTableRow.stories.d.ts.map +1 -1
- package/dist/browser/components/WalletAccountDetails/WalletAccountDetails.stories.d.ts +1 -1
- package/dist/browser/components/WalletAccountDetails/WalletAccountDetails.stories.d.ts.map +1 -1
- package/dist/browser/components/WalletAccountDetails/WalletAccountDetailsWithProvider.stories.d.ts +1 -1
- package/dist/browser/components/WalletAccountDetails/WalletAccountDetailsWithProvider.stories.d.ts.map +1 -1
- package/dist/browser/components/WalletAccountSelect/WalletAccountSelect.stories.d.ts +2 -2
- package/dist/browser/components/WalletAccountSelect/WalletAccountSelect.stories.d.ts.map +1 -1
- package/dist/browser/components/WalletAccountSelect/WalletAccountSelectBar.stories.d.ts +5 -5
- package/dist/browser/components/WalletAccountSelect/WalletAccountSelectBar.stories.d.ts.map +1 -1
- package/dist/browser/components/WalletAccountSelect/WalletAccountSelectWithProvider.stories.d.ts +6 -6
- package/dist/browser/components/WalletAccountSelect/WalletAccountSelectWithProvider.stories.d.ts.map +1 -1
- package/dist/browser/index.mjs +673 -572
- package/dist/browser/index.mjs.map +1 -1
- package/package.json +39 -36
package/dist/browser/index.mjs
CHANGED
|
@@ -1,34 +1,55 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
-
|
|
4
1
|
// src/components/MaxAccounts/MaxAccountsTableRow.tsx
|
|
5
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
ButtonGroup,
|
|
4
|
+
TableCell,
|
|
5
|
+
TableRow,
|
|
6
|
+
Typography
|
|
7
|
+
} from "@mui/material";
|
|
6
8
|
import { ButtonEx } from "@xylabs/react-button";
|
|
7
|
-
import
|
|
9
|
+
import { useState } from "react";
|
|
8
10
|
|
|
9
11
|
// src/components/MaxAccounts/OutOfBoundsSnackBar.tsx
|
|
10
|
-
import {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
12
|
+
import {
|
|
13
|
+
Alert,
|
|
14
|
+
AlertTitle,
|
|
15
|
+
Snackbar
|
|
16
|
+
} from "@mui/material";
|
|
17
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
18
|
+
var OutOfBoundsSnackBar = ({
|
|
19
|
+
activeAccountIndex,
|
|
20
|
+
desiredMaximumAccounts,
|
|
21
|
+
setShowSnackBar,
|
|
22
|
+
showSnackBar
|
|
23
|
+
}) => {
|
|
24
|
+
return /* @__PURE__ */ jsx(
|
|
25
|
+
Snackbar,
|
|
26
|
+
{
|
|
27
|
+
anchorOrigin: { horizontal: "center", vertical: "top" },
|
|
28
|
+
autoHideDuration: 5e3,
|
|
29
|
+
onClose: () => setShowSnackBar?.(false),
|
|
30
|
+
open: showSnackBar,
|
|
31
|
+
children: /* @__PURE__ */ jsxs(Alert, { severity: "error", onClose: () => setShowSnackBar?.(false), children: [
|
|
32
|
+
/* @__PURE__ */ jsx(AlertTitle, { children: "Maximum Accounts Error" }),
|
|
33
|
+
"Your currently selected account number (",
|
|
34
|
+
activeAccountIndex === void 0 ? "" : activeAccountIndex + 1,
|
|
35
|
+
") cannot be greater than the desired Maximum Accounts (",
|
|
36
|
+
desiredMaximumAccounts,
|
|
37
|
+
")."
|
|
38
|
+
] })
|
|
39
|
+
}
|
|
40
|
+
);
|
|
41
|
+
};
|
|
26
42
|
|
|
27
43
|
// src/components/MaxAccounts/MaxAccountsTableRow.tsx
|
|
28
|
-
|
|
44
|
+
import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
45
|
+
var MaxAccountsTableRow = ({
|
|
46
|
+
activeAccountIndex,
|
|
47
|
+
changeMaxAccounts,
|
|
48
|
+
maxAccounts
|
|
49
|
+
}) => {
|
|
29
50
|
const [desiredMaximumAccounts, setDesiredMaximumAccounts] = useState();
|
|
30
51
|
const [showSnackBar, setShowSnackBar] = useState(false);
|
|
31
|
-
const handleChangeMaxAccounts =
|
|
52
|
+
const handleChangeMaxAccounts = (change) => {
|
|
32
53
|
if (maxAccounts !== void 0 && activeAccountIndex !== void 0) {
|
|
33
54
|
switch (change) {
|
|
34
55
|
case "decrease": {
|
|
@@ -53,58 +74,87 @@ var MaxAccountsTableRow = /* @__PURE__ */ __name(({ activeAccountIndex, changeMa
|
|
|
53
74
|
} else {
|
|
54
75
|
throw new Error("Max Accounts is unset and needs a default");
|
|
55
76
|
}
|
|
56
|
-
}
|
|
57
|
-
return /* @__PURE__ */
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
}, "MaxAccountsTableRow");
|
|
77
|
+
};
|
|
78
|
+
return /* @__PURE__ */ jsxs2(TableRow, { children: [
|
|
79
|
+
/* @__PURE__ */ jsx2(TableCell, { children: "Maximum Accounts" }),
|
|
80
|
+
/* @__PURE__ */ jsx2(TableCell, { align: "center", children: /* @__PURE__ */ jsx2(Typography, { variant: "caption", children: maxAccounts }) }),
|
|
81
|
+
/* @__PURE__ */ jsxs2(TableCell, { align: "center", children: [
|
|
82
|
+
/* @__PURE__ */ jsxs2(ButtonGroup, { children: [
|
|
83
|
+
/* @__PURE__ */ jsx2(ButtonEx, { onClick: () => handleChangeMaxAccounts("decrease"), variant: "contained", size: "small", children: "-" }),
|
|
84
|
+
/* @__PURE__ */ jsx2(ButtonEx, { onClick: () => handleChangeMaxAccounts("increase"), variant: "contained", size: "small", children: "+" })
|
|
85
|
+
] }),
|
|
86
|
+
/* @__PURE__ */ jsx2(
|
|
87
|
+
OutOfBoundsSnackBar,
|
|
88
|
+
{
|
|
89
|
+
desiredMaximumAccounts,
|
|
90
|
+
activeAccountIndex,
|
|
91
|
+
setShowSnackBar,
|
|
92
|
+
showSnackBar
|
|
93
|
+
}
|
|
94
|
+
)
|
|
95
|
+
] })
|
|
96
|
+
] });
|
|
97
|
+
};
|
|
78
98
|
|
|
79
99
|
// src/components/SeedPhrase/_shared/SeedPhraseIconButton.tsx
|
|
80
100
|
import { HelpOutline as HelpOutlineIcon } from "@mui/icons-material";
|
|
81
|
-
import {
|
|
82
|
-
|
|
83
|
-
|
|
101
|
+
import {
|
|
102
|
+
Button,
|
|
103
|
+
Dialog,
|
|
104
|
+
DialogActions,
|
|
105
|
+
DialogContent,
|
|
106
|
+
DialogTitle,
|
|
107
|
+
IconButton,
|
|
108
|
+
Link,
|
|
109
|
+
List,
|
|
110
|
+
ListItem,
|
|
111
|
+
Typography as Typography2
|
|
112
|
+
} from "@mui/material";
|
|
113
|
+
import { useState as useState2 } from "react";
|
|
114
|
+
import { Fragment, jsx as jsx3, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
115
|
+
var SeedPhraseIconButton = (props) => {
|
|
84
116
|
const [open, setOpen] = useState2(false);
|
|
85
|
-
const onClose =
|
|
86
|
-
return /* @__PURE__ */
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
117
|
+
const onClose = () => setOpen(false);
|
|
118
|
+
return /* @__PURE__ */ jsxs3(Fragment, { children: [
|
|
119
|
+
/* @__PURE__ */ jsx3(IconButton, { onClick: () => setOpen(true), ...props, children: /* @__PURE__ */ jsx3(HelpOutlineIcon, { fontSize: "small" }) }),
|
|
120
|
+
/* @__PURE__ */ jsxs3(Dialog, { open, children: [
|
|
121
|
+
/* @__PURE__ */ jsx3(DialogTitle, { children: "Understanding your Seed Phrase" }),
|
|
122
|
+
/* @__PURE__ */ jsxs3(DialogContent, { children: [
|
|
123
|
+
/* @__PURE__ */ jsxs3(Typography2, { children: [
|
|
124
|
+
"Your Seed Phrase should adhere to the",
|
|
125
|
+
" ",
|
|
126
|
+
/* @__PURE__ */ jsx3(Link, { target: "_blank", href: "https://github.com/bitcoin/bips/blob/master/bip-0039.mediawiki", children: "bip39 specification" }),
|
|
127
|
+
" ",
|
|
128
|
+
"and is used to generate accounts which identify your data on the XYO Network."
|
|
129
|
+
] }),
|
|
130
|
+
/* @__PURE__ */ jsxs3(List, { children: [
|
|
131
|
+
/* @__PURE__ */ jsx3(ListItem, { children: "Do not share this phrase with anyone." }),
|
|
132
|
+
/* @__PURE__ */ jsx3(ListItem, { children: "Do not save it to a public computer." }),
|
|
133
|
+
/* @__PURE__ */ jsx3(ListItem, { children: "Do not use a existing phrase from another wallet (i.e. Metamask)." }),
|
|
134
|
+
/* @__PURE__ */ jsx3(ListItem, { children: "Do not use before copying it down somewhere safe." })
|
|
135
|
+
] })
|
|
136
|
+
] }),
|
|
137
|
+
/* @__PURE__ */ jsx3(DialogActions, { children: /* @__PURE__ */ jsx3(Button, { onClick: onClose, variant: "outlined", children: "OK" }) })
|
|
138
|
+
] })
|
|
139
|
+
] });
|
|
140
|
+
};
|
|
101
141
|
|
|
102
142
|
// src/components/SeedPhrase/DefaultSeedPhrase.tsx
|
|
103
|
-
import {
|
|
143
|
+
import {
|
|
144
|
+
Alert as Alert2,
|
|
145
|
+
AlertTitle as AlertTitle2,
|
|
146
|
+
Snackbar as Snackbar2
|
|
147
|
+
} from "@mui/material";
|
|
104
148
|
import { generateMnemonic } from "@scure/bip39";
|
|
105
149
|
import { wordlist } from "@scure/bip39/wordlists/english";
|
|
106
|
-
import
|
|
107
|
-
|
|
150
|
+
import { useMemo, useState as useState3 } from "react";
|
|
151
|
+
import { Fragment as Fragment2, jsx as jsx4, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
152
|
+
var DefaultSeedPhrase = ({
|
|
153
|
+
changeSeedPhrase,
|
|
154
|
+
children,
|
|
155
|
+
hideDefaultSeedPhraseMessage,
|
|
156
|
+
seedPhrase
|
|
157
|
+
}) => {
|
|
108
158
|
const [showSnackBar, setShowSnackBar] = useState3(false);
|
|
109
159
|
useMemo(() => {
|
|
110
160
|
if (!seedPhrase) {
|
|
@@ -112,26 +162,27 @@ var DefaultSeedPhrase = /* @__PURE__ */ __name(({ changeSeedPhrase, children, hi
|
|
|
112
162
|
changeSeedPhrase?.(mnemonic);
|
|
113
163
|
setShowSnackBar(true);
|
|
114
164
|
}
|
|
115
|
-
}, [
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
165
|
+
}, [changeSeedPhrase, seedPhrase]);
|
|
166
|
+
return /* @__PURE__ */ jsxs4(Fragment2, { children: [
|
|
167
|
+
hideDefaultSeedPhraseMessage ? null : /* @__PURE__ */ jsx4(
|
|
168
|
+
Snackbar2,
|
|
169
|
+
{
|
|
170
|
+
open: showSnackBar,
|
|
171
|
+
autoHideDuration: 5e3,
|
|
172
|
+
onClose: () => setShowSnackBar(false),
|
|
173
|
+
anchorOrigin: { horizontal: "center", vertical: "top" },
|
|
174
|
+
children: /* @__PURE__ */ jsxs4(Alert2, { severity: "success", children: [
|
|
175
|
+
/* @__PURE__ */ jsx4(AlertTitle2, { children: "Default Seed Phrase Generated" }),
|
|
176
|
+
"Go to application settings to save it."
|
|
177
|
+
] })
|
|
178
|
+
}
|
|
179
|
+
),
|
|
180
|
+
children
|
|
181
|
+
] });
|
|
182
|
+
};
|
|
131
183
|
|
|
132
184
|
// src/components/SeedPhrase/dialog/components/DialogActionButtons.tsx
|
|
133
185
|
import { Button as Button2, DialogActions as DialogActions2 } from "@mui/material";
|
|
134
|
-
import React7 from "react";
|
|
135
186
|
|
|
136
187
|
// src/contexts/SeedPhrase/Context.ts
|
|
137
188
|
import { createContextEx } from "@xylabs/react-shared";
|
|
@@ -141,25 +192,34 @@ var SeedPhraseContext = createContextEx();
|
|
|
141
192
|
import { generateMnemonic as generateMnemonic2, validateMnemonic } from "@scure/bip39";
|
|
142
193
|
import { wordlist as wordlist2 } from "@scure/bip39/wordlists/english";
|
|
143
194
|
import { useResetState } from "@xylabs/react-hooks";
|
|
144
|
-
import
|
|
145
|
-
|
|
195
|
+
import {
|
|
196
|
+
useCallback,
|
|
197
|
+
useEffect,
|
|
198
|
+
useMemo as useMemo2,
|
|
199
|
+
useState as useState4
|
|
200
|
+
} from "react";
|
|
201
|
+
import { jsx as jsx5 } from "react/jsx-runtime";
|
|
202
|
+
var validate = (passedPhrase) => {
|
|
146
203
|
if (!passedPhrase) {
|
|
147
204
|
return null;
|
|
148
205
|
}
|
|
149
206
|
return validateMnemonic(passedPhrase, wordlist2);
|
|
150
|
-
}
|
|
151
|
-
var SeedPhraseProvider =
|
|
207
|
+
};
|
|
208
|
+
var SeedPhraseProvider = ({
|
|
209
|
+
children,
|
|
210
|
+
defaultPhrase,
|
|
211
|
+
handleChangeSeedPhrase,
|
|
212
|
+
saveCallback,
|
|
213
|
+
seedPhrase,
|
|
214
|
+
open
|
|
215
|
+
}) => {
|
|
152
216
|
const [phrase, setPhrase] = useResetState(defaultPhrase);
|
|
153
217
|
const [overwriteWarning, setOverwriteWarning] = useState4(false);
|
|
154
218
|
useEffect(() => {
|
|
155
219
|
if (seedPhrase || open) {
|
|
156
220
|
setPhrase?.(seedPhrase ?? "");
|
|
157
221
|
}
|
|
158
|
-
}, [
|
|
159
|
-
seedPhrase,
|
|
160
|
-
open,
|
|
161
|
-
setPhrase
|
|
162
|
-
]);
|
|
222
|
+
}, [seedPhrase, open, setPhrase]);
|
|
163
223
|
const handleGenerate = useCallback(() => {
|
|
164
224
|
const mnemonic = generateMnemonic2(wordlist2, 256);
|
|
165
225
|
setPhrase?.(mnemonic);
|
|
@@ -167,16 +227,11 @@ var SeedPhraseProvider = /* @__PURE__ */ __name(({ children, defaultPhrase, hand
|
|
|
167
227
|
}, []);
|
|
168
228
|
const handleCancelOverwrite = useCallback(() => {
|
|
169
229
|
setOverwriteWarning(false);
|
|
170
|
-
}, [
|
|
171
|
-
setOverwriteWarning
|
|
172
|
-
]);
|
|
230
|
+
}, [setOverwriteWarning]);
|
|
173
231
|
const handleClear = useCallback(() => {
|
|
174
232
|
setPhrase("");
|
|
175
233
|
setOverwriteWarning(false);
|
|
176
|
-
}, [
|
|
177
|
-
setPhrase,
|
|
178
|
-
setOverwriteWarning
|
|
179
|
-
]);
|
|
234
|
+
}, [setPhrase, setOverwriteWarning]);
|
|
180
235
|
const handleSave = useCallback(() => {
|
|
181
236
|
if (!overwriteWarning && seedPhrase && seedPhrase !== phrase) {
|
|
182
237
|
setOverwriteWarning?.(true);
|
|
@@ -184,27 +239,14 @@ var SeedPhraseProvider = /* @__PURE__ */ __name(({ children, defaultPhrase, hand
|
|
|
184
239
|
handleChangeSeedPhrase?.(phrase ?? "");
|
|
185
240
|
saveCallback?.();
|
|
186
241
|
}
|
|
187
|
-
}, [
|
|
188
|
-
handleChangeSeedPhrase,
|
|
189
|
-
overwriteWarning,
|
|
190
|
-
phrase,
|
|
191
|
-
saveCallback,
|
|
192
|
-
seedPhrase
|
|
193
|
-
]);
|
|
242
|
+
}, [handleChangeSeedPhrase, overwriteWarning, phrase, saveCallback, seedPhrase]);
|
|
194
243
|
useEffect(() => {
|
|
195
244
|
if (!open) {
|
|
196
245
|
handleCancelOverwrite();
|
|
197
246
|
}
|
|
198
|
-
}, [
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
]);
|
|
202
|
-
const validSeedPhrase = useMemo2(() => validate?.(seedPhrase), [
|
|
203
|
-
seedPhrase
|
|
204
|
-
]);
|
|
205
|
-
const validPhrase = useMemo2(() => validate?.(phrase), [
|
|
206
|
-
phrase
|
|
207
|
-
]);
|
|
247
|
+
}, [handleCancelOverwrite, open]);
|
|
248
|
+
const validSeedPhrase = useMemo2(() => validate?.(seedPhrase), [seedPhrase]);
|
|
249
|
+
const validPhrase = useMemo2(() => validate?.(phrase), [phrase]);
|
|
208
250
|
const value = useMemo2(() => ({
|
|
209
251
|
handleCancelOverwrite,
|
|
210
252
|
handleChangeSeedPhrase,
|
|
@@ -235,14 +277,18 @@ var SeedPhraseProvider = /* @__PURE__ */ __name(({ children, defaultPhrase, hand
|
|
|
235
277
|
validSeedPhrase,
|
|
236
278
|
validate
|
|
237
279
|
]);
|
|
238
|
-
return /* @__PURE__ */
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
280
|
+
return /* @__PURE__ */ jsx5(
|
|
281
|
+
SeedPhraseContext,
|
|
282
|
+
{
|
|
283
|
+
value,
|
|
284
|
+
children
|
|
285
|
+
}
|
|
286
|
+
);
|
|
287
|
+
};
|
|
242
288
|
|
|
243
289
|
// src/contexts/SeedPhrase/use.ts
|
|
244
290
|
import { useContextEx } from "@xylabs/react-shared";
|
|
245
|
-
var useSeedPhrase =
|
|
291
|
+
var useSeedPhrase = () => useContextEx(SeedPhraseContext, "SeedPhrase", true);
|
|
246
292
|
|
|
247
293
|
// src/contexts/Wallet/Context.ts
|
|
248
294
|
import { createContextEx as createContextEx2 } from "@xylabs/react-shared";
|
|
@@ -251,13 +297,16 @@ var WalletContext = createContextEx2();
|
|
|
251
297
|
// src/contexts/Wallet/Provider.tsx
|
|
252
298
|
import { useResetState as useResetState2 } from "@xylabs/react-hooks";
|
|
253
299
|
import { usePromise } from "@xylabs/react-promise";
|
|
254
|
-
import
|
|
255
|
-
|
|
300
|
+
import { useMemo as useMemo3 } from "react";
|
|
301
|
+
import { jsx as jsx6 } from "react/jsx-runtime";
|
|
302
|
+
var WalletProvider = ({
|
|
303
|
+
children,
|
|
304
|
+
defaultActiveAccountIndex = 0,
|
|
305
|
+
rootWallet = null,
|
|
306
|
+
...props
|
|
307
|
+
}) => {
|
|
256
308
|
const [activeAccountIndex, setActiveAccountIndex] = useResetState2(defaultActiveAccountIndex);
|
|
257
|
-
const [activeAccount = null] = usePromise(async () => await rootWallet?.derivePath(activeAccountIndex.toString()), [
|
|
258
|
-
activeAccountIndex,
|
|
259
|
-
rootWallet
|
|
260
|
-
]);
|
|
309
|
+
const [activeAccount = null] = usePromise(async () => await rootWallet?.derivePath(activeAccountIndex.toString()), [activeAccountIndex, rootWallet]);
|
|
261
310
|
const value = useMemo3(() => ({
|
|
262
311
|
activeAccount,
|
|
263
312
|
activeAccountIndex,
|
|
@@ -270,74 +319,59 @@ var WalletProvider = /* @__PURE__ */ __name(({ children, defaultActiveAccountInd
|
|
|
270
319
|
rootWallet,
|
|
271
320
|
setActiveAccountIndex
|
|
272
321
|
]);
|
|
273
|
-
return /* @__PURE__ */
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
322
|
+
return /* @__PURE__ */ jsx6(
|
|
323
|
+
WalletContext,
|
|
324
|
+
{
|
|
325
|
+
value,
|
|
326
|
+
...props,
|
|
327
|
+
children
|
|
328
|
+
}
|
|
329
|
+
);
|
|
330
|
+
};
|
|
278
331
|
|
|
279
332
|
// src/contexts/Wallet/use.ts
|
|
280
333
|
import { usePromise as usePromise2 } from "@xylabs/react-promise";
|
|
281
334
|
import { useContextEx as useContextEx2, useProvided } from "@xylabs/react-shared";
|
|
282
|
-
var useWalletContext =
|
|
335
|
+
var useWalletContext = (required = true) => {
|
|
283
336
|
return useContextEx2(WalletContext, "Wallet", required);
|
|
284
|
-
}
|
|
285
|
-
var useWalletProvided =
|
|
337
|
+
};
|
|
338
|
+
var useWalletProvided = () => {
|
|
286
339
|
return useProvided(WalletContext);
|
|
287
|
-
}
|
|
288
|
-
var useRootWallet =
|
|
340
|
+
};
|
|
341
|
+
var useRootWallet = (required = true) => {
|
|
289
342
|
const { rootWallet } = useWalletContext(required);
|
|
290
|
-
return [
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
];
|
|
294
|
-
}, "useRootWallet");
|
|
295
|
-
var useIndexedWalletFromContext = /* @__PURE__ */ __name((index, required = true) => {
|
|
343
|
+
return [rootWallet, void 0];
|
|
344
|
+
};
|
|
345
|
+
var useIndexedWalletFromContext = (index, required = true) => {
|
|
296
346
|
const { rootWallet } = useWalletContext(required);
|
|
297
|
-
const [wallet] = usePromise2(async () => await rootWallet?.derivePath(index.toString()) ?? rootWallet, [
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
return [
|
|
302
|
-
wallet,
|
|
303
|
-
void 0
|
|
304
|
-
];
|
|
305
|
-
}, "useIndexedWalletFromContext");
|
|
306
|
-
var useSelectedWalletAccount = /* @__PURE__ */ __name((required = true) => {
|
|
347
|
+
const [wallet] = usePromise2(async () => await rootWallet?.derivePath(index.toString()) ?? rootWallet, [rootWallet, index]);
|
|
348
|
+
return [wallet, void 0];
|
|
349
|
+
};
|
|
350
|
+
var useSelectedWalletAccount = (required = true) => {
|
|
307
351
|
const { activeAccountIndex } = useWalletContext(required);
|
|
308
352
|
const [account] = useIndexedWalletFromContext(activeAccountIndex ?? 0, required);
|
|
309
|
-
return activeAccountIndex === void 0 && account === null ? [
|
|
310
|
-
|
|
311
|
-
void 0
|
|
312
|
-
] : [
|
|
313
|
-
account,
|
|
314
|
-
void 0
|
|
315
|
-
];
|
|
316
|
-
}, "useSelectedWalletAccount");
|
|
353
|
+
return activeAccountIndex === void 0 && account === null ? [null, void 0] : [account, void 0];
|
|
354
|
+
};
|
|
317
355
|
|
|
318
356
|
// src/components/SeedPhrase/dialog/components/DialogActionButtons.tsx
|
|
319
|
-
|
|
357
|
+
import { jsx as jsx7, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
358
|
+
var DialogActionButtons = ({ onClose, ...props }) => {
|
|
320
359
|
const { handleSave, setPhrase } = useSeedPhrase();
|
|
321
|
-
const wrappedOnClose =
|
|
360
|
+
const wrappedOnClose = (e) => {
|
|
322
361
|
setPhrase?.("");
|
|
323
362
|
onClose?.(e, "escapeKeyDown");
|
|
324
|
-
}
|
|
325
|
-
return /* @__PURE__ */
|
|
326
|
-
variant: "outlined",
|
|
327
|
-
onClick:
|
|
328
|
-
}
|
|
329
|
-
|
|
330
|
-
variant: "contained",
|
|
331
|
-
onClick: handleSave
|
|
332
|
-
}, "Save"));
|
|
333
|
-
}, "DialogActionButtons");
|
|
363
|
+
};
|
|
364
|
+
return /* @__PURE__ */ jsxs5(DialogActions2, { ...props, children: [
|
|
365
|
+
/* @__PURE__ */ jsx7(Button2, { variant: "outlined", onClick: wrappedOnClose, children: "Cancel" }),
|
|
366
|
+
/* @__PURE__ */ jsx7(Button2, { type: "submit", variant: "contained", onClick: handleSave, children: "Save" })
|
|
367
|
+
] });
|
|
368
|
+
};
|
|
334
369
|
|
|
335
370
|
// src/components/SeedPhrase/dialog/components/fields/NewPhraseTextField.tsx
|
|
336
371
|
import { FormControl, TextField } from "@mui/material";
|
|
337
|
-
import React10 from "react";
|
|
338
372
|
|
|
339
373
|
// src/components/SeedPhrase/dialog/components/fields/validation-messages/colorParser.ts
|
|
340
|
-
var colorParser =
|
|
374
|
+
var colorParser = (conditional) => {
|
|
341
375
|
switch (conditional) {
|
|
342
376
|
case true: {
|
|
343
377
|
return "success";
|
|
@@ -349,25 +383,27 @@ var colorParser = /* @__PURE__ */ __name((conditional) => {
|
|
|
349
383
|
return;
|
|
350
384
|
}
|
|
351
385
|
}
|
|
352
|
-
}
|
|
386
|
+
};
|
|
353
387
|
|
|
354
388
|
// src/components/SeedPhrase/dialog/components/fields/validation-messages/InvalidPhrase.tsx
|
|
355
389
|
import { Link as Link2, Typography as Typography3 } from "@mui/material";
|
|
356
|
-
import
|
|
357
|
-
var InvalidPhraseTypography =
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
}
|
|
362
|
-
target: "_blank",
|
|
363
|
-
href: "https://github.com/bitcoin/bips/blob/master/bip-0039.mediawiki"
|
|
364
|
-
}, "bip39 Proposal")), "InvalidPhraseTypography");
|
|
390
|
+
import { jsx as jsx8, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
391
|
+
var InvalidPhraseTypography = (props) => /* @__PURE__ */ jsxs6(Typography3, { variant: "caption", color: "error", ...props, children: [
|
|
392
|
+
"Invalid seed phrase. See -",
|
|
393
|
+
" ",
|
|
394
|
+
/* @__PURE__ */ jsx8(Link2, { target: "_blank", href: "https://github.com/bitcoin/bips/blob/master/bip-0039.mediawiki", children: "bip39 Proposal" })
|
|
395
|
+
] });
|
|
365
396
|
|
|
366
397
|
// src/components/SeedPhrase/dialog/components/fields/validation-messages/PhraseHeaderBox.tsx
|
|
367
398
|
import { CheckCircleOutline as CheckCircleOutlineIcon, HighlightOff as HighlightOffIcon } from "@mui/icons-material";
|
|
368
399
|
import { FlexRow } from "@xylabs/react-flexbox";
|
|
369
|
-
import
|
|
370
|
-
|
|
400
|
+
import { useMemo as useMemo4 } from "react";
|
|
401
|
+
import { jsx as jsx9, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
402
|
+
var PhraseHeaderBox = ({
|
|
403
|
+
children,
|
|
404
|
+
conditional,
|
|
405
|
+
...props
|
|
406
|
+
}) => {
|
|
371
407
|
const state = useMemo4(() => {
|
|
372
408
|
switch (conditional) {
|
|
373
409
|
case true: {
|
|
@@ -380,98 +416,118 @@ var PhraseHeaderBox = /* @__PURE__ */ __name(({ children, conditional, ...props
|
|
|
380
416
|
return null;
|
|
381
417
|
}
|
|
382
418
|
}
|
|
383
|
-
}, [
|
|
384
|
-
conditional
|
|
385
|
-
]);
|
|
419
|
+
}, [conditional]);
|
|
386
420
|
const Icon = useMemo4(() => {
|
|
387
421
|
switch (state) {
|
|
388
422
|
case "success": {
|
|
389
|
-
return /* @__PURE__ */
|
|
390
|
-
fontSize: "small",
|
|
391
|
-
color: "success"
|
|
392
|
-
});
|
|
423
|
+
return /* @__PURE__ */ jsx9(CheckCircleOutlineIcon, { fontSize: "small", color: "success" });
|
|
393
424
|
}
|
|
394
425
|
case "error": {
|
|
395
|
-
return /* @__PURE__ */
|
|
396
|
-
fontSize: "small",
|
|
397
|
-
color: "error"
|
|
398
|
-
});
|
|
426
|
+
return /* @__PURE__ */ jsx9(HighlightOffIcon, { fontSize: "small", color: "error" });
|
|
399
427
|
}
|
|
400
428
|
default: {
|
|
401
429
|
return null;
|
|
402
430
|
}
|
|
403
431
|
}
|
|
404
|
-
}, [
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
...props
|
|
411
|
-
}, Icon, children);
|
|
412
|
-
}, "PhraseHeaderBox");
|
|
432
|
+
}, [state]);
|
|
433
|
+
return /* @__PURE__ */ jsxs7(FlexRow, { justifyContent: "start", columnGap: 1, ...props, children: [
|
|
434
|
+
Icon,
|
|
435
|
+
children
|
|
436
|
+
] });
|
|
437
|
+
};
|
|
413
438
|
|
|
414
439
|
// src/components/SeedPhrase/dialog/components/fields/NewPhraseTextField.tsx
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
440
|
+
import { Fragment as Fragment3, jsx as jsx10, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
441
|
+
var NewPhraseTextField = ({
|
|
442
|
+
children,
|
|
443
|
+
disableColor,
|
|
444
|
+
...props
|
|
445
|
+
}) => {
|
|
446
|
+
const {
|
|
447
|
+
phrase,
|
|
448
|
+
setPhrase,
|
|
449
|
+
validPhrase
|
|
450
|
+
} = useSeedPhrase();
|
|
451
|
+
return /* @__PURE__ */ jsx10(Fragment3, { children: /* @__PURE__ */ jsxs8(
|
|
452
|
+
FormControl,
|
|
453
|
+
{
|
|
454
|
+
fullWidth: true,
|
|
455
|
+
size: "small",
|
|
456
|
+
sx: {
|
|
457
|
+
display: "flex",
|
|
458
|
+
flexDirection: "column",
|
|
459
|
+
rowGap: 1
|
|
460
|
+
},
|
|
461
|
+
children: [
|
|
462
|
+
children,
|
|
463
|
+
/* @__PURE__ */ jsx10(
|
|
464
|
+
TextField,
|
|
465
|
+
{
|
|
466
|
+
focused: true,
|
|
467
|
+
color: disableColor ? void 0 : colorParser(validPhrase),
|
|
468
|
+
error: validPhrase === false,
|
|
469
|
+
helperText: validPhrase === false ? /* @__PURE__ */ jsx10(InvalidPhraseTypography, {}) : null,
|
|
470
|
+
fullWidth: true,
|
|
471
|
+
maxRows: Number.POSITIVE_INFINITY,
|
|
472
|
+
multiline: true,
|
|
473
|
+
onChange: (e) => setPhrase?.(e.target.value),
|
|
474
|
+
value: phrase,
|
|
475
|
+
...props
|
|
476
|
+
}
|
|
477
|
+
)
|
|
478
|
+
]
|
|
424
479
|
}
|
|
425
|
-
}
|
|
426
|
-
|
|
427
|
-
color: disableColor ? void 0 : colorParser(validPhrase),
|
|
428
|
-
error: validPhrase === false,
|
|
429
|
-
helperText: validPhrase === false ? /* @__PURE__ */ React10.createElement(InvalidPhraseTypography, null) : null,
|
|
430
|
-
fullWidth: true,
|
|
431
|
-
maxRows: Number.POSITIVE_INFINITY,
|
|
432
|
-
multiline: true,
|
|
433
|
-
onChange: /* @__PURE__ */ __name((e) => setPhrase?.(e.target.value), "onChange"),
|
|
434
|
-
value: phrase,
|
|
435
|
-
...props
|
|
436
|
-
})));
|
|
437
|
-
}, "NewPhraseTextField");
|
|
480
|
+
) });
|
|
481
|
+
};
|
|
438
482
|
|
|
439
483
|
// src/components/SeedPhrase/dialog/components/fields/PhraseDialogActions.tsx
|
|
440
484
|
import { Button as Button3, DialogActions as DialogActions3 } from "@mui/material";
|
|
441
|
-
import
|
|
442
|
-
var PhraseDialogActions =
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
variant: "outlined",
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
}, "PhraseDialogActions");
|
|
485
|
+
import { jsx as jsx11, jsxs as jsxs9 } from "react/jsx-runtime";
|
|
486
|
+
var PhraseDialogActions = ({
|
|
487
|
+
hideClear,
|
|
488
|
+
hideGenerate,
|
|
489
|
+
...props
|
|
490
|
+
}) => {
|
|
491
|
+
const {
|
|
492
|
+
handleClear,
|
|
493
|
+
handleGenerate,
|
|
494
|
+
overwriteWarning
|
|
495
|
+
} = useSeedPhrase();
|
|
496
|
+
return /* @__PURE__ */ jsxs9(DialogActions3, { sx: { justifyContent: "center" }, ...props, children: [
|
|
497
|
+
hideGenerate ? null : /* @__PURE__ */ jsx11(Button3, { disabled: overwriteWarning, variant: "contained", onClick: handleGenerate, children: "Generate" }),
|
|
498
|
+
hideClear ? null : /* @__PURE__ */ jsx11(Button3, { variant: "outlined", onClick: handleClear, children: "Clear" })
|
|
499
|
+
] });
|
|
500
|
+
};
|
|
458
501
|
|
|
459
502
|
// src/components/SeedPhrase/dialog/components/fields/SavedPhraseTextField.tsx
|
|
460
503
|
import { ContentCopy } from "@mui/icons-material";
|
|
461
|
-
import {
|
|
504
|
+
import {
|
|
505
|
+
Chip,
|
|
506
|
+
FormControl as FormControl2,
|
|
507
|
+
FormLabel,
|
|
508
|
+
IconButton as IconButton2,
|
|
509
|
+
TextField as TextField2,
|
|
510
|
+
Tooltip,
|
|
511
|
+
useTheme
|
|
512
|
+
} from "@mui/material";
|
|
462
513
|
import { FlexRow as FlexRow2 } from "@xylabs/react-flexbox";
|
|
463
|
-
import
|
|
464
|
-
|
|
514
|
+
import { useMemo as useMemo5, useState as useState5 } from "react";
|
|
515
|
+
import { jsx as jsx12, jsxs as jsxs10 } from "react/jsx-runtime";
|
|
516
|
+
var SavedPhraseTextField = ({
|
|
517
|
+
fullWidth,
|
|
518
|
+
showCopyButton,
|
|
519
|
+
showPhraseHeader,
|
|
520
|
+
visible: visibleProp,
|
|
521
|
+
...props
|
|
522
|
+
}) => {
|
|
465
523
|
const { validSeedPhrase, seedPhrase } = useSeedPhrase();
|
|
466
524
|
const theme = useTheme();
|
|
467
525
|
const [visible, setVisible] = useState5(visibleProp);
|
|
468
526
|
useMemo5(() => {
|
|
469
527
|
setVisible(visibleProp);
|
|
470
|
-
}, [
|
|
471
|
-
visibleProp
|
|
472
|
-
]);
|
|
528
|
+
}, [visibleProp]);
|
|
473
529
|
const [copied, setCopied] = useState5(false);
|
|
474
|
-
const onCopyPhrase =
|
|
530
|
+
const onCopyPhrase = async () => {
|
|
475
531
|
if (seedPhrase) {
|
|
476
532
|
try {
|
|
477
533
|
await navigator.clipboard.writeText(seedPhrase);
|
|
@@ -481,164 +537,198 @@ var SavedPhraseTextField = /* @__PURE__ */ __name(({ fullWidth, showCopyButton,
|
|
|
481
537
|
console.error("Error copying resolvedSelectedAddress to clipboard", e);
|
|
482
538
|
}
|
|
483
539
|
}
|
|
484
|
-
}
|
|
485
|
-
return /* @__PURE__ */
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
540
|
+
};
|
|
541
|
+
return /* @__PURE__ */ jsxs10(
|
|
542
|
+
FormControl2,
|
|
543
|
+
{
|
|
544
|
+
fullWidth,
|
|
545
|
+
size: "small",
|
|
546
|
+
sx: {
|
|
547
|
+
display: "flex",
|
|
548
|
+
flexDirection: "column",
|
|
549
|
+
rowGap: 1
|
|
550
|
+
},
|
|
551
|
+
children: [
|
|
552
|
+
/* @__PURE__ */ jsxs10(FlexRow2, { gap: 0.5, children: [
|
|
553
|
+
/* @__PURE__ */ jsx12(
|
|
554
|
+
Chip,
|
|
555
|
+
{
|
|
556
|
+
label: "Show Seed Phrase",
|
|
557
|
+
onClick: () => setVisible(!visible),
|
|
558
|
+
sx: { alignSelf: "center", my: "2px" }
|
|
559
|
+
}
|
|
560
|
+
),
|
|
561
|
+
/* @__PURE__ */ jsx12(Tooltip, { title: copied ? "Copied!" : "Copy", children: /* @__PURE__ */ jsx12(
|
|
562
|
+
IconButton2,
|
|
563
|
+
{
|
|
564
|
+
onClick: () => void onCopyPhrase(),
|
|
565
|
+
sx: {
|
|
566
|
+
height: visible ? "auto" : 0,
|
|
567
|
+
opacity: visible ? 1 : 0,
|
|
568
|
+
overflow: "hidden",
|
|
569
|
+
padding: visible ? theme.spacing(1) : 0,
|
|
570
|
+
transition: "all .25s ease-in-out",
|
|
571
|
+
width: visible ? "max-content" : 0
|
|
572
|
+
},
|
|
573
|
+
children: /* @__PURE__ */ jsx12(ContentCopy, { fontSize: "small" })
|
|
574
|
+
}
|
|
575
|
+
) })
|
|
576
|
+
] }),
|
|
577
|
+
visible && showPhraseHeader ? /* @__PURE__ */ jsx12(FormLabel, { children: /* @__PURE__ */ jsx12(PhraseHeaderBox, { conditional: validSeedPhrase, children: "Saved Seed Phrase" }) }) : null,
|
|
578
|
+
/* @__PURE__ */ jsx12(
|
|
579
|
+
TextField2,
|
|
580
|
+
{
|
|
581
|
+
defaultValue: seedPhrase,
|
|
582
|
+
disabled: true,
|
|
583
|
+
error: validSeedPhrase === false,
|
|
584
|
+
helperText: validSeedPhrase === false ? /* @__PURE__ */ jsx12(InvalidPhraseTypography, {}) : null,
|
|
585
|
+
fullWidth: true,
|
|
586
|
+
maxRows: Number.POSITIVE_INFINITY,
|
|
587
|
+
multiline: true,
|
|
588
|
+
slotProps: {
|
|
589
|
+
input: {
|
|
590
|
+
style: {
|
|
591
|
+
height: visible ? "auto" : "0",
|
|
592
|
+
overflow: "hidden",
|
|
593
|
+
opacity: visible ? 1 : 0,
|
|
594
|
+
padding: visible ? theme.spacing(1) : 0,
|
|
595
|
+
transition: "all .25s ease-in-out"
|
|
596
|
+
}
|
|
597
|
+
}
|
|
598
|
+
},
|
|
599
|
+
...props
|
|
600
|
+
}
|
|
601
|
+
)
|
|
602
|
+
]
|
|
514
603
|
}
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
})))), visible && showPhraseHeader ? /* @__PURE__ */ React12.createElement(FormLabel, null, /* @__PURE__ */ React12.createElement(PhraseHeaderBox, {
|
|
518
|
-
conditional: validSeedPhrase
|
|
519
|
-
}, "Saved Seed Phrase")) : null, /* @__PURE__ */ React12.createElement(TextField2, {
|
|
520
|
-
defaultValue: seedPhrase,
|
|
521
|
-
disabled: true,
|
|
522
|
-
error: validSeedPhrase === false,
|
|
523
|
-
helperText: validSeedPhrase === false ? /* @__PURE__ */ React12.createElement(InvalidPhraseTypography, null) : null,
|
|
524
|
-
fullWidth: true,
|
|
525
|
-
maxRows: Number.POSITIVE_INFINITY,
|
|
526
|
-
multiline: true,
|
|
527
|
-
slotProps: {
|
|
528
|
-
input: {
|
|
529
|
-
style: {
|
|
530
|
-
height: visible ? "auto" : "0",
|
|
531
|
-
overflow: "hidden",
|
|
532
|
-
opacity: visible ? 1 : 0,
|
|
533
|
-
padding: visible ? theme.spacing(1) : 0,
|
|
534
|
-
transition: "all .25s ease-in-out"
|
|
535
|
-
}
|
|
536
|
-
}
|
|
537
|
-
},
|
|
538
|
-
...props
|
|
539
|
-
}));
|
|
540
|
-
}, "SavedPhraseTextField");
|
|
604
|
+
);
|
|
605
|
+
};
|
|
541
606
|
|
|
542
607
|
// src/components/SeedPhrase/dialog/components/OverwriteWarning.tsx
|
|
543
608
|
import { Alert as Alert3, Button as Button4 } from "@mui/material";
|
|
544
609
|
import { FlexRow as FlexRow3 } from "@xylabs/react-flexbox";
|
|
545
|
-
import
|
|
546
|
-
var OverwriteWarning =
|
|
610
|
+
import { jsx as jsx13, jsxs as jsxs11 } from "react/jsx-runtime";
|
|
611
|
+
var OverwriteWarning = () => {
|
|
547
612
|
const { handleCancelOverwrite, handleSave } = useSeedPhrase();
|
|
548
|
-
return /* @__PURE__ */
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
action: /* @__PURE__ */ React13.createElement(FlexRow3, {
|
|
552
|
-
sx: {
|
|
553
|
-
columnGap: 1
|
|
554
|
-
}
|
|
555
|
-
}, /* @__PURE__ */ React13.createElement(Button4, {
|
|
556
|
-
variant: "outlined",
|
|
557
|
-
color: "inherit",
|
|
558
|
-
size: "small",
|
|
559
|
-
onClick: handleSave
|
|
560
|
-
}, "Overwrite"), /* @__PURE__ */ React13.createElement(Button4, {
|
|
613
|
+
return /* @__PURE__ */ jsx13(
|
|
614
|
+
Alert3,
|
|
615
|
+
{
|
|
561
616
|
variant: "outlined",
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
617
|
+
severity: "warning",
|
|
618
|
+
action: /* @__PURE__ */ jsxs11(FlexRow3, { sx: { columnGap: 1 }, children: [
|
|
619
|
+
/* @__PURE__ */ jsx13(Button4, { variant: "outlined", color: "inherit", size: "small", onClick: handleSave, children: "Overwrite" }),
|
|
620
|
+
/* @__PURE__ */ jsx13(Button4, { variant: "outlined", color: "inherit", size: "small", onClick: handleCancelOverwrite, children: "Cancel" })
|
|
621
|
+
] }),
|
|
622
|
+
children: "Are you sure you want to overwrite existing seed phrase? This action cannot be undone."
|
|
623
|
+
}
|
|
624
|
+
);
|
|
625
|
+
};
|
|
568
626
|
|
|
569
627
|
// src/components/SeedPhrase/dialog/SeedPhraseDialog.tsx
|
|
570
|
-
import {
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
}
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
}, /* @__PURE__ */ React14.createElement(DialogTitle2, {
|
|
593
|
-
id: "alert-dialog-title",
|
|
594
|
-
sx: {
|
|
595
|
-
alignItems: "center",
|
|
596
|
-
display: "inline-flex",
|
|
597
|
-
flexDirection: "row"
|
|
598
|
-
}
|
|
599
|
-
}, dialogTitle, /* @__PURE__ */ React14.createElement(SeedPhraseIconButton, null)), /* @__PURE__ */ React14.createElement(DialogContent2, {
|
|
600
|
-
sx: {
|
|
601
|
-
display: "flex",
|
|
602
|
-
flexDirection: "column",
|
|
603
|
-
rowGap: 2
|
|
628
|
+
import {
|
|
629
|
+
Dialog as Dialog2,
|
|
630
|
+
DialogContent as DialogContent2,
|
|
631
|
+
DialogTitle as DialogTitle2,
|
|
632
|
+
FormLabel as FormLabel2
|
|
633
|
+
} from "@mui/material";
|
|
634
|
+
import { jsx as jsx14, jsxs as jsxs12 } from "react/jsx-runtime";
|
|
635
|
+
var SeedPhraseDialog = ({
|
|
636
|
+
changeSeedPhrase,
|
|
637
|
+
dialogTitle = "Update Your Seed Phrase",
|
|
638
|
+
seedPhrase,
|
|
639
|
+
seedPhraseTextFieldTitle = "New Seed Phrase",
|
|
640
|
+
...props
|
|
641
|
+
}) => {
|
|
642
|
+
return /* @__PURE__ */ jsx14(
|
|
643
|
+
SeedPhraseProvider,
|
|
644
|
+
{
|
|
645
|
+
seedPhrase,
|
|
646
|
+
handleChangeSeedPhrase: changeSeedPhrase,
|
|
647
|
+
open: props.open,
|
|
648
|
+
saveCallback: () => props.onClose?.({}, "escapeKeyDown"),
|
|
649
|
+
children: /* @__PURE__ */ jsx14(SeedPhraseDialogInner, { dialogTitle, seedPhraseTextFieldTitle, ...props })
|
|
604
650
|
}
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
}
|
|
651
|
+
);
|
|
652
|
+
};
|
|
653
|
+
var SeedPhraseDialogInner = ({
|
|
654
|
+
dialogTitle,
|
|
655
|
+
seedPhraseTextFieldTitle,
|
|
656
|
+
showCopyButton,
|
|
657
|
+
...props
|
|
658
|
+
}) => {
|
|
659
|
+
const {
|
|
660
|
+
overwriteWarning,
|
|
661
|
+
seedPhrase,
|
|
662
|
+
validPhrase
|
|
663
|
+
} = useSeedPhrase();
|
|
664
|
+
return /* @__PURE__ */ jsxs12(Dialog2, { "aria-labelledby": "alert-dialog-title", "aria-describedby": "alert-dialog-description", fullWidth: true, maxWidth: "sm", ...props, children: [
|
|
665
|
+
/* @__PURE__ */ jsxs12(
|
|
666
|
+
DialogTitle2,
|
|
667
|
+
{
|
|
668
|
+
id: "alert-dialog-title",
|
|
669
|
+
sx: {
|
|
670
|
+
alignItems: "center",
|
|
671
|
+
display: "inline-flex",
|
|
672
|
+
flexDirection: "row"
|
|
673
|
+
},
|
|
674
|
+
children: [
|
|
675
|
+
dialogTitle,
|
|
676
|
+
/* @__PURE__ */ jsx14(SeedPhraseIconButton, {})
|
|
677
|
+
]
|
|
678
|
+
}
|
|
679
|
+
),
|
|
680
|
+
/* @__PURE__ */ jsxs12(
|
|
681
|
+
DialogContent2,
|
|
682
|
+
{
|
|
683
|
+
sx: {
|
|
684
|
+
display: "flex",
|
|
685
|
+
flexDirection: "column",
|
|
686
|
+
rowGap: 2
|
|
687
|
+
},
|
|
688
|
+
children: [
|
|
689
|
+
/* @__PURE__ */ jsx14(NewPhraseTextField, { children: /* @__PURE__ */ jsx14(FormLabel2, { children: /* @__PURE__ */ jsx14(PhraseHeaderBox, { conditional: validPhrase, children: seedPhraseTextFieldTitle }) }) }),
|
|
690
|
+
/* @__PURE__ */ jsx14(PhraseDialogActions, {}),
|
|
691
|
+
seedPhrase ? /* @__PURE__ */ jsx14(SavedPhraseTextField, { showCopyButton }) : null,
|
|
692
|
+
overwriteWarning ? /* @__PURE__ */ jsx14(OverwriteWarning, {}) : null
|
|
693
|
+
]
|
|
694
|
+
}
|
|
695
|
+
),
|
|
696
|
+
/* @__PURE__ */ jsx14(DialogActionButtons, { onClose: props.onClose })
|
|
697
|
+
] });
|
|
698
|
+
};
|
|
613
699
|
|
|
614
700
|
// src/components/SeedPhrase/settings/SeedPhraseTableRow.tsx
|
|
615
701
|
import { Cancel as CancelIcon, RadioButtonChecked as RadioButtonCheckedIcon } from "@mui/icons-material";
|
|
616
|
-
import {
|
|
617
|
-
|
|
618
|
-
|
|
702
|
+
import {
|
|
703
|
+
Button as Button5,
|
|
704
|
+
ButtonGroup as ButtonGroup2,
|
|
705
|
+
TableCell as TableCell2,
|
|
706
|
+
TableRow as TableRow2
|
|
707
|
+
} from "@mui/material";
|
|
708
|
+
import { useState as useState6 } from "react";
|
|
709
|
+
import { jsx as jsx15, jsxs as jsxs13 } from "react/jsx-runtime";
|
|
710
|
+
var SeedPhraseTableRow = ({
|
|
711
|
+
changeSeedPhrase,
|
|
712
|
+
seedPhrase,
|
|
713
|
+
...props
|
|
714
|
+
}) => {
|
|
619
715
|
const [open, setOpen] = useState6(false);
|
|
620
|
-
const handleOpen =
|
|
716
|
+
const handleOpen = () => {
|
|
621
717
|
setOpen(true);
|
|
622
|
-
}
|
|
623
|
-
return /* @__PURE__ */
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
})
|
|
635
|
-
|
|
636
|
-
}, /* @__PURE__ */ React15.createElement(Button5, {
|
|
637
|
-
variant: "contained",
|
|
638
|
-
size: "small",
|
|
639
|
-
onClick: handleOpen
|
|
640
|
-
}, "Update"))));
|
|
641
|
-
}, "SeedPhraseTableRow");
|
|
718
|
+
};
|
|
719
|
+
return /* @__PURE__ */ jsxs13(TableRow2, { ...props, children: [
|
|
720
|
+
/* @__PURE__ */ jsxs13(TableCell2, { children: [
|
|
721
|
+
"Seed Phrase",
|
|
722
|
+
" ",
|
|
723
|
+
/* @__PURE__ */ jsx15(SeedPhraseIconButton, {})
|
|
724
|
+
] }),
|
|
725
|
+
/* @__PURE__ */ jsx15(TableCell2, { align: "center", children: seedPhrase ? /* @__PURE__ */ jsx15(RadioButtonCheckedIcon, { color: "success" }) : /* @__PURE__ */ jsx15(CancelIcon, { color: "error" }) }),
|
|
726
|
+
/* @__PURE__ */ jsxs13(TableCell2, { children: [
|
|
727
|
+
/* @__PURE__ */ jsx15(SeedPhraseDialog, { changeSeedPhrase, open, onClose: () => setOpen(false), seedPhrase }),
|
|
728
|
+
/* @__PURE__ */ jsx15(ButtonGroup2, { fullWidth: true, children: /* @__PURE__ */ jsx15(Button5, { variant: "contained", size: "small", onClick: handleOpen, children: "Update" }) })
|
|
729
|
+
] })
|
|
730
|
+
] });
|
|
731
|
+
};
|
|
642
732
|
|
|
643
733
|
// src/components/WalletAccountDetails/WalletAccountDetails.tsx
|
|
644
734
|
import { EthAddressWrapper } from "@xylabs/eth-address";
|
|
@@ -646,12 +736,16 @@ import { EthAccountButton } from "@xylabs/react-crypto";
|
|
|
646
736
|
import { FlexCol, FlexRow as FlexRow4 } from "@xylabs/react-flexbox";
|
|
647
737
|
import { NumberStatus } from "@xylabs/react-number-status";
|
|
648
738
|
import { useNetwork } from "@xyo-network/react-network";
|
|
649
|
-
import React16 from "react";
|
|
650
739
|
|
|
651
740
|
// src/hooks/useAccount.ts
|
|
652
741
|
import { usePromise as usePromise3 } from "@xylabs/react-promise";
|
|
653
742
|
import { useState as useState7 } from "react";
|
|
654
|
-
var useAccount =
|
|
743
|
+
var useAccount = ({
|
|
744
|
+
wallet,
|
|
745
|
+
account,
|
|
746
|
+
index,
|
|
747
|
+
required = false
|
|
748
|
+
} = {}) => {
|
|
655
749
|
const walletContextProvided = useWalletProvided();
|
|
656
750
|
const [validationError, setValidationError] = useState7();
|
|
657
751
|
if (wallet && account && !validationError) {
|
|
@@ -679,13 +773,7 @@ var useAccount = /* @__PURE__ */ __name(({ wallet, account, index, required = fa
|
|
|
679
773
|
console.error(error2.message);
|
|
680
774
|
setError(error2);
|
|
681
775
|
}
|
|
682
|
-
}, [
|
|
683
|
-
index,
|
|
684
|
-
wallet,
|
|
685
|
-
rootWallet,
|
|
686
|
-
activeAccountIndex,
|
|
687
|
-
validationError
|
|
688
|
-
]);
|
|
776
|
+
}, [index, wallet, rootWallet, activeAccountIndex, validationError]);
|
|
689
777
|
if (validationError && !error) {
|
|
690
778
|
console.error(validationError.message);
|
|
691
779
|
setError(validationError);
|
|
@@ -694,13 +782,19 @@ var useAccount = /* @__PURE__ */ __name(({ wallet, account, index, required = fa
|
|
|
694
782
|
error ? void 0 : account ?? activeAccount ?? walletContextProvided ? null : void 0,
|
|
695
783
|
error
|
|
696
784
|
];
|
|
697
|
-
}
|
|
785
|
+
};
|
|
698
786
|
|
|
699
787
|
// src/hooks/useWallet.ts
|
|
700
788
|
import { usePromise as usePromise4 } from "@xylabs/react-promise";
|
|
701
789
|
import { HDWallet } from "@xyo-network/wallet";
|
|
702
790
|
import { useState as useState8 } from "react";
|
|
703
|
-
var useWallet =
|
|
791
|
+
var useWallet = ({
|
|
792
|
+
mnemonic,
|
|
793
|
+
wallet,
|
|
794
|
+
path,
|
|
795
|
+
required = false,
|
|
796
|
+
seed
|
|
797
|
+
} = {}) => {
|
|
704
798
|
const walletContextProvided = useWalletContext(false);
|
|
705
799
|
const [error, setError] = useState8();
|
|
706
800
|
const [contextAccount] = useSelectedWalletAccount(!wallet && required);
|
|
@@ -720,35 +814,21 @@ var useWallet = /* @__PURE__ */ __name(({ mnemonic, wallet, path, required = fal
|
|
|
720
814
|
} catch (ex) {
|
|
721
815
|
setError(ex);
|
|
722
816
|
}
|
|
723
|
-
}, [
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
seed,
|
|
727
|
-
path,
|
|
728
|
-
wallet
|
|
729
|
-
]);
|
|
730
|
-
return [
|
|
731
|
-
activeAccount ?? (walletContextProvided ? null : activeAccount),
|
|
732
|
-
error
|
|
733
|
-
];
|
|
734
|
-
}, "useWallet");
|
|
817
|
+
}, [mnemonic, contextAccount, seed, path, wallet]);
|
|
818
|
+
return [activeAccount ?? (walletContextProvided ? null : activeAccount), error];
|
|
819
|
+
};
|
|
735
820
|
|
|
736
821
|
// src/hooks/useWallets.ts
|
|
737
822
|
import { usePromise as usePromise5 } from "@xylabs/react-promise";
|
|
738
|
-
var useWallets =
|
|
823
|
+
var useWallets = ({ wallet, paths }) => {
|
|
739
824
|
const walletContextProvided = useWalletContext(false);
|
|
740
|
-
const [foundWallet] = useWallet({
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
return [
|
|
748
|
-
wallets ?? (walletContextProvided ? null : wallets),
|
|
749
|
-
error
|
|
750
|
-
];
|
|
751
|
-
}, "useWallets");
|
|
825
|
+
const [foundWallet] = useWallet({ wallet });
|
|
826
|
+
const [wallets, error] = usePromise5(
|
|
827
|
+
async () => foundWallet ? await Promise.all(paths.map((path) => foundWallet.derivePath(path))) : void 0,
|
|
828
|
+
[foundWallet, paths]
|
|
829
|
+
);
|
|
830
|
+
return [wallets ?? (walletContextProvided ? null : wallets), error];
|
|
831
|
+
};
|
|
752
832
|
|
|
753
833
|
// src/hooks/useWrapperAccount.ts
|
|
754
834
|
import { usePromise as usePromise6 } from "@xylabs/react-promise";
|
|
@@ -756,7 +836,7 @@ import { HDWallet as HDWallet2 } from "@xyo-network/wallet";
|
|
|
756
836
|
import { Mutex } from "async-mutex";
|
|
757
837
|
var globalWrapperWallet;
|
|
758
838
|
var globalWrapperWalletMutex = new Mutex();
|
|
759
|
-
var useWrapperAccount =
|
|
839
|
+
var useWrapperAccount = (account) => {
|
|
760
840
|
return usePromise6(async () => {
|
|
761
841
|
return await globalWrapperWalletMutex.runExclusive(async () => {
|
|
762
842
|
if (account !== void 0) {
|
|
@@ -774,166 +854,187 @@ var useWrapperAccount = /* @__PURE__ */ __name((account) => {
|
|
|
774
854
|
}
|
|
775
855
|
return globalWrapperWallet;
|
|
776
856
|
});
|
|
777
|
-
}, [
|
|
778
|
-
|
|
779
|
-
]);
|
|
780
|
-
}, "useWrapperAccount");
|
|
857
|
+
}, [account]);
|
|
858
|
+
};
|
|
781
859
|
|
|
782
860
|
// src/components/WalletAccountDetails/WalletAccountDetails.tsx
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
861
|
+
import { jsx as jsx16, jsxs as jsxs14 } from "react/jsx-runtime";
|
|
862
|
+
var WalletAccountDetails = ({
|
|
863
|
+
exploreUrl = "https://explore.xyo.network",
|
|
864
|
+
account,
|
|
865
|
+
...props
|
|
866
|
+
}) => {
|
|
867
|
+
const [accountToUse] = useAccount({ account });
|
|
787
868
|
const { network } = useNetwork();
|
|
788
869
|
const exploreAddressUrl = `${exploreUrl}/recent?account=${accountToUse?.address}&network=${network?.name ?? "main"}`;
|
|
789
|
-
return /* @__PURE__ */
|
|
790
|
-
address: EthAddressWrapper.fromString(accountToUse?.address)
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
}), /* @__PURE__ */ React16.createElement(NumberStatus, {
|
|
800
|
-
rounded: true,
|
|
801
|
-
title: "NFTs",
|
|
802
|
-
value: 0,
|
|
803
|
-
to: `${exploreAddressUrl}&schema=network.xyo.account.nfts`,
|
|
804
|
-
target: "_blank"
|
|
805
|
-
}), /* @__PURE__ */ React16.createElement(NumberStatus, {
|
|
806
|
-
rounded: true,
|
|
807
|
-
title: "Signatures",
|
|
808
|
-
value: 0,
|
|
809
|
-
to: `${exploreAddressUrl}&schema=network.xyo.account.signatures`,
|
|
810
|
-
target: "_blank"
|
|
811
|
-
}), /* @__PURE__ */ React16.createElement(NumberStatus, {
|
|
812
|
-
rounded: true,
|
|
813
|
-
title: "Signins",
|
|
814
|
-
value: 0,
|
|
815
|
-
to: `${exploreAddressUrl}&schema=network.xyo.account.signins`,
|
|
816
|
-
target: "_blank"
|
|
817
|
-
})));
|
|
818
|
-
}, "WalletAccountDetails");
|
|
870
|
+
return /* @__PURE__ */ jsxs14(FlexCol, { ...props, children: [
|
|
871
|
+
/* @__PURE__ */ jsx16(EthAccountButton, { address: EthAddressWrapper.fromString(accountToUse?.address) }),
|
|
872
|
+
/* @__PURE__ */ jsxs14(FlexRow4, { gap: 1, children: [
|
|
873
|
+
/* @__PURE__ */ jsx16(NumberStatus, { rounded: true, title: "Tokens", value: 0, to: `${exploreAddressUrl}&schema=network.xyo.account.tokens`, target: "_blank" }),
|
|
874
|
+
/* @__PURE__ */ jsx16(NumberStatus, { rounded: true, title: "NFTs", value: 0, to: `${exploreAddressUrl}&schema=network.xyo.account.nfts`, target: "_blank" }),
|
|
875
|
+
/* @__PURE__ */ jsx16(NumberStatus, { rounded: true, title: "Signatures", value: 0, to: `${exploreAddressUrl}&schema=network.xyo.account.signatures`, target: "_blank" }),
|
|
876
|
+
/* @__PURE__ */ jsx16(NumberStatus, { rounded: true, title: "Signins", value: 0, to: `${exploreAddressUrl}&schema=network.xyo.account.signins`, target: "_blank" })
|
|
877
|
+
] })
|
|
878
|
+
] });
|
|
879
|
+
};
|
|
819
880
|
|
|
820
881
|
// src/components/WalletAccountSelect/Select.tsx
|
|
821
882
|
import { CircularProgress, MenuItem as MenuItem2 } from "@mui/material";
|
|
822
883
|
import { SelectEx } from "@xylabs/react-select";
|
|
823
884
|
import { AddressRenderRowBox as AddressRenderRowBox2 } from "@xyo-network/react-address-render";
|
|
824
|
-
import React18 from "react";
|
|
825
885
|
|
|
826
886
|
// src/components/WalletAccountSelect/RenderedMenuItem.tsx
|
|
827
887
|
import { MenuItem } from "@mui/material";
|
|
828
888
|
import { AddressRenderRowBox } from "@xyo-network/react-address-render";
|
|
829
|
-
import
|
|
830
|
-
var RenderedAccountMenuItem =
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
889
|
+
import { jsx as jsx17 } from "react/jsx-runtime";
|
|
890
|
+
var RenderedAccountMenuItem = ({
|
|
891
|
+
selectedAccountIndex,
|
|
892
|
+
rootWallet,
|
|
893
|
+
addressNames,
|
|
894
|
+
iconOnly,
|
|
895
|
+
iconSize,
|
|
896
|
+
icons,
|
|
897
|
+
showFavorite
|
|
898
|
+
}) => {
|
|
899
|
+
const [selectedAccount] = useWallet({ path: selectedAccountIndex?.toString(), wallet: rootWallet });
|
|
835
900
|
const customName = selectedAccount ? addressNames?.[selectedAccount.address] : void 0;
|
|
836
901
|
const favorite = !!selectedAccount && selectedAccount.address in (addressNames ?? {});
|
|
837
|
-
return /* @__PURE__ */
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
paddingBottom: 0,
|
|
842
|
-
paddingTop: 0
|
|
843
|
-
}
|
|
844
|
-
}, /* @__PURE__ */ React17.createElement(AddressRenderRowBox, {
|
|
845
|
-
disableSharedRef: true,
|
|
846
|
-
flexGrow: 1,
|
|
847
|
-
address: selectedAccount?.address,
|
|
848
|
-
iconOnly,
|
|
849
|
-
iconSize,
|
|
850
|
-
icons,
|
|
851
|
-
name: customName,
|
|
852
|
-
favorite,
|
|
853
|
-
showFavorite
|
|
854
|
-
}));
|
|
855
|
-
}, "RenderedAccountMenuItem");
|
|
856
|
-
|
|
857
|
-
// src/components/WalletAccountSelect/Select.tsx
|
|
858
|
-
var arrayRange = /* @__PURE__ */ __name((length, start = 0) => {
|
|
859
|
-
return [
|
|
860
|
-
...Array.from({
|
|
861
|
-
length
|
|
862
|
-
}).keys()
|
|
863
|
-
].map((x) => x + start);
|
|
864
|
-
}, "arrayRange");
|
|
865
|
-
var WalletAccountSelect = /* @__PURE__ */ __name(({ addressNames, iconOnly, iconSize = 24, icons, maxAccounts = 1, showFavorite = false, size, variant = "outlined", ...props }) => {
|
|
866
|
-
const { activeAccountIndex, setActiveAccountIndex, rootWallet } = useWalletContext();
|
|
867
|
-
const disabled = !rootWallet || activeAccountIndex === void 0;
|
|
868
|
-
return /* @__PURE__ */ React18.createElement(React18.Fragment, null, rootWallet ? /* @__PURE__ */ React18.createElement(SelectEx, {
|
|
869
|
-
margin: "dense",
|
|
870
|
-
disabled,
|
|
871
|
-
renderValue: /* @__PURE__ */ __name((selectedAccountIndex) => {
|
|
872
|
-
return /* @__PURE__ */ React18.createElement(RenderedAccountMenuItem, {
|
|
873
|
-
addressNames,
|
|
874
|
-
iconOnly,
|
|
875
|
-
iconSize,
|
|
876
|
-
icons,
|
|
877
|
-
rootWallet,
|
|
878
|
-
selectedAccountIndex,
|
|
879
|
-
showFavorite
|
|
880
|
-
});
|
|
881
|
-
}, "renderValue"),
|
|
882
|
-
value: activeAccountIndex === void 0 ? "" : activeAccountIndex,
|
|
883
|
-
onChange: /* @__PURE__ */ __name((event) => setActiveAccountIndex?.(Number.parseInt(`${event.target.value}`)), "onChange"),
|
|
884
|
-
size,
|
|
885
|
-
variant,
|
|
886
|
-
...props
|
|
887
|
-
}, rootWallet && arrayRange(maxAccounts).map((index) => {
|
|
888
|
-
const [account] = useWallet({
|
|
889
|
-
path: index.toString(),
|
|
890
|
-
wallet: rootWallet
|
|
891
|
-
});
|
|
892
|
-
const customName = account ? addressNames?.[account.address] : void 0;
|
|
893
|
-
const favorite = !!account && account.address in (addressNames ?? {});
|
|
894
|
-
return /* @__PURE__ */ React18.createElement(MenuItem2, {
|
|
895
|
-
key: account?.address,
|
|
896
|
-
value: index,
|
|
902
|
+
return /* @__PURE__ */ jsx17(
|
|
903
|
+
MenuItem,
|
|
904
|
+
{
|
|
905
|
+
value: selectedAccountIndex,
|
|
897
906
|
sx: {
|
|
898
907
|
minHeight: 0,
|
|
899
908
|
paddingBottom: 0,
|
|
900
909
|
paddingTop: 0
|
|
901
|
-
}
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
}
|
|
910
|
+
},
|
|
911
|
+
children: /* @__PURE__ */ jsx17(
|
|
912
|
+
AddressRenderRowBox,
|
|
913
|
+
{
|
|
914
|
+
disableSharedRef: true,
|
|
915
|
+
flexGrow: 1,
|
|
916
|
+
address: selectedAccount?.address,
|
|
917
|
+
iconOnly,
|
|
918
|
+
iconSize,
|
|
919
|
+
icons,
|
|
920
|
+
name: customName,
|
|
921
|
+
favorite,
|
|
922
|
+
showFavorite
|
|
923
|
+
}
|
|
924
|
+
)
|
|
925
|
+
}
|
|
926
|
+
);
|
|
927
|
+
};
|
|
928
|
+
|
|
929
|
+
// src/components/WalletAccountSelect/Select.tsx
|
|
930
|
+
import { Fragment as Fragment4, jsx as jsx18 } from "react/jsx-runtime";
|
|
931
|
+
var arrayRange = (length, start = 0) => {
|
|
932
|
+
return [...Array.from({ length }).keys()].map((x) => x + start);
|
|
933
|
+
};
|
|
934
|
+
var WalletAccountSelect = ({
|
|
935
|
+
addressNames,
|
|
936
|
+
iconOnly,
|
|
937
|
+
iconSize = 24,
|
|
938
|
+
icons,
|
|
939
|
+
maxAccounts = 1,
|
|
940
|
+
showFavorite = false,
|
|
941
|
+
size,
|
|
942
|
+
variant = "outlined",
|
|
943
|
+
...props
|
|
944
|
+
}) => {
|
|
945
|
+
const {
|
|
946
|
+
activeAccountIndex,
|
|
947
|
+
setActiveAccountIndex,
|
|
948
|
+
rootWallet
|
|
949
|
+
} = useWalletContext();
|
|
950
|
+
const disabled = !rootWallet || activeAccountIndex === void 0;
|
|
951
|
+
return /* @__PURE__ */ jsx18(Fragment4, { children: rootWallet ? /* @__PURE__ */ jsx18(
|
|
952
|
+
SelectEx,
|
|
953
|
+
{
|
|
954
|
+
margin: "dense",
|
|
955
|
+
disabled,
|
|
956
|
+
renderValue: (selectedAccountIndex) => {
|
|
957
|
+
return /* @__PURE__ */ jsx18(
|
|
958
|
+
RenderedAccountMenuItem,
|
|
959
|
+
{
|
|
960
|
+
addressNames,
|
|
961
|
+
iconOnly,
|
|
962
|
+
iconSize,
|
|
963
|
+
icons,
|
|
964
|
+
rootWallet,
|
|
965
|
+
selectedAccountIndex,
|
|
966
|
+
showFavorite
|
|
967
|
+
}
|
|
968
|
+
);
|
|
969
|
+
},
|
|
970
|
+
value: activeAccountIndex === void 0 ? "" : activeAccountIndex,
|
|
971
|
+
onChange: (event) => setActiveAccountIndex?.(Number.parseInt(`${event.target.value}`)),
|
|
972
|
+
size,
|
|
973
|
+
variant,
|
|
974
|
+
...props,
|
|
975
|
+
children: rootWallet && arrayRange(maxAccounts).map((index) => {
|
|
976
|
+
const [account] = useWallet({ path: index.toString(), wallet: rootWallet });
|
|
977
|
+
const customName = account ? addressNames?.[account.address] : void 0;
|
|
978
|
+
const favorite = !!account && account.address in (addressNames ?? {});
|
|
979
|
+
return /* @__PURE__ */ jsx18(
|
|
980
|
+
MenuItem2,
|
|
981
|
+
{
|
|
982
|
+
value: index,
|
|
983
|
+
sx: {
|
|
984
|
+
minHeight: 0,
|
|
985
|
+
paddingBottom: 0,
|
|
986
|
+
paddingTop: 0
|
|
987
|
+
},
|
|
988
|
+
children: /* @__PURE__ */ jsx18(
|
|
989
|
+
AddressRenderRowBox2,
|
|
990
|
+
{
|
|
991
|
+
disableSharedRef: true,
|
|
992
|
+
flexGrow: 1,
|
|
993
|
+
address: account?.address,
|
|
994
|
+
favorite,
|
|
995
|
+
iconOnly,
|
|
996
|
+
iconSize,
|
|
997
|
+
icons,
|
|
998
|
+
name: customName,
|
|
999
|
+
showFavorite
|
|
1000
|
+
}
|
|
1001
|
+
)
|
|
1002
|
+
},
|
|
1003
|
+
account?.address
|
|
1004
|
+
);
|
|
1005
|
+
})
|
|
1006
|
+
}
|
|
1007
|
+
) : /* @__PURE__ */ jsx18(CircularProgress, { size: 24 }) });
|
|
1008
|
+
};
|
|
917
1009
|
|
|
918
1010
|
// src/components/WalletAccountSelect/SelectBar.tsx
|
|
919
1011
|
import { FlexCol as FlexCol2 } from "@xylabs/react-flexbox";
|
|
920
|
-
import
|
|
921
|
-
var WalletAccountSelectBar =
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
1012
|
+
import { jsx as jsx19 } from "react/jsx-runtime";
|
|
1013
|
+
var WalletAccountSelectBar = ({
|
|
1014
|
+
addressNames,
|
|
1015
|
+
iconOnly,
|
|
1016
|
+
iconSize,
|
|
1017
|
+
icons,
|
|
1018
|
+
maxAccounts = 1,
|
|
1019
|
+
showFavorite = false,
|
|
1020
|
+
size = "small",
|
|
1021
|
+
...props
|
|
1022
|
+
}) => {
|
|
1023
|
+
return /* @__PURE__ */ jsx19(FlexCol2, { alignItems: "stretch", ...props, children: /* @__PURE__ */ jsx19(
|
|
1024
|
+
WalletAccountSelect,
|
|
1025
|
+
{
|
|
1026
|
+
addressNames,
|
|
1027
|
+
fullWidth: true,
|
|
1028
|
+
showFavorite,
|
|
1029
|
+
iconSize,
|
|
1030
|
+
iconOnly,
|
|
1031
|
+
icons,
|
|
1032
|
+
maxAccounts,
|
|
1033
|
+
size: size ?? "small",
|
|
1034
|
+
variant: "outlined"
|
|
1035
|
+
}
|
|
1036
|
+
) });
|
|
1037
|
+
};
|
|
937
1038
|
export {
|
|
938
1039
|
DefaultSeedPhrase,
|
|
939
1040
|
DialogActionButtons,
|