@xyo-network/xl1-protocol-sdk 3.0.6 → 3.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/neutral/CreatableProvider/AbstractCreatableProvider.d.ts +5 -95
- package/dist/neutral/CreatableProvider/AbstractCreatableProvider.d.ts.map +1 -1
- package/dist/neutral/config/Actor.d.ts +30 -573
- package/dist/neutral/config/Actor.d.ts.map +1 -1
- package/dist/neutral/config/Actors.d.ts +5 -98
- package/dist/neutral/config/Actors.d.ts.map +1 -1
- package/dist/neutral/config/Base.d.ts +5 -98
- package/dist/neutral/config/Base.d.ts.map +1 -1
- package/dist/neutral/config/Config.d.ts +20 -386
- package/dist/neutral/config/Config.d.ts.map +1 -1
- package/dist/neutral/config/HostActor.d.ts +30 -573
- package/dist/neutral/config/HostActor.d.ts.map +1 -1
- package/dist/neutral/config/index.d.ts +2 -4
- package/dist/neutral/config/index.d.ts.map +1 -1
- package/dist/neutral/config/normalizeConnectionsConfig.d.ts +2 -5
- package/dist/neutral/config/normalizeConnectionsConfig.d.ts.map +1 -1
- package/dist/neutral/config/synthesizeRpcConnectionBindings.d.ts +8 -0
- package/dist/neutral/config/synthesizeRpcConnectionBindings.d.ts.map +1 -0
- package/dist/neutral/config/transports/Mongo.d.ts +12 -0
- package/dist/neutral/config/transports/Mongo.d.ts.map +1 -0
- package/dist/neutral/config/{Remote.d.ts → transports/Rpc.d.ts} +1 -14
- package/dist/neutral/config/transports/Rpc.d.ts.map +1 -0
- package/dist/neutral/config/transports/S3.d.ts +19 -0
- package/dist/neutral/config/transports/S3.d.ts.map +1 -0
- package/dist/neutral/config/transports/Transport.d.ts +15 -6
- package/dist/neutral/config/transports/Transport.d.ts.map +1 -1
- package/dist/neutral/config/transports/index.d.ts +3 -0
- package/dist/neutral/config/transports/index.d.ts.map +1 -1
- package/dist/neutral/context/Actor.d.ts +30 -573
- package/dist/neutral/context/Actor.d.ts.map +1 -1
- package/dist/neutral/context/HostActor.d.ts +30 -573
- package/dist/neutral/context/HostActor.d.ts.map +1 -1
- package/dist/neutral/context/index.d.ts +0 -1
- package/dist/neutral/context/index.d.ts.map +1 -1
- package/dist/neutral/getFileConfig.d.ts +10 -190
- package/dist/neutral/getFileConfig.d.ts.map +1 -1
- package/dist/neutral/getFileConfig.mjs +133 -199
- package/dist/neutral/getFileConfig.mjs.map +4 -4
- package/dist/neutral/index.mjs +317 -567
- package/dist/neutral/index.mjs.map +4 -4
- package/dist/neutral/model/CreatableProviderContext.zod.d.ts +30 -573
- package/dist/neutral/model/CreatableProviderContext.zod.d.ts.map +1 -1
- package/dist/neutral/simple/mempool/SimpleMempoolRunner.d.ts +1 -1
- package/dist/neutral/test/index.mjs +141 -207
- package/dist/neutral/test/index.mjs.map +4 -4
- package/package.json +13 -13
- package/dist/neutral/config/Evm.d.ts +0 -24
- package/dist/neutral/config/Evm.d.ts.map +0 -1
- package/dist/neutral/config/Remote.d.ts.map +0 -1
- package/dist/neutral/config/adaptLegacyConfig.d.ts +0 -8
- package/dist/neutral/config/adaptLegacyConfig.d.ts.map +0 -1
- package/dist/neutral/config/storage/Storage.d.ts +0 -45
- package/dist/neutral/config/storage/Storage.d.ts.map +0 -1
- package/dist/neutral/config/storage/driver/Mongo.d.ts +0 -25
- package/dist/neutral/config/storage/driver/Mongo.d.ts.map +0 -1
- package/dist/neutral/config/storage/driver/S3.d.ts +0 -77
- package/dist/neutral/config/storage/driver/S3.d.ts.map +0 -1
- package/dist/neutral/config/storage/driver/index.d.ts +0 -3
- package/dist/neutral/config/storage/driver/index.d.ts.map +0 -1
- package/dist/neutral/config/storage/index.d.ts +0 -3
- package/dist/neutral/config/storage/index.d.ts.map +0 -1
- package/dist/neutral/context/getEmptyProviderContext.d.ts +0 -7
- package/dist/neutral/context/getEmptyProviderContext.d.ts.map +0 -1
package/dist/neutral/index.mjs
CHANGED
|
@@ -1120,9 +1120,6 @@ function factoryBackingsCompatible(declared, available) {
|
|
|
1120
1120
|
}
|
|
1121
1121
|
|
|
1122
1122
|
// src/config/normalizeConnectionsConfig.ts
|
|
1123
|
-
function mergeConnectionMaps(transports, connections) {
|
|
1124
|
-
return { ...transports, ...connections };
|
|
1125
|
-
}
|
|
1126
1123
|
function normalizeProviderBinding(binding) {
|
|
1127
1124
|
const connectionName = binding.connection ?? binding.transport;
|
|
1128
1125
|
if (connectionName === void 0 || connectionName === "") {
|
|
@@ -1143,18 +1140,14 @@ function normalizeProviderBindings(bindings) {
|
|
|
1143
1140
|
return normalized;
|
|
1144
1141
|
}
|
|
1145
1142
|
function normalizeConnectionsConfig(config) {
|
|
1146
|
-
const transports = config.transports ?? {};
|
|
1147
|
-
const connections = config.connections ?? {};
|
|
1148
|
-
const merged = mergeConnectionMaps(transports, connections);
|
|
1149
1143
|
return {
|
|
1150
1144
|
...config,
|
|
1151
|
-
connections:
|
|
1152
|
-
providerBindings: normalizeProviderBindings(config.providerBindings ?? {})
|
|
1153
|
-
transports: merged
|
|
1145
|
+
connections: config.connections ?? {},
|
|
1146
|
+
providerBindings: normalizeProviderBindings(config.providerBindings ?? {})
|
|
1154
1147
|
};
|
|
1155
1148
|
}
|
|
1156
1149
|
function hasDeclaredConnectionProfiles(config) {
|
|
1157
|
-
return Object.keys(config.
|
|
1150
|
+
return Object.keys(config.connections ?? {}).length > 0;
|
|
1158
1151
|
}
|
|
1159
1152
|
|
|
1160
1153
|
// src/CreatableProvider/ProviderFactoryLocator.ts
|
|
@@ -1714,10 +1707,10 @@ import {
|
|
|
1714
1707
|
zodIsFactory as zodIsFactory2,
|
|
1715
1708
|
zodToFactory as zodToFactory2
|
|
1716
1709
|
} from "@xylabs/sdk-js";
|
|
1717
|
-
import { globalRegistry as
|
|
1710
|
+
import { globalRegistry as globalRegistry11, z as z17 } from "zod/mini";
|
|
1718
1711
|
|
|
1719
1712
|
// src/config/Base.ts
|
|
1720
|
-
import { z as
|
|
1713
|
+
import { z as z16 } from "zod/mini";
|
|
1721
1714
|
|
|
1722
1715
|
// src/config/Chain.ts
|
|
1723
1716
|
import { HexZod } from "@xylabs/sdk-js";
|
|
@@ -1737,172 +1730,129 @@ var ChainConfigZod = z2.object({
|
|
|
1737
1730
|
});
|
|
1738
1731
|
|
|
1739
1732
|
// src/config/transports/Transport.ts
|
|
1740
|
-
import { globalRegistry as
|
|
1733
|
+
import { globalRegistry as globalRegistry3, z as z5 } from "zod";
|
|
1741
1734
|
|
|
1742
|
-
// src/config/
|
|
1735
|
+
// src/config/transports/Mongo.ts
|
|
1743
1736
|
import { globalRegistry as globalRegistry2, z as z3 } from "zod";
|
|
1744
|
-
var
|
|
1745
|
-
protocol: z3.string("http").register(globalRegistry2, {
|
|
1746
|
-
description: "Protocol for the RPC connection",
|
|
1747
|
-
type: "string"
|
|
1748
|
-
})
|
|
1749
|
-
}).describe("Base configuration for the remote RPC");
|
|
1750
|
-
var HttpRpcRemoteConfigZod = RpcRemoteConfigBaseZod.extend({
|
|
1751
|
-
protocol: z3.string("http").register(globalRegistry2, {
|
|
1752
|
-
description: "Protocol for the RPC connection",
|
|
1753
|
-
type: "string"
|
|
1754
|
-
}).default("http"),
|
|
1755
|
-
url: z3.string().register(globalRegistry2, {
|
|
1756
|
-
description: "URL for the Chain RPC API",
|
|
1757
|
-
type: "string"
|
|
1758
|
-
})
|
|
1759
|
-
}).describe("Configuration for the remote RPC using Http");
|
|
1760
|
-
var PostMessageRpcRemoteConfigZod = RpcRemoteConfigBaseZod.extend({
|
|
1761
|
-
protocol: z3.string().register(globalRegistry2, {
|
|
1762
|
-
description: "Protocol for the RPC connection",
|
|
1763
|
-
type: "string"
|
|
1764
|
-
}).default("postMessage"),
|
|
1765
|
-
networkId: z3.string().register(globalRegistry2, {
|
|
1766
|
-
description: "Network ID to use for the postMessage RPC connection",
|
|
1767
|
-
type: "string"
|
|
1768
|
-
}),
|
|
1769
|
-
sessionId: z3.string().register(globalRegistry2, {
|
|
1770
|
-
description: "Session ID to use for the postMessage RPC connection",
|
|
1771
|
-
type: "string"
|
|
1772
|
-
})
|
|
1773
|
-
}).describe("Configuration for the remote RPC using postMessage");
|
|
1774
|
-
var RpcRemoteConfigZod = z3.union([HttpRpcRemoteConfigZod, PostMessageRpcRemoteConfigZod]).describe("Configuration for a remote RPC connection, either Http or postMessage");
|
|
1775
|
-
var RemoteConfigZod = z3.object({ rpc: RpcRemoteConfigZod.optional() }).describe("Configuration for remote connections, including RPC");
|
|
1776
|
-
|
|
1777
|
-
// src/config/storage/driver/Mongo.ts
|
|
1778
|
-
import { isDefined as isDefined5, isUndefined as isUndefined5 } from "@xylabs/sdk-js";
|
|
1779
|
-
import { globalRegistry as globalRegistry3, z as z4 } from "zod";
|
|
1780
|
-
var hasMongoConfig = (config) => {
|
|
1781
|
-
if (isUndefined5(config)) return false;
|
|
1782
|
-
return isDefined5(config.connectionString) && isDefined5(config.database) && isDefined5(config.domain);
|
|
1783
|
-
};
|
|
1784
|
-
var MongoConfigZod = z4.object({
|
|
1737
|
+
var MongoConfigZod = z3.object({
|
|
1785
1738
|
// TODO: Create from other arguments
|
|
1786
|
-
connectionString:
|
|
1739
|
+
connectionString: z3.string().nonempty().optional().register(globalRegistry2, {
|
|
1787
1740
|
description: "MongoDB connection string",
|
|
1788
1741
|
title: "storage.mongo.connectionString",
|
|
1789
1742
|
type: "string"
|
|
1790
1743
|
}),
|
|
1791
|
-
database:
|
|
1744
|
+
database: z3.string().nonempty().optional().register(globalRegistry2, {
|
|
1792
1745
|
description: "MongoDB database name",
|
|
1793
1746
|
title: "storage.mongo.database",
|
|
1794
1747
|
type: "string"
|
|
1795
1748
|
}),
|
|
1796
|
-
domain:
|
|
1749
|
+
domain: z3.string().nonempty().optional().register(globalRegistry2, {
|
|
1797
1750
|
description: "MongoDB domain",
|
|
1798
1751
|
title: "storage.mongo.domain",
|
|
1799
1752
|
type: "string"
|
|
1800
1753
|
}),
|
|
1801
|
-
password:
|
|
1754
|
+
password: z3.string().nonempty().optional().register(globalRegistry2, {
|
|
1802
1755
|
description: "MongoDB password",
|
|
1803
1756
|
title: "storage.mongo.password",
|
|
1804
1757
|
type: "string"
|
|
1805
1758
|
}),
|
|
1806
|
-
username:
|
|
1759
|
+
username: z3.string().nonempty().optional().register(globalRegistry2, {
|
|
1807
1760
|
description: "MongoDB username",
|
|
1808
1761
|
title: "storage.mongo.username",
|
|
1809
1762
|
type: "string"
|
|
1810
1763
|
})
|
|
1811
1764
|
});
|
|
1812
1765
|
|
|
1813
|
-
// src/config/
|
|
1814
|
-
import {
|
|
1815
|
-
|
|
1816
|
-
|
|
1817
|
-
|
|
1818
|
-
|
|
1819
|
-
|
|
1820
|
-
|
|
1821
|
-
|
|
1822
|
-
secretAccessKey: z5.string().nonempty().optional().describe("S3-compatible secret access key for this bucket (overrides the shared default)")
|
|
1823
|
-
});
|
|
1824
|
-
var S3ConfigZod = z5.object({
|
|
1825
|
-
accessKeyId: z5.string().nonempty().optional().describe("Shared S3-compatible access key id (default for all buckets)"),
|
|
1826
|
-
accountId: z5.string().nonempty().optional().describe("Shared account id (default for all buckets; on Cloudflare R2 it forms the endpoint)"),
|
|
1827
|
-
chainState: S3BucketConfigZod.optional().describe("Bucket for the mutable chain state (the head pointer)"),
|
|
1828
|
-
finalized: S3BucketConfigZod.optional().describe("Bucket for the finalized files (blocks, payloads, manifest)"),
|
|
1829
|
-
index: S3BucketConfigZod.optional().describe("Bucket for the chain index (the step-summary families)"),
|
|
1830
|
-
prefix: z5.string().nonempty().optional().describe("Shared key prefix (default for all buckets)"),
|
|
1831
|
-
secretAccessKey: z5.string().nonempty().optional().describe("Shared S3-compatible secret access key (default for all buckets)")
|
|
1766
|
+
// src/config/transports/S3.ts
|
|
1767
|
+
import { z as z4 } from "zod";
|
|
1768
|
+
var S3BucketConfigZod = z4.object({
|
|
1769
|
+
accessKeyId: z4.string().nonempty().optional().describe("S3-compatible access key id for this bucket (overrides the shared default)"),
|
|
1770
|
+
accountId: z4.string().nonempty().optional().describe("Account id for this bucket; on Cloudflare R2 it forms the endpoint (overrides the shared default)"),
|
|
1771
|
+
bucket: z4.string().nonempty().optional().describe("S3-compatible bucket name"),
|
|
1772
|
+
prefix: z4.string().nonempty().optional().describe("Optional key prefix within the bucket"),
|
|
1773
|
+
readUrl: z4.string().nonempty().optional().describe("Public HTTP/CDN base URL for anonymous reads of this bucket"),
|
|
1774
|
+
secretAccessKey: z4.string().nonempty().optional().describe("S3-compatible secret access key for this bucket (overrides the shared default)")
|
|
1832
1775
|
});
|
|
1833
|
-
function resolveS3Bucket(config, which) {
|
|
1834
|
-
if (config === void 0) return void 0;
|
|
1835
|
-
const entry = config[which];
|
|
1836
|
-
const accessKeyId = entry?.accessKeyId ?? config.accessKeyId;
|
|
1837
|
-
const accountId = entry?.accountId ?? config.accountId;
|
|
1838
|
-
const secretAccessKey = entry?.secretAccessKey ?? config.secretAccessKey;
|
|
1839
|
-
const bucket = entry?.bucket ?? config.finalized?.bucket;
|
|
1840
|
-
if (!isDefined6(accessKeyId) || !isDefined6(accountId) || !isDefined6(secretAccessKey) || !isDefined6(bucket)) return void 0;
|
|
1841
|
-
return {
|
|
1842
|
-
accessKeyId,
|
|
1843
|
-
accountId,
|
|
1844
|
-
bucket,
|
|
1845
|
-
prefix: entry?.prefix ?? config.prefix,
|
|
1846
|
-
readUrl: entry?.readUrl,
|
|
1847
|
-
secretAccessKey
|
|
1848
|
-
};
|
|
1849
|
-
}
|
|
1850
|
-
function hasS3Config(config, which = "finalized") {
|
|
1851
|
-
return resolveS3Bucket(config, which) !== void 0;
|
|
1852
|
-
}
|
|
1853
1776
|
|
|
1854
1777
|
// src/config/transports/Transport.ts
|
|
1855
|
-
var LmdbTransportConfigZod =
|
|
1856
|
-
access:
|
|
1778
|
+
var LmdbTransportConfigZod = z5.object({
|
|
1779
|
+
access: z5.enum(["read", "write"]).optional().register(globalRegistry3, {
|
|
1857
1780
|
description: "Access mode for this LMDB connection (read or write)",
|
|
1858
1781
|
title: "transports.lmdb.access",
|
|
1859
1782
|
type: "string"
|
|
1860
1783
|
}),
|
|
1861
|
-
root:
|
|
1784
|
+
root: z5.string().register(globalRegistry3, {
|
|
1862
1785
|
description: "Root directory for local LMDB storage",
|
|
1863
1786
|
title: "transports.lmdb.root",
|
|
1864
1787
|
type: "string"
|
|
1865
1788
|
}),
|
|
1866
|
-
store:
|
|
1789
|
+
store: z5.string().optional().register(globalRegistry3, {
|
|
1867
1790
|
description: "Logical store name within the LMDB root (e.g. finalized-chain, mempool)",
|
|
1868
1791
|
title: "transports.lmdb.store",
|
|
1869
1792
|
type: "string"
|
|
1870
1793
|
}),
|
|
1871
|
-
type:
|
|
1794
|
+
type: z5.literal("lmdb")
|
|
1872
1795
|
}).describe("LMDB local storage transport");
|
|
1873
|
-
var MongoTransportConfigZod =
|
|
1874
|
-
type:
|
|
1796
|
+
var MongoTransportConfigZod = z5.object({
|
|
1797
|
+
type: z5.literal("mongo"),
|
|
1875
1798
|
connectionString: MongoConfigZod.shape.connectionString,
|
|
1876
1799
|
database: MongoConfigZod.shape.database,
|
|
1877
1800
|
domain: MongoConfigZod.shape.domain,
|
|
1878
1801
|
password: MongoConfigZod.shape.password,
|
|
1879
1802
|
username: MongoConfigZod.shape.username
|
|
1880
1803
|
}).describe("MongoDB storage transport");
|
|
1881
|
-
var RpcTransportConfigZod =
|
|
1882
|
-
|
|
1883
|
-
|
|
1884
|
-
|
|
1804
|
+
var RpcTransportConfigZod = z5.object({
|
|
1805
|
+
type: z5.literal("rpc"),
|
|
1806
|
+
protocol: z5.string().default("http").register(globalRegistry3, {
|
|
1807
|
+
description: "Protocol for the RPC connection (http or postMessage)",
|
|
1808
|
+
title: "transports.rpc.protocol",
|
|
1809
|
+
type: "string"
|
|
1810
|
+
}),
|
|
1811
|
+
url: z5.string().optional().register(globalRegistry3, {
|
|
1812
|
+
description: "URL for the Chain RPC API (http protocol)",
|
|
1813
|
+
title: "transports.rpc.url",
|
|
1814
|
+
type: "string"
|
|
1815
|
+
}),
|
|
1816
|
+
networkId: z5.string().optional().register(globalRegistry3, {
|
|
1817
|
+
description: "Network ID for the postMessage RPC connection",
|
|
1818
|
+
title: "transports.rpc.networkId",
|
|
1819
|
+
type: "string"
|
|
1820
|
+
}),
|
|
1821
|
+
sessionId: z5.string().optional().register(globalRegistry3, {
|
|
1822
|
+
description: "Session ID for the postMessage RPC connection",
|
|
1823
|
+
title: "transports.rpc.sessionId",
|
|
1824
|
+
type: "string"
|
|
1825
|
+
})
|
|
1826
|
+
}).describe("XL1 JSON-RPC transport");
|
|
1827
|
+
var RestTransportConfigZod = z5.object({
|
|
1828
|
+
type: z5.literal("rest"),
|
|
1829
|
+
baseUrl: z5.string().register(globalRegistry3, {
|
|
1885
1830
|
description: "HTTP base URL for REST reads",
|
|
1886
1831
|
title: "transports.rest.baseUrl",
|
|
1887
1832
|
type: "string"
|
|
1888
1833
|
})
|
|
1889
1834
|
}).describe("HTTP REST read transport");
|
|
1890
1835
|
var S3TransportConfigZod = S3BucketConfigZod.extend({
|
|
1891
|
-
type:
|
|
1892
|
-
accessKeyId:
|
|
1893
|
-
accountId:
|
|
1894
|
-
secretAccessKey:
|
|
1836
|
+
type: z5.literal("s3"),
|
|
1837
|
+
accessKeyId: z5.string().optional(),
|
|
1838
|
+
accountId: z5.string().optional(),
|
|
1839
|
+
secretAccessKey: z5.string().optional()
|
|
1895
1840
|
}).describe("S3-compatible object storage transport");
|
|
1896
|
-
var EvmRpcTransportConfigZod =
|
|
1897
|
-
type:
|
|
1898
|
-
url:
|
|
1841
|
+
var EvmRpcTransportConfigZod = z5.object({
|
|
1842
|
+
type: z5.literal("evm-rpc"),
|
|
1843
|
+
url: z5.string().register(globalRegistry3, {
|
|
1899
1844
|
description: "EVM JSON-RPC URL",
|
|
1900
1845
|
title: "transports.evm-rpc.url",
|
|
1901
1846
|
type: "string"
|
|
1847
|
+
}),
|
|
1848
|
+
chainId: z5.string().optional().register(globalRegistry3, {
|
|
1849
|
+
description: "EVM chain ID for this RPC endpoint; auto-detected from the endpoint when omitted",
|
|
1850
|
+
title: "transports.evm-rpc.chainId",
|
|
1851
|
+
type: "string"
|
|
1902
1852
|
})
|
|
1903
1853
|
}).describe("EVM JSON-RPC transport");
|
|
1904
|
-
var MemoryTransportConfigZod =
|
|
1905
|
-
var TransportConfigZod =
|
|
1854
|
+
var MemoryTransportConfigZod = z5.object({ type: z5.literal("memory") }).describe("In-process memory transport");
|
|
1855
|
+
var TransportConfigZod = z5.discriminatedUnion("type", [
|
|
1906
1856
|
LmdbTransportConfigZod,
|
|
1907
1857
|
MongoTransportConfigZod,
|
|
1908
1858
|
RpcTransportConfigZod,
|
|
@@ -1911,18 +1861,18 @@ var TransportConfigZod = z6.discriminatedUnion("type", [
|
|
|
1911
1861
|
EvmRpcTransportConfigZod,
|
|
1912
1862
|
MemoryTransportConfigZod
|
|
1913
1863
|
]);
|
|
1914
|
-
var TransportsConfigZod =
|
|
1864
|
+
var TransportsConfigZod = z5.record(z5.string(), TransportConfigZod).default({});
|
|
1915
1865
|
|
|
1916
1866
|
// src/config/DataLake/DataLake.ts
|
|
1917
|
-
import { z as
|
|
1867
|
+
import { z as z9 } from "zod";
|
|
1918
1868
|
|
|
1919
1869
|
// src/config/DataLake/RestDataLakeConfig.ts
|
|
1920
|
-
import { globalRegistry as
|
|
1870
|
+
import { globalRegistry as globalRegistry5, z as z7 } from "zod";
|
|
1921
1871
|
|
|
1922
1872
|
// src/config/DataLake/DataLakeRemoteConfig.ts
|
|
1923
|
-
import { globalRegistry as
|
|
1924
|
-
var DataLakeDriverConfigBaseZod =
|
|
1925
|
-
driver:
|
|
1873
|
+
import { globalRegistry as globalRegistry4, z as z6 } from "zod";
|
|
1874
|
+
var DataLakeDriverConfigBaseZod = z6.object({
|
|
1875
|
+
driver: z6.string().register(globalRegistry4, {
|
|
1926
1876
|
description: "Driver for the data lake",
|
|
1927
1877
|
type: "string"
|
|
1928
1878
|
})
|
|
@@ -1930,76 +1880,45 @@ var DataLakeDriverConfigBaseZod = z7.object({
|
|
|
1930
1880
|
|
|
1931
1881
|
// src/config/DataLake/RestDataLakeConfig.ts
|
|
1932
1882
|
var RestDataLakeConfigZod = DataLakeDriverConfigBaseZod.extend({
|
|
1933
|
-
driver:
|
|
1883
|
+
driver: z7.literal("rest").register(globalRegistry5, {
|
|
1934
1884
|
description: "Driver for the REST data lake",
|
|
1935
1885
|
type: "string"
|
|
1936
1886
|
}),
|
|
1937
|
-
url:
|
|
1887
|
+
url: z7.string().register(globalRegistry5, {
|
|
1938
1888
|
description: "URL for the REST data lake",
|
|
1939
1889
|
type: "string"
|
|
1940
1890
|
})
|
|
1941
1891
|
}).describe("Configuration for the REST data lake driver");
|
|
1942
1892
|
|
|
1943
1893
|
// src/config/DataLake/RouterDataLakeConfig.ts
|
|
1944
|
-
import { globalRegistry as
|
|
1945
|
-
var RouterDataLakeConfigZod =
|
|
1946
|
-
driver:
|
|
1894
|
+
import { globalRegistry as globalRegistry6, z as z8 } from "zod";
|
|
1895
|
+
var RouterDataLakeConfigZod = z8.object({
|
|
1896
|
+
driver: z8.literal("router").register(globalRegistry6, {
|
|
1947
1897
|
description: "Driver for the router data lake",
|
|
1948
1898
|
type: "string"
|
|
1949
1899
|
}),
|
|
1950
|
-
children:
|
|
1900
|
+
children: z8.array(z8.lazy(() => DataLakeConfigZod)).register(globalRegistry6, {
|
|
1951
1901
|
description: "Child data lake drivers",
|
|
1952
1902
|
type: "array"
|
|
1953
1903
|
})
|
|
1954
1904
|
}).describe("Configuration for the router data lake driver");
|
|
1955
1905
|
|
|
1956
1906
|
// src/config/DataLake/DataLake.ts
|
|
1957
|
-
var DataLakeConfigZod =
|
|
1958
|
-
|
|
1959
|
-
// src/config/Evm.ts
|
|
1960
|
-
import { globalRegistry as globalRegistry8, z as z11 } from "zod";
|
|
1961
|
-
var EvmInfuraConfigZod = z11.object({
|
|
1962
|
-
projectId: z11.string().optional().register(globalRegistry8, {
|
|
1963
|
-
description: "Infura project ID",
|
|
1964
|
-
title: "evm.infura.projectId",
|
|
1965
|
-
type: "string"
|
|
1966
|
-
}),
|
|
1967
|
-
projectSecret: z11.string().optional().register(globalRegistry8, {
|
|
1968
|
-
description: "Infura project secret",
|
|
1969
|
-
title: "evm.infura.projectSecret",
|
|
1970
|
-
type: "string"
|
|
1971
|
-
})
|
|
1972
|
-
});
|
|
1973
|
-
var EvmJsonRpcConfigZod = z11.object({
|
|
1974
|
-
url: z11.url().optional().register(globalRegistry8, {
|
|
1975
|
-
description: "JSON-RPC URL",
|
|
1976
|
-
title: "evm.jsonRpc.url",
|
|
1977
|
-
type: "string"
|
|
1978
|
-
})
|
|
1979
|
-
});
|
|
1980
|
-
var EvmConfigZod = z11.object({
|
|
1981
|
-
chainId: z11.string().optional().register(globalRegistry8, {
|
|
1982
|
-
description: "EVM chain ID",
|
|
1983
|
-
title: "evm.chainId",
|
|
1984
|
-
type: "string"
|
|
1985
|
-
}),
|
|
1986
|
-
infura: EvmInfuraConfigZod.optional().describe("Infura Provider configuration"),
|
|
1987
|
-
jsonRpc: EvmJsonRpcConfigZod.optional().describe("JSON-RPC Provider configuration")
|
|
1988
|
-
});
|
|
1907
|
+
var DataLakeConfigZod = z9.lazy(() => z9.union([RestDataLakeConfigZod, RouterDataLakeConfigZod])).describe("Configuration for a data lake");
|
|
1989
1908
|
|
|
1990
1909
|
// src/config/Log.ts
|
|
1991
1910
|
import { LogLevel } from "@xylabs/sdk-js";
|
|
1992
|
-
import { globalRegistry as
|
|
1911
|
+
import { globalRegistry as globalRegistry7, z as z10 } from "zod";
|
|
1993
1912
|
var LogLevelNames = Object.keys(LogLevel);
|
|
1994
|
-
var LogConfigZod =
|
|
1995
|
-
logLevel:
|
|
1913
|
+
var LogConfigZod = z10.object({
|
|
1914
|
+
logLevel: z10.enum(LogLevelNames).default("info").register(globalRegistry7, {
|
|
1996
1915
|
choices: LogLevelNames,
|
|
1997
1916
|
default: "info",
|
|
1998
1917
|
description: "Desired process verbosity",
|
|
1999
1918
|
title: "logLevel",
|
|
2000
1919
|
type: "string"
|
|
2001
1920
|
}),
|
|
2002
|
-
silent:
|
|
1921
|
+
silent: z10.boolean().default(false).register(globalRegistry7, {
|
|
2003
1922
|
default: false,
|
|
2004
1923
|
description: "Whether to run in silent mode",
|
|
2005
1924
|
title: "silent",
|
|
@@ -2008,23 +1927,23 @@ var LogConfigZod = z12.object({
|
|
|
2008
1927
|
});
|
|
2009
1928
|
|
|
2010
1929
|
// src/config/ProviderBinding.ts
|
|
2011
|
-
import { globalRegistry as
|
|
2012
|
-
var ProviderBindingConfigZod =
|
|
2013
|
-
connection:
|
|
1930
|
+
import { globalRegistry as globalRegistry8, z as z11 } from "zod";
|
|
1931
|
+
var ProviderBindingConfigZod = z11.object({
|
|
1932
|
+
connection: z11.string().optional().register(globalRegistry8, {
|
|
2014
1933
|
description: "Named connection from the top-level connections map",
|
|
2015
1934
|
title: "providerBindings.connection",
|
|
2016
1935
|
type: "string"
|
|
2017
1936
|
}),
|
|
2018
|
-
transport:
|
|
1937
|
+
transport: z11.string().optional().register(globalRegistry8, {
|
|
2019
1938
|
description: "Deprecated alias for connection (kept in sync during migration)",
|
|
2020
1939
|
title: "providerBindings.transport",
|
|
2021
1940
|
type: "string"
|
|
2022
1941
|
})
|
|
2023
1942
|
}).describe("Provider connection binding");
|
|
2024
|
-
var ProviderBindingsConfigZod =
|
|
1943
|
+
var ProviderBindingsConfigZod = z11.record(z11.string(), ProviderBindingConfigZod).default({});
|
|
2025
1944
|
|
|
2026
1945
|
// src/config/Providers.ts
|
|
2027
|
-
import
|
|
1946
|
+
import z13 from "zod";
|
|
2028
1947
|
|
|
2029
1948
|
// src/config/Provider.ts
|
|
2030
1949
|
import {
|
|
@@ -2032,32 +1951,20 @@ import {
|
|
|
2032
1951
|
zodIsFactory,
|
|
2033
1952
|
zodToFactory
|
|
2034
1953
|
} from "@xylabs/sdk-js";
|
|
2035
|
-
import { z as
|
|
2036
|
-
var ProviderConfigZod =
|
|
2037
|
-
moniker:
|
|
2038
|
-
labels:
|
|
1954
|
+
import { z as z12 } from "zod";
|
|
1955
|
+
var ProviderConfigZod = z12.object({
|
|
1956
|
+
moniker: z12.string(),
|
|
1957
|
+
labels: z12.array(z12.string()).optional()
|
|
2039
1958
|
}).describe("Configuration for a Provider");
|
|
2040
1959
|
var isProviderConfig = zodIsFactory(ProviderConfigZod);
|
|
2041
1960
|
var asProviderConfig = zodAsFactory2(ProviderConfigZod, "asProviderConfig");
|
|
2042
1961
|
var toProviderConfig = zodToFactory(ProviderConfigZod, "toProviderConfig");
|
|
2043
1962
|
|
|
2044
1963
|
// src/config/Providers.ts
|
|
2045
|
-
var ProvidersConfigZod =
|
|
2046
|
-
|
|
2047
|
-
// src/config/storage/Storage.ts
|
|
2048
|
-
import { globalRegistry as globalRegistry11, z as z16 } from "zod";
|
|
2049
|
-
var StorageConfigZod = z16.object({
|
|
2050
|
-
mongo: MongoConfigZod.optional().describe("Configuration for the MongoD storage driver"),
|
|
2051
|
-
root: z16.string().optional().register(globalRegistry11, {
|
|
2052
|
-
description: "Root directory for local storage",
|
|
2053
|
-
title: "storage.root",
|
|
2054
|
-
type: "string"
|
|
2055
|
-
}),
|
|
2056
|
-
s3: S3ConfigZod.optional().describe("Configuration for S3-compatible object storage (e.g. Cloudflare R2)")
|
|
2057
|
-
}).describe("Storage configuration options");
|
|
1964
|
+
var ProvidersConfigZod = z13.array(ProviderConfigZod.loose()).describe("Configuration for providers").default([]);
|
|
2058
1965
|
|
|
2059
1966
|
// src/config/Telemetry.ts
|
|
2060
|
-
import { globalRegistry as
|
|
1967
|
+
import { globalRegistry as globalRegistry9, z as z14 } from "zod";
|
|
2061
1968
|
var DefaultMetricsScrapePorts = {
|
|
2062
1969
|
api: 9465,
|
|
2063
1970
|
bridge: 9468,
|
|
@@ -2065,29 +1972,29 @@ var DefaultMetricsScrapePorts = {
|
|
|
2065
1972
|
producer: 9464,
|
|
2066
1973
|
rewardRedemptionApi: 9467
|
|
2067
1974
|
};
|
|
2068
|
-
var MetricsScrapeConfigZod =
|
|
2069
|
-
path:
|
|
1975
|
+
var MetricsScrapeConfigZod = z14.object({
|
|
1976
|
+
path: z14.string().default("/metrics").register(globalRegistry9, {
|
|
2070
1977
|
default: "/metrics",
|
|
2071
1978
|
description: "Path for the metrics scrape endpoint",
|
|
2072
1979
|
title: "telemetry.metrics.scrape.path",
|
|
2073
1980
|
type: "string"
|
|
2074
1981
|
}),
|
|
2075
|
-
port:
|
|
2076
|
-
description: "Port for the metrics scrape endpoint",
|
|
1982
|
+
port: z14.coerce.number().int().nonnegative().optional().register(globalRegistry9, {
|
|
1983
|
+
description: "Port for the metrics scrape endpoint (0 disables the scrape endpoint)",
|
|
2077
1984
|
title: "telemetry.metrics.scrape.port",
|
|
2078
1985
|
type: "number"
|
|
2079
1986
|
})
|
|
2080
1987
|
}).describe("Metrics scrape configuration");
|
|
2081
|
-
var MetricsConfigZod =
|
|
2082
|
-
var OpenTelemetryConfigZod =
|
|
1988
|
+
var MetricsConfigZod = z14.object({ scrape: MetricsScrapeConfigZod }).describe("Metrics configuration options");
|
|
1989
|
+
var OpenTelemetryConfigZod = z14.object({
|
|
2083
1990
|
// OpenTelemetry options
|
|
2084
|
-
otlpEndpoint:
|
|
1991
|
+
otlpEndpoint: z14.url().optional().register(globalRegistry9, {
|
|
2085
1992
|
description: "OTLP endpoint for exporting telemetry data",
|
|
2086
1993
|
title: "telemetry.otel.otlpEndpoint",
|
|
2087
1994
|
type: "string"
|
|
2088
1995
|
})
|
|
2089
1996
|
});
|
|
2090
|
-
var TelemetryConfigZod =
|
|
1997
|
+
var TelemetryConfigZod = z14.object({
|
|
2091
1998
|
// Metrics configuration
|
|
2092
1999
|
metrics: MetricsConfigZod.optional().describe("Metrics configuration"),
|
|
2093
2000
|
// OpenTelemetry configuration
|
|
@@ -2096,7 +2003,7 @@ var TelemetryConfigZod = z17.object({
|
|
|
2096
2003
|
|
|
2097
2004
|
// src/config/Validation.ts
|
|
2098
2005
|
import { XyoAddressZod as XyoAddressZod2 } from "@xyo-network/sdk-js";
|
|
2099
|
-
import { globalRegistry as
|
|
2006
|
+
import { globalRegistry as globalRegistry10, z as z15 } from "zod";
|
|
2100
2007
|
|
|
2101
2008
|
// src/primitives/block/range/blockRangeSteps.ts
|
|
2102
2009
|
import { asXL1BlockNumber as asXL1BlockNumber2, StepSizes as StepSizes3 } from "@xyo-network/xl1-protocol-lib";
|
|
@@ -2117,11 +2024,11 @@ function blockRangeSteps(range, steps) {
|
|
|
2117
2024
|
}
|
|
2118
2025
|
|
|
2119
2026
|
// src/primitives/block/rate/blockRate.ts
|
|
2120
|
-
import { isDefined as
|
|
2027
|
+
import { isDefined as isDefined6, isFalsy } from "@xylabs/sdk-js";
|
|
2121
2028
|
import { asXL1BlockRange } from "@xyo-network/xl1-protocol-lib";
|
|
2122
2029
|
|
|
2123
2030
|
// src/primitives/block/rate/timeHelpers.ts
|
|
2124
|
-
import { assertEx as assertEx10, isDefined as
|
|
2031
|
+
import { assertEx as assertEx10, isDefined as isDefined5 } from "@xylabs/sdk-js";
|
|
2125
2032
|
var rateMultipliers = {
|
|
2126
2033
|
millis: 1,
|
|
2127
2034
|
seconds: 1e3,
|
|
@@ -2139,7 +2046,7 @@ var timeDurations = (timeInMs) => ({
|
|
|
2139
2046
|
weeks: timeInMs / (1e3 * 60 * 60 * 24 * 7)
|
|
2140
2047
|
});
|
|
2141
2048
|
var getTimeConfigInMilliseconds = (timeConfig) => {
|
|
2142
|
-
const assertedTimeConfig = assertEx10(
|
|
2049
|
+
const assertedTimeConfig = assertEx10(isDefined5(timeConfig) ? timeConfig : void 0, () => "Time configuration must be provided");
|
|
2143
2050
|
let totalMilliseconds = 0;
|
|
2144
2051
|
if ("years" in assertedTimeConfig) {
|
|
2145
2052
|
totalMilliseconds += assertedTimeConfig.years * 31536e6;
|
|
@@ -2178,13 +2085,13 @@ var blockRate = (startBlock, endBlock, timeUnit) => {
|
|
|
2178
2085
|
throw new Error("Time difference must be greater than 0");
|
|
2179
2086
|
}
|
|
2180
2087
|
const rate = heightDifference / timeDifference;
|
|
2181
|
-
const timeUnitValue =
|
|
2182
|
-
const returnedTimeDifference =
|
|
2088
|
+
const timeUnitValue = isDefined6(timeUnit) ? timeUnit : "millis";
|
|
2089
|
+
const returnedTimeDifference = isDefined6(timeUnit) ? timeDurations(timeDifference)[timeUnit] : timeDifference;
|
|
2183
2090
|
const timePerBlock = returnedTimeDifference / heightDifference;
|
|
2184
2091
|
return {
|
|
2185
2092
|
range: asXL1BlockRange([startingBlock.block, endingBlock.block], true),
|
|
2186
2093
|
span: heightDifference,
|
|
2187
|
-
rate:
|
|
2094
|
+
rate: isDefined6(timeUnit) ? rate * rateMultipliers[timeUnit] : rate,
|
|
2188
2095
|
timeUnit: timeUnitValue,
|
|
2189
2096
|
timeDifference: returnedTimeDifference,
|
|
2190
2097
|
timePerBlock
|
|
@@ -2232,7 +2139,7 @@ var calculateStepSizeRate = async (viewer, start, stepIndex, count = 1, timeUnit
|
|
|
2232
2139
|
// src/primitives/block/rate/timeRate.ts
|
|
2233
2140
|
import {
|
|
2234
2141
|
assertEx as assertEx12,
|
|
2235
|
-
isDefined as
|
|
2142
|
+
isDefined as isDefined7,
|
|
2236
2143
|
isDefinedNotNull
|
|
2237
2144
|
} from "@xylabs/sdk-js";
|
|
2238
2145
|
import { asXL1BlockNumber as asXL1BlockNumber3, asXL1BlockRange as asXL1BlockRange3 } from "@xyo-network/xl1-protocol-lib";
|
|
@@ -2271,7 +2178,7 @@ var findEndBlockRecursive = async (viewer, startBlock, targetTimeMs, estimatedBl
|
|
|
2271
2178
|
}
|
|
2272
2179
|
const endBlock = await viewer.blockByNumber(estimatedEndBlockNumber);
|
|
2273
2180
|
const resolvedEndBlock = assertEx12(
|
|
2274
|
-
|
|
2181
|
+
isDefined7(endBlock?.[0]) ? endBlock[0] : void 0,
|
|
2275
2182
|
() => `Could not retrieve block ${estimatedEndBlockNumber} for time rate calculation`
|
|
2276
2183
|
);
|
|
2277
2184
|
const endBlockEpoch = resolvedEndBlock.$epoch;
|
|
@@ -2308,7 +2215,7 @@ var findEndBlockRecursive = async (viewer, startBlock, targetTimeMs, estimatedBl
|
|
|
2308
2215
|
// src/primitives/chain/getWindowedChain.ts
|
|
2309
2216
|
import {
|
|
2310
2217
|
assertEx as assertEx13,
|
|
2311
|
-
isDefined as
|
|
2218
|
+
isDefined as isDefined8,
|
|
2312
2219
|
isNull,
|
|
2313
2220
|
spanRootAsync
|
|
2314
2221
|
} from "@xylabs/sdk-js";
|
|
@@ -2322,7 +2229,7 @@ async function getWindowedChain(context, blockViewer, maxWindowSize, previousCha
|
|
|
2322
2229
|
while (currentBlock !== null && newChain.length < maxWindowSize) {
|
|
2323
2230
|
const currentBlockNumber = currentBlock[0].block;
|
|
2324
2231
|
const nextBlock = newChain[0];
|
|
2325
|
-
if (
|
|
2232
|
+
if (isDefined8(nextBlock)) {
|
|
2326
2233
|
const nextBlockNumber = nextBlock[0].block;
|
|
2327
2234
|
assertEx13(
|
|
2328
2235
|
currentBlockNumber === nextBlockNumber - 1,
|
|
@@ -2419,7 +2326,7 @@ async function chainStepRewardAddress(context, blockViewer, { block, step }) {
|
|
|
2419
2326
|
}
|
|
2420
2327
|
|
|
2421
2328
|
// src/primitives/chain/step/stepRewardTotal.ts
|
|
2422
|
-
import { assertEx as assertEx17, isDefined as
|
|
2329
|
+
import { assertEx as assertEx17, isDefined as isDefined9 } from "@xylabs/sdk-js";
|
|
2423
2330
|
import {
|
|
2424
2331
|
asAttoXL1,
|
|
2425
2332
|
asXL1BlockRange as asXL1BlockRange5,
|
|
@@ -2512,7 +2419,7 @@ function stepInRange(step, range) {
|
|
|
2512
2419
|
return stepRange[0] >= range[0] && stepRange[1] <= range[1];
|
|
2513
2420
|
}
|
|
2514
2421
|
async function stepRewardTotal(context, blockViewer, { block, step }, multipliers) {
|
|
2515
|
-
const cacheKey = `${block}|${step}|${
|
|
2422
|
+
const cacheKey = `${block}|${step}|${isDefined9(multipliers)}`;
|
|
2516
2423
|
return await withContextCacheResponse(context, "stepRewardTotal", cacheKey, async () => {
|
|
2517
2424
|
const [blockBw, payloads] = await stepRewardBlock(context, blockViewer, { block, step });
|
|
2518
2425
|
assertEx17(blockBw.block === block, () => `Block Mismatch: expected ${block}, got ${blockBw.block}`);
|
|
@@ -2603,7 +2510,7 @@ async function externalBlockRangeFromStep(context, blockViewer, stepIdentity) {
|
|
|
2603
2510
|
}
|
|
2604
2511
|
|
|
2605
2512
|
// src/primitives/mapToMapType.ts
|
|
2606
|
-
import { isDefined as
|
|
2513
|
+
import { isDefined as isDefined10 } from "@xylabs/sdk-js";
|
|
2607
2514
|
function mapToMapType(map) {
|
|
2608
2515
|
return {
|
|
2609
2516
|
get: (key) => map.get(key),
|
|
@@ -2622,7 +2529,7 @@ function mapToMapType(map) {
|
|
|
2622
2529
|
const result = [];
|
|
2623
2530
|
for (const key of keys) {
|
|
2624
2531
|
const value = map.get(key);
|
|
2625
|
-
if (
|
|
2532
|
+
if (isDefined10(value)) {
|
|
2626
2533
|
result.push(value);
|
|
2627
2534
|
}
|
|
2628
2535
|
}
|
|
@@ -2637,7 +2544,7 @@ function mapToMapType(map) {
|
|
|
2637
2544
|
}
|
|
2638
2545
|
|
|
2639
2546
|
// src/primitives/readPayloadMapFromStore.ts
|
|
2640
|
-
import { isDefined as
|
|
2547
|
+
import { isDefined as isDefined11 } from "@xylabs/sdk-js";
|
|
2641
2548
|
function readPayloadMapFromStore(store) {
|
|
2642
2549
|
if (isReadArchivist(store)) {
|
|
2643
2550
|
return {
|
|
@@ -2650,7 +2557,7 @@ function readPayloadMapFromStore(store) {
|
|
|
2650
2557
|
},
|
|
2651
2558
|
has: async (hash) => {
|
|
2652
2559
|
const results = await store.get([hash]);
|
|
2653
|
-
return
|
|
2560
|
+
return isDefined11(results[0]);
|
|
2654
2561
|
}
|
|
2655
2562
|
};
|
|
2656
2563
|
}
|
|
@@ -2668,7 +2575,7 @@ function payloadMapFromStore(store) {
|
|
|
2668
2575
|
},
|
|
2669
2576
|
has: async (hash) => {
|
|
2670
2577
|
const results = await store.get([hash]);
|
|
2671
|
-
return
|
|
2578
|
+
return isDefined11(results[0]);
|
|
2672
2579
|
},
|
|
2673
2580
|
clear: async () => {
|
|
2674
2581
|
return await store.clear();
|
|
@@ -2714,7 +2621,7 @@ function rewardFromBlockNumber(blockNumber) {
|
|
|
2714
2621
|
import { XYO_NETWORK_STAKING_ADDRESS } from "@xyo-network/xl1-protocol-lib";
|
|
2715
2622
|
|
|
2716
2623
|
// src/primitives/stake/activeStakeAtTimeByAddress.ts
|
|
2717
|
-
import { isDefined as
|
|
2624
|
+
import { isDefined as isDefined12 } from "@xylabs/sdk-js";
|
|
2718
2625
|
|
|
2719
2626
|
// src/primitives/stake/mergedAddRemoveStakeEventsByStaker.ts
|
|
2720
2627
|
async function mergedAddRemoveStakeEventsByStaker(chainEvents, range, staked, staker) {
|
|
@@ -2734,7 +2641,7 @@ async function activeStakeAtTimeByAddress(chain, staked, time, staker) {
|
|
|
2734
2641
|
for (const event of stakeEvents) {
|
|
2735
2642
|
if (event.time > time) break;
|
|
2736
2643
|
if (event.args.staked !== staked) continue;
|
|
2737
|
-
if (
|
|
2644
|
+
if (isDefined12(staker) && event.args.staker !== staker) continue;
|
|
2738
2645
|
if (event.name === "StakeAdded") {
|
|
2739
2646
|
result += event.args.amount;
|
|
2740
2647
|
} else if (event.name === "StakeRemoved") {
|
|
@@ -2745,7 +2652,7 @@ async function activeStakeAtTimeByAddress(chain, staked, time, staker) {
|
|
|
2745
2652
|
}
|
|
2746
2653
|
|
|
2747
2654
|
// src/primitives/stake/activeStakeAtTimeByPosition.ts
|
|
2748
|
-
import { isUndefined as
|
|
2655
|
+
import { isUndefined as isUndefined5 } from "@xylabs/sdk-js";
|
|
2749
2656
|
|
|
2750
2657
|
// src/primitives/stake/mergedAddRemoveStakeEventsByPosition.ts
|
|
2751
2658
|
async function mergedAddRemoveStakeEventsByPosition(chainEvents, range, position) {
|
|
@@ -2764,7 +2671,7 @@ async function activeStakeAtTimeByPosition(chainStakeEvents, externalTime, posit
|
|
|
2764
2671
|
let result = 0n;
|
|
2765
2672
|
for (const event of stakeEvents) {
|
|
2766
2673
|
if (event.time > externalTime) break;
|
|
2767
|
-
if (
|
|
2674
|
+
if (isUndefined5(position) || position === Number(event.args.id)) {
|
|
2768
2675
|
if (event.name === "StakeAdded") {
|
|
2769
2676
|
result += event.args.amount;
|
|
2770
2677
|
} else if (event.name === "StakeRemoved") {
|
|
@@ -2808,20 +2715,20 @@ async function allStakersForStep(context, blockViewer, stakeEventsViewer, stepCo
|
|
|
2808
2715
|
}
|
|
2809
2716
|
|
|
2810
2717
|
// src/primitives/stake/weightedStakeForRangeByPosition.ts
|
|
2811
|
-
import { isDefined as
|
|
2718
|
+
import { isDefined as isDefined13 } from "@xylabs/sdk-js";
|
|
2812
2719
|
import { asBlockNumber as asBlockNumber2 } from "@xyo-network/xl1-protocol-lib";
|
|
2813
2720
|
async function weightedStakeForRangeByPosition(context, blockViewer, stakeEventsViewer, externalRange, staked, positionId) {
|
|
2814
|
-
const cacheKey =
|
|
2721
|
+
const cacheKey = isDefined13(positionId) ? `${externalRange[0]}-${externalRange[1]}-${positionId}` : `${externalRange[0]}-${externalRange[1]}-all`;
|
|
2815
2722
|
return await withContextCacheResponse(context, "weightedStakeForRangeByPosition", cacheKey, async () => {
|
|
2816
2723
|
let weightedStakeSum = 0n;
|
|
2817
|
-
if (
|
|
2724
|
+
if (isDefined13(positionId)) {
|
|
2818
2725
|
const mergedEventsResult = await mergedAddRemoveStakeEventsByPosition(
|
|
2819
2726
|
stakeEventsViewer,
|
|
2820
2727
|
[0, externalRange[1]],
|
|
2821
2728
|
positionId
|
|
2822
2729
|
);
|
|
2823
2730
|
const mergedEvents = mergedEventsResult.toSorted((a, b) => a.time - b.time);
|
|
2824
|
-
if (
|
|
2731
|
+
if (isDefined13(staked) && mergedEvents.at(0)?.args.staked !== staked) {
|
|
2825
2732
|
return 0n;
|
|
2826
2733
|
}
|
|
2827
2734
|
let currentTime = externalRange[0];
|
|
@@ -3014,24 +2921,24 @@ function findUncles(context, finalizedWindowedChain, blocks) {
|
|
|
3014
2921
|
}
|
|
3015
2922
|
|
|
3016
2923
|
// src/config/Validation.ts
|
|
3017
|
-
var ValidationConfigZod =
|
|
3018
|
-
allowedRewardRedeemers:
|
|
2924
|
+
var ValidationConfigZod = z15.object({
|
|
2925
|
+
allowedRewardRedeemers: z15.array(XyoAddressZod2).optional().register(globalRegistry10, {
|
|
3019
2926
|
description: "List of allowed reward redeemer addresses, if undefined anyone can participate",
|
|
3020
2927
|
title: "allowedRewardRedeemers",
|
|
3021
2928
|
type: "array"
|
|
3022
2929
|
}),
|
|
3023
|
-
allowedRewardEscrowAccountSigners:
|
|
2930
|
+
allowedRewardEscrowAccountSigners: z15.array(XyoAddressZod2).optional().register(globalRegistry10, {
|
|
3024
2931
|
description: "List of allowed reward escrow account signer addresses, if undefined anyone can participate",
|
|
3025
2932
|
title: "allowedRewardEscrowAccountSigners",
|
|
3026
2933
|
type: "array"
|
|
3027
2934
|
}),
|
|
3028
|
-
minCandidates:
|
|
2935
|
+
minCandidates: z15.coerce.number().default(DEFAULT_MIN_CANDIDATES).register(globalRegistry10, {
|
|
3029
2936
|
default: DEFAULT_MIN_CANDIDATES,
|
|
3030
2937
|
description: "Minimum number of uncle candidates before selecting the best uncle",
|
|
3031
2938
|
title: "validation.minCandidates",
|
|
3032
2939
|
type: "number"
|
|
3033
2940
|
}),
|
|
3034
|
-
backoffMs:
|
|
2941
|
+
backoffMs: z15.coerce.number().default(DEFAULT_BACKOFF_MS).register(globalRegistry10, {
|
|
3035
2942
|
default: DEFAULT_BACKOFF_MS,
|
|
3036
2943
|
description: "Back-off timeout in ms. If head age exceeds this, minCandidates is ignored",
|
|
3037
2944
|
title: "validation.backoffMs",
|
|
@@ -3040,29 +2947,25 @@ var ValidationConfigZod = z18.object({
|
|
|
3040
2947
|
});
|
|
3041
2948
|
|
|
3042
2949
|
// src/config/Base.ts
|
|
3043
|
-
var BaseConfigZod =
|
|
3044
|
-
chain:
|
|
3045
|
-
dataLake:
|
|
3046
|
-
|
|
3047
|
-
|
|
3048
|
-
|
|
3049
|
-
|
|
3050
|
-
|
|
3051
|
-
|
|
3052
|
-
transports: z19._default(TransportsConfigZod, TransportsConfigZod.parse({})).check(z19.describe("Deprecated alias for connections (kept in sync during migration)")),
|
|
3053
|
-
storage: z19._default(StorageConfigZod, StorageConfigZod.parse({})).check(z19.describe("Configuration for the storage")),
|
|
3054
|
-
telemetry: z19._default(TelemetryConfigZod, TelemetryConfigZod.parse({})).check(z19.describe("Configuration for telemetry")),
|
|
3055
|
-
validation: z19._default(ValidationConfigZod, ValidationConfigZod.parse({})).check(z19.describe("Configuration for validation"))
|
|
2950
|
+
var BaseConfigZod = z16.object({
|
|
2951
|
+
chain: z16._default(ChainConfigZod, ChainConfigZod.parse({})).check(z16.describe("Configuration for the chain")),
|
|
2952
|
+
dataLake: z16.optional(DataLakeConfigZod).check(z16.describe("Configuration for data lakes")),
|
|
2953
|
+
log: z16._default(LogConfigZod, LogConfigZod.parse({})).check(z16.describe("Configuration for logging")),
|
|
2954
|
+
connections: z16._default(TransportsConfigZod, TransportsConfigZod.parse({})).check(z16.describe("Named connection profiles (rpc, rest, s3, lmdb, mongo, evm-rpc)")),
|
|
2955
|
+
providerBindings: z16._default(ProviderBindingsConfigZod, ProviderBindingsConfigZod.parse({})).check(z16.describe("Per-moniker provider connection bindings")),
|
|
2956
|
+
providers: z16._default(ProvidersConfigZod, ProvidersConfigZod.parse([])).check(z16.describe("Configuration for providers")),
|
|
2957
|
+
telemetry: z16._default(TelemetryConfigZod, TelemetryConfigZod.parse({})).check(z16.describe("Configuration for telemetry")),
|
|
2958
|
+
validation: z16._default(ValidationConfigZod, ValidationConfigZod.parse({})).check(z16.describe("Configuration for validation"))
|
|
3056
2959
|
});
|
|
3057
2960
|
|
|
3058
2961
|
// src/config/Actor.ts
|
|
3059
|
-
var AccountPathZod =
|
|
2962
|
+
var AccountPathZod = z17.string().check(z17.regex(
|
|
3060
2963
|
/^(m(\/\d+'?)+|\d+'?(\/\d+'?)*)$/,
|
|
3061
2964
|
`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".`
|
|
3062
2965
|
));
|
|
3063
|
-
var ActorConfigZod =
|
|
3064
|
-
name:
|
|
3065
|
-
accountPath:
|
|
2966
|
+
var ActorConfigZod = z17.extend(BaseConfigZod, {
|
|
2967
|
+
name: z17.string(),
|
|
2968
|
+
accountPath: z17.optional(AccountPathZod).register(globalRegistry11, {
|
|
3066
2969
|
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.',
|
|
3067
2970
|
title: "accountPath",
|
|
3068
2971
|
type: "string"
|
|
@@ -3073,25 +2976,22 @@ var asActorConfig = zodAsFactory3(ActorConfigZod, "asActorConfig");
|
|
|
3073
2976
|
var toActorConfig = zodToFactory2(ActorConfigZod, "toActorConfig");
|
|
3074
2977
|
|
|
3075
2978
|
// src/config/Actors.ts
|
|
3076
|
-
import { z as
|
|
3077
|
-
var ActorsConfigZod =
|
|
3078
|
-
|
|
2979
|
+
import { z as z18 } from "zod/mini";
|
|
2980
|
+
var ActorsConfigZod = z18._default(
|
|
2981
|
+
z18.array(z18.looseObject(ActorConfigZod.shape)).check(z18.describe("Actor-specific configurations that override the base configuration when the actor is running")),
|
|
3079
2982
|
[]
|
|
3080
2983
|
);
|
|
3081
2984
|
|
|
3082
|
-
// src/config/adaptLegacyConfig.ts
|
|
3083
|
-
import { isDefined as isDefined16 } from "@xylabs/sdk-js";
|
|
3084
|
-
|
|
3085
2985
|
// src/config/Config.ts
|
|
3086
|
-
import { globalRegistry as
|
|
3087
|
-
var ConfigZod =
|
|
2986
|
+
import { globalRegistry as globalRegistry12, z as z19 } from "zod/mini";
|
|
2987
|
+
var ConfigZod = z19.extend(BaseConfigZod, {
|
|
3088
2988
|
actors: ActorsConfigZod,
|
|
3089
|
-
healthCheckPort:
|
|
2989
|
+
healthCheckPort: z19.optional(z19.coerce.number()).register(globalRegistry12, {
|
|
3090
2990
|
description: "Port for the system-wide health, readiness, and liveness endpoints (/healthz, /livez, /readyz). Set to 0 to disable.",
|
|
3091
2991
|
title: "healthCheckPort",
|
|
3092
2992
|
type: "number"
|
|
3093
2993
|
})
|
|
3094
|
-
}).check(
|
|
2994
|
+
}).check(z19.describe("The complete configuration for the protocol, including global settings and actor-specific overrides"));
|
|
3095
2995
|
function resolveConfig(config) {
|
|
3096
2996
|
const parsedConfig = ConfigZod.parse(config);
|
|
3097
2997
|
const {
|
|
@@ -3100,108 +3000,38 @@ function resolveConfig(config) {
|
|
|
3100
3000
|
...rootConfig
|
|
3101
3001
|
} = parsedConfig;
|
|
3102
3002
|
parsedConfig.actors = actors.map((actorConfig) => {
|
|
3103
|
-
return
|
|
3003
|
+
return z19.looseObject(ActorConfigZod.shape).parse({ ...rootConfig, ...actorConfig });
|
|
3104
3004
|
});
|
|
3105
3005
|
return parsedConfig;
|
|
3106
3006
|
}
|
|
3107
3007
|
|
|
3108
|
-
// src/config/
|
|
3109
|
-
|
|
3110
|
-
|
|
3111
|
-
|
|
3112
|
-
|
|
3113
|
-
|
|
3114
|
-
|
|
3115
|
-
|
|
3116
|
-
|
|
3117
|
-
|
|
3118
|
-
|
|
3119
|
-
|
|
3120
|
-
|
|
3121
|
-
|
|
3122
|
-
|
|
3123
|
-
|
|
3124
|
-
|
|
3125
|
-
|
|
3126
|
-
|
|
3127
|
-
|
|
3128
|
-
|
|
3129
|
-
|
|
3130
|
-
|
|
3131
|
-
|
|
3132
|
-
|
|
3133
|
-
|
|
3134
|
-
|
|
3135
|
-
type: "s3",
|
|
3136
|
-
accessKeyId: entry?.accessKeyId ?? shared.accessKeyId,
|
|
3137
|
-
accountId: entry?.accountId ?? shared.accountId,
|
|
3138
|
-
bucket: entry?.bucket ?? fallbackBucket,
|
|
3139
|
-
prefix: entry?.prefix ?? shared.prefix,
|
|
3140
|
-
readUrl: entry?.readUrl,
|
|
3141
|
-
secretAccessKey: entry?.secretAccessKey ?? shared.secretAccessKey
|
|
3142
|
-
};
|
|
3143
|
-
}
|
|
3144
|
-
function synthesizeS3Transports(s3) {
|
|
3145
|
-
const shared = {
|
|
3146
|
-
accessKeyId: s3.accessKeyId,
|
|
3147
|
-
accountId: s3.accountId,
|
|
3148
|
-
prefix: s3.prefix,
|
|
3149
|
-
secretAccessKey: s3.secretAccessKey
|
|
3150
|
-
};
|
|
3151
|
-
const transports = {};
|
|
3152
|
-
const finalized = s3TransportFromBucket(shared, s3.finalized);
|
|
3153
|
-
const fallbackBucket = s3.finalized?.bucket;
|
|
3154
|
-
if (finalized) {
|
|
3155
|
-
transports[S3_FINALIZED_TRANSPORT] = finalized;
|
|
3156
|
-
}
|
|
3157
|
-
const chainState = s3TransportFromBucket(shared, s3.chainState, fallbackBucket);
|
|
3158
|
-
if (chainState) {
|
|
3159
|
-
transports[S3_CHAIN_STATE_TRANSPORT] = chainState;
|
|
3160
|
-
}
|
|
3161
|
-
const index = s3TransportFromBucket(shared, s3.index, fallbackBucket);
|
|
3162
|
-
if (index) {
|
|
3163
|
-
transports[S3_INDEX_TRANSPORT] = index;
|
|
3164
|
-
}
|
|
3165
|
-
return transports;
|
|
3166
|
-
}
|
|
3167
|
-
function hasTransport(transports, key) {
|
|
3168
|
-
return Object.hasOwn(transports, key) && transports[key] !== void 0;
|
|
3169
|
-
}
|
|
3170
|
-
function bindMoniker2(bindings, moniker, connectionName) {
|
|
3171
|
-
bindings[moniker] = { connection: connectionName, transport: connectionName };
|
|
3172
|
-
}
|
|
3173
|
-
var LMDB_MONIKERS = [
|
|
3174
|
-
"AccountBalanceViewer",
|
|
3175
|
-
"BlockRewardViewer",
|
|
3176
|
-
"BlockRunner",
|
|
3177
|
-
"BlockValidationViewer",
|
|
3178
|
-
"BlockViewer",
|
|
3179
|
-
"ChainContractViewer",
|
|
3180
|
-
"DeadLetterQueueRunner",
|
|
3181
|
-
"DeadLetterQueueViewer",
|
|
3182
|
-
"FinalizationRunner",
|
|
3183
|
-
"FinalizationViewer",
|
|
3184
|
-
"MempoolRunner",
|
|
3185
|
-
"MempoolViewer",
|
|
3186
|
-
"NetworkStakeViewer",
|
|
3187
|
-
"NetworkStakeStepRewardsByPositionViewer",
|
|
3188
|
-
"NetworkStakeStepRewardsByStakerViewer",
|
|
3189
|
-
"NetworkStakeStepRewardsByStepViewer",
|
|
3190
|
-
"NetworkStakeStepRewardsTotalViewer",
|
|
3191
|
-
"NetworkStakeStepRewardsViewer",
|
|
3192
|
-
"StakeEventsViewer",
|
|
3193
|
-
"StakeTotalsViewer",
|
|
3194
|
-
"StakeViewer",
|
|
3195
|
-
"StepViewer",
|
|
3196
|
-
"TimeSyncViewer",
|
|
3197
|
-
"TransactionValidationViewer",
|
|
3198
|
-
"TransactionViewer",
|
|
3199
|
-
"WindowedBlockViewer",
|
|
3200
|
-
"XyoConnection",
|
|
3201
|
-
"XyoGateway",
|
|
3202
|
-
"XyoRunner",
|
|
3203
|
-
"XyoViewer"
|
|
3204
|
-
];
|
|
3008
|
+
// src/config/HostActor.ts
|
|
3009
|
+
import {
|
|
3010
|
+
zodAsFactory as zodAsFactory4,
|
|
3011
|
+
zodIsFactory as zodIsFactory3,
|
|
3012
|
+
zodToFactory as zodToFactory3
|
|
3013
|
+
} from "@xylabs/sdk-js";
|
|
3014
|
+
import { globalRegistry as globalRegistry13, z as z20 } from "zod/mini";
|
|
3015
|
+
var HostActorConfigZod = z20.extend(ActorConfigZod, {
|
|
3016
|
+
host: z20._default(z20.string(), "localhost").register(globalRegistry13, {
|
|
3017
|
+
default: "localhost",
|
|
3018
|
+
description: "Host for the Actor",
|
|
3019
|
+
title: "host",
|
|
3020
|
+
type: "string"
|
|
3021
|
+
}),
|
|
3022
|
+
port: z20._default(z20.coerce.number(), 8080).register(globalRegistry13, {
|
|
3023
|
+
default: 8080,
|
|
3024
|
+
description: "Port for the Actor",
|
|
3025
|
+
title: "port",
|
|
3026
|
+
type: "number"
|
|
3027
|
+
})
|
|
3028
|
+
});
|
|
3029
|
+
var isHostActorConfig = zodIsFactory3(HostActorConfigZod);
|
|
3030
|
+
var asHostActorConfig = zodAsFactory4(HostActorConfigZod, "asHostActorConfig");
|
|
3031
|
+
var toHostActorConfig = zodToFactory3(HostActorConfigZod, "toHostActorConfig");
|
|
3032
|
+
|
|
3033
|
+
// src/config/synthesizeRpcConnectionBindings.ts
|
|
3034
|
+
var DEFAULT_RPC_CONNECTION = "default-rpc";
|
|
3205
3035
|
var RPC_MONIKERS = [
|
|
3206
3036
|
"AccountBalanceViewer",
|
|
3207
3037
|
"BlockRewardViewer",
|
|
@@ -3223,133 +3053,73 @@ var RPC_MONIKERS = [
|
|
|
3223
3053
|
"WindowedBlockViewer",
|
|
3224
3054
|
"XyoViewer"
|
|
3225
3055
|
];
|
|
3226
|
-
function
|
|
3056
|
+
function synthesizeRpcConnectionBindings() {
|
|
3227
3057
|
const bindings = {};
|
|
3228
|
-
|
|
3229
|
-
|
|
3230
|
-
}
|
|
3231
|
-
for (const moniker of LMDB_MONIKERS) {
|
|
3232
|
-
bindMoniker2(bindings, moniker, DEFAULT_LMDB_TRANSPORT);
|
|
3233
|
-
}
|
|
3234
|
-
return bindings;
|
|
3235
|
-
}
|
|
3236
|
-
function synthesizeProviderBindings(transports) {
|
|
3237
|
-
const bindings = {};
|
|
3238
|
-
if (hasTransport(transports, DEFAULT_RPC_TRANSPORT)) {
|
|
3239
|
-
for (const moniker of RPC_MONIKERS) {
|
|
3240
|
-
bindMoniker2(bindings, moniker, DEFAULT_RPC_TRANSPORT);
|
|
3241
|
-
}
|
|
3242
|
-
}
|
|
3243
|
-
if (hasTransport(transports, S3_FINALIZED_TRANSPORT)) {
|
|
3244
|
-
bindMoniker2(bindings, "BlockPublishRunner", S3_FINALIZED_TRANSPORT);
|
|
3245
|
-
}
|
|
3246
|
-
if (hasTransport(transports, S3_CHAIN_STATE_TRANSPORT)) {
|
|
3247
|
-
bindMoniker2(bindings, "ChainStateViewer", S3_CHAIN_STATE_TRANSPORT);
|
|
3248
|
-
bindMoniker2(bindings, "ChainStatePublishRunner", S3_CHAIN_STATE_TRANSPORT);
|
|
3249
|
-
}
|
|
3250
|
-
if (hasTransport(transports, S3_INDEX_TRANSPORT)) {
|
|
3251
|
-
bindMoniker2(bindings, "IndexPublishRunner", S3_INDEX_TRANSPORT);
|
|
3252
|
-
}
|
|
3253
|
-
if (hasTransport(transports, DEFAULT_EVM_RPC_TRANSPORT)) {
|
|
3254
|
-
bindMoniker2(bindings, "ChainContractViewer", DEFAULT_EVM_RPC_TRANSPORT);
|
|
3255
|
-
bindMoniker2(bindings, "StakeEventsViewer", DEFAULT_EVM_RPC_TRANSPORT);
|
|
3256
|
-
bindMoniker2(bindings, "StakeTotalsViewer", DEFAULT_EVM_RPC_TRANSPORT);
|
|
3257
|
-
bindMoniker2(bindings, "StakeViewer", DEFAULT_EVM_RPC_TRANSPORT);
|
|
3258
|
-
bindMoniker2(bindings, "TimeSyncViewer", DEFAULT_EVM_RPC_TRANSPORT);
|
|
3058
|
+
for (const moniker of RPC_MONIKERS) {
|
|
3059
|
+
bindings[moniker] = { connection: DEFAULT_RPC_CONNECTION, transport: DEFAULT_RPC_CONNECTION };
|
|
3259
3060
|
}
|
|
3260
3061
|
return bindings;
|
|
3261
3062
|
}
|
|
3262
|
-
function adaptLegacyConfig(config) {
|
|
3263
|
-
const parsed = ConfigZod.parse(config);
|
|
3264
|
-
if (hasDeclaredConnectionProfiles(parsed)) {
|
|
3265
|
-
return ConfigZod.parse(normalizeConnectionsConfig(parsed));
|
|
3266
|
-
}
|
|
3267
|
-
const transports = { ...parsed.transports, ...parsed.connections };
|
|
3268
|
-
if (isDefined16(parsed.storage?.root) && parsed.storage.root !== "") {
|
|
3269
|
-
transports[DEFAULT_LMDB_TRANSPORT] = { type: "lmdb", root: parsed.storage.root };
|
|
3270
|
-
}
|
|
3271
|
-
if (hasMongoConfig(parsed.storage?.mongo)) {
|
|
3272
|
-
transports["chain-mongo"] = {
|
|
3273
|
-
type: "mongo",
|
|
3274
|
-
connectionString: parsed.storage.mongo.connectionString,
|
|
3275
|
-
database: parsed.storage.mongo.database,
|
|
3276
|
-
domain: parsed.storage.mongo.domain,
|
|
3277
|
-
password: parsed.storage.mongo.password,
|
|
3278
|
-
username: parsed.storage.mongo.username
|
|
3279
|
-
};
|
|
3280
|
-
}
|
|
3281
|
-
if (isDefined16(parsed.remote?.rpc)) {
|
|
3282
|
-
transports[DEFAULT_RPC_TRANSPORT] = rpcTransportFromRemote(parsed.remote.rpc);
|
|
3283
|
-
}
|
|
3284
|
-
if (isDefined16(parsed.evm?.jsonRpc?.url)) {
|
|
3285
|
-
transports[DEFAULT_EVM_RPC_TRANSPORT] = { type: "evm-rpc", url: parsed.evm.jsonRpc.url };
|
|
3286
|
-
}
|
|
3287
|
-
if (isDefined16(parsed.storage?.s3)) {
|
|
3288
|
-
Object.assign(transports, synthesizeS3Transports(parsed.storage.s3));
|
|
3289
|
-
}
|
|
3290
|
-
const providerBindings = {
|
|
3291
|
-
...synthesizeLmdbProviderBindings(transports),
|
|
3292
|
-
...synthesizeProviderBindings(transports),
|
|
3293
|
-
...parsed.providerBindings
|
|
3294
|
-
};
|
|
3295
|
-
return ConfigZod.parse(normalizeConnectionsConfig({
|
|
3296
|
-
...parsed,
|
|
3297
|
-
connections: transports,
|
|
3298
|
-
providerBindings,
|
|
3299
|
-
transports
|
|
3300
|
-
}));
|
|
3301
|
-
}
|
|
3302
3063
|
|
|
3303
|
-
// src/config/
|
|
3304
|
-
import {
|
|
3305
|
-
|
|
3306
|
-
|
|
3307
|
-
|
|
3308
|
-
|
|
3309
|
-
|
|
3310
|
-
|
|
3311
|
-
|
|
3312
|
-
|
|
3313
|
-
description: "
|
|
3314
|
-
|
|
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",
|
|
3315
3089
|
type: "string"
|
|
3316
3090
|
}),
|
|
3317
|
-
|
|
3318
|
-
|
|
3319
|
-
|
|
3320
|
-
title: "port",
|
|
3321
|
-
type: "number"
|
|
3091
|
+
sessionId: z21.string().register(globalRegistry14, {
|
|
3092
|
+
description: "Session ID to use for the postMessage RPC connection",
|
|
3093
|
+
type: "string"
|
|
3322
3094
|
})
|
|
3323
|
-
});
|
|
3324
|
-
var
|
|
3325
|
-
var asHostActorConfig = zodAsFactory4(HostActorConfigZod, "asHostActorConfig");
|
|
3326
|
-
var toHostActorConfig = zodToFactory3(HostActorConfigZod, "toHostActorConfig");
|
|
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");
|
|
3327
3097
|
|
|
3328
3098
|
// src/config/UsageMeta.ts
|
|
3329
|
-
import { z as
|
|
3330
|
-
var DescriptionSchema =
|
|
3331
|
-
var TitleSchema =
|
|
3332
|
-
var JSONSchemaMetaSchema =
|
|
3333
|
-
id:
|
|
3099
|
+
import { z as z22 } from "zod";
|
|
3100
|
+
var DescriptionSchema = z22.string();
|
|
3101
|
+
var TitleSchema = z22.string();
|
|
3102
|
+
var JSONSchemaMetaSchema = z22.object({
|
|
3103
|
+
id: z22.string().optional(),
|
|
3334
3104
|
title: TitleSchema.optional(),
|
|
3335
3105
|
description: DescriptionSchema.optional(),
|
|
3336
|
-
deprecated:
|
|
3337
|
-
}).catchall(
|
|
3106
|
+
deprecated: z22.boolean().optional()
|
|
3107
|
+
}).catchall(z22.unknown());
|
|
3338
3108
|
var GlobalMetaSchema = JSONSchemaMetaSchema.extend({});
|
|
3339
|
-
var ChoicesSchema =
|
|
3109
|
+
var ChoicesSchema = z22.array(z22.union([z22.string(), z22.number(), z22.literal(true), z22.undefined()])).readonly();
|
|
3340
3110
|
var UsageMetaSchema = GlobalMetaSchema.extend({
|
|
3341
3111
|
choices: ChoicesSchema.optional(),
|
|
3342
|
-
default:
|
|
3112
|
+
default: z22.unknown().optional(),
|
|
3343
3113
|
description: DescriptionSchema,
|
|
3344
|
-
group:
|
|
3345
|
-
hidden:
|
|
3114
|
+
group: z22.string().optional(),
|
|
3115
|
+
hidden: z22.boolean().optional(),
|
|
3346
3116
|
title: TitleSchema,
|
|
3347
|
-
type:
|
|
3348
|
-
|
|
3349
|
-
|
|
3350
|
-
|
|
3351
|
-
|
|
3352
|
-
|
|
3117
|
+
type: z22.union([
|
|
3118
|
+
z22.literal("array"),
|
|
3119
|
+
z22.literal("count"),
|
|
3120
|
+
z22.literal("boolean"),
|
|
3121
|
+
z22.literal("number"),
|
|
3122
|
+
z22.literal("string")
|
|
3353
3123
|
])
|
|
3354
3124
|
});
|
|
3355
3125
|
function isUsageMeta(v) {
|
|
@@ -3362,7 +3132,7 @@ import {
|
|
|
3362
3132
|
zodIsFactory as zodIsFactory5,
|
|
3363
3133
|
zodToFactory as zodToFactory5
|
|
3364
3134
|
} from "@xylabs/sdk-js";
|
|
3365
|
-
import { z as
|
|
3135
|
+
import { z as z24 } from "zod/mini";
|
|
3366
3136
|
|
|
3367
3137
|
// src/model/CreatableProviderContext.zod.ts
|
|
3368
3138
|
import {
|
|
@@ -3371,17 +3141,17 @@ import {
|
|
|
3371
3141
|
zodToFactory as zodToFactory4
|
|
3372
3142
|
} from "@xylabs/sdk-js";
|
|
3373
3143
|
import { CachingContextZod } from "@xyo-network/xl1-protocol-lib";
|
|
3374
|
-
import { z as
|
|
3375
|
-
var RuntimeStatusMonitorZod =
|
|
3376
|
-
var ProviderFactoryLocatorZod =
|
|
3377
|
-
var BaseConfigContextZod =
|
|
3378
|
-
config:
|
|
3379
|
-
locator:
|
|
3144
|
+
import { z as z23 } from "zod/mini";
|
|
3145
|
+
var RuntimeStatusMonitorZod = z23.custom((val) => val !== null && val !== void 0 && typeof val === "object");
|
|
3146
|
+
var ProviderFactoryLocatorZod = z23.lazy(() => z23.custom((val) => val !== null && val !== void 0 && typeof val === "object" && "context" in val && "registry" in val));
|
|
3147
|
+
var BaseConfigContextZod = z23.extend(CachingContextZod, {
|
|
3148
|
+
config: z23.looseObject(BaseConfigZod.shape),
|
|
3149
|
+
locator: z23.optional(ProviderFactoryLocatorZod)
|
|
3380
3150
|
});
|
|
3381
|
-
var CreatableProviderContextZod =
|
|
3382
|
-
_id:
|
|
3151
|
+
var CreatableProviderContextZod = z23.lazy(() => z23.extend(BaseConfigContextZod, {
|
|
3152
|
+
_id: z23.optional(z23.string()),
|
|
3383
3153
|
locator: ProviderFactoryLocatorZod,
|
|
3384
|
-
statusReporter:
|
|
3154
|
+
statusReporter: z23.optional(RuntimeStatusMonitorZod)
|
|
3385
3155
|
}));
|
|
3386
3156
|
var isBaseConfigContext = zodIsFactory4(BaseConfigContextZod);
|
|
3387
3157
|
var asBaseConfigContext = zodAsFactory5(BaseConfigContextZod, "asBaseConfigContext");
|
|
@@ -3502,7 +3272,7 @@ async function buildUnsignedTransaction(chain, onChainPayloads, offChainPayloads
|
|
|
3502
3272
|
// src/transaction/confirmSubmittedTransaction.ts
|
|
3503
3273
|
import {
|
|
3504
3274
|
delay,
|
|
3505
|
-
isDefined as
|
|
3275
|
+
isDefined as isDefined14,
|
|
3506
3276
|
isNumber
|
|
3507
3277
|
} from "@xylabs/sdk-js";
|
|
3508
3278
|
var DEFAULT_CONFIRMATION_ATTEMPTS = 20;
|
|
@@ -3524,7 +3294,7 @@ var confirmSubmittedTransaction = async (viewer, txHash, options) => {
|
|
|
3524
3294
|
let attempts = 0;
|
|
3525
3295
|
while (true) {
|
|
3526
3296
|
const tx = await viewer.transaction.byHash(txHash) ?? void 0;
|
|
3527
|
-
if (
|
|
3297
|
+
if (isDefined14(tx)) {
|
|
3528
3298
|
options?.logger?.debug("Transaction confirmed", txHash);
|
|
3529
3299
|
return tx;
|
|
3530
3300
|
}
|
|
@@ -3835,11 +3605,23 @@ var bundle2 = (root, transaction) => {
|
|
|
3835
3605
|
};
|
|
3836
3606
|
|
|
3837
3607
|
// src/context/Actor.ts
|
|
3838
|
-
var ActorConfigContext =
|
|
3608
|
+
var ActorConfigContext = z24.extend(BaseConfigContextZod, { config: ActorConfigZod });
|
|
3839
3609
|
var isActorConfigContext = zodIsFactory5(ActorConfigContext);
|
|
3840
3610
|
var asActorConfigContext = zodAsFactory6(ActorConfigContext, "asActorConfigContext");
|
|
3841
3611
|
var toActorConfigContext = zodToFactory5(ActorConfigContext, "toActorConfigContext");
|
|
3842
3612
|
|
|
3613
|
+
// src/context/HostActor.ts
|
|
3614
|
+
import {
|
|
3615
|
+
zodAsFactory as zodAsFactory7,
|
|
3616
|
+
zodIsFactory as zodIsFactory6,
|
|
3617
|
+
zodToFactory as zodToFactory6
|
|
3618
|
+
} from "@xylabs/sdk-js";
|
|
3619
|
+
import { z as z25 } from "zod/mini";
|
|
3620
|
+
var HostActorConfigContext = z25.extend(BaseConfigContextZod, { config: HostActorConfigZod });
|
|
3621
|
+
var isHostActorConfigContext = zodIsFactory6(HostActorConfigContext);
|
|
3622
|
+
var asHostActorConfigContext = zodAsFactory7(HostActorConfigContext, "asHostActorConfigContext");
|
|
3623
|
+
var toHostActorConfigContext = zodToFactory6(HostActorConfigContext, "toHostActorConfigContext");
|
|
3624
|
+
|
|
3843
3625
|
// src/CreatableProvider/AbstractCreatableProvider.ts
|
|
3844
3626
|
import {
|
|
3845
3627
|
AbstractCreatable,
|
|
@@ -3921,42 +3703,14 @@ function labeledCreatableProvider() {
|
|
|
3921
3703
|
};
|
|
3922
3704
|
}
|
|
3923
3705
|
|
|
3924
|
-
// src/context/getEmptyProviderContext.ts
|
|
3925
|
-
function getEmptyProviderContext(config) {
|
|
3926
|
-
const singletons = {};
|
|
3927
|
-
const caches = {};
|
|
3928
|
-
const locator = new ProviderFactoryLocator({
|
|
3929
|
-
config,
|
|
3930
|
-
singletons,
|
|
3931
|
-
caches,
|
|
3932
|
-
logger: console
|
|
3933
|
-
});
|
|
3934
|
-
return locator.context;
|
|
3935
|
-
}
|
|
3936
|
-
function getEmptyContext(config) {
|
|
3937
|
-
return getEmptyProviderContext(config);
|
|
3938
|
-
}
|
|
3939
|
-
|
|
3940
|
-
// src/context/HostActor.ts
|
|
3941
|
-
import {
|
|
3942
|
-
zodAsFactory as zodAsFactory7,
|
|
3943
|
-
zodIsFactory as zodIsFactory6,
|
|
3944
|
-
zodToFactory as zodToFactory6
|
|
3945
|
-
} from "@xylabs/sdk-js";
|
|
3946
|
-
import { z as z27 } from "zod/mini";
|
|
3947
|
-
var HostActorConfigContext = z27.extend(BaseConfigContextZod, { config: HostActorConfigZod });
|
|
3948
|
-
var isHostActorConfigContext = zodIsFactory6(HostActorConfigContext);
|
|
3949
|
-
var asHostActorConfigContext = zodAsFactory7(HostActorConfigContext, "asHostActorConfigContext");
|
|
3950
|
-
var toHostActorConfigContext = zodToFactory6(HostActorConfigContext, "toHostActorConfigContext");
|
|
3951
|
-
|
|
3952
3706
|
// src/createDeclarationPayload.ts
|
|
3953
|
-
import { isDefined as
|
|
3707
|
+
import { isDefined as isDefined15 } from "@xylabs/sdk-js";
|
|
3954
3708
|
import { PayloadBuilder as PayloadBuilder13 } from "@xyo-network/sdk-js";
|
|
3955
3709
|
import {
|
|
3956
3710
|
ChainStakeIntentSchema
|
|
3957
3711
|
} from "@xyo-network/xl1-protocol-lib";
|
|
3958
3712
|
var createDeclarationIntent = (address, intent, nbf, exp) => {
|
|
3959
|
-
const expiration =
|
|
3713
|
+
const expiration = isDefined15(exp) ? exp : nbf + 1e4;
|
|
3960
3714
|
const payloadBuilder = new PayloadBuilder13({ schema: ChainStakeIntentSchema });
|
|
3961
3715
|
const builder = payloadBuilder.fields({
|
|
3962
3716
|
from: address,
|
|
@@ -3988,26 +3742,26 @@ import {
|
|
|
3988
3742
|
asSchema as asSchema2,
|
|
3989
3743
|
isPayloadOfZodType
|
|
3990
3744
|
} from "@xyo-network/sdk-js";
|
|
3991
|
-
import { z as
|
|
3745
|
+
import { z as z27 } from "zod";
|
|
3992
3746
|
|
|
3993
3747
|
// src/eip-712/Types.ts
|
|
3994
|
-
import { z as
|
|
3995
|
-
var TypedDataDomainZod =
|
|
3996
|
-
name:
|
|
3997
|
-
version:
|
|
3998
|
-
chainId:
|
|
3999
|
-
verifyingContract:
|
|
4000
|
-
salt:
|
|
3748
|
+
import { z as z26 } from "zod";
|
|
3749
|
+
var TypedDataDomainZod = z26.object({
|
|
3750
|
+
name: z26.string().nullable().optional(),
|
|
3751
|
+
version: z26.string().nullable().optional(),
|
|
3752
|
+
chainId: z26.union([z26.string(), z26.number(), z26.bigint()]).nullable().optional(),
|
|
3753
|
+
verifyingContract: z26.string().nullable().optional(),
|
|
3754
|
+
salt: z26.union([z26.string(), z26.instanceof(Uint8Array)]).nullable().optional()
|
|
4001
3755
|
});
|
|
4002
|
-
var TypedDataFieldZod =
|
|
4003
|
-
name:
|
|
4004
|
-
type:
|
|
3756
|
+
var TypedDataFieldZod = z26.object({
|
|
3757
|
+
name: z26.string(),
|
|
3758
|
+
type: z26.string()
|
|
4005
3759
|
});
|
|
4006
|
-
var TypedDataTypesZod =
|
|
4007
|
-
var TypedDataValueZod =
|
|
3760
|
+
var TypedDataTypesZod = z26.record(z26.string(), z26.array(TypedDataFieldZod));
|
|
3761
|
+
var TypedDataValueZod = z26.record(z26.string(), z26.any());
|
|
4008
3762
|
|
|
4009
3763
|
// src/eip-712/Payloads/EIP712Data.ts
|
|
4010
|
-
var EIP712DataPayloadFieldsZod =
|
|
3764
|
+
var EIP712DataPayloadFieldsZod = z27.object({
|
|
4011
3765
|
domain: TypedDataDomainZod,
|
|
4012
3766
|
types: TypedDataTypesZod,
|
|
4013
3767
|
values: TypedDataValueZod
|
|
@@ -4025,11 +3779,11 @@ import {
|
|
|
4025
3779
|
asSchema as asSchema3,
|
|
4026
3780
|
isPayloadOfZodType as isPayloadOfZodType2
|
|
4027
3781
|
} from "@xyo-network/sdk-js";
|
|
4028
|
-
import { z as
|
|
4029
|
-
var EIP712SignaturePayloadFieldsZod =
|
|
4030
|
-
address:
|
|
3782
|
+
import { z as z28 } from "zod";
|
|
3783
|
+
var EIP712SignaturePayloadFieldsZod = z28.object({
|
|
3784
|
+
address: z28.string(),
|
|
4031
3785
|
hash: HashZod,
|
|
4032
|
-
signature:
|
|
3786
|
+
signature: z28.string()
|
|
4033
3787
|
});
|
|
4034
3788
|
var EIP712SignaturePayloadSchema = asSchema3("network.xyo.chains.ethereum.eip712.signature", true);
|
|
4035
3789
|
var isEIP712SignaturePayload = isPayloadOfZodType2(
|
|
@@ -4058,7 +3812,7 @@ var signEIP712Message = async (signer, data) => {
|
|
|
4058
3812
|
};
|
|
4059
3813
|
|
|
4060
3814
|
// src/eip-712/verify.ts
|
|
4061
|
-
import { asHash as asHash3, isUndefined as
|
|
3815
|
+
import { asHash as asHash3, isUndefined as isUndefined6 } from "@xylabs/sdk-js";
|
|
4062
3816
|
import { PayloadBuilder as PayloadBuilder16 } from "@xyo-network/sdk-js";
|
|
4063
3817
|
import { verifyTypedData } from "ethers";
|
|
4064
3818
|
var verifyEIP712Message = async (data, sig) => {
|
|
@@ -4069,7 +3823,7 @@ var verifyEIP712Message = async (data, sig) => {
|
|
|
4069
3823
|
} = sig;
|
|
4070
3824
|
const { schema, ...fields } = data;
|
|
4071
3825
|
const signedHash = asHash3(hash);
|
|
4072
|
-
if (
|
|
3826
|
+
if (isUndefined6(signedHash) || signedHash !== await PayloadBuilder16.hash(data)) return false;
|
|
4073
3827
|
const recoveredAddress = verifyTypedData(fields.domain, fields.types, fields.values, signature);
|
|
4074
3828
|
return recoveredAddress.toLowerCase() === address.toLowerCase();
|
|
4075
3829
|
};
|
|
@@ -4140,7 +3894,7 @@ import {
|
|
|
4140
3894
|
asHash as asHash4,
|
|
4141
3895
|
assertEx as assertEx33,
|
|
4142
3896
|
exists as exists3,
|
|
4143
|
-
isDefined as
|
|
3897
|
+
isDefined as isDefined16,
|
|
4144
3898
|
ZERO_ADDRESS
|
|
4145
3899
|
} from "@xylabs/sdk-js";
|
|
4146
3900
|
import {
|
|
@@ -4639,7 +4393,7 @@ var SimpleAccountBalanceViewer = class extends AbstractCreatableProvider {
|
|
|
4639
4393
|
block[1].find((p) => p._hash === hash),
|
|
4640
4394
|
() => `Error: Could not find Transfer with hash ${hash} in block ${block[0]._hash}`
|
|
4641
4395
|
);
|
|
4642
|
-
}).filter(exists3).filter((t) => t.from === address ||
|
|
4396
|
+
}).filter(exists3).filter((t) => t.from === address || isDefined16(t.transfers[address]));
|
|
4643
4397
|
if (transfers.length === 0) {
|
|
4644
4398
|
continue;
|
|
4645
4399
|
}
|
|
@@ -4758,7 +4512,7 @@ var SimpleAccountBalanceViewer = class extends AbstractCreatableProvider {
|
|
|
4758
4512
|
return await this.spanAsync("qualifiedAccountBalanceHistory", async () => {
|
|
4759
4513
|
const range = asRange(headOrRange);
|
|
4760
4514
|
const headHash = asHash4(headOrRange);
|
|
4761
|
-
const [head] = assertEx33(
|
|
4515
|
+
const [head] = assertEx33(isDefined16(headHash) ? await this.blockViewer.blockByHash(headHash) : await this.blockViewer.currentBlock(), () => "Could not resolve head block");
|
|
4762
4516
|
const startingRange = asXL1BlockRange10(range ?? [0, head.block], true);
|
|
4763
4517
|
const blockNumbers = await this.distillTransferHistory(address, startingRange);
|
|
4764
4518
|
const blockResults = await Promise.all(blockNumbers.map(async (bn) => await this.blockViewer.blockByNumber(bn)));
|
|
@@ -4772,7 +4526,7 @@ var SimpleAccountBalanceViewer = class extends AbstractCreatableProvider {
|
|
|
4772
4526
|
block[1].find((p) => p._hash === hash),
|
|
4773
4527
|
() => `Error: Could not find Transfer with hash ${hash} in block ${block[0]._hash}`
|
|
4774
4528
|
);
|
|
4775
|
-
}).filter(exists3).filter((t) => t.from === address ||
|
|
4529
|
+
}).filter(exists3).filter((t) => t.from === address || isDefined16(t.transfers[address]));
|
|
4776
4530
|
if (transfers.length === 0) {
|
|
4777
4531
|
continue;
|
|
4778
4532
|
}
|
|
@@ -4802,7 +4556,7 @@ SimpleAccountBalanceViewer = __decorateClass([
|
|
|
4802
4556
|
import {
|
|
4803
4557
|
assertEx as assertEx34,
|
|
4804
4558
|
exists as exists4,
|
|
4805
|
-
isUndefined as
|
|
4559
|
+
isUndefined as isUndefined7
|
|
4806
4560
|
} from "@xylabs/sdk-js";
|
|
4807
4561
|
import { LruCacheMap as LruCacheMap2 } from "@xyo-network/xl1-driver-memory";
|
|
4808
4562
|
import {
|
|
@@ -4841,12 +4595,12 @@ var HydratedCache = class {
|
|
|
4841
4595
|
};
|
|
4842
4596
|
|
|
4843
4597
|
// src/utils/isZodError.ts
|
|
4844
|
-
import { z as
|
|
4598
|
+
import { z as z29 } from "zod";
|
|
4845
4599
|
var isZodError = (error) => {
|
|
4846
|
-
return error instanceof
|
|
4600
|
+
return error instanceof z29.ZodError;
|
|
4847
4601
|
};
|
|
4848
4602
|
var prettifyZodError = (error) => {
|
|
4849
|
-
return
|
|
4603
|
+
return z29.prettifyError(error);
|
|
4850
4604
|
};
|
|
4851
4605
|
|
|
4852
4606
|
// src/simple/block/SimpleBlockViewer.ts
|
|
@@ -4916,7 +4670,7 @@ var SimpleBlockViewer = class extends AbstractCreatableProvider {
|
|
|
4916
4670
|
async blockByNumber(blockNumber) {
|
|
4917
4671
|
return await this.spanAsync("blockByNumber", async () => {
|
|
4918
4672
|
const chainContext = await this.getChainContextRead();
|
|
4919
|
-
if (
|
|
4673
|
+
if (isUndefined7(chainContext.head)) {
|
|
4920
4674
|
return null;
|
|
4921
4675
|
}
|
|
4922
4676
|
return await this.blockByNumberWithContext(chainContext, blockNumber);
|
|
@@ -4942,7 +4696,7 @@ var SimpleBlockViewer = class extends AbstractCreatableProvider {
|
|
|
4942
4696
|
assertEx34(limit > 0, () => "limit must be greater than 0");
|
|
4943
4697
|
assertEx34(limit <= 100, () => "limit must be less than 100");
|
|
4944
4698
|
const chainContext = await this.getChainContextRead();
|
|
4945
|
-
if (
|
|
4699
|
+
if (isUndefined7(chainContext.head)) {
|
|
4946
4700
|
return [];
|
|
4947
4701
|
}
|
|
4948
4702
|
const blocks = [];
|
|
@@ -4965,7 +4719,7 @@ var SimpleBlockViewer = class extends AbstractCreatableProvider {
|
|
|
4965
4719
|
() => `blocksByStep does not support step levels above ${blocksMaxStep} (requested ${stepLevel})`
|
|
4966
4720
|
);
|
|
4967
4721
|
const chainContext = await this.getChainContextRead();
|
|
4968
|
-
if (
|
|
4722
|
+
if (isUndefined7(chainContext.head)) {
|
|
4969
4723
|
return [];
|
|
4970
4724
|
}
|
|
4971
4725
|
const start = stepIndex * size;
|
|
@@ -5341,7 +5095,7 @@ var SimpleXyoClient = class {
|
|
|
5341
5095
|
import { assertEx as assertEx37, exists as exists6 } from "@xylabs/sdk-js";
|
|
5342
5096
|
import { isAnyPayload as isAnyPayload8, PayloadZodLoose } from "@xyo-network/sdk-js";
|
|
5343
5097
|
import { DataLakeRunnerMoniker } from "@xyo-network/xl1-protocol-lib";
|
|
5344
|
-
import { z as
|
|
5098
|
+
import { z as z30 } from "zod/mini";
|
|
5345
5099
|
|
|
5346
5100
|
// src/simple/datalake/AbstractRestDataLake.ts
|
|
5347
5101
|
import { FetchClientError, FetchJsonClient } from "@xylabs/sdk-js";
|
|
@@ -5416,7 +5170,7 @@ var RestDataLakeRunner = class extends AbstractRestDataLake {
|
|
|
5416
5170
|
}).filter(exists6);
|
|
5417
5171
|
if (allowedItems.length > 0) {
|
|
5418
5172
|
const result = await this.client.post(`${this.params.endpoint}/insert`, allowedItems);
|
|
5419
|
-
return
|
|
5173
|
+
return z30.array(PayloadZodLoose).parse(result.data);
|
|
5420
5174
|
}
|
|
5421
5175
|
return [];
|
|
5422
5176
|
}
|
|
@@ -5693,7 +5447,7 @@ var SimpleXyoGateway = class _SimpleXyoGateway extends AbstractCreatableProvider
|
|
|
5693
5447
|
import {
|
|
5694
5448
|
assertEx as assertEx40,
|
|
5695
5449
|
BigIntToJsonZod,
|
|
5696
|
-
isDefined as
|
|
5450
|
+
isDefined as isDefined17
|
|
5697
5451
|
} from "@xylabs/sdk-js";
|
|
5698
5452
|
import { PayloadBuilder as PayloadBuilder20 } from "@xyo-network/sdk-js";
|
|
5699
5453
|
import {
|
|
@@ -5731,9 +5485,9 @@ var SimpleXyoGatewayRunner = class _SimpleXyoGatewayRunner extends AbstractCreat
|
|
|
5731
5485
|
chain,
|
|
5732
5486
|
fees
|
|
5733
5487
|
} = options ?? {};
|
|
5734
|
-
const resolvedChainId =
|
|
5735
|
-
const resolvedNbf = asXL1BlockNumber10(
|
|
5736
|
-
const resolvedExp = asXL1BlockNumber10(
|
|
5488
|
+
const resolvedChainId = isDefined17(chain) ? chain : await viewer.chainId();
|
|
5489
|
+
const resolvedNbf = asXL1BlockNumber10(isDefined17(nbf) ? nbf : await viewer.currentBlockNumber(), true);
|
|
5490
|
+
const resolvedExp = asXL1BlockNumber10(isDefined17(exp) ? exp : resolvedNbf + 10, true);
|
|
5737
5491
|
const tx = await buildUnsignedTransaction(resolvedChainId, onChain, offChain, resolvedNbf, resolvedExp, await this.signer.address(), fees);
|
|
5738
5492
|
return await this.addTransactionToChain(tx, await PayloadBuilder20.addHashMeta(offChain));
|
|
5739
5493
|
}
|
|
@@ -6231,7 +5985,7 @@ SimpleMempoolRunner = __decorateClass([
|
|
|
6231
5985
|
import {
|
|
6232
5986
|
assertEx as assertEx42,
|
|
6233
5987
|
exists as exists9,
|
|
6234
|
-
isDefined as
|
|
5988
|
+
isDefined as isDefined18,
|
|
6235
5989
|
isHash as isHash2
|
|
6236
5990
|
} from "@xylabs/sdk-js";
|
|
6237
5991
|
import { isHashMeta as isHashMeta2, isPayloadBundle as isPayloadBundle2 } from "@xyo-network/sdk-js";
|
|
@@ -6302,7 +6056,7 @@ var SimpleMempoolViewer = class extends AbstractCreatableProvider {
|
|
|
6302
6056
|
let cursor = void 0;
|
|
6303
6057
|
if (isHash2(providedCursor)) {
|
|
6304
6058
|
const [p] = await this.pendingBlocksArchivist.get([providedCursor]);
|
|
6305
|
-
if (
|
|
6059
|
+
if (isDefined18(p)) {
|
|
6306
6060
|
cursor = p._sequence;
|
|
6307
6061
|
}
|
|
6308
6062
|
}
|
|
@@ -6322,7 +6076,7 @@ var SimpleMempoolViewer = class extends AbstractCreatableProvider {
|
|
|
6322
6076
|
let cursor = void 0;
|
|
6323
6077
|
if (isHash2(providedCursor)) {
|
|
6324
6078
|
const [p] = await this.pendingTransactionsArchivist.get([providedCursor]);
|
|
6325
|
-
if (
|
|
6079
|
+
if (isDefined18(p)) {
|
|
6326
6080
|
cursor = p._sequence;
|
|
6327
6081
|
}
|
|
6328
6082
|
}
|
|
@@ -6395,7 +6149,7 @@ var SimpleMempoolViewer = class extends AbstractCreatableProvider {
|
|
|
6395
6149
|
const hydratedResults = await Promise.all(
|
|
6396
6150
|
filteredBundles.map(async (bundle3) => {
|
|
6397
6151
|
const tx = await bundledPayloadToHydratedTransaction(bundle3);
|
|
6398
|
-
return
|
|
6152
|
+
return isDefined18(tx) ? { bundle: bundle3, tx } : void 0;
|
|
6399
6153
|
})
|
|
6400
6154
|
);
|
|
6401
6155
|
return hydratedResults.filter(exists9);
|
|
@@ -6467,7 +6221,7 @@ function deduplicateWithBundleBySigner(items) {
|
|
|
6467
6221
|
}
|
|
6468
6222
|
|
|
6469
6223
|
// src/simple/network/SimpleXyoNetwork.ts
|
|
6470
|
-
import { fetchJsonGet, isUndefined as
|
|
6224
|
+
import { fetchJsonGet, isUndefined as isUndefined8 } from "@xylabs/sdk-js";
|
|
6471
6225
|
import { isNetworkStatus } from "@xyo-network/xl1-protocol-lib";
|
|
6472
6226
|
|
|
6473
6227
|
// src/simple/network/lib/FailedNetworkStatusPayloads.ts
|
|
@@ -6515,7 +6269,7 @@ var SimpleXyoNetwork = class {
|
|
|
6515
6269
|
}
|
|
6516
6270
|
async status() {
|
|
6517
6271
|
const statusNetwork = StatusNetworks[this._networkId];
|
|
6518
|
-
if (
|
|
6272
|
+
if (isUndefined8(statusNetwork)) {
|
|
6519
6273
|
throw new Error(`Unknown status network ID: ${this._networkId}`);
|
|
6520
6274
|
}
|
|
6521
6275
|
return await this.makeRequest(statusNetwork.statusUrl);
|
|
@@ -6701,7 +6455,7 @@ var SimpleXyoSigner = class _SimpleXyoSigner extends AbstractCreatableProvider {
|
|
|
6701
6455
|
};
|
|
6702
6456
|
|
|
6703
6457
|
// src/simple/StakeEventsViewer/SimpleStakeEventsViewer.ts
|
|
6704
|
-
import { isDefined as
|
|
6458
|
+
import { isDefined as isDefined19 } from "@xylabs/sdk-js";
|
|
6705
6459
|
import { StakeEventsViewerMoniker } from "@xyo-network/xl1-protocol-lib";
|
|
6706
6460
|
var SimpleStakeEventsViewer = class extends AbstractCreatableProvider {
|
|
6707
6461
|
moniker = SimpleStakeEventsViewer.defaultMoniker;
|
|
@@ -6714,7 +6468,7 @@ var SimpleStakeEventsViewer = class extends AbstractCreatableProvider {
|
|
|
6714
6468
|
stakeEvents(range, { name } = {}) {
|
|
6715
6469
|
const positions = this.positionsFromRange(range);
|
|
6716
6470
|
const events = this.eventsFromPositions(positions);
|
|
6717
|
-
if (
|
|
6471
|
+
if (isDefined19(name)) {
|
|
6718
6472
|
return events.filter((event) => event.name === name);
|
|
6719
6473
|
}
|
|
6720
6474
|
return events;
|
|
@@ -7068,7 +6822,7 @@ RestSyncViewer = __decorateClass([
|
|
|
7068
6822
|
import {
|
|
7069
6823
|
asHash as asHash5,
|
|
7070
6824
|
assertEx as assertEx47,
|
|
7071
|
-
isDefined as
|
|
6825
|
+
isDefined as isDefined20
|
|
7072
6826
|
} from "@xylabs/sdk-js";
|
|
7073
6827
|
import {
|
|
7074
6828
|
asTimePayload as asTimePayload2,
|
|
@@ -7092,7 +6846,7 @@ var SimpleTimeSyncViewer = class extends AbstractCreatableProvider {
|
|
|
7092
6846
|
const [block, payloads] = assertEx47(await this.blockViewer.blockByNumber(asXL1BlockNumber11(from, true)), () => "Block not found");
|
|
7093
6847
|
const timeSchemaIndex = block.payload_schemas.indexOf(TimeSchema);
|
|
7094
6848
|
const hash = timeSchemaIndex === -1 ? void 0 : block.payload_hashes[timeSchemaIndex];
|
|
7095
|
-
const timePayload = asTimePayload2(
|
|
6849
|
+
const timePayload = asTimePayload2(isDefined20(hash) ? payloads.find((p) => p._hash === hash) : void 0);
|
|
7096
6850
|
if (timePayload === void 0) return 0;
|
|
7097
6851
|
switch (toDomain) {
|
|
7098
6852
|
case "xl1": {
|
|
@@ -7166,7 +6920,7 @@ var SimpleTimeSyncViewer = class extends AbstractCreatableProvider {
|
|
|
7166
6920
|
xl1Hash: assertEx47(xl1Hash, () => "No xl1 hash available from time sync service"),
|
|
7167
6921
|
epoch: Date.now()
|
|
7168
6922
|
};
|
|
7169
|
-
if (
|
|
6923
|
+
if (isDefined20(this.ethProvider)) {
|
|
7170
6924
|
const [ethereum, ethHashOrNull] = await this.currentTimeAndHash("ethereum");
|
|
7171
6925
|
const ethereumHash = asHash5(ethHashOrNull, () => "No ethereum hash available from time sync service");
|
|
7172
6926
|
timePayload.ethereum = ethereum;
|
|
@@ -7670,7 +7424,7 @@ import {
|
|
|
7670
7424
|
} from "@xyo-network/xl1-protocol-lib";
|
|
7671
7425
|
|
|
7672
7426
|
// src/test/buildBlock.ts
|
|
7673
|
-
import { assertEx as assertEx51, isDefined as
|
|
7427
|
+
import { assertEx as assertEx51, isDefined as isDefined21 } from "@xylabs/sdk-js";
|
|
7674
7428
|
import {
|
|
7675
7429
|
asAnyPayload as asAnyPayload5,
|
|
7676
7430
|
BoundWitnessBuilder as BoundWitnessBuilder3,
|
|
@@ -7754,7 +7508,7 @@ function buildStepHashes(blockNumber, inStepHashes, previousBlockHash, chainStep
|
|
|
7754
7508
|
completedStepRewardTransfers.push(createTransferPayload(chainStepRewardAddress2, { [completedStepRewardHolderAddress]: completedStepReward }));
|
|
7755
7509
|
}
|
|
7756
7510
|
step_hashes.push(assertEx51(previousBlockHash, () => `Previous block hash is required for step ${step} at block ${blockNumber}`));
|
|
7757
|
-
} else if (
|
|
7511
|
+
} else if (isDefined21(inStepHashes.at(i))) {
|
|
7758
7512
|
step_hashes.push(inStepHashes[i]);
|
|
7759
7513
|
}
|
|
7760
7514
|
}
|
|
@@ -8056,8 +7810,8 @@ var getUrl = (host, port) => {
|
|
|
8056
7810
|
var TODO = true;
|
|
8057
7811
|
|
|
8058
7812
|
// src/validation/schema/Mnemonic.ts
|
|
8059
|
-
import { z as
|
|
8060
|
-
var MnemonicStringZod =
|
|
7813
|
+
import { z as z31 } from "zod";
|
|
7814
|
+
var MnemonicStringZod = z31.string().transform((s) => s.trim().replaceAll(/\s+/g, " ")).refine(
|
|
8061
7815
|
(s) => [12, 15, 18, 21, 24].includes(s.split(" ").length),
|
|
8062
7816
|
{ message: "Mnemonic must contain 12, 15, 18, 21, or 24 words." }
|
|
8063
7817
|
).describe("BIP-39 mnemonic string");
|
|
@@ -8134,6 +7888,7 @@ export {
|
|
|
8134
7888
|
MemoryTransportConfigZod,
|
|
8135
7889
|
MissingCapabilityError,
|
|
8136
7890
|
MnemonicStringZod,
|
|
7891
|
+
MongoConfigZod,
|
|
8137
7892
|
MongoTransportConfigZod as MongoConnectionConfigZod,
|
|
8138
7893
|
MongoTransportConfigZod,
|
|
8139
7894
|
PENDING_BLOCKS_ARCHIVIST_ROLE,
|
|
@@ -8150,7 +7905,6 @@ export {
|
|
|
8150
7905
|
ProvidersConfigZod,
|
|
8151
7906
|
REJECTED_BLOCKS_ARCHIVIST_ROLE,
|
|
8152
7907
|
REJECTED_TRANSACTIONS_ARCHIVIST_ROLE,
|
|
8153
|
-
RemoteConfigZod,
|
|
8154
7908
|
RestTransportConfigZod as RestConnectionConfigZod,
|
|
8155
7909
|
RestDataLakeConfigZod,
|
|
8156
7910
|
RestDataLakeRunner,
|
|
@@ -8165,6 +7919,7 @@ export {
|
|
|
8165
7919
|
RpcTransportConfigZod,
|
|
8166
7920
|
RuntimeStatusMonitor,
|
|
8167
7921
|
RuntimeStatusMonitorZod,
|
|
7922
|
+
S3BucketConfigZod,
|
|
8168
7923
|
S3TransportConfigZod as S3ConnectionConfigZod,
|
|
8169
7924
|
S3TransportConfigZod,
|
|
8170
7925
|
SchemasStepSummarySchema,
|
|
@@ -8217,7 +7972,6 @@ export {
|
|
|
8217
7972
|
XL1_NETWORK_STAKING_GENESIS_PERIOD_TOTAL_REWARDS,
|
|
8218
7973
|
activeStakeAtTimeByAddress,
|
|
8219
7974
|
activeStakeAtTimeByPosition,
|
|
8220
|
-
adaptLegacyConfig,
|
|
8221
7975
|
addDataLakePayloads,
|
|
8222
7976
|
addDataLakePayloadsToPayloads,
|
|
8223
7977
|
allHashesPresent,
|
|
@@ -8299,8 +8053,6 @@ export {
|
|
|
8299
8053
|
generateXyoBaseWalletFromPhrase,
|
|
8300
8054
|
getArchivistFactory,
|
|
8301
8055
|
getBlockRateBlocks,
|
|
8302
|
-
getEmptyContext,
|
|
8303
|
-
getEmptyProviderContext,
|
|
8304
8056
|
getProducerKey,
|
|
8305
8057
|
getTestProviderContext2 as getTestProviderContext,
|
|
8306
8058
|
getTestSimpleBlockViewerLocator,
|
|
@@ -8309,8 +8061,6 @@ export {
|
|
|
8309
8061
|
getWindowedChain,
|
|
8310
8062
|
hasDeclaredConnectionProfiles,
|
|
8311
8063
|
hasLabels,
|
|
8312
|
-
hasMongoConfig,
|
|
8313
|
-
hasS3Config,
|
|
8314
8064
|
hashFromBlockNumber,
|
|
8315
8065
|
hydrateBlock,
|
|
8316
8066
|
hydrateElevatedTransaction,
|
|
@@ -8374,7 +8124,6 @@ export {
|
|
|
8374
8124
|
resolveConfig,
|
|
8375
8125
|
resolveProviders,
|
|
8376
8126
|
resolveProvidersFromConfig,
|
|
8377
|
-
resolveS3Bucket,
|
|
8378
8127
|
rewardFromBlockNumber,
|
|
8379
8128
|
schemasMaxStep,
|
|
8380
8129
|
schemasStepSummaryFromRange,
|
|
@@ -8393,6 +8142,7 @@ export {
|
|
|
8393
8142
|
stepsRewardTotalGenesisPeriod,
|
|
8394
8143
|
stepsRewardTotalRange,
|
|
8395
8144
|
surfaceForBranch,
|
|
8145
|
+
synthesizeRpcConnectionBindings,
|
|
8396
8146
|
timeDurations,
|
|
8397
8147
|
toActorConfig,
|
|
8398
8148
|
toActorConfigContext,
|