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

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 (34) 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/Provider.d.ts +60 -0
  10. package/dist/browser/context/in-page/Provider.d.ts.map +1 -0
  11. package/dist/browser/context/in-page/index.d.ts +5 -0
  12. package/dist/browser/context/in-page/index.d.ts.map +1 -0
  13. package/dist/browser/context/in-page/lib/buildGateway.d.ts +3 -0
  14. package/dist/browser/context/in-page/lib/buildGateway.d.ts.map +1 -0
  15. package/dist/browser/context/in-page/lib/index.d.ts +2 -0
  16. package/dist/browser/context/in-page/lib/index.d.ts.map +1 -0
  17. package/dist/browser/context/in-page/useProvidedInPageGateways.d.ts +13 -0
  18. package/dist/browser/context/in-page/useProvidedInPageGateways.d.ts.map +1 -0
  19. package/dist/browser/context/index.d.ts +2 -1
  20. package/dist/browser/context/index.d.ts.map +1 -1
  21. package/dist/browser/context/providers/GatewayProvider.d.ts +47 -0
  22. package/dist/browser/context/providers/GatewayProvider.d.ts.map +1 -0
  23. package/dist/browser/context/{WalletGatewayProvider.d.ts → providers/WalletGatewayProvider.d.ts} +1 -1
  24. package/dist/browser/context/providers/WalletGatewayProvider.d.ts.map +1 -0
  25. package/dist/browser/context/providers/index.d.ts +3 -0
  26. package/dist/browser/context/providers/index.d.ts.map +1 -0
  27. package/dist/browser/context/providers/story/GatewayStatus.d.ts +9 -0
  28. package/dist/browser/context/providers/story/GatewayStatus.d.ts.map +1 -0
  29. package/dist/browser/context/useProvidedGateway.d.ts +12 -0
  30. package/dist/browser/context/useProvidedGateway.d.ts.map +1 -1
  31. package/dist/browser/index.mjs +167 -9
  32. package/dist/browser/index.mjs.map +1 -1
  33. package/package.json +4 -4
  34. 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,60 @@
