@xyo-network/react-chain-client 1.20.24 → 1.20.25

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.
Files changed (30) hide show
  1. package/dist/browser/context/GatewayContext.d.ts +20 -0
  2. package/dist/browser/context/GatewayContext.d.ts.map +1 -1
  3. package/dist/browser/context/GatewayProviderState.d.ts +20 -0
  4. package/dist/browser/context/GatewayProviderState.d.ts.map +1 -1
  5. package/dist/browser/context/in-page/InPageGatewaysContext.d.ts +16 -0
  6. package/dist/browser/context/in-page/InPageGatewaysContext.d.ts.map +1 -0
  7. package/dist/browser/context/in-page/InPageGatewaysState.d.ts +21 -0
  8. package/dist/browser/context/in-page/InPageGatewaysState.d.ts.map +1 -0
  9. package/dist/browser/context/in-page/index.d.ts +4 -0
  10. package/dist/browser/context/in-page/index.d.ts.map +1 -0
  11. package/dist/browser/context/in-page/useProvidedInPageGateways.d.ts +13 -0
  12. package/dist/browser/context/in-page/useProvidedInPageGateways.d.ts.map +1 -0
  13. package/dist/browser/context/index.d.ts +2 -1
  14. package/dist/browser/context/index.d.ts.map +1 -1
  15. package/dist/browser/context/providers/GatewayProvider.d.ts +47 -0
  16. package/dist/browser/context/providers/GatewayProvider.d.ts.map +1 -0
  17. package/dist/browser/context/{WalletGatewayProvider.d.ts → providers/WalletGatewayProvider.d.ts} +1 -1
  18. package/dist/browser/context/providers/WalletGatewayProvider.d.ts.map +1 -0
  19. package/dist/browser/context/providers/index.d.ts +3 -0
  20. package/dist/browser/context/providers/index.d.ts.map +1 -0
  21. package/dist/browser/context/providers/story/GatewayStatus.d.ts +9 -0
  22. package/dist/browser/context/providers/story/GatewayStatus.d.ts.map +1 -0
  23. package/dist/browser/context/providers/story/mockInPageGatewaysDecorator.d.ts +10 -0
  24. package/dist/browser/context/providers/story/mockInPageGatewaysDecorator.d.ts.map +1 -0
  25. package/dist/browser/context/useProvidedGateway.d.ts +12 -0
  26. package/dist/browser/context/useProvidedGateway.d.ts.map +1 -1
  27. package/dist/browser/index.mjs +80 -8
  28. package/dist/browser/index.mjs.map +1 -1
  29. package/package.json +4 -4
  30. package/dist/browser/context/WalletGatewayProvider.d.ts.map +0 -1
