@xyo-network/xl1-rpc 3.0.6 → 3.0.8
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/neutral/client/index.mjs +39 -31
- package/dist/neutral/client/index.mjs.map +3 -3
- package/dist/neutral/engine-node/createRpcDispatchMiddleware.d.ts +17 -0
- package/dist/neutral/engine-node/createRpcDispatchMiddleware.d.ts.map +1 -0
- package/dist/neutral/engine-node/index.d.ts +1 -0
- package/dist/neutral/engine-node/index.d.ts.map +1 -1
- package/dist/neutral/engine-node/rpcEngineFromConnection.d.ts +1 -2
- package/dist/neutral/engine-node/rpcEngineFromConnection.d.ts.map +1 -1
- package/dist/neutral/index.mjs +70 -57
- package/dist/neutral/index.mjs.map +4 -4
- package/dist/neutral/provider/runner/JsonRpcRunner.d.ts.map +1 -1
- package/dist/neutral/provider/viewer/JsonRpcViewer.d.ts.map +1 -1
- package/dist/neutral/server/index.d.ts +1 -0
- package/dist/neutral/server/index.d.ts.map +1 -1
- package/dist/neutral/server/index.mjs +31 -26
- package/dist/neutral/server/index.mjs.map +3 -3
- package/dist/neutral/types/schema/RpcSchemaMap.d.ts +2 -0
- package/dist/neutral/types/schema/RpcSchemaMap.d.ts.map +1 -1
- package/package.json +11 -11
|
@@ -1572,11 +1572,8 @@ import { creatableProvider } from "@xyo-network/xl1-protocol-sdk";
|
|
|
1572
1572
|
import { AccountBalanceViewerMoniker } from "@xyo-network/xl1-protocol-lib";
|
|
1573
1573
|
|
|
1574
1574
|
// src/provider/viewer/JsonRpcViewer.ts
|
|
1575
|
-
import {
|
|
1576
|
-
|
|
1577
|
-
HttpRpcRemoteConfigZod,
|
|
1578
|
-
PostMessageRpcRemoteConfigZod
|
|
1579
|
-
} from "@xyo-network/xl1-protocol-sdk";
|
|
1575
|
+
import { isDefined as isDefined5 } from "@xylabs/sdk-js";
|
|
1576
|
+
import { AbstractCreatableProvider } from "@xyo-network/xl1-protocol-sdk";
|
|
1580
1577
|
|
|
1581
1578
|
// src/transport/HttpRpcTransport.ts
|
|
1582
1579
|
import {
|
|
@@ -1841,6 +1838,14 @@ var PostMessageRpcTransport = class {
|
|
|
1841
1838
|
};
|
|
1842
1839
|
|
|
1843
1840
|
// src/provider/viewer/JsonRpcViewer.ts
|
|
1841
|
+
function resolveRpcConnection(connections) {
|
|
1842
|
+
const named = connections["default-rpc"];
|
|
1843
|
+
if (isDefined5(named) && named.type === "rpc") {
|
|
1844
|
+
return named;
|
|
1845
|
+
}
|
|
1846
|
+
const first = Object.values(connections).find((connection) => connection?.type === "rpc");
|
|
1847
|
+
return first;
|
|
1848
|
+
}
|
|
1844
1849
|
var AbstractJsonRpcViewer = class extends AbstractCreatableProvider {
|
|
1845
1850
|
_transport;
|
|
1846
1851
|
get transport() {
|
|
@@ -1851,15 +1856,14 @@ var AbstractJsonRpcViewer = class extends AbstractCreatableProvider {
|
|
|
1851
1856
|
await super.createHandler();
|
|
1852
1857
|
}
|
|
1853
1858
|
createTransport() {
|
|
1854
|
-
const
|
|
1855
|
-
if (
|
|
1856
|
-
|
|
1857
|
-
|
|
1858
|
-
|
|
1859
|
-
|
|
1860
|
-
|
|
1861
|
-
|
|
1862
|
-
return new PostMessageRpcTransport(networkId, this.schemas(), sessionId, this.logger);
|
|
1859
|
+
const connection = resolveRpcConnection(this.config.connections);
|
|
1860
|
+
if (isDefined5(connection)) {
|
|
1861
|
+
if (connection.protocol === "postMessage" || isDefined5(connection.networkId)) {
|
|
1862
|
+
return new PostMessageRpcTransport(connection.networkId ?? "", this.schemas(), connection.sessionId ?? "", this.logger);
|
|
1863
|
+
}
|
|
1864
|
+
if (isDefined5(connection.url)) {
|
|
1865
|
+
return new HttpRpcTransport(connection.url, this.schemas());
|
|
1866
|
+
}
|
|
1863
1867
|
}
|
|
1864
1868
|
throw new Error("Unable to create transport");
|
|
1865
1869
|
}
|
|
@@ -1924,20 +1928,20 @@ import {
|
|
|
1924
1928
|
} from "@xyo-network/xl1-protocol-sdk";
|
|
1925
1929
|
|
|
1926
1930
|
// src/provider/viewer/JsonRpcBlockViewer/JsonRpcBlockViewerMethods.ts
|
|
1927
|
-
import { isDefined as
|
|
1931
|
+
import { isDefined as isDefined6 } from "@xylabs/sdk-js";
|
|
1928
1932
|
import { BlockViewerMoniker } from "@xyo-network/xl1-protocol-lib";
|
|
1929
1933
|
var JsonRpcBlockViewerMethods = class extends AbstractJsonRpcViewer {
|
|
1930
1934
|
moniker = BlockViewerMoniker;
|
|
1931
1935
|
async blocksByHash(hash, limit) {
|
|
1932
1936
|
return await this.transport.sendRequest(
|
|
1933
1937
|
"blockViewer_blocksByHash",
|
|
1934
|
-
|
|
1938
|
+
isDefined6(limit) ? [hash, limit] : [hash]
|
|
1935
1939
|
);
|
|
1936
1940
|
}
|
|
1937
1941
|
async blocksByNumber(block, limit) {
|
|
1938
1942
|
return await this.transport.sendRequest(
|
|
1939
1943
|
"blockViewer_blocksByNumber",
|
|
1940
|
-
|
|
1944
|
+
isDefined6(limit) ? [block, limit] : [block]
|
|
1941
1945
|
);
|
|
1942
1946
|
}
|
|
1943
1947
|
async blocksByStep(stepLevel, stepIndex) {
|
|
@@ -2782,11 +2786,16 @@ import { PayloadBuilder as PayloadBuilder2 } from "@xyo-network/sdk-js";
|
|
|
2782
2786
|
import { elevatedTransaction, MempoolRunnerMoniker } from "@xyo-network/xl1-protocol-lib";
|
|
2783
2787
|
|
|
2784
2788
|
// src/provider/runner/JsonRpcRunner.ts
|
|
2785
|
-
import {
|
|
2786
|
-
|
|
2787
|
-
|
|
2788
|
-
|
|
2789
|
-
|
|
2789
|
+
import { isDefined as isDefined7 } from "@xylabs/sdk-js";
|
|
2790
|
+
import { AbstractCreatableProvider as AbstractCreatableProvider2 } from "@xyo-network/xl1-protocol-sdk";
|
|
2791
|
+
function resolveRpcConnection2(connections) {
|
|
2792
|
+
const named = connections["default-rpc"];
|
|
2793
|
+
if (isDefined7(named) && named.type === "rpc") {
|
|
2794
|
+
return named;
|
|
2795
|
+
}
|
|
2796
|
+
const first = Object.values(connections).find((connection) => connection?.type === "rpc");
|
|
2797
|
+
return first;
|
|
2798
|
+
}
|
|
2790
2799
|
var AbstractJsonRpcRunner = class extends AbstractCreatableProvider2 {
|
|
2791
2800
|
get transport() {
|
|
2792
2801
|
return this.params.transport;
|
|
@@ -2796,15 +2805,14 @@ var AbstractJsonRpcRunner = class extends AbstractCreatableProvider2 {
|
|
|
2796
2805
|
await super.createHandler();
|
|
2797
2806
|
}
|
|
2798
2807
|
createTransport() {
|
|
2799
|
-
const
|
|
2800
|
-
if (
|
|
2801
|
-
|
|
2802
|
-
|
|
2803
|
-
|
|
2804
|
-
|
|
2805
|
-
|
|
2806
|
-
|
|
2807
|
-
return new PostMessageRpcTransport(networkId, this.schemas(), sessionId, this.logger);
|
|
2808
|
+
const connection = resolveRpcConnection2(this.config.connections);
|
|
2809
|
+
if (isDefined7(connection)) {
|
|
2810
|
+
if (connection.protocol === "postMessage" || isDefined7(connection.networkId)) {
|
|
2811
|
+
return new PostMessageRpcTransport(connection.networkId ?? "", this.schemas(), connection.sessionId ?? "", this.logger);
|
|
2812
|
+
}
|
|
2813
|
+
if (isDefined7(connection.url)) {
|
|
2814
|
+
return new HttpRpcTransport(connection.url, this.schemas());
|
|
2815
|
+
}
|
|
2808
2816
|
}
|
|
2809
2817
|
throw new Error("Unable to create transport");
|
|
2810
2818
|
}
|