@xyo-network/react-connected-accounts 6.2.0 → 7.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser/classes/EnabledWallets.d.ts.map +1 -1
- package/dist/browser/components/ConnectedAccountsFlexbox.stories.d.ts +2 -2
- package/dist/browser/components/ConnectedAccountsFlexbox.stories.d.ts.map +1 -1
- package/dist/browser/hooks/useDetectWallets.d.ts.map +1 -1
- package/dist/browser/index.mjs +377 -337
- package/dist/browser/index.mjs.map +1 -1
- package/package.json +23 -16
- package/src/classes/EnabledWallets.ts +5 -1
- package/src/hooks/useDetectWallets.tsx +6 -4
- package/typedoc.json +0 -5
- package/xy.config.ts +0 -10
package/dist/browser/index.mjs
CHANGED
@@ -1,12 +1,6 @@
|
|
1
|
-
var __defProp = Object.defineProperty;
|
2
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
3
|
-
|
4
1
|
// src/classes/EnabledWallets.ts
|
5
2
|
var DEFAULT_LOCAL_STORAGE_KEY = "XYO|EnabledWallets";
|
6
3
|
var EnabledEthWalletConnections = class {
|
7
|
-
static {
|
8
|
-
__name(this, "EnabledEthWalletConnections");
|
9
|
-
}
|
10
4
|
// control whether or not enabled/disabled preferences are persisted (i.e. in localStorage)
|
11
5
|
persistPreferences = true;
|
12
6
|
// Map of wallet names and their enabled/disabled state
|
@@ -31,26 +25,27 @@ var EnabledEthWalletConnections = class {
|
|
31
25
|
this.toggleEnabledWallet(rdns, true);
|
32
26
|
}
|
33
27
|
/**
|
34
|
-
|
35
|
-
|
28
|
+
* Given a new set of wallets, set their enabled state based off previous preferences
|
29
|
+
*/
|
36
30
|
resetWallets(wallets) {
|
37
31
|
const newWallets = {};
|
38
|
-
const addWallet =
|
32
|
+
const addWallet = ([walletName, wallet]) => {
|
39
33
|
newWallets[walletName] = {
|
40
34
|
// preserve the existing enabled state
|
41
35
|
enabled: walletName in this.enabledWallets ? this.enabledWallets[walletName] : true,
|
42
36
|
wallet
|
43
37
|
};
|
44
|
-
}
|
45
|
-
Object.entries(wallets).forEach(
|
38
|
+
};
|
39
|
+
Object.entries(wallets).forEach((wallet) => {
|
40
|
+
if (wallet !== void 0) {
|
41
|
+
addWallet.bind(this);
|
42
|
+
}
|
43
|
+
});
|
46
44
|
this.ethWalletsState = newWallets;
|
47
45
|
this.emitChange();
|
48
46
|
}
|
49
47
|
subscribe(listener) {
|
50
|
-
this.listeners = [
|
51
|
-
...this.listeners,
|
52
|
-
listener
|
53
|
-
];
|
48
|
+
this.listeners = [...this.listeners, listener];
|
54
49
|
return () => {
|
55
50
|
this.listeners = this.listeners.filter((existingListener) => existingListener !== listener);
|
56
51
|
};
|
@@ -58,9 +53,7 @@ var EnabledEthWalletConnections = class {
|
|
58
53
|
toggleEnabledWallet(rdns, enabled) {
|
59
54
|
if (rdns && this.ethWalletsState[rdns]) {
|
60
55
|
this.ethWalletsState[rdns].enabled = enabled;
|
61
|
-
this.ethWalletsState = {
|
62
|
-
...this.ethWalletsState
|
63
|
-
};
|
56
|
+
this.ethWalletsState = { ...this.ethWalletsState };
|
64
57
|
this.emitChange();
|
65
58
|
}
|
66
59
|
}
|
@@ -100,219 +93,236 @@ var EnabledEthWalletConnections = class {
|
|
100
93
|
// src/components/ConnectedAccountsFlexbox.tsx
|
101
94
|
import { Typography as Typography6, useTheme as useTheme2 } from "@mui/material";
|
102
95
|
import { FlexCol as FlexCol3 } from "@xylabs/react-flexbox";
|
103
|
-
import React13 from "react";
|
104
96
|
|
105
97
|
// src/hooks/useDetectWallets.tsx
|
106
98
|
import { useWalletDiscovery } from "@xylabs/react-crypto";
|
107
99
|
import { useMemo } from "react";
|
108
|
-
var sortWallets =
|
100
|
+
var sortWallets = (wallets) => {
|
109
101
|
const result = [];
|
110
102
|
for (const wallet of Object.values(wallets)) {
|
111
|
-
if (wallet
|
112
|
-
|
103
|
+
if (wallet) {
|
104
|
+
if (wallet.allowedAccounts.length > 0)
|
105
|
+
result.unshift(wallet);
|
106
|
+
else
|
107
|
+
result.push(wallet);
|
108
|
+
}
|
113
109
|
}
|
114
110
|
return result;
|
115
|
-
}
|
116
|
-
var useDetectedWallets =
|
111
|
+
};
|
112
|
+
var useDetectedWallets = () => {
|
117
113
|
const wallets = useWalletDiscovery();
|
118
|
-
const sortedWallets = useMemo(() => sortWallets(wallets), [
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
sortedWallets,
|
126
|
-
totalConnectedAccounts
|
127
|
-
};
|
128
|
-
}, "useDetectedWallets");
|
114
|
+
const sortedWallets = useMemo(() => sortWallets(wallets), [wallets]);
|
115
|
+
const totalConnectedAccounts = useMemo(
|
116
|
+
() => Object.values(sortedWallets).reduce((acc, wallet) => acc + wallet.allowedAccounts.length, 0),
|
117
|
+
[sortedWallets]
|
118
|
+
);
|
119
|
+
return { sortedWallets, totalConnectedAccounts };
|
120
|
+
};
|
129
121
|
|
130
122
|
// src/hooks/useEnabledWallets.tsx
|
131
123
|
import { useWalletDiscovery as useWalletDiscovery2 } from "@xylabs/react-crypto";
|
132
124
|
import { useMemo as useMemo2, useSyncExternalStore } from "react";
|
133
125
|
var enabledEthWallets;
|
134
|
-
var useEnabledWalletsInner =
|
126
|
+
var useEnabledWalletsInner = (enabledWalletsRdns) => {
|
135
127
|
const discoveredWallets = useWalletDiscovery2();
|
136
128
|
const wallets = useMemo2(() => {
|
137
129
|
if (enabledEthWallets === void 0) enabledEthWallets = new EnabledEthWalletConnections();
|
138
130
|
enabledEthWallets.resetWallets(discoveredWallets);
|
139
131
|
for (const [rdns, enabled] of Object.entries(enabledWalletsRdns ?? {})) enabledEthWallets?.toggleEnabledWallet(rdns, enabled);
|
140
132
|
return enabledEthWallets;
|
141
|
-
}, [
|
142
|
-
discoveredWallets,
|
143
|
-
enabledWalletsRdns
|
144
|
-
]);
|
133
|
+
}, [discoveredWallets, enabledWalletsRdns]);
|
145
134
|
return useSyncExternalStore(wallets.subscribe.bind(wallets), () => wallets.wallets);
|
146
|
-
}
|
147
|
-
var useEnabledWallets =
|
135
|
+
};
|
136
|
+
var useEnabledWallets = (enabledWalletsRdns) => {
|
148
137
|
const wallets = useEnabledWalletsInner(enabledWalletsRdns);
|
149
|
-
const enabledWallets = useMemo2(
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
138
|
+
const enabledWallets = useMemo2(
|
139
|
+
() => (
|
140
|
+
// eslint-disable-next-line unicorn/no-array-reduce
|
141
|
+
Object.entries(wallets).reduce((acc, [walletName, wallet]) => {
|
142
|
+
if (wallet.enabled) acc[walletName] = wallet;
|
143
|
+
return acc;
|
144
|
+
}, {})
|
145
|
+
),
|
146
|
+
[wallets]
|
147
|
+
);
|
158
148
|
return {
|
159
149
|
disableWallet: enabledEthWallets?.disableWallet.bind(enabledEthWallets),
|
160
150
|
enableWallet: enabledEthWallets?.enableWallet.bind(enabledEthWallets),
|
161
151
|
enabledWallets,
|
162
152
|
wallets
|
163
153
|
};
|
164
|
-
}
|
154
|
+
};
|
165
155
|
|
166
156
|
// src/components/wallet/dialogs/connect/CheckboxFormControl.tsx
|
167
|
-
import {
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
157
|
+
import {
|
158
|
+
Checkbox,
|
159
|
+
FormControl,
|
160
|
+
FormLabel
|
161
|
+
} from "@mui/material";
|
162
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
163
|
+
var CheckboxFormControl = ({ onCheckChanged, ...props }) => {
|
164
|
+
return /* @__PURE__ */ jsx(FormControl, { ...props, children: /* @__PURE__ */ jsxs(FormLabel, { children: [
|
165
|
+
/* @__PURE__ */ jsx(Checkbox, { onChange: (_, checked) => onCheckChanged?.(checked) }),
|
166
|
+
"Do not show this again."
|
167
|
+
] }) });
|
168
|
+
};
|
174
169
|
|
175
170
|
// src/components/wallet/dialogs/connect/Dialog.tsx
|
176
|
-
import {
|
177
|
-
|
171
|
+
import {
|
172
|
+
Button,
|
173
|
+
Dialog,
|
174
|
+
DialogActions,
|
175
|
+
DialogContent,
|
176
|
+
DialogTitle
|
177
|
+
} from "@mui/material";
|
178
178
|
|
179
179
|
// src/components/wallet/dialogs/connect/LinkedProvidersFlexbox.tsx
|
180
180
|
import { SyncAlt } from "@mui/icons-material";
|
181
181
|
import { Typography } from "@mui/material";
|
182
182
|
import { ConstrainedImage } from "@xylabs/react-crypto";
|
183
183
|
import { FlexCol, FlexRow } from "@xylabs/react-flexbox";
|
184
|
-
import React2 from "react";
|
185
184
|
|
186
185
|
// src/img/xyo-color-logo.svg
|
187
186
|
var xyo_color_logo_default = '<svg id="Layer_1" data-name="Layer 1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 256 238"><defs><style>.cls-1{fill:#8d8fc6;}.cls-2{fill:#579fd6;}.cls-3{fill:#f27046;}.cls-4{fill:#eb407a;}</style></defs><path class="cls-1" d="M74.5,28.33,21.29,120.5,74.5,212.67H180.94l1.76-3,51.46-89.13L180.94,28.33ZM84.65,40.54h78.83L111.65,56.93a15.85,15.85,0,0,1,2,5l59.66-18.81L185.22,101a20.12,20.12,0,0,1,5.36-.78l-10-47.91,37.87,65.53h-7.62a24.21,24.21,0,0,1,.15,2.68,23.29,23.29,0,0,1-.15,2.68h7.62l-39.1,67.75,10.92-50.13A20.57,20.57,0,0,1,185,140l-12.88,59-58.37-19.53a17.61,17.61,0,0,1-1.7,5l47.5,15.92H84.65l4-6.85A20.17,20.17,0,0,1,83.93,191L80,197.78,42.67,133.13l37,32.66a20.52,20.52,0,0,1,3.6-4L36.69,120.66,85,77.79a17.45,17.45,0,0,1-3.19-4.32l-39.46,35L80,43.22l5.56,9.69A17.51,17.51,0,0,1,90.12,50Zm28.24,31.17a16.15,16.15,0,0,1-2.68,4.64l62,35.81a19.74,19.74,0,0,1,2.83-4.54Zm-20,10.51v75.33a18,18,0,0,1,2.47-.16,17.18,17.18,0,0,1,2.89.21v-75a11.21,11.21,0,0,1-1.29,0,17.57,17.57,0,0,1-4.07-.47Zm79.34,46.63-62.08,35.81a18.45,18.45,0,0,1,2.68,4.68l62.23-36a19.68,19.68,0,0,1-2.83-4.53Z"/><path class="cls-2" d="M97,48.58a17.06,17.06,0,1,0,17,17,17.08,17.08,0,0,0-17-17Zm0,5.36a11.7,11.7,0,1,1-11.7,11.69A11.65,11.65,0,0,1,97,53.94Z"/><path class="cls-3" d="M95.37,157.39a18.73,18.73,0,1,0,18.7,18.7,18.74,18.74,0,0,0-18.7-18.7Zm0,5.31A13.4,13.4,0,1,1,82,176.09a13.37,13.37,0,0,1,13.4-13.39Z"/><path class="cls-4" d="M190.73,100.2A20.3,20.3,0,1,0,211,120.5a20.34,20.34,0,0,0-20.3-20.3Zm0,5.36a14.94,14.94,0,1,1-14.94,14.94,14.88,14.88,0,0,1,14.94-14.94Z"/></svg>';
|
188
187
|
|
189
188
|
// src/components/wallet/dialogs/connect/LinkedProvidersFlexbox.tsx
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
}
|
217
|
-
}), /* @__PURE__ */ React2.createElement(Typography, {
|
218
|
-
variant: "subtitle1"
|
219
|
-
}, providerName)));
|
220
|
-
}, "LinkedProvidersFlexbox");
|
189
|
+
import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
|
190
|
+
var LinkedProvidersFlexbox = ({
|
191
|
+
icon,
|
192
|
+
providerName,
|
193
|
+
...props
|
194
|
+
}) => {
|
195
|
+
return /* @__PURE__ */ jsxs2(FlexRow, { gap: 4, justifyContent: "space-evenly", ...props, children: [
|
196
|
+
/* @__PURE__ */ jsxs2(FlexCol, { gap: 0.5, children: [
|
197
|
+
/* @__PURE__ */ jsx2("img", { alt: "XYO Logo", src: xyo_color_logo_default, style: { height: "48px" } }),
|
198
|
+
/* @__PURE__ */ jsx2(Typography, { variant: "subtitle1", children: "XYO App" })
|
199
|
+
] }),
|
200
|
+
/* @__PURE__ */ jsx2(SyncAlt, { fontSize: "large" }),
|
201
|
+
/* @__PURE__ */ jsxs2(FlexCol, { gap: 0.5, children: [
|
202
|
+
/* @__PURE__ */ jsx2(
|
203
|
+
ConstrainedImage,
|
204
|
+
{
|
205
|
+
constrainedValue: "48px",
|
206
|
+
src: icon,
|
207
|
+
alt: providerName,
|
208
|
+
style: { height: "48px", maxWidth: "48px" }
|
209
|
+
}
|
210
|
+
),
|
211
|
+
/* @__PURE__ */ jsx2(Typography, { variant: "subtitle1", children: providerName })
|
212
|
+
] })
|
213
|
+
] });
|
214
|
+
};
|
221
215
|
|
222
216
|
// src/components/wallet/dialogs/connect/Permissions.tsx
|
223
217
|
import { Link, Typography as Typography2 } from "@mui/material";
|
224
218
|
import { FlexCol as FlexCol2 } from "@xylabs/react-flexbox";
|
225
|
-
import
|
226
|
-
var WalletPermissionsFlexbox =
|
227
|
-
return /* @__PURE__ */
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
}
|
219
|
+
import { jsx as jsx3, jsxs as jsxs3 } from "react/jsx-runtime";
|
220
|
+
var WalletPermissionsFlexbox = (props) => {
|
221
|
+
return /* @__PURE__ */ jsxs3(FlexCol2, { gap: 4, ...props, children: [
|
222
|
+
/* @__PURE__ */ jsx3(Typography2, { fontWeight: "bold", sx: { textAlign: "center" }, children: "This will allow XYO to:" }),
|
223
|
+
/* @__PURE__ */ jsxs3("ul", { children: [
|
224
|
+
/* @__PURE__ */ jsx3("li", { children: "View your wallet account(s) and address(es)" }),
|
225
|
+
/* @__PURE__ */ jsx3("li", { children: "Read-only access to browse the public blockchain(s) you select" })
|
226
|
+
] }),
|
227
|
+
/* @__PURE__ */ jsxs3(Typography2, { variant: "subtitle1", sx: { textAlign: "center" }, children: [
|
228
|
+
"You control what accounts to share and what blockchains to view. You can see or revoke access via your wallet's settings at anytime. View more on XYO's sovereign data philosophy",
|
229
|
+
" ",
|
230
|
+
/* @__PURE__ */ jsx3(
|
231
|
+
Link,
|
232
|
+
{
|
233
|
+
href: "https://cointelegraph.com/innovation-circle/decentralization-and-sovereignty-debunking-our-approach-to-digital-sovereignty",
|
234
|
+
sx: { fontWeight: "bold" },
|
235
|
+
target: "_blank",
|
236
|
+
children: "here"
|
237
|
+
}
|
238
|
+
),
|
239
|
+
"."
|
240
|
+
] })
|
241
|
+
] });
|
242
|
+
};
|
248
243
|
|
249
244
|
// src/components/wallet/dialogs/connect/Dialog.tsx
|
250
|
-
|
245
|
+
import { jsx as jsx4, jsxs as jsxs4 } from "react/jsx-runtime";
|
246
|
+
var ConnectWalletDialog = ({
|
247
|
+
activeProvider,
|
248
|
+
onIgnoreConnectDialog,
|
249
|
+
...props
|
250
|
+
}) => {
|
251
251
|
const { icon, providerName } = activeProvider ?? {};
|
252
|
-
const onConnect =
|
252
|
+
const onConnect = async () => {
|
253
253
|
try {
|
254
254
|
await activeProvider?.connectWallet?.();
|
255
255
|
props.onClose?.({}, "escapeKeyDown");
|
256
256
|
} catch (e) {
|
257
257
|
console.warn(`Error connecting to wallet: ${e.message}`);
|
258
258
|
}
|
259
|
-
}
|
260
|
-
return /* @__PURE__ */
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
}
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
259
|
+
};
|
260
|
+
return /* @__PURE__ */ jsxs4(
|
261
|
+
Dialog,
|
262
|
+
{
|
263
|
+
slotProps: { paper: { sx: { display: "flex", gap: 4 } } },
|
264
|
+
...props,
|
265
|
+
children: [
|
266
|
+
/* @__PURE__ */ jsx4(DialogTitle, { sx: { textAlign: "center" }, children: "XYO Wants To Access The Blockchain on Your Behalf" }),
|
267
|
+
/* @__PURE__ */ jsxs4(
|
268
|
+
DialogContent,
|
269
|
+
{
|
270
|
+
sx: {
|
271
|
+
display: "flex",
|
272
|
+
flexDirection: "column",
|
273
|
+
gap: 4
|
274
|
+
},
|
275
|
+
children: [
|
276
|
+
/* @__PURE__ */ jsx4(LinkedProvidersFlexbox, { icon, providerName }),
|
277
|
+
/* @__PURE__ */ jsx4(WalletPermissionsFlexbox, {}),
|
278
|
+
/* @__PURE__ */ jsx4(CheckboxFormControl, { onCheckChanged: onIgnoreConnectDialog })
|
279
|
+
]
|
280
|
+
}
|
281
|
+
),
|
282
|
+
/* @__PURE__ */ jsxs4(DialogActions, { children: [
|
283
|
+
/* @__PURE__ */ jsx4(Button, { variant: "outlined", onClick: () => props.onClose?.({}, "escapeKeyDown"), children: "Close" }),
|
284
|
+
/* @__PURE__ */ jsx4(Button, { variant: "contained", onClick: onConnect, children: "Connect" })
|
285
|
+
] })
|
286
|
+
]
|
279
287
|
}
|
280
|
-
|
281
|
-
|
282
|
-
providerName
|
283
|
-
}), /* @__PURE__ */ React4.createElement(WalletPermissionsFlexbox, null), /* @__PURE__ */ React4.createElement(CheckboxFormControl, {
|
284
|
-
onCheckChanged: onIgnoreConnectDialog
|
285
|
-
})), /* @__PURE__ */ React4.createElement(DialogActions, null, /* @__PURE__ */ React4.createElement(Button, {
|
286
|
-
variant: "outlined",
|
287
|
-
onClick: /* @__PURE__ */ __name(() => props.onClose?.({}, "escapeKeyDown"), "onClick")
|
288
|
-
}, "Close"), /* @__PURE__ */ React4.createElement(Button, {
|
289
|
-
variant: "contained",
|
290
|
-
onClick: onConnect
|
291
|
-
}, "Connect")));
|
292
|
-
}, "ConnectWalletDialog");
|
288
|
+
);
|
289
|
+
};
|
293
290
|
|
294
291
|
// src/components/wallet/dialogs/revoke/Dialog.tsx
|
295
|
-
import {
|
292
|
+
import {
|
293
|
+
Button as Button2,
|
294
|
+
Dialog as Dialog2,
|
295
|
+
DialogActions as DialogActions2,
|
296
|
+
DialogContent as DialogContent2,
|
297
|
+
DialogTitle as DialogTitle2,
|
298
|
+
Typography as Typography3
|
299
|
+
} from "@mui/material";
|
296
300
|
import { ConstrainedImage as ConstrainedImage2 } from "@xylabs/react-crypto";
|
297
301
|
import { FlexRow as FlexRow2 } from "@xylabs/react-flexbox";
|
298
|
-
import
|
299
|
-
var RevokeWalletConnectionDialog =
|
300
|
-
return /* @__PURE__ */
|
301
|
-
gap: 2,
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
302
|
+
import { jsx as jsx5, jsxs as jsxs5 } from "react/jsx-runtime";
|
303
|
+
var RevokeWalletConnectionDialog = ({ activeProvider, ...props }) => {
|
304
|
+
return /* @__PURE__ */ jsxs5(Dialog2, { ...props, children: [
|
305
|
+
/* @__PURE__ */ jsxs5(FlexRow2, { gap: 2, justifyContent: "start", pl: 2, children: [
|
306
|
+
/* @__PURE__ */ jsx5(ConstrainedImage2, { src: activeProvider?.icon, constrainedValue: "24px" }),
|
307
|
+
/* @__PURE__ */ jsxs5(DialogTitle2, { sx: { pl: 0 }, children: [
|
308
|
+
"Revoke",
|
309
|
+
activeProvider?.providerName,
|
310
|
+
" ",
|
311
|
+
"Access"
|
312
|
+
] })
|
313
|
+
] }),
|
314
|
+
/* @__PURE__ */ jsxs5(DialogContent2, { children: [
|
315
|
+
/* @__PURE__ */ jsxs5(Typography3, { children: [
|
316
|
+
"Revoking access to your wallet must be done from the wallet's browser extension. Wallets grant access to specific domains please consult",
|
317
|
+
" ",
|
318
|
+
activeProvider?.providerName,
|
319
|
+
"'s documentation on how to revoke access to this website:"
|
320
|
+
] }),
|
321
|
+
/* @__PURE__ */ jsx5(Typography3, { children: globalThis.location.origin })
|
322
|
+
] }),
|
323
|
+
/* @__PURE__ */ jsx5(DialogActions2, { children: /* @__PURE__ */ jsx5(Button2, { variant: "contained", onClick: () => props.onClose?.({}, "escapeKeyDown"), children: "Close" }) })
|
324
|
+
] });
|
325
|
+
};
|
316
326
|
|
317
327
|
// src/components/wallet/lib/TableHeadData.ts
|
318
328
|
var WalletsTableHeadCells = [
|
@@ -354,88 +364,100 @@ var WalletsTableHeadCells = [
|
|
354
364
|
];
|
355
365
|
|
356
366
|
// src/components/wallet/table/cells/Accounts.tsx
|
357
|
-
import {
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
|
367
|
+
import {
|
368
|
+
TableCell,
|
369
|
+
Tooltip,
|
370
|
+
Typography as Typography4
|
371
|
+
} from "@mui/material";
|
372
|
+
import { jsx as jsx6 } from "react/jsx-runtime";
|
373
|
+
var ConnectedWalletsAccountsTableCell = ({
|
374
|
+
additionalAccounts,
|
375
|
+
currentAccount,
|
376
|
+
totalAccounts,
|
377
|
+
tableCellProps
|
378
|
+
}) => {
|
379
|
+
return /* @__PURE__ */ jsx6(TableCell, { ...tableCellProps, children: /* @__PURE__ */ jsx6(
|
380
|
+
Tooltip,
|
381
|
+
{
|
382
|
+
sx: { cursor: totalAccounts > 0 ? "pointer" : "auto" },
|
383
|
+
title: [...currentAccount ?? [], ...additionalAccounts ?? []].map((address, index) => /* @__PURE__ */ jsx6("p", { children: address }, index)),
|
384
|
+
children: /* @__PURE__ */ jsx6(Typography4, { children: totalAccounts })
|
385
|
+
}
|
386
|
+
) });
|
387
|
+
};
|
372
388
|
|
373
389
|
// src/components/wallet/table/cells/Actions.tsx
|
374
390
|
import { Check, InfoOutlined } from "@mui/icons-material";
|
375
|
-
import {
|
391
|
+
import {
|
392
|
+
Button as Button3,
|
393
|
+
IconButton,
|
394
|
+
TableCell as TableCell2,
|
395
|
+
Typography as Typography5
|
396
|
+
} from "@mui/material";
|
376
397
|
import { FlexRow as FlexRow3 } from "@xylabs/react-flexbox";
|
377
|
-
import
|
378
|
-
var ConnectedWalletsActionsTableCell =
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
|
388
|
-
variant: "contained",
|
389
|
-
onClick:
|
390
|
-
}
|
391
|
-
|
392
|
-
}, /* @__PURE__ */ React7.createElement(InfoOutlined, null)) : null));
|
393
|
-
}, "ConnectedWalletsActionsTableCell");
|
398
|
+
import { jsx as jsx7, jsxs as jsxs6 } from "react/jsx-runtime";
|
399
|
+
var ConnectedWalletsActionsTableCell = ({
|
400
|
+
connected,
|
401
|
+
onConnect,
|
402
|
+
onRevoke,
|
403
|
+
tableCellProps
|
404
|
+
}) => {
|
405
|
+
return /* @__PURE__ */ jsx7(TableCell2, { ...tableCellProps, children: /* @__PURE__ */ jsxs6(FlexRow3, { gap: 2, justifyContent: "start", children: [
|
406
|
+
connected ? /* @__PURE__ */ jsxs6(Typography5, { sx: { display: "inline-flex", gap: 0.5 }, children: [
|
407
|
+
/* @__PURE__ */ jsx7(Check, {}),
|
408
|
+
"Connected"
|
409
|
+
] }) : /* @__PURE__ */ jsx7(Button3, { variant: "contained", onClick: onConnect, children: "Connect" }),
|
410
|
+
connected ? /* @__PURE__ */ jsx7(IconButton, { onClick: onRevoke, children: /* @__PURE__ */ jsx7(InfoOutlined, {}) }) : null
|
411
|
+
] }) });
|
412
|
+
};
|
394
413
|
|
395
414
|
// src/components/wallet/table/cells/ChainName.tsx
|
396
415
|
import { TableCell as TableCell3 } from "@mui/material";
|
397
|
-
import
|
398
|
-
var ConnectedWalletsChainNameTableCell =
|
399
|
-
return /* @__PURE__ */
|
400
|
-
}
|
416
|
+
import { jsx as jsx8 } from "react/jsx-runtime";
|
417
|
+
var ConnectedWalletsChainNameTableCell = ({ chainName, tableCellProps }) => {
|
418
|
+
return /* @__PURE__ */ jsx8(TableCell3, { ...tableCellProps, children: chainName });
|
419
|
+
};
|
401
420
|
|
402
421
|
// src/components/wallet/table/cells/State.tsx
|
403
422
|
import { Switch, TableCell as TableCell4 } from "@mui/material";
|
404
|
-
import
|
405
|
-
|
406
|
-
|
407
|
-
|
408
|
-
|
409
|
-
|
410
|
-
|
411
|
-
const
|
423
|
+
import { useMemo as useMemo3 } from "react";
|
424
|
+
import { jsx as jsx9 } from "react/jsx-runtime";
|
425
|
+
var ConnectedWalletState = ({
|
426
|
+
connected,
|
427
|
+
walletRdns,
|
428
|
+
tableCellProps
|
429
|
+
}) => {
|
430
|
+
const {
|
431
|
+
disableWallet,
|
432
|
+
enableWallet,
|
433
|
+
wallets
|
434
|
+
} = useEnabledWallets();
|
435
|
+
const enabled = useMemo3(() => walletRdns ? wallets[walletRdns].enabled : false, [wallets, walletRdns]);
|
436
|
+
const handleClick = (event) => {
|
412
437
|
const checked = event.target?.checked;
|
413
438
|
if (walletRdns) {
|
414
439
|
checked ? enableWallet?.(walletRdns) : disableWallet?.(walletRdns);
|
415
440
|
}
|
416
|
-
}
|
417
|
-
return /* @__PURE__ */
|
418
|
-
|
419
|
-
checked: connected && enabled,
|
420
|
-
onChange: handleClick
|
421
|
-
}));
|
422
|
-
}, "ConnectedWalletState");
|
441
|
+
};
|
442
|
+
return /* @__PURE__ */ jsx9(TableCell4, { ...tableCellProps, children: /* @__PURE__ */ jsx9(Switch, { disabled: !connected, checked: connected && enabled, onChange: handleClick }) });
|
443
|
+
};
|
423
444
|
|
424
445
|
// src/components/wallet/table/cells/Wallet.tsx
|
425
446
|
import { TableCell as TableCell5, useTheme } from "@mui/material";
|
426
447
|
import { ConstrainedImage as ConstrainedImage3 } from "@xylabs/react-crypto";
|
427
448
|
import { FlexRow as FlexRow4 } from "@xylabs/react-flexbox";
|
428
|
-
import
|
429
|
-
var ConnectedWalletsWalletTableCell =
|
449
|
+
import { jsx as jsx10, jsxs as jsxs7 } from "react/jsx-runtime";
|
450
|
+
var ConnectedWalletsWalletTableCell = ({
|
451
|
+
icon,
|
452
|
+
walletName,
|
453
|
+
tableCellProps
|
454
|
+
}) => {
|
430
455
|
const theme = useTheme();
|
431
|
-
return /* @__PURE__ */
|
432
|
-
|
433
|
-
|
434
|
-
}
|
435
|
-
|
436
|
-
src: icon
|
437
|
-
}), walletName));
|
438
|
-
}, "ConnectedWalletsWalletTableCell");
|
456
|
+
return /* @__PURE__ */ jsx10(TableCell5, { ...tableCellProps, children: /* @__PURE__ */ jsxs7(FlexRow4, { gap: 2, justifyContent: "start", children: [
|
457
|
+
/* @__PURE__ */ jsx10(ConstrainedImage3, { constrainedValue: theme.spacing(4), src: icon }),
|
458
|
+
walletName
|
459
|
+
] }) });
|
460
|
+
};
|
439
461
|
|
440
462
|
// src/components/wallet/table/cells/Cells.tsx
|
441
463
|
var ConnectedWalletTableCells = [
|
@@ -447,145 +469,163 @@ var ConnectedWalletTableCells = [
|
|
447
469
|
];
|
448
470
|
|
449
471
|
// src/components/wallet/table/ConnectedWalletsTable.tsx
|
450
|
-
import {
|
451
|
-
|
472
|
+
import {
|
473
|
+
Table,
|
474
|
+
TableBody,
|
475
|
+
TableCell as TableCell6,
|
476
|
+
TableHead,
|
477
|
+
TableRow as TableRow2
|
478
|
+
} from "@mui/material";
|
479
|
+
import { useState as useState2 } from "react";
|
452
480
|
|
453
481
|
// src/components/wallet/table/ConnectedWalletsTableRow.tsx
|
454
482
|
import { TableRow } from "@mui/material";
|
455
483
|
import { useEthWallet } from "@xylabs/react-crypto";
|
456
|
-
import
|
457
|
-
|
458
|
-
|
459
|
-
|
460
|
-
|
461
|
-
|
484
|
+
import { useCallback, useMemo as useMemo4 } from "react";
|
485
|
+
import { jsx as jsx11 } from "react/jsx-runtime";
|
486
|
+
var WalletConnectionsTableRow = ({
|
487
|
+
ignoreConnectDialog,
|
488
|
+
onConnectClick,
|
489
|
+
onRevoke,
|
490
|
+
wallet,
|
491
|
+
...props
|
492
|
+
}) => {
|
493
|
+
const {
|
494
|
+
currentAccount: currentAccountFromWallet,
|
495
|
+
additionalAccounts,
|
496
|
+
chainName,
|
497
|
+
connectWallet,
|
498
|
+
providerInfo
|
499
|
+
} = useEthWallet(wallet);
|
500
|
+
const currentAccount = currentAccountFromWallet?.toString() ? [currentAccountFromWallet.toString()] : [];
|
462
501
|
const totalAccounts = (additionalAccounts?.length ?? 0) + (currentAccount?.length ?? 0);
|
463
502
|
const connected = !!currentAccount?.length;
|
464
|
-
const {
|
503
|
+
const {
|
504
|
+
icon,
|
505
|
+
name,
|
506
|
+
rdns
|
507
|
+
} = useMemo4(() => providerInfo ?? {
|
465
508
|
icon: void 0,
|
466
509
|
name: void 0,
|
467
510
|
rdns: void 0
|
468
|
-
}, [
|
469
|
-
|
470
|
-
|
471
|
-
|
472
|
-
|
473
|
-
|
474
|
-
|
475
|
-
|
476
|
-
|
477
|
-
icon,
|
478
|
-
name
|
479
|
-
]);
|
511
|
+
}, [providerInfo]);
|
512
|
+
const activeProvider = useMemo4(
|
513
|
+
() => ({
|
514
|
+
connectWallet,
|
515
|
+
icon,
|
516
|
+
providerName: name
|
517
|
+
}),
|
518
|
+
[connectWallet, icon, name]
|
519
|
+
);
|
480
520
|
const onRevokeLocal = useCallback(() => {
|
481
521
|
onRevoke?.(activeProvider);
|
482
|
-
}, [
|
483
|
-
activeProvider,
|
484
|
-
onRevoke
|
485
|
-
]);
|
522
|
+
}, [activeProvider, onRevoke]);
|
486
523
|
const onConnectLocal = useCallback(async () => {
|
487
524
|
if (ignoreConnectDialog) {
|
488
525
|
await connectWallet?.();
|
489
526
|
} else {
|
490
527
|
onConnectClick?.(activeProvider);
|
491
528
|
}
|
492
|
-
}, [
|
493
|
-
|
494
|
-
|
495
|
-
|
496
|
-
|
497
|
-
|
498
|
-
|
499
|
-
|
500
|
-
|
501
|
-
|
502
|
-
|
503
|
-
|
504
|
-
|
505
|
-
|
506
|
-
|
507
|
-
|
508
|
-
|
509
|
-
|
510
|
-
})));
|
511
|
-
}, "WalletConnectionsTableRow");
|
529
|
+
}, [activeProvider, connectWallet, ignoreConnectDialog, onConnectClick]);
|
530
|
+
return /* @__PURE__ */ jsx11(TableRow, { ...props, children: Object.values(ConnectedWalletTableCells).map((Cell, index) => /* @__PURE__ */ jsx11(
|
531
|
+
Cell,
|
532
|
+
{
|
533
|
+
additionalAccounts,
|
534
|
+
chainName,
|
535
|
+
connected,
|
536
|
+
currentAccount,
|
537
|
+
icon,
|
538
|
+
onConnect: onConnectLocal,
|
539
|
+
onRevoke: onRevokeLocal,
|
540
|
+
totalAccounts,
|
541
|
+
walletName: name,
|
542
|
+
walletRdns: rdns
|
543
|
+
},
|
544
|
+
index
|
545
|
+
)) });
|
546
|
+
};
|
512
547
|
|
513
548
|
// src/components/wallet/table/hooks/useActiveProviderDialogState.tsx
|
514
549
|
import { useState } from "react";
|
515
|
-
var useActiveProviderDialogState =
|
550
|
+
var useActiveProviderDialogState = (setActiveProvider) => {
|
516
551
|
const [show, setShow] = useState(false);
|
517
|
-
const onSetActiveProvider =
|
552
|
+
const onSetActiveProvider = (activeProvider) => {
|
518
553
|
setShow(true);
|
519
554
|
setActiveProvider(activeProvider);
|
520
|
-
}
|
521
|
-
const onClose =
|
555
|
+
};
|
556
|
+
const onClose = () => {
|
522
557
|
setShow(false);
|
523
558
|
setActiveProvider({});
|
524
|
-
}
|
525
|
-
return [
|
526
|
-
|
527
|
-
onSetActiveProvider,
|
528
|
-
onClose
|
529
|
-
];
|
530
|
-
}, "useActiveProviderDialogState");
|
559
|
+
};
|
560
|
+
return [show, onSetActiveProvider, onClose];
|
561
|
+
};
|
531
562
|
|
532
563
|
// src/components/wallet/table/ConnectedWalletsTable.tsx
|
533
|
-
|
564
|
+
import { Fragment, jsx as jsx12, jsxs as jsxs8 } from "react/jsx-runtime";
|
565
|
+
var ConnectedWalletsTable = ({
|
566
|
+
ignoreConnectDialog,
|
567
|
+
onIgnoreConnectDialog,
|
568
|
+
wallets,
|
569
|
+
...props
|
570
|
+
}) => {
|
534
571
|
const [activeProvider, setActiveProvider] = useState2();
|
535
572
|
const [showConnect, onSetActiveProviderConnect, onConnectClose] = useActiveProviderDialogState(setActiveProvider);
|
536
573
|
const [showRevoke, onSetActiveProviderRevoke, onRevokeClose] = useActiveProviderDialogState(setActiveProvider);
|
537
|
-
return /* @__PURE__ */
|
538
|
-
|
539
|
-
|
540
|
-
|
541
|
-
|
542
|
-
|
543
|
-
|
544
|
-
|
545
|
-
|
546
|
-
|
547
|
-
|
548
|
-
|
549
|
-
|
550
|
-
|
551
|
-
|
552
|
-
|
553
|
-
|
554
|
-
|
555
|
-
|
556
|
-
|
557
|
-
|
558
|
-
|
574
|
+
return /* @__PURE__ */ jsxs8(Fragment, { children: [
|
575
|
+
/* @__PURE__ */ jsxs8(Table, { ...props, children: [
|
576
|
+
/* @__PURE__ */ jsx12(TableHead, { children: /* @__PURE__ */ jsx12(TableRow2, { children: WalletsTableHeadCells.map(({
|
577
|
+
disablePadding,
|
578
|
+
id,
|
579
|
+
label,
|
580
|
+
align,
|
581
|
+
width
|
582
|
+
}) => /* @__PURE__ */ jsx12(TableCell6, { align, padding: disablePadding ? "none" : "normal", width: width ?? "auto", children: label }, id)) }) }),
|
583
|
+
/* @__PURE__ */ jsx12(TableBody, { children: (wallets ?? []).map((wallet) => /* @__PURE__ */ jsx12(
|
584
|
+
WalletConnectionsTableRow,
|
585
|
+
{
|
586
|
+
ignoreConnectDialog,
|
587
|
+
onConnectClick: onSetActiveProviderConnect,
|
588
|
+
onRevoke: onSetActiveProviderRevoke,
|
589
|
+
wallet
|
590
|
+
},
|
591
|
+
wallet.providerInfo?.rdns
|
592
|
+
)) })
|
593
|
+
] }),
|
594
|
+
/* @__PURE__ */ jsx12(RevokeWalletConnectionDialog, { open: showRevoke, onClose: onRevokeClose, activeProvider }),
|
595
|
+
/* @__PURE__ */ jsx12(
|
596
|
+
ConnectWalletDialog,
|
597
|
+
{
|
598
|
+
activeProvider,
|
599
|
+
onClose: onConnectClose,
|
600
|
+
open: showConnect,
|
601
|
+
onIgnoreConnectDialog
|
602
|
+
}
|
603
|
+
)
|
604
|
+
] });
|
605
|
+
};
|
559
606
|
|
560
607
|
// src/components/ConnectedAccountsFlexbox.tsx
|
561
|
-
|
608
|
+
import { jsx as jsx13, jsxs as jsxs9 } from "react/jsx-runtime";
|
609
|
+
var ConnectedAccountsFlexbox = ({
|
610
|
+
ref,
|
611
|
+
ignoreConnectDialog,
|
612
|
+
onIgnoreConnectDialog,
|
613
|
+
...props
|
614
|
+
}) => {
|
562
615
|
const theme = useTheme2();
|
563
616
|
const { totalConnectedAccounts, sortedWallets } = useDetectedWallets();
|
564
|
-
return /* @__PURE__ */
|
565
|
-
alignItems: "
|
566
|
-
|
567
|
-
|
568
|
-
|
569
|
-
|
570
|
-
|
571
|
-
|
572
|
-
|
573
|
-
|
574
|
-
|
575
|
-
|
576
|
-
}
|
577
|
-
}, "Detected Web3 Wallets"), totalConnectedAccounts ? /* @__PURE__ */ React13.createElement(Typography6, {
|
578
|
-
variant: "subtitle1",
|
579
|
-
color: theme.vars.palette.secondary.main,
|
580
|
-
sx: {
|
581
|
-
opacity: 0.5
|
582
|
-
}
|
583
|
-
}, "Total Connected Accounts:", " ", totalConnectedAccounts) : null), /* @__PURE__ */ React13.createElement(ConnectedWalletsTable, {
|
584
|
-
wallets: sortedWallets,
|
585
|
-
ignoreConnectDialog,
|
586
|
-
onIgnoreConnectDialog
|
587
|
-
}));
|
588
|
-
}, "ConnectedAccountsFlexbox");
|
617
|
+
return /* @__PURE__ */ jsxs9(FlexCol3, { alignItems: "stretch", justifyContent: "start", gap: 2, ref, ...props, children: [
|
618
|
+
/* @__PURE__ */ jsxs9(FlexCol3, { alignItems: "start", children: [
|
619
|
+
/* @__PURE__ */ jsx13(Typography6, { variant: "h2", sx: { mb: 0.5 }, children: "Detected Web3 Wallets" }),
|
620
|
+
totalConnectedAccounts ? /* @__PURE__ */ jsxs9(Typography6, { variant: "subtitle1", color: theme.vars.palette.secondary.main, sx: { opacity: 0.5 }, children: [
|
621
|
+
"Total Connected Accounts:",
|
622
|
+
" ",
|
623
|
+
totalConnectedAccounts
|
624
|
+
] }) : null
|
625
|
+
] }),
|
626
|
+
/* @__PURE__ */ jsx13(ConnectedWalletsTable, { wallets: sortedWallets, ignoreConnectDialog, onIgnoreConnectDialog })
|
627
|
+
] });
|
628
|
+
};
|
589
629
|
ConnectedAccountsFlexbox.displayName = "ConnectedAccountsFlexbox";
|
590
630
|
export {
|
591
631
|
CheckboxFormControl,
|