@xyo-network/xl1-protocol-sdk 3.0.10 → 3.0.12
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/Archivists/ArchivistFactory.d.ts +3 -3
- package/dist/neutral/Archivists/ArchivistFactory.d.ts.map +1 -1
- package/dist/neutral/Archivists/MemoryArchivistFactory.d.ts +3 -3
- package/dist/neutral/Archivists/MemoryArchivistFactory.d.ts.map +1 -1
- package/dist/neutral/Archivists/archivistFactoryRegistry.d.ts +3 -3
- package/dist/neutral/Archivists/archivistFactoryRegistry.d.ts.map +1 -1
- package/dist/neutral/CreatableProvider/AbstractCreatableProvider.d.ts +0 -2
- package/dist/neutral/CreatableProvider/AbstractCreatableProvider.d.ts.map +1 -1
- package/dist/neutral/CreatableProvider/CreatableProvider.d.ts +3 -3
- package/dist/neutral/CreatableProvider/CreatableProvider.d.ts.map +1 -1
- package/dist/neutral/capabilities/connectionTypes.d.ts +2 -2
- package/dist/neutral/capabilities/connectionTypes.d.ts.map +1 -1
- package/dist/neutral/capabilities/needsFromProviderBindings.d.ts +2 -2
- package/dist/neutral/capabilities/needsFromProviderBindings.d.ts.map +1 -1
- package/dist/neutral/capabilities/resolveProviders.d.ts +2 -3
- package/dist/neutral/capabilities/resolveProviders.d.ts.map +1 -1
- package/dist/neutral/config/Actor.d.ts +0 -12
- package/dist/neutral/config/Actor.d.ts.map +1 -1
- package/dist/neutral/config/Actors.d.ts +0 -2
- package/dist/neutral/config/Actors.d.ts.map +1 -1
- package/dist/neutral/config/Base.d.ts +0 -2
- package/dist/neutral/config/Base.d.ts.map +1 -1
- package/dist/neutral/config/Config.d.ts +0 -8
- package/dist/neutral/config/Config.d.ts.map +1 -1
- package/dist/neutral/config/HostActor.d.ts +0 -12
- package/dist/neutral/config/HostActor.d.ts.map +1 -1
- package/dist/neutral/config/ProviderBinding.d.ts +0 -2
- package/dist/neutral/config/ProviderBinding.d.ts.map +1 -1
- package/dist/neutral/config/{transports/Transport.d.ts → connections/Connection.d.ts} +29 -29
- package/dist/neutral/config/connections/Connection.d.ts.map +1 -0
- package/dist/neutral/config/connections/Mongo.d.ts.map +1 -0
- package/dist/neutral/config/{transports/Rpc.d.ts → connections/RpcRemote.d.ts} +1 -1
- package/dist/neutral/config/connections/RpcRemote.d.ts.map +1 -0
- package/dist/neutral/config/connections/S3.d.ts.map +1 -0
- package/dist/neutral/config/connections/index.d.ts +4 -5
- package/dist/neutral/config/connections/index.d.ts.map +1 -1
- package/dist/neutral/config/index.d.ts +1 -2
- package/dist/neutral/config/index.d.ts.map +1 -1
- package/dist/neutral/config/normalizeConnectionsConfig.d.ts +2 -2
- package/dist/neutral/config/normalizeConnectionsConfig.d.ts.map +1 -1
- package/dist/neutral/config/resolveRestConnectionEndpoint.d.ts +5 -0
- package/dist/neutral/config/resolveRestConnectionEndpoint.d.ts.map +1 -0
- package/dist/neutral/context/Actor.d.ts +0 -12
- package/dist/neutral/context/Actor.d.ts.map +1 -1
- package/dist/neutral/context/HostActor.d.ts +0 -12
- package/dist/neutral/context/HostActor.d.ts.map +1 -1
- package/dist/neutral/getFileConfig.d.ts +0 -4
- package/dist/neutral/getFileConfig.d.ts.map +1 -1
- package/dist/neutral/getFileConfig.mjs +87 -136
- package/dist/neutral/getFileConfig.mjs.map +4 -4
- package/dist/neutral/index.mjs +365 -406
- package/dist/neutral/index.mjs.map +4 -4
- package/dist/neutral/model/CreatableProviderContext.zod.d.ts +0 -12
- package/dist/neutral/model/CreatableProviderContext.zod.d.ts.map +1 -1
- package/dist/neutral/simple/datalake/AbstractRestDataLake.d.ts +11 -1
- package/dist/neutral/simple/datalake/AbstractRestDataLake.d.ts.map +1 -1
- package/dist/neutral/test/index.mjs +85 -134
- package/dist/neutral/test/index.mjs.map +4 -4
- package/package.json +6 -6
- package/dist/neutral/config/DataLake/DataLake.d.ts +0 -8
- package/dist/neutral/config/DataLake/DataLake.d.ts.map +0 -1
- package/dist/neutral/config/DataLake/DataLakeRemoteConfig.d.ts +0 -8
- package/dist/neutral/config/DataLake/DataLakeRemoteConfig.d.ts.map +0 -1
- package/dist/neutral/config/DataLake/RestDataLakeConfig.d.ts +0 -9
- package/dist/neutral/config/DataLake/RestDataLakeConfig.d.ts.map +0 -1
- package/dist/neutral/config/DataLake/RouterDataLakeConfig.d.ts +0 -10
- package/dist/neutral/config/DataLake/RouterDataLakeConfig.d.ts.map +0 -1
- package/dist/neutral/config/DataLake/index.d.ts +0 -5
- package/dist/neutral/config/DataLake/index.d.ts.map +0 -1
- package/dist/neutral/config/transports/Mongo.d.ts.map +0 -1
- package/dist/neutral/config/transports/Rpc.d.ts.map +0 -1
- package/dist/neutral/config/transports/S3.d.ts.map +0 -1
- package/dist/neutral/config/transports/Transport.d.ts.map +0 -1
- package/dist/neutral/config/transports/index.d.ts +0 -5
- package/dist/neutral/config/transports/index.d.ts.map +0 -1
- /package/dist/neutral/config/{transports → connections}/Mongo.d.ts +0 -0
- /package/dist/neutral/config/{transports → connections}/S3.d.ts +0 -0
package/dist/neutral/index.mjs
CHANGED
|
@@ -1120,30 +1120,11 @@ function factoryBackingsCompatible(declared, available) {
|
|
|
1120
1120
|
}
|
|
1121
1121
|
|
|
1122
1122
|
// src/config/normalizeConnectionsConfig.ts
|
|
1123
|
-
function normalizeProviderBinding(binding) {
|
|
1124
|
-
const connectionName = binding.connection ?? binding.transport;
|
|
1125
|
-
if (connectionName === void 0 || connectionName === "") {
|
|
1126
|
-
return binding;
|
|
1127
|
-
}
|
|
1128
|
-
return {
|
|
1129
|
-
...binding,
|
|
1130
|
-
connection: connectionName,
|
|
1131
|
-
transport: connectionName
|
|
1132
|
-
};
|
|
1133
|
-
}
|
|
1134
|
-
function normalizeProviderBindings(bindings) {
|
|
1135
|
-
const normalized = {};
|
|
1136
|
-
for (const [moniker, binding] of Object.entries(bindings)) {
|
|
1137
|
-
if (binding === void 0) continue;
|
|
1138
|
-
normalized[moniker] = normalizeProviderBinding(binding);
|
|
1139
|
-
}
|
|
1140
|
-
return normalized;
|
|
1141
|
-
}
|
|
1142
1123
|
function normalizeConnectionsConfig(config) {
|
|
1143
1124
|
return {
|
|
1144
1125
|
...config,
|
|
1145
1126
|
connections: config.connections ?? {},
|
|
1146
|
-
providerBindings:
|
|
1127
|
+
providerBindings: config.providerBindings ?? {}
|
|
1147
1128
|
};
|
|
1148
1129
|
}
|
|
1149
1130
|
function hasDeclaredConnectionProfiles(config) {
|
|
@@ -1564,7 +1545,7 @@ function bindMoniker(moniker, wanted, bindings, selectedById, candidatesByMonike
|
|
|
1564
1545
|
}
|
|
1565
1546
|
function connectionNameForMoniker(moniker, options) {
|
|
1566
1547
|
const binding = options.providerBindings?.[moniker];
|
|
1567
|
-
const connectionName = binding?.connection
|
|
1548
|
+
const connectionName = binding?.connection;
|
|
1568
1549
|
if (!isDefined4(connectionName) || connectionName === "") {
|
|
1569
1550
|
throw new UnboundProviderError(moniker);
|
|
1570
1551
|
}
|
|
@@ -1674,7 +1655,7 @@ function needsFromConnectionTypes(config, connectionTypes) {
|
|
|
1674
1655
|
const allowed = new Set(connectionTypes);
|
|
1675
1656
|
const needs = /* @__PURE__ */ new Set();
|
|
1676
1657
|
for (const [moniker, binding] of Object.entries(config.providerBindings)) {
|
|
1677
|
-
const connectionName = binding?.connection
|
|
1658
|
+
const connectionName = binding?.connection;
|
|
1678
1659
|
if (connectionName === void 0 || connectionName === "") {
|
|
1679
1660
|
continue;
|
|
1680
1661
|
}
|
|
@@ -1707,10 +1688,10 @@ import {
|
|
|
1707
1688
|
zodIsFactory as zodIsFactory2,
|
|
1708
1689
|
zodToFactory as zodToFactory2
|
|
1709
1690
|
} from "@xylabs/sdk-js";
|
|
1710
|
-
import { globalRegistry as
|
|
1691
|
+
import { globalRegistry as globalRegistry9, z as z14 } from "zod/mini";
|
|
1711
1692
|
|
|
1712
1693
|
// src/config/Base.ts
|
|
1713
|
-
import { z as
|
|
1694
|
+
import { z as z13 } from "zod/mini";
|
|
1714
1695
|
|
|
1715
1696
|
// src/config/Chain.ts
|
|
1716
1697
|
import { HexZod } from "@xylabs/sdk-js";
|
|
@@ -1729,10 +1710,10 @@ var ChainConfigZod = z2.object({
|
|
|
1729
1710
|
})
|
|
1730
1711
|
});
|
|
1731
1712
|
|
|
1732
|
-
// src/config/
|
|
1713
|
+
// src/config/connections/Connection.ts
|
|
1733
1714
|
import { globalRegistry as globalRegistry3, z as z5 } from "zod";
|
|
1734
1715
|
|
|
1735
|
-
// src/config/
|
|
1716
|
+
// src/config/connections/Mongo.ts
|
|
1736
1717
|
import { globalRegistry as globalRegistry2, z as z3 } from "zod";
|
|
1737
1718
|
var MongoConfigZod = z3.object({
|
|
1738
1719
|
// TODO: Create from other arguments
|
|
@@ -1763,7 +1744,7 @@ var MongoConfigZod = z3.object({
|
|
|
1763
1744
|
})
|
|
1764
1745
|
});
|
|
1765
1746
|
|
|
1766
|
-
// src/config/
|
|
1747
|
+
// src/config/connections/S3.ts
|
|
1767
1748
|
import { z as z4 } from "zod";
|
|
1768
1749
|
var S3BucketConfigZod = z4.object({
|
|
1769
1750
|
accessKeyId: z4.string().nonempty().optional().describe("S3-compatible access key id for this bucket (overrides the shared default)"),
|
|
@@ -1774,151 +1755,142 @@ var S3BucketConfigZod = z4.object({
|
|
|
1774
1755
|
secretAccessKey: z4.string().nonempty().optional().describe("S3-compatible secret access key for this bucket (overrides the shared default)")
|
|
1775
1756
|
});
|
|
1776
1757
|
|
|
1777
|
-
// src/config/
|
|
1778
|
-
var
|
|
1758
|
+
// src/config/connections/Connection.ts
|
|
1759
|
+
var LmdbConnectionConfigZod = z5.object({
|
|
1779
1760
|
access: z5.enum(["read", "write"]).optional().register(globalRegistry3, {
|
|
1780
1761
|
description: "Access mode for this LMDB connection (read or write)",
|
|
1781
|
-
title: "
|
|
1762
|
+
title: "connections.lmdb.access",
|
|
1782
1763
|
type: "string"
|
|
1783
1764
|
}),
|
|
1784
1765
|
root: z5.string().register(globalRegistry3, {
|
|
1785
1766
|
description: "Root directory for local LMDB storage",
|
|
1786
|
-
title: "
|
|
1767
|
+
title: "connections.lmdb.root",
|
|
1787
1768
|
type: "string"
|
|
1788
1769
|
}),
|
|
1789
1770
|
store: z5.string().optional().register(globalRegistry3, {
|
|
1790
1771
|
description: "Logical store name within the LMDB root (e.g. finalized-chain, mempool)",
|
|
1791
|
-
title: "
|
|
1772
|
+
title: "connections.lmdb.store",
|
|
1792
1773
|
type: "string"
|
|
1793
1774
|
}),
|
|
1794
1775
|
type: z5.literal("lmdb")
|
|
1795
|
-
}).describe("LMDB local storage
|
|
1796
|
-
var
|
|
1776
|
+
}).describe("LMDB local storage connection");
|
|
1777
|
+
var MongoConnectionConfigZod = z5.object({
|
|
1797
1778
|
type: z5.literal("mongo"),
|
|
1798
1779
|
connectionString: MongoConfigZod.shape.connectionString,
|
|
1799
1780
|
database: MongoConfigZod.shape.database,
|
|
1800
1781
|
domain: MongoConfigZod.shape.domain,
|
|
1801
1782
|
password: MongoConfigZod.shape.password,
|
|
1802
1783
|
username: MongoConfigZod.shape.username
|
|
1803
|
-
}).describe("MongoDB storage
|
|
1804
|
-
var
|
|
1784
|
+
}).describe("MongoDB storage connection");
|
|
1785
|
+
var RpcConnectionConfigZod = z5.object({
|
|
1805
1786
|
type: z5.literal("rpc"),
|
|
1806
1787
|
protocol: z5.string().default("http").register(globalRegistry3, {
|
|
1807
1788
|
description: "Protocol for the RPC connection (http or postMessage)",
|
|
1808
|
-
title: "
|
|
1789
|
+
title: "connections.rpc.protocol",
|
|
1809
1790
|
type: "string"
|
|
1810
1791
|
}),
|
|
1811
1792
|
url: z5.string().optional().register(globalRegistry3, {
|
|
1812
1793
|
description: "URL for the Chain RPC API (http protocol)",
|
|
1813
|
-
title: "
|
|
1794
|
+
title: "connections.rpc.url",
|
|
1814
1795
|
type: "string"
|
|
1815
1796
|
}),
|
|
1816
1797
|
networkId: z5.string().optional().register(globalRegistry3, {
|
|
1817
1798
|
description: "Network ID for the postMessage RPC connection",
|
|
1818
|
-
title: "
|
|
1799
|
+
title: "connections.rpc.networkId",
|
|
1819
1800
|
type: "string"
|
|
1820
1801
|
}),
|
|
1821
1802
|
sessionId: z5.string().optional().register(globalRegistry3, {
|
|
1822
1803
|
description: "Session ID for the postMessage RPC connection",
|
|
1823
|
-
title: "
|
|
1804
|
+
title: "connections.rpc.sessionId",
|
|
1824
1805
|
type: "string"
|
|
1825
1806
|
})
|
|
1826
|
-
}).describe("XL1 JSON-RPC
|
|
1827
|
-
var
|
|
1807
|
+
}).describe("XL1 JSON-RPC connection");
|
|
1808
|
+
var RestConnectionConfigZod = z5.object({
|
|
1828
1809
|
type: z5.literal("rest"),
|
|
1829
1810
|
baseUrl: z5.string().register(globalRegistry3, {
|
|
1830
1811
|
description: "HTTP base URL for REST reads",
|
|
1831
|
-
title: "
|
|
1812
|
+
title: "connections.rest.baseUrl",
|
|
1832
1813
|
type: "string"
|
|
1833
1814
|
})
|
|
1834
|
-
}).describe("HTTP REST read
|
|
1835
|
-
var
|
|
1815
|
+
}).describe("HTTP REST read connection");
|
|
1816
|
+
var S3ConnectionConfigZod = S3BucketConfigZod.extend({
|
|
1836
1817
|
type: z5.literal("s3"),
|
|
1837
1818
|
accessKeyId: z5.string().optional(),
|
|
1838
1819
|
accountId: z5.string().optional(),
|
|
1839
1820
|
secretAccessKey: z5.string().optional()
|
|
1840
|
-
}).describe("S3-compatible object storage
|
|
1841
|
-
var
|
|
1821
|
+
}).describe("S3-compatible object storage connection");
|
|
1822
|
+
var EvmRpcConnectionConfigZod = z5.object({
|
|
1842
1823
|
type: z5.literal("evm-rpc"),
|
|
1843
1824
|
url: z5.string().register(globalRegistry3, {
|
|
1844
1825
|
description: "EVM JSON-RPC URL",
|
|
1845
|
-
title: "
|
|
1826
|
+
title: "connections.evm-rpc.url",
|
|
1846
1827
|
type: "string"
|
|
1847
1828
|
}),
|
|
1848
1829
|
chainId: z5.string().optional().register(globalRegistry3, {
|
|
1849
1830
|
description: "EVM chain ID for this RPC endpoint; auto-detected from the endpoint when omitted",
|
|
1850
|
-
title: "
|
|
1831
|
+
title: "connections.evm-rpc.chainId",
|
|
1851
1832
|
type: "string"
|
|
1852
1833
|
})
|
|
1853
|
-
}).describe("EVM JSON-RPC
|
|
1854
|
-
var
|
|
1855
|
-
var
|
|
1856
|
-
|
|
1857
|
-
|
|
1858
|
-
|
|
1859
|
-
|
|
1860
|
-
|
|
1861
|
-
|
|
1862
|
-
|
|
1834
|
+
}).describe("EVM JSON-RPC connection");
|
|
1835
|
+
var MemoryConnectionConfigZod = z5.object({ type: z5.literal("memory") }).describe("In-process memory connection");
|
|
1836
|
+
var ConnectionConfigZod = z5.discriminatedUnion("type", [
|
|
1837
|
+
LmdbConnectionConfigZod,
|
|
1838
|
+
MongoConnectionConfigZod,
|
|
1839
|
+
RpcConnectionConfigZod,
|
|
1840
|
+
RestConnectionConfigZod,
|
|
1841
|
+
S3ConnectionConfigZod,
|
|
1842
|
+
EvmRpcConnectionConfigZod,
|
|
1843
|
+
MemoryConnectionConfigZod
|
|
1863
1844
|
]);
|
|
1864
|
-
var
|
|
1865
|
-
|
|
1866
|
-
// src/config/DataLake/DataLake.ts
|
|
1867
|
-
import { z as z9 } from "zod";
|
|
1868
|
-
|
|
1869
|
-
// src/config/DataLake/RestDataLakeConfig.ts
|
|
1870
|
-
import { globalRegistry as globalRegistry5, z as z7 } from "zod";
|
|
1845
|
+
var ConnectionsConfigZod = z5.record(z5.string(), ConnectionConfigZod).default({});
|
|
1871
1846
|
|
|
1872
|
-
// src/config/
|
|
1847
|
+
// src/config/connections/RpcRemote.ts
|
|
1873
1848
|
import { globalRegistry as globalRegistry4, z as z6 } from "zod";
|
|
1874
|
-
var
|
|
1875
|
-
|
|
1876
|
-
description: "
|
|
1849
|
+
var RpcRemoteConfigBaseZod = z6.object({
|
|
1850
|
+
protocol: z6.string("http").register(globalRegistry4, {
|
|
1851
|
+
description: "Protocol for the RPC connection",
|
|
1877
1852
|
type: "string"
|
|
1878
1853
|
})
|
|
1879
|
-
}).describe("Base configuration for
|
|
1880
|
-
|
|
1881
|
-
|
|
1882
|
-
|
|
1883
|
-
driver: z7.literal("rest").register(globalRegistry5, {
|
|
1884
|
-
description: "Driver for the REST data lake",
|
|
1854
|
+
}).describe("Base configuration for the remote RPC");
|
|
1855
|
+
var HttpRpcRemoteConfigZod = RpcRemoteConfigBaseZod.extend({
|
|
1856
|
+
protocol: z6.string("http").register(globalRegistry4, {
|
|
1857
|
+
description: "Protocol for the RPC connection",
|
|
1885
1858
|
type: "string"
|
|
1886
|
-
}),
|
|
1887
|
-
url:
|
|
1888
|
-
description: "URL for the
|
|
1859
|
+
}).default("http"),
|
|
1860
|
+
url: z6.string().register(globalRegistry4, {
|
|
1861
|
+
description: "URL for the Chain RPC API",
|
|
1889
1862
|
type: "string"
|
|
1890
1863
|
})
|
|
1891
|
-
}).describe("Configuration for the
|
|
1892
|
-
|
|
1893
|
-
|
|
1894
|
-
|
|
1895
|
-
|
|
1896
|
-
|
|
1897
|
-
|
|
1864
|
+
}).describe("Configuration for the remote RPC using Http");
|
|
1865
|
+
var PostMessageRpcRemoteConfigZod = RpcRemoteConfigBaseZod.extend({
|
|
1866
|
+
protocol: z6.string().register(globalRegistry4, {
|
|
1867
|
+
description: "Protocol for the RPC connection",
|
|
1868
|
+
type: "string"
|
|
1869
|
+
}).default("postMessage"),
|
|
1870
|
+
networkId: z6.string().register(globalRegistry4, {
|
|
1871
|
+
description: "Network ID to use for the postMessage RPC connection",
|
|
1898
1872
|
type: "string"
|
|
1899
1873
|
}),
|
|
1900
|
-
|
|
1901
|
-
description: "
|
|
1902
|
-
type: "
|
|
1874
|
+
sessionId: z6.string().register(globalRegistry4, {
|
|
1875
|
+
description: "Session ID to use for the postMessage RPC connection",
|
|
1876
|
+
type: "string"
|
|
1903
1877
|
})
|
|
1904
|
-
}).describe("Configuration for the
|
|
1905
|
-
|
|
1906
|
-
// src/config/DataLake/DataLake.ts
|
|
1907
|
-
var DataLakeConfigZod = z9.lazy(() => z9.union([RestDataLakeConfigZod, RouterDataLakeConfigZod])).describe("Configuration for a data lake");
|
|
1878
|
+
}).describe("Configuration for the remote RPC using postMessage");
|
|
1879
|
+
var RpcRemoteConfigZod = z6.union([HttpRpcRemoteConfigZod, PostMessageRpcRemoteConfigZod]).describe("Configuration for a remote RPC connection, either Http or postMessage");
|
|
1908
1880
|
|
|
1909
1881
|
// src/config/Log.ts
|
|
1910
1882
|
import { LogLevel } from "@xylabs/sdk-js";
|
|
1911
|
-
import { globalRegistry as
|
|
1883
|
+
import { globalRegistry as globalRegistry5, z as z7 } from "zod";
|
|
1912
1884
|
var LogLevelNames = Object.keys(LogLevel);
|
|
1913
|
-
var LogConfigZod =
|
|
1914
|
-
logLevel:
|
|
1885
|
+
var LogConfigZod = z7.object({
|
|
1886
|
+
logLevel: z7.enum(LogLevelNames).default("info").register(globalRegistry5, {
|
|
1915
1887
|
choices: LogLevelNames,
|
|
1916
1888
|
default: "info",
|
|
1917
1889
|
description: "Desired process verbosity",
|
|
1918
1890
|
title: "logLevel",
|
|
1919
1891
|
type: "string"
|
|
1920
1892
|
}),
|
|
1921
|
-
silent:
|
|
1893
|
+
silent: z7.boolean().default(false).register(globalRegistry5, {
|
|
1922
1894
|
default: false,
|
|
1923
1895
|
description: "Whether to run in silent mode",
|
|
1924
1896
|
title: "silent",
|
|
@@ -1927,23 +1899,18 @@ var LogConfigZod = z10.object({
|
|
|
1927
1899
|
});
|
|
1928
1900
|
|
|
1929
1901
|
// src/config/ProviderBinding.ts
|
|
1930
|
-
import { globalRegistry as
|
|
1931
|
-
var ProviderBindingConfigZod =
|
|
1932
|
-
connection:
|
|
1902
|
+
import { globalRegistry as globalRegistry6, z as z8 } from "zod";
|
|
1903
|
+
var ProviderBindingConfigZod = z8.object({
|
|
1904
|
+
connection: z8.string().optional().register(globalRegistry6, {
|
|
1933
1905
|
description: "Named connection from the top-level connections map",
|
|
1934
1906
|
title: "providerBindings.connection",
|
|
1935
1907
|
type: "string"
|
|
1936
|
-
}),
|
|
1937
|
-
transport: z11.string().optional().register(globalRegistry8, {
|
|
1938
|
-
description: "Deprecated alias for connection (kept in sync during migration)",
|
|
1939
|
-
title: "providerBindings.transport",
|
|
1940
|
-
type: "string"
|
|
1941
1908
|
})
|
|
1942
1909
|
}).describe("Provider connection binding");
|
|
1943
|
-
var ProviderBindingsConfigZod =
|
|
1910
|
+
var ProviderBindingsConfigZod = z8.record(z8.string(), ProviderBindingConfigZod).default({});
|
|
1944
1911
|
|
|
1945
1912
|
// src/config/Providers.ts
|
|
1946
|
-
import
|
|
1913
|
+
import z10 from "zod";
|
|
1947
1914
|
|
|
1948
1915
|
// src/config/Provider.ts
|
|
1949
1916
|
import {
|
|
@@ -1951,20 +1918,20 @@ import {
|
|
|
1951
1918
|
zodIsFactory,
|
|
1952
1919
|
zodToFactory
|
|
1953
1920
|
} from "@xylabs/sdk-js";
|
|
1954
|
-
import { z as
|
|
1955
|
-
var ProviderConfigZod =
|
|
1956
|
-
moniker:
|
|
1957
|
-
labels:
|
|
1921
|
+
import { z as z9 } from "zod";
|
|
1922
|
+
var ProviderConfigZod = z9.object({
|
|
1923
|
+
moniker: z9.string(),
|
|
1924
|
+
labels: z9.array(z9.string()).optional()
|
|
1958
1925
|
}).describe("Configuration for a Provider");
|
|
1959
1926
|
var isProviderConfig = zodIsFactory(ProviderConfigZod);
|
|
1960
1927
|
var asProviderConfig = zodAsFactory2(ProviderConfigZod, "asProviderConfig");
|
|
1961
1928
|
var toProviderConfig = zodToFactory(ProviderConfigZod, "toProviderConfig");
|
|
1962
1929
|
|
|
1963
1930
|
// src/config/Providers.ts
|
|
1964
|
-
var ProvidersConfigZod =
|
|
1931
|
+
var ProvidersConfigZod = z10.array(ProviderConfigZod.loose()).describe("Configuration for providers").default([]);
|
|
1965
1932
|
|
|
1966
1933
|
// src/config/Telemetry.ts
|
|
1967
|
-
import { globalRegistry as
|
|
1934
|
+
import { globalRegistry as globalRegistry7, z as z11 } from "zod";
|
|
1968
1935
|
var DefaultMetricsScrapePorts = {
|
|
1969
1936
|
api: 9465,
|
|
1970
1937
|
bridge: 9468,
|
|
@@ -1972,29 +1939,29 @@ var DefaultMetricsScrapePorts = {
|
|
|
1972
1939
|
producer: 9464,
|
|
1973
1940
|
rewardRedemptionApi: 9467
|
|
1974
1941
|
};
|
|
1975
|
-
var MetricsScrapeConfigZod =
|
|
1976
|
-
path:
|
|
1942
|
+
var MetricsScrapeConfigZod = z11.object({
|
|
1943
|
+
path: z11.string().default("/metrics").register(globalRegistry7, {
|
|
1977
1944
|
default: "/metrics",
|
|
1978
1945
|
description: "Path for the metrics scrape endpoint",
|
|
1979
1946
|
title: "telemetry.metrics.scrape.path",
|
|
1980
1947
|
type: "string"
|
|
1981
1948
|
}),
|
|
1982
|
-
port:
|
|
1949
|
+
port: z11.coerce.number().int().nonnegative().optional().register(globalRegistry7, {
|
|
1983
1950
|
description: "Port for the metrics scrape endpoint (0 disables the scrape endpoint)",
|
|
1984
1951
|
title: "telemetry.metrics.scrape.port",
|
|
1985
1952
|
type: "number"
|
|
1986
1953
|
})
|
|
1987
1954
|
}).describe("Metrics scrape configuration");
|
|
1988
|
-
var MetricsConfigZod =
|
|
1989
|
-
var OpenTelemetryConfigZod =
|
|
1955
|
+
var MetricsConfigZod = z11.object({ scrape: MetricsScrapeConfigZod }).describe("Metrics configuration options");
|
|
1956
|
+
var OpenTelemetryConfigZod = z11.object({
|
|
1990
1957
|
// OpenTelemetry options
|
|
1991
|
-
otlpEndpoint:
|
|
1958
|
+
otlpEndpoint: z11.url().optional().register(globalRegistry7, {
|
|
1992
1959
|
description: "OTLP endpoint for exporting telemetry data",
|
|
1993
1960
|
title: "telemetry.otel.otlpEndpoint",
|
|
1994
1961
|
type: "string"
|
|
1995
1962
|
})
|
|
1996
1963
|
});
|
|
1997
|
-
var TelemetryConfigZod =
|
|
1964
|
+
var TelemetryConfigZod = z11.object({
|
|
1998
1965
|
// Metrics configuration
|
|
1999
1966
|
metrics: MetricsConfigZod.optional().describe("Metrics configuration"),
|
|
2000
1967
|
// OpenTelemetry configuration
|
|
@@ -2003,7 +1970,7 @@ var TelemetryConfigZod = z14.object({
|
|
|
2003
1970
|
|
|
2004
1971
|
// src/config/Validation.ts
|
|
2005
1972
|
import { XyoAddressZod as XyoAddressZod2 } from "@xyo-network/sdk-js";
|
|
2006
|
-
import { globalRegistry as
|
|
1973
|
+
import { globalRegistry as globalRegistry8, z as z12 } from "zod";
|
|
2007
1974
|
|
|
2008
1975
|
// src/primitives/block/range/blockRangeSteps.ts
|
|
2009
1976
|
import { asXL1BlockNumber as asXL1BlockNumber2, StepSizes as StepSizes3 } from "@xyo-network/xl1-protocol-lib";
|
|
@@ -2921,24 +2888,24 @@ function findUncles(context, finalizedWindowedChain, blocks) {
|
|
|
2921
2888
|
}
|
|
2922
2889
|
|
|
2923
2890
|
// src/config/Validation.ts
|
|
2924
|
-
var ValidationConfigZod =
|
|
2925
|
-
allowedRewardRedeemers:
|
|
2891
|
+
var ValidationConfigZod = z12.object({
|
|
2892
|
+
allowedRewardRedeemers: z12.array(XyoAddressZod2).optional().register(globalRegistry8, {
|
|
2926
2893
|
description: "List of allowed reward redeemer addresses, if undefined anyone can participate",
|
|
2927
2894
|
title: "allowedRewardRedeemers",
|
|
2928
2895
|
type: "array"
|
|
2929
2896
|
}),
|
|
2930
|
-
allowedRewardEscrowAccountSigners:
|
|
2897
|
+
allowedRewardEscrowAccountSigners: z12.array(XyoAddressZod2).optional().register(globalRegistry8, {
|
|
2931
2898
|
description: "List of allowed reward escrow account signer addresses, if undefined anyone can participate",
|
|
2932
2899
|
title: "allowedRewardEscrowAccountSigners",
|
|
2933
2900
|
type: "array"
|
|
2934
2901
|
}),
|
|
2935
|
-
minCandidates:
|
|
2902
|
+
minCandidates: z12.coerce.number().default(DEFAULT_MIN_CANDIDATES).register(globalRegistry8, {
|
|
2936
2903
|
default: DEFAULT_MIN_CANDIDATES,
|
|
2937
2904
|
description: "Minimum number of uncle candidates before selecting the best uncle",
|
|
2938
2905
|
title: "validation.minCandidates",
|
|
2939
2906
|
type: "number"
|
|
2940
2907
|
}),
|
|
2941
|
-
backoffMs:
|
|
2908
|
+
backoffMs: z12.coerce.number().default(DEFAULT_BACKOFF_MS).register(globalRegistry8, {
|
|
2942
2909
|
default: DEFAULT_BACKOFF_MS,
|
|
2943
2910
|
description: "Back-off timeout in ms. If head age exceeds this, minCandidates is ignored",
|
|
2944
2911
|
title: "validation.backoffMs",
|
|
@@ -2947,25 +2914,24 @@ var ValidationConfigZod = z15.object({
|
|
|
2947
2914
|
});
|
|
2948
2915
|
|
|
2949
2916
|
// src/config/Base.ts
|
|
2950
|
-
var BaseConfigZod =
|
|
2951
|
-
chain:
|
|
2952
|
-
|
|
2953
|
-
|
|
2954
|
-
|
|
2955
|
-
|
|
2956
|
-
|
|
2957
|
-
|
|
2958
|
-
validation: z16._default(ValidationConfigZod, ValidationConfigZod.parse({})).check(z16.describe("Configuration for validation"))
|
|
2917
|
+
var BaseConfigZod = z13.object({
|
|
2918
|
+
chain: z13._default(ChainConfigZod, ChainConfigZod.parse({})).check(z13.describe("Configuration for the chain")),
|
|
2919
|
+
log: z13._default(LogConfigZod, LogConfigZod.parse({})).check(z13.describe("Configuration for logging")),
|
|
2920
|
+
connections: z13._default(ConnectionsConfigZod, ConnectionsConfigZod.parse({})).check(z13.describe("Named connection profiles (rpc, rest, s3, lmdb, mongo, evm-rpc)")),
|
|
2921
|
+
providerBindings: z13._default(ProviderBindingsConfigZod, ProviderBindingsConfigZod.parse({})).check(z13.describe("Per-moniker provider connection bindings")),
|
|
2922
|
+
providers: z13._default(ProvidersConfigZod, ProvidersConfigZod.parse([])).check(z13.describe("Configuration for providers")),
|
|
2923
|
+
telemetry: z13._default(TelemetryConfigZod, TelemetryConfigZod.parse({})).check(z13.describe("Configuration for telemetry")),
|
|
2924
|
+
validation: z13._default(ValidationConfigZod, ValidationConfigZod.parse({})).check(z13.describe("Configuration for validation"))
|
|
2959
2925
|
});
|
|
2960
2926
|
|
|
2961
2927
|
// src/config/Actor.ts
|
|
2962
|
-
var AccountPathZod =
|
|
2928
|
+
var AccountPathZod = z14.string().check(z14.regex(
|
|
2963
2929
|
/^(m(\/\d+'?)+|\d+'?(\/\d+'?)*)$/,
|
|
2964
2930
|
`Invalid BIP-32 derivation path. Use either an absolute path like "m/44'/60'/0'/0/0" or a relative path like "0", "0/1", or "44'/60'/0'/0/0".`
|
|
2965
2931
|
));
|
|
2966
|
-
var ActorConfigZod =
|
|
2967
|
-
name:
|
|
2968
|
-
accountPath:
|
|
2932
|
+
var ActorConfigZod = z14.extend(BaseConfigZod, {
|
|
2933
|
+
name: z14.string(),
|
|
2934
|
+
accountPath: z14.optional(AccountPathZod).register(globalRegistry9, {
|
|
2969
2935
|
description: 'BIP-32 derivation path for the actor wallet. Absolute when it starts with "m/"; otherwise relative to the root wallet base path. Each actor must derive to a distinct path.',
|
|
2970
2936
|
title: "accountPath",
|
|
2971
2937
|
type: "string"
|
|
@@ -2976,22 +2942,22 @@ var asActorConfig = zodAsFactory3(ActorConfigZod, "asActorConfig");
|
|
|
2976
2942
|
var toActorConfig = zodToFactory2(ActorConfigZod, "toActorConfig");
|
|
2977
2943
|
|
|
2978
2944
|
// src/config/Actors.ts
|
|
2979
|
-
import { z as
|
|
2980
|
-
var ActorsConfigZod =
|
|
2981
|
-
|
|
2945
|
+
import { z as z15 } from "zod/mini";
|
|
2946
|
+
var ActorsConfigZod = z15._default(
|
|
2947
|
+
z15.array(z15.looseObject(ActorConfigZod.shape)).check(z15.describe("Actor-specific configurations that override the base configuration when the actor is running")),
|
|
2982
2948
|
[]
|
|
2983
2949
|
);
|
|
2984
2950
|
|
|
2985
2951
|
// src/config/Config.ts
|
|
2986
|
-
import { globalRegistry as
|
|
2987
|
-
var ConfigZod =
|
|
2952
|
+
import { globalRegistry as globalRegistry10, z as z16 } from "zod/mini";
|
|
2953
|
+
var ConfigZod = z16.extend(BaseConfigZod, {
|
|
2988
2954
|
actors: ActorsConfigZod,
|
|
2989
|
-
healthCheckPort:
|
|
2955
|
+
healthCheckPort: z16.optional(z16.coerce.number()).register(globalRegistry10, {
|
|
2990
2956
|
description: "Port for the system-wide health, readiness, and liveness endpoints (/healthz, /livez, /readyz). Set to 0 to disable.",
|
|
2991
2957
|
title: "healthCheckPort",
|
|
2992
2958
|
type: "number"
|
|
2993
2959
|
})
|
|
2994
|
-
}).check(
|
|
2960
|
+
}).check(z16.describe("The complete configuration for the protocol, including global settings and actor-specific overrides"));
|
|
2995
2961
|
function resolveConfig(config) {
|
|
2996
2962
|
const parsedConfig = ConfigZod.parse(config);
|
|
2997
2963
|
const {
|
|
@@ -3000,7 +2966,7 @@ function resolveConfig(config) {
|
|
|
3000
2966
|
...rootConfig
|
|
3001
2967
|
} = parsedConfig;
|
|
3002
2968
|
parsedConfig.actors = actors.map((actorConfig) => {
|
|
3003
|
-
return
|
|
2969
|
+
return z16.looseObject(ActorConfigZod.shape).parse({ ...rootConfig, ...actorConfig });
|
|
3004
2970
|
});
|
|
3005
2971
|
return parsedConfig;
|
|
3006
2972
|
}
|
|
@@ -3011,15 +2977,15 @@ import {
|
|
|
3011
2977
|
zodIsFactory as zodIsFactory3,
|
|
3012
2978
|
zodToFactory as zodToFactory3
|
|
3013
2979
|
} from "@xylabs/sdk-js";
|
|
3014
|
-
import { globalRegistry as
|
|
3015
|
-
var HostActorConfigZod =
|
|
3016
|
-
host:
|
|
2980
|
+
import { globalRegistry as globalRegistry11, z as z17 } from "zod/mini";
|
|
2981
|
+
var HostActorConfigZod = z17.extend(ActorConfigZod, {
|
|
2982
|
+
host: z17._default(z17.string(), "localhost").register(globalRegistry11, {
|
|
3017
2983
|
default: "localhost",
|
|
3018
2984
|
description: "Host for the Actor",
|
|
3019
2985
|
title: "host",
|
|
3020
2986
|
type: "string"
|
|
3021
2987
|
}),
|
|
3022
|
-
port:
|
|
2988
|
+
port: z17._default(z17.coerce.number(), 8080).register(globalRegistry11, {
|
|
3023
2989
|
default: 8080,
|
|
3024
2990
|
description: "Port for the Actor",
|
|
3025
2991
|
title: "port",
|
|
@@ -3030,6 +2996,31 @@ var isHostActorConfig = zodIsFactory3(HostActorConfigZod);
|
|
|
3030
2996
|
var asHostActorConfig = zodAsFactory4(HostActorConfigZod, "asHostActorConfig");
|
|
3031
2997
|
var toHostActorConfig = zodToFactory3(HostActorConfigZod, "toHostActorConfig");
|
|
3032
2998
|
|
|
2999
|
+
// src/config/resolveRestConnectionEndpoint.ts
|
|
3000
|
+
import { assertEx as assertEx21, isDefined as isDefined14 } from "@xylabs/sdk-js";
|
|
3001
|
+
function asRestConnectionConfig(connection) {
|
|
3002
|
+
if (connection?.type !== "rest") return void 0;
|
|
3003
|
+
return connection;
|
|
3004
|
+
}
|
|
3005
|
+
function resolveRestConnectionEndpoint(config, moniker) {
|
|
3006
|
+
const normalized = normalizeConnectionsConfig(config);
|
|
3007
|
+
const binding = normalized.providerBindings[moniker];
|
|
3008
|
+
const connectionName = assertEx21(
|
|
3009
|
+
binding?.connection,
|
|
3010
|
+
() => `Provider "${moniker}" has no providerBindings.connection for REST endpoint resolution`
|
|
3011
|
+
);
|
|
3012
|
+
const rest = assertEx21(
|
|
3013
|
+
asRestConnectionConfig(normalized.connections[connectionName]),
|
|
3014
|
+
() => `Connection "${connectionName}" bound to "${moniker}" is not a rest connection`
|
|
3015
|
+
);
|
|
3016
|
+
const { baseUrl } = rest;
|
|
3017
|
+
assertEx21(
|
|
3018
|
+
isDefined14(baseUrl) && baseUrl !== "",
|
|
3019
|
+
() => `Rest connection "${connectionName}" requires baseUrl`
|
|
3020
|
+
);
|
|
3021
|
+
return baseUrl;
|
|
3022
|
+
}
|
|
3023
|
+
|
|
3033
3024
|
// src/config/synthesizeRpcConnectionBindings.ts
|
|
3034
3025
|
var DEFAULT_RPC_CONNECTION = "default-rpc";
|
|
3035
3026
|
var RPC_MONIKERS = [
|
|
@@ -3056,70 +3047,36 @@ var RPC_MONIKERS = [
|
|
|
3056
3047
|
function synthesizeRpcConnectionBindings() {
|
|
3057
3048
|
const bindings = {};
|
|
3058
3049
|
for (const moniker of RPC_MONIKERS) {
|
|
3059
|
-
bindings[moniker] = { connection: DEFAULT_RPC_CONNECTION
|
|
3050
|
+
bindings[moniker] = { connection: DEFAULT_RPC_CONNECTION };
|
|
3060
3051
|
}
|
|
3061
3052
|
return bindings;
|
|
3062
3053
|
}
|
|
3063
3054
|
|
|
3064
|
-
// src/config/transports/Rpc.ts
|
|
3065
|
-
import { globalRegistry as globalRegistry14, z as z21 } from "zod";
|
|
3066
|
-
var RpcRemoteConfigBaseZod = z21.object({
|
|
3067
|
-
protocol: z21.string("http").register(globalRegistry14, {
|
|
3068
|
-
description: "Protocol for the RPC connection",
|
|
3069
|
-
type: "string"
|
|
3070
|
-
})
|
|
3071
|
-
}).describe("Base configuration for the remote RPC");
|
|
3072
|
-
var HttpRpcRemoteConfigZod = RpcRemoteConfigBaseZod.extend({
|
|
3073
|
-
protocol: z21.string("http").register(globalRegistry14, {
|
|
3074
|
-
description: "Protocol for the RPC connection",
|
|
3075
|
-
type: "string"
|
|
3076
|
-
}).default("http"),
|
|
3077
|
-
url: z21.string().register(globalRegistry14, {
|
|
3078
|
-
description: "URL for the Chain RPC API",
|
|
3079
|
-
type: "string"
|
|
3080
|
-
})
|
|
3081
|
-
}).describe("Configuration for the remote RPC using Http");
|
|
3082
|
-
var PostMessageRpcRemoteConfigZod = RpcRemoteConfigBaseZod.extend({
|
|
3083
|
-
protocol: z21.string().register(globalRegistry14, {
|
|
3084
|
-
description: "Protocol for the RPC connection",
|
|
3085
|
-
type: "string"
|
|
3086
|
-
}).default("postMessage"),
|
|
3087
|
-
networkId: z21.string().register(globalRegistry14, {
|
|
3088
|
-
description: "Network ID to use for the postMessage RPC connection",
|
|
3089
|
-
type: "string"
|
|
3090
|
-
}),
|
|
3091
|
-
sessionId: z21.string().register(globalRegistry14, {
|
|
3092
|
-
description: "Session ID to use for the postMessage RPC connection",
|
|
3093
|
-
type: "string"
|
|
3094
|
-
})
|
|
3095
|
-
}).describe("Configuration for the remote RPC using postMessage");
|
|
3096
|
-
var RpcRemoteConfigZod = z21.union([HttpRpcRemoteConfigZod, PostMessageRpcRemoteConfigZod]).describe("Configuration for a remote RPC connection, either Http or postMessage");
|
|
3097
|
-
|
|
3098
3055
|
// src/config/UsageMeta.ts
|
|
3099
|
-
import { z as
|
|
3100
|
-
var DescriptionSchema =
|
|
3101
|
-
var TitleSchema =
|
|
3102
|
-
var JSONSchemaMetaSchema =
|
|
3103
|
-
id:
|
|
3056
|
+
import { z as z18 } from "zod";
|
|
3057
|
+
var DescriptionSchema = z18.string();
|
|
3058
|
+
var TitleSchema = z18.string();
|
|
3059
|
+
var JSONSchemaMetaSchema = z18.object({
|
|
3060
|
+
id: z18.string().optional(),
|
|
3104
3061
|
title: TitleSchema.optional(),
|
|
3105
3062
|
description: DescriptionSchema.optional(),
|
|
3106
|
-
deprecated:
|
|
3107
|
-
}).catchall(
|
|
3063
|
+
deprecated: z18.boolean().optional()
|
|
3064
|
+
}).catchall(z18.unknown());
|
|
3108
3065
|
var GlobalMetaSchema = JSONSchemaMetaSchema.extend({});
|
|
3109
|
-
var ChoicesSchema =
|
|
3066
|
+
var ChoicesSchema = z18.array(z18.union([z18.string(), z18.number(), z18.literal(true), z18.undefined()])).readonly();
|
|
3110
3067
|
var UsageMetaSchema = GlobalMetaSchema.extend({
|
|
3111
3068
|
choices: ChoicesSchema.optional(),
|
|
3112
|
-
default:
|
|
3069
|
+
default: z18.unknown().optional(),
|
|
3113
3070
|
description: DescriptionSchema,
|
|
3114
|
-
group:
|
|
3115
|
-
hidden:
|
|
3071
|
+
group: z18.string().optional(),
|
|
3072
|
+
hidden: z18.boolean().optional(),
|
|
3116
3073
|
title: TitleSchema,
|
|
3117
|
-
type:
|
|
3118
|
-
|
|
3119
|
-
|
|
3120
|
-
|
|
3121
|
-
|
|
3122
|
-
|
|
3074
|
+
type: z18.union([
|
|
3075
|
+
z18.literal("array"),
|
|
3076
|
+
z18.literal("count"),
|
|
3077
|
+
z18.literal("boolean"),
|
|
3078
|
+
z18.literal("number"),
|
|
3079
|
+
z18.literal("string")
|
|
3123
3080
|
])
|
|
3124
3081
|
});
|
|
3125
3082
|
function isUsageMeta(v) {
|
|
@@ -3132,7 +3089,7 @@ import {
|
|
|
3132
3089
|
zodIsFactory as zodIsFactory5,
|
|
3133
3090
|
zodToFactory as zodToFactory5
|
|
3134
3091
|
} from "@xylabs/sdk-js";
|
|
3135
|
-
import { z as
|
|
3092
|
+
import { z as z20 } from "zod/mini";
|
|
3136
3093
|
|
|
3137
3094
|
// src/model/CreatableProviderContext.zod.ts
|
|
3138
3095
|
import {
|
|
@@ -3141,17 +3098,17 @@ import {
|
|
|
3141
3098
|
zodToFactory as zodToFactory4
|
|
3142
3099
|
} from "@xylabs/sdk-js";
|
|
3143
3100
|
import { CachingContextZod } from "@xyo-network/xl1-protocol-lib";
|
|
3144
|
-
import { z as
|
|
3145
|
-
var RuntimeStatusMonitorZod =
|
|
3146
|
-
var ProviderFactoryLocatorZod =
|
|
3147
|
-
var BaseConfigContextZod =
|
|
3148
|
-
config:
|
|
3149
|
-
locator:
|
|
3101
|
+
import { z as z19 } from "zod/mini";
|
|
3102
|
+
var RuntimeStatusMonitorZod = z19.custom((val) => val !== null && val !== void 0 && typeof val === "object");
|
|
3103
|
+
var ProviderFactoryLocatorZod = z19.lazy(() => z19.custom((val) => val !== null && val !== void 0 && typeof val === "object" && "context" in val && "registry" in val));
|
|
3104
|
+
var BaseConfigContextZod = z19.extend(CachingContextZod, {
|
|
3105
|
+
config: z19.looseObject(BaseConfigZod.shape),
|
|
3106
|
+
locator: z19.optional(ProviderFactoryLocatorZod)
|
|
3150
3107
|
});
|
|
3151
|
-
var CreatableProviderContextZod =
|
|
3152
|
-
_id:
|
|
3108
|
+
var CreatableProviderContextZod = z19.lazy(() => z19.extend(BaseConfigContextZod, {
|
|
3109
|
+
_id: z19.optional(z19.string()),
|
|
3153
3110
|
locator: ProviderFactoryLocatorZod,
|
|
3154
|
-
statusReporter:
|
|
3111
|
+
statusReporter: z19.optional(RuntimeStatusMonitorZod)
|
|
3155
3112
|
}));
|
|
3156
3113
|
var isBaseConfigContext = zodIsFactory4(BaseConfigContextZod);
|
|
3157
3114
|
var asBaseConfigContext = zodAsFactory5(BaseConfigContextZod, "asBaseConfigContext");
|
|
@@ -3201,7 +3158,7 @@ import { PayloadBundleSchema as PayloadBundleSchema2 } from "@xyo-network/sdk-js
|
|
|
3201
3158
|
import { PayloadBuilder as PayloadBuilder12 } from "@xyo-network/sdk-js";
|
|
3202
3159
|
|
|
3203
3160
|
// src/transaction/buildTransaction.ts
|
|
3204
|
-
import { assertEx as
|
|
3161
|
+
import { assertEx as assertEx22, toHex } from "@xylabs/sdk-js";
|
|
3205
3162
|
import {
|
|
3206
3163
|
asAnyPayload as asAnyPayload2,
|
|
3207
3164
|
BoundWitnessBuilder,
|
|
@@ -3227,7 +3184,7 @@ async function buildTransaction(chain, onChainPayloads, offChainPayloads, signer
|
|
|
3227
3184
|
const script = Array.from(elevatedHashes, (elevatedHash) => `elevate|${elevatedHash}`);
|
|
3228
3185
|
const fields = {
|
|
3229
3186
|
...txBoundWitnessFields,
|
|
3230
|
-
from: from ?? (Array.isArray(signer) ?
|
|
3187
|
+
from: from ?? (Array.isArray(signer) ? assertEx22(signer.at(0)?.address) : signer.address)
|
|
3231
3188
|
};
|
|
3232
3189
|
if (script.length > 0) {
|
|
3233
3190
|
fields.script = script;
|
|
@@ -3272,7 +3229,7 @@ async function buildUnsignedTransaction(chain, onChainPayloads, offChainPayloads
|
|
|
3272
3229
|
// src/transaction/confirmSubmittedTransaction.ts
|
|
3273
3230
|
import {
|
|
3274
3231
|
delay,
|
|
3275
|
-
isDefined as
|
|
3232
|
+
isDefined as isDefined15,
|
|
3276
3233
|
isNumber
|
|
3277
3234
|
} from "@xylabs/sdk-js";
|
|
3278
3235
|
var DEFAULT_CONFIRMATION_ATTEMPTS = 20;
|
|
@@ -3294,7 +3251,7 @@ var confirmSubmittedTransaction = async (viewer, txHash, options) => {
|
|
|
3294
3251
|
let attempts = 0;
|
|
3295
3252
|
while (true) {
|
|
3296
3253
|
const tx = await viewer.transaction.byHash(txHash) ?? void 0;
|
|
3297
|
-
if (
|
|
3254
|
+
if (isDefined15(tx)) {
|
|
3298
3255
|
options?.logger?.debug("Transaction confirmed", txHash);
|
|
3299
3256
|
return tx;
|
|
3300
3257
|
}
|
|
@@ -3312,7 +3269,7 @@ var confirmSubmittedTransaction = async (viewer, txHash, options) => {
|
|
|
3312
3269
|
};
|
|
3313
3270
|
|
|
3314
3271
|
// src/transaction/hydrateTransaction.ts
|
|
3315
|
-
import { assertEx as
|
|
3272
|
+
import { assertEx as assertEx23 } from "@xylabs/sdk-js";
|
|
3316
3273
|
import {
|
|
3317
3274
|
asAnyPayload as asAnyPayload3,
|
|
3318
3275
|
hydrateTypedBoundWitness,
|
|
@@ -3383,7 +3340,7 @@ var tryHydrateElevatedTransaction = async ({ chainMap }, hash) => {
|
|
|
3383
3340
|
return void 0;
|
|
3384
3341
|
};
|
|
3385
3342
|
var hydrateElevatedTransaction = async (context, hash) => {
|
|
3386
|
-
return
|
|
3343
|
+
return assertEx23(await tryHydrateElevatedTransaction(context, hash), () => "Hydration failed");
|
|
3387
3344
|
};
|
|
3388
3345
|
|
|
3389
3346
|
// src/transaction/primitives/transactionBlockByteCount.ts
|
|
@@ -3436,13 +3393,13 @@ function transactionRequiredGas(hydratedTransaction) {
|
|
|
3436
3393
|
|
|
3437
3394
|
// src/transaction/signTransaction.ts
|
|
3438
3395
|
import {
|
|
3439
|
-
assertEx as
|
|
3396
|
+
assertEx as assertEx24,
|
|
3440
3397
|
hexFromArrayBuffer,
|
|
3441
3398
|
toArrayBuffer
|
|
3442
3399
|
} from "@xylabs/sdk-js";
|
|
3443
3400
|
import { PayloadBuilder as PayloadBuilder10 } from "@xyo-network/sdk-js";
|
|
3444
3401
|
async function signTransaction(tx, account) {
|
|
3445
|
-
|
|
3402
|
+
assertEx24(tx.from === account.address, () => "Signer address does not match transaction from address");
|
|
3446
3403
|
const unsignedTx = structuredClone(tx);
|
|
3447
3404
|
unsignedTx.addresses = [account.address];
|
|
3448
3405
|
unsignedTx.previous_hashes = [account.previousHash ?? null];
|
|
@@ -3457,7 +3414,7 @@ async function signTransaction(tx, account) {
|
|
|
3457
3414
|
}
|
|
3458
3415
|
|
|
3459
3416
|
// src/transaction/TransactionBuilder.ts
|
|
3460
|
-
import { assertEx as
|
|
3417
|
+
import { assertEx as assertEx25, Base } from "@xylabs/sdk-js";
|
|
3461
3418
|
import { PayloadBuilder as PayloadBuilder11 } from "@xyo-network/sdk-js";
|
|
3462
3419
|
import {
|
|
3463
3420
|
asXL1BlockNumber as asXL1BlockNumber4,
|
|
@@ -3477,9 +3434,9 @@ var TransactionBuilder = class extends Base {
|
|
|
3477
3434
|
super(options);
|
|
3478
3435
|
}
|
|
3479
3436
|
async build() {
|
|
3480
|
-
const chain =
|
|
3481
|
-
const fees =
|
|
3482
|
-
const blockRange =
|
|
3437
|
+
const chain = assertEx25(this._chain, () => "Chain must be set before building the transaction");
|
|
3438
|
+
const fees = assertEx25(this._fees, () => "Fees must be set before building the transaction");
|
|
3439
|
+
const blockRange = assertEx25(this._blockRange, () => "Block range must be set before building the transaction");
|
|
3483
3440
|
return await buildTransaction(
|
|
3484
3441
|
chain,
|
|
3485
3442
|
this._elevatedPayloads,
|
|
@@ -3509,7 +3466,7 @@ var TransactionBuilder = class extends Base {
|
|
|
3509
3466
|
}
|
|
3510
3467
|
elevatedPayload(payload) {
|
|
3511
3468
|
const allowedPayload = isAllowedBlockPayload2(payload) ? payload : void 0;
|
|
3512
|
-
const allowPayloadExists =
|
|
3469
|
+
const allowPayloadExists = assertEx25(allowedPayload, () => "Payload must be an AllowedBlockPayload");
|
|
3513
3470
|
this._elevatedPayloads.push(allowPayloadExists);
|
|
3514
3471
|
return this;
|
|
3515
3472
|
}
|
|
@@ -3605,7 +3562,7 @@ var bundle2 = (root, transaction) => {
|
|
|
3605
3562
|
};
|
|
3606
3563
|
|
|
3607
3564
|
// src/context/Actor.ts
|
|
3608
|
-
var ActorConfigContext =
|
|
3565
|
+
var ActorConfigContext = z20.extend(BaseConfigContextZod, { config: ActorConfigZod });
|
|
3609
3566
|
var isActorConfigContext = zodIsFactory5(ActorConfigContext);
|
|
3610
3567
|
var asActorConfigContext = zodAsFactory6(ActorConfigContext, "asActorConfigContext");
|
|
3611
3568
|
var toActorConfigContext = zodToFactory5(ActorConfigContext, "toActorConfigContext");
|
|
@@ -3616,8 +3573,8 @@ import {
|
|
|
3616
3573
|
zodIsFactory as zodIsFactory6,
|
|
3617
3574
|
zodToFactory as zodToFactory6
|
|
3618
3575
|
} from "@xylabs/sdk-js";
|
|
3619
|
-
import { z as
|
|
3620
|
-
var HostActorConfigContext =
|
|
3576
|
+
import { z as z21 } from "zod/mini";
|
|
3577
|
+
var HostActorConfigContext = z21.extend(BaseConfigContextZod, { config: HostActorConfigZod });
|
|
3621
3578
|
var isHostActorConfigContext = zodIsFactory6(HostActorConfigContext);
|
|
3622
3579
|
var asHostActorConfigContext = zodAsFactory7(HostActorConfigContext, "asHostActorConfigContext");
|
|
3623
3580
|
var toHostActorConfigContext = zodToFactory6(HostActorConfigContext, "toHostActorConfigContext");
|
|
@@ -3625,7 +3582,7 @@ var toHostActorConfigContext = zodToFactory6(HostActorConfigContext, "toHostActo
|
|
|
3625
3582
|
// src/CreatableProvider/AbstractCreatableProvider.ts
|
|
3626
3583
|
import {
|
|
3627
3584
|
AbstractCreatable,
|
|
3628
|
-
assertEx as
|
|
3585
|
+
assertEx as assertEx26,
|
|
3629
3586
|
IdLogger
|
|
3630
3587
|
} from "@xylabs/sdk-js";
|
|
3631
3588
|
var AbstractCreatableProvider = class extends AbstractCreatable {
|
|
@@ -3659,9 +3616,9 @@ var AbstractCreatableProvider = class extends AbstractCreatable {
|
|
|
3659
3616
|
return factory;
|
|
3660
3617
|
}
|
|
3661
3618
|
static async paramsHandler(params = {}) {
|
|
3662
|
-
const context =
|
|
3663
|
-
const config =
|
|
3664
|
-
const locator =
|
|
3619
|
+
const context = assertEx26(params.context, () => new Error("Context is required"));
|
|
3620
|
+
const config = assertEx26(context.config, () => new Error("Context config is required"));
|
|
3621
|
+
const locator = assertEx26(context.locator, () => new Error("Context locator is required"));
|
|
3665
3622
|
return await super.paramsHandler({
|
|
3666
3623
|
...params,
|
|
3667
3624
|
statusReporter: params.statusReporter ?? context.statusReporter,
|
|
@@ -3704,13 +3661,13 @@ function labeledCreatableProvider() {
|
|
|
3704
3661
|
}
|
|
3705
3662
|
|
|
3706
3663
|
// src/createDeclarationPayload.ts
|
|
3707
|
-
import { isDefined as
|
|
3664
|
+
import { isDefined as isDefined16 } from "@xylabs/sdk-js";
|
|
3708
3665
|
import { PayloadBuilder as PayloadBuilder13 } from "@xyo-network/sdk-js";
|
|
3709
3666
|
import {
|
|
3710
3667
|
ChainStakeIntentSchema
|
|
3711
3668
|
} from "@xyo-network/xl1-protocol-lib";
|
|
3712
3669
|
var createDeclarationIntent = (address, intent, nbf, exp) => {
|
|
3713
|
-
const expiration =
|
|
3670
|
+
const expiration = isDefined16(exp) ? exp : nbf + 1e4;
|
|
3714
3671
|
const payloadBuilder = new PayloadBuilder13({ schema: ChainStakeIntentSchema });
|
|
3715
3672
|
const builder = payloadBuilder.fields({
|
|
3716
3673
|
from: address,
|
|
@@ -3742,26 +3699,26 @@ import {
|
|
|
3742
3699
|
asSchema as asSchema2,
|
|
3743
3700
|
isPayloadOfZodType
|
|
3744
3701
|
} from "@xyo-network/sdk-js";
|
|
3745
|
-
import { z as
|
|
3702
|
+
import { z as z23 } from "zod";
|
|
3746
3703
|
|
|
3747
3704
|
// src/eip-712/Types.ts
|
|
3748
|
-
import { z as
|
|
3749
|
-
var TypedDataDomainZod =
|
|
3750
|
-
name:
|
|
3751
|
-
version:
|
|
3752
|
-
chainId:
|
|
3753
|
-
verifyingContract:
|
|
3754
|
-
salt:
|
|
3705
|
+
import { z as z22 } from "zod";
|
|
3706
|
+
var TypedDataDomainZod = z22.object({
|
|
3707
|
+
name: z22.string().nullable().optional(),
|
|
3708
|
+
version: z22.string().nullable().optional(),
|
|
3709
|
+
chainId: z22.union([z22.string(), z22.number(), z22.bigint()]).nullable().optional(),
|
|
3710
|
+
verifyingContract: z22.string().nullable().optional(),
|
|
3711
|
+
salt: z22.union([z22.string(), z22.instanceof(Uint8Array)]).nullable().optional()
|
|
3755
3712
|
});
|
|
3756
|
-
var TypedDataFieldZod =
|
|
3757
|
-
name:
|
|
3758
|
-
type:
|
|
3713
|
+
var TypedDataFieldZod = z22.object({
|
|
3714
|
+
name: z22.string(),
|
|
3715
|
+
type: z22.string()
|
|
3759
3716
|
});
|
|
3760
|
-
var TypedDataTypesZod =
|
|
3761
|
-
var TypedDataValueZod =
|
|
3717
|
+
var TypedDataTypesZod = z22.record(z22.string(), z22.array(TypedDataFieldZod));
|
|
3718
|
+
var TypedDataValueZod = z22.record(z22.string(), z22.any());
|
|
3762
3719
|
|
|
3763
3720
|
// src/eip-712/Payloads/EIP712Data.ts
|
|
3764
|
-
var EIP712DataPayloadFieldsZod =
|
|
3721
|
+
var EIP712DataPayloadFieldsZod = z23.object({
|
|
3765
3722
|
domain: TypedDataDomainZod,
|
|
3766
3723
|
types: TypedDataTypesZod,
|
|
3767
3724
|
values: TypedDataValueZod
|
|
@@ -3779,11 +3736,11 @@ import {
|
|
|
3779
3736
|
asSchema as asSchema3,
|
|
3780
3737
|
isPayloadOfZodType as isPayloadOfZodType2
|
|
3781
3738
|
} from "@xyo-network/sdk-js";
|
|
3782
|
-
import { z as
|
|
3783
|
-
var EIP712SignaturePayloadFieldsZod =
|
|
3784
|
-
address:
|
|
3739
|
+
import { z as z24 } from "zod";
|
|
3740
|
+
var EIP712SignaturePayloadFieldsZod = z24.object({
|
|
3741
|
+
address: z24.string(),
|
|
3785
3742
|
hash: HashZod,
|
|
3786
|
-
signature:
|
|
3743
|
+
signature: z24.string()
|
|
3787
3744
|
});
|
|
3788
3745
|
var EIP712SignaturePayloadSchema = asSchema3("network.xyo.chains.ethereum.eip712.signature", true);
|
|
3789
3746
|
var isEIP712SignaturePayload = isPayloadOfZodType2(
|
|
@@ -3892,9 +3849,9 @@ var toPositiveBigInt = (value) => {
|
|
|
3892
3849
|
// src/simple/accountBalance/SimpleAccountBalanceViewer.ts
|
|
3893
3850
|
import {
|
|
3894
3851
|
asHash as asHash4,
|
|
3895
|
-
assertEx as
|
|
3852
|
+
assertEx as assertEx34,
|
|
3896
3853
|
exists as exists3,
|
|
3897
|
-
isDefined as
|
|
3854
|
+
isDefined as isDefined17,
|
|
3898
3855
|
ZERO_ADDRESS
|
|
3899
3856
|
} from "@xylabs/sdk-js";
|
|
3900
3857
|
import {
|
|
@@ -3960,18 +3917,18 @@ var asTransfersStepSummaryWithStorageMeta = AsObjectFactory7.create(isTransfersS
|
|
|
3960
3917
|
var balancesMaxStep = 5;
|
|
3961
3918
|
|
|
3962
3919
|
// src/summary/primitives/balances/balancesStepSummaryFromRange.ts
|
|
3963
|
-
import { assertEx as
|
|
3920
|
+
import { assertEx as assertEx27, spanRootAsync as spanRootAsync2 } from "@xylabs/sdk-js";
|
|
3964
3921
|
import { isAnyPayload as isAnyPayload3 } from "@xyo-network/sdk-js";
|
|
3965
3922
|
import { asXL1BlockNumber as asXL1BlockNumber5, StepSizes as StepSizes8 } from "@xyo-network/xl1-protocol-lib";
|
|
3966
3923
|
async function balancesStepSummaryFromRange(context, semaphores, blockViewer, summaryMap, range) {
|
|
3967
3924
|
const cacheKey = `${range[0]}|${range[1]}`;
|
|
3968
3925
|
return await withContextCacheResponse(context, "balancesStepSummaryFromRange", cacheKey, async () => {
|
|
3969
3926
|
return await spanRootAsync2("balancesStepSummaryFromRange", async () => {
|
|
3970
|
-
const [frameHead] =
|
|
3927
|
+
const [frameHead] = assertEx27(await blockViewer.blockByNumber(range[1]), () => `Block not found for number: ${range[1]}`);
|
|
3971
3928
|
const frameSize = range[1] - range[0] + 1;
|
|
3972
3929
|
const key = `${frameHead._hash}|${frameSize}`;
|
|
3973
3930
|
return frameSize === 1 ? await spanRootAsync2(`balancesStepSummaryFromRange.frameSize=1[${key}]`, async () => {
|
|
3974
|
-
const [, payloads] =
|
|
3931
|
+
const [, payloads] = assertEx27(await blockViewer.blockByNumber(range[0]), () => `Block not found for number: ${range[0]}`);
|
|
3975
3932
|
const balances = {};
|
|
3976
3933
|
for (const [address, balance] of Object.entries(netBalancesForPayloads(context, payloads))) {
|
|
3977
3934
|
balances[address] = toSignedBigInt(balance);
|
|
@@ -3984,7 +3941,7 @@ async function balancesStepSummaryFromRange(context, semaphores, blockViewer, su
|
|
|
3984
3941
|
};
|
|
3985
3942
|
}, { ...context, timeBudgetLimit: 500 }) : await spanRootAsync2(`balancesStepSummaryFromRange.frameSize>1[${key}]`, async () => {
|
|
3986
3943
|
const step = StepSizes8.indexOf(asXL1BlockNumber5(frameSize, true));
|
|
3987
|
-
|
|
3944
|
+
assertEx27(step !== -1, () => `Invalid step size: ${frameSize}. Must be one of ${StepSizes8.join(", ")}`);
|
|
3988
3945
|
const summaryResult = await summaryMap.get(`${frameHead._hash}|${frameSize}`);
|
|
3989
3946
|
if (isAnyPayload3(summaryResult)) {
|
|
3990
3947
|
return summaryResult;
|
|
@@ -4027,7 +3984,7 @@ async function balancesStepSummaryFromRange(context, semaphores, blockViewer, su
|
|
|
4027
3984
|
}
|
|
4028
3985
|
|
|
4029
3986
|
// src/summary/primitives/balances/balancesSummary.ts
|
|
4030
|
-
import { assertEx as
|
|
3987
|
+
import { assertEx as assertEx28, spanRootAsync as spanRootAsync3 } from "@xylabs/sdk-js";
|
|
4031
3988
|
import { asXyoAddress } from "@xyo-network/sdk-js";
|
|
4032
3989
|
import {
|
|
4033
3990
|
asBlockBoundWitnessWithStorageMeta as asBlockBoundWitnessWithStorageMeta3,
|
|
@@ -4038,7 +3995,7 @@ import {
|
|
|
4038
3995
|
async function balancesSummary(context, semaphores, blockViewer, summaryMap, config) {
|
|
4039
3996
|
return await spanRootAsync3("balancesSummary", async () => {
|
|
4040
3997
|
const headHash = isChainQualifiedHeadConfig(config) ? config.head : await blockViewer.currentBlockHash();
|
|
4041
|
-
const [head] =
|
|
3998
|
+
const [head] = assertEx28(await blockViewer.blockByHash(headHash), () => `Block not found for hash: ${headHash}`);
|
|
4042
3999
|
const headBoundWitness = asBlockBoundWitnessWithStorageMeta3(head, () => `Found Block not a BlockWithHashMeta: ${headHash}`);
|
|
4043
4000
|
const range = isChainQualifiedRangeConfig(config) ? config.range : asXL1BlockRange7([0, headBoundWitness.block], true);
|
|
4044
4001
|
const ranges = deepCalculateFramesFromRange(asXL1BlockRange7(
|
|
@@ -4061,7 +4018,7 @@ async function balancesSummary(context, semaphores, blockViewer, summaryMap, con
|
|
|
4061
4018
|
var blocksMaxStep = 3;
|
|
4062
4019
|
|
|
4063
4020
|
// src/summary/primitives/blocks/blocksStepSummaryFromRange.ts
|
|
4064
|
-
import { assertEx as
|
|
4021
|
+
import { assertEx as assertEx29, spanRootAsync as spanRootAsync4 } from "@xylabs/sdk-js";
|
|
4065
4022
|
import { isAnyPayload as isAnyPayload4 } from "@xyo-network/sdk-js";
|
|
4066
4023
|
import {
|
|
4067
4024
|
asBlocksStepSummary,
|
|
@@ -4076,7 +4033,7 @@ async function blocksStepSummaryFromRange(context, semaphores, blockViewer, summ
|
|
|
4076
4033
|
const cacheKey = `${range[0]}|${range[1]}`;
|
|
4077
4034
|
return await withContextCacheResponse(context, "blocksStepSummaryFromRange", cacheKey, async () => {
|
|
4078
4035
|
return await spanRootAsync4("blocksStepSummaryFromRange", async () => {
|
|
4079
|
-
const frameHead =
|
|
4036
|
+
const frameHead = assertEx29(
|
|
4080
4037
|
await blockViewer.blockByNumber(range[1]),
|
|
4081
4038
|
() => `Block not found for number: ${range[1]}`
|
|
4082
4039
|
);
|
|
@@ -4092,7 +4049,7 @@ async function blocksStepSummaryFromRange(context, semaphores, blockViewer, summ
|
|
|
4092
4049
|
};
|
|
4093
4050
|
} else {
|
|
4094
4051
|
const step = StepSizes9.indexOf(asXL1BlockNumber6(frameSize, true));
|
|
4095
|
-
|
|
4052
|
+
assertEx29(step !== -1, () => `Invalid step size: ${frameSize}. Must be one of ${StepSizes9.join(", ")}`);
|
|
4096
4053
|
const key = blocksStepSummaryKey(frameHeadHash, frameSize);
|
|
4097
4054
|
const summaryResult = await summaryMap.get(key);
|
|
4098
4055
|
if (isAnyPayload4(summaryResult)) {
|
|
@@ -4130,7 +4087,7 @@ async function blocksStepSummaryFromRange(context, semaphores, blockViewer, summ
|
|
|
4130
4087
|
var schemasMaxStep = 5;
|
|
4131
4088
|
|
|
4132
4089
|
// src/summary/primitives/schemas/schemasStepSummaryFromRange.ts
|
|
4133
|
-
import { assertEx as
|
|
4090
|
+
import { assertEx as assertEx30 } from "@xylabs/sdk-js";
|
|
4134
4091
|
import {
|
|
4135
4092
|
isAnyPayload as isAnyPayload5,
|
|
4136
4093
|
isBoundWitness as isBoundWitness2,
|
|
@@ -4139,11 +4096,11 @@ import {
|
|
|
4139
4096
|
} from "@xyo-network/sdk-js";
|
|
4140
4097
|
import { StepSizes as StepSizes10 } from "@xyo-network/xl1-protocol-lib";
|
|
4141
4098
|
async function schemasStepSummaryFromRange(context, semaphores, blockViewer, summaryMap, range) {
|
|
4142
|
-
const [frameHead] =
|
|
4099
|
+
const [frameHead] = assertEx30(await blockViewer.blockByNumber(range[1]), () => `Block not found for number: ${range[1]}`);
|
|
4143
4100
|
const frameSize = range[1] - range[0] + 1;
|
|
4144
4101
|
let result;
|
|
4145
4102
|
if (frameSize === 1) {
|
|
4146
|
-
const [block, payloads] =
|
|
4103
|
+
const [block, payloads] = assertEx30(await blockViewer.blockByNumber(range[0]), () => `Block not found for number: ${range[0]}`);
|
|
4147
4104
|
const boundWitnesses = [block, ...payloads.filter((x) => isBoundWitness2(x) && isHashMeta(x))];
|
|
4148
4105
|
const schemas = {};
|
|
4149
4106
|
for (const bw of boundWitnesses) {
|
|
@@ -4160,7 +4117,7 @@ async function schemasStepSummaryFromRange(context, semaphores, blockViewer, sum
|
|
|
4160
4117
|
});
|
|
4161
4118
|
} else {
|
|
4162
4119
|
const step = StepSizes10.indexOf(frameSize);
|
|
4163
|
-
|
|
4120
|
+
assertEx30(step !== -1, () => `Invalid step size: ${frameSize}. Must be one of ${StepSizes10.join(", ")}`);
|
|
4164
4121
|
const summaryResult = await summaryMap.get(`${frameHead._hash}|${frameSize}`);
|
|
4165
4122
|
if (isAnyPayload5(summaryResult)) {
|
|
4166
4123
|
result = summaryResult;
|
|
@@ -4199,7 +4156,7 @@ async function schemasStepSummaryFromRange(context, semaphores, blockViewer, sum
|
|
|
4199
4156
|
}
|
|
4200
4157
|
|
|
4201
4158
|
// src/summary/primitives/schemas/schemasSummary.ts
|
|
4202
|
-
import { assertEx as
|
|
4159
|
+
import { assertEx as assertEx31, spanRootAsync as spanRootAsync5 } from "@xylabs/sdk-js";
|
|
4203
4160
|
import {
|
|
4204
4161
|
asBlockBoundWitnessWithStorageMeta as asBlockBoundWitnessWithStorageMeta4,
|
|
4205
4162
|
asXL1BlockRange as asXL1BlockRange8,
|
|
@@ -4209,7 +4166,7 @@ import {
|
|
|
4209
4166
|
async function schemasSummary(context, semaphores, blockViewer, summaryMap, config) {
|
|
4210
4167
|
return await spanRootAsync5("schemasSummary", async () => {
|
|
4211
4168
|
const headHash = isChainQualifiedHeadConfig2(config) ? config.head : await blockViewer.currentBlockHash();
|
|
4212
|
-
const [head] =
|
|
4169
|
+
const [head] = assertEx31(await blockViewer.blockByHash(headHash), () => `Block not found for hash: ${headHash}`);
|
|
4213
4170
|
const headBoundWitness = asBlockBoundWitnessWithStorageMeta4(head, () => `Found Block not a BlockWithHashMeta: ${headHash}`);
|
|
4214
4171
|
const range = isChainQualifiedRangeConfig2(config) ? config.range : asXL1BlockRange8([0, headBoundWitness.block], true);
|
|
4215
4172
|
const ranges = deepCalculateFramesFromRange(asXL1BlockRange8(
|
|
@@ -4232,7 +4189,7 @@ async function schemasSummary(context, semaphores, blockViewer, summaryMap, conf
|
|
|
4232
4189
|
var transfersMaxStep = 4;
|
|
4233
4190
|
|
|
4234
4191
|
// src/summary/primitives/transfers/transfersStepSummaryFromRange.ts
|
|
4235
|
-
import { assertEx as
|
|
4192
|
+
import { assertEx as assertEx32, spanRootAsync as spanRootAsync6 } from "@xylabs/sdk-js";
|
|
4236
4193
|
import { isAnyPayload as isAnyPayload6 } from "@xyo-network/sdk-js";
|
|
4237
4194
|
import { asXL1BlockNumber as asXL1BlockNumber7, StepSizes as StepSizes11 } from "@xyo-network/xl1-protocol-lib";
|
|
4238
4195
|
function transfersSummaryKey(frameHeadHash, frameSize) {
|
|
@@ -4242,11 +4199,11 @@ async function transfersStepSummaryFromRange(context, semaphores, blockViewer, s
|
|
|
4242
4199
|
const cacheKey = `${range[0]}|${range[1]}`;
|
|
4243
4200
|
return await withContextCacheResponse(context, "transfersStepSummaryFromRange", cacheKey, async () => {
|
|
4244
4201
|
return await spanRootAsync6("transfersStepSummaryFromRange", async () => {
|
|
4245
|
-
const [frameHead] =
|
|
4202
|
+
const [frameHead] = assertEx32(await blockViewer.blockByNumber(range[1]), () => `Block not found for number: ${range[1]}`);
|
|
4246
4203
|
const frameSize = range[1] - range[0] + 1;
|
|
4247
4204
|
let result;
|
|
4248
4205
|
if (frameSize === 1) {
|
|
4249
|
-
const [, payloads] =
|
|
4206
|
+
const [, payloads] = assertEx32(await blockViewer.blockByNumber(range[0]), () => `Block not found for number: ${range[0]}`);
|
|
4250
4207
|
const transfers = {};
|
|
4251
4208
|
for (const [from, toMap] of Object.entries(netTransfersForPayloads(context, payloads))) {
|
|
4252
4209
|
transfers[from] = transfers[from] ?? {};
|
|
@@ -4262,7 +4219,7 @@ async function transfersStepSummaryFromRange(context, semaphores, blockViewer, s
|
|
|
4262
4219
|
};
|
|
4263
4220
|
} else {
|
|
4264
4221
|
const step = StepSizes11.indexOf(asXL1BlockNumber7(frameSize, true));
|
|
4265
|
-
|
|
4222
|
+
assertEx32(step !== -1, () => `Invalid step size: ${frameSize}. Must be one of ${StepSizes11.join(", ")}`);
|
|
4266
4223
|
const key = transfersSummaryKey(frameHead._hash, frameSize);
|
|
4267
4224
|
const summaryResult = await summaryMap.get(key);
|
|
4268
4225
|
if (isAnyPayload6(summaryResult)) {
|
|
@@ -4313,7 +4270,7 @@ async function transfersStepSummaryFromRange(context, semaphores, blockViewer, s
|
|
|
4313
4270
|
}
|
|
4314
4271
|
|
|
4315
4272
|
// src/summary/primitives/transfers/transfersSummary.ts
|
|
4316
|
-
import { assertEx as
|
|
4273
|
+
import { assertEx as assertEx33, spanRootAsync as spanRootAsync7 } from "@xylabs/sdk-js";
|
|
4317
4274
|
import { asXyoAddress as asXyoAddress2 } from "@xyo-network/sdk-js";
|
|
4318
4275
|
import {
|
|
4319
4276
|
asBlockBoundWitnessWithStorageMeta as asBlockBoundWitnessWithStorageMeta5,
|
|
@@ -4324,7 +4281,7 @@ import {
|
|
|
4324
4281
|
async function transfersSummary(context, semaphores, blockViewer, summaryMap, config) {
|
|
4325
4282
|
return await spanRootAsync7("transferSummary", async () => {
|
|
4326
4283
|
const headHash = isChainQualifiedHeadConfig3(config) ? config.head : await blockViewer.currentBlockHash();
|
|
4327
|
-
const [head] =
|
|
4284
|
+
const [head] = assertEx33(await blockViewer.blockByHash(headHash), () => `Block not found for hash: ${headHash}`);
|
|
4328
4285
|
const headBoundWitness = asBlockBoundWitnessWithStorageMeta5(head, () => `Found Block not a BlockWithHashMeta: ${headHash}`);
|
|
4329
4286
|
const range = isChainQualifiedRangeConfig3(config) ? config.range : asXL1BlockRange9([0, headBoundWitness.block], true);
|
|
4330
4287
|
const ranges = deepCalculateFramesFromRange(asXL1BlockRange9(
|
|
@@ -4365,8 +4322,8 @@ var SimpleAccountBalanceViewer = class extends AbstractCreatableProvider {
|
|
|
4365
4322
|
static async paramsHandler(params = {}) {
|
|
4366
4323
|
return {
|
|
4367
4324
|
...await super.paramsHandler(params),
|
|
4368
|
-
balancesSummaryMap:
|
|
4369
|
-
transfersSummaryMap:
|
|
4325
|
+
balancesSummaryMap: assertEx34(params.balancesSummaryMap, () => "balancesSummaryMap is required"),
|
|
4326
|
+
transfersSummaryMap: assertEx34(params.transfersSummaryMap, () => "transfersSummaryMap is required")
|
|
4370
4327
|
};
|
|
4371
4328
|
}
|
|
4372
4329
|
async accountBalance(address, config) {
|
|
@@ -4389,11 +4346,11 @@ var SimpleAccountBalanceViewer = class extends AbstractCreatableProvider {
|
|
|
4389
4346
|
const transferIndexes = block[0].payload_schemas.map((schema, index) => schema === TransferSchema2 ? index : void 0).filter(exists3);
|
|
4390
4347
|
const transfers = transferIndexes.map((index) => {
|
|
4391
4348
|
const hash = block[0].payload_hashes[index];
|
|
4392
|
-
return
|
|
4349
|
+
return assertEx34(
|
|
4393
4350
|
block[1].find((p) => p._hash === hash),
|
|
4394
4351
|
() => `Error: Could not find Transfer with hash ${hash} in block ${block[0]._hash}`
|
|
4395
4352
|
);
|
|
4396
|
-
}).filter(exists3).filter((t) => t.from === address ||
|
|
4353
|
+
}).filter(exists3).filter((t) => t.from === address || isDefined17(t.transfers[address]));
|
|
4397
4354
|
if (transfers.length === 0) {
|
|
4398
4355
|
continue;
|
|
4399
4356
|
}
|
|
@@ -4422,7 +4379,7 @@ var SimpleAccountBalanceViewer = class extends AbstractCreatableProvider {
|
|
|
4422
4379
|
const head = isChainQualifiedHeadConfig4(config) ? config.head : await this.blockViewer.currentBlockHash();
|
|
4423
4380
|
const range = isChainQualifiedRangeConfig4(config) ? config.range : asXL1BlockRange10([
|
|
4424
4381
|
0,
|
|
4425
|
-
|
|
4382
|
+
assertEx34(
|
|
4426
4383
|
await this.blockViewer.blockByHash(head),
|
|
4427
4384
|
() => `Error: Could not find block with hash ${head}`
|
|
4428
4385
|
)[0].block
|
|
@@ -4437,11 +4394,11 @@ var SimpleAccountBalanceViewer = class extends AbstractCreatableProvider {
|
|
|
4437
4394
|
const qualifiedRange = qualifiedEntries[0][1][1].range;
|
|
4438
4395
|
const qualifiedHeadHash = qualifiedEntries[0][1][1].head;
|
|
4439
4396
|
for (const [_, [__, { range: range2, head: head2 }]] of qualifiedEntries) {
|
|
4440
|
-
|
|
4397
|
+
assertEx34(
|
|
4441
4398
|
range2[0] === qualifiedRange[0] && range2[1] === qualifiedRange[1],
|
|
4442
4399
|
() => "Inconsistent ranges in qualifiedAccountBalanceHistories"
|
|
4443
4400
|
);
|
|
4444
|
-
|
|
4401
|
+
assertEx34(
|
|
4445
4402
|
head2 === qualifiedHeadHash,
|
|
4446
4403
|
() => "Inconsistent head hashes in qualifiedAccountBalanceHistories"
|
|
4447
4404
|
);
|
|
@@ -4512,7 +4469,7 @@ var SimpleAccountBalanceViewer = class extends AbstractCreatableProvider {
|
|
|
4512
4469
|
return await this.spanAsync("qualifiedAccountBalanceHistory", async () => {
|
|
4513
4470
|
const range = asRange(headOrRange);
|
|
4514
4471
|
const headHash = asHash4(headOrRange);
|
|
4515
|
-
const [head] =
|
|
4472
|
+
const [head] = assertEx34(isDefined17(headHash) ? await this.blockViewer.blockByHash(headHash) : await this.blockViewer.currentBlock(), () => "Could not resolve head block");
|
|
4516
4473
|
const startingRange = asXL1BlockRange10(range ?? [0, head.block], true);
|
|
4517
4474
|
const blockNumbers = await this.distillTransferHistory(address, startingRange);
|
|
4518
4475
|
const blockResults = await Promise.all(blockNumbers.map(async (bn) => await this.blockViewer.blockByNumber(bn)));
|
|
@@ -4522,11 +4479,11 @@ var SimpleAccountBalanceViewer = class extends AbstractCreatableProvider {
|
|
|
4522
4479
|
const transferIndexes = block[0].payload_schemas.map((schema, index) => schema === TransferSchema2 ? index : void 0).filter(exists3);
|
|
4523
4480
|
const transfers = transferIndexes.map((index) => {
|
|
4524
4481
|
const hash = block[0].payload_hashes[index];
|
|
4525
|
-
return
|
|
4482
|
+
return assertEx34(
|
|
4526
4483
|
block[1].find((p) => p._hash === hash),
|
|
4527
4484
|
() => `Error: Could not find Transfer with hash ${hash} in block ${block[0]._hash}`
|
|
4528
4485
|
);
|
|
4529
|
-
}).filter(exists3).filter((t) => t.from === address ||
|
|
4486
|
+
}).filter(exists3).filter((t) => t.from === address || isDefined17(t.transfers[address]));
|
|
4530
4487
|
if (transfers.length === 0) {
|
|
4531
4488
|
continue;
|
|
4532
4489
|
}
|
|
@@ -4554,7 +4511,7 @@ SimpleAccountBalanceViewer = __decorateClass([
|
|
|
4554
4511
|
|
|
4555
4512
|
// src/simple/block/SimpleBlockViewer.ts
|
|
4556
4513
|
import {
|
|
4557
|
-
assertEx as
|
|
4514
|
+
assertEx as assertEx35,
|
|
4558
4515
|
exists as exists4,
|
|
4559
4516
|
isUndefined as isUndefined7
|
|
4560
4517
|
} from "@xylabs/sdk-js";
|
|
@@ -4595,12 +4552,12 @@ var HydratedCache = class {
|
|
|
4595
4552
|
};
|
|
4596
4553
|
|
|
4597
4554
|
// src/utils/isZodError.ts
|
|
4598
|
-
import { z as
|
|
4555
|
+
import { z as z25 } from "zod";
|
|
4599
4556
|
var isZodError = (error) => {
|
|
4600
|
-
return error instanceof
|
|
4557
|
+
return error instanceof z25.ZodError;
|
|
4601
4558
|
};
|
|
4602
4559
|
var prettifyZodError = (error) => {
|
|
4603
|
-
return
|
|
4560
|
+
return z25.prettifyError(error);
|
|
4604
4561
|
};
|
|
4605
4562
|
|
|
4606
4563
|
// src/simple/block/SimpleBlockViewer.ts
|
|
@@ -4618,7 +4575,7 @@ var SimpleBlockViewer = class extends AbstractCreatableProvider {
|
|
|
4618
4575
|
_headPollTimer = null;
|
|
4619
4576
|
_signedHydratedBlockCache;
|
|
4620
4577
|
get finalizedArchivist() {
|
|
4621
|
-
return
|
|
4578
|
+
return assertEx35(this.params.finalizedArchivist, () => "finalizedArchivist is required \u2014 inject it or bind a connection");
|
|
4622
4579
|
}
|
|
4623
4580
|
get blocksSummaryMap() {
|
|
4624
4581
|
this._blocksSummaryMap ??= this.params.blocksSummaryMap ?? new LruCacheMap2({ max: 32 });
|
|
@@ -4642,14 +4599,14 @@ var SimpleBlockViewer = class extends AbstractCreatableProvider {
|
|
|
4642
4599
|
static async paramsHandler(params) {
|
|
4643
4600
|
const headPollIntervalMs = params.headPollIntervalMs;
|
|
4644
4601
|
if (headPollIntervalMs !== void 0) {
|
|
4645
|
-
|
|
4602
|
+
assertEx35(headPollIntervalMs >= MIN_HEAD_POLL_INTERVAL_MS, () => `headPollIntervalMs must be at least ${MIN_HEAD_POLL_INTERVAL_MS}ms`);
|
|
4646
4603
|
}
|
|
4647
4604
|
const connection = params.connection;
|
|
4648
4605
|
const finalizedArchivist = params.finalizedArchivist ?? (connection ? await connectArchivist(connection, { name: CHAIN_ARCHIVIST_ROLE }) : void 0);
|
|
4649
4606
|
return {
|
|
4650
4607
|
...await super.paramsHandler(params),
|
|
4651
4608
|
blocksSummaryMap: params.blocksSummaryMap,
|
|
4652
|
-
finalizedArchivist:
|
|
4609
|
+
finalizedArchivist: assertEx35(finalizedArchivist, () => "finalizedArchivist is required \u2014 inject it or bind a connection"),
|
|
4653
4610
|
headPollIntervalMs
|
|
4654
4611
|
};
|
|
4655
4612
|
}
|
|
@@ -4678,8 +4635,8 @@ var SimpleBlockViewer = class extends AbstractCreatableProvider {
|
|
|
4678
4635
|
}
|
|
4679
4636
|
async blocksByHash(hash, limit = 50) {
|
|
4680
4637
|
return await this.spanAsync("blocksByHash", async () => {
|
|
4681
|
-
|
|
4682
|
-
|
|
4638
|
+
assertEx35(limit > 0, () => "limit must be greater than 0");
|
|
4639
|
+
assertEx35(limit <= 100, () => "limit must be less than 100");
|
|
4683
4640
|
const blocks = [];
|
|
4684
4641
|
let current = await this.blockByHash(hash);
|
|
4685
4642
|
while (current && blocks.length < limit) {
|
|
@@ -4693,8 +4650,8 @@ var SimpleBlockViewer = class extends AbstractCreatableProvider {
|
|
|
4693
4650
|
}
|
|
4694
4651
|
async blocksByNumber(blockNumber, limit = 50) {
|
|
4695
4652
|
return await this.spanAsync("blocksByNumber", async () => {
|
|
4696
|
-
|
|
4697
|
-
|
|
4653
|
+
assertEx35(limit > 0, () => "limit must be greater than 0");
|
|
4654
|
+
assertEx35(limit <= 100, () => "limit must be less than 100");
|
|
4698
4655
|
const chainContext = await this.getChainContextRead();
|
|
4699
4656
|
if (isUndefined7(chainContext.head)) {
|
|
4700
4657
|
return [];
|
|
@@ -4712,9 +4669,9 @@ var SimpleBlockViewer = class extends AbstractCreatableProvider {
|
|
|
4712
4669
|
}
|
|
4713
4670
|
async blocksByStep(stepLevel, stepIndex) {
|
|
4714
4671
|
return await this.spanAsync("blocksByStep", async () => {
|
|
4715
|
-
|
|
4672
|
+
assertEx35(Number.isSafeInteger(stepIndex) && stepIndex >= 0, () => "stepIndex must be a non-negative integer");
|
|
4716
4673
|
const size = stepSize2(stepLevel);
|
|
4717
|
-
|
|
4674
|
+
assertEx35(
|
|
4718
4675
|
stepLevel <= blocksMaxStep,
|
|
4719
4676
|
() => `blocksByStep does not support step levels above ${blocksMaxStep} (requested ${stepLevel})`
|
|
4720
4677
|
);
|
|
@@ -4740,7 +4697,7 @@ var SimpleBlockViewer = class extends AbstractCreatableProvider {
|
|
|
4740
4697
|
const headBlock = await this.finalizationViewer.headBlock();
|
|
4741
4698
|
return headBlock.chain;
|
|
4742
4699
|
}
|
|
4743
|
-
const block =
|
|
4700
|
+
const block = assertEx35(await this.blockByNumber(blockNumber), () => `Block not found [${blockNumber}]`);
|
|
4744
4701
|
return block[0].chain;
|
|
4745
4702
|
}, this.context);
|
|
4746
4703
|
}
|
|
@@ -4876,7 +4833,7 @@ SimpleBlockRewardViewer = __decorateClass([
|
|
|
4876
4833
|
], SimpleBlockRewardViewer);
|
|
4877
4834
|
|
|
4878
4835
|
// src/simple/blockValidation/SimpleBlockValidationViewer.ts
|
|
4879
|
-
import { assertEx as
|
|
4836
|
+
import { assertEx as assertEx36 } from "@xylabs/sdk-js";
|
|
4880
4837
|
import { PayloadBuilder as PayloadBuilder18 } from "@xyo-network/sdk-js";
|
|
4881
4838
|
import {
|
|
4882
4839
|
AccountBalanceViewerMoniker as AccountBalanceViewerMoniker2,
|
|
@@ -4932,7 +4889,7 @@ var SimpleBlockValidationViewer = class extends AbstractCreatableProvider {
|
|
|
4932
4889
|
let head;
|
|
4933
4890
|
if (isChainQualifiedHeadConfig5(config)) {
|
|
4934
4891
|
const headBlockResult = await this.blockViewer.blockByHash(config.head);
|
|
4935
|
-
head = headBlockResult == null ?
|
|
4892
|
+
head = headBlockResult == null ? assertEx36(
|
|
4936
4893
|
void 0,
|
|
4937
4894
|
() => `Specified a head that is not in the chain [${config.head}]`
|
|
4938
4895
|
) : headBlockResult[0];
|
|
@@ -5020,7 +4977,7 @@ SimpleBlockValidationViewer = __decorateClass([
|
|
|
5020
4977
|
], SimpleBlockValidationViewer);
|
|
5021
4978
|
|
|
5022
4979
|
// src/simple/chainContractViewer/SimpleChainContractViewer.ts
|
|
5023
|
-
import { assertEx as
|
|
4980
|
+
import { assertEx as assertEx37 } from "@xylabs/sdk-js";
|
|
5024
4981
|
import { ChainContractViewerMoniker as ChainContractViewerMoniker2, FinalizationViewerMoniker as FinalizationViewerMoniker2 } from "@xyo-network/xl1-protocol-lib";
|
|
5025
4982
|
var SimpleChainContractViewer = class extends AbstractCreatableProvider {
|
|
5026
4983
|
moniker = SimpleChainContractViewer.defaultMoniker;
|
|
@@ -5037,7 +4994,7 @@ var SimpleChainContractViewer = class extends AbstractCreatableProvider {
|
|
|
5037
4994
|
let contractViewer = this;
|
|
5038
4995
|
let forkedAtBlockNumber = await contractViewer.forkedAtBlockNumber();
|
|
5039
4996
|
while (forkedAtBlockNumber !== null && blockNumber <= forkedAtBlockNumber) {
|
|
5040
|
-
contractViewer =
|
|
4997
|
+
contractViewer = assertEx37(await contractViewer.forkedChainContractViewer());
|
|
5041
4998
|
forkedAtBlockNumber = await contractViewer.forkedAtBlockNumber();
|
|
5042
4999
|
chainId = await contractViewer.chainId();
|
|
5043
5000
|
}
|
|
@@ -5092,15 +5049,17 @@ var SimpleXyoClient = class {
|
|
|
5092
5049
|
};
|
|
5093
5050
|
|
|
5094
5051
|
// src/simple/datalake/RestDataLakeRunner.ts
|
|
5095
|
-
import { assertEx as
|
|
5052
|
+
import { assertEx as assertEx39, exists as exists6 } from "@xylabs/sdk-js";
|
|
5096
5053
|
import { isAnyPayload as isAnyPayload8, PayloadZodLoose } from "@xyo-network/sdk-js";
|
|
5097
5054
|
import { DataLakeRunnerMoniker } from "@xyo-network/xl1-protocol-lib";
|
|
5098
|
-
import { z as
|
|
5055
|
+
import { z as z26 } from "zod/mini";
|
|
5099
5056
|
|
|
5100
5057
|
// src/simple/datalake/AbstractRestDataLake.ts
|
|
5101
5058
|
import { FetchClientError, FetchJsonClient } from "@xylabs/sdk-js";
|
|
5102
5059
|
import {
|
|
5103
|
-
|
|
5060
|
+
assertEx as assertEx38,
|
|
5061
|
+
exists as exists5,
|
|
5062
|
+
isDefined as isDefined18
|
|
5104
5063
|
} from "@xylabs/sdk-js";
|
|
5105
5064
|
import { asAnyPayload as asAnyPayload4, isAnyPayload as isAnyPayload7 } from "@xyo-network/sdk-js";
|
|
5106
5065
|
var AbstractRestDataLake = class extends AbstractCreatableProvider {
|
|
@@ -5114,7 +5073,18 @@ var AbstractRestDataLake = class extends AbstractCreatableProvider {
|
|
|
5114
5073
|
return this.params.disallowedSchemas;
|
|
5115
5074
|
}
|
|
5116
5075
|
get endpoint() {
|
|
5117
|
-
return this.params.endpoint;
|
|
5076
|
+
return this.params.endpoint ?? "";
|
|
5077
|
+
}
|
|
5078
|
+
static async paramsHandler(params = {}) {
|
|
5079
|
+
const moniker = this.defaultMoniker;
|
|
5080
|
+
const endpoint = isDefined18(params.endpoint) && params.endpoint !== "" ? params.endpoint : resolveRestConnectionEndpoint(
|
|
5081
|
+
assertEx38(params.context?.config, () => "Context config is required to resolve REST data lake endpoint"),
|
|
5082
|
+
moniker
|
|
5083
|
+
);
|
|
5084
|
+
return {
|
|
5085
|
+
...await super.paramsHandler(params),
|
|
5086
|
+
endpoint
|
|
5087
|
+
};
|
|
5118
5088
|
}
|
|
5119
5089
|
async get(hashes) {
|
|
5120
5090
|
const results = await Promise.all(hashes.map((hash) => this.getOne(hash)));
|
|
@@ -5163,14 +5133,14 @@ var RestDataLakeRunner = class extends AbstractRestDataLake {
|
|
|
5163
5133
|
async insert(items) {
|
|
5164
5134
|
const allowedItems = items.map((item) => {
|
|
5165
5135
|
if (isAnyPayload8(item) && this.isAllowed(item)) {
|
|
5166
|
-
|
|
5136
|
+
assertEx39(typeof item === "object" && item !== null, () => "Data must be an object");
|
|
5167
5137
|
return item;
|
|
5168
5138
|
}
|
|
5169
5139
|
return null;
|
|
5170
5140
|
}).filter(exists6);
|
|
5171
5141
|
if (allowedItems.length > 0) {
|
|
5172
5142
|
const result = await this.client.post(`${this.params.endpoint}/insert`, allowedItems);
|
|
5173
|
-
return
|
|
5143
|
+
return z26.array(PayloadZodLoose).parse(result.data);
|
|
5174
5144
|
}
|
|
5175
5145
|
return [];
|
|
5176
5146
|
}
|
|
@@ -5286,13 +5256,13 @@ SimpleDataLakeViewer = __decorateClass([
|
|
|
5286
5256
|
], SimpleDataLakeViewer);
|
|
5287
5257
|
|
|
5288
5258
|
// src/simple/finalization/SimpleFinalizationRunner.ts
|
|
5289
|
-
import { assertEx as
|
|
5259
|
+
import { assertEx as assertEx40 } from "@xylabs/sdk-js";
|
|
5290
5260
|
import { FinalizationRunnerMoniker } from "@xyo-network/xl1-protocol-lib";
|
|
5291
5261
|
var SimpleFinalizationRunner = class extends AbstractCreatableProvider {
|
|
5292
5262
|
moniker = SimpleFinalizationRunner.defaultMoniker;
|
|
5293
5263
|
_store;
|
|
5294
5264
|
get finalizedArchivist() {
|
|
5295
|
-
return
|
|
5265
|
+
return assertEx40(this.params.finalizedArchivist, () => "finalizedArchivist is required \u2014 inject it or bind a connection");
|
|
5296
5266
|
}
|
|
5297
5267
|
get store() {
|
|
5298
5268
|
return this._store;
|
|
@@ -5302,7 +5272,7 @@ var SimpleFinalizationRunner = class extends AbstractCreatableProvider {
|
|
|
5302
5272
|
const finalizedArchivist = params?.finalizedArchivist ?? (connection ? await connectArchivist(connection, { name: CHAIN_ARCHIVIST_ROLE }) : void 0);
|
|
5303
5273
|
return {
|
|
5304
5274
|
...await super.paramsHandler(params),
|
|
5305
|
-
finalizedArchivist:
|
|
5275
|
+
finalizedArchivist: assertEx40(finalizedArchivist, () => "finalizedArchivist is required \u2014 inject it or bind a connection")
|
|
5306
5276
|
};
|
|
5307
5277
|
}
|
|
5308
5278
|
async createHandler() {
|
|
@@ -5330,7 +5300,7 @@ SimpleFinalizationRunner = __decorateClass([
|
|
|
5330
5300
|
], SimpleFinalizationRunner);
|
|
5331
5301
|
|
|
5332
5302
|
// src/simple/finalization/SimpleFinalizationViewer.ts
|
|
5333
|
-
import { assertEx as
|
|
5303
|
+
import { assertEx as assertEx41 } from "@xylabs/sdk-js";
|
|
5334
5304
|
import {
|
|
5335
5305
|
asSignedHydratedBlockWithStorageMeta as asSignedHydratedBlockWithStorageMeta2,
|
|
5336
5306
|
ChainContractViewerMoniker as ChainContractViewerMoniker3,
|
|
@@ -5342,7 +5312,7 @@ var SimpleFinalizationViewer = class extends AbstractCreatableProvider {
|
|
|
5342
5312
|
_store;
|
|
5343
5313
|
_signedHydratedBlockCache;
|
|
5344
5314
|
get finalizedArchivist() {
|
|
5345
|
-
return
|
|
5315
|
+
return assertEx41(this.params.finalizedArchivist, () => "finalizedArchivist is required \u2014 inject it or bind a connection");
|
|
5346
5316
|
}
|
|
5347
5317
|
get hydratedBlockCache() {
|
|
5348
5318
|
if (this._signedHydratedBlockCache) return this._signedHydratedBlockCache;
|
|
@@ -5361,7 +5331,7 @@ var SimpleFinalizationViewer = class extends AbstractCreatableProvider {
|
|
|
5361
5331
|
const finalizedArchivist = params.finalizedArchivist ?? (connection ? await connectArchivist(connection, { name: CHAIN_ARCHIVIST_ROLE }) : void 0);
|
|
5362
5332
|
return {
|
|
5363
5333
|
...await super.paramsHandler(params),
|
|
5364
|
-
finalizedArchivist:
|
|
5334
|
+
finalizedArchivist: assertEx41(finalizedArchivist, () => "finalizedArchivist is required \u2014 inject it or bind a connection")
|
|
5365
5335
|
};
|
|
5366
5336
|
}
|
|
5367
5337
|
chainId() {
|
|
@@ -5371,18 +5341,18 @@ var SimpleFinalizationViewer = class extends AbstractCreatableProvider {
|
|
|
5371
5341
|
await super.createHandler();
|
|
5372
5342
|
const finalizedArchivist = this.finalizedArchivist;
|
|
5373
5343
|
const mostRecentBlock = await findMostRecentBlock(finalizedArchivist);
|
|
5374
|
-
this._chainId =
|
|
5344
|
+
this._chainId = assertEx41(this.config.chain.id ?? mostRecentBlock?.chain, () => "chain.id is required if empty archivist");
|
|
5375
5345
|
this._store = { chainMap: finalizedArchivist };
|
|
5376
5346
|
}
|
|
5377
5347
|
async head() {
|
|
5378
5348
|
return await this.spanAsync("head", async () => {
|
|
5379
|
-
const currentHead =
|
|
5349
|
+
const currentHead = assertEx41(await this.getCurrentHead(), () => "Could not find most recent block [currentBlock]");
|
|
5380
5350
|
const cache = this.hydratedBlockCache;
|
|
5381
5351
|
const block = await cache.get(currentHead._hash);
|
|
5382
5352
|
if (!block) {
|
|
5383
5353
|
this.logger?.error(`Could not find current block with hash ${currentHead._hash}`);
|
|
5384
5354
|
}
|
|
5385
|
-
return
|
|
5355
|
+
return assertEx41(block, () => "Could not find current block");
|
|
5386
5356
|
}, this.context);
|
|
5387
5357
|
}
|
|
5388
5358
|
async headBlock() {
|
|
@@ -5412,8 +5382,8 @@ var SimpleFinalizationViewer = class extends AbstractCreatableProvider {
|
|
|
5412
5382
|
}
|
|
5413
5383
|
async getCurrentHead() {
|
|
5414
5384
|
const chainArchivist = this.finalizedArchivist;
|
|
5415
|
-
const result =
|
|
5416
|
-
|
|
5385
|
+
const result = assertEx41(await findMostRecentBlock(chainArchivist), () => "Could not find most recent block [getCurrentHead]");
|
|
5386
|
+
assertEx41(result?.chain === this._chainId, () => "Chain ID does not match head block chain ID");
|
|
5417
5387
|
return result;
|
|
5418
5388
|
}
|
|
5419
5389
|
};
|
|
@@ -5445,9 +5415,9 @@ var SimpleXyoGateway = class _SimpleXyoGateway extends AbstractCreatableProvider
|
|
|
5445
5415
|
|
|
5446
5416
|
// src/simple/gateway/SimpleXyoGatewayRunner.ts
|
|
5447
5417
|
import {
|
|
5448
|
-
assertEx as
|
|
5418
|
+
assertEx as assertEx42,
|
|
5449
5419
|
BigIntToJsonZod,
|
|
5450
|
-
isDefined as
|
|
5420
|
+
isDefined as isDefined19
|
|
5451
5421
|
} from "@xylabs/sdk-js";
|
|
5452
5422
|
import { PayloadBuilder as PayloadBuilder20 } from "@xyo-network/sdk-js";
|
|
5453
5423
|
import {
|
|
@@ -5478,23 +5448,23 @@ var SimpleXyoGatewayRunner = class _SimpleXyoGatewayRunner extends AbstractCreat
|
|
|
5478
5448
|
return this._signer;
|
|
5479
5449
|
}
|
|
5480
5450
|
async addPayloadsToChain(onChain, offChain, options) {
|
|
5481
|
-
const viewer =
|
|
5451
|
+
const viewer = assertEx42(this.connection.viewer, () => "No viewer available on connection");
|
|
5482
5452
|
const {
|
|
5483
5453
|
nbf,
|
|
5484
5454
|
exp,
|
|
5485
5455
|
chain,
|
|
5486
5456
|
fees
|
|
5487
5457
|
} = options ?? {};
|
|
5488
|
-
const resolvedChainId =
|
|
5489
|
-
const resolvedNbf = asXL1BlockNumber10(
|
|
5490
|
-
const resolvedExp = asXL1BlockNumber10(
|
|
5458
|
+
const resolvedChainId = isDefined19(chain) ? chain : await viewer.chainId();
|
|
5459
|
+
const resolvedNbf = asXL1BlockNumber10(isDefined19(nbf) ? nbf : await viewer.currentBlockNumber(), true);
|
|
5460
|
+
const resolvedExp = asXL1BlockNumber10(isDefined19(exp) ? exp : resolvedNbf + 10, true);
|
|
5491
5461
|
const tx = await buildUnsignedTransaction(resolvedChainId, onChain, offChain, resolvedNbf, resolvedExp, await this.signer.address(), fees);
|
|
5492
5462
|
return await this.addTransactionToChain(tx, await PayloadBuilder20.addHashMeta(offChain));
|
|
5493
5463
|
}
|
|
5494
5464
|
async addTransactionToChain(tx, offChain = []) {
|
|
5495
5465
|
const connection = this.connection;
|
|
5496
5466
|
const signer = this.signer;
|
|
5497
|
-
const runner =
|
|
5467
|
+
const runner = assertEx42(connection.runner, () => "No runner available on connection");
|
|
5498
5468
|
let signedTx;
|
|
5499
5469
|
if (isSignedHydratedTransaction(tx)) {
|
|
5500
5470
|
const [bw, payloads] = tx;
|
|
@@ -5509,7 +5479,7 @@ var SimpleXyoGatewayRunner = class _SimpleXyoGatewayRunner extends AbstractCreat
|
|
|
5509
5479
|
}
|
|
5510
5480
|
async confirmSubmittedTransaction(txHash, options) {
|
|
5511
5481
|
return await confirmSubmittedTransaction(
|
|
5512
|
-
|
|
5482
|
+
assertEx42(this.connection.viewer, () => "Connection viewer is undefined"),
|
|
5513
5483
|
txHash,
|
|
5514
5484
|
options
|
|
5515
5485
|
);
|
|
@@ -5548,7 +5518,7 @@ var SimpleXyoGatewayRunner = class _SimpleXyoGatewayRunner extends AbstractCreat
|
|
|
5548
5518
|
|
|
5549
5519
|
// src/simple/mempool/SimpleMempoolRunner.ts
|
|
5550
5520
|
import {
|
|
5551
|
-
assertEx as
|
|
5521
|
+
assertEx as assertEx43,
|
|
5552
5522
|
exists as exists8
|
|
5553
5523
|
} from "@xylabs/sdk-js";
|
|
5554
5524
|
import { isPayloadBundle, PayloadBuilder as PayloadBuilder21 } from "@xyo-network/sdk-js";
|
|
@@ -5604,10 +5574,10 @@ var SimpleMempoolRunner = class extends AbstractCreatableProvider {
|
|
|
5604
5574
|
return this.params.maxPendingTransactions ?? 0;
|
|
5605
5575
|
}
|
|
5606
5576
|
get pendingBlocksArchivist() {
|
|
5607
|
-
return
|
|
5577
|
+
return assertEx43(this.params.pendingBlocksArchivist, () => "pendingBlocksArchivist is required \u2014 inject it or bind a connection");
|
|
5608
5578
|
}
|
|
5609
5579
|
get pendingTransactionsArchivist() {
|
|
5610
|
-
return
|
|
5580
|
+
return assertEx43(this.params.pendingTransactionsArchivist, () => "pendingTransactionsArchivist is required \u2014 inject it or bind a connection");
|
|
5611
5581
|
}
|
|
5612
5582
|
get syncInterval() {
|
|
5613
5583
|
return this.params.syncInterval ?? DEFAULT_SYNC_INTERVAL;
|
|
@@ -5627,8 +5597,8 @@ var SimpleMempoolRunner = class extends AbstractCreatableProvider {
|
|
|
5627
5597
|
const pendingTransactionsArchivist = params?.pendingTransactionsArchivist ?? (connection ? await connectArchivist(connection, { name: PENDING_TRANSACTIONS_ARCHIVIST_ROLE }) : void 0);
|
|
5628
5598
|
return {
|
|
5629
5599
|
...await super.paramsHandler(params),
|
|
5630
|
-
pendingBlocksArchivist:
|
|
5631
|
-
pendingTransactionsArchivist:
|
|
5600
|
+
pendingBlocksArchivist: assertEx43(pendingBlocksArchivist, () => "pendingBlocksArchivist is required \u2014 inject it or bind a connection"),
|
|
5601
|
+
pendingTransactionsArchivist: assertEx43(pendingTransactionsArchivist, () => "pendingTransactionsArchivist is required \u2014 inject it or bind a connection")
|
|
5632
5602
|
};
|
|
5633
5603
|
}
|
|
5634
5604
|
async createHandler() {
|
|
@@ -5667,7 +5637,7 @@ var SimpleMempoolRunner = class extends AbstractCreatableProvider {
|
|
|
5667
5637
|
remainingBlockMap.push(i);
|
|
5668
5638
|
return b;
|
|
5669
5639
|
}).filter(exists8);
|
|
5670
|
-
|
|
5640
|
+
assertEx43(
|
|
5671
5641
|
remainingBlockMap.length === remainingBlocks.length,
|
|
5672
5642
|
() => `remainingBlockMap length should match remainingBlocks length [${remainingBlockMap.length}/${remainingBlocks.length}]`
|
|
5673
5643
|
);
|
|
@@ -5730,7 +5700,7 @@ var SimpleMempoolRunner = class extends AbstractCreatableProvider {
|
|
|
5730
5700
|
remainingTransactionMap.push(i);
|
|
5731
5701
|
return t;
|
|
5732
5702
|
}).filter(exists8);
|
|
5733
|
-
|
|
5703
|
+
assertEx43(
|
|
5734
5704
|
remainingTransactionMap.length === remainingTransactions.length,
|
|
5735
5705
|
() => `remainingTransactionMap length should match remainingTransactions length [${remainingTransactionMap.length}/${remainingTransactions.length}]`
|
|
5736
5706
|
);
|
|
@@ -5983,9 +5953,9 @@ SimpleMempoolRunner = __decorateClass([
|
|
|
5983
5953
|
|
|
5984
5954
|
// src/simple/mempool/SimpleMempoolViewer.ts
|
|
5985
5955
|
import {
|
|
5986
|
-
assertEx as
|
|
5956
|
+
assertEx as assertEx44,
|
|
5987
5957
|
exists as exists9,
|
|
5988
|
-
isDefined as
|
|
5958
|
+
isDefined as isDefined20,
|
|
5989
5959
|
isHash as isHash2
|
|
5990
5960
|
} from "@xylabs/sdk-js";
|
|
5991
5961
|
import { isHashMeta as isHashMeta2, isPayloadBundle as isPayloadBundle2 } from "@xyo-network/sdk-js";
|
|
@@ -6004,10 +5974,10 @@ var SimpleMempoolViewer = class extends AbstractCreatableProvider {
|
|
|
6004
5974
|
return this.params.handoutStatsTtlBlocks ?? DEFAULT_HANDOUT_STATS_TTL_BLOCKS;
|
|
6005
5975
|
}
|
|
6006
5976
|
get pendingBlocksArchivist() {
|
|
6007
|
-
return
|
|
5977
|
+
return assertEx44(this.params.pendingBlocksArchivist, () => "pendingBlocksArchivist is required \u2014 inject it or bind a connection");
|
|
6008
5978
|
}
|
|
6009
5979
|
get pendingTransactionsArchivist() {
|
|
6010
|
-
return
|
|
5980
|
+
return assertEx44(this.params.pendingTransactionsArchivist, () => "pendingTransactionsArchivist is required \u2014 inject it or bind a connection");
|
|
6011
5981
|
}
|
|
6012
5982
|
get windowedBlockViewer() {
|
|
6013
5983
|
return this._windowedBlockViewer;
|
|
@@ -6056,7 +6026,7 @@ var SimpleMempoolViewer = class extends AbstractCreatableProvider {
|
|
|
6056
6026
|
let cursor = void 0;
|
|
6057
6027
|
if (isHash2(providedCursor)) {
|
|
6058
6028
|
const [p] = await this.pendingBlocksArchivist.get([providedCursor]);
|
|
6059
|
-
if (
|
|
6029
|
+
if (isDefined20(p)) {
|
|
6060
6030
|
cursor = p._sequence;
|
|
6061
6031
|
}
|
|
6062
6032
|
}
|
|
@@ -6076,7 +6046,7 @@ var SimpleMempoolViewer = class extends AbstractCreatableProvider {
|
|
|
6076
6046
|
let cursor = void 0;
|
|
6077
6047
|
if (isHash2(providedCursor)) {
|
|
6078
6048
|
const [p] = await this.pendingTransactionsArchivist.get([providedCursor]);
|
|
6079
|
-
if (
|
|
6049
|
+
if (isDefined20(p)) {
|
|
6080
6050
|
cursor = p._sequence;
|
|
6081
6051
|
}
|
|
6082
6052
|
}
|
|
@@ -6149,7 +6119,7 @@ var SimpleMempoolViewer = class extends AbstractCreatableProvider {
|
|
|
6149
6119
|
const hydratedResults = await Promise.all(
|
|
6150
6120
|
filteredBundles.map(async (bundle3) => {
|
|
6151
6121
|
const tx = await bundledPayloadToHydratedTransaction(bundle3);
|
|
6152
|
-
return
|
|
6122
|
+
return isDefined20(tx) ? { bundle: bundle3, tx } : void 0;
|
|
6153
6123
|
})
|
|
6154
6124
|
);
|
|
6155
6125
|
return hydratedResults.filter(exists9);
|
|
@@ -6293,7 +6263,7 @@ var SimpleXyoNetwork = class {
|
|
|
6293
6263
|
};
|
|
6294
6264
|
|
|
6295
6265
|
// src/simple/permissions/SimpleXyoPermissions.ts
|
|
6296
|
-
import { assertEx as
|
|
6266
|
+
import { assertEx as assertEx45 } from "@xylabs/sdk-js";
|
|
6297
6267
|
var SimpleXyoPermissions = class {
|
|
6298
6268
|
invoker;
|
|
6299
6269
|
_store;
|
|
@@ -6302,7 +6272,7 @@ var SimpleXyoPermissions = class {
|
|
|
6302
6272
|
this.invoker = store.invoker;
|
|
6303
6273
|
}
|
|
6304
6274
|
get store() {
|
|
6305
|
-
return
|
|
6275
|
+
return assertEx45(this._store, () => "Store must be defined to get permissions");
|
|
6306
6276
|
}
|
|
6307
6277
|
async getPermissions() {
|
|
6308
6278
|
return await this.store.getPermissions();
|
|
@@ -6355,7 +6325,7 @@ var SimpleXyoPermissions = class {
|
|
|
6355
6325
|
};
|
|
6356
6326
|
|
|
6357
6327
|
// src/simple/permissions/store/MemoryPermissions.ts
|
|
6358
|
-
import { assertEx as
|
|
6328
|
+
import { assertEx as assertEx46 } from "@xylabs/sdk-js";
|
|
6359
6329
|
var MemoryPermissionsStore = class {
|
|
6360
6330
|
_invoker;
|
|
6361
6331
|
permissions = [];
|
|
@@ -6363,7 +6333,7 @@ var MemoryPermissionsStore = class {
|
|
|
6363
6333
|
this._invoker = invoker;
|
|
6364
6334
|
}
|
|
6365
6335
|
get invoker() {
|
|
6366
|
-
return
|
|
6336
|
+
return assertEx46(this._invoker, () => "Invoker must be defined to get permissions");
|
|
6367
6337
|
}
|
|
6368
6338
|
async getPermissions() {
|
|
6369
6339
|
await Promise.resolve();
|
|
@@ -6455,7 +6425,7 @@ var SimpleXyoSigner = class _SimpleXyoSigner extends AbstractCreatableProvider {
|
|
|
6455
6425
|
};
|
|
6456
6426
|
|
|
6457
6427
|
// src/simple/StakeEventsViewer/SimpleStakeEventsViewer.ts
|
|
6458
|
-
import { isDefined as
|
|
6428
|
+
import { isDefined as isDefined21 } from "@xylabs/sdk-js";
|
|
6459
6429
|
import { StakeEventsViewerMoniker } from "@xyo-network/xl1-protocol-lib";
|
|
6460
6430
|
var SimpleStakeEventsViewer = class extends AbstractCreatableProvider {
|
|
6461
6431
|
moniker = SimpleStakeEventsViewer.defaultMoniker;
|
|
@@ -6468,7 +6438,7 @@ var SimpleStakeEventsViewer = class extends AbstractCreatableProvider {
|
|
|
6468
6438
|
stakeEvents(range, { name } = {}) {
|
|
6469
6439
|
const positions = this.positionsFromRange(range);
|
|
6470
6440
|
const events = this.eventsFromPositions(positions);
|
|
6471
|
-
if (
|
|
6441
|
+
if (isDefined21(name)) {
|
|
6472
6442
|
return events.filter((event) => event.name === name);
|
|
6473
6443
|
}
|
|
6474
6444
|
return events;
|
|
@@ -6535,7 +6505,7 @@ SimpleStakeEventsViewer = __decorateClass([
|
|
|
6535
6505
|
], SimpleStakeEventsViewer);
|
|
6536
6506
|
|
|
6537
6507
|
// src/simple/StakeTotalsViewer/SimpleStakeTotalsViewer.ts
|
|
6538
|
-
import { assertEx as
|
|
6508
|
+
import { assertEx as assertEx47 } from "@xylabs/sdk-js";
|
|
6539
6509
|
import { asXyoAddress as asXyoAddress3 } from "@xyo-network/sdk-js";
|
|
6540
6510
|
import {
|
|
6541
6511
|
StakeTotalsViewerMoniker,
|
|
@@ -6579,7 +6549,7 @@ var SimpleStakeTotalsViewer = class extends AbstractCreatableProvider {
|
|
|
6579
6549
|
}
|
|
6580
6550
|
async createHandler() {
|
|
6581
6551
|
await super.createHandler();
|
|
6582
|
-
this._stakeViewer =
|
|
6552
|
+
this._stakeViewer = assertEx47(
|
|
6583
6553
|
await this.locateAndCreate(StakeViewerMoniker),
|
|
6584
6554
|
() => "Failed to create StakeViewer"
|
|
6585
6555
|
);
|
|
@@ -6635,14 +6605,14 @@ SimpleStakeTotalsViewer = __decorateClass([
|
|
|
6635
6605
|
], SimpleStakeTotalsViewer);
|
|
6636
6606
|
|
|
6637
6607
|
// src/simple/StakeViewer/SimpleStakeViewer.ts
|
|
6638
|
-
import { assertEx as
|
|
6608
|
+
import { assertEx as assertEx48, toAddress } from "@xylabs/sdk-js";
|
|
6639
6609
|
import { asXyoAddress as asXyoAddress4 } from "@xyo-network/sdk-js";
|
|
6640
6610
|
import { StakeEventsViewerMoniker as StakeEventsViewerMoniker2, StakeViewerMoniker as StakeViewerMoniker2 } from "@xyo-network/xl1-protocol-lib";
|
|
6641
6611
|
var SimpleStakeViewer = class extends AbstractCreatableProvider {
|
|
6642
6612
|
moniker = SimpleStakeViewer.defaultMoniker;
|
|
6643
6613
|
_chainStakeEventsViewer;
|
|
6644
6614
|
get stakeEvents() {
|
|
6645
|
-
return
|
|
6615
|
+
return assertEx48(this._chainStakeEventsViewer, () => "Stake events viewer not set");
|
|
6646
6616
|
}
|
|
6647
6617
|
get positions() {
|
|
6648
6618
|
return this.params.positions;
|
|
@@ -6682,7 +6652,7 @@ var SimpleStakeViewer = class extends AbstractCreatableProvider {
|
|
|
6682
6652
|
}
|
|
6683
6653
|
async createHandler() {
|
|
6684
6654
|
await super.createHandler();
|
|
6685
|
-
this._chainStakeEventsViewer =
|
|
6655
|
+
this._chainStakeEventsViewer = assertEx48(
|
|
6686
6656
|
await this.locateAndCreate(StakeEventsViewerMoniker2),
|
|
6687
6657
|
() => "Failed to create StakeEventsViewer"
|
|
6688
6658
|
);
|
|
@@ -6717,7 +6687,7 @@ var SimpleStakeViewer = class extends AbstractCreatableProvider {
|
|
|
6717
6687
|
return toAddress(toAddress(1n));
|
|
6718
6688
|
}
|
|
6719
6689
|
stakeById(id) {
|
|
6720
|
-
return
|
|
6690
|
+
return assertEx48(this.positions[id], () => new Error(`Stake with id ${id} not found`));
|
|
6721
6691
|
}
|
|
6722
6692
|
stakeByStaker(staker, slot) {
|
|
6723
6693
|
return this.positions.filter((s) => asXyoAddress4(s.staker) === asXyoAddress4(staker))[slot];
|
|
@@ -6821,8 +6791,8 @@ RestSyncViewer = __decorateClass([
|
|
|
6821
6791
|
// src/simple/timeSync2/SimpleTimeSyncViewer.ts
|
|
6822
6792
|
import {
|
|
6823
6793
|
asHash as asHash5,
|
|
6824
|
-
assertEx as
|
|
6825
|
-
isDefined as
|
|
6794
|
+
assertEx as assertEx49,
|
|
6795
|
+
isDefined as isDefined22
|
|
6826
6796
|
} from "@xylabs/sdk-js";
|
|
6827
6797
|
import {
|
|
6828
6798
|
asTimePayload as asTimePayload2,
|
|
@@ -6843,10 +6813,10 @@ var SimpleTimeSyncViewer = class extends AbstractCreatableProvider {
|
|
|
6843
6813
|
async convertTime(fromDomain, toDomain, from) {
|
|
6844
6814
|
switch (fromDomain) {
|
|
6845
6815
|
case "xl1": {
|
|
6846
|
-
const [block, payloads] =
|
|
6816
|
+
const [block, payloads] = assertEx49(await this.blockViewer.blockByNumber(asXL1BlockNumber11(from, true)), () => "Block not found");
|
|
6847
6817
|
const timeSchemaIndex = block.payload_schemas.indexOf(TimeSchema);
|
|
6848
6818
|
const hash = timeSchemaIndex === -1 ? void 0 : block.payload_hashes[timeSchemaIndex];
|
|
6849
|
-
const timePayload = asTimePayload2(
|
|
6819
|
+
const timePayload = asTimePayload2(isDefined22(hash) ? payloads.find((p) => p._hash === hash) : void 0);
|
|
6850
6820
|
if (timePayload === void 0) return 0;
|
|
6851
6821
|
switch (toDomain) {
|
|
6852
6822
|
case "xl1": {
|
|
@@ -6899,10 +6869,10 @@ var SimpleTimeSyncViewer = class extends AbstractCreatableProvider {
|
|
|
6899
6869
|
return [Date.now(), null];
|
|
6900
6870
|
}
|
|
6901
6871
|
case "ethereum": {
|
|
6902
|
-
const provider =
|
|
6872
|
+
const provider = assertEx49(this.ethProvider, () => "Ethereum provider not configured");
|
|
6903
6873
|
const blockNumber = await provider.getBlockNumber() ?? 0;
|
|
6904
6874
|
const block = await provider.getBlock(blockNumber);
|
|
6905
|
-
const blockHash = asHash5(
|
|
6875
|
+
const blockHash = asHash5(assertEx49(block?.hash, () => "Block hash not found"), true);
|
|
6906
6876
|
return [blockNumber, blockHash];
|
|
6907
6877
|
}
|
|
6908
6878
|
default: {
|
|
@@ -6917,10 +6887,10 @@ var SimpleTimeSyncViewer = class extends AbstractCreatableProvider {
|
|
|
6917
6887
|
// this is for the previous block
|
|
6918
6888
|
xl1,
|
|
6919
6889
|
// this is for the previous block
|
|
6920
|
-
xl1Hash:
|
|
6890
|
+
xl1Hash: assertEx49(xl1Hash, () => "No xl1 hash available from time sync service"),
|
|
6921
6891
|
epoch: Date.now()
|
|
6922
6892
|
};
|
|
6923
|
-
if (
|
|
6893
|
+
if (isDefined22(this.ethProvider)) {
|
|
6924
6894
|
const [ethereum, ethHashOrNull] = await this.currentTimeAndHash("ethereum");
|
|
6925
6895
|
const ethereumHash = asHash5(ethHashOrNull, () => "No ethereum hash available from time sync service");
|
|
6926
6896
|
timePayload.ethereum = ethereum;
|
|
@@ -6939,7 +6909,7 @@ SimpleTimeSyncViewer = __decorateClass([
|
|
|
6939
6909
|
], SimpleTimeSyncViewer);
|
|
6940
6910
|
|
|
6941
6911
|
// src/simple/transactionValidation/SimpleTransactionValidationViewer.ts
|
|
6942
|
-
import { assertEx as
|
|
6912
|
+
import { assertEx as assertEx50 } from "@xylabs/sdk-js";
|
|
6943
6913
|
import { PayloadBuilder as PayloadBuilder24 } from "@xyo-network/sdk-js";
|
|
6944
6914
|
import {
|
|
6945
6915
|
AccountBalanceViewerMoniker as AccountBalanceViewerMoniker3,
|
|
@@ -6993,7 +6963,7 @@ var SimpleTransactionValidationViewer = class extends AbstractCreatableProvider
|
|
|
6993
6963
|
let head;
|
|
6994
6964
|
if (isChainQualifiedHeadConfig6(config)) {
|
|
6995
6965
|
const headBlockResult = await this.blockViewer.blockByHash(config.head);
|
|
6996
|
-
head = headBlockResult == null ?
|
|
6966
|
+
head = headBlockResult == null ? assertEx50(
|
|
6997
6967
|
void 0,
|
|
6998
6968
|
() => `Specified a head that is not in the chain [${config.head}]`
|
|
6999
6969
|
) : headBlockResult[0];
|
|
@@ -7065,7 +7035,7 @@ SimpleTransactionValidationViewer = __decorateClass([
|
|
|
7065
7035
|
], SimpleTransactionValidationViewer);
|
|
7066
7036
|
|
|
7067
7037
|
// src/simple/TransactionViewer/SimpleTransactionViewer.ts
|
|
7068
|
-
import { assertEx as
|
|
7038
|
+
import { assertEx as assertEx51, exists as exists10 } from "@xylabs/sdk-js";
|
|
7069
7039
|
import { BoundWitnessSchema } from "@xyo-network/sdk-js";
|
|
7070
7040
|
import {
|
|
7071
7041
|
asSignedHydratedTransactionWithHashMeta,
|
|
@@ -7082,7 +7052,7 @@ var SimpleTransactionViewer = class extends AbstractCreatableProvider {
|
|
|
7082
7052
|
}
|
|
7083
7053
|
async byBlockHashAndIndex(blockHash, transactionIndex) {
|
|
7084
7054
|
return await this.spanAsync("byBlockHashAndIndex", async () => {
|
|
7085
|
-
|
|
7055
|
+
assertEx51(transactionIndex >= 0, () => "transactionIndex must be greater than or equal to 0");
|
|
7086
7056
|
try {
|
|
7087
7057
|
const block = await this.blockViewer.blockByHash(blockHash);
|
|
7088
7058
|
if (!block) return null;
|
|
@@ -7147,7 +7117,7 @@ SimpleTransactionViewer = __decorateClass([
|
|
|
7147
7117
|
|
|
7148
7118
|
// src/simple/windowedBlock/SimpleWindowedBlockViewer.ts
|
|
7149
7119
|
import {
|
|
7150
|
-
assertEx as
|
|
7120
|
+
assertEx as assertEx52,
|
|
7151
7121
|
exists as exists11,
|
|
7152
7122
|
isNull as isNull2
|
|
7153
7123
|
} from "@xylabs/sdk-js";
|
|
@@ -7229,7 +7199,7 @@ var SimpleWindowedBlockViewer = class extends AbstractCreatableProvider {
|
|
|
7229
7199
|
}
|
|
7230
7200
|
async createHandler() {
|
|
7231
7201
|
await super.createHandler();
|
|
7232
|
-
this._blockViewer =
|
|
7202
|
+
this._blockViewer = assertEx52(
|
|
7233
7203
|
this.params.blockViewer ?? await this.locator.getInstance(BlockViewerMoniker7),
|
|
7234
7204
|
() => "BlockViewer instance is required"
|
|
7235
7205
|
);
|
|
@@ -7238,13 +7208,13 @@ var SimpleWindowedBlockViewer = class extends AbstractCreatableProvider {
|
|
|
7238
7208
|
this._transactionHashMap = new MemoryMap2();
|
|
7239
7209
|
}
|
|
7240
7210
|
currentBlock() {
|
|
7241
|
-
return
|
|
7211
|
+
return assertEx52(this._chain.at(-1));
|
|
7242
7212
|
}
|
|
7243
7213
|
currentBlockHash() {
|
|
7244
|
-
return
|
|
7214
|
+
return assertEx52(this._chain.at(-1)?.[0]._hash);
|
|
7245
7215
|
}
|
|
7246
7216
|
currentBlockNumber() {
|
|
7247
|
-
return
|
|
7217
|
+
return assertEx52(this._chain.at(-1)?.[0].block);
|
|
7248
7218
|
}
|
|
7249
7219
|
async payloadByHash(hash) {
|
|
7250
7220
|
const payloads = await this.payloadsByHash([hash]);
|
|
@@ -7405,7 +7375,7 @@ var RuntimeStatusMonitor = class extends LoggerStatusReporter {
|
|
|
7405
7375
|
};
|
|
7406
7376
|
|
|
7407
7377
|
// src/test/buildRandomChain.ts
|
|
7408
|
-
import { asAddress as asAddress2, assertEx as
|
|
7378
|
+
import { asAddress as asAddress2, assertEx as assertEx55 } from "@xylabs/sdk-js";
|
|
7409
7379
|
import {
|
|
7410
7380
|
Account as Account4,
|
|
7411
7381
|
asSchema as asSchema9,
|
|
@@ -7424,7 +7394,7 @@ import {
|
|
|
7424
7394
|
} from "@xyo-network/xl1-protocol-lib";
|
|
7425
7395
|
|
|
7426
7396
|
// src/test/buildBlock.ts
|
|
7427
|
-
import { assertEx as
|
|
7397
|
+
import { assertEx as assertEx53, isDefined as isDefined23 } from "@xylabs/sdk-js";
|
|
7428
7398
|
import {
|
|
7429
7399
|
asAnyPayload as asAnyPayload5,
|
|
7430
7400
|
BoundWitnessBuilder as BoundWitnessBuilder3,
|
|
@@ -7507,8 +7477,8 @@ function buildStepHashes(blockNumber, inStepHashes, previousBlockHash, chainStep
|
|
|
7507
7477
|
const completedStepReward = calculateCompletedStepReward(i, stepRewardPoolBalance);
|
|
7508
7478
|
completedStepRewardTransfers.push(createTransferPayload(chainStepRewardAddress2, { [completedStepRewardHolderAddress]: completedStepReward }));
|
|
7509
7479
|
}
|
|
7510
|
-
step_hashes.push(
|
|
7511
|
-
} else if (
|
|
7480
|
+
step_hashes.push(assertEx53(previousBlockHash, () => `Previous block hash is required for step ${step} at block ${blockNumber}`));
|
|
7481
|
+
} else if (isDefined23(inStepHashes.at(i))) {
|
|
7512
7482
|
step_hashes.push(inStepHashes[i]);
|
|
7513
7483
|
}
|
|
7514
7484
|
}
|
|
@@ -7561,7 +7531,7 @@ async function buildBlock(options) {
|
|
|
7561
7531
|
protocol
|
|
7562
7532
|
}).meta({ $epoch: Date.now(), $signatures: [] }).signers(signers).payloads(await PayloadBuilder25.addStorageMeta(payloads));
|
|
7563
7533
|
const [bw, txPayloads] = await builder.build();
|
|
7564
|
-
|
|
7534
|
+
assertEx53(isBlockBoundWitness(bw), () => "Build of BlockBoundWitness failed");
|
|
7565
7535
|
return [await PayloadBuilder25.addStorageMeta(bw), txPayloads.map((p) => asAnyPayload5(p, true))];
|
|
7566
7536
|
}
|
|
7567
7537
|
|
|
@@ -7582,7 +7552,7 @@ async function buildNextBlock(previousBlock, txs, blockPayloads, signers, chainS
|
|
|
7582
7552
|
}
|
|
7583
7553
|
|
|
7584
7554
|
// src/test/buildRandomGenesisBlock.ts
|
|
7585
|
-
import { asAddress, assertEx as
|
|
7555
|
+
import { asAddress, assertEx as assertEx54 } from "@xylabs/sdk-js";
|
|
7586
7556
|
import {
|
|
7587
7557
|
Account as Account3,
|
|
7588
7558
|
asAnyPayload as asAnyPayload6,
|
|
@@ -7626,7 +7596,7 @@ var buildRandomTransaction = async (chain, payloads, account, nbf = asXL1BlockNu
|
|
|
7626
7596
|
};
|
|
7627
7597
|
|
|
7628
7598
|
// src/test/buildRandomGenesisBlock.ts
|
|
7629
|
-
var TestChainId =
|
|
7599
|
+
var TestChainId = assertEx54(asAddress("c5fe2e6F6841Cbab12d8C0618Be2DF8C6156cC44"));
|
|
7630
7600
|
|
|
7631
7601
|
// src/test/createGenesisBlock.ts
|
|
7632
7602
|
import { PayloadBuilder as PayloadBuilder28 } from "@xyo-network/sdk-js";
|
|
@@ -7681,7 +7651,7 @@ var createGenesisBlock = async (initialBlockProducer, nextContractAddress, genes
|
|
|
7681
7651
|
};
|
|
7682
7652
|
|
|
7683
7653
|
// src/test/buildRandomChain.ts
|
|
7684
|
-
var TestGenesisBlockRewardAddress =
|
|
7654
|
+
var TestGenesisBlockRewardAddress = assertEx55(asAddress2("fa7f0bb865a4bfff3d5e2c726d3e063297014da9"));
|
|
7685
7655
|
var buildRandomChain = async (blockProducer, count = 10, previousBlock, chainId, transactionAccount, receiverAddresses) => {
|
|
7686
7656
|
const chainIdToUse = chainId ?? TestChainId;
|
|
7687
7657
|
const blocks = [];
|
|
@@ -7725,7 +7695,7 @@ var buildRandomChain = async (blockProducer, count = 10, previousBlock, chainId,
|
|
|
7725
7695
|
receiverAddress
|
|
7726
7696
|
));
|
|
7727
7697
|
}
|
|
7728
|
-
const previousBlock2 =
|
|
7698
|
+
const previousBlock2 = assertEx55(lastBlock?.[0], () => new Error("No last block"));
|
|
7729
7699
|
const block = await buildNextBlock(previousBlock2, txs, [], [blockProducer], transactionAccountToUse.address);
|
|
7730
7700
|
blocks.push(block);
|
|
7731
7701
|
remaining = remaining - 1;
|
|
@@ -7786,13 +7756,13 @@ function getTestProviderContext2(config) {
|
|
|
7786
7756
|
}
|
|
7787
7757
|
|
|
7788
7758
|
// src/time/primitives/xl1BlockNumberToEthBlockNumber.ts
|
|
7789
|
-
import { assertEx as
|
|
7759
|
+
import { assertEx as assertEx56 } from "@xylabs/sdk-js";
|
|
7790
7760
|
import { asTimePayload as asTimePayload3, TimeSchema as TimeSchema2 } from "@xyo-network/xl1-protocol-lib";
|
|
7791
7761
|
async function xl1BlockNumberToEthBlockNumber(context, xl1BlockNumber) {
|
|
7792
7762
|
const blockHash = await hashFromBlockNumber(context, xl1BlockNumber);
|
|
7793
7763
|
const hydratedBlock = await hydrateBlock(context, blockHash);
|
|
7794
7764
|
const timePayload = asTimePayload3(hydratedBlock[1].find((p) => p.schema === TimeSchema2), { required: true });
|
|
7795
|
-
return
|
|
7765
|
+
return assertEx56(timePayload.ethereum, () => "No ethereum timestamp found on block");
|
|
7796
7766
|
}
|
|
7797
7767
|
|
|
7798
7768
|
// src/validation/lib/isLocalhost.ts
|
|
@@ -7810,8 +7780,8 @@ var getUrl = (host, port) => {
|
|
|
7810
7780
|
var TODO = true;
|
|
7811
7781
|
|
|
7812
7782
|
// src/validation/schema/Mnemonic.ts
|
|
7813
|
-
import { z as
|
|
7814
|
-
var MnemonicStringZod =
|
|
7783
|
+
import { z as z27 } from "zod";
|
|
7784
|
+
var MnemonicStringZod = z27.string().transform((s) => s.trim().replaceAll(/\s+/g, " ")).refine(
|
|
7815
7785
|
(s) => [12, 15, 18, 21, 24].includes(s.split(" ").length),
|
|
7816
7786
|
{ message: "Mnemonic must contain 12, 15, 18, 21, or 24 words." }
|
|
7817
7787
|
).describe("BIP-39 mnemonic string");
|
|
@@ -7856,23 +7826,20 @@ export {
|
|
|
7856
7826
|
COIN_TYPES,
|
|
7857
7827
|
ChainIndexingServiceStateSchema,
|
|
7858
7828
|
ConfigZod,
|
|
7859
|
-
|
|
7860
|
-
|
|
7829
|
+
ConnectionConfigZod,
|
|
7830
|
+
ConnectionsConfigZod,
|
|
7861
7831
|
CreatableProviderContextZod,
|
|
7862
7832
|
DEFAULT_BACKOFF_MS,
|
|
7863
7833
|
DEFAULT_MAX_ATTEMPTS,
|
|
7864
7834
|
DEFAULT_MIN_CANDIDATES,
|
|
7865
7835
|
DEFAULT_TOLERANCE_MS,
|
|
7866
7836
|
DEFAULT_WALLET_PATH,
|
|
7867
|
-
DataLakeConfigZod,
|
|
7868
|
-
DataLakeDriverConfigBaseZod,
|
|
7869
7837
|
DefaultMetricsScrapePorts,
|
|
7870
7838
|
EIP712DataPayloadFieldsZod,
|
|
7871
7839
|
EIP712DataPayloadSchema,
|
|
7872
7840
|
EIP712SignaturePayloadFieldsZod,
|
|
7873
7841
|
EIP712SignaturePayloadSchema,
|
|
7874
|
-
|
|
7875
|
-
EvmRpcTransportConfigZod,
|
|
7842
|
+
EvmRpcConnectionConfigZod,
|
|
7876
7843
|
GlobalMetaSchema,
|
|
7877
7844
|
HostActorConfigContext,
|
|
7878
7845
|
HostActorConfigZod,
|
|
@@ -7880,17 +7847,15 @@ export {
|
|
|
7880
7847
|
HydratedBoundWitnessWithStorageMetaZod,
|
|
7881
7848
|
HydratedCache,
|
|
7882
7849
|
JSONSchemaMetaSchema,
|
|
7883
|
-
|
|
7884
|
-
LmdbTransportConfigZod,
|
|
7850
|
+
LmdbConnectionConfigZod,
|
|
7885
7851
|
LoggerStatusReporter,
|
|
7886
7852
|
MemoryArchivistFactory,
|
|
7853
|
+
MemoryConnectionConfigZod,
|
|
7887
7854
|
MemoryPermissionsStore,
|
|
7888
|
-
MemoryTransportConfigZod,
|
|
7889
7855
|
MissingCapabilityError,
|
|
7890
7856
|
MnemonicStringZod,
|
|
7891
7857
|
MongoConfigZod,
|
|
7892
|
-
|
|
7893
|
-
MongoTransportConfigZod,
|
|
7858
|
+
MongoConnectionConfigZod,
|
|
7894
7859
|
PENDING_BLOCKS_ARCHIVIST_ROLE,
|
|
7895
7860
|
PENDING_TRANSACTIONS_ARCHIVIST_ROLE,
|
|
7896
7861
|
PRODUCER_DIVERSITY_BONUS,
|
|
@@ -7905,23 +7870,18 @@ export {
|
|
|
7905
7870
|
ProvidersConfigZod,
|
|
7906
7871
|
REJECTED_BLOCKS_ARCHIVIST_ROLE,
|
|
7907
7872
|
REJECTED_TRANSACTIONS_ARCHIVIST_ROLE,
|
|
7908
|
-
|
|
7909
|
-
RestDataLakeConfigZod,
|
|
7873
|
+
RestConnectionConfigZod,
|
|
7910
7874
|
RestDataLakeRunner,
|
|
7911
7875
|
RestDataLakeViewer,
|
|
7912
7876
|
RestSyncViewer,
|
|
7913
|
-
RestTransportConfigZod,
|
|
7914
7877
|
RewardMultipliers,
|
|
7915
|
-
|
|
7916
|
-
RpcTransportConfigZod as RpcConnectionConfigZod,
|
|
7878
|
+
RpcConnectionConfigZod,
|
|
7917
7879
|
RpcRemoteConfigBaseZod,
|
|
7918
7880
|
RpcRemoteConfigZod,
|
|
7919
|
-
RpcTransportConfigZod,
|
|
7920
7881
|
RuntimeStatusMonitor,
|
|
7921
7882
|
RuntimeStatusMonitorZod,
|
|
7922
7883
|
S3BucketConfigZod,
|
|
7923
|
-
|
|
7924
|
-
S3TransportConfigZod,
|
|
7884
|
+
S3ConnectionConfigZod,
|
|
7925
7885
|
SchemasStepSummarySchema,
|
|
7926
7886
|
ShiftedBigInt,
|
|
7927
7887
|
SimpleAccountBalanceViewer,
|
|
@@ -7953,8 +7913,6 @@ export {
|
|
|
7953
7913
|
TestGenesisBlockRewardAddress,
|
|
7954
7914
|
TransactionBuilder,
|
|
7955
7915
|
TransfersStepSummarySchema,
|
|
7956
|
-
TransportConfigZod,
|
|
7957
|
-
TransportsConfigZod,
|
|
7958
7916
|
TypedDataDomainZod,
|
|
7959
7917
|
TypedDataFieldZod,
|
|
7960
7918
|
TypedDataTypesZod,
|
|
@@ -8124,6 +8082,7 @@ export {
|
|
|
8124
8082
|
resolveConfig,
|
|
8125
8083
|
resolveProviders,
|
|
8126
8084
|
resolveProvidersFromConfig,
|
|
8085
|
+
resolveRestConnectionEndpoint,
|
|
8127
8086
|
rewardFromBlockNumber,
|
|
8128
8087
|
schemasMaxStep,
|
|
8129
8088
|
schemasStepSummaryFromRange,
|