@xyo-network/react-chain-client 1.20.21 → 1.20.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser/components/connected/ConnectAccountsStack.d.ts +18 -0
- package/dist/browser/components/connected/ConnectAccountsStack.d.ts.map +1 -0
- package/dist/browser/components/connected/account/Connected.d.ts +5 -0
- package/dist/browser/components/connected/account/Connected.d.ts.map +1 -0
- package/dist/browser/components/connected/account/index.d.ts +2 -0
- package/dist/browser/components/connected/account/index.d.ts.map +1 -0
- package/dist/browser/components/connected/hooks/index.d.ts +2 -0
- package/dist/browser/components/connected/hooks/index.d.ts.map +1 -0
- package/dist/browser/components/connected/hooks/useConnectAccount.d.ts +17 -0
- package/dist/browser/components/connected/hooks/useConnectAccount.d.ts.map +1 -0
- package/dist/browser/components/connected/index.d.ts +3 -0
- package/dist/browser/components/connected/index.d.ts.map +1 -0
- package/dist/browser/components/index.d.ts +2 -0
- package/dist/browser/components/index.d.ts.map +1 -0
- package/dist/browser/context/GatewayContext.d.ts +8 -0
- package/dist/browser/context/GatewayContext.d.ts.map +1 -0
- package/dist/browser/context/GatewayProviderProps.d.ts +6 -0
- package/dist/browser/context/GatewayProviderProps.d.ts.map +1 -0
- package/dist/browser/context/GatewayProviderState.d.ts +13 -0
- package/dist/browser/context/GatewayProviderState.d.ts.map +1 -0
- package/dist/browser/context/WalletGatewayProvider.d.ts +4 -0
- package/dist/browser/context/WalletGatewayProvider.d.ts.map +1 -0
- package/dist/browser/context/index.d.ts +6 -0
- package/dist/browser/context/index.d.ts.map +1 -0
- package/dist/browser/context/useProvidedGateway.d.ts +4 -0
- package/dist/browser/context/useProvidedGateway.d.ts.map +1 -0
- package/dist/browser/index.d.ts +2 -0
- package/dist/browser/index.d.ts.map +1 -1
- package/dist/browser/index.mjs +170 -1
- package/dist/browser/index.mjs.map +1 -1
- package/dist/browser/story/GatewayStats.d.ts +7 -0
- package/dist/browser/story/GatewayStats.d.ts.map +1 -0
- package/dist/browser/story/GatewayStatus.d.ts +3 -0
- package/dist/browser/story/GatewayStatus.d.ts.map +1 -0
- package/dist/browser/types/ContextGatewayType.d.ts +3 -0
- package/dist/browser/types/ContextGatewayType.d.ts.map +1 -0
- package/dist/browser/types/index.d.ts +1 -0
- package/dist/browser/types/index.d.ts.map +1 -1
- package/package.json +10 -9
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { StackProps } from '@mui/material';
|
|
2
|
+
import type { Address } from '@xylabs/sdk-js';
|
|
3
|
+
import type { ComponentType, MouseEventHandler } from 'react';
|
|
4
|
+
import React from 'react';
|
|
5
|
+
export interface ConnectClientAccountsStackProps extends StackProps {
|
|
6
|
+
AccountComponent?: ComponentType<{
|
|
7
|
+
account?: string;
|
|
8
|
+
}>;
|
|
9
|
+
ConnectComponent?: ComponentType<{
|
|
10
|
+
onClick?: MouseEventHandler<HTMLElement>;
|
|
11
|
+
}>;
|
|
12
|
+
NoWalletInstalledComponent?: ComponentType;
|
|
13
|
+
onAccountConnected?: (account: Address) => void;
|
|
14
|
+
onCancel?: () => void;
|
|
15
|
+
timeout?: number;
|
|
16
|
+
}
|
|
17
|
+
export declare const ConnectAccountsStack: React.FC<ConnectClientAccountsStackProps>;
|
|
18
|
+
//# sourceMappingURL=ConnectAccountsStack.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ConnectAccountsStack.d.ts","sourceRoot":"","sources":["../../../../src/components/connected/ConnectAccountsStack.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAO/C,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAA;AAG7C,OAAO,KAAK,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAA;AAC7D,OAAO,KAAoB,MAAM,OAAO,CAAA;AA4BxC,MAAM,WAAW,+BAAgC,SAAQ,UAAU;IACjE,gBAAgB,CAAC,EAAE,aAAa,CAAC;QAAE,OAAO,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,CAAA;IACtD,gBAAgB,CAAC,EAAE,aAAa,CAAC;QAAE,OAAO,CAAC,EAAE,iBAAiB,CAAC,WAAW,CAAC,CAAA;KAAE,CAAC,CAAA;IAC9E,0BAA0B,CAAC,EAAE,aAAa,CAAA;IAC1C,kBAAkB,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,IAAI,CAAA;IAC/C,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAA;IACrB,OAAO,CAAC,EAAE,MAAM,CAAA;CACjB;AAED,eAAO,MAAM,oBAAoB,EAAE,KAAK,CAAC,EAAE,CAAC,+BAA+B,CA2C1E,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Connected.d.ts","sourceRoot":"","sources":["../../../../../src/components/connected/account/Connected.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,eAAO,MAAM,gBAAgB,EAAE,KAAK,CAAC,EAAE,CAAC;IAAE,OAAO,EAAE,MAAM,CAAA;CAAE,CAW1D,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/components/connected/account/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/components/connected/hooks/index.ts"],"names":[],"mappings":"AAAA,cAAc,wBAAwB,CAAA"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { GatewayName } from '@xyo-network/xl1-sdk';
|
|
2
|
+
export declare const useConnectAccount: (gatewayName?: GatewayName, timeout?: number) => {
|
|
3
|
+
address: (Lowercase<string> & {
|
|
4
|
+
readonly __hex: true;
|
|
5
|
+
} & {
|
|
6
|
+
readonly __address: true;
|
|
7
|
+
}) | undefined;
|
|
8
|
+
connectSigner: () => Promise<(Lowercase<string> & {
|
|
9
|
+
readonly __hex: true;
|
|
10
|
+
} & {
|
|
11
|
+
readonly __address: true;
|
|
12
|
+
}) | undefined>;
|
|
13
|
+
error: Error | undefined;
|
|
14
|
+
gateway: import("@xyo-network/xl1-sdk").XyoGatewayRunner | null | undefined;
|
|
15
|
+
timedout: boolean;
|
|
16
|
+
};
|
|
17
|
+
//# sourceMappingURL=useConnectAccount.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useConnectAccount.d.ts","sourceRoot":"","sources":["../../../../../src/components/connected/hooks/useConnectAccount.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAA;AAMvD,eAAO,MAAM,iBAAiB,GAAI,cAAa,WAA4B,EAAE,UAAU,MAAM;;;;;;;;;;;;;;CA2B5F,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/connected/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAA;AAClC,cAAc,4BAA4B,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAA"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export declare const GatewayContext: import("react").Context<(import("./GatewayProviderState.ts").GatewayStateFields & {
|
|
2
|
+
provided: true;
|
|
3
|
+
}) | (import("@xylabs/react-shared").FixedValues<import("@xylabs/react-shared").ProvidedContextExState<import("./GatewayProviderState.ts").GatewayStateFields>, never> & {
|
|
4
|
+
provided: false;
|
|
5
|
+
}) | (import("@xylabs/react-shared").FixedValues<import("@xylabs/react-shared").NotProvidedContextExState<import("./GatewayProviderState.ts").GatewayStateFields>, never> & {
|
|
6
|
+
provided: false;
|
|
7
|
+
})>;
|
|
8
|
+
//# sourceMappingURL=GatewayContext.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GatewayContext.d.ts","sourceRoot":"","sources":["../../../src/context/GatewayContext.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,cAAc;;;;;;GAAyC,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GatewayProviderProps.d.ts","sourceRoot":"","sources":["../../../src/context/GatewayProviderProps.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAA;AACvD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAA;AAE9C,MAAM,WAAW,oBAAqB,SAAQ,iBAAiB;IAC7D,WAAW,CAAC,EAAE,WAAW,CAAA;CAC1B"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { ContextExState } from '@xylabs/react-shared';
|
|
2
|
+
import type { ContextGatewayType } from '../types/index.ts';
|
|
3
|
+
export interface GatewayStateFields {
|
|
4
|
+
defaultGateway: ContextGatewayType | undefined | null;
|
|
5
|
+
error: Error | null | undefined;
|
|
6
|
+
gateways: {
|
|
7
|
+
inPageGateway: ContextGatewayType | undefined | null;
|
|
8
|
+
walletGateway: ContextGatewayType | undefined | null;
|
|
9
|
+
};
|
|
10
|
+
resetGatewaysFromConfig?: () => void;
|
|
11
|
+
}
|
|
12
|
+
export type GatewayContextState = ContextExState<GatewayStateFields>;
|
|
13
|
+
//# sourceMappingURL=GatewayProviderState.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GatewayProviderState.d.ts","sourceRoot":"","sources":["../../../src/context/GatewayProviderState.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AAE1D,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAA;AAE3D,MAAM,WAAW,kBAAkB;IACjC,cAAc,EAAE,kBAAkB,GAAG,SAAS,GAAG,IAAI,CAAA;IACrD,KAAK,EAAE,KAAK,GAAG,IAAI,GAAG,SAAS,CAAA;IAC/B,QAAQ,EAAE;QACR,aAAa,EAAE,kBAAkB,GAAG,SAAS,GAAG,IAAI,CAAA;QACpD,aAAa,EAAE,kBAAkB,GAAG,SAAS,GAAG,IAAI,CAAA;KACrD,CAAA;IACD,uBAAuB,CAAC,EAAE,MAAM,IAAI,CAAA;CACrC;AAED,MAAM,MAAM,mBAAmB,GAAG,cAAc,CAAC,kBAAkB,CAAC,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"WalletGatewayProvider.d.ts","sourceRoot":"","sources":["../../../src/context/WalletGatewayProvider.tsx"],"names":[],"mappings":"AACA,OAAO,KAAkB,MAAM,OAAO,CAAA;AAItC,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAA;AAGrE,eAAO,MAAM,qBAAqB,EAAE,KAAK,CAAC,EAAE,CAAC,oBAAoB,CAoChE,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/context/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAA;AACnC,cAAc,2BAA2B,CAAA;AACzC,cAAc,2BAA2B,CAAA;AACzC,cAAc,yBAAyB,CAAA;AACvC,cAAc,6BAA6B,CAAA"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export declare const useProvidedGateway: (required?: boolean) => Omit<import("./GatewayProviderState.ts").GatewayStateFields & {
|
|
2
|
+
provided: true;
|
|
3
|
+
}, "provided"> | Omit<import("@xylabs/react-shared").NotProvidedContextExState<import("./GatewayProviderState.ts").GatewayContextState>, "provided">;
|
|
4
|
+
//# sourceMappingURL=useProvidedGateway.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useProvidedGateway.d.ts","sourceRoot":"","sources":["../../../src/context/useProvidedGateway.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,kBAAkB,GAAI,kBAAe;;oJAAsD,CAAA"}
|
package/dist/browser/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAA;AAChC,cAAc,kBAAkB,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAA;AACrC,cAAc,oBAAoB,CAAA;AAClC,cAAc,kBAAkB,CAAA;AAChC,cAAc,kBAAkB,CAAA"}
|
package/dist/browser/index.mjs
CHANGED
|
@@ -1,6 +1,42 @@
|
|
|
1
1
|
var __defProp = Object.defineProperty;
|
|
2
2
|
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
3
|
|
|
4
|
+
// src/components/connected/account/Connected.tsx
|
|
5
|
+
import { Stack, Tooltip, Typography } from "@mui/material";
|
|
6
|
+
import { EthAddressWrapper } from "@xylabs/sdk-js";
|
|
7
|
+
import { BlockiesAvatarAddress } from "@xyo-network/react-chain-blockies";
|
|
8
|
+
import React from "react";
|
|
9
|
+
var ConnectedAccount = /* @__PURE__ */ __name(({ address }) => {
|
|
10
|
+
const shortenedAddress = `${EthAddressWrapper.fromString(address)?.toShortString(4)}`;
|
|
11
|
+
return /* @__PURE__ */ React.createElement(Stack, {
|
|
12
|
+
direction: "row",
|
|
13
|
+
alignItems: "center",
|
|
14
|
+
spacing: 1
|
|
15
|
+
}, /* @__PURE__ */ React.createElement(BlockiesAvatarAddress, {
|
|
16
|
+
address,
|
|
17
|
+
size: 21
|
|
18
|
+
}), /* @__PURE__ */ React.createElement(Tooltip, {
|
|
19
|
+
title: address
|
|
20
|
+
}, /* @__PURE__ */ React.createElement(Typography, {
|
|
21
|
+
color: "textSecondary",
|
|
22
|
+
variant: "caption",
|
|
23
|
+
fontFamily: "monospace"
|
|
24
|
+
}, shortenedAddress)));
|
|
25
|
+
}, "ConnectedAccount");
|
|
26
|
+
|
|
27
|
+
// src/components/connected/ConnectAccountsStack.tsx
|
|
28
|
+
import { Alert, AlertTitle, Button, Stack as Stack2, Typography as Typography2 } from "@mui/material";
|
|
29
|
+
import { ButtonEx } from "@xylabs/react-button";
|
|
30
|
+
import { isDefined as isDefined3, isUndefined as isUndefined3 } from "@xylabs/sdk-js";
|
|
31
|
+
import { ErrorRender } from "@xyo-network/react-error";
|
|
32
|
+
import React2, { useEffect as useEffect2 } from "react";
|
|
33
|
+
|
|
34
|
+
// src/components/connected/hooks/useConnectAccount.ts
|
|
35
|
+
import { asAddress } from "@xylabs/sdk-js";
|
|
36
|
+
import { assertEx } from "@xylabs/sdk-js";
|
|
37
|
+
import { MainNetwork } from "@xyo-network/xl1-sdk";
|
|
38
|
+
import { useCallback, useState as useState2 } from "react";
|
|
39
|
+
|
|
4
40
|
// src/hooks/client/helpers/findCaveat.ts
|
|
5
41
|
import { isDefined } from "@xylabs/sdk-js";
|
|
6
42
|
var findCaveat = /* @__PURE__ */ __name(async (permissions, targetCapability, targetCaveatType) => {
|
|
@@ -184,7 +220,139 @@ var useGatewayFromWallet = /* @__PURE__ */ __name((gatewayName, timeout) => {
|
|
|
184
220
|
};
|
|
185
221
|
}, "useGatewayFromWallet");
|
|
186
222
|
var useGateway = useGatewayFromWallet;
|
|
223
|
+
|
|
224
|
+
// src/components/connected/hooks/useConnectAccount.ts
|
|
225
|
+
var useConnectAccount = /* @__PURE__ */ __name((gatewayName = MainNetwork.id, timeout) => {
|
|
226
|
+
const [connectError, setConnectError] = useState2();
|
|
227
|
+
const { gateway, error, timedout } = useGatewayFromWallet(gatewayName, timeout);
|
|
228
|
+
const [accountPermissions, accountPermissionsError] = useAccountPermissions();
|
|
229
|
+
const [address, setAddress] = useState2();
|
|
230
|
+
const connectSigner = useCallback(async () => {
|
|
231
|
+
try {
|
|
232
|
+
setConnectError(void 0);
|
|
233
|
+
const assertedGateway = assertEx(gateway, () => `Gateway ${gatewayName} is not available`);
|
|
234
|
+
const signer = assertedGateway.signer;
|
|
235
|
+
const address2 = await signer.address();
|
|
236
|
+
setAddress(address2);
|
|
237
|
+
return address2;
|
|
238
|
+
} catch (e) {
|
|
239
|
+
setConnectError(e);
|
|
240
|
+
}
|
|
241
|
+
}, [
|
|
242
|
+
gateway,
|
|
243
|
+
gatewayName
|
|
244
|
+
]);
|
|
245
|
+
return {
|
|
246
|
+
address: asAddress(accountPermissions?.[0] ?? address),
|
|
247
|
+
connectSigner,
|
|
248
|
+
error: error ?? accountPermissionsError ?? connectError,
|
|
249
|
+
gateway,
|
|
250
|
+
timedout
|
|
251
|
+
};
|
|
252
|
+
}, "useConnectAccount");
|
|
253
|
+
|
|
254
|
+
// src/components/connected/ConnectAccountsStack.tsx
|
|
255
|
+
var DefaultConnectComponent = /* @__PURE__ */ __name((props) => /* @__PURE__ */ React2.createElement(ButtonEx, {
|
|
256
|
+
variant: "contained",
|
|
257
|
+
size: "small",
|
|
258
|
+
...props
|
|
259
|
+
}), "DefaultConnectComponent");
|
|
260
|
+
var DefaultNoWalletInstalledComponent = /* @__PURE__ */ __name(() => /* @__PURE__ */ React2.createElement(Alert, {
|
|
261
|
+
severity: "warning"
|
|
262
|
+
}, /* @__PURE__ */ React2.createElement(AlertTitle, null, "XL1 Wallet Not Found"), /* @__PURE__ */ React2.createElement(Typography2, {
|
|
263
|
+
gutterBottom: true
|
|
264
|
+
}, "Please ensure that your XL1 Wallet is installed to connect your account."), /* @__PURE__ */ React2.createElement(Button, {
|
|
265
|
+
sx: {
|
|
266
|
+
display: "flex",
|
|
267
|
+
justifySelf: "end"
|
|
268
|
+
},
|
|
269
|
+
size: "small",
|
|
270
|
+
variant: "outlined",
|
|
271
|
+
href: "https://chromewebstore.google.com/detail/xl1-wallet/fblbagcjeigmhakkfgjpdlcapcgmcfbm",
|
|
272
|
+
target: "_blank",
|
|
273
|
+
rel: "noopener"
|
|
274
|
+
}, "Get XL1 Wallet")), "DefaultNoWalletInstalledComponent");
|
|
275
|
+
var ConnectAccountsStack = /* @__PURE__ */ __name(({ AccountComponent = ConnectedAccount, ConnectComponent = DefaultConnectComponent, NoWalletInstalledComponent = DefaultNoWalletInstalledComponent, onAccountConnected, onCancel, timeout, ...props }) => {
|
|
276
|
+
const { address, connectSigner, error, timedout } = useConnectAccount(void 0, timeout);
|
|
277
|
+
useEffect2(() => {
|
|
278
|
+
if (isDefined3(error) && isDefined3(onCancel)) {
|
|
279
|
+
onCancel();
|
|
280
|
+
}
|
|
281
|
+
}, [
|
|
282
|
+
error,
|
|
283
|
+
onCancel
|
|
284
|
+
]);
|
|
285
|
+
useEffect2(() => {
|
|
286
|
+
if (isDefined3(address) && isDefined3(onAccountConnected)) {
|
|
287
|
+
onAccountConnected(address);
|
|
288
|
+
}
|
|
289
|
+
}, [
|
|
290
|
+
address,
|
|
291
|
+
onAccountConnected
|
|
292
|
+
]);
|
|
293
|
+
return /* @__PURE__ */ React2.createElement(Stack2, {
|
|
294
|
+
direction: "row",
|
|
295
|
+
alignItems: "start",
|
|
296
|
+
spacing: 2,
|
|
297
|
+
...props
|
|
298
|
+
}, isDefined3(address) ? /* @__PURE__ */ React2.createElement(AccountComponent, {
|
|
299
|
+
address
|
|
300
|
+
}) : null, isUndefined3(address) && !timedout ? /* @__PURE__ */ React2.createElement(ConnectComponent, {
|
|
301
|
+
onClick: /* @__PURE__ */ __name(() => void connectSigner(), "onClick")
|
|
302
|
+
}, "Connect") : null, isUndefined3(address) && timedout ? /* @__PURE__ */ React2.createElement(NoWalletInstalledComponent, null) : null, /* @__PURE__ */ React2.createElement(ErrorRender, {
|
|
303
|
+
error,
|
|
304
|
+
scope: "ConnectSigner:error"
|
|
305
|
+
}));
|
|
306
|
+
}, "ConnectAccountsStack");
|
|
307
|
+
|
|
308
|
+
// src/context/GatewayContext.ts
|
|
309
|
+
import { createContextEx } from "@xylabs/react-shared";
|
|
310
|
+
var GatewayContext = createContextEx();
|
|
311
|
+
|
|
312
|
+
// src/context/useProvidedGateway.ts
|
|
313
|
+
import { useContextEx } from "@xylabs/react-shared";
|
|
314
|
+
var useProvidedGateway = /* @__PURE__ */ __name((required = true) => useContextEx(GatewayContext, "Gateway", required), "useProvidedGateway");
|
|
315
|
+
|
|
316
|
+
// src/context/WalletGatewayProvider.tsx
|
|
317
|
+
import { ErrorRender as ErrorRender2 } from "@xyo-network/react-error";
|
|
318
|
+
import React3, { useMemo } from "react";
|
|
319
|
+
var WalletGatewayProvider = /* @__PURE__ */ __name(({ gatewayName, children }) => {
|
|
320
|
+
const { gateway: gatewayFromWallet, error: gatewayFromWalletError } = useGatewayFromWallet(gatewayName);
|
|
321
|
+
const { defaultGateway, gateways } = useMemo(() => {
|
|
322
|
+
return {
|
|
323
|
+
defaultGateway: gatewayFromWallet,
|
|
324
|
+
gateways: {
|
|
325
|
+
inPageGateway: null,
|
|
326
|
+
walletGateway: gatewayFromWallet
|
|
327
|
+
}
|
|
328
|
+
};
|
|
329
|
+
}, [
|
|
330
|
+
gatewayFromWallet
|
|
331
|
+
]);
|
|
332
|
+
const value = useMemo(() => {
|
|
333
|
+
const value2 = {
|
|
334
|
+
defaultGateway,
|
|
335
|
+
error: gatewayFromWalletError,
|
|
336
|
+
gateways,
|
|
337
|
+
provided: true
|
|
338
|
+
};
|
|
339
|
+
return value2;
|
|
340
|
+
}, [
|
|
341
|
+
defaultGateway,
|
|
342
|
+
gatewayFromWalletError,
|
|
343
|
+
gateways
|
|
344
|
+
]);
|
|
345
|
+
return /* @__PURE__ */ React3.createElement(GatewayContext, {
|
|
346
|
+
value
|
|
347
|
+
}, /* @__PURE__ */ React3.createElement(ErrorRender2, {
|
|
348
|
+
error: gatewayFromWalletError
|
|
349
|
+
}), children);
|
|
350
|
+
}, "WalletGatewayProvider");
|
|
187
351
|
export {
|
|
352
|
+
ConnectAccountsStack,
|
|
353
|
+
ConnectedAccount,
|
|
354
|
+
GatewayContext,
|
|
355
|
+
WalletGatewayProvider,
|
|
188
356
|
findCaveat,
|
|
189
357
|
getXyoClient,
|
|
190
358
|
listenForClientInjection,
|
|
@@ -193,6 +361,7 @@ export {
|
|
|
193
361
|
useClientFromWallet,
|
|
194
362
|
useGateway,
|
|
195
363
|
useGatewayFromWallet,
|
|
196
|
-
usePermissions
|
|
364
|
+
usePermissions,
|
|
365
|
+
useProvidedGateway
|
|
197
366
|
};
|
|
198
367
|
//# sourceMappingURL=index.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/hooks/client/helpers/findCaveat.ts","../../src/hooks/client/useClientFromWallet.ts","../../src/hooks/helpers/getXyoClient.ts","../../src/hooks/client/permissions/usePermissions.ts","../../src/hooks/client/permissions/usePermissionsAccounts.ts","../../src/hooks/client/useGatewayFromWallet.ts"],"sourcesContent":["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"],"mappings":";;;;AAAA,SAASA,iBAAiB;AAKnB,IAAMC,aAAa,8BACxBC,aACAC,kBACAC,qBAAAA;AAEA,QAAMC,sBAAsB,MAAMH,YAAYI,eAAc;AAC5D,MAAIC,UAAUF,mBAAAA,KAAwBA,oBAAoBG,SAAS,GAAG;AACpE,UAAMC,mBAAmBJ,oBACtBK,KAAKC,CAAAA,MAAKA,EAAEC,qBAAqBT,gBAAAA;AACpC,QAAII,UAAUE,gBAAAA,GAAmB;AAC/B,aAAOA,iBAAiBI,SAASH,KAAKI,CAAAA,WAAUA,OAAOC,SAASX,gBAAAA,GAAmBY,SAAS,CAAA;IAC9F;EACF;AACA,SAAOX;AACT,GAd0B;;;ACL1B,SAASY,eAAAA,oBAAmB;AAE5B,SAASC,WAAWC,gBAAgB;;;ACFpC,SAASC,mBAAmB;AAG5B,IAAMC,0BAA0B;AAEhC,IAAMC,eAAe,6BAAA;AACnB,SAAO,YAAYC,WAAWC;AAChC,GAFqB;AAId,IAAMC,2BAA2B,wBAACC,eAA2BC,SAAiBC,cAAAA;AACnF,MAAIC,WAAW;AACf,QAA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MAAMc;QAC/BL;;QAEA;QACA;MAAA;AAEF,aAAOV,2BAA2BC,kBAAAA;IACpC;EACF,GAAG;IAACS;GAAY;AAClB,GAfqC;;;ACtBrC,SAASM,cAAc;AAoBhB,IAAMC,uBAAuB,wBAACC,aAA2BC,YAAAA;AAC9D,QAAM,EACJC,QAAQC,WAAWC,OAAOC,SAAQ,IAChCC,oBAAoBL,OAAAA;AAExB,QAAMM,iBAAiB,6BAAA;AAErB,QAAIC,OAAON,MAAAA,EAAS,QAAO;AAG3B,WAAOA,QAAQO,WAAWT,WAAAA;EAC5B,GANuB;AAQvB,SAAO;;IAELU,SAASV,cAAcO,eAAAA,IAAmBI;IAC1CR;IACAC;IACAC;EACF;AACF,GApBoC;AAuB7B,IAAMO,aAAab;","names":["isDefined","findCaveat","permissions","targetCapability","targetCaveatType","existingPermissions","getPermissions","isDefined","length","foundPermissions","find","p","parentCapability","caveats","caveat","type","value","isUndefined","useEffect","useState","isUndefined","CLIENT_LISTENER_TIMEOUT","hasXyoClient","globalThis","xyo","listenForClientInjection","onClientReady","timeout","onTimeout","resolved","listener","addEventListener","setTimeout","removeEventListener","getXyoClient","isUndefined","client","Promise","resolve","initialState","client","undefined","error","isLoading","timedout","useClientFromWallet","timeout","state","setState","useState","useEffect","cancelled","initialize","prev","getXyoClient","onPluginReady","isUndefined","globalThis","xyo","addEventListener","removeEventListener","useClient","usePermissions","client","isLoading","error","timedout","useClientFromWallet","permissions","usePromise","isArray","isDefined","isDefinedNotNull","isString","validateRestrictedAccounts","restrictedAccounts","isDefined","isArray","every","isString","Error","JSON","stringify","useAccountPermissions","permissions","error","usePermissions","usePromise","isDefinedNotNull","findCaveat","isNull","useGatewayFromWallet","gatewayName","timeout","client","isLoading","error","timedout","useClientFromWallet","resolveGateway","isNull","gateways","gateway","undefined","useGateway"]}
|
|
1
|
+
{"version":3,"sources":["../../src/components/connected/account/Connected.tsx","../../src/components/connected/ConnectAccountsStack.tsx","../../src/components/connected/hooks/useConnectAccount.ts","../../src/hooks/client/helpers/findCaveat.ts","../../src/hooks/client/useClientFromWallet.ts","../../src/hooks/helpers/getXyoClient.ts","../../src/hooks/client/permissions/usePermissions.ts","../../src/hooks/client/permissions/usePermissionsAccounts.ts","../../src/hooks/client/useGatewayFromWallet.ts","../../src/context/GatewayContext.ts","../../src/context/useProvidedGateway.ts","../../src/context/WalletGatewayProvider.tsx"],"sourcesContent":["import {\n Stack, Tooltip, Typography,\n} from '@mui/material'\nimport { EthAddressWrapper } from '@xylabs/sdk-js'\nimport { BlockiesAvatarAddress } from '@xyo-network/react-chain-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 type { Address } from '@xylabs/sdk-js'\nimport { isDefined, isUndefined } from '@xylabs/sdk-js'\nimport { ErrorRender } from '@xyo-network/react-error'\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\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\nexport const GatewayContext = createContextEx<GatewayContextState>()\n","import { useContextEx } from '@xylabs/react-shared'\n\nimport { GatewayContext } from './GatewayContext.ts'\n\nexport const useProvidedGateway = (required = true) => useContextEx(GatewayContext, 'Gateway', required)\n","import { ErrorRender } from '@xyo-network/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\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}>\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AAGP,GApCqE;","names":["Stack","Tooltip","Typography","EthAddressWrapper","BlockiesAvatarAddress","React","ConnectedAccount","address","shortenedAddress","EthAddressWrapper","fromString","toShortString","Stack","direction","alignItems","spacing","BlockiesAvatarAddress","size","Tooltip","title","Typography","color","variant","fontFamily","Alert","AlertTitle","Button","Stack","Typography","ButtonEx","isDefined","isUndefined","ErrorRender","React","useEffect","asAddress","assertEx","MainNetwork","useCallback","useState","isDefined","findCaveat","permissions","targetCapability","targetCaveatType","existingPermissions","getPermissions","isDefined","length","foundPermissions","find","p","parentCapability","caveats","caveat","type","value","isUndefined","useEffect","useState","isUndefined","CLIENT_LISTENER_TIMEOUT","hasXyoClient","globalThis","xyo","listenForClientInjection","onClientReady","timeout","onTimeout","resolved","listener","addEventListener","setTimeout","removeEventListener","getXyoClient","isUndefined","client","Promise","resolve","initialState","client","undefined","error","isLoading","timedout","useClientFromWallet","timeout","state","setState","useState","useEffect","cancelled","initialize","prev","getXyoClient","onPluginReady","isUndefined","globalThis","xyo","addEventListener","removeEventListener","useClient","usePermissions","client","isLoading","error","timedout","useClientFromWallet","permissions","usePromise","isArray","isDefined","isDefinedNotNull","isString","validateRestrictedAccounts","restrictedAccounts","isDefined","isArray","every","isString","Error","JSON","stringify","useAccountPermissions","permissions","error","usePermissions","usePromise","isDefinedNotNull","findCaveat","isNull","useGatewayFromWallet","gatewayName","timeout","client","isLoading","error","timedout","useClientFromWallet","resolveGateway","isNull","gateways","gateway","undefined","useGateway","useConnectAccount","gatewayName","MainNetwork","id","timeout","connectError","setConnectError","useState","gateway","error","timedout","useGatewayFromWallet","accountPermissions","accountPermissionsError","useAccountPermissions","address","setAddress","connectSigner","useCallback","undefined","assertedGateway","assertEx","signer","e","asAddress","DefaultConnectComponent","props","React","ButtonEx","variant","size","DefaultNoWalletInstalledComponent","Alert","severity","AlertTitle","Typography","gutterBottom","Button","sx","display","justifySelf","href","target","rel","ConnectAccountsStack","AccountComponent","ConnectedAccount","ConnectComponent","NoWalletInstalledComponent","onAccountConnected","onCancel","timeout","address","connectSigner","error","timedout","useConnectAccount","undefined","useEffect","isDefined","Stack","direction","alignItems","spacing","isUndefined","onClick","ErrorRender","scope","createContextEx","GatewayContext","useContextEx","useProvidedGateway","required","useContextEx","GatewayContext","ErrorRender","React","useMemo","WalletGatewayProvider","gatewayName","children","gateway","gatewayFromWallet","error","gatewayFromWalletError","useGatewayFromWallet","defaultGateway","gateways","useMemo","inPageGateway","walletGateway","value","provided","React","GatewayContext","ErrorRender"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GatewayStats.d.ts","sourceRoot":"","sources":["../../../src/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/story/GatewayStatus.tsx"],"names":[],"mappings":"AAMA,8EAA8E;AAC9E,eAAO,MAAM,aAAa,EAAE,KAAK,CAAC,EA6CjC,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ContextGatewayType.d.ts","sourceRoot":"","sources":["../../../src/types/ContextGatewayType.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAA;AAGxE,MAAM,MAAM,kBAAkB,GAAG,UAAU,GAAG,gBAAgB,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/types/index.ts"],"names":[],"mappings":"AAAA,cAAc,wBAAwB,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/types/index.ts"],"names":[],"mappings":"AAAA,cAAc,yBAAyB,CAAA;AACvC,cAAc,wBAAwB,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xyo-network/react-chain-client",
|
|
3
|
-
"version": "1.20.
|
|
3
|
+
"version": "1.20.22",
|
|
4
4
|
"description": "XYO Layer One React SDK - Client/Wallet Hooks",
|
|
5
5
|
"homepage": "https://xylabs.com",
|
|
6
6
|
"bugs": {
|
|
@@ -38,18 +38,19 @@
|
|
|
38
38
|
"README.md"
|
|
39
39
|
],
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@
|
|
42
|
-
"@xyo-network/
|
|
41
|
+
"@xyo-network/xl1-sdk": "^1.26.35",
|
|
42
|
+
"@xyo-network/react-chain-blockies": "~1.20.22"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
45
|
"@emotion/react": "^11.5.0",
|
|
46
46
|
"@emotion/styled": "^11.3.0",
|
|
47
47
|
"@mui/material": "^7.3.9",
|
|
48
48
|
"@opentelemetry/api": "^1",
|
|
49
|
+
"@storybook/react-vite": "~10.3.5",
|
|
49
50
|
"@types/node": "^25.6.0",
|
|
50
51
|
"@types/react": "~19.2.14",
|
|
51
52
|
"@xylabs/react-promise": "~7.1.20",
|
|
52
|
-
"@xylabs/sdk-js": "~5.0.
|
|
53
|
+
"@xylabs/sdk-js": "~5.0.97",
|
|
53
54
|
"@xylabs/toolchain": "~7.10.8",
|
|
54
55
|
"@xylabs/tsconfig": "~7.10.8",
|
|
55
56
|
"@xylabs/tsconfig-dom": "~7.10.8",
|
|
@@ -105,7 +106,7 @@
|
|
|
105
106
|
"@xyo-network/witness-adhoc": "~5.3.30",
|
|
106
107
|
"@xyo-network/witness-model": "~5.3.30",
|
|
107
108
|
"ajv": "^8",
|
|
108
|
-
"axios": "^1.15.
|
|
109
|
+
"axios": "^1.15.1",
|
|
109
110
|
"esbuild": "*",
|
|
110
111
|
"ethers": "^6.16.0",
|
|
111
112
|
"pako": "~2.1.0",
|
|
@@ -113,14 +114,14 @@
|
|
|
113
114
|
"react-dom": "^19.2.5",
|
|
114
115
|
"storybook": "~10.3.5",
|
|
115
116
|
"typescript": "~5.9.3",
|
|
116
|
-
"vite": "^8.0.
|
|
117
|
+
"vite": "^8.0.9",
|
|
117
118
|
"zod": "~4.3.6",
|
|
118
|
-
"@xyo-network/react-chain-model": "~1.20.
|
|
119
|
-
"@xyo-network/react-chain-shared": "~1.20.
|
|
119
|
+
"@xyo-network/react-chain-model": "~1.20.22",
|
|
120
|
+
"@xyo-network/react-chain-shared": "~1.20.22"
|
|
120
121
|
},
|
|
121
122
|
"peerDependencies": {
|
|
122
123
|
"@xylabs/react-promise": "~7.1.20",
|
|
123
|
-
"@xylabs/sdk-js": "~5.0.
|
|
124
|
+
"@xylabs/sdk-js": "~5.0.97",
|
|
124
125
|
"react": "~19.2.4"
|
|
125
126
|
},
|
|
126
127
|
"engines": {
|