@xyo-network/xl1-react-client-sdk 4.4.0 → 4.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser/client/context/in-page/Provider.d.ts +1 -0
- package/dist/browser/client/context/in-page/Provider.d.ts.map +1 -1
- package/dist/browser/client/context/in-page/index.d.ts +1 -0
- package/dist/browser/client/context/in-page/index.d.ts.map +1 -1
- package/dist/browser/client/context/in-page/lib/buildGateway.d.ts +21 -2
- package/dist/browser/client/context/in-page/lib/buildGateway.d.ts.map +1 -1
- package/dist/browser/client/context/in-page/story/CurrentBlockRow.d.ts +19 -0
- package/dist/browser/client/context/in-page/story/CurrentBlockRow.d.ts.map +1 -0
- package/dist/browser/client/index.mjs +41 -22
- package/dist/browser/client/index.mjs.map +4 -4
- package/dist/browser/index.mjs +41 -22
- package/dist/browser/index.mjs.map +4 -4
- package/package.json +5 -4
|
@@ -2,6 +2,7 @@ import type { CreatableProviderFactory, RpcTransport, XyoSignerRpcSchemas } from
|
|
|
2
2
|
import type { PropsWithChildren } from 'react';
|
|
3
3
|
import React from 'react';
|
|
4
4
|
export interface InPageGatewaysProviderProps extends PropsWithChildren {
|
|
5
|
+
localEndpoint?: string;
|
|
5
6
|
signerFactory?: CreatableProviderFactory;
|
|
6
7
|
signerTransport?: RpcTransport<XyoSignerRpcSchemas>;
|
|
7
8
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Provider.d.ts","sourceRoot":"","sources":["../../../../../src/client/context/in-page/Provider.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,wBAAwB,EACX,YAAY,EAAE,mBAAmB,EAC/C,MAAM,sBAAsB,CAAA;AAE7B,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAA;AAC9C,OAAO,KAGN,MAAM,OAAO,CAAA;
|
|
1
|
+
{"version":3,"file":"Provider.d.ts","sourceRoot":"","sources":["../../../../../src/client/context/in-page/Provider.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,wBAAwB,EACX,YAAY,EAAE,mBAAmB,EAC/C,MAAM,sBAAsB,CAAA;AAE7B,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAA;AAC9C,OAAO,KAGN,MAAM,OAAO,CAAA;AAUd,MAAM,WAAW,2BAA4B,SAAQ,iBAAiB;IAEpE,aAAa,CAAC,EAAE,MAAM,CAAA;IAEtB,aAAa,CAAC,EAAE,wBAAwB,CAAA;IAExC,eAAe,CAAC,EAAE,YAAY,CAAC,mBAAmB,CAAC,CAAA;CACpD;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmDG;AACH,eAAO,MAAM,sBAAsB,EAAE,KAAK,CAAC,EAAE,CAAC,2BAA2B,CAuExE,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/client/context/in-page/index.ts"],"names":[],"mappings":"AAAA,cAAc,4BAA4B,CAAA;AAC1C,cAAc,0BAA0B,CAAA;AACxC,cAAc,gBAAgB,CAAA;AAC9B,cAAc,gCAAgC,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/client/context/in-page/index.ts"],"names":[],"mappings":"AAAA,cAAc,4BAA4B,CAAA;AAC1C,cAAc,0BAA0B,CAAA;AACxC,cAAc,gBAAgB,CAAA;AAC9B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,gCAAgC,CAAA"}
|
|
@@ -1,3 +1,22 @@
|
|
|
1
|
-
import type { CreatableProviderFactory, GatewayName, RpcTransport,
|
|
2
|
-
|
|
1
|
+
import type { CreatableProviderFactory, GatewayName, RpcTransport, XyoSignerRpcSchemas } from '@xyo-network/xl1-sdk';
|
|
2
|
+
import type { ContextGatewayType } from '../../../types/index.ts';
|
|
3
|
+
/**
|
|
4
|
+
* Builds a single in-page gateway for `gatewayName`, backed by the network's static REST/S3
|
|
5
|
+
* layout for chain reads. When a signing capability is supplied it returns a write-capable
|
|
6
|
+
* `XyoGatewayRunner` (mempool submission over the RPC endpoint); otherwise a read-only
|
|
7
|
+
* `XyoGateway`.
|
|
8
|
+
*
|
|
9
|
+
* The static REST layout and the RPC mempool endpoint live at different hosts: chain reads come
|
|
10
|
+
* from the per-network `<gatewayName>.xyo.space` root (blocks./state./indexes. subdomains derived
|
|
11
|
+
* from it), while transaction submission goes to the network's RPC url (`network.url` + `/rpc`).
|
|
12
|
+
* The local network is the exception — it reads a path-based layout (`/blocks`, `/state`,
|
|
13
|
+
* `/indexes`) served by `localEndpoint`, since there is no published `local.xyo.space` host.
|
|
14
|
+
*
|
|
15
|
+
* - `localEndpoint` — the REST/S3 root the local network reads from (path-based buckets). Unused
|
|
16
|
+
* for other networks, whose buckets are derived from `<gatewayName>.xyo.space`.
|
|
17
|
+
* - `signerTransport` — an RPC transport to a remote signer, for pages that don't own a signer.
|
|
18
|
+
* - `signerFactory` — a pre-built in-page local signer provider. Takes precedence over
|
|
19
|
+
* `signerTransport` when both are supplied (matches the runner locator's own ordering).
|
|
20
|
+
*/
|
|
21
|
+
export declare const buildGateway: (gatewayName: GatewayName, localEndpoint: string, signerTransport?: RpcTransport<XyoSignerRpcSchemas>, signerFactory?: CreatableProviderFactory) => Promise<ContextGatewayType>;
|
|
3
22
|
//# sourceMappingURL=buildGateway.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buildGateway.d.ts","sourceRoot":"","sources":["../../../../../../src/client/context/in-page/lib/buildGateway.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,wBAAwB,EACxB,WAAW,
|
|
1
|
+
{"version":3,"file":"buildGateway.d.ts","sourceRoot":"","sources":["../../../../../../src/client/context/in-page/lib/buildGateway.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,wBAAwB,EACxB,WAAW,EAEX,YAAY,EACZ,mBAAmB,EACpB,MAAM,sBAAsB,CAAA;AAS7B,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAA;AAEjE;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,YAAY,GACvB,aAAa,WAAW,EACxB,eAAe,MAAM,EACrB,kBAAkB,YAAY,CAAC,mBAAmB,CAAC,EACnD,gBAAgB,wBAAwB,KACvC,OAAO,CAAC,kBAAkB,CA6B5B,CAAA"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { GatewayName } from '@xyo-network/xl1-sdk';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
export interface CurrentBlockRowProps {
|
|
4
|
+
id: GatewayName;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Reads one network's in-page gateway out of `InPageGatewaysContext` and
|
|
8
|
+
* proves it is reachable by calling
|
|
9
|
+
* `gateway.connection.viewer.block.currentBlockNumber()`.
|
|
10
|
+
*
|
|
11
|
+
* Status strings are stable so story `play` functions can assert on them:
|
|
12
|
+
* - `<id> building gateway…` — the provider hasn't produced a gateway yet.
|
|
13
|
+
* - `<id> build failed: …` — the provider recorded a build error.
|
|
14
|
+
* - `<id> reading current block…` — gateway present, block read in flight.
|
|
15
|
+
* - `<id> reachable — block <n>` — the block viewer returned a number.
|
|
16
|
+
* - `<id> unreachable: …` — the block read threw.
|
|
17
|
+
*/
|
|
18
|
+
export declare const CurrentBlockRow: React.FC<CurrentBlockRowProps>;
|
|
19
|
+
//# sourceMappingURL=CurrentBlockRow.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CurrentBlockRow.d.ts","sourceRoot":"","sources":["../../../../../../src/client/context/in-page/story/CurrentBlockRow.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAA;AACvD,OAAO,KAAmB,MAAM,OAAO,CAAA;AAIvC,MAAM,WAAW,oBAAoB;IACnC,EAAE,EAAE,WAAW,CAAA;CAChB;AAED;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,eAAe,EAAE,KAAK,CAAC,EAAE,CAAC,oBAAoB,CAoD1D,CAAA"}
|
|
@@ -2149,38 +2149,56 @@ var GatewayContext = createContextEx();
|
|
|
2149
2149
|
import { createContextEx as createContextEx2 } from "@ariestools/sdk-react";
|
|
2150
2150
|
var InPageGatewaysContext = createContextEx2();
|
|
2151
2151
|
|
|
2152
|
-
// src/client/context/in-page/Provider.tsx
|
|
2153
|
-
import { DefaultNetworks as DefaultNetworks2 } from "@xyo-network/xl1-sdk";
|
|
2154
|
-
import {
|
|
2155
|
-
startTransition,
|
|
2156
|
-
useCallback as useCallback6,
|
|
2157
|
-
useEffect as useEffect5,
|
|
2158
|
-
useMemo as useMemo6,
|
|
2159
|
-
useState as useState15
|
|
2160
|
-
} from "react";
|
|
2161
|
-
|
|
2162
2152
|
// src/client/context/in-page/lib/buildGateway.ts
|
|
2163
2153
|
import { assertEx as assertEx3, isDefined as isDefined14 } from "@ariestools/sdk";
|
|
2164
2154
|
import {
|
|
2165
|
-
basicRemoteRunnerLocator,
|
|
2166
|
-
basicRemoteViewerLocator,
|
|
2167
2155
|
DefaultNetworks,
|
|
2168
|
-
|
|
2156
|
+
getRestGateway,
|
|
2157
|
+
getRestGatewayRunner,
|
|
2158
|
+
LocalNetwork as LocalNetwork2,
|
|
2159
|
+
restGatewayConfigFromEndpoint
|
|
2169
2160
|
} from "@xyo-network/xl1-sdk";
|
|
2170
|
-
var buildGateway = async (gatewayName, signerTransport, signerFactory) => {
|
|
2161
|
+
var buildGateway = async (gatewayName, localEndpoint, signerTransport, signerFactory) => {
|
|
2171
2162
|
const network = DefaultNetworks.find((network2) => network2.id === gatewayName);
|
|
2172
2163
|
const resolvedNetwork = assertEx3(network, () => `No network found for id ${gatewayName}`);
|
|
2173
|
-
const
|
|
2174
|
-
|
|
2175
|
-
|
|
2176
|
-
|
|
2177
|
-
|
|
2178
|
-
|
|
2164
|
+
const rpcUrl = `${resolvedNetwork.url}/rpc`;
|
|
2165
|
+
const config = gatewayName === LocalNetwork2.id ? {
|
|
2166
|
+
blocks: { readUrl: `${localEndpoint}/blocks` },
|
|
2167
|
+
chainState: { readUrl: `${localEndpoint}/state` },
|
|
2168
|
+
index: { readUrl: `${localEndpoint}/indexes` }
|
|
2169
|
+
} : restGatewayConfigFromEndpoint(`https://${gatewayName}.xyo.space`);
|
|
2170
|
+
if (isDefined14(signerFactory)) {
|
|
2171
|
+
return await getRestGatewayRunner({
|
|
2172
|
+
...config,
|
|
2173
|
+
name: gatewayName,
|
|
2174
|
+
rpcUrl,
|
|
2175
|
+
signerFactory
|
|
2176
|
+
});
|
|
2177
|
+
}
|
|
2178
|
+
if (isDefined14(signerTransport)) {
|
|
2179
|
+
return await getRestGatewayRunner({
|
|
2180
|
+
...config,
|
|
2181
|
+
name: gatewayName,
|
|
2182
|
+
rpcUrl,
|
|
2183
|
+
signerTransport
|
|
2184
|
+
});
|
|
2185
|
+
}
|
|
2186
|
+
return await getRestGateway({ ...config, name: gatewayName });
|
|
2179
2187
|
};
|
|
2180
2188
|
|
|
2181
2189
|
// src/client/context/in-page/Provider.tsx
|
|
2190
|
+
import { DefaultNetworks as DefaultNetworks2 } from "@xyo-network/xl1-sdk";
|
|
2191
|
+
import {
|
|
2192
|
+
startTransition,
|
|
2193
|
+
useCallback as useCallback6,
|
|
2194
|
+
useEffect as useEffect5,
|
|
2195
|
+
useMemo as useMemo6,
|
|
2196
|
+
useState as useState15
|
|
2197
|
+
} from "react";
|
|
2182
2198
|
import { jsx as jsx17 } from "react/jsx-runtime";
|
|
2199
|
+
var DEFAULT_LOCAL_ENDPOINT = "http://127.0.0.1:8791";
|
|
2183
2200
|
var InPageGatewaysProvider = ({
|
|
2201
|
+
localEndpoint = DEFAULT_LOCAL_ENDPOINT,
|
|
2184
2202
|
signerFactory,
|
|
2185
2203
|
signerTransport,
|
|
2186
2204
|
children
|
|
@@ -2202,7 +2220,7 @@ var InPageGatewaysProvider = ({
|
|
|
2202
2220
|
if (cancelled) return;
|
|
2203
2221
|
const results = await Promise.allSettled(
|
|
2204
2222
|
DefaultNetworks2.map(async (network) => {
|
|
2205
|
-
const gateway = await buildGateway(network.id, signerTransport, signerFactory);
|
|
2223
|
+
const gateway = await buildGateway(network.id, localEndpoint, signerTransport, signerFactory);
|
|
2206
2224
|
return { id: network.id, gateway };
|
|
2207
2225
|
})
|
|
2208
2226
|
);
|
|
@@ -2227,7 +2245,7 @@ var InPageGatewaysProvider = ({
|
|
|
2227
2245
|
return () => {
|
|
2228
2246
|
cancelled = true;
|
|
2229
2247
|
};
|
|
2230
|
-
}, [signerFactory, signerTransport]);
|
|
2248
|
+
}, [localEndpoint, signerFactory, signerTransport]);
|
|
2231
2249
|
const value = useMemo6(() => {
|
|
2232
2250
|
const value2 = {
|
|
2233
2251
|
clearAll,
|
|
@@ -2370,6 +2388,7 @@ export {
|
|
|
2370
2388
|
RequestPermissionsButton,
|
|
2371
2389
|
SignTransactionButton,
|
|
2372
2390
|
WalletGatewayProvider,
|
|
2391
|
+
buildGateway,
|
|
2373
2392
|
findCaveat,
|
|
2374
2393
|
getXyoClient,
|
|
2375
2394
|
listenForClientInjection,
|