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