@@ -1,3 +1,23 @@
1
+ /**
2
+ * Shared React context that decouples gateway *sources* from gateway
3
+ * *consumers*. Any provider that can resolve an `XyoGateway` publishes to
4
+ * this context; any hook or component that needs a gateway reads from it
5
+ * via `useProvidedGateway`. Consumers never import a specific provider —
6
+ * they just require that *some* provider is mounted above them in the
7
+ * tree.
8
+ *
9
+ * Current publishers:
10
+ * - `WalletGatewayProvider` (this package) — sources gateways from the
11
+ * injected XL1 wallet extension.
12
+ * - `GatewayProvider` in `@xyo-network/react-chain-provider` — sources
13
+ * gateways built in-page against RPC endpoints, falling back to the
14
+ * wallet when available.
15
+ *
16
+ * To add a new source (e.g. a mock provider for tests, an iframe-bridged
17
+ * provider, a server-rendered provider), publish a `GatewayContextState`
18
+ * to this same context — do not create a parallel context, or consumers
19
+ * will silently stop receiving updates.
20
+ */
1
21
  export declare const GatewayContext: import("react").Context<(import("./GatewayProviderState.ts").GatewayStateFields & {
2
22
  provided: true;
3
23
  }) | (import("@xylabs/react-shared").FixedValues<import("@xylabs/react-shared").ProvidedContextExState<import("./GatewayProviderState.ts").GatewayStateFields>, never> & {
@@ -1 +1 @@
1
- {"version":3,"file":"GatewayContext.d.ts","sourceRoot":"","sources":["../../../src/context/GatewayContext.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,cAAc;;;;;;GAAyC,CAAA"}
1
+ {"version":3,"file":"GatewayContext.d.ts","sourceRoot":"","sources":["../../../src/context/GatewayContext.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,eAAO,MAAM,cAAc;;;;;;GAAyC,CAAA"}
@@ -1,5 +1,25 @@
1
1
  import type { ContextExState } from '@xylabs/react-shared';
2
2
  import type { ContextGatewayType } from '../types/index.ts';
3
+ /**
4
+ * The common surface area published to `GatewayContext`. Every gateway
5
+ * provider — wallet-backed, in-page, mock, or otherwise — must emit this
6
+ * shape so that consumers can ignore where the gateway came from.
7
+ *
8
+ * Fields use a three-state contract:
9
+ * - `undefined` — resolution is still in progress; show a loading state.
10
+ * - `null` — resolution completed and the gateway is definitively absent
11
+ * (e.g. no wallet installed, RPC unreachable); safe to show fallback UI.
12
+ * - `XyoGateway` — resolved and ready to use.
13
+ *
14
+ * `defaultGateway` is what most consumers want — the provider picks the
15
+ * best available source. `gateways` exposes the individual sources for
16
+ * the rare consumer that needs to differentiate (e.g. a debug panel, or
17
+ * a flow that must sign with the wallet specifically).
18
+ *
19
+ * `resetGatewaysFromConfig` is optional because not every provider has
20
+ * rebuildable in-page gateways (the wallet-only provider, for instance,
21
+ * has nothing to reset).
22
+ */
3
23
  export interface GatewayStateFields {
4
24
  defaultGateway: ContextGatewayType | undefined | null;
5
25
  error: Error | null | undefined;
@@ -1 +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"}
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;;;;;;;;;;;;;;;;;;;GAmBG;AACH,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,16 @@
1
+ /**
2
+ * Narrow, provider-internal context that `InPageGatewaysProvider` writes
3
+ * to and `GatewayProvider` reads from. Do not consume this in application
4
+ * code — use `useProvidedGateway` (which reads the shared
5
+ * `GatewayContext`) instead. This context only exists to decouple the
6
+ * single in-page *builder* from the many single-gateway *adapters* that
7
+ * sit between it and the shared gateway surface.
8
+ */
9
+ export declare const InPageGatewaysContext: import("react").Context<(import("./InPageGatewaysState.ts").InPageGatewaysStateFields & {
10
+ provided: true;
11
+ }) | (import("@xylabs/react-shared").FixedValues<import("@xylabs/react-shared").ProvidedContextExState<import("./InPageGatewaysState.ts").InPageGatewaysStateFields>, never> & {
12
+ provided: false;
13
+ }) | (import("@xylabs/react-shared").FixedValues<import("@xylabs/react-shared").NotProvidedContextExState<import("./InPageGatewaysState.ts").InPageGatewaysStateFields>, never> & {
14
+ provided: false;
15
+ })>;
16
+ //# sourceMappingURL=InPageGatewaysContext.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"InPageGatewaysContext.d.ts","sourceRoot":"","sources":["../../../../src/context/in-page/InPageGatewaysContext.ts"],"names":[],"mappings":"AAIA;;;;;;;GAOG;AACH,eAAO,MAAM,qBAAqB;;;;;;GAAyC,CAAA"}
@@ -0,0 +1,21 @@
1
+ import type { ContextExState } from '@xylabs/react-shared';
2
+ import type { GatewayName } from '@xyo-network/xl1-sdk';
3
+ import type { ContextGatewayType } from '../../types/index.ts';
4
+ /**
5
+ * Internal handoff shape published by `InPageGatewaysProvider` and
6
+ * consumed by `GatewayProvider`. Unlike `GatewayContextState`, this is a
7
+ * *map* of gateways keyed by network id — one builder near the tree root
8
+ * computes every network's gateway once, and individual `GatewayProvider`
9
+ * instances deeper in the tree pick out the one they need.
10
+ *
11
+ * This is not the cross-publisher surface area; consumers that want "a
12
+ * gateway" should read the shared `GatewayContext` via
13
+ * `useProvidedGateway`, not this map directly.
14
+ */
15
+ export interface InPageGatewaysStateFields {
16
+ clearAll: () => void;
17
+ errors: Partial<Record<GatewayName, Error>>;
18
+ gateways: Partial<Record<GatewayName, ContextGatewayType>>;
19
+ }
20
+ export type InPageGatewaysState = ContextExState<InPageGatewaysStateFields>;
21
+ //# sourceMappingURL=InPageGatewaysState.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"InPageGatewaysState.d.ts","sourceRoot":"","sources":["../../../../src/context/in-page/InPageGatewaysState.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AAC1D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAA;AAEvD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAA;AAE9D;;;;;;;;;;GAUG;AACH,MAAM,WAAW,yBAAyB;IACxC,QAAQ,EAAE,MAAM,IAAI,CAAA;IACpB,MAAM,EAAE,OAAO,CAAC,MAAM,CAAC,WAAW,EAAE,KAAK,CAAC,CAAC,CAAA;IAC3C,QAAQ,EAAE,OAAO,CAAC,MAAM,CAAC,WAAW,EAAE,kBAAkB,CAAC,CAAC,CAAA;CAC3D;AAED,MAAM,MAAM,mBAAmB,GAAG,cAAc,CAAC,yBAAyB,CAAC,CAAA"}
@@ -0,0 +1,4 @@
1
+ export * from './InPageGatewaysContext.ts';
2
+ export * from './InPageGatewaysState.ts';
3
+ export * from './useProvidedInPageGateways.ts';
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/context/in-page/index.ts"],"names":[],"mappings":"AAAA,cAAc,4BAA4B,CAAA;AAC1C,cAAc,0BAA0B,CAAA;AACxC,cAAc,gCAAgC,CAAA"}
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Reads the `InPageGatewaysContext` map of per-network in-page gateways.
3
+ * Intended for internal use by `GatewayProvider` — application code
4
+ * should prefer `useProvidedGateway`, which returns a single resolved
5
+ * gateway regardless of source.
6
+ *
7
+ * @param required - When `true` (default), throws if no
8
+ * `InPageGatewaysProvider` is mounted above.
9
+ */
10
+ export declare const useProvidedInPageGateways: (required?: boolean) => Omit<import("./InPageGatewaysState.ts").InPageGatewaysStateFields & {
11
+ provided: true;
12
+ }, "provided"> | Omit<import("@xylabs/react-shared").NotProvidedContextExState<import("./InPageGatewaysState.ts").InPageGatewaysState>, "provided">;
13
+ //# sourceMappingURL=useProvidedInPageGateways.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useProvidedInPageGateways.d.ts","sourceRoot":"","sources":["../../../../src/context/in-page/useProvidedInPageGateways.ts"],"names":[],"mappings":"AAIA;;;;;;;;GAQG;AACH,eAAO,MAAM,yBAAyB,GAAI,kBAAe;;mJAAoE,CAAA"}
@@ -1,6 +1,7 @@
1
1
  export * from './GatewayContext.ts';
2
2
  export * from './GatewayProviderProps.ts';
3
3
  export * from './GatewayProviderState.ts';
4
+ export * from './in-page/index.ts';
5
+ export * from './providers/index.ts';
4
6
  export * from './useProvidedGateway.ts';
5
- export * from './WalletGatewayProvider.tsx';
6
7
  //# sourceMappingURL=index.d.ts.map
@@ -1 +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"}
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,oBAAoB,CAAA;AAClC,cAAc,sBAAsB,CAAA;AACpC,cAAc,yBAAyB,CAAA"}
@@ -0,0 +1,47 @@
1
+ import React from 'react';
2
+ import type { GatewayProviderProps } from '../GatewayProviderProps.ts';
3
+ /**
4
+ * Publishes the shared `GatewayContext` backed by two sources: the
5
+ * injected XL1 Wallet extension *and* the in-page gateways built by
6
+ * `InPageGatewaysProvider`. Use this provider when the host app can
7
+ * function without a wallet (falling back to the in-page client) but
8
+ * should still prefer the wallet when it is present.
9
+ *
10
+ * Required ancestry: an `InPageGatewaysProvider` must be mounted above
11
+ * this provider — `useProvidedInPageGateways(true)` throws if missing.
12
+ * If you only need a wallet-backed gateway, use `WalletGatewayProvider`
13
+ * instead.
14
+ *
15
+ * Source precedence for `defaultGateway`:
16
+ * - Wallet present and resolved (`XyoGatewayRunner`) → wallet wins; the
17
+ * in-page gateway is still exposed via `gateways.inPageGateway` for
18
+ * the rare consumer that needs to target it specifically.
19
+ * - Wallet definitively absent (`null`) → fall back to the in-page
20
+ * gateway matching `gatewayName`.
21
+ * - Wallet still resolving (`undefined`) → leave `defaultGateway`
22
+ * `undefined` so consumers render a loading state rather than
23
+ * committing to the in-page fallback prematurely.
24
+ *
25
+ * The published `GatewayContextState` shape:
26
+ * - `defaultGateway` — resolved per the precedence above. Three-state:
27
+ * `undefined` = loading, `null` is not produced by this provider
28
+ * (wallet-null collapses to `gatewayFromConfig`), `XyoGateway` = ready.
29
+ * - `gateways.walletGateway` — raw wallet result (tri-state).
30
+ * - `gateways.inPageGateway` — raw in-page result for the requested
31
+ * `gatewayName`, or `undefined` if no `gatewayName` was passed.
32
+ * - `error` — first non-null of wallet error, then in-page build error
33
+ * for this `gatewayName`. Also rendered inline via `ErrorRender` above
34
+ * `children` so mount-time failures surface even when no consumer
35
+ * reads `error`.
36
+ * - `resetGatewaysFromConfig` — forwards `clearAll` from
37
+ * `InPageGatewaysProvider`, letting consumers force a rebuild of the
38
+ * in-page gateways (e.g. after a network or endpoint change).
39
+ * - `provided: true` — lets descendants detect a real provider in the
40
+ * tree.
41
+ *
42
+ * `defaultGateway`, `gateways`, and the context `value` are memoized so
43
+ * consumers only re-render when wallet or in-page sources actually
44
+ * change identity.
45
+ */
46
+ export declare const GatewayProvider: React.FC<GatewayProviderProps>;
47
+ //# sourceMappingURL=GatewayProvider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GatewayProvider.d.ts","sourceRoot":"","sources":["../../../../src/context/providers/GatewayProvider.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAkB,MAAM,OAAO,CAAA;AAItC,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAA;AAItE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0CG;AACH,eAAO,MAAM,eAAe,EAAE,KAAK,CAAC,EAAE,CAAC,oBAAoB,CAiE1D,CAAA"}
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import type { GatewayProviderProps } from './GatewayProviderProps.ts';
2
+ import type { GatewayProviderProps } from '../GatewayProviderProps.ts';
3
3
  /**
4
4
  * Publishes a `GatewayContext` backed exclusively by the injected XL1 Wallet
5
5
  * extension (i.e. `globalThis.xyo`). This is the provider to use when the
@@ -0,0 +1 @@
1
+ {"version":3,"file":"WalletGatewayProvider.d.ts","sourceRoot":"","sources":["../../../../src/context/providers/WalletGatewayProvider.tsx"],"names":[],"mappings":"AACA,OAAO,KAAkB,MAAM,OAAO,CAAA;AAItC,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAA;AAGtE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,eAAO,MAAM,qBAAqB,EAAE,KAAK,CAAC,EAAE,CAAC,oBAAoB,CAoChE,CAAA"}
@@ -0,0 +1,3 @@
1
+ export * from './GatewayProvider.tsx';
2
+ export * from './WalletGatewayProvider.tsx';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/context/providers/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAA;AACrC,cAAc,6BAA6B,CAAA"}
@@ -0,0 +1,9 @@
1
+ import React from 'react';
2
+ /**
3
+ * Consumer that reads `useProvidedGateway` and renders the resolved
4
+ * state in a way that interaction tests can query. Headings (`Gateway
5
+ * loaded`, `Gateway not available`, etc.) are stable strings so `play`
6
+ * functions can assert on them without depending on ARIA roles.
7
+ */
8
+ export declare const GatewayStatus: React.FC;
9
+ //# sourceMappingURL=GatewayStatus.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GatewayStatus.d.ts","sourceRoot":"","sources":["../../../../../src/context/providers/story/GatewayStatus.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,MAAM,OAAO,CAAA;AAIzB;;;;;GAKG;AACH,eAAO,MAAM,aAAa,EAAE,KAAK,CAAC,EA8CjC,CAAA"}
@@ -0,0 +1,10 @@
1
+ import type { Decorator } from '@storybook/react-vite';
2
+ /**
3
+ * Decorator that publishes a mock `InPageGatewaysContext` value so
4
+ * `GatewayProvider` can be exercised in isolation — without needing the
5
+ * real `InPageGatewaysProvider` (which depends on `buildGateway` from the
6
+ * provider package). Reads `inPageScenario` from story args to toggle
7
+ * between a populated map and an empty one.
8
+ */
9
+ export declare const WithMockInPageGateways: Decorator;
10
+ //# sourceMappingURL=mockInPageGatewaysDecorator.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mockInPageGatewaysDecorator.d.ts","sourceRoot":"","sources":["../../../../../src/context/providers/story/mockInPageGatewaysDecorator.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAA;AAiBtD;;;;;;GAMG;AACH,eAAO,MAAM,sBAAsB,EAAE,SAkBpC,CAAA"}
@@ -1,3 +1,15 @@
1
+ /**
2
+ * The sole consumer entry point for gateway state. Reads the nearest
3
+ * `GatewayContext` in the tree, regardless of which provider published
4
+ * it — this is the decoupling that lets a component work unchanged when
5
+ * the surrounding app swaps `WalletGatewayProvider` for
6
+ * `GatewayProvider` (or a test double).
7
+ *
8
+ * @param required - When `true` (default), throws if no gateway provider
9
+ * is mounted above — use this when the component is meaningless
10
+ * without a gateway. When `false`, returns default state (all fields
11
+ * undefined) so the component can render a graceful fallback.
12
+ */
1
13
  export declare const useProvidedGateway: (required?: boolean) => Omit<import("./GatewayProviderState.ts").GatewayStateFields & {
2
14
  provided: true;
3
15
  }, "provided"> | Omit<import("@xylabs/react-shared").NotProvidedContextExState<import("./GatewayProviderState.ts").GatewayContextState>, "provided">;
@@ -1 +1 @@
1
- {"version":3,"file":"useProvidedGateway.d.ts","sourceRoot":"","sources":["../../../src/context/useProvidedGateway.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,kBAAkB,GAAI,kBAAe;;oJAAsD,CAAA"}
1
+ {"version":3,"file":"useProvidedGateway.d.ts","sourceRoot":"","sources":["../../../src/context/useProvidedGateway.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,kBAAkB,GAAI,kBAAe;;oJAAsD,CAAA"}
@@ -309,16 +309,81 @@ var ConnectAccountsStack = /* @__PURE__ */ __name(({ AccountComponent = Connecte
309
309
  import { createContextEx } from "@xylabs/react-shared";
310
310
  var GatewayContext = createContextEx();
311
311
 
312
- // src/context/useProvidedGateway.ts
312
+ // src/context/in-page/InPageGatewaysContext.ts
313
+ import { createContextEx as createContextEx2 } from "@xylabs/react-shared";
314
+ var InPageGatewaysContext = createContextEx2();
315
+
316
+ // src/context/in-page/useProvidedInPageGateways.ts
313
317
  import { useContextEx } from "@xylabs/react-shared";
314
- var useProvidedGateway = /* @__PURE__ */ __name((required = true) => useContextEx(GatewayContext, "Gateway", required), "useProvidedGateway");
318
+ var useProvidedInPageGateways = /* @__PURE__ */ __name((required = true) => useContextEx(InPageGatewaysContext, "InPageGateways", required), "useProvidedInPageGateways");
315
319
 
316
- // src/context/WalletGatewayProvider.tsx
320
+ // src/context/providers/GatewayProvider.tsx
317
321
  import { ErrorRender as ErrorRender2 } from "@xylabs/react-error";
322
+ import { isDefinedNotNull as isDefinedNotNull2, isNull as isNull2 } from "@xylabs/sdk-js";
318
323
  import React3, { useMemo } from "react";
319
- var WalletGatewayProvider = /* @__PURE__ */ __name(({ gatewayName, children }) => {
324
+ var GatewayProvider = /* @__PURE__ */ __name(({ gatewayName, children }) => {
320
325
  const { gateway: gatewayFromWallet, error: gatewayFromWalletError } = useGatewayFromWallet(gatewayName);
326
+ const { gateways: allGateways, errors: allGatewayErrors, clearAll } = useProvidedInPageGateways(true);
327
+ const gatewayFromConfig = gatewayName ? allGateways[gatewayName] : void 0;
328
+ const gatewayFromConfigError = gatewayName ? allGatewayErrors[gatewayName] : void 0;
321
329
  const { defaultGateway, gateways } = useMemo(() => {
330
+ if (isNull2(gatewayFromWallet)) {
331
+ return {
332
+ defaultGateway: gatewayFromConfig,
333
+ gateways: {
334
+ inPageGateway: gatewayFromConfig,
335
+ walletGateway: null
336
+ }
337
+ };
338
+ } else if (isDefinedNotNull2(gatewayFromWallet)) {
339
+ return {
340
+ defaultGateway: gatewayFromWallet,
341
+ gateways: {
342
+ inPageGateway: gatewayFromConfig,
343
+ walletGateway: gatewayFromWallet
344
+ }
345
+ };
346
+ }
347
+ return {
348
+ defaultGateway: void 0,
349
+ gateways: {
350
+ inPageGateway: void 0,
351
+ walletGateway: void 0
352
+ }
353
+ };
354
+ }, [
355
+ gatewayFromConfig,
356
+ gatewayFromWallet
357
+ ]);
358
+ const value = useMemo(() => {
359
+ const value2 = {
360
+ defaultGateway,
361
+ error: gatewayFromWalletError || gatewayFromConfigError,
362
+ gateways,
363
+ provided: true,
364
+ resetGatewaysFromConfig: clearAll
365
+ };
366
+ return value2;
367
+ }, [
368
+ defaultGateway,
369
+ gatewayFromWalletError,
370
+ gatewayFromConfigError,
371
+ gateways,
372
+ clearAll
373
+ ]);
374
+ return /* @__PURE__ */ React3.createElement(GatewayContext, {
375
+ value
376
+ }, /* @__PURE__ */ React3.createElement(ErrorRender2, {
377
+ error: gatewayFromConfigError
378
+ }), children);
379
+ }, "GatewayProvider");
380
+
381
+ // src/context/providers/WalletGatewayProvider.tsx
382
+ import { ErrorRender as ErrorRender3 } from "@xylabs/react-error";
383
+ import React4, { useMemo as useMemo2 } from "react";
384
+ var WalletGatewayProvider = /* @__PURE__ */ __name(({ gatewayName, children }) => {
385
+ const { gateway: gatewayFromWallet, error: gatewayFromWalletError } = useGatewayFromWallet(gatewayName);
386
+ const { defaultGateway, gateways } = useMemo2(() => {
322
387
  return {
323
388
  defaultGateway: gatewayFromWallet,
324
389
  gateways: {
@@ -329,7 +394,7 @@ var WalletGatewayProvider = /* @__PURE__ */ __name(({ gatewayName, children }) =
329
394
  }, [
330
395
  gatewayFromWallet
331
396
  ]);
332
- const value = useMemo(() => {
397
+ const value = useMemo2(() => {
333
398
  const value2 = {
334
399
  defaultGateway,
335
400
  error: gatewayFromWalletError,
@@ -342,16 +407,22 @@ var WalletGatewayProvider = /* @__PURE__ */ __name(({ gatewayName, children }) =
342
407
  gatewayFromWalletError,
343
408
  gateways
344
409
  ]);
345
- return /* @__PURE__ */ React3.createElement(GatewayContext, {
410
+ return /* @__PURE__ */ React4.createElement(GatewayContext, {
346
411
  value
347
- }, /* @__PURE__ */ React3.createElement(ErrorRender2, {
412
+ }, /* @__PURE__ */ React4.createElement(ErrorRender3, {
348
413
  error: gatewayFromWalletError
349
414
  }), children);
350
415
  }, "WalletGatewayProvider");
416
+
417
+ // src/context/useProvidedGateway.ts
418
+ import { useContextEx as useContextEx2 } from "@xylabs/react-shared";
419
+ var useProvidedGateway = /* @__PURE__ */ __name((required = true) => useContextEx2(GatewayContext, "Gateway", required), "useProvidedGateway");
351
420
  export {
352
421
  ConnectAccountsStack,
353
422
  ConnectedAccount,
354
423
  GatewayContext,
424
+ GatewayProvider,
425
+ InPageGatewaysContext,
355
426
  WalletGatewayProvider,
356
427
  findCaveat,
357
428
  getXyoClient,
@@ -362,6 +433,7 @@ export {
362
433
  useGateway,
363
434
  useGatewayFromWallet,
364
435
  usePermissions,
365
- useProvidedGateway
436
+ useProvidedGateway,
437
+ useProvidedInPageGateways
366
438
  };
367
439
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
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 { 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\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 '@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"],"mappings":";;;;AAAA,SACEA,OAAOC,SAASC,kBACX;AACP,SAASC,yBAAyB;AAClC,SAASC,6BAA6B;AACtC,OAAOC,WAAW;AAEX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AAiBO;OAClB,MACHY,aAAYZ,OAAAA,KAAY,CAACG,WAEpB,gBAAA5B,OAAA,cAACoB,kBAAAA;IAAiBkB,SAAS,6BAAM,KAAKZ,cAAAA,GAAX;KAA4B,SAAA,IAEzD,MACHW,aAAYZ,OAAAA,KAAYG,WAEnB,gBAAA5B,OAAA,cAACqB,4BAAAA,IAAAA,IAEH,MACJ,gBAAArB,OAAA,cAACuC,aAAAA;IAAYZ;IAAca,OAAM;;AAGvC,GA3C+E;;;AQjF/E,SAASC,uBAAuB;AAIzB,IAAMC,iBAAiBD,gBAAAA;;;ACJ9B,SAASE,oBAAoB;AAItB,IAAMC,qBAAqB,wBAACC,WAAW,SAASC,aAAaC,gBAAgB,WAAWF,QAAAA,GAA7D;;;ACJlC,SAASG,eAAAA,oBAAmB;AAC5B,OAAOC,UAASC,eAAe;AAqCxB,IAAMC,wBAAwD,wBAAC,EAAEC,aAAaC,SAAQ,MAAE;AAC7F,QAAM,EACJC,SAASC,mBACTC,OAAOC,uBAAsB,IAC3BC,qBAAqBN,WAAAA;AAEzB,QAAM,EAAEO,gBAAgBC,SAAQ,IAAKC,QAAQ,MAAA;AAC3C,WAAO;MACLF,gBAAgBJ;MAChBK,UAAU;QACRE,eAAe;QACfC,eAAeR;MACjB;IACF;EACF,GAAG;IAACA;GAAkB;AAEtB,QAAMS,QAAQH,QAAQ,MAAA;AACpB,UAAMG,SAA6B;MACjCL;MACAH,OAAOC;MACPG;MACAK,UAAU;IACZ;AACA,WAAOD;EACT,GAAG;IACDL;IACAF;IACAG;GACD;AAED,SACE,gBAAAM,OAAA,cAACC,gBAAAA;IAAeH;KACd,gBAAAE,OAAA,cAACE,cAAAA;IAAYZ,OAAOC;MACnBJ,QAAAA;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","ErrorRender","isDefined","isUndefined","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"]}
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/in-page/InPageGatewaysContext.ts","../../src/context/in-page/useProvidedInPageGateways.ts","../../src/context/providers/GatewayProvider.tsx","../../src/context/providers/WalletGatewayProvider.tsx","../../src/context/useProvidedGateway.ts"],"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 { 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 { 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,SACEA,OAAOC,SAASC,kBACX;AACP,SAASC,yBAAyB;AAClC,SAASC,6BAA6B;AACtC,OAAOC,WAAW;AAEX,IAAMC,mBAAkD,wBAAC,EAAEC,QAAO,MAAE;AACzE,QAAMC,mBAAmB,GAAGC,kBAAkBC,WAAWH,OAAAA,GAAUI,cAAc,CAAA,CAAA;AAEjF,SACE,sBAAA,cAACC,OAAAA;IAAMC,WAAU;IAAMC,YAAW;IAASC,SAAS;KAClD,sBAAA,cAACC,uBAAAA;IAAsBT;IAAkBU,MAAM;MAC/C,sBAAA,cAACC,SAAAA;IAAQC,OAAOZ;KACd,sBAAA,cAACa,YAAAA;IAAWC,OAAM;IAAgBC,SAAQ;IAAUC,YAAW;KAAaf,gBAAAA,CAAAA,CAAAA;AAIpF,GAX+D;;;ACN/D,SACEgB,OAAOC,YAAYC,QAAQC,SAAAA,QAC3BC,cAAAA,mBACK;AAEP,SAASC,gBAAgB;AACzB,SAASC,mBAAmB;AAE5B,SAASC,aAAAA,YAAWC,eAAAA,oBAAmB;AAEvC,O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E;AAC7F,QAAM,EACJC,SAASC,mBACTC,OAAOC,uBAAsB,IAC3BC,qBAAqBN,WAAAA;AAEzB,QAAM,EAAEO,gBAAgBC,SAAQ,IAAKC,SAAQ,MAAA;AAC3C,WAAO;MACLF,gBAAgBJ;MAChBK,UAAU;QACRE,eAAe;QACfC,eAAeR;MACjB;IACF;EACF,GAAG;IAACA;GAAkB;AAEtB,QAAMS,QAAQH,SAAQ,MAAA;AACpB,UAAMG,SAA6B;MACjCL;MACAH,OAAOC;MACPG;MACAK,UAAU;IACZ;AACA,WAAOD;EACT,GAAG;IACDL;IACAF;IACAG;GACD;AAED,SACE,gBAAAM,OAAA,cAACC,gBAAAA;IAAeH;KACd,gBAAAE,OAAA,cAACE,cAAAA;IAAYZ,OAAOC;MACnBJ,QAAAA;AAGP,GApCqE;;;ACtCrE,SAASgB,gBAAAA,qBAAoB;AAgBtB,IAAMC,qBAAqB,wBAACC,WAAW,SAASC,cAAaC,gBAAgB,WAAWF,QAAAA,GAA7D;","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","ErrorRender","isDefined","isUndefined","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","createContextEx","InPageGatewaysContext","useContextEx","useProvidedInPageGateways","required","useContextEx","InPageGatewaysContext","ErrorRender","isDefinedNotNull","isNull","React","useMemo","GatewayProvider","gatewayName","children","gateway","gatewayFromWallet","error","gatewayFromWalletError","useGatewayFromWallet","gateways","allGateways","errors","allGatewayErrors","clearAll","useProvidedInPageGateways","gatewayFromConfig","undefined","gatewayFromConfigError","defaultGateway","useMemo","isNull","inPageGateway","walletGateway","isDefinedNotNull","value","provided","resetGatewaysFromConfig","React","GatewayContext","ErrorRender","ErrorRender","React","useMemo","WalletGatewayProvider","gatewayName","children","gateway","gatewayFromWallet","error","gatewayFromWalletError","useGatewayFromWallet","defaultGateway","gateways","useMemo","inPageGateway","walletGateway","value","provided","React","GatewayContext","ErrorRender","useContextEx","useProvidedGateway","required","useContextEx","GatewayContext"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xyo-network/react-chain-client",
3
- "version": "1.20.24",
3
+ "version": "1.20.25",
4
4
  "description": "XYO Layer One React SDK - Client/Wallet Hooks",
5
5
  "homepage": "https://xylabs.com",
6
6
  "bugs": {
@@ -42,7 +42,7 @@
42
42
  "@xylabs/react-error": "~7.1.20",
43
43
  "@xylabs/react-shared": "~7.1.20",
44
44
  "@xyo-network/xl1-sdk": "^1.26.36",
45
- "@xyo-network/react-chain-blockies": "~1.20.24"
45
+ "@xyo-network/react-chain-blockies": "~1.20.25"
46
46
  },
47
47
  "devDependencies": {
48
48
  "@emotion/react": "^11.5.0",
@@ -134,8 +134,8 @@
134
134
  "vite": "^8.0.9",
135
135
  "webextension-polyfill": "^0.10.0 || ^0.11.0 || ^0.12.0",
136
136
  "zod": "~4.3.6",
137
- "@xyo-network/react-chain-model": "~1.20.24",
138
- "@xyo-network/react-chain-shared": "~1.20.24"
137
+ "@xyo-network/react-chain-model": "~1.20.25",
138
+ "@xyo-network/react-chain-shared": "~1.20.25"
139
139
  },
140
140
  "peerDependencies": {
141
141
  "@mui/material": ">=6 <8",
@@ -1 +0,0 @@
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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,eAAO,MAAM,qBAAqB,EAAE,KAAK,CAAC,EAAE,CAAC,oBAAoB,CAoChE,CAAA"}