1
+ import type { RpcTransport, XyoSignerRpcSchemas } from '@xyo-network/xl1-sdk';
2
+ import type { PropsWithChildren } from 'react';
3
+ import React from 'react';
4
+ export interface InPageGatewaysProviderProps extends PropsWithChildren {
5
+ signerTransport?: RpcTransport<XyoSignerRpcSchemas>;
6
+ }
7
+ /**
8
+ * Publishes a keyed map of in-page gateways — one per network in
9
+ * `DefaultNetworks` — under the narrow `InPageGatewaysContext`.
10
+ *
11
+ * This provider is deliberately *not* a direct publisher of the shared
12
+ * `GatewayContext` that `useProvidedGateway` reads. Its consumer is the
13
+ * wrapping `GatewayProvider` in this same package, which picks the
14
+ * `gatewayName` the consumer asked for out of this map, adapts it into
15
+ * the single-gateway `GatewayContextState` shape, and then publishes *that*
16
+ * to the shared context. Splitting the work this way lets one
17
+ * `InPageGatewaysProvider` near the root build every network's gateway
18
+ * once, while many `GatewayProvider` instances deeper in the tree each
19
+ * expose whichever gateway their subtree cares about.
20
+ *
21
+ * Unlike `WalletGatewayProvider`, gateways here are constructed directly
22
+ * in the page (via `buildGateway`) against each network's RPC endpoint
23
+ * — no browser wallet extension is required. `signerTransport` switches
24
+ * between viewer (read-only) and runner (can sign/send) locators; supply
25
+ * it only when the app needs to sign.
26
+ *
27
+ * Behavior:
28
+ * - On mount, and whenever `signerTransport` changes, `buildGateway` is
29
+ * called in parallel for every network in `DefaultNetworks` via
30
+ * `Promise.allSettled`. Networks that resolve populate `gateways[id]`;
31
+ * networks that reject populate `errors[id]`. One failed network does
32
+ * not block the others.
33
+ * - If `signerTransport` is provided, gateways are built with a remote
34
+ * *runner* locator, otherwise with a remote *viewer* locator.
35
+ * - When `signerTransport` changes identity mid-life, the provider clears
36
+ * all cached gateways and errors synchronously during render (via
37
+ * `previousSignerTransport` state) so consumers never see gateways
38
+ * bound to the previous transport, then rebuilds in the effect.
39
+ * - State updates from the rebuild are wrapped in `startTransition` so a
40
+ * slow network doesn't stall higher-priority UI updates.
41
+ * - A `cancelled` flag in the effect's cleanup discards results from a
42
+ * prior `signerTransport` once a new one is in flight.
43
+ *
44
+ * Published `InPageGatewaysState` (narrower than `GatewayContextState` —
45
+ * this is an internal handoff shape, not the cross-publisher surface):
46
+ * - `gateways` — `Partial<Record<GatewayName, ContextGatewayType>>`. Keys
47
+ * are only present for networks that built successfully.
48
+ * - `errors` — `Partial<Record<GatewayName, Error>>`. Per-network build
49
+ * failures, keyed by `GatewayName`.
50
+ * - `clearAll()` — manually empties both maps. Also invoked internally on
51
+ * transport changes. Forwarded by `GatewayProvider` to consumers as
52
+ * `resetGatewaysFromConfig`.
53
+ * - `provided: true` — lets descendants detect a real provider.
54
+ *
55
+ * Note: the commented-out `SimpleXyoClient` at the top is intentionally
56
+ * disabled pending a type unification between `XyoGateway` and
57
+ * `XyoGatewayRunner`.
58
+ */
59
+ export declare const InPageGatewaysProvider: React.FC<InPageGatewaysProviderProps>;
60
+ //# sourceMappingURL=Provider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Provider.d.ts","sourceRoot":"","sources":["../../../../src/context/in-page/Provider.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACG,YAAY,EAAE,mBAAmB,EAC/C,MAAM,sBAAsB,CAAA;AAE7B,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAA;AAC9C,OAAO,KAGN,MAAM,OAAO,CAAA;AAOd,MAAM,WAAW,2BAA4B,SAAQ,iBAAiB;IACpE,eAAe,CAAC,EAAE,YAAY,CAAC,mBAAmB,CAAC,CAAA;CACpD;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmDG;AACH,eAAO,MAAM,sBAAsB,EAAE,KAAK,CAAC,EAAE,CAAC,2BAA2B,CAmExE,CAAA"}
@@ -0,0 +1,5 @@
1
+ export * from './InPageGatewaysContext.ts';
2
+ export * from './InPageGatewaysState.ts';
3
+ export * from './Provider.tsx';
4
+ export * from './useProvidedInPageGateways.ts';
5
+ //# 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,gBAAgB,CAAA;AAC9B,cAAc,gCAAgC,CAAA"}
@@ -0,0 +1,3 @@
1
+ import type { GatewayName, RpcTransport, SimpleXyoGateway, XyoSignerRpcSchemas } from '@xyo-network/xl1-sdk';
2
+ export declare const buildGateway: (gatewayName: GatewayName, signerTransport?: RpcTransport<XyoSignerRpcSchemas>) => Promise<import("@xyo-network/xl1-sdk").CreatableProviderInstance<SimpleXyoGateway>>;
3
+ //# sourceMappingURL=buildGateway.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"buildGateway.d.ts","sourceRoot":"","sources":["../../../../../src/context/in-page/lib/buildGateway.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,WAAW,EACG,YAAY,EAAE,gBAAgB,EAC5C,mBAAmB,EACpB,MAAM,sBAAsB,CAAA;AAO7B,eAAO,MAAM,YAAY,GAAU,aAAa,WAAW,EAAE,kBAAkB,YAAY,CAAC,mBAAmB,CAAC,wFAkB/G,CAAA"}
@@ -0,0 +1,2 @@
1
+ export * from './buildGateway.ts';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/context/in-page/lib/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,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"}
@@ -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,166 @@ 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/Provider.tsx
317
+ import { DefaultNetworks as DefaultNetworks2 } from "@xyo-network/xl1-sdk";
318
+ import React3, { startTransition, useCallback as useCallback2, useEffect as useEffect3, useMemo, useState as useState3 } from "react";
319
+
320
+ // src/context/in-page/lib/buildGateway.ts
321
+ import { assertEx as assertEx2, isDefined as isDefined4 } from "@xylabs/sdk-js";
322
+ import { basicRemoteRunnerLocator, basicRemoteViewerLocator, DefaultNetworks, NetworkDataLakeUrls, XyoGatewayMoniker } from "@xyo-network/xl1-sdk";
323
+ var buildGateway = /* @__PURE__ */ __name(async (gatewayName, signerTransport) => {
324
+ const network = DefaultNetworks.find((network2) => network2.id === gatewayName);
325
+ const resolvedNetwork = assertEx2(network, () => `No network found for id ${gatewayName}`);
326
+ const remoteConfig = {
327
+ rpc: {
328
+ protocol: "http",
329
+ url: `${resolvedNetwork.url}/rpc`
330
+ }
331
+ };
332
+ const dataLakeEndpoint = NetworkDataLakeUrls[gatewayName];
333
+ const locator = isDefined4(signerTransport) ? await basicRemoteRunnerLocator(gatewayName, remoteConfig, signerTransport, dataLakeEndpoint) : await basicRemoteViewerLocator(gatewayName, remoteConfig, dataLakeEndpoint);
334
+ return await locator.getInstance(XyoGatewayMoniker);
335
+ }, "buildGateway");
336
+
337
+ // src/context/in-page/Provider.tsx
338
+ var InPageGatewaysProvider = /* @__PURE__ */ __name(({ signerTransport, children }) => {
339
+ const [gateways, setGateways] = useState3({});
340
+ const [errors, setErrors] = useState3({});
341
+ const [previousSignerTransport, setPreviousSignerTransport] = useState3(signerTransport);
342
+ const clearAll = useCallback2(() => {
343
+ setGateways({});
344
+ setErrors({});
345
+ }, []);
346
+ if (previousSignerTransport !== signerTransport) {
347
+ clearAll();
348
+ setPreviousSignerTransport(signerTransport);
349
+ }
350
+ useEffect3(() => {
351
+ let cancelled = false;
352
+ const buildAll = /* @__PURE__ */ __name(async () => {
353
+ const results = await Promise.allSettled(DefaultNetworks2.map(async (network) => {
354
+ const gateway = await buildGateway(network.id, signerTransport);
355
+ return {
356
+ id: network.id,
357
+ gateway
358
+ };
359
+ }));
360
+ if (cancelled) return;
361
+ const nextGateways = {};
362
+ const nextErrors = {};
363
+ for (const [index, result] of results.entries()) {
364
+ const networkId = DefaultNetworks2[index].id;
365
+ if (result.status === "fulfilled") {
366
+ nextGateways[networkId] = result.value.gateway;
367
+ } else {
368
+ nextErrors[networkId] = result.reason instanceof Error ? result.reason : new Error(String(result.reason));
369
+ }
370
+ }
371
+ startTransition(() => {
372
+ setGateways(nextGateways);
373
+ setErrors(nextErrors);
374
+ });
375
+ }, "buildAll");
376
+ void buildAll();
377
+ return () => {
378
+ cancelled = true;
379
+ };
380
+ }, [
381
+ signerTransport
382
+ ]);
383
+ const value = useMemo(() => {
384
+ const value2 = {
385
+ clearAll,
386
+ errors,
387
+ gateways,
388
+ provided: true
389
+ };
390
+ return value2;
391
+ }, [
392
+ clearAll,
393
+ errors,
394
+ gateways
395
+ ]);
396
+ return /* @__PURE__ */ React3.createElement(InPageGatewaysContext, {
397
+ value
398
+ }, children);
399
+ }, "InPageGatewaysProvider");
400
+
401
+ // src/context/in-page/useProvidedInPageGateways.ts
313
402
  import { useContextEx } from "@xylabs/react-shared";
