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