@xyo-network/xl1-react-client-sdk 1.28.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/LICENSE +165 -0
- package/README.md +30 -0
- package/dist/browser/client/components/connected/ConnectAccountsStack.d.ts +51 -0
- package/dist/browser/client/components/connected/ConnectAccountsStack.d.ts.map +1 -0
- package/dist/browser/client/components/connected/account/Connected.d.ts +5 -0
- package/dist/browser/client/components/connected/account/Connected.d.ts.map +1 -0
- package/dist/browser/client/components/connected/account/index.d.ts +2 -0
- package/dist/browser/client/components/connected/account/index.d.ts.map +1 -0
- package/dist/browser/client/components/connected/hooks/index.d.ts +2 -0
- package/dist/browser/client/components/connected/hooks/index.d.ts.map +1 -0
- package/dist/browser/client/components/connected/hooks/useConnectAccount.d.ts +17 -0
- package/dist/browser/client/components/connected/hooks/useConnectAccount.d.ts.map +1 -0
- package/dist/browser/client/components/connected/index.d.ts +3 -0
- package/dist/browser/client/components/connected/index.d.ts.map +1 -0
- package/dist/browser/client/components/index.d.ts +2 -0
- package/dist/browser/client/components/index.d.ts.map +1 -0
- package/dist/browser/client/context/GatewayContext.d.ts +28 -0
- package/dist/browser/client/context/GatewayContext.d.ts.map +1 -0
- package/dist/browser/client/context/GatewayProviderProps.d.ts +6 -0
- package/dist/browser/client/context/GatewayProviderProps.d.ts.map +1 -0
- package/dist/browser/client/context/GatewayProviderState.d.ts +33 -0
- package/dist/browser/client/context/GatewayProviderState.d.ts.map +1 -0
- package/dist/browser/client/context/in-page/InPageGatewaysContext.d.ts +16 -0
- package/dist/browser/client/context/in-page/InPageGatewaysContext.d.ts.map +1 -0
- package/dist/browser/client/context/in-page/InPageGatewaysState.d.ts +21 -0
- package/dist/browser/client/context/in-page/InPageGatewaysState.d.ts.map +1 -0
- package/dist/browser/client/context/in-page/Provider.d.ts +60 -0
- package/dist/browser/client/context/in-page/Provider.d.ts.map +1 -0
- package/dist/browser/client/context/in-page/index.d.ts +5 -0
- package/dist/browser/client/context/in-page/index.d.ts.map +1 -0
- package/dist/browser/client/context/in-page/lib/buildGateway.d.ts +3 -0
- package/dist/browser/client/context/in-page/lib/buildGateway.d.ts.map +1 -0
- package/dist/browser/client/context/in-page/lib/index.d.ts +2 -0
- package/dist/browser/client/context/in-page/lib/index.d.ts.map +1 -0
- package/dist/browser/client/context/in-page/useProvidedInPageGateways.d.ts +13 -0
- package/dist/browser/client/context/in-page/useProvidedInPageGateways.d.ts.map +1 -0
- package/dist/browser/client/context/index.d.ts +7 -0
- package/dist/browser/client/context/index.d.ts.map +1 -0
- package/dist/browser/client/context/providers/GatewayProvider.d.ts +47 -0
- package/dist/browser/client/context/providers/GatewayProvider.d.ts.map +1 -0
- package/dist/browser/client/context/providers/WalletGatewayProvider.d.ts +34 -0
- package/dist/browser/client/context/providers/WalletGatewayProvider.d.ts.map +1 -0
- package/dist/browser/client/context/providers/index.d.ts +3 -0
- package/dist/browser/client/context/providers/index.d.ts.map +1 -0
- package/dist/browser/client/context/providers/story/GatewayStatus.d.ts +9 -0
- package/dist/browser/client/context/providers/story/GatewayStatus.d.ts.map +1 -0
- package/dist/browser/client/context/useProvidedGateway.d.ts +16 -0
- package/dist/browser/client/context/useProvidedGateway.d.ts.map +1 -0
- package/dist/browser/client/hooks/client/helpers/findCaveat.d.ts +3 -0
- package/dist/browser/client/hooks/client/helpers/findCaveat.d.ts.map +1 -0
- package/dist/browser/client/hooks/client/helpers/index.d.ts +2 -0
- package/dist/browser/client/hooks/client/helpers/index.d.ts.map +1 -0
- package/dist/browser/client/hooks/client/index.d.ts +5 -0
- package/dist/browser/client/hooks/client/index.d.ts.map +1 -0
- package/dist/browser/client/hooks/client/permissions/index.d.ts +3 -0
- package/dist/browser/client/hooks/client/permissions/index.d.ts.map +1 -0
- package/dist/browser/client/hooks/client/permissions/usePermissions.d.ts +7 -0
- package/dist/browser/client/hooks/client/permissions/usePermissions.d.ts.map +1 -0
- package/dist/browser/client/hooks/client/permissions/usePermissionsAccounts.d.ts +2 -0
- package/dist/browser/client/hooks/client/permissions/usePermissionsAccounts.d.ts.map +1 -0
- package/dist/browser/client/hooks/client/story/GatewayFromWalletStatus.d.ts +7 -0
- package/dist/browser/client/hooks/client/story/GatewayFromWalletStatus.d.ts.map +1 -0
- package/dist/browser/client/hooks/client/story/mockWalletDecorator.d.ts +3 -0
- package/dist/browser/client/hooks/client/story/mockWalletDecorator.d.ts.map +1 -0
- package/dist/browser/client/hooks/client/useClientFromWallet.d.ts +12 -0
- package/dist/browser/client/hooks/client/useClientFromWallet.d.ts.map +1 -0
- package/dist/browser/client/hooks/client/useGatewayFromWallet.d.ts +20 -0
- package/dist/browser/client/hooks/client/useGatewayFromWallet.d.ts.map +1 -0
- package/dist/browser/client/hooks/helpers/getXyoClient.d.ts +6 -0
- package/dist/browser/client/hooks/helpers/getXyoClient.d.ts.map +1 -0
- package/dist/browser/client/hooks/helpers/index.d.ts +2 -0
- package/dist/browser/client/hooks/helpers/index.d.ts.map +1 -0
- package/dist/browser/client/hooks/index.d.ts +3 -0
- package/dist/browser/client/hooks/index.d.ts.map +1 -0
- package/dist/browser/client/index.d.ts +5 -0
- package/dist/browser/client/index.d.ts.map +1 -0
- package/dist/browser/client/index.mjs +546 -0
- package/dist/browser/client/index.mjs.map +1 -0
- package/dist/browser/client/story/GatewayStats.d.ts +7 -0
- package/dist/browser/client/story/GatewayStats.d.ts.map +1 -0
- package/dist/browser/client/story/GatewayStatus.d.ts +3 -0
- package/dist/browser/client/story/GatewayStatus.d.ts.map +1 -0
- package/dist/browser/client/types/ContextGatewayType.d.ts +3 -0
- package/dist/browser/client/types/ContextGatewayType.d.ts.map +1 -0
- package/dist/browser/client/types/GatewayFromWallet.d.ts +8 -0
- package/dist/browser/client/types/GatewayFromWallet.d.ts.map +1 -0
- package/dist/browser/client/types/index.d.ts +3 -0
- package/dist/browser/client/types/index.d.ts.map +1 -0
- package/dist/browser/index.d.ts +4 -0
- package/dist/browser/index.d.ts.map +1 -0
- package/dist/browser/index.mjs +722 -0
- package/dist/browser/index.mjs.map +1 -0
- package/dist/browser/model/index.d.ts +2 -0
- package/dist/browser/model/index.d.ts.map +1 -0
- package/dist/browser/model/index.mjs +13 -0
- package/dist/browser/model/index.mjs.map +1 -0
- package/dist/browser/model/types/XyoGlobal.d.ts +17 -0
- package/dist/browser/model/types/XyoGlobal.d.ts.map +1 -0
- package/dist/browser/model/types/index.d.ts +2 -0
- package/dist/browser/model/types/index.d.ts.map +1 -0
- package/dist/browser/shared/components/index.d.ts +3 -0
- package/dist/browser/shared/components/index.d.ts.map +1 -0
- package/dist/browser/shared/components/menu-item/ActiveMenuItem.d.ts +6 -0
- package/dist/browser/shared/components/menu-item/ActiveMenuItem.d.ts.map +1 -0
- package/dist/browser/shared/components/menu-item/index.d.ts +2 -0
- package/dist/browser/shared/components/menu-item/index.d.ts.map +1 -0
- package/dist/browser/shared/components/stack/DetailsStack.d.ts +10 -0
- package/dist/browser/shared/components/stack/DetailsStack.d.ts.map +1 -0
- package/dist/browser/shared/components/stack/LabelValueStack.d.ts +8 -0
- package/dist/browser/shared/components/stack/LabelValueStack.d.ts.map +1 -0
- package/dist/browser/shared/components/stack/index.d.ts +3 -0
- package/dist/browser/shared/components/stack/index.d.ts.map +1 -0
- package/dist/browser/shared/decorators/IframeWalletWarningDecorator.d.ts +10 -0
- package/dist/browser/shared/decorators/IframeWalletWarningDecorator.d.ts.map +1 -0
- package/dist/browser/shared/decorators/index.d.ts +2 -0
- package/dist/browser/shared/decorators/index.d.ts.map +1 -0
- package/dist/browser/shared/index.d.ts +3 -0
- package/dist/browser/shared/index.d.ts.map +1 -0
- package/dist/browser/shared/index.mjs +175 -0
- package/dist/browser/shared/index.mjs.map +1 -0
- package/package.json +234 -0
|
@@ -0,0 +1,546 @@
|
|
|
1
|
+
// src/client/components/connected/account/Connected.tsx
|
|
2
|
+
import {
|
|
3
|
+
Stack,
|
|
4
|
+
Tooltip,
|
|
5
|
+
Typography
|
|
6
|
+
} from "@mui/material";
|
|
7
|
+
import { EthAddressWrapper } from "@xylabs/sdk-js";
|
|
8
|
+
import { BlockiesAvatarAddress } from "@xyo-network/xl1-blockies";
|
|
9
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
10
|
+
var ConnectedAccount = ({ address }) => {
|
|
11
|
+
const shortenedAddress = `${EthAddressWrapper.fromString(address)?.toShortString(4)}`;
|
|
12
|
+
return /* @__PURE__ */ jsxs(Stack, { direction: "row", alignItems: "center", spacing: 1, children: [
|
|
13
|
+
/* @__PURE__ */ jsx(BlockiesAvatarAddress, { address, size: 21 }),
|
|
14
|
+
/* @__PURE__ */ jsx(Tooltip, { title: address, children: /* @__PURE__ */ jsx(Typography, { color: "textSecondary", variant: "caption", fontFamily: "monospace", children: shortenedAddress }) })
|
|
15
|
+
] });
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
// src/client/components/connected/ConnectAccountsStack.tsx
|
|
19
|
+
import {
|
|
20
|
+
Alert,
|
|
21
|
+
AlertTitle,
|
|
22
|
+
Button,
|
|
23
|
+
Stack as Stack2,
|
|
24
|
+
Typography as Typography2
|
|
25
|
+
} from "@mui/material";
|
|
26
|
+
import { ButtonEx } from "@xylabs/react-button";
|
|
27
|
+
import { ErrorRender } from "@xylabs/react-error";
|
|
28
|
+
import { isDefined as isDefined3, isUndefined as isUndefined3 } from "@xylabs/sdk-js";
|
|
29
|
+
import { useEffect as useEffect2 } from "react";
|
|
30
|
+
|
|
31
|
+
// src/client/components/connected/hooks/useConnectAccount.ts
|
|
32
|
+
import { asAddress } from "@xylabs/sdk-js";
|
|
33
|
+
import { assertEx } from "@xylabs/sdk-js";
|
|
34
|
+
import { MainNetwork } from "@xyo-network/xl1-sdk";
|
|
35
|
+
import { useCallback, useState as useState2 } from "react";
|
|
36
|
+
|
|
37
|
+
// src/client/hooks/client/helpers/findCaveat.ts
|
|
38
|
+
import { isDefined } from "@xylabs/sdk-js";
|
|
39
|
+
var findCaveat = async (permissions, targetCapability, targetCaveatType) => {
|
|
40
|
+
const existingPermissions = await permissions.getPermissions();
|
|
41
|
+
if (isDefined(existingPermissions) && existingPermissions.length > 0) {
|
|
42
|
+
const foundPermissions = existingPermissions.find((p) => p.parentCapability === targetCapability);
|
|
43
|
+
if (isDefined(foundPermissions)) {
|
|
44
|
+
return foundPermissions.caveats?.find((caveat) => caveat.type === targetCaveatType)?.value ?? [];
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
return existingPermissions;
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
// src/client/hooks/client/useClientFromWallet.ts
|
|
51
|
+
import { isUndefined as isUndefined2 } from "@xylabs/sdk-js";
|
|
52
|
+
import { useEffect, useState } from "react";
|
|
53
|
+
|
|
54
|
+
// src/client/hooks/helpers/getXyoClient.ts
|
|
55
|
+
import { isUndefined } from "@xylabs/sdk-js";
|
|
56
|
+
var CLIENT_LISTENER_TIMEOUT = 2e3;
|
|
57
|
+
var hasXyoClient = () => {
|
|
58
|
+
return "client" in globalThis.xyo;
|
|
59
|
+
};
|
|
60
|
+
var listenForClientInjection = (onClientReady, timeout, onTimeout) => {
|
|
61
|
+
let resolved = false;
|
|
62
|
+
const listener = () => {
|
|
63
|
+
onClientReady();
|
|
64
|
+
resolved = true;
|
|
65
|
+
};
|
|
66
|
+
globalThis.addEventListener("xyo:plugin-ready", listener);
|
|
67
|
+
setTimeout(() => {
|
|
68
|
+
if (!resolved) {
|
|
69
|
+
globalThis.removeEventListener("xyo:plugin-ready", listener);
|
|
70
|
+
onTimeout();
|
|
71
|
+
}
|
|
72
|
+
}, timeout);
|
|
73
|
+
};
|
|
74
|
+
async function getXyoClient(timeout = CLIENT_LISTENER_TIMEOUT) {
|
|
75
|
+
if (isUndefined(globalThis.xyo)) {
|
|
76
|
+
return null;
|
|
77
|
+
}
|
|
78
|
+
return hasXyoClient() ? globalThis.xyo.client : await new Promise((resolve) => {
|
|
79
|
+
listenForClientInjection(
|
|
80
|
+
() => {
|
|
81
|
+
resolve(globalThis.xyo.client);
|
|
82
|
+
},
|
|
83
|
+
timeout,
|
|
84
|
+
() => {
|
|
85
|
+
resolve(null);
|
|
86
|
+
}
|
|
87
|
+
);
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
// src/client/hooks/client/useClientFromWallet.ts
|
|
92
|
+
var initialState = {
|
|
93
|
+
client: void 0,
|
|
94
|
+
error: null,
|
|
95
|
+
isLoading: false,
|
|
96
|
+
timedout: false
|
|
97
|
+
};
|
|
98
|
+
var useClientFromWallet = (timeout) => {
|
|
99
|
+
const [state, setState] = useState(initialState);
|
|
100
|
+
useEffect(() => {
|
|
101
|
+
let cancelled = false;
|
|
102
|
+
const initialize = async () => {
|
|
103
|
+
setState((prev) => {
|
|
104
|
+
if (prev.isLoading) return prev;
|
|
105
|
+
return {
|
|
106
|
+
...prev,
|
|
107
|
+
isLoading: true,
|
|
108
|
+
error: null
|
|
109
|
+
};
|
|
110
|
+
});
|
|
111
|
+
try {
|
|
112
|
+
const client = await getXyoClient(timeout);
|
|
113
|
+
if (cancelled) return;
|
|
114
|
+
if (client === null) {
|
|
115
|
+
setState({
|
|
116
|
+
client: null,
|
|
117
|
+
timedout: true,
|
|
118
|
+
isLoading: false,
|
|
119
|
+
error: null
|
|
120
|
+
});
|
|
121
|
+
} else {
|
|
122
|
+
setState({
|
|
123
|
+
client,
|
|
124
|
+
isLoading: false,
|
|
125
|
+
error: null,
|
|
126
|
+
timedout: false
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
} catch (error) {
|
|
130
|
+
if (cancelled) return;
|
|
131
|
+
setState({
|
|
132
|
+
client: void 0,
|
|
133
|
+
isLoading: false,
|
|
134
|
+
error,
|
|
135
|
+
timedout: false
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
};
|
|
139
|
+
void initialize();
|
|
140
|
+
const onPluginReady = () => {
|
|
141
|
+
if (cancelled) return;
|
|
142
|
+
const client = isUndefined2(globalThis.xyo) ? null : globalThis.xyo?.client ?? null;
|
|
143
|
+
setState({
|
|
144
|
+
client,
|
|
145
|
+
isLoading: false,
|
|
146
|
+
timedout: false,
|
|
147
|
+
error: null
|
|
148
|
+
});
|
|
149
|
+
};
|
|
150
|
+
globalThis.addEventListener("xyo:plugin-ready", onPluginReady);
|
|
151
|
+
return () => {
|
|
152
|
+
cancelled = true;
|
|
153
|
+
globalThis.removeEventListener("xyo:plugin-ready", onPluginReady);
|
|
154
|
+
};
|
|
155
|
+
}, [timeout]);
|
|
156
|
+
return state;
|
|
157
|
+
};
|
|
158
|
+
var useClient = useClientFromWallet;
|
|
159
|
+
|
|
160
|
+
// src/client/hooks/client/permissions/usePermissions.ts
|
|
161
|
+
var usePermissions = () => {
|
|
162
|
+
const {
|
|
163
|
+
client,
|
|
164
|
+
isLoading,
|
|
165
|
+
error,
|
|
166
|
+
timedout
|
|
167
|
+
} = useClientFromWallet();
|
|
168
|
+
const permissions = client?.permissions;
|
|
169
|
+
return {
|
|
170
|
+
permissions,
|
|
171
|
+
isLoading,
|
|
172
|
+
error,
|
|
173
|
+
timedout
|
|
174
|
+
};
|
|
175
|
+
};
|
|
176
|
+
|
|
177
|
+
// src/client/hooks/client/permissions/usePermissionsAccounts.ts
|
|
178
|
+
import { usePromise } from "@xylabs/react-promise";
|
|
179
|
+
import {
|
|
180
|
+
isArray,
|
|
181
|
+
isDefined as isDefined2,
|
|
182
|
+
isDefinedNotNull,
|
|
183
|
+
isString
|
|
184
|
+
} from "@xylabs/sdk-js";
|
|
185
|
+
var validateRestrictedAccounts = (restrictedAccounts) => {
|
|
186
|
+
if (isDefined2(restrictedAccounts)) {
|
|
187
|
+
if (isArray(restrictedAccounts) && restrictedAccounts.every(isString)) {
|
|
188
|
+
return restrictedAccounts;
|
|
189
|
+
}
|
|
190
|
+
throw new Error(
|
|
191
|
+
`Unrecognized format for restrictReturnedAccounts caveat found on permissions.
|
|
192
|
+
|
|
193
|
+
Should be an array of strings: ${JSON.stringify(restrictedAccounts)}`
|
|
194
|
+
);
|
|
195
|
+
}
|
|
196
|
+
return [];
|
|
197
|
+
};
|
|
198
|
+
var useAccountPermissions = () => {
|
|
199
|
+
const { permissions, error } = usePermissions();
|
|
200
|
+
return usePromise(async () => {
|
|
201
|
+
if (isDefinedNotNull(error)) throw error;
|
|
202
|
+
if (isDefined2(permissions)) {
|
|
203
|
+
const restrictedAccounts = await findCaveat(
|
|
204
|
+
permissions,
|
|
205
|
+
// TODO - extract to constant in protocol package
|
|
206
|
+
"xyoWallet_getAccounts",
|
|
207
|
+
"restrictReturnedAccounts"
|
|
208
|
+
);
|
|
209
|
+
return validateRestrictedAccounts(restrictedAccounts);
|
|
210
|
+
}
|
|
211
|
+
}, [permissions]);
|
|
212
|
+
};
|
|
213
|
+
|
|
214
|
+
// src/client/hooks/client/useGatewayFromWallet.ts
|
|
215
|
+
import { isNull } from "@xylabs/sdk-js";
|
|
216
|
+
var useGatewayFromWallet = (gatewayName, timeout) => {
|
|
217
|
+
const {
|
|
218
|
+
client,
|
|
219
|
+
isLoading,
|
|
220
|
+
error,
|
|
221
|
+
timedout
|
|
222
|
+
} = useClientFromWallet(timeout);
|
|
223
|
+
const resolveGateway = () => {
|
|
224
|
+
if (isNull(client)) return null;
|
|
225
|
+
return client?.gateways?.[gatewayName];
|
|
226
|
+
};
|
|
227
|
+
return {
|
|
228
|
+
// no gatewayName requested = undefined (opt-out, not "absent")
|
|
229
|
+
gateway: gatewayName ? resolveGateway() : void 0,
|
|
230
|
+
isLoading,
|
|
231
|
+
error,
|
|
232
|
+
timedout
|
|
233
|
+
};
|
|
234
|
+
};
|
|
235
|
+
var useGateway = useGatewayFromWallet;
|
|
236
|
+
|
|
237
|
+
// src/client/components/connected/hooks/useConnectAccount.ts
|
|
238
|
+
var useConnectAccount = (gatewayName = MainNetwork.id, timeout) => {
|
|
239
|
+
const [connectError, setConnectError] = useState2();
|
|
240
|
+
const {
|
|
241
|
+
gateway,
|
|
242
|
+
error,
|
|
243
|
+
timedout
|
|
244
|
+
} = useGatewayFromWallet(gatewayName, timeout);
|
|
245
|
+
const [accountPermissions, accountPermissionsError] = useAccountPermissions();
|
|
246
|
+
const [address, setAddress] = useState2();
|
|
247
|
+
const connectSigner = useCallback(async () => {
|
|
248
|
+
try {
|
|
249
|
+
setConnectError(void 0);
|
|
250
|
+
const assertedGateway = assertEx(gateway, () => `Gateway ${gatewayName} is not available`);
|
|
251
|
+
const signer = assertedGateway.signer;
|
|
252
|
+
const address2 = await signer.address();
|
|
253
|
+
setAddress(address2);
|
|
254
|
+
return address2;
|
|
255
|
+
} catch (e) {
|
|
256
|
+
setConnectError(e);
|
|
257
|
+
}
|
|
258
|
+
}, [gateway, gatewayName]);
|
|
259
|
+
return {
|
|
260
|
+
address: asAddress(accountPermissions?.[0] ?? address),
|
|
261
|
+
connectSigner,
|
|
262
|
+
error: error ?? accountPermissionsError ?? connectError,
|
|
263
|
+
gateway,
|
|
264
|
+
timedout
|
|
265
|
+
};
|
|
266
|
+
};
|
|
267
|
+
|
|
268
|
+
// src/client/components/connected/ConnectAccountsStack.tsx
|
|
269
|
+
import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
270
|
+
var DefaultConnectComponent = (props) => /* @__PURE__ */ jsx2(ButtonEx, { variant: "contained", size: "small", ...props });
|
|
271
|
+
var DefaultNoWalletInstalledComponent = () => /* @__PURE__ */ jsxs2(Alert, { severity: "warning", children: [
|
|
272
|
+
/* @__PURE__ */ jsx2(AlertTitle, { children: "XL1 Wallet Not Found" }),
|
|
273
|
+
/* @__PURE__ */ jsx2(Typography2, { gutterBottom: true, children: "Please ensure that your XL1 Wallet is installed to connect your account." }),
|
|
274
|
+
/* @__PURE__ */ jsx2(
|
|
275
|
+
Button,
|
|
276
|
+
{
|
|
277
|
+
sx: { display: "flex", justifySelf: "end" },
|
|
278
|
+
size: "small",
|
|
279
|
+
variant: "outlined",
|
|
280
|
+
href: "https://chromewebstore.google.com/detail/xl1-wallet/fblbagcjeigmhakkfgjpdlcapcgmcfbm",
|
|
281
|
+
target: "_blank",
|
|
282
|
+
rel: "noopener",
|
|
283
|
+
children: "Get XL1 Wallet"
|
|
284
|
+
}
|
|
285
|
+
)
|
|
286
|
+
] });
|
|
287
|
+
var ConnectAccountsStack = ({
|
|
288
|
+
AccountComponent = ConnectedAccount,
|
|
289
|
+
ConnectComponent = DefaultConnectComponent,
|
|
290
|
+
NoWalletInstalledComponent = DefaultNoWalletInstalledComponent,
|
|
291
|
+
onAccountConnected,
|
|
292
|
+
onCancel,
|
|
293
|
+
timeout,
|
|
294
|
+
...props
|
|
295
|
+
}) => {
|
|
296
|
+
const {
|
|
297
|
+
address,
|
|
298
|
+
connectSigner,
|
|
299
|
+
error,
|
|
300
|
+
timedout
|
|
301
|
+
} = useConnectAccount(void 0, timeout);
|
|
302
|
+
useEffect2(() => {
|
|
303
|
+
if (isDefined3(error) && isDefined3(onCancel)) {
|
|
304
|
+
onCancel();
|
|
305
|
+
}
|
|
306
|
+
}, [error, onCancel]);
|
|
307
|
+
useEffect2(() => {
|
|
308
|
+
if (isDefined3(address) && isDefined3(onAccountConnected)) {
|
|
309
|
+
onAccountConnected(address);
|
|
310
|
+
}
|
|
311
|
+
}, [address, onAccountConnected]);
|
|
312
|
+
return /* @__PURE__ */ jsxs2(Stack2, { direction: "row", alignItems: "start", spacing: 2, ...props, children: [
|
|
313
|
+
isDefined3(address) ? /* @__PURE__ */ jsx2(AccountComponent, { address }) : null,
|
|
314
|
+
isUndefined3(address) && !timedout ? /* @__PURE__ */ jsx2(ConnectComponent, { onClick: () => void connectSigner(), children: "Connect" }) : null,
|
|
315
|
+
isUndefined3(address) && timedout ? /* @__PURE__ */ jsx2(NoWalletInstalledComponent, {}) : null,
|
|
316
|
+
/* @__PURE__ */ jsx2(ErrorRender, { error, scope: "ConnectSigner:error" })
|
|
317
|
+
] });
|
|
318
|
+
};
|
|
319
|
+
|
|
320
|
+
// src/client/context/GatewayContext.ts
|
|
321
|
+
import { createContextEx } from "@xylabs/react-shared";
|
|
322
|
+
var GatewayContext = createContextEx();
|
|
323
|
+
|
|
324
|
+
// src/client/context/in-page/InPageGatewaysContext.ts
|
|
325
|
+
import { createContextEx as createContextEx2 } from "@xylabs/react-shared";
|
|
326
|
+
var InPageGatewaysContext = createContextEx2();
|
|
327
|
+
|
|
328
|
+
// src/client/context/in-page/Provider.tsx
|
|
329
|
+
import { DefaultNetworks as DefaultNetworks2 } from "@xyo-network/xl1-sdk";
|
|
330
|
+
import {
|
|
331
|
+
startTransition,
|
|
332
|
+
useCallback as useCallback2,
|
|
333
|
+
useEffect as useEffect3,
|
|
334
|
+
useMemo,
|
|
335
|
+
useState as useState3
|
|
336
|
+
} from "react";
|
|
337
|
+
|
|
338
|
+
// src/client/context/in-page/lib/buildGateway.ts
|
|
339
|
+
import { assertEx as assertEx2, isDefined as isDefined4 } from "@xylabs/sdk-js";
|
|
340
|
+
import {
|
|
341
|
+
basicRemoteRunnerLocator,
|
|
342
|
+
basicRemoteViewerLocator,
|
|
343
|
+
DefaultNetworks,
|
|
344
|
+
NetworkDataLakeUrls,
|
|
345
|
+
XyoGatewayMoniker
|
|
346
|
+
} from "@xyo-network/xl1-sdk";
|
|
347
|
+
var buildGateway = async (gatewayName, signerTransport) => {
|
|
348
|
+
const network = DefaultNetworks.find((network2) => network2.id === gatewayName);
|
|
349
|
+
const resolvedNetwork = assertEx2(network, () => `No network found for id ${gatewayName}`);
|
|
350
|
+
const remoteConfig = {
|
|
351
|
+
rpc: {
|
|
352
|
+
protocol: "http",
|
|
353
|
+
url: `${resolvedNetwork.url}/rpc`
|
|
354
|
+
}
|
|
355
|
+
};
|
|
356
|
+
const dataLakeEndpoint = NetworkDataLakeUrls[gatewayName];
|
|
357
|
+
const locator = isDefined4(signerTransport) ? await basicRemoteRunnerLocator(gatewayName, remoteConfig, signerTransport, dataLakeEndpoint) : await basicRemoteViewerLocator(gatewayName, remoteConfig, dataLakeEndpoint);
|
|
358
|
+
return await locator.getInstance(XyoGatewayMoniker);
|
|
359
|
+
};
|
|
360
|
+
|
|
361
|
+
// src/client/context/in-page/Provider.tsx
|
|
362
|
+
import { jsx as jsx3 } from "react/jsx-runtime";
|
|
363
|
+
var InPageGatewaysProvider = ({ signerTransport, children }) => {
|
|
364
|
+
const [gateways, setGateways] = useState3({});
|
|
365
|
+
const [errors, setErrors] = useState3({});
|
|
366
|
+
const [previousSignerTransport, setPreviousSignerTransport] = useState3(signerTransport);
|
|
367
|
+
const clearAll = useCallback2(() => {
|
|
368
|
+
setGateways({});
|
|
369
|
+
setErrors({});
|
|
370
|
+
}, []);
|
|
371
|
+
if (previousSignerTransport !== signerTransport) {
|
|
372
|
+
clearAll();
|
|
373
|
+
setPreviousSignerTransport(signerTransport);
|
|
374
|
+
}
|
|
375
|
+
useEffect3(() => {
|
|
376
|
+
let cancelled = false;
|
|
377
|
+
const buildAll = async () => {
|
|
378
|
+
const results = await Promise.allSettled(
|
|
379
|
+
DefaultNetworks2.map(async (network) => {
|
|
380
|
+
const gateway = await buildGateway(network.id, signerTransport);
|
|
381
|
+
return { id: network.id, gateway };
|
|
382
|
+
})
|
|
383
|
+
);
|
|
384
|
+
if (cancelled) return;
|
|
385
|
+
const nextGateways = {};
|
|
386
|
+
const nextErrors = {};
|
|
387
|
+
for (const [index, result] of results.entries()) {
|
|
388
|
+
const networkId = DefaultNetworks2[index].id;
|
|
389
|
+
if (result.status === "fulfilled") {
|
|
390
|
+
nextGateways[networkId] = result.value.gateway;
|
|
391
|
+
} else {
|
|
392
|
+
nextErrors[networkId] = result.reason instanceof Error ? result.reason : new Error(String(result.reason));
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
startTransition(() => {
|
|
396
|
+
setGateways(nextGateways);
|
|
397
|
+
setErrors(nextErrors);
|
|
398
|
+
});
|
|
399
|
+
};
|
|
400
|
+
void buildAll();
|
|
401
|
+
return () => {
|
|
402
|
+
cancelled = true;
|
|
403
|
+
};
|
|
404
|
+
}, [signerTransport]);
|
|
405
|
+
const value = useMemo(() => {
|
|
406
|
+
const value2 = {
|
|
407
|
+
clearAll,
|
|
408
|
+
errors,
|
|
409
|
+
gateways,
|
|
410
|
+
provided: true
|
|
411
|
+
};
|
|
412
|
+
return value2;
|
|
413
|
+
}, [clearAll, errors, gateways]);
|
|
414
|
+
return /* @__PURE__ */ jsx3(InPageGatewaysContext, { value, children });
|
|
415
|
+
};
|
|
416
|
+
|
|
417
|
+
// src/client/context/in-page/useProvidedInPageGateways.ts
|
|
418
|
+
import { useContextEx } from "@xylabs/react-shared";
|
|
419
|
+
var useProvidedInPageGateways = (required = true) => useContextEx(InPageGatewaysContext, "InPageGateways", required);
|
|
420
|
+
|
|
421
|
+
// src/client/context/providers/GatewayProvider.tsx
|
|
422
|
+
import { ErrorRender as ErrorRender2 } from "@xylabs/react-error";
|
|
423
|
+
import { isDefinedNotNull as isDefinedNotNull2, isNull as isNull2 } from "@xylabs/sdk-js";
|
|
424
|
+
import { useMemo as useMemo2 } from "react";
|
|
425
|
+
import { jsx as jsx4, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
426
|
+
var GatewayProvider = ({ gatewayName, children }) => {
|
|
427
|
+
const {
|
|
428
|
+
gateway: gatewayFromWallet,
|
|
429
|
+
error: gatewayFromWalletError
|
|
430
|
+
} = useGatewayFromWallet(gatewayName);
|
|
431
|
+
const {
|
|
432
|
+
gateways: allGateways,
|
|
433
|
+
errors: allGatewayErrors,
|
|
434
|
+
clearAll
|
|
435
|
+
} = useProvidedInPageGateways(true);
|
|
436
|
+
const gatewayFromConfig = gatewayName ? allGateways[gatewayName] : void 0;
|
|
437
|
+
const gatewayFromConfigError = gatewayName ? allGatewayErrors[gatewayName] : void 0;
|
|
438
|
+
const { defaultGateway, gateways } = useMemo2(() => {
|
|
439
|
+
if (isNull2(gatewayFromWallet)) {
|
|
440
|
+
return {
|
|
441
|
+
defaultGateway: gatewayFromConfig,
|
|
442
|
+
gateways: {
|
|
443
|
+
inPageGateway: gatewayFromConfig,
|
|
444
|
+
walletGateway: null
|
|
445
|
+
}
|
|
446
|
+
};
|
|
447
|
+
} else if (isDefinedNotNull2(gatewayFromWallet)) {
|
|
448
|
+
return {
|
|
449
|
+
defaultGateway: gatewayFromWallet,
|
|
450
|
+
gateways: {
|
|
451
|
+
inPageGateway: gatewayFromConfig,
|
|
452
|
+
walletGateway: gatewayFromWallet
|
|
453
|
+
}
|
|
454
|
+
};
|
|
455
|
+
}
|
|
456
|
+
return {
|
|
457
|
+
defaultGateway: void 0,
|
|
458
|
+
gateways: {
|
|
459
|
+
inPageGateway: void 0,
|
|
460
|
+
walletGateway: void 0
|
|
461
|
+
}
|
|
462
|
+
};
|
|
463
|
+
}, [gatewayFromConfig, gatewayFromWallet]);
|
|
464
|
+
const value = useMemo2(() => {
|
|
465
|
+
const value2 = {
|
|
466
|
+
defaultGateway,
|
|
467
|
+
error: gatewayFromWalletError ?? gatewayFromConfigError,
|
|
468
|
+
gateways,
|
|
469
|
+
provided: true,
|
|
470
|
+
resetGatewaysFromConfig: clearAll
|
|
471
|
+
};
|
|
472
|
+
return value2;
|
|
473
|
+
}, [
|
|
474
|
+
defaultGateway,
|
|
475
|
+
gatewayFromWalletError,
|
|
476
|
+
gatewayFromConfigError,
|
|
477
|
+
gateways,
|
|
478
|
+
clearAll
|
|
479
|
+
]);
|
|
480
|
+
return /* @__PURE__ */ jsxs3(GatewayContext, { value, children: [
|
|
481
|
+
/* @__PURE__ */ jsx4(ErrorRender2, { error: gatewayFromConfigError }),
|
|
482
|
+
children
|
|
483
|
+
] });
|
|
484
|
+
};
|
|
485
|
+
|
|
486
|
+
// src/client/context/providers/WalletGatewayProvider.tsx
|
|
487
|
+
import { ErrorRender as ErrorRender3 } from "@xylabs/react-error";
|
|
488
|
+
import { useMemo as useMemo3 } from "react";
|
|
489
|
+
import { jsx as jsx5, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
490
|
+
var WalletGatewayProvider = ({ gatewayName, children }) => {
|
|
491
|
+
const {
|
|
492
|
+
gateway: gatewayFromWallet,
|
|
493
|
+
error: gatewayFromWalletError
|
|
494
|
+
} = useGatewayFromWallet(gatewayName);
|
|
495
|
+
const { defaultGateway, gateways } = useMemo3(() => {
|
|
496
|
+
return {
|
|
497
|
+
defaultGateway: gatewayFromWallet,
|
|
498
|
+
gateways: {
|
|
499
|
+
inPageGateway: null,
|
|
500
|
+
walletGateway: gatewayFromWallet
|
|
501
|
+
}
|
|
502
|
+
};
|
|
503
|
+
}, [gatewayFromWallet]);
|
|
504
|
+
const value = useMemo3(() => {
|
|
505
|
+
const value2 = {
|
|
506
|
+
defaultGateway,
|
|
507
|
+
error: gatewayFromWalletError,
|
|
508
|
+
gateways,
|
|
509
|
+
provided: true
|
|
510
|
+
};
|
|
511
|
+
return value2;
|
|
512
|
+
}, [
|
|
513
|
+
defaultGateway,
|
|
514
|
+
gatewayFromWalletError,
|
|
515
|
+
gateways
|
|
516
|
+
]);
|
|
517
|
+
return /* @__PURE__ */ jsxs4(GatewayContext, { value, children: [
|
|
518
|
+
/* @__PURE__ */ jsx5(ErrorRender3, { error: gatewayFromWalletError }),
|
|
519
|
+
children
|
|
520
|
+
] });
|
|
521
|
+
};
|
|
522
|
+
|
|
523
|
+
// src/client/context/useProvidedGateway.ts
|
|
524
|
+
import { useContextEx as useContextEx2 } from "@xylabs/react-shared";
|
|
525
|
+
var useProvidedGateway = (required = true) => useContextEx2(GatewayContext, "Gateway", required);
|
|
526
|
+
export {
|
|
527
|
+
ConnectAccountsStack,
|
|
528
|
+
ConnectedAccount,
|
|
529
|
+
GatewayContext,
|
|
530
|
+
GatewayProvider,
|
|
531
|
+
InPageGatewaysContext,
|
|
532
|
+
InPageGatewaysProvider,
|
|
533
|
+
WalletGatewayProvider,
|
|
534
|
+
findCaveat,
|
|
535
|
+
getXyoClient,
|
|
536
|
+
listenForClientInjection,
|
|
537
|
+
useAccountPermissions,
|
|
538
|
+
useClient,
|
|
539
|
+
useClientFromWallet,
|
|
540
|
+
useGateway,
|
|
541
|
+
useGatewayFromWallet,
|
|
542
|
+
usePermissions,
|
|
543
|
+
useProvidedGateway,
|
|
544
|
+
useProvidedInPageGateways
|
|
545
|
+
};
|
|
546
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/client/components/connected/account/Connected.tsx","../../../src/client/components/connected/ConnectAccountsStack.tsx","../../../src/client/components/connected/hooks/useConnectAccount.ts","../../../src/client/hooks/client/helpers/findCaveat.ts","../../../src/client/hooks/client/useClientFromWallet.ts","../../../src/client/hooks/helpers/getXyoClient.ts","../../../src/client/hooks/client/permissions/usePermissions.ts","../../../src/client/hooks/client/permissions/usePermissionsAccounts.ts","../../../src/client/hooks/client/useGatewayFromWallet.ts","../../../src/client/context/GatewayContext.ts","../../../src/client/context/in-page/InPageGatewaysContext.ts","../../../src/client/context/in-page/Provider.tsx","../../../src/client/context/in-page/lib/buildGateway.ts","../../../src/client/context/in-page/useProvidedInPageGateways.ts","../../../src/client/context/providers/GatewayProvider.tsx","../../../src/client/context/providers/WalletGatewayProvider.tsx","../../../src/client/context/useProvidedGateway.ts"],"sourcesContent":["import {\n Stack, Tooltip, Typography,\n} from '@mui/material'\nimport { EthAddressWrapper } from '@xylabs/sdk-js'\nimport { BlockiesAvatarAddress } from '@xyo-network/xl1-blockies'\nimport React from 'react'\n\nexport const ConnectedAccount: React.FC<{ address: string }> = ({ address }) => {\n const shortenedAddress = `${EthAddressWrapper.fromString(address)?.toShortString(4)}`\n\n return (\n <Stack direction=\"row\" alignItems=\"center\" spacing={1}>\n <BlockiesAvatarAddress address={address} size={21} />\n <Tooltip title={address}>\n <Typography color=\"textSecondary\" variant=\"caption\" fontFamily=\"monospace\">{shortenedAddress}</Typography>\n </Tooltip>\n </Stack>\n )\n}\n","import type { StackProps } from '@mui/material'\nimport {\n Alert, AlertTitle, Button, Stack,\n Typography,\n} from '@mui/material'\nimport type { ButtonExProps } from '@xylabs/react-button'\nimport { ButtonEx } from '@xylabs/react-button'\nimport { ErrorRender } from '@xylabs/react-error'\nimport type { Address } from '@xylabs/sdk-js'\nimport { isDefined, isUndefined } from '@xylabs/sdk-js'\nimport type { ComponentType, MouseEventHandler } from 'react'\nimport React, { useEffect } from 'react'\n\nimport { ConnectedAccount } from './account/index.ts'\nimport { useConnectAccount } from './hooks/index.ts'\n\nconst DefaultConnectComponent: React.FC<ButtonExProps> = props => (\n <ButtonEx variant=\"contained\" size=\"small\" {...props} />\n)\n\nconst DefaultNoWalletInstalledComponent: React.FC = () => (\n <Alert severity=\"warning\">\n <AlertTitle>XL1 Wallet Not Found</AlertTitle>\n <Typography gutterBottom>\n Please ensure that your XL1 Wallet is installed to connect your account.\n </Typography>\n <Button\n sx={{ display: 'flex', justifySelf: 'end' }}\n size=\"small\"\n variant=\"outlined\"\n href=\"https://chromewebstore.google.com/detail/xl1-wallet/fblbagcjeigmhakkfgjpdlcapcgmcfbm\"\n target=\"_blank\"\n rel=\"noopener\"\n >\n Get XL1 Wallet\n </Button>\n </Alert>\n)\n\nexport interface ConnectClientAccountsStackProps extends StackProps {\n AccountComponent?: ComponentType<{ account?: string }>\n ConnectComponent?: ComponentType<{ onClick?: MouseEventHandler<HTMLElement> }>\n NoWalletInstalledComponent?: ComponentType\n onAccountConnected?: (account: Address) => void\n onCancel?: () => void\n timeout?: number\n}\n\n/**\n * Renders a horizontal stack that surfaces the current state of the user's\n * connection to an XL1 wallet (e.g. the XL1 Chrome extension) and lets them\n * kick off a connection.\n *\n * Connection state is derived from `useConnectAccount`, which wraps\n * `useGatewayFromWallet` (wallet/gateway discovery with a configurable\n * `timeout`) and `useAccountPermissions` (already-authorized addresses).\n * The hook returns: `address` (resolved once the wallet exposes one),\n * `connectSigner` (prompts the wallet for an address), `timedout` (the\n * gateway never appeared within `timeout`), and `error` (the first of\n * gateway, permissions, or signer-connect failures).\n *\n * The component renders exactly one of the following wallet states, plus\n * an always-present error slot:\n *\n * - **Connected** — `address` is defined: renders `AccountComponent` for\n * that address. Also fires `onAccountConnected(address)` once via effect.\n * - **Disconnected, wallet available** — no `address` and not `timedout`:\n * renders `ConnectComponent` as a \"Connect\" button that invokes\n * `connectSigner()`. This covers both \"wallet installed but no account\n * authorized yet\" and \"gateway still resolving\".\n * - **Wallet missing / unreachable** — no `address` and `timedout` is true:\n * renders `NoWalletInstalledComponent` (defaults to an Alert linking to\n * the XL1 Wallet Chrome Web Store listing).\n * - **Error** — any error from the hook is rendered via `ErrorRender`\n * alongside the state above, and `onCancel()` is fired once via effect\n * so the host UI can close/abort its connect flow.\n *\n * All three slot components (`AccountComponent`, `ConnectComponent`,\n * `NoWalletInstalledComponent`) are injectable so consumers can restyle\n * any state without forking this component.\n */\nexport const ConnectAccountsStack: React.FC<ConnectClientAccountsStackProps> = ({\n AccountComponent = ConnectedAccount,\n ConnectComponent = DefaultConnectComponent,\n NoWalletInstalledComponent = DefaultNoWalletInstalledComponent,\n onAccountConnected,\n onCancel,\n timeout,\n ...props\n}) => {\n const {\n address, connectSigner, error, timedout,\n } = useConnectAccount(undefined, timeout)\n\n useEffect(() => {\n if (isDefined(error) && isDefined(onCancel)) {\n onCancel()\n }\n }, [error, onCancel])\n\n useEffect(() => {\n if (isDefined(address) && isDefined(onAccountConnected)) {\n onAccountConnected(address)\n }\n }, [address, onAccountConnected])\n\n return (\n <Stack direction=\"row\" alignItems=\"start\" spacing={2} {...props}>\n {isDefined(address)\n ? <AccountComponent address={address} />\n : null}\n {isUndefined(address) && !timedout\n ? (\n <ConnectComponent onClick={() => void connectSigner()}>Connect</ConnectComponent>\n )\n : null}\n {isUndefined(address) && timedout\n ? (\n <NoWalletInstalledComponent />\n )\n : null}\n <ErrorRender error={error} scope=\"ConnectSigner:error\" />\n </Stack>\n )\n}\n","import { type Address, asAddress } from '@xylabs/sdk-js'\nimport { assertEx } from '@xylabs/sdk-js'\nimport type { GatewayName } from '@xyo-network/xl1-sdk'\nimport { MainNetwork } from '@xyo-network/xl1-sdk'\nimport { useCallback, useState } from 'react'\n\nimport { useAccountPermissions, useGatewayFromWallet } from '../../../hooks/index.ts'\n\nexport const useConnectAccount = (gatewayName: GatewayName = MainNetwork.id, timeout?: number) => {\n const [connectError, setConnectError] = useState<Error>()\n\n const {\n gateway, error, timedout,\n } = useGatewayFromWallet(gatewayName, timeout)\n\n const [accountPermissions, accountPermissionsError] = useAccountPermissions()\n\n const [address, setAddress] = useState<Address>()\n\n const connectSigner = useCallback(async () => {\n try {\n setConnectError(undefined)\n const assertedGateway = assertEx(gateway, () => `Gateway ${gatewayName} is not available`)\n const signer = assertedGateway.signer\n const address = await signer.address()\n setAddress(address)\n return address\n } catch (e) {\n setConnectError(e as Error)\n }\n }, [gateway, gatewayName])\n\n return {\n address: asAddress(accountPermissions?.[0] ?? address), connectSigner, error: error ?? accountPermissionsError ?? connectError, gateway, timedout,\n }\n}\n","import { isDefined } from '@xylabs/sdk-js'\nimport type {\n CaveatTypes, ParentCapability, XyoPermissions,\n} from '@xyo-network/xl1-sdk'\n\nexport const findCaveat = async (\n permissions: XyoPermissions,\n targetCapability: ParentCapability,\n targetCaveatType: CaveatTypes,\n) => {\n const existingPermissions = await permissions.getPermissions()\n if (isDefined(existingPermissions) && existingPermissions.length > 0) {\n const foundPermissions = existingPermissions\n .find(p => p.parentCapability === targetCapability)\n if (isDefined(foundPermissions)) {\n return foundPermissions.caveats?.find(caveat => caveat.type === targetCaveatType)?.value ?? []\n }\n }\n return existingPermissions\n}\n","import { isUndefined } from '@xylabs/sdk-js'\nimport type { XyoClient } from '@xyo-network/xl1-sdk'\nimport { useEffect, useState } from 'react'\n\nimport { getXyoClient } from '../helpers/index.ts'\n\ninterface ClientState {\n client?: XyoClient | null\n error: Error | null\n isLoading: boolean\n timedout: boolean\n}\n\nconst initialState: ClientState = {\n client: undefined,\n error: null,\n isLoading: false,\n timedout: false,\n}\n\nexport const useClientFromWallet = (timeout?: number): ClientState => {\n const [state, setState] = useState<ClientState>(initialState)\n\n useEffect(() => {\n let cancelled = false\n\n const initialize = async () => {\n setState((prev) => {\n if (prev.isLoading) return prev\n return {\n ...prev, isLoading: true, error: null,\n }\n })\n\n try {\n const client = await getXyoClient(timeout)\n if (cancelled) return\n if (client === null) {\n setState({\n client: null, timedout: true, isLoading: false, error: null,\n })\n } else {\n setState({\n client, isLoading: false, error: null, timedout: false,\n })\n }\n } catch (error) {\n if (cancelled) return\n setState({\n client: undefined, isLoading: false, error: error as Error, timedout: false,\n })\n }\n }\n\n void initialize()\n\n // Late recovery: if wallet loads after timeout, update state\n const onPluginReady = () => {\n if (cancelled) return\n const client = isUndefined(globalThis.xyo) ? null : globalThis.xyo?.client ?? null\n setState({\n client, isLoading: false, timedout: false, error: null,\n })\n }\n globalThis.addEventListener('xyo:plugin-ready', onPluginReady)\n\n return () => {\n cancelled = true\n globalThis.removeEventListener('xyo:plugin-ready', onPluginReady)\n }\n }, [timeout])\n\n return state\n}\n\n/** @deprecated - use useClientFromWallet instead */\nexport const useClient = useClientFromWallet\n","import { isUndefined } from '@xylabs/sdk-js'\nimport type { XyoClient } from '@xyo-network/xl1-sdk'\n\nconst CLIENT_LISTENER_TIMEOUT = 2000\n\nconst hasXyoClient = () => {\n return 'client' in globalThis.xyo\n}\n\nexport const listenForClientInjection = (onClientReady: () => void, timeout: number, onTimeout: () => void) => {\n let resolved = false\n const listener: EventListener = () => {\n onClientReady()\n resolved = true\n }\n globalThis.addEventListener('xyo:plugin-ready', listener)\n setTimeout(() => {\n if (!resolved) {\n globalThis.removeEventListener('xyo:plugin-ready', listener)\n onTimeout()\n }\n }, timeout)\n}\n\ntype ReturnType = XyoClient | undefined | null\n\nexport async function getXyoClient(timeout = CLIENT_LISTENER_TIMEOUT): Promise<ReturnType> {\n // if no xyo object, we can bail early\n if (isUndefined(globalThis.xyo)) {\n return null\n }\n return hasXyoClient()\n ? globalThis.xyo.client\n // listen for the XyoWallet to be injected\n : await new Promise<ReturnType>((resolve) => {\n listenForClientInjection(\n () => {\n resolve(globalThis.xyo.client)\n },\n timeout,\n () => {\n resolve(null)\n },\n )\n })\n}\n","import { useClientFromWallet } from '../useClientFromWallet.ts'\n\nexport const usePermissions = () => {\n const {\n client, isLoading, error, timedout,\n } = useClientFromWallet()\n const permissions = client?.permissions\n return {\n permissions,\n isLoading,\n error,\n timedout,\n }\n}\n","import { usePromise } from '@xylabs/react-promise'\nimport type { JsonValue } from '@xylabs/sdk-js'\nimport {\n isArray, isDefined, isDefinedNotNull, isString,\n} from '@xylabs/sdk-js'\n\nimport { findCaveat } from '../helpers/index.ts'\nimport { usePermissions } from './usePermissions.ts'\n\nconst validateRestrictedAccounts = (restrictedAccounts: JsonValue): readonly string [] => {\n if (isDefined(restrictedAccounts)) {\n if (isArray(restrictedAccounts) && restrictedAccounts.every(isString)) {\n return restrictedAccounts\n }\n throw new Error(\n `Unrecognized format for restrictReturnedAccounts caveat found on permissions. \\n\n Should be an array of strings: ${JSON.stringify(restrictedAccounts)}`,\n )\n }\n return []\n}\n\nexport const useAccountPermissions = () => {\n const { permissions, error } = usePermissions()\n\n return usePromise(async () => {\n if (isDefinedNotNull(error)) throw error\n if (isDefined(permissions)) {\n const restrictedAccounts = await findCaveat(\n permissions,\n // TODO - extract to constant in protocol package\n 'xyoWallet_getAccounts',\n 'restrictReturnedAccounts',\n )\n return validateRestrictedAccounts(restrictedAccounts)\n }\n }, [permissions])\n}\n","import { isNull } from '@xylabs/sdk-js'\nimport type { GatewayName } from '@xyo-network/xl1-sdk'\n\nimport type { GatewayFromWallet } from '../../types/index.ts'\nimport { useClientFromWallet } from './useClientFromWallet.ts'\n\n/**\n * Resolves a gateway from the injected XL1 Wallet extension.\n *\n * The returned `gateway` uses a three-state contract:\n * - `undefined` — wallet detection is still in progress (isLoading=true),\n * or no gatewayName was provided. Consumers should treat this as \"not yet known\"\n * and avoid committing to either a present or absent UI state.\n * - `null` — wallet is definitively absent. Either globalThis.xyo was never set,\n * or detection timed out. Safe to show fallback UI (e.g. \"Get XL1 Wallet\").\n * A late-recovery listener may still transition this to a real gateway if\n * the extension loads after the timeout.\n * - `XyoGatewayRunner` — wallet is present and exposes this gateway for the\n * requested network. Ready to use for transactions and queries.\n */\nexport const useGatewayFromWallet = (gatewayName?: GatewayName, timeout?: number): GatewayFromWallet => {\n const {\n client, isLoading, error, timedout,\n } = useClientFromWallet(timeout)\n\n const resolveGateway = () => {\n // null client = wallet confirmed absent (no globalThis.xyo or timed out)\n if (isNull(client)) return null\n // client is undefined (still loading) or defined (wallet present) —\n // optional chain returns undefined while loading, or the gateway if available\n return client?.gateways?.[gatewayName!]\n }\n\n return {\n // no gatewayName requested = undefined (opt-out, not \"absent\")\n gateway: gatewayName ? resolveGateway() : undefined,\n isLoading,\n error,\n timedout,\n }\n}\n\n/** @deprecated - useGatewayFromWallet */\nexport const useGateway = useGatewayFromWallet\n","import { createContextEx } from '@xylabs/react-shared'\n\nimport type { GatewayContextState } from './GatewayProviderState.ts'\n\n/**\n * Shared React context that decouples gateway *sources* from gateway\n * *consumers*. Any provider that can resolve an `XyoGateway` publishes to\n * this context; any hook or component that needs a gateway reads from it\n * via `useProvidedGateway`. Consumers never import a specific provider —\n * they just require that *some* provider is mounted above them in the\n * tree.\n *\n * Current publishers:\n * - `WalletGatewayProvider` (this package) — sources gateways from the\n * injected XL1 wallet extension.\n * - `GatewayProvider` in `@xyo-network/react-chain-provider` — sources\n * gateways built in-page against RPC endpoints, falling back to the\n * wallet when available.\n *\n * To add a new source (e.g. a mock provider for tests, an iframe-bridged\n * provider, a server-rendered provider), publish a `GatewayContextState`\n * to this same context — do not create a parallel context, or consumers\n * will silently stop receiving updates.\n */\nexport const GatewayContext = createContextEx<GatewayContextState>()\n","import { createContextEx } from '@xylabs/react-shared'\n\nimport type { InPageGatewaysState } from './InPageGatewaysState.ts'\n\n/**\n * Narrow, provider-internal context that `InPageGatewaysProvider` writes\n * to and `GatewayProvider` reads from. Do not consume this in application\n * code — use `useProvidedGateway` (which reads the shared\n * `GatewayContext`) instead. This context only exists to decouple the\n * single in-page *builder* from the many single-gateway *adapters* that\n * sit between it and the shared gateway surface.\n */\nexport const InPageGatewaysContext = createContextEx<InPageGatewaysState>()\n","import type {\n GatewayName, RpcTransport, XyoSignerRpcSchemas,\n} from '@xyo-network/xl1-sdk'\nimport { DefaultNetworks } from '@xyo-network/xl1-sdk'\nimport type { PropsWithChildren } from 'react'\nimport React, {\n startTransition,\n useCallback, useEffect, useMemo, useState,\n} from 'react'\n\nimport type { ContextGatewayType } from '../../types/index.ts'\nimport { InPageGatewaysContext } from './InPageGatewaysContext.ts'\nimport type { InPageGatewaysState } from './InPageGatewaysState.ts'\nimport { buildGateway } from './lib/index.ts'\n\nexport interface InPageGatewaysProviderProps extends PropsWithChildren {\n signerTransport?: RpcTransport<XyoSignerRpcSchemas>\n}\n\n/**\n * Publishes a keyed map of in-page gateways — one per network in\n * `DefaultNetworks` — under the narrow `InPageGatewaysContext`.\n *\n * This provider is deliberately *not* a direct publisher of the shared\n * `GatewayContext` that `useProvidedGateway` reads. Its consumer is the\n * wrapping `GatewayProvider` in this same package, which picks the\n * `gatewayName` the consumer asked for out of this map, adapts it into\n * the single-gateway `GatewayContextState` shape, and then publishes *that*\n * to the shared context. Splitting the work this way lets one\n * `InPageGatewaysProvider` near the root build every network's gateway\n * once, while many `GatewayProvider` instances deeper in the tree each\n * expose whichever gateway their subtree cares about.\n *\n * Unlike `WalletGatewayProvider`, gateways here are constructed directly\n * in the page (via `buildGateway`) against each network's RPC endpoint\n * — no browser wallet extension is required. `signerTransport` switches\n * between viewer (read-only) and runner (can sign/send) locators; supply\n * it only when the app needs to sign.\n *\n * Behavior:\n * - On mount, and whenever `signerTransport` changes, `buildGateway` is\n * called in parallel for every network in `DefaultNetworks` via\n * `Promise.allSettled`. Networks that resolve populate `gateways[id]`;\n * networks that reject populate `errors[id]`. One failed network does\n * not block the others.\n * - If `signerTransport` is provided, gateways are built with a remote\n * *runner* locator, otherwise with a remote *viewer* locator.\n * - When `signerTransport` changes identity mid-life, the provider clears\n * all cached gateways and errors synchronously during render (via\n * `previousSignerTransport` state) so consumers never see gateways\n * bound to the previous transport, then rebuilds in the effect.\n * - State updates from the rebuild are wrapped in `startTransition` so a\n * slow network doesn't stall higher-priority UI updates.\n * - A `cancelled` flag in the effect's cleanup discards results from a\n * prior `signerTransport` once a new one is in flight.\n *\n * Published `InPageGatewaysState` (narrower than `GatewayContextState` —\n * this is an internal handoff shape, not the cross-publisher surface):\n * - `gateways` — `Partial<Record<GatewayName, ContextGatewayType>>`. Keys\n * are only present for networks that built successfully.\n * - `errors` — `Partial<Record<GatewayName, Error>>`. Per-network build\n * failures, keyed by `GatewayName`.\n * - `clearAll()` — manually empties both maps. Also invoked internally on\n * transport changes. Forwarded by `GatewayProvider` to consumers as\n * `resetGatewaysFromConfig`.\n * - `provided: true` — lets descendants detect a real provider.\n *\n * Note: the commented-out `SimpleXyoClient` at the top is intentionally\n * disabled pending a type unification between `XyoGateway` and\n * `XyoGatewayRunner`.\n */\nexport const InPageGatewaysProvider: React.FC<InPageGatewaysProviderProps> = ({ signerTransport, children }) => {\n const [gateways, setGateways] = useState<Partial<Record<GatewayName, ContextGatewayType>>>({})\n const [errors, setErrors] = useState<Partial<Record<GatewayName, Error>>>({})\n const [previousSignerTransport, setPreviousSignerTransport] = useState<RpcTransport<XyoSignerRpcSchemas> | undefined>(signerTransport)\n\n // This can come back once we homogenize the type for XyoGateway.\n // Right now, SimpleXyoClient takes XyoGatewayRunners but ideally it would take XyoGateway.\n // const clientInPage = useMemo(() => new SimpleXyoClient(gateways, {}), [gateways])\n\n const clearAll = useCallback(() => {\n setGateways({})\n setErrors({})\n }, [])\n\n if (previousSignerTransport !== signerTransport) {\n clearAll()\n setPreviousSignerTransport(signerTransport)\n }\n\n useEffect(() => {\n let cancelled = false\n\n const buildAll = async () => {\n const results = await Promise.allSettled(\n DefaultNetworks.map(async (network) => {\n const gateway = await buildGateway(network.id, signerTransport)\n return { id: network.id, gateway }\n }),\n )\n\n if (cancelled) return\n\n const nextGateways: Partial<Record<GatewayName, ContextGatewayType>> = {}\n const nextErrors: Partial<Record<GatewayName, Error>> = {}\n\n for (const [index, result] of results.entries()) {\n const networkId = DefaultNetworks[index].id as GatewayName\n if (result.status === 'fulfilled') {\n nextGateways[networkId] = result.value.gateway\n } else {\n nextErrors[networkId] = result.reason instanceof Error ? result.reason : new Error(String(result.reason))\n }\n }\n\n startTransition(() => {\n setGateways(nextGateways)\n setErrors(nextErrors)\n })\n }\n\n void buildAll()\n return () => {\n cancelled = true\n }\n }, [signerTransport])\n\n const value = useMemo(() => {\n const value: InPageGatewaysState = {\n clearAll,\n errors,\n gateways,\n provided: true,\n }\n return value\n }, [clearAll, errors, gateways])\n\n return <InPageGatewaysContext value={value}>{children}</InPageGatewaysContext>\n}\n","import { assertEx, isDefined } from '@xylabs/sdk-js'\nimport type {\n GatewayName,\n RemoteConfig, RpcTransport, SimpleXyoGateway,\n XyoSignerRpcSchemas,\n} from '@xyo-network/xl1-sdk'\nimport {\n basicRemoteRunnerLocator,\n basicRemoteViewerLocator,\n DefaultNetworks, NetworkDataLakeUrls, XyoGatewayMoniker,\n} from '@xyo-network/xl1-sdk'\n\nexport const buildGateway = async (gatewayName: GatewayName, signerTransport?: RpcTransport<XyoSignerRpcSchemas>) => {\n const network = DefaultNetworks.find(network => network.id === gatewayName)\n const resolvedNetwork = assertEx(network, () => `No network found for id ${gatewayName}`)\n\n const remoteConfig: RemoteConfig = {\n rpc: {\n protocol: 'http',\n url: `${resolvedNetwork.url}/rpc`,\n },\n }\n\n const dataLakeEndpoint = NetworkDataLakeUrls[gatewayName]\n\n const locator = isDefined(signerTransport)\n ? await basicRemoteRunnerLocator(gatewayName, remoteConfig, signerTransport, dataLakeEndpoint)\n : await basicRemoteViewerLocator(gatewayName, remoteConfig, dataLakeEndpoint)\n\n return await locator.getInstance<SimpleXyoGateway>(XyoGatewayMoniker)\n}\n","import { useContextEx } from '@xylabs/react-shared'\n\nimport { InPageGatewaysContext } from './InPageGatewaysContext.ts'\n\n/**\n * Reads the `InPageGatewaysContext` map of per-network in-page gateways.\n * Intended for internal use by `GatewayProvider` — application code\n * should prefer `useProvidedGateway`, which returns a single resolved\n * gateway regardless of source.\n *\n * @param required - When `true` (default), throws if no\n * `InPageGatewaysProvider` is mounted above.\n */\nexport const useProvidedInPageGateways = (required = true) => useContextEx(InPageGatewaysContext, 'InPageGateways', required)\n","import { ErrorRender } from '@xylabs/react-error'\nimport { isDefinedNotNull, isNull } from '@xylabs/sdk-js'\nimport React, { useMemo } from 'react'\n\nimport { useGatewayFromWallet } from '../../hooks/index.ts'\nimport { GatewayContext } from '../GatewayContext.ts'\nimport type { GatewayProviderProps } from '../GatewayProviderProps.ts'\nimport type { GatewayContextState } from '../GatewayProviderState.ts'\nimport { useProvidedInPageGateways } from '../in-page/index.ts'\n\n/**\n * Publishes the shared `GatewayContext` backed by two sources: the\n * injected XL1 Wallet extension *and* the in-page gateways built by\n * `InPageGatewaysProvider`. Use this provider when the host app can\n * function without a wallet (falling back to the in-page client) but\n * should still prefer the wallet when it is present.\n *\n * Required ancestry: an `InPageGatewaysProvider` must be mounted above\n * this provider — `useProvidedInPageGateways(true)` throws if missing.\n * If you only need a wallet-backed gateway, use `WalletGatewayProvider`\n * instead.\n *\n * Source precedence for `defaultGateway`:\n * - Wallet present and resolved (`XyoGatewayRunner`) → wallet wins; the\n * in-page gateway is still exposed via `gateways.inPageGateway` for\n * the rare consumer that needs to target it specifically.\n * - Wallet definitively absent (`null`) → fall back to the in-page\n * gateway matching `gatewayName`.\n * - Wallet still resolving (`undefined`) → leave `defaultGateway`\n * `undefined` so consumers render a loading state rather than\n * committing to the in-page fallback prematurely.\n *\n * The published `GatewayContextState` shape:\n * - `defaultGateway` — resolved per the precedence above. Three-state:\n * `undefined` = loading, `null` is not produced by this provider\n * (wallet-null collapses to `gatewayFromConfig`), `XyoGateway` = ready.\n * - `gateways.walletGateway` — raw wallet result (tri-state).\n * - `gateways.inPageGateway` — raw in-page result for the requested\n * `gatewayName`, or `undefined` if no `gatewayName` was passed.\n * - `error` — first non-null of wallet error, then in-page build error\n * for this `gatewayName`. Also rendered inline via `ErrorRender` above\n * `children` so mount-time failures surface even when no consumer\n * reads `error`.\n * - `resetGatewaysFromConfig` — forwards `clearAll` from\n * `InPageGatewaysProvider`, letting consumers force a rebuild of the\n * in-page gateways (e.g. after a network or endpoint change).\n * - `provided: true` — lets descendants detect a real provider in the\n * tree.\n *\n * `defaultGateway`, `gateways`, and the context `value` are memoized so\n * consumers only re-render when wallet or in-page sources actually\n * change identity.\n */\nexport const GatewayProvider: React.FC<GatewayProviderProps> = ({ gatewayName, children }) => {\n const {\n gateway: gatewayFromWallet,\n error: gatewayFromWalletError,\n } = useGatewayFromWallet(gatewayName)\n\n const {\n gateways: allGateways,\n errors: allGatewayErrors,\n clearAll,\n } = useProvidedInPageGateways(true)\n\n const gatewayFromConfig = gatewayName ? allGateways[gatewayName] : undefined\n const gatewayFromConfigError = gatewayName ? allGatewayErrors[gatewayName] : undefined\n\n const { defaultGateway, gateways } = useMemo(() => {\n if (isNull(gatewayFromWallet)) {\n return {\n defaultGateway: gatewayFromConfig,\n gateways: {\n inPageGateway: gatewayFromConfig,\n walletGateway: null,\n },\n }\n } else if (isDefinedNotNull(gatewayFromWallet)) {\n return {\n defaultGateway: gatewayFromWallet,\n gateways: {\n inPageGateway: gatewayFromConfig,\n walletGateway: gatewayFromWallet,\n },\n }\n }\n return {\n defaultGateway: undefined,\n gateways: {\n inPageGateway: undefined,\n walletGateway: undefined,\n },\n }\n }, [gatewayFromConfig, gatewayFromWallet])\n\n const value = useMemo(() => {\n const value: GatewayContextState = {\n defaultGateway,\n error: gatewayFromWalletError ?? gatewayFromConfigError,\n gateways,\n provided: true,\n resetGatewaysFromConfig: clearAll,\n }\n return value\n }, [\n defaultGateway,\n gatewayFromWalletError,\n gatewayFromConfigError,\n gateways,\n clearAll,\n ])\n\n return (\n <GatewayContext value={value}>\n <ErrorRender error={gatewayFromConfigError} />\n {children}\n </GatewayContext>\n )\n}\n","import { ErrorRender } from '@xylabs/react-error'\nimport React, { useMemo } from 'react'\n\nimport { useGatewayFromWallet } from '../../hooks/index.ts'\nimport { GatewayContext } from '../GatewayContext.ts'\nimport type { GatewayProviderProps } from '../GatewayProviderProps.ts'\nimport type { GatewayContextState } from '../GatewayProviderState.ts'\n\n/**\n * Publishes a `GatewayContext` backed exclusively by the injected XL1 Wallet\n * extension (i.e. `globalThis.xyo`). This is the provider to use when the\n * host app is a browser UI that expects the user to bring their own wallet,\n * rather than running an in-page gateway.\n *\n * The requested `gatewayName` is forwarded to `useGatewayFromWallet`, whose\n * returned gateway uses a three-state contract (`undefined` = still\n * resolving, `null` = wallet confirmed absent / timed out,\n * `XyoGatewayRunner` = ready). That tri-state is passed through to\n * consumers unchanged as `defaultGateway` / `gateways.walletGateway`, so\n * downstream hooks can distinguish \"loading\" from \"missing\".\n *\n * The published `GatewayContextState` shape:\n * - `defaultGateway` — the wallet gateway, used when consumers don't\n * specify which gateway they want.\n * - `gateways.walletGateway` — same instance as `defaultGateway`.\n * - `gateways.inPageGateway` — always `null` here; this provider does not\n * stand up an in-page client. Pair with a different provider if you need\n * both.\n * - `error` — surfaced from `useGatewayFromWallet` (detection / timeout /\n * wallet errors). Also rendered inline via `ErrorRender` above `children`\n * so mount-time failures are visible even if no consumer reads `error`.\n * - `provided: true` — lets descendants detect that a real provider (not\n * the default empty context) is in the tree.\n *\n * The `defaultGateway`, `gateways`, and context `value` are memoized so\n * consumers only re-render when the underlying wallet gateway reference or\n * error actually changes.\n */\nexport const WalletGatewayProvider: React.FC<GatewayProviderProps> = ({ gatewayName, children }) => {\n const {\n gateway: gatewayFromWallet,\n error: gatewayFromWalletError,\n } = useGatewayFromWallet(gatewayName)\n\n const { defaultGateway, gateways } = useMemo(() => {\n return {\n defaultGateway: gatewayFromWallet,\n gateways: {\n inPageGateway: null,\n walletGateway: gatewayFromWallet,\n },\n }\n }, [gatewayFromWallet])\n\n const value = useMemo(() => {\n const value: GatewayContextState = {\n defaultGateway,\n error: gatewayFromWalletError,\n gateways,\n provided: true,\n }\n return value\n }, [\n defaultGateway,\n gatewayFromWalletError,\n gateways,\n ])\n\n return (\n <GatewayContext value={value}>\n <ErrorRender error={gatewayFromWalletError} />\n {children}\n </GatewayContext>\n )\n}\n","import { useContextEx } from '@xylabs/react-shared'\n\nimport { GatewayContext } from './GatewayContext.ts'\n\n/**\n * The sole consumer entry point for gateway state. Reads the nearest\n * `GatewayContext` in the tree, regardless of which provider published\n * it — this is the decoupling that lets a component work unchanged when\n * the surrounding app swaps `WalletGatewayProvider` for\n * `GatewayProvider` (or a test double).\n *\n * @param required - When `true` (default), throws if no gateway provider\n * is mounted above — use this when the component is meaningless\n * without a gateway. When `false`, returns default state (all fields\n * undefined) so the component can render a graceful fallback.\n */\nexport const useProvidedGateway = (required = true) => useContextEx(GatewayContext, 'Gateway', required)\n"],"mappings":";AAAA;AAAA,EACE;AAAA,EAAO;AAAA,EAAS;AAAA,OACX;AACP,SAAS,yBAAyB;AAClC,SAAS,6BAA6B;AAOlC,SACE,KADF;AAJG,IAAM,mBAAkD,CAAC,EAAE,QAAQ,MAAM;AAC9E,QAAM,mBAAmB,GAAG,kBAAkB,WAAW,OAAO,GAAG,cAAc,CAAC,CAAC;AAEnF,SACE,qBAAC,SAAM,WAAU,OAAM,YAAW,UAAS,SAAS,GAClD;AAAA,wBAAC,yBAAsB,SAAkB,MAAM,IAAI;AAAA,IACnD,oBAAC,WAAQ,OAAO,SACd,8BAAC,cAAW,OAAM,iBAAgB,SAAQ,WAAU,YAAW,aAAa,4BAAiB,GAC/F;AAAA,KACF;AAEJ;;;ACjBA;AAAA,EACE;AAAA,EAAO;AAAA,EAAY;AAAA,EAAQ,SAAAA;AAAA,EAC3B,cAAAC;AAAA,OACK;AAEP,SAAS,gBAAgB;AACzB,SAAS,mBAAmB;AAE5B,SAAS,aAAAC,YAAW,eAAAC,oBAAmB;AAEvC,SAAgB,aAAAC,kBAAiB;;;ACXjC,SAAuB,iBAAiB;AACxC,SAAS,gBAAgB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QAAAC,aAAA;AA/BG,IAAM,wBAAwD,CAAC,EAAE,aAAa,SAAS,MAAM;AAClG,QAAM;AAAA,IACJ,SAAS;AAAA,IACT,OAAO;AAAA,EACT,IAAI,qBAAqB,WAAW;AAEpC,QAAM,EAAE,gBAAgB,SAAS,IAAIC,SAAQ,MAAM;AACjD,WAAO;AAAA,MACL,gBAAgB;AAAA,MAChB,UAAU;AAAA,QACR,eAAe;AAAA,QACf,eAAe;AAAA,MACjB;AAAA,IACF;AAAA,EACF,GAAG,CAAC,iBAAiB,CAAC;AAEtB,QAAM,QAAQA,SAAQ,MAAM;AAC1B,UAAMC,SAA6B;AAAA,MACjC;AAAA,MACA,OAAO;AAAA,MACP;AAAA,MACA,UAAU;AAAA,IACZ;AACA,WAAOA;AAAA,EACT,GAAG;AAAA,IACD;AAAA,IACA;AAAA,IACA;AAAA,EACF,CAAC;AAED,SACE,gBAAAF,MAAC,kBAAe,OACd;AAAA,oBAAAD,KAACI,cAAA,EAAY,OAAO,wBAAwB;AAAA,IAC3C;AAAA,KACH;AAEJ;;;AC1EA,SAAS,gBAAAC,qBAAoB;AAgBtB,IAAM,qBAAqB,CAAC,WAAW,SAASC,cAAa,gBAAgB,WAAW,QAAQ;","names":["Stack","Typography","isDefined","isUndefined","useEffect","useState","isUndefined","isUndefined","isDefined","isDefined","useState","address","jsx","jsxs","Typography","useEffect","isDefined","Stack","isUndefined","createContextEx","DefaultNetworks","useCallback","useEffect","useState","assertEx","isDefined","network","jsx","useState","useCallback","useEffect","DefaultNetworks","value","ErrorRender","isDefinedNotNull","isNull","useMemo","jsx","jsxs","useMemo","isNull","isDefinedNotNull","value","ErrorRender","ErrorRender","useMemo","jsx","jsxs","useMemo","value","ErrorRender","useContextEx","useContextEx"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GatewayStats.d.ts","sourceRoot":"","sources":["../../../../src/client/story/GatewayStats.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAA;AAKvD,MAAM,WAAW,iBAAiB;IAChC,EAAE,CAAC,EAAE,WAAW,CAAA;IAChB,GAAG,CAAC,EAAE,MAAM,CAAA;CACb;AAED,eAAO,MAAM,YAAY,EAAE,KAAK,CAAC,EAAE,CAAC,iBAAiB,CAcpD,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GatewayStatus.d.ts","sourceRoot":"","sources":["../../../../src/client/story/GatewayStatus.tsx"],"names":[],"mappings":"AAMA,8EAA8E;AAC9E,eAAO,MAAM,aAAa,EAAE,KAAK,CAAC,EA6CjC,CAAA"}
|