314
- var useProvidedGateway = /* @__PURE__ */ __name((required = true) => useContextEx(GatewayContext, "Gateway", required), "useProvidedGateway");
403
+ var useProvidedInPageGateways = /* @__PURE__ */ __name((required = true) => useContextEx(InPageGatewaysContext, "InPageGateways", required), "useProvidedInPageGateways");
315
404
 
316
- // src/context/WalletGatewayProvider.tsx
405
+ // src/context/providers/GatewayProvider.tsx
317
406
  import { ErrorRender as ErrorRender2 } from "@xylabs/react-error";
318
- import React3, { useMemo } from "react";
407
+ import { isDefinedNotNull as isDefinedNotNull2, isNull as isNull2 } from "@xylabs/sdk-js";
408
+ import React4, { useMemo as useMemo2 } from "react";
409
+ var GatewayProvider = /* @__PURE__ */ __name(({ gatewayName, children }) => {
410
+ const { gateway: gatewayFromWallet, error: gatewayFromWalletError } = useGatewayFromWallet(gatewayName);
411
+ const { gateways: allGateways, errors: allGatewayErrors, clearAll } = useProvidedInPageGateways(true);
412
+ const gatewayFromConfig = gatewayName ? allGateways[gatewayName] : void 0;
413
+ const gatewayFromConfigError = gatewayName ? allGatewayErrors[gatewayName] : void 0;
414
+ const { defaultGateway, gateways } = useMemo2(() => {
415
+ if (isNull2(gatewayFromWallet)) {
416
+ return {
417
+ defaultGateway: gatewayFromConfig,
418
+ gateways: {
419
+ inPageGateway: gatewayFromConfig,
420
+ walletGateway: null
421
+ }
422
+ };
423
+ } else if (isDefinedNotNull2(gatewayFromWallet)) {
424
+ return {
425
+ defaultGateway: gatewayFromWallet,
426
+ gateways: {
427
+ inPageGateway: gatewayFromConfig,
428
+ walletGateway: gatewayFromWallet
429
+ }
430
+ };
431
+ }
432
+ return {
433
+ defaultGateway: void 0,
434
+ gateways: {
435
+ inPageGateway: void 0,
436
+ walletGateway: void 0
437
+ }
438
+ };
439
+ }, [
440
+ gatewayFromConfig,
441
+ gatewayFromWallet
442
+ ]);
443
+ const value = useMemo2(() => {
444
+ const value2 = {
445
+ defaultGateway,
446
+ error: gatewayFromWalletError || gatewayFromConfigError,
447
+ gateways,
448
+ provided: true,
449
+ resetGatewaysFromConfig: clearAll
450
+ };
451
+ return value2;
452
+ }, [
453
+ defaultGateway,
454
+ gatewayFromWalletError,
455
+ gatewayFromConfigError,
456
+ gateways,
457
+ clearAll
458
+ ]);
459
+ return /* @__PURE__ */ React4.createElement(GatewayContext, {
460
+ value
461
+ }, /* @__PURE__ */ React4.createElement(ErrorRender2, {
462
+ error: gatewayFromConfigError
463
+ }), children);
464
+ }, "GatewayProvider");
465
+
466
+ // src/context/providers/WalletGatewayProvider.tsx
467
+ import { ErrorRender as ErrorRender3 } from "@xylabs/react-error";
468
+ import React5, { useMemo as useMemo3 } from "react";
319
469
  var WalletGatewayProvider = /* @__PURE__ */ __name(({ gatewayName, children }) => {
320
470
  const { gateway: gatewayFromWallet, error: gatewayFromWalletError } = useGatewayFromWallet(gatewayName);
321
- const { defaultGateway, gateways } = useMemo(() => {
471
+ const { defaultGateway, gateways } = useMemo3(() => {
322
472
  return {
323
473
  defaultGateway: gatewayFromWallet,
324
474
  gateways: {
@@ -329,7 +479,7 @@ var WalletGatewayProvider = /* @__PURE__ */ __name(({ gatewayName, children }) =
329
479
  }, [
330
480
  gatewayFromWallet
331
481
  ]);
332
- const value = useMemo(() => {
482
+ const value = useMemo3(() => {
333
483
  const value2 = {
334
484
  defaultGateway,
335
485
  error: gatewayFromWalletError,
@@ -342,16 +492,23 @@ var WalletGatewayProvider = /* @__PURE__ */ __name(({ gatewayName, children }) =
342
492
  gatewayFromWalletError,
343
493
  gateways
344
494
  ]);
345
- return /* @__PURE__ */ React3.createElement(GatewayContext, {
495
+ return /* @__PURE__ */ React5.createElement(GatewayContext, {
346
496
  value
347
- }, /* @__PURE__ */ React3.createElement(ErrorRender2, {
497
+ }, /* @__PURE__ */ React5.createElement(ErrorRender3, {
348
498
  error: gatewayFromWalletError
349
499
  }), children);
350
500
  }, "WalletGatewayProvider");
501
+
502
+ // src/context/useProvidedGateway.ts
503
+ import { useContextEx as useContextEx2 } from "@xylabs/react-shared";
504
+ var useProvidedGateway = /* @__PURE__ */ __name((required = true) => useContextEx2(GatewayContext, "Gateway", required), "useProvidedGateway");
351
505
  export {
352
506
  ConnectAccountsStack,
353
507
  ConnectedAccount,
354
508
  GatewayContext,
509
+ GatewayProvider,
510
+ InPageGatewaysContext,
511
+ InPageGatewaysProvider,
355
512
  WalletGatewayProvider,
356
513
  findCaveat,
357
514
  getXyoClient,
@@ -362,6 +519,7 @@ export {
362
519
  useGateway,
363
520
  useGatewayFromWallet,
364
521
  usePermissions,
365
- useProvidedGateway
522
+ useProvidedGateway,
523
+ useProvidedInPageGateways
366
524
  };
367
525
  //# 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,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,cAAC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AAA;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/Provider.tsx","../../src/context/in-page/lib/buildGateway.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 type {\n GatewayName, RpcTransport, XyoSignerRpcSchemas,\n} from '@xyo-network/xl1-sdk'\nimport { DefaultNetworks } from '@xyo-network/xl1-sdk'\nimport type { PropsWithChildren } from 'react'\nimport React, {\n startTransition,\n useCallback, useEffect, useMemo, useState,\n} from 'react'\n\nimport type { ContextGatewayType } from '../../types/index.ts'\nimport { InPageGatewaysContext } from './InPageGatewaysContext.ts'\nimport type { InPageGatewaysState } from './InPageGatewaysState.ts'\nimport { buildGateway } from './lib/index.ts'\n\nexport interface InPageGatewaysProviderProps extends PropsWithChildren {\n signerTransport?: RpcTransport<XyoSignerRpcSchemas>\n}\n\n/**\n * Publishes a keyed map of in-page gateways — one per network in\n * `DefaultNetworks` — under the narrow `InPageGatewaysContext`.\n *\n * This provider is deliberately *not* a direct publisher of the shared\n * `GatewayContext` that `useProvidedGateway` reads. Its consumer is the\n * wrapping `GatewayProvider` in this same package, which picks the\n * `gatewayName` the consumer asked for out of this map, adapts it into\n * the single-gateway `GatewayContextState` shape, and then publishes *that*\n * to the shared context. Splitting the work this way lets one\n * `InPageGatewaysProvider` near the root build every network's gateway\n * once, while many `GatewayProvider` instances deeper in the tree each\n * expose whichever gateway their subtree cares about.\n *\n * Unlike `WalletGatewayProvider`, gateways here are constructed directly\n * in the page (via `buildGateway`) against each network's RPC endpoint\n * — no browser wallet extension is required. `signerTransport` switches\n * between viewer (read-only) and runner (can sign/send) locators; supply\n * it only when the app needs to sign.\n *\n * Behavior:\n * - On mount, and whenever `signerTransport` changes, `buildGateway` is\n * called in parallel for every network in `DefaultNetworks` via\n * `Promise.allSettled`. Networks that resolve populate `gateways[id]`;\n * networks that reject populate `errors[id]`. One failed network does\n * not block the others.\n * - If `signerTransport` is provided, gateways are built with a remote\n * *runner* locator, otherwise with a remote *viewer* locator.\n * - When `signerTransport` changes identity mid-life, the provider clears\n * all cached gateways and errors synchronously during render (via\n * `previousSignerTransport` state) so consumers never see gateways\n * bound to the previous transport, then rebuilds in the effect.\n * - State updates from the rebuild are wrapped in `startTransition` so a\n * slow network doesn't stall higher-priority UI updates.\n * - A `cancelled` flag in the effect's cleanup discards results from a\n * prior `signerTransport` once a new one is in flight.\n *\n * Published `InPageGatewaysState` (narrower than `GatewayContextState` —\n * this is an internal handoff shape, not the cross-publisher surface):\n * - `gateways` — `Partial<Record<GatewayName, ContextGatewayType>>`. Keys\n * are only present for networks that built successfully.\n * - `errors` — `Partial<Record<GatewayName, Error>>`. Per-network build\n * failures, keyed by `GatewayName`.\n * - `clearAll()` — manually empties both maps. Also invoked internally on\n * transport changes. Forwarded by `GatewayProvider` to consumers as\n * `resetGatewaysFromConfig`.\n * - `provided: true` — lets descendants detect a real provider.\n *\n * Note: the commented-out `SimpleXyoClient` at the top is intentionally\n * disabled pending a type unification between `XyoGateway` and\n * `XyoGatewayRunner`.\n */\nexport const InPageGatewaysProvider: React.FC<InPageGatewaysProviderProps> = ({ signerTransport, children }) => {\n const [gateways, setGateways] = useState<Partial<Record<GatewayName, ContextGatewayType>>>({})\n const [errors, setErrors] = useState<Partial<Record<GatewayName, Error>>>({})\n const [previousSignerTransport, setPreviousSignerTransport] = useState<RpcTransport<XyoSignerRpcSchemas> | undefined>(signerTransport)\n\n // This can come back once we homogenize the type for XyoGateway.\n // Right now, SimpleXyoClient takes XyoGatewayRunners but ideally it would take XyoGateway.\n // const clientInPage = useMemo(() => new SimpleXyoClient(gateways, {}), [gateways])\n\n const clearAll = useCallback(() => {\n setGateways({})\n setErrors({})\n }, [])\n\n if (previousSignerTransport !== signerTransport) {\n clearAll()\n setPreviousSignerTransport(signerTransport)\n }\n\n useEffect(() => {\n let cancelled = false\n\n const buildAll = async () => {\n const results = await Promise.allSettled(\n DefaultNetworks.map(async (network) => {\n const gateway = await buildGateway(network.id as GatewayName, signerTransport)\n return { id: network.id as GatewayName, gateway }\n }),\n )\n\n if (cancelled) return\n\n const nextGateways: Partial<Record<GatewayName, ContextGatewayType>> = {}\n const nextErrors: Partial<Record<GatewayName, Error>> = {}\n\n for (const [index, result] of results.entries()) {\n const networkId = DefaultNetworks[index].id as GatewayName\n if (result.status === 'fulfilled') {\n nextGateways[networkId] = result.value.gateway\n } else {\n nextErrors[networkId] = result.reason instanceof Error ? result.reason : new Error(String(result.reason))\n }\n }\n\n startTransition(() => {\n setGateways(nextGateways)\n setErrors(nextErrors)\n })\n }\n\n void buildAll()\n return () => {\n cancelled = true\n }\n }, [signerTransport])\n\n const value = useMemo(() => {\n const value: InPageGatewaysState = {\n clearAll,\n errors,\n gateways,\n provided: true,\n }\n return value\n }, [clearAll, errors, gateways])\n\n return <InPageGatewaysContext value={value}>{children}</InPageGatewaysContext>\n}\n","import { assertEx, isDefined } from '@xylabs/sdk-js'\nimport type {\n GatewayName,\n RemoteConfig, RpcTransport, SimpleXyoGateway,\n XyoSignerRpcSchemas,\n} from '@xyo-network/xl1-sdk'\nimport {\n basicRemoteRunnerLocator,\n basicRemoteViewerLocator,\n DefaultNetworks, NetworkDataLakeUrls, XyoGatewayMoniker,\n} from '@xyo-network/xl1-sdk'\n\nexport const buildGateway = async (gatewayName: GatewayName, signerTransport?: RpcTransport<XyoSignerRpcSchemas>) => {\n const network = DefaultNetworks.find(network => network.id === gatewayName)\n const resolvedNetwork = assertEx(network, () => `No network found for id ${gatewayName}`)\n\n const remoteConfig: RemoteConfig = {\n rpc: {\n protocol: 'http',\n url: `${resolvedNetwork.url}/rpc`,\n },\n }\n\n const dataLakeEndpoint = NetworkDataLakeUrls[gatewayName]\n\n const locator = isDefined(signerTransport)\n ? await basicRemoteRunnerLocator(gatewayName, remoteConfig, signerTransport, dataLakeEndpoint)\n : await basicRemoteViewerLocator(gatewayName, remoteConfig, dataLakeEndpoint)\n\n return await locator.getInstance<SimpleXyoGateway>(XyoGatewayMoniker)\n}\n","import { useContextEx } from '@xylabs/react-shared'\n\nimport { InPageGatewaysContext } from './InPageGatewaysContext.ts'\n\n/**\n * Reads the `InPageGatewaysContext` map of per-network in-page gateways.\n * Intended for internal use by `GatewayProvider` — application code\n * should prefer `useProvidedGateway`, which returns a single resolved\n * gateway regardless of source.\n *\n * @param required - When `true` (default), throws if no\n * `InPageGatewaysProvider` is mounted above.\n */\nexport const useProvidedInPageGateways = (required = true) => useContextEx(InPageGatewaysContext, 'InPageGateways', required)\n","import { ErrorRender } from '@xylabs/react-error'\nimport { isDefinedNotNull, isNull } from '@xylabs/sdk-js'\nimport React, { useMemo } from 'react'\n\nimport { useGatewayFromWallet } from '../../hooks/index.ts'\nimport { GatewayContext } from '../GatewayContext.ts'\nimport type { GatewayProviderProps } from '../GatewayProviderProps.ts'\nimport type { GatewayContextState } from '../GatewayProviderState.ts'\nimport { useProvidedInPageGateways } from '../in-page/index.ts'\n\n/**\n * Publishes the shared `GatewayContext` backed by two sources: the\n * injected XL1 Wallet extension *and* the in-page gateways built by\n * `InPageGatewaysProvider`. Use this provider when the host app can\n * function without a wallet (falling back to the in-page client) but\n * should still prefer the wallet when it is present.\n *\n * Required ancestry: an `InPageGatewaysProvider` must be mounted above\n * this provider — `useProvidedInPageGateways(true)` throws if missing.\n * If you only need a wallet-backed gateway, use `WalletGatewayProvider`\n * instead.\n *\n * Source precedence for `defaultGateway`:\n * - Wallet present and resolved (`XyoGatewayRunner`) → wallet wins; the\n * in-page gateway is still exposed via `gateways.inPageGateway` for\n * the rare consumer that needs to target it specifically.\n * - Wallet definitively absent (`null`) → fall back to the in-page\n * gateway matching `gatewayName`.\n * - Wallet still resolving (`undefined`) → leave `defaultGateway`\n * `undefined` so consumers render a loading state rather than\n * committing to the in-page fallback prematurely.\n *\n * The published `GatewayContextState` shape:\n * - `defaultGateway` — resolved per the precedence above. Three-state:\n * `undefined` = loading, `null` is not produced by this provider\n * (wallet-null collapses to `gatewayFromConfig`), `XyoGateway` = ready.\n * - `gateways.walletGateway` — raw wallet result (tri-state).\n * - `gateways.inPageGateway` — raw in-page result for the requested\n * `gatewayName`, or `undefined` if no `gatewayName` was passed.\n * - `error` — first non-null of wallet error, then in-page build error\n * for this `gatewayName`. Also rendered inline via `ErrorRender` above\n * `children` so mount-time failures surface even when no consumer\n * reads `error`.\n * - `resetGatewaysFromConfig` — forwards `clearAll` from\n * `InPageGatewaysProvider`, letting consumers force a rebuild of the\n * in-page gateways (e.g. after a network or endpoint change).\n * - `provided: true` — lets descendants detect a real provider in the\n * tree.\n *\n * `defaultGateway`, `gateways`, and the context `value` are memoized so\n * consumers only re-render when wallet or in-page sources actually\n * change identity.\n */\nexport const GatewayProvider: React.FC<GatewayProviderProps> = ({ gatewayName, children }) => {\n const {\n gateway: gatewayFromWallet,\n error: gatewayFromWalletError,\n } = useGatewayFromWallet(gatewayName)\n\n const {\n gateways: allGateways,\n errors: allGatewayErrors,\n clearAll,\n } = useProvidedInPageGateways(true)\n\n const gatewayFromConfig = gatewayName ? allGateways[gatewayName] : undefined\n const gatewayFromConfigError = gatewayName ? allGatewayErrors[gatewayName] : undefined\n\n const { defaultGateway, gateways } = useMemo(() => {\n if (isNull(gatewayFromWallet)) {\n return {\n defaultGateway: gatewayFromConfig,\n gateways: {\n inPageGateway: gatewayFromConfig,\n walletGateway: null,\n },\n }\n } else if (isDefinedNotNull(gatewayFromWallet)) {\n return {\n defaultGateway: gatewayFromWallet,\n gateways: {\n inPageGateway: gatewayFromConfig,\n walletGateway: gatewayFromWallet,\n },\n }\n }\n return {\n defaultGateway: undefined,\n gateways: {\n inPageGateway: undefined,\n walletGateway: undefined,\n },\n }\n }, [gatewayFromConfig, gatewayFromWallet])\n\n const value = useMemo(() => {\n const value: GatewayContextState = {\n defaultGateway,\n error: gatewayFromWalletError || gatewayFromConfigError,\n gateways,\n provided: true,\n resetGatewaysFromConfig: clearAll,\n }\n return value\n }, [\n defaultGateway,\n gatewayFromWalletError,\n gatewayFromConfigError,\n gateways,\n clearAll,\n ])\n\n return (\n <GatewayContext value={value}>\n <ErrorRender error={gatewayFromConfigError} />\n {children}\n </GatewayContext>\n )\n}\n","import { ErrorRender } from '@xylabs/react-error'\nimport React, { useMemo } from 'react'\n\nimport { useGatewayFromWallet } from '../../hooks/index.ts'\nimport { GatewayContext } from '../GatewayContext.ts'\nimport type { GatewayProviderProps } from '../GatewayProviderProps.ts'\nimport type { GatewayContextState } from '../GatewayProviderState.ts'\n\n/**\n * Publishes a `GatewayContext` backed exclusively by the injected XL1 Wallet\n * extension (i.e. `globalThis.xyo`). This is the provider to use when the\n * host app is a browser UI that expects the user to bring their own wallet,\n * rather than running an in-page gateway.\n *\n * The requested `gatewayName` is forwarded to `useGatewayFromWallet`, whose\n * returned gateway uses a three-state contract (`undefined` = still\n * resolving, `null` = wallet confirmed absent / timed out,\n * `XyoGatewayRunner` = ready). That tri-state is passed through to\n * consumers unchanged as `defaultGateway` / `gateways.walletGateway`, so\n * downstream hooks can distinguish \"loading\" from \"missing\".\n *\n * The published `GatewayContextState` shape:\n * - `defaultGateway` — the wallet gateway, used when consumers don't\n * specify which gateway they want.\n * - `gateways.walletGateway` — same instance as `defaultGateway`.\n * - `gateways.inPageGateway` — always `null` here; this provider does not\n * stand up an in-page client. Pair with a different provider if you need\n * both.\n * - `error` — surfaced from `useGatewayFromWallet` (detection / timeout /\n * wallet errors). Also rendered inline via `ErrorRender` above `children`\n * so mount-time failures are visible even if no consumer reads `error`.\n * - `provided: true` — lets descendants detect that a real provider (not\n * the default empty context) is in the tree.\n *\n * The `defaultGateway`, `gateways`, and context `value` are memoized so\n * consumers only re-render when the underlying wallet gateway reference or\n * error actually changes.\n */\nexport const WalletGatewayProvider: React.FC<GatewayProviderProps> = ({ gatewayName, children }) => {\n const {\n gateway: gatewayFromWallet,\n error: gatewayFromWalletError,\n } = useGatewayFromWallet(gatewayName)\n\n const { defaultGateway, gateways } = useMemo(() => {\n return {\n defaultGateway: gatewayFromWallet,\n gateways: {\n inPageGateway: null,\n walletGateway: gatewayFromWallet,\n },\n }\n }, [gatewayFromWallet])\n\n const value = useMemo(() => {\n const value: GatewayContextState = {\n defaultGateway,\n error: gatewayFromWalletError,\n gateways,\n provided: true,\n }\n return value\n }, [\n defaultGateway,\n gatewayFromWalletError,\n gateways,\n ])\n\n return (\n <GatewayContext value={value}>\n <ErrorRender error={gatewayFromWalletError} />\n {children}\n </GatewayContext>\n )\n}\n","import { useContextEx } from '@xylabs/react-shared'\n\nimport { GatewayContext } from './GatewayContext.ts'\n\n/**\n * The sole consumer entry point for gateway state. Reads the nearest\n * `GatewayContext` in the tree, regardless of which provider published\n * it — this is the decoupling that lets a component work unchanged when\n * the surrounding app swaps `WalletGatewayProvider` for\n * `GatewayProvider` (or a test double).\n *\n * @param required - When `true` (default), throws if no gateway provider\n * is mounted above — use this when the component is meaningless\n * without a gateway. When `false`, returns default state (all fields\n * undefined) so the component can render a graceful fallback.\n */\nexport const useProvidedGateway = (required = true) => useContextEx(GatewayContext, 'Gateway', required)\n"],"mappings":";;;;AAAA,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,OAAOC,UAASC,aAAAA,kBAAiB;;;ACXjC,SAAuBC,iBAAiB;AACxC,SAASC,gBAAgB;AAEzB,SAASC,mBAAmB;AAC5B,SAASC,aAAaC,YAAAA,iBAAgB;;;ACJtC,SAASC,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,M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AAaC,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","DefaultNetworks","React","startTransition","useCallback","useEffect","useMemo","useState","assertEx","isDefined","basicRemoteRunnerLocator","basicRemoteViewerLocator","DefaultNetworks","NetworkDataLakeUrls","XyoGatewayMoniker","buildGateway","gatewayName","signerTransport","network","DefaultNetworks","find","id","resolvedNetwork","assertEx","remoteConfig","rpc","protocol","url","dataLakeEndpoint","NetworkDataLakeUrls","locator","isDefined","basicRemoteRunnerLocator","basicRemoteViewerLocator","getInstance","XyoGatewayMoniker","InPageGatewaysProvider","signerTransport","children","gateways","setGateways","useState","errors","setErrors","previousSignerTransport","setPreviousSignerTransport","clearAll","useCallback","useEffect","cancelled","buildAll","results","Promise","allSettled","DefaultNetworks","map","network","gateway","buildGateway","id","nextGateways","nextErrors","index","result","entries","networkId","status","value","reason","Error","String","startTransition","useMemo","provided","React","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.26",
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.26"
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.26",
138
+ "@xyo-network/react-chain-shared": "~1.20.26"
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"}