@xyo-network/xl1-protocol-sdk 3.0.10 → 3.0.11
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 +0 -1
- package/dist/neutral/CreatableProvider/AbstractCreatableProvider.d.ts.map +1 -1
- package/dist/neutral/config/Actor.d.ts +0 -6
- package/dist/neutral/config/Actor.d.ts.map +1 -1
- package/dist/neutral/config/Actors.d.ts +0 -1
- package/dist/neutral/config/Actors.d.ts.map +1 -1
- package/dist/neutral/config/Base.d.ts +0 -1
- package/dist/neutral/config/Base.d.ts.map +1 -1
- package/dist/neutral/config/Config.d.ts +0 -4
- package/dist/neutral/config/Config.d.ts.map +1 -1
- package/dist/neutral/config/HostActor.d.ts +0 -6
- package/dist/neutral/config/HostActor.d.ts.map +1 -1
- package/dist/neutral/config/index.d.ts +1 -1
- package/dist/neutral/config/index.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 -6
- package/dist/neutral/context/Actor.d.ts.map +1 -1
- package/dist/neutral/context/HostActor.d.ts +0 -6
- package/dist/neutral/context/HostActor.d.ts.map +1 -1
- package/dist/neutral/getFileConfig.d.ts +0 -2
- package/dist/neutral/getFileConfig.d.ts.map +1 -1
- package/dist/neutral/getFileConfig.mjs +52 -96
- package/dist/neutral/getFileConfig.mjs.map +4 -4
- package/dist/neutral/index.mjs +302 -311
- package/dist/neutral/index.mjs.map +4 -4
- package/dist/neutral/model/CreatableProviderContext.zod.d.ts +0 -6
- 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 +50 -94
- 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/index.mjs
CHANGED
|
@@ -1707,10 +1707,10 @@ import {
|
|
|
1707
1707
|
zodIsFactory as zodIsFactory2,
|
|
1708
1708
|
zodToFactory as zodToFactory2
|
|
1709
1709
|
} from "@xylabs/sdk-js";
|
|
1710
|
-
import { globalRegistry as
|
|
1710
|
+
import { globalRegistry as globalRegistry8, z as z13 } from "zod/mini";
|
|
1711
1711
|
|
|
1712
1712
|
// src/config/Base.ts
|
|
1713
|
-
import { z as
|
|
1713
|
+
import { z as z12 } from "zod/mini";
|
|
1714
1714
|
|
|
1715
1715
|
// src/config/Chain.ts
|
|
1716
1716
|
import { HexZod } from "@xylabs/sdk-js";
|
|
@@ -1863,62 +1863,19 @@ var TransportConfigZod = z5.discriminatedUnion("type", [
|
|
|
1863
1863
|
]);
|
|
1864
1864
|
var TransportsConfigZod = z5.record(z5.string(), TransportConfigZod).default({});
|
|
1865
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";
|
|
1871
|
-
|
|
1872
|
-
// src/config/DataLake/DataLakeRemoteConfig.ts
|
|
1873
|
-
import { globalRegistry as globalRegistry4, z as z6 } from "zod";
|
|
1874
|
-
var DataLakeDriverConfigBaseZod = z6.object({
|
|
1875
|
-
driver: z6.string().register(globalRegistry4, {
|
|
1876
|
-
description: "Driver for the data lake",
|
|
1877
|
-
type: "string"
|
|
1878
|
-
})
|
|
1879
|
-
}).describe("Base configuration for a data lake driver");
|
|
1880
|
-
|
|
1881
|
-
// src/config/DataLake/RestDataLakeConfig.ts
|
|
1882
|
-
var RestDataLakeConfigZod = DataLakeDriverConfigBaseZod.extend({
|
|
1883
|
-
driver: z7.literal("rest").register(globalRegistry5, {
|
|
1884
|
-
description: "Driver for the REST data lake",
|
|
1885
|
-
type: "string"
|
|
1886
|
-
}),
|
|
1887
|
-
url: z7.string().register(globalRegistry5, {
|
|
1888
|
-
description: "URL for the REST data lake",
|
|
1889
|
-
type: "string"
|
|
1890
|
-
})
|
|
1891
|
-
}).describe("Configuration for the REST data lake driver");
|
|
1892
|
-
|
|
1893
|
-
// src/config/DataLake/RouterDataLakeConfig.ts
|
|
1894
|
-
import { globalRegistry as globalRegistry6, z as z8 } from "zod";
|
|
1895
|
-
var RouterDataLakeConfigZod = z8.object({
|
|
1896
|
-
driver: z8.literal("router").register(globalRegistry6, {
|
|
1897
|
-
description: "Driver for the router data lake",
|
|
1898
|
-
type: "string"
|
|
1899
|
-
}),
|
|
1900
|
-
children: z8.array(z8.lazy(() => DataLakeConfigZod)).register(globalRegistry6, {
|
|
1901
|
-
description: "Child data lake drivers",
|
|
1902
|
-
type: "array"
|
|
1903
|
-
})
|
|
1904
|
-
}).describe("Configuration for the router data lake driver");
|
|
1905
|
-
|
|
1906
|
-
// src/config/DataLake/DataLake.ts
|
|
1907
|
-
var DataLakeConfigZod = z9.lazy(() => z9.union([RestDataLakeConfigZod, RouterDataLakeConfigZod])).describe("Configuration for a data lake");
|
|
1908
|
-
|
|
1909
1866
|
// src/config/Log.ts
|
|
1910
1867
|
import { LogLevel } from "@xylabs/sdk-js";
|
|
1911
|
-
import { globalRegistry as
|
|
1868
|
+
import { globalRegistry as globalRegistry4, z as z6 } from "zod";
|
|
1912
1869
|
var LogLevelNames = Object.keys(LogLevel);
|
|
1913
|
-
var LogConfigZod =
|
|
1914
|
-
logLevel:
|
|
1870
|
+
var LogConfigZod = z6.object({
|
|
1871
|
+
logLevel: z6.enum(LogLevelNames).default("info").register(globalRegistry4, {
|
|
1915
1872
|
choices: LogLevelNames,
|
|
1916
1873
|
default: "info",
|
|
1917
1874
|
description: "Desired process verbosity",
|
|
1918
1875
|
title: "logLevel",
|
|
1919
1876
|
type: "string"
|
|
1920
1877
|
}),
|
|
1921
|
-
silent:
|
|
1878
|
+
silent: z6.boolean().default(false).register(globalRegistry4, {
|
|
1922
1879
|
default: false,
|
|
1923
1880
|
description: "Whether to run in silent mode",
|
|
1924
1881
|
title: "silent",
|
|
@@ -1927,23 +1884,23 @@ var LogConfigZod = z10.object({
|
|
|
1927
1884
|
});
|
|
1928
1885
|
|
|
1929
1886
|
// src/config/ProviderBinding.ts
|
|
1930
|
-
import { globalRegistry as
|
|
1931
|
-
var ProviderBindingConfigZod =
|
|
1932
|
-
connection:
|
|
1887
|
+
import { globalRegistry as globalRegistry5, z as z7 } from "zod";
|
|
1888
|
+
var ProviderBindingConfigZod = z7.object({
|
|
1889
|
+
connection: z7.string().optional().register(globalRegistry5, {
|
|
1933
1890
|
description: "Named connection from the top-level connections map",
|
|
1934
1891
|
title: "providerBindings.connection",
|
|
1935
1892
|
type: "string"
|
|
1936
1893
|
}),
|
|
1937
|
-
transport:
|
|
1894
|
+
transport: z7.string().optional().register(globalRegistry5, {
|
|
1938
1895
|
description: "Deprecated alias for connection (kept in sync during migration)",
|
|
1939
1896
|
title: "providerBindings.transport",
|
|
1940
1897
|
type: "string"
|
|
1941
1898
|
})
|
|
1942
1899
|
}).describe("Provider connection binding");
|
|
1943
|
-
var ProviderBindingsConfigZod =
|
|
1900
|
+
var ProviderBindingsConfigZod = z7.record(z7.string(), ProviderBindingConfigZod).default({});
|
|
1944
1901
|
|
|
1945
1902
|
// src/config/Providers.ts
|
|
1946
|
-
import
|
|
1903
|
+
import z9 from "zod";
|
|
1947
1904
|
|
|
1948
1905
|
// src/config/Provider.ts
|
|
1949
1906
|
import {
|
|
@@ -1951,20 +1908,20 @@ import {
|
|
|
1951
1908
|
zodIsFactory,
|
|
1952
1909
|
zodToFactory
|
|
1953
1910
|
} from "@xylabs/sdk-js";
|
|
1954
|
-
import { z as
|
|
1955
|
-
var ProviderConfigZod =
|
|
1956
|
-
moniker:
|
|
1957
|
-
labels:
|
|
1911
|
+
import { z as z8 } from "zod";
|
|
1912
|
+
var ProviderConfigZod = z8.object({
|
|
1913
|
+
moniker: z8.string(),
|
|
1914
|
+
labels: z8.array(z8.string()).optional()
|
|
1958
1915
|
}).describe("Configuration for a Provider");
|
|
1959
1916
|
var isProviderConfig = zodIsFactory(ProviderConfigZod);
|
|
1960
1917
|
var asProviderConfig = zodAsFactory2(ProviderConfigZod, "asProviderConfig");
|
|
1961
1918
|
var toProviderConfig = zodToFactory(ProviderConfigZod, "toProviderConfig");
|
|
1962
1919
|
|
|
1963
1920
|
// src/config/Providers.ts
|
|
1964
|
-
var ProvidersConfigZod =
|
|
1921
|
+
var ProvidersConfigZod = z9.array(ProviderConfigZod.loose()).describe("Configuration for providers").default([]);
|
|
1965
1922
|
|
|
1966
1923
|
// src/config/Telemetry.ts
|
|
1967
|
-
import { globalRegistry as
|
|
1924
|
+
import { globalRegistry as globalRegistry6, z as z10 } from "zod";
|
|
1968
1925
|
var DefaultMetricsScrapePorts = {
|
|
1969
1926
|
api: 9465,
|
|
1970
1927
|
bridge: 9468,
|
|
@@ -1972,29 +1929,29 @@ var DefaultMetricsScrapePorts = {
|
|
|
1972
1929
|
producer: 9464,
|
|
1973
1930
|
rewardRedemptionApi: 9467
|
|
1974
1931
|
};
|
|
1975
|
-
var MetricsScrapeConfigZod =
|
|
1976
|
-
path:
|
|
1932
|
+
var MetricsScrapeConfigZod = z10.object({
|
|
1933
|
+
path: z10.string().default("/metrics").register(globalRegistry6, {
|
|
1977
1934
|
default: "/metrics",
|
|
1978
1935
|
description: "Path for the metrics scrape endpoint",
|
|
1979
1936
|
title: "telemetry.metrics.scrape.path",
|
|
1980
1937
|
type: "string"
|
|
1981
1938
|
}),
|
|
1982
|
-
port:
|
|
1939
|
+
port: z10.coerce.number().int().nonnegative().optional().register(globalRegistry6, {
|
|
1983
1940
|
description: "Port for the metrics scrape endpoint (0 disables the scrape endpoint)",
|
|
1984
1941
|
title: "telemetry.metrics.scrape.port",
|
|
1985
1942
|
type: "number"
|
|
1986
1943
|
})
|
|
1987
1944
|
}).describe("Metrics scrape configuration");
|
|
1988
|
-
var MetricsConfigZod =
|
|
1989
|
-
var OpenTelemetryConfigZod =
|
|
1945
|
+
var MetricsConfigZod = z10.object({ scrape: MetricsScrapeConfigZod }).describe("Metrics configuration options");
|
|
1946
|
+
var OpenTelemetryConfigZod = z10.object({
|
|
1990
1947
|
// OpenTelemetry options
|
|
1991
|
-
otlpEndpoint:
|
|
1948
|
+
otlpEndpoint: z10.url().optional().register(globalRegistry6, {
|
|
1992
1949
|
description: "OTLP endpoint for exporting telemetry data",
|
|
1993
1950
|
title: "telemetry.otel.otlpEndpoint",
|
|
1994
1951
|
type: "string"
|
|
1995
1952
|
})
|
|
1996
1953
|
});
|
|
1997
|
-
var TelemetryConfigZod =
|
|
1954
|
+
var TelemetryConfigZod = z10.object({
|
|
1998
1955
|
// Metrics configuration
|
|
1999
1956
|
metrics: MetricsConfigZod.optional().describe("Metrics configuration"),
|
|
2000
1957
|
// OpenTelemetry configuration
|
|
@@ -2003,7 +1960,7 @@ var TelemetryConfigZod = z14.object({
|
|
|
2003
1960
|
|
|
2004
1961
|
// src/config/Validation.ts
|
|
2005
1962
|
import { XyoAddressZod as XyoAddressZod2 } from "@xyo-network/sdk-js";
|
|
2006
|
-
import { globalRegistry as
|
|
1963
|
+
import { globalRegistry as globalRegistry7, z as z11 } from "zod";
|
|
2007
1964
|
|
|
2008
1965
|
// src/primitives/block/range/blockRangeSteps.ts
|
|
2009
1966
|
import { asXL1BlockNumber as asXL1BlockNumber2, StepSizes as StepSizes3 } from "@xyo-network/xl1-protocol-lib";
|
|
@@ -2921,24 +2878,24 @@ function findUncles(context, finalizedWindowedChain, blocks) {
|
|
|
2921
2878
|
}
|
|
2922
2879
|
|
|
2923
2880
|
// src/config/Validation.ts
|
|
2924
|
-
var ValidationConfigZod =
|
|
2925
|
-
allowedRewardRedeemers:
|
|
2881
|
+
var ValidationConfigZod = z11.object({
|
|
2882
|
+
allowedRewardRedeemers: z11.array(XyoAddressZod2).optional().register(globalRegistry7, {
|
|
2926
2883
|
description: "List of allowed reward redeemer addresses, if undefined anyone can participate",
|
|
2927
2884
|
title: "allowedRewardRedeemers",
|
|
2928
2885
|
type: "array"
|
|
2929
2886
|
}),
|
|
2930
|
-
allowedRewardEscrowAccountSigners:
|
|
2887
|
+
allowedRewardEscrowAccountSigners: z11.array(XyoAddressZod2).optional().register(globalRegistry7, {
|
|
2931
2888
|
description: "List of allowed reward escrow account signer addresses, if undefined anyone can participate",
|
|
2932
2889
|
title: "allowedRewardEscrowAccountSigners",
|
|
2933
2890
|
type: "array"
|
|
2934
2891
|
}),
|
|
2935
|
-
minCandidates:
|
|
2892
|
+
minCandidates: z11.coerce.number().default(DEFAULT_MIN_CANDIDATES).register(globalRegistry7, {
|
|
2936
2893
|
default: DEFAULT_MIN_CANDIDATES,
|
|
2937
2894
|
description: "Minimum number of uncle candidates before selecting the best uncle",
|
|
2938
2895
|
title: "validation.minCandidates",
|
|
2939
2896
|
type: "number"
|
|
2940
2897
|
}),
|
|
2941
|
-
backoffMs:
|
|
2898
|
+
backoffMs: z11.coerce.number().default(DEFAULT_BACKOFF_MS).register(globalRegistry7, {
|
|
2942
2899
|
default: DEFAULT_BACKOFF_MS,
|
|
2943
2900
|
description: "Back-off timeout in ms. If head age exceeds this, minCandidates is ignored",
|
|
2944
2901
|
title: "validation.backoffMs",
|
|
@@ -2947,25 +2904,24 @@ var ValidationConfigZod = z15.object({
|
|
|
2947
2904
|
});
|
|
2948
2905
|
|
|
2949
2906
|
// 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"))
|
|
2907
|
+
var BaseConfigZod = z12.object({
|
|
2908
|
+
chain: z12._default(ChainConfigZod, ChainConfigZod.parse({})).check(z12.describe("Configuration for the chain")),
|
|
2909
|
+
log: z12._default(LogConfigZod, LogConfigZod.parse({})).check(z12.describe("Configuration for logging")),
|
|
2910
|
+
connections: z12._default(TransportsConfigZod, TransportsConfigZod.parse({})).check(z12.describe("Named connection profiles (rpc, rest, s3, lmdb, mongo, evm-rpc)")),
|
|
2911
|
+
providerBindings: z12._default(ProviderBindingsConfigZod, ProviderBindingsConfigZod.parse({})).check(z12.describe("Per-moniker provider connection bindings")),
|
|
2912
|
+
providers: z12._default(ProvidersConfigZod, ProvidersConfigZod.parse([])).check(z12.describe("Configuration for providers")),
|
|
2913
|
+
telemetry: z12._default(TelemetryConfigZod, TelemetryConfigZod.parse({})).check(z12.describe("Configuration for telemetry")),
|
|
2914
|
+
validation: z12._default(ValidationConfigZod, ValidationConfigZod.parse({})).check(z12.describe("Configuration for validation"))
|
|
2959
2915
|
});
|
|
2960
2916
|
|
|
2961
2917
|
// src/config/Actor.ts
|
|
2962
|
-
var AccountPathZod =
|
|
2918
|
+
var AccountPathZod = z13.string().check(z13.regex(
|
|
2963
2919
|
/^(m(\/\d+'?)+|\d+'?(\/\d+'?)*)$/,
|
|
2964
2920
|
`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
2921
|
));
|
|
2966
|
-
var ActorConfigZod =
|
|
2967
|
-
name:
|
|
2968
|
-
accountPath:
|
|
2922
|
+
var ActorConfigZod = z13.extend(BaseConfigZod, {
|
|
2923
|
+
name: z13.string(),
|
|
2924
|
+
accountPath: z13.optional(AccountPathZod).register(globalRegistry8, {
|
|
2969
2925
|
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
2926
|
title: "accountPath",
|
|
2971
2927
|
type: "string"
|
|
@@ -2976,22 +2932,22 @@ var asActorConfig = zodAsFactory3(ActorConfigZod, "asActorConfig");
|
|
|
2976
2932
|
var toActorConfig = zodToFactory2(ActorConfigZod, "toActorConfig");
|
|
2977
2933
|
|
|
2978
2934
|
// src/config/Actors.ts
|
|
2979
|
-
import { z as
|
|
2980
|
-
var ActorsConfigZod =
|
|
2981
|
-
|
|
2935
|
+
import { z as z14 } from "zod/mini";
|
|
2936
|
+
var ActorsConfigZod = z14._default(
|
|
2937
|
+
z14.array(z14.looseObject(ActorConfigZod.shape)).check(z14.describe("Actor-specific configurations that override the base configuration when the actor is running")),
|
|
2982
2938
|
[]
|
|
2983
2939
|
);
|
|
2984
2940
|
|
|
2985
2941
|
// src/config/Config.ts
|
|
2986
|
-
import { globalRegistry as
|
|
2987
|
-
var ConfigZod =
|
|
2942
|
+
import { globalRegistry as globalRegistry9, z as z15 } from "zod/mini";
|
|
2943
|
+
var ConfigZod = z15.extend(BaseConfigZod, {
|
|
2988
2944
|
actors: ActorsConfigZod,
|
|
2989
|
-
healthCheckPort:
|
|
2945
|
+
healthCheckPort: z15.optional(z15.coerce.number()).register(globalRegistry9, {
|
|
2990
2946
|
description: "Port for the system-wide health, readiness, and liveness endpoints (/healthz, /livez, /readyz). Set to 0 to disable.",
|
|
2991
2947
|
title: "healthCheckPort",
|
|
2992
2948
|
type: "number"
|
|
2993
2949
|
})
|
|
2994
|
-
}).check(
|
|
2950
|
+
}).check(z15.describe("The complete configuration for the protocol, including global settings and actor-specific overrides"));
|
|
2995
2951
|
function resolveConfig(config) {
|
|
2996
2952
|
const parsedConfig = ConfigZod.parse(config);
|
|
2997
2953
|
const {
|
|
@@ -3000,7 +2956,7 @@ function resolveConfig(config) {
|
|
|
3000
2956
|
...rootConfig
|
|
3001
2957
|
} = parsedConfig;
|
|
3002
2958
|
parsedConfig.actors = actors.map((actorConfig) => {
|
|
3003
|
-
return
|
|
2959
|
+
return z15.looseObject(ActorConfigZod.shape).parse({ ...rootConfig, ...actorConfig });
|
|
3004
2960
|
});
|
|
3005
2961
|
return parsedConfig;
|
|
3006
2962
|
}
|
|
@@ -3011,15 +2967,15 @@ import {
|
|
|
3011
2967
|
zodIsFactory as zodIsFactory3,
|
|
3012
2968
|
zodToFactory as zodToFactory3
|
|
3013
2969
|
} from "@xylabs/sdk-js";
|
|
3014
|
-
import { globalRegistry as
|
|
3015
|
-
var HostActorConfigZod =
|
|
3016
|
-
host:
|
|
2970
|
+
import { globalRegistry as globalRegistry10, z as z16 } from "zod/mini";
|
|
2971
|
+
var HostActorConfigZod = z16.extend(ActorConfigZod, {
|
|
2972
|
+
host: z16._default(z16.string(), "localhost").register(globalRegistry10, {
|
|
3017
2973
|
default: "localhost",
|
|
3018
2974
|
description: "Host for the Actor",
|
|
3019
2975
|
title: "host",
|
|
3020
2976
|
type: "string"
|
|
3021
2977
|
}),
|
|
3022
|
-
port:
|
|
2978
|
+
port: z16._default(z16.coerce.number(), 8080).register(globalRegistry10, {
|
|
3023
2979
|
default: 8080,
|
|
3024
2980
|
description: "Port for the Actor",
|
|
3025
2981
|
title: "port",
|
|
@@ -3030,6 +2986,31 @@ var isHostActorConfig = zodIsFactory3(HostActorConfigZod);
|
|
|
3030
2986
|
var asHostActorConfig = zodAsFactory4(HostActorConfigZod, "asHostActorConfig");
|
|
3031
2987
|
var toHostActorConfig = zodToFactory3(HostActorConfigZod, "toHostActorConfig");
|
|
3032
2988
|
|
|
2989
|
+
// src/config/resolveRestConnectionEndpoint.ts
|
|
2990
|
+
import { assertEx as assertEx21, isDefined as isDefined14 } from "@xylabs/sdk-js";
|
|
2991
|
+
function asRestConnectionConfig(connection) {
|
|
2992
|
+
if (connection?.type !== "rest") return void 0;
|
|
2993
|
+
return connection;
|
|
2994
|
+
}
|
|
2995
|
+
function resolveRestConnectionEndpoint(config, moniker) {
|
|
2996
|
+
const normalized = normalizeConnectionsConfig(config);
|
|
2997
|
+
const binding = normalized.providerBindings[moniker];
|
|
2998
|
+
const connectionName = assertEx21(
|
|
2999
|
+
binding?.connection ?? binding?.transport,
|
|
3000
|
+
() => `Provider "${moniker}" has no providerBindings.connection for REST endpoint resolution`
|
|
3001
|
+
);
|
|
3002
|
+
const rest = assertEx21(
|
|
3003
|
+
asRestConnectionConfig(normalized.connections[connectionName]),
|
|
3004
|
+
() => `Connection "${connectionName}" bound to "${moniker}" is not a rest connection`
|
|
3005
|
+
);
|
|
3006
|
+
const { baseUrl } = rest;
|
|
3007
|
+
assertEx21(
|
|
3008
|
+
isDefined14(baseUrl) && baseUrl !== "",
|
|
3009
|
+
() => `Rest connection "${connectionName}" requires baseUrl`
|
|
3010
|
+
);
|
|
3011
|
+
return baseUrl;
|
|
3012
|
+
}
|
|
3013
|
+
|
|
3033
3014
|
// src/config/synthesizeRpcConnectionBindings.ts
|
|
3034
3015
|
var DEFAULT_RPC_CONNECTION = "default-rpc";
|
|
3035
3016
|
var RPC_MONIKERS = [
|
|
@@ -3062,64 +3043,64 @@ function synthesizeRpcConnectionBindings() {
|
|
|
3062
3043
|
}
|
|
3063
3044
|
|
|
3064
3045
|
// src/config/transports/Rpc.ts
|
|
3065
|
-
import { globalRegistry as
|
|
3066
|
-
var RpcRemoteConfigBaseZod =
|
|
3067
|
-
protocol:
|
|
3046
|
+
import { globalRegistry as globalRegistry11, z as z17 } from "zod";
|
|
3047
|
+
var RpcRemoteConfigBaseZod = z17.object({
|
|
3048
|
+
protocol: z17.string("http").register(globalRegistry11, {
|
|
3068
3049
|
description: "Protocol for the RPC connection",
|
|
3069
3050
|
type: "string"
|
|
3070
3051
|
})
|
|
3071
3052
|
}).describe("Base configuration for the remote RPC");
|
|
3072
3053
|
var HttpRpcRemoteConfigZod = RpcRemoteConfigBaseZod.extend({
|
|
3073
|
-
protocol:
|
|
3054
|
+
protocol: z17.string("http").register(globalRegistry11, {
|
|
3074
3055
|
description: "Protocol for the RPC connection",
|
|
3075
3056
|
type: "string"
|
|
3076
3057
|
}).default("http"),
|
|
3077
|
-
url:
|
|
3058
|
+
url: z17.string().register(globalRegistry11, {
|
|
3078
3059
|
description: "URL for the Chain RPC API",
|
|
3079
3060
|
type: "string"
|
|
3080
3061
|
})
|
|
3081
3062
|
}).describe("Configuration for the remote RPC using Http");
|
|
3082
3063
|
var PostMessageRpcRemoteConfigZod = RpcRemoteConfigBaseZod.extend({
|
|
3083
|
-
protocol:
|
|
3064
|
+
protocol: z17.string().register(globalRegistry11, {
|
|
3084
3065
|
description: "Protocol for the RPC connection",
|
|
3085
3066
|
type: "string"
|
|
3086
3067
|
}).default("postMessage"),
|
|
3087
|
-
networkId:
|
|
3068
|
+
networkId: z17.string().register(globalRegistry11, {
|
|
3088
3069
|
description: "Network ID to use for the postMessage RPC connection",
|
|
3089
3070
|
type: "string"
|
|
3090
3071
|
}),
|
|
3091
|
-
sessionId:
|
|
3072
|
+
sessionId: z17.string().register(globalRegistry11, {
|
|
3092
3073
|
description: "Session ID to use for the postMessage RPC connection",
|
|
3093
3074
|
type: "string"
|
|
3094
3075
|
})
|
|
3095
3076
|
}).describe("Configuration for the remote RPC using postMessage");
|
|
3096
|
-
var RpcRemoteConfigZod =
|
|
3077
|
+
var RpcRemoteConfigZod = z17.union([HttpRpcRemoteConfigZod, PostMessageRpcRemoteConfigZod]).describe("Configuration for a remote RPC connection, either Http or postMessage");
|
|
3097
3078
|
|
|
3098
3079
|
// src/config/UsageMeta.ts
|
|
3099
|
-
import { z as
|
|
3100
|
-
var DescriptionSchema =
|
|
3101
|
-
var TitleSchema =
|
|
3102
|
-
var JSONSchemaMetaSchema =
|
|
3103
|
-
id:
|
|
3080
|
+
import { z as z18 } from "zod";
|
|
3081
|
+
var DescriptionSchema = z18.string();
|
|
3082
|
+
var TitleSchema = z18.string();
|
|
3083
|
+
var JSONSchemaMetaSchema = z18.object({
|
|
3084
|
+
id: z18.string().optional(),
|
|
3104
3085
|
title: TitleSchema.optional(),
|
|
3105
3086
|
description: DescriptionSchema.optional(),
|
|
3106
|
-
deprecated:
|
|
3107
|
-
}).catchall(
|
|
3087
|
+
deprecated: z18.boolean().optional()
|
|
3088
|
+
}).catchall(z18.unknown());
|
|
3108
3089
|
var GlobalMetaSchema = JSONSchemaMetaSchema.extend({});
|
|
3109
|
-
var ChoicesSchema =
|
|
3090
|
+
var ChoicesSchema = z18.array(z18.union([z18.string(), z18.number(), z18.literal(true), z18.undefined()])).readonly();
|
|
3110
3091
|
var UsageMetaSchema = GlobalMetaSchema.extend({
|
|
3111
3092
|
choices: ChoicesSchema.optional(),
|
|
3112
|
-
default:
|
|
3093
|
+
default: z18.unknown().optional(),
|
|
3113
3094
|
description: DescriptionSchema,
|
|
3114
|
-
group:
|
|
3115
|
-
hidden:
|
|
3095
|
+
group: z18.string().optional(),
|
|
3096
|
+
hidden: z18.boolean().optional(),
|
|
3116
3097
|
title: TitleSchema,
|
|
3117
|
-
type:
|
|
3118
|
-
|
|
3119
|
-
|
|
3120
|
-
|
|
3121
|
-
|
|
3122
|
-
|
|
3098
|
+
type: z18.union([
|
|
3099
|
+
z18.literal("array"),
|
|
3100
|
+
z18.literal("count"),
|
|
3101
|
+
z18.literal("boolean"),
|
|
3102
|
+
z18.literal("number"),
|
|
3103
|
+
z18.literal("string")
|
|
3123
3104
|
])
|
|
3124
3105
|
});
|
|
3125
3106
|
function isUsageMeta(v) {
|
|
@@ -3132,7 +3113,7 @@ import {
|
|
|
3132
3113
|
zodIsFactory as zodIsFactory5,
|
|
3133
3114
|
zodToFactory as zodToFactory5
|
|
3134
3115
|
} from "@xylabs/sdk-js";
|
|
3135
|
-
import { z as
|
|
3116
|
+
import { z as z20 } from "zod/mini";
|
|
3136
3117
|
|
|
3137
3118
|
// src/model/CreatableProviderContext.zod.ts
|
|
3138
3119
|
import {
|
|
@@ -3141,17 +3122,17 @@ import {
|
|
|
3141
3122
|
zodToFactory as zodToFactory4
|
|
3142
3123
|
} from "@xylabs/sdk-js";
|
|
3143
3124
|
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:
|
|
3125
|
+
import { z as z19 } from "zod/mini";
|
|
3126
|
+
var RuntimeStatusMonitorZod = z19.custom((val) => val !== null && val !== void 0 && typeof val === "object");
|
|
3127
|
+
var ProviderFactoryLocatorZod = z19.lazy(() => z19.custom((val) => val !== null && val !== void 0 && typeof val === "object" && "context" in val && "registry" in val));
|
|
3128
|
+
var BaseConfigContextZod = z19.extend(CachingContextZod, {
|
|
3129
|
+
config: z19.looseObject(BaseConfigZod.shape),
|
|
3130
|
+
locator: z19.optional(ProviderFactoryLocatorZod)
|
|
3150
3131
|
});
|
|
3151
|
-
var CreatableProviderContextZod =
|
|
3152
|
-
_id:
|
|
3132
|
+
var CreatableProviderContextZod = z19.lazy(() => z19.extend(BaseConfigContextZod, {
|
|
3133
|
+
_id: z19.optional(z19.string()),
|
|
3153
3134
|
locator: ProviderFactoryLocatorZod,
|
|
3154
|
-
statusReporter:
|
|
3135
|
+
statusReporter: z19.optional(RuntimeStatusMonitorZod)
|
|
3155
3136
|
}));
|
|
3156
3137
|
var isBaseConfigContext = zodIsFactory4(BaseConfigContextZod);
|
|
3157
3138
|
var asBaseConfigContext = zodAsFactory5(BaseConfigContextZod, "asBaseConfigContext");
|
|
@@ -3201,7 +3182,7 @@ import { PayloadBundleSchema as PayloadBundleSchema2 } from "@xyo-network/sdk-js
|
|
|
3201
3182
|
import { PayloadBuilder as PayloadBuilder12 } from "@xyo-network/sdk-js";
|
|
3202
3183
|
|
|
3203
3184
|
// src/transaction/buildTransaction.ts
|
|
3204
|
-
import { assertEx as
|
|
3185
|
+
import { assertEx as assertEx22, toHex } from "@xylabs/sdk-js";
|
|
3205
3186
|
import {
|
|
3206
3187
|
asAnyPayload as asAnyPayload2,
|
|
3207
3188
|
BoundWitnessBuilder,
|
|
@@ -3227,7 +3208,7 @@ async function buildTransaction(chain, onChainPayloads, offChainPayloads, signer
|
|
|
3227
3208
|
const script = Array.from(elevatedHashes, (elevatedHash) => `elevate|${elevatedHash}`);
|
|
3228
3209
|
const fields = {
|
|
3229
3210
|
...txBoundWitnessFields,
|
|
3230
|
-
from: from ?? (Array.isArray(signer) ?
|
|
3211
|
+
from: from ?? (Array.isArray(signer) ? assertEx22(signer.at(0)?.address) : signer.address)
|
|
3231
3212
|
};
|
|
3232
3213
|
if (script.length > 0) {
|
|
3233
3214
|
fields.script = script;
|
|
@@ -3272,7 +3253,7 @@ async function buildUnsignedTransaction(chain, onChainPayloads, offChainPayloads
|
|
|
3272
3253
|
// src/transaction/confirmSubmittedTransaction.ts
|
|
3273
3254
|
import {
|
|
3274
3255
|
delay,
|
|
3275
|
-
isDefined as
|
|
3256
|
+
isDefined as isDefined15,
|
|
3276
3257
|
isNumber
|
|
3277
3258
|
} from "@xylabs/sdk-js";
|
|
3278
3259
|
var DEFAULT_CONFIRMATION_ATTEMPTS = 20;
|
|
@@ -3294,7 +3275,7 @@ var confirmSubmittedTransaction = async (viewer, txHash, options) => {
|
|
|
3294
3275
|
let attempts = 0;
|
|
3295
3276
|
while (true) {
|
|
3296
3277
|
const tx = await viewer.transaction.byHash(txHash) ?? void 0;
|
|
3297
|
-
if (
|
|
3278
|
+
if (isDefined15(tx)) {
|
|
3298
3279
|
options?.logger?.debug("Transaction confirmed", txHash);
|
|
3299
3280
|
return tx;
|
|
3300
3281
|
}
|
|
@@ -3312,7 +3293,7 @@ var confirmSubmittedTransaction = async (viewer, txHash, options) => {
|
|
|
3312
3293
|
};
|
|
3313
3294
|
|
|
3314
3295
|
// src/transaction/hydrateTransaction.ts
|
|
3315
|
-
import { assertEx as
|
|
3296
|
+
import { assertEx as assertEx23 } from "@xylabs/sdk-js";
|
|
3316
3297
|
import {
|
|
3317
3298
|
asAnyPayload as asAnyPayload3,
|
|
3318
3299
|
hydrateTypedBoundWitness,
|
|
@@ -3383,7 +3364,7 @@ var tryHydrateElevatedTransaction = async ({ chainMap }, hash) => {
|
|
|
3383
3364
|
return void 0;
|
|
3384
3365
|
};
|
|
3385
3366
|
var hydrateElevatedTransaction = async (context, hash) => {
|
|
3386
|
-
return
|
|
3367
|
+
return assertEx23(await tryHydrateElevatedTransaction(context, hash), () => "Hydration failed");
|
|
3387
3368
|
};
|
|
3388
3369
|
|
|
3389
3370
|
// src/transaction/primitives/transactionBlockByteCount.ts
|
|
@@ -3436,13 +3417,13 @@ function transactionRequiredGas(hydratedTransaction) {
|
|
|
3436
3417
|
|
|
3437
3418
|
// src/transaction/signTransaction.ts
|
|
3438
3419
|
import {
|
|
3439
|
-
assertEx as
|
|
3420
|
+
assertEx as assertEx24,
|
|
3440
3421
|
hexFromArrayBuffer,
|
|
3441
3422
|
toArrayBuffer
|
|
3442
3423
|
} from "@xylabs/sdk-js";
|
|
3443
3424
|
import { PayloadBuilder as PayloadBuilder10 } from "@xyo-network/sdk-js";
|
|
3444
3425
|
async function signTransaction(tx, account) {
|
|
3445
|
-
|
|
3426
|
+
assertEx24(tx.from === account.address, () => "Signer address does not match transaction from address");
|
|
3446
3427
|
const unsignedTx = structuredClone(tx);
|
|
3447
3428
|
unsignedTx.addresses = [account.address];
|
|
3448
3429
|
unsignedTx.previous_hashes = [account.previousHash ?? null];
|
|
@@ -3457,7 +3438,7 @@ async function signTransaction(tx, account) {
|
|
|
3457
3438
|
}
|
|
3458
3439
|
|
|
3459
3440
|
// src/transaction/TransactionBuilder.ts
|
|
3460
|
-
import { assertEx as
|
|
3441
|
+
import { assertEx as assertEx25, Base } from "@xylabs/sdk-js";
|
|
3461
3442
|
import { PayloadBuilder as PayloadBuilder11 } from "@xyo-network/sdk-js";
|
|
3462
3443
|
import {
|
|
3463
3444
|
asXL1BlockNumber as asXL1BlockNumber4,
|
|
@@ -3477,9 +3458,9 @@ var TransactionBuilder = class extends Base {
|
|
|
3477
3458
|
super(options);
|
|
3478
3459
|
}
|
|
3479
3460
|
async build() {
|
|
3480
|
-
const chain =
|
|
3481
|
-
const fees =
|
|
3482
|
-
const blockRange =
|
|
3461
|
+
const chain = assertEx25(this._chain, () => "Chain must be set before building the transaction");
|
|
3462
|
+
const fees = assertEx25(this._fees, () => "Fees must be set before building the transaction");
|
|
3463
|
+
const blockRange = assertEx25(this._blockRange, () => "Block range must be set before building the transaction");
|
|
3483
3464
|
return await buildTransaction(
|
|
3484
3465
|
chain,
|
|
3485
3466
|
this._elevatedPayloads,
|
|
@@ -3509,7 +3490,7 @@ var TransactionBuilder = class extends Base {
|
|
|
3509
3490
|
}
|
|
3510
3491
|
elevatedPayload(payload) {
|
|
3511
3492
|
const allowedPayload = isAllowedBlockPayload2(payload) ? payload : void 0;
|
|
3512
|
-
const allowPayloadExists =
|
|
3493
|
+
const allowPayloadExists = assertEx25(allowedPayload, () => "Payload must be an AllowedBlockPayload");
|
|
3513
3494
|
this._elevatedPayloads.push(allowPayloadExists);
|
|
3514
3495
|
return this;
|
|
3515
3496
|
}
|
|
@@ -3605,7 +3586,7 @@ var bundle2 = (root, transaction) => {
|
|
|
3605
3586
|
};
|
|
3606
3587
|
|
|
3607
3588
|
// src/context/Actor.ts
|
|
3608
|
-
var ActorConfigContext =
|
|
3589
|
+
var ActorConfigContext = z20.extend(BaseConfigContextZod, { config: ActorConfigZod });
|
|
3609
3590
|
var isActorConfigContext = zodIsFactory5(ActorConfigContext);
|
|
3610
3591
|
var asActorConfigContext = zodAsFactory6(ActorConfigContext, "asActorConfigContext");
|
|
3611
3592
|
var toActorConfigContext = zodToFactory5(ActorConfigContext, "toActorConfigContext");
|
|
@@ -3616,8 +3597,8 @@ import {
|
|
|
3616
3597
|
zodIsFactory as zodIsFactory6,
|
|
3617
3598
|
zodToFactory as zodToFactory6
|
|
3618
3599
|
} from "@xylabs/sdk-js";
|
|
3619
|
-
import { z as
|
|
3620
|
-
var HostActorConfigContext =
|
|
3600
|
+
import { z as z21 } from "zod/mini";
|
|
3601
|
+
var HostActorConfigContext = z21.extend(BaseConfigContextZod, { config: HostActorConfigZod });
|
|
3621
3602
|
var isHostActorConfigContext = zodIsFactory6(HostActorConfigContext);
|
|
3622
3603
|
var asHostActorConfigContext = zodAsFactory7(HostActorConfigContext, "asHostActorConfigContext");
|
|
3623
3604
|
var toHostActorConfigContext = zodToFactory6(HostActorConfigContext, "toHostActorConfigContext");
|
|
@@ -3625,7 +3606,7 @@ var toHostActorConfigContext = zodToFactory6(HostActorConfigContext, "toHostActo
|
|
|
3625
3606
|
// src/CreatableProvider/AbstractCreatableProvider.ts
|
|
3626
3607
|
import {
|
|
3627
3608
|
AbstractCreatable,
|
|
3628
|
-
assertEx as
|
|
3609
|
+
assertEx as assertEx26,
|
|
3629
3610
|
IdLogger
|
|
3630
3611
|
} from "@xylabs/sdk-js";
|
|
3631
3612
|
var AbstractCreatableProvider = class extends AbstractCreatable {
|
|
@@ -3659,9 +3640,9 @@ var AbstractCreatableProvider = class extends AbstractCreatable {
|
|
|
3659
3640
|
return factory;
|
|
3660
3641
|
}
|
|
3661
3642
|
static async paramsHandler(params = {}) {
|
|
3662
|
-
const context =
|
|
3663
|
-
const config =
|
|
3664
|
-
const locator =
|
|
3643
|
+
const context = assertEx26(params.context, () => new Error("Context is required"));
|
|
3644
|
+
const config = assertEx26(context.config, () => new Error("Context config is required"));
|
|
3645
|
+
const locator = assertEx26(context.locator, () => new Error("Context locator is required"));
|
|
3665
3646
|
return await super.paramsHandler({
|
|
3666
3647
|
...params,
|
|
3667
3648
|
statusReporter: params.statusReporter ?? context.statusReporter,
|
|
@@ -3704,13 +3685,13 @@ function labeledCreatableProvider() {
|
|
|
3704
3685
|
}
|
|
3705
3686
|
|
|
3706
3687
|
// src/createDeclarationPayload.ts
|
|
3707
|
-
import { isDefined as
|
|
3688
|
+
import { isDefined as isDefined16 } from "@xylabs/sdk-js";
|
|
3708
3689
|
import { PayloadBuilder as PayloadBuilder13 } from "@xyo-network/sdk-js";
|
|
3709
3690
|
import {
|
|
3710
3691
|
ChainStakeIntentSchema
|
|
3711
3692
|
} from "@xyo-network/xl1-protocol-lib";
|
|
3712
3693
|
var createDeclarationIntent = (address, intent, nbf, exp) => {
|
|
3713
|
-
const expiration =
|
|
3694
|
+
const expiration = isDefined16(exp) ? exp : nbf + 1e4;
|
|
3714
3695
|
const payloadBuilder = new PayloadBuilder13({ schema: ChainStakeIntentSchema });
|
|
3715
3696
|
const builder = payloadBuilder.fields({
|
|
3716
3697
|
from: address,
|
|
@@ -3742,26 +3723,26 @@ import {
|
|
|
3742
3723
|
asSchema as asSchema2,
|
|
3743
3724
|
isPayloadOfZodType
|
|
3744
3725
|
} from "@xyo-network/sdk-js";
|
|
3745
|
-
import { z as
|
|
3726
|
+
import { z as z23 } from "zod";
|
|
3746
3727
|
|
|
3747
3728
|
// src/eip-712/Types.ts
|
|
3748
|
-
import { z as
|
|
3749
|
-
var TypedDataDomainZod =
|
|
3750
|
-
name:
|
|
3751
|
-
version:
|
|
3752
|
-
chainId:
|
|
3753
|
-
verifyingContract:
|
|
3754
|
-
salt:
|
|
3729
|
+
import { z as z22 } from "zod";
|
|
3730
|
+
var TypedDataDomainZod = z22.object({
|
|
3731
|
+
name: z22.string().nullable().optional(),
|
|
3732
|
+
version: z22.string().nullable().optional(),
|
|
3733
|
+
chainId: z22.union([z22.string(), z22.number(), z22.bigint()]).nullable().optional(),
|
|
3734
|
+
verifyingContract: z22.string().nullable().optional(),
|
|
3735
|
+
salt: z22.union([z22.string(), z22.instanceof(Uint8Array)]).nullable().optional()
|
|
3755
3736
|
});
|
|
3756
|
-
var TypedDataFieldZod =
|
|
3757
|
-
name:
|
|
3758
|
-
type:
|
|
3737
|
+
var TypedDataFieldZod = z22.object({
|
|
3738
|
+
name: z22.string(),
|
|
3739
|
+
type: z22.string()
|
|
3759
3740
|
});
|
|
3760
|
-
var TypedDataTypesZod =
|
|
3761
|
-
var TypedDataValueZod =
|
|
3741
|
+
var TypedDataTypesZod = z22.record(z22.string(), z22.array(TypedDataFieldZod));
|
|
3742
|
+
var TypedDataValueZod = z22.record(z22.string(), z22.any());
|
|
3762
3743
|
|
|
3763
3744
|
// src/eip-712/Payloads/EIP712Data.ts
|
|
3764
|
-
var EIP712DataPayloadFieldsZod =
|
|
3745
|
+
var EIP712DataPayloadFieldsZod = z23.object({
|
|
3765
3746
|
domain: TypedDataDomainZod,
|
|
3766
3747
|
types: TypedDataTypesZod,
|
|
3767
3748
|
values: TypedDataValueZod
|
|
@@ -3779,11 +3760,11 @@ import {
|
|
|
3779
3760
|
asSchema as asSchema3,
|
|
3780
3761
|
isPayloadOfZodType as isPayloadOfZodType2
|
|
3781
3762
|
} from "@xyo-network/sdk-js";
|
|
3782
|
-
import { z as
|
|
3783
|
-
var EIP712SignaturePayloadFieldsZod =
|
|
3784
|
-
address:
|
|
3763
|
+
import { z as z24 } from "zod";
|
|
3764
|
+
var EIP712SignaturePayloadFieldsZod = z24.object({
|
|
3765
|
+
address: z24.string(),
|
|
3785
3766
|
hash: HashZod,
|
|
3786
|
-
signature:
|
|
3767
|
+
signature: z24.string()
|
|
3787
3768
|
});
|
|
3788
3769
|
var EIP712SignaturePayloadSchema = asSchema3("network.xyo.chains.ethereum.eip712.signature", true);
|
|
3789
3770
|
var isEIP712SignaturePayload = isPayloadOfZodType2(
|
|
@@ -3892,9 +3873,9 @@ var toPositiveBigInt = (value) => {
|
|
|
3892
3873
|
// src/simple/accountBalance/SimpleAccountBalanceViewer.ts
|
|
3893
3874
|
import {
|
|
3894
3875
|
asHash as asHash4,
|
|
3895
|
-
assertEx as
|
|
3876
|
+
assertEx as assertEx34,
|
|
3896
3877
|
exists as exists3,
|
|
3897
|
-
isDefined as
|
|
3878
|
+
isDefined as isDefined17,
|
|
3898
3879
|
ZERO_ADDRESS
|
|
3899
3880
|
} from "@xylabs/sdk-js";
|
|
3900
3881
|
import {
|
|
@@ -3960,18 +3941,18 @@ var asTransfersStepSummaryWithStorageMeta = AsObjectFactory7.create(isTransfersS
|
|
|
3960
3941
|
var balancesMaxStep = 5;
|
|
3961
3942
|
|
|
3962
3943
|
// src/summary/primitives/balances/balancesStepSummaryFromRange.ts
|
|
3963
|
-
import { assertEx as
|
|
3944
|
+
import { assertEx as assertEx27, spanRootAsync as spanRootAsync2 } from "@xylabs/sdk-js";
|
|
3964
3945
|
import { isAnyPayload as isAnyPayload3 } from "@xyo-network/sdk-js";
|
|
3965
3946
|
import { asXL1BlockNumber as asXL1BlockNumber5, StepSizes as StepSizes8 } from "@xyo-network/xl1-protocol-lib";
|
|
3966
3947
|
async function balancesStepSummaryFromRange(context, semaphores, blockViewer, summaryMap, range) {
|
|
3967
3948
|
const cacheKey = `${range[0]}|${range[1]}`;
|
|
3968
3949
|
return await withContextCacheResponse(context, "balancesStepSummaryFromRange", cacheKey, async () => {
|
|
3969
3950
|
return await spanRootAsync2("balancesStepSummaryFromRange", async () => {
|
|
3970
|
-
const [frameHead] =
|
|
3951
|
+
const [frameHead] = assertEx27(await blockViewer.blockByNumber(range[1]), () => `Block not found for number: ${range[1]}`);
|
|
3971
3952
|
const frameSize = range[1] - range[0] + 1;
|
|
3972
3953
|
const key = `${frameHead._hash}|${frameSize}`;
|
|
3973
3954
|
return frameSize === 1 ? await spanRootAsync2(`balancesStepSummaryFromRange.frameSize=1[${key}]`, async () => {
|
|
3974
|
-
const [, payloads] =
|
|
3955
|
+
const [, payloads] = assertEx27(await blockViewer.blockByNumber(range[0]), () => `Block not found for number: ${range[0]}`);
|
|
3975
3956
|
const balances = {};
|
|
3976
3957
|
for (const [address, balance] of Object.entries(netBalancesForPayloads(context, payloads))) {
|
|
3977
3958
|
balances[address] = toSignedBigInt(balance);
|
|
@@ -3984,7 +3965,7 @@ async function balancesStepSummaryFromRange(context, semaphores, blockViewer, su
|
|
|
3984
3965
|
};
|
|
3985
3966
|
}, { ...context, timeBudgetLimit: 500 }) : await spanRootAsync2(`balancesStepSummaryFromRange.frameSize>1[${key}]`, async () => {
|
|
3986
3967
|
const step = StepSizes8.indexOf(asXL1BlockNumber5(frameSize, true));
|
|
3987
|
-
|
|
3968
|
+
assertEx27(step !== -1, () => `Invalid step size: ${frameSize}. Must be one of ${StepSizes8.join(", ")}`);
|
|
3988
3969
|
const summaryResult = await summaryMap.get(`${frameHead._hash}|${frameSize}`);
|
|
3989
3970
|
if (isAnyPayload3(summaryResult)) {
|
|
3990
3971
|
return summaryResult;
|
|
@@ -4027,7 +4008,7 @@ async function balancesStepSummaryFromRange(context, semaphores, blockViewer, su
|
|
|
4027
4008
|
}
|
|
4028
4009
|
|
|
4029
4010
|
// src/summary/primitives/balances/balancesSummary.ts
|
|
4030
|
-
import { assertEx as
|
|
4011
|
+
import { assertEx as assertEx28, spanRootAsync as spanRootAsync3 } from "@xylabs/sdk-js";
|
|
4031
4012
|
import { asXyoAddress } from "@xyo-network/sdk-js";
|
|
4032
4013
|
import {
|
|
4033
4014
|
asBlockBoundWitnessWithStorageMeta as asBlockBoundWitnessWithStorageMeta3,
|
|
@@ -4038,7 +4019,7 @@ import {
|
|
|
4038
4019
|
async function balancesSummary(context, semaphores, blockViewer, summaryMap, config) {
|
|
4039
4020
|
return await spanRootAsync3("balancesSummary", async () => {
|
|
4040
4021
|
const headHash = isChainQualifiedHeadConfig(config) ? config.head : await blockViewer.currentBlockHash();
|
|
4041
|
-
const [head] =
|
|
4022
|
+
const [head] = assertEx28(await blockViewer.blockByHash(headHash), () => `Block not found for hash: ${headHash}`);
|
|
4042
4023
|
const headBoundWitness = asBlockBoundWitnessWithStorageMeta3(head, () => `Found Block not a BlockWithHashMeta: ${headHash}`);
|
|
4043
4024
|
const range = isChainQualifiedRangeConfig(config) ? config.range : asXL1BlockRange7([0, headBoundWitness.block], true);
|
|
4044
4025
|
const ranges = deepCalculateFramesFromRange(asXL1BlockRange7(
|
|
@@ -4061,7 +4042,7 @@ async function balancesSummary(context, semaphores, blockViewer, summaryMap, con
|
|
|
4061
4042
|
var blocksMaxStep = 3;
|
|
4062
4043
|
|
|
4063
4044
|
// src/summary/primitives/blocks/blocksStepSummaryFromRange.ts
|
|
4064
|
-
import { assertEx as
|
|
4045
|
+
import { assertEx as assertEx29, spanRootAsync as spanRootAsync4 } from "@xylabs/sdk-js";
|
|
4065
4046
|
import { isAnyPayload as isAnyPayload4 } from "@xyo-network/sdk-js";
|
|
4066
4047
|
import {
|
|
4067
4048
|
asBlocksStepSummary,
|
|
@@ -4076,7 +4057,7 @@ async function blocksStepSummaryFromRange(context, semaphores, blockViewer, summ
|
|
|
4076
4057
|
const cacheKey = `${range[0]}|${range[1]}`;
|
|
4077
4058
|
return await withContextCacheResponse(context, "blocksStepSummaryFromRange", cacheKey, async () => {
|
|
4078
4059
|
return await spanRootAsync4("blocksStepSummaryFromRange", async () => {
|
|
4079
|
-
const frameHead =
|
|
4060
|
+
const frameHead = assertEx29(
|
|
4080
4061
|
await blockViewer.blockByNumber(range[1]),
|
|
4081
4062
|
() => `Block not found for number: ${range[1]}`
|
|
4082
4063
|
);
|
|
@@ -4092,7 +4073,7 @@ async function blocksStepSummaryFromRange(context, semaphores, blockViewer, summ
|
|
|
4092
4073
|
};
|
|
4093
4074
|
} else {
|
|
4094
4075
|
const step = StepSizes9.indexOf(asXL1BlockNumber6(frameSize, true));
|
|
4095
|
-
|
|
4076
|
+
assertEx29(step !== -1, () => `Invalid step size: ${frameSize}. Must be one of ${StepSizes9.join(", ")}`);
|
|
4096
4077
|
const key = blocksStepSummaryKey(frameHeadHash, frameSize);
|
|
4097
4078
|
const summaryResult = await summaryMap.get(key);
|
|
4098
4079
|
if (isAnyPayload4(summaryResult)) {
|
|
@@ -4130,7 +4111,7 @@ async function blocksStepSummaryFromRange(context, semaphores, blockViewer, summ
|
|
|
4130
4111
|
var schemasMaxStep = 5;
|
|
4131
4112
|
|
|
4132
4113
|
// src/summary/primitives/schemas/schemasStepSummaryFromRange.ts
|
|
4133
|
-
import { assertEx as
|
|
4114
|
+
import { assertEx as assertEx30 } from "@xylabs/sdk-js";
|
|
4134
4115
|
import {
|
|
4135
4116
|
isAnyPayload as isAnyPayload5,
|
|
4136
4117
|
isBoundWitness as isBoundWitness2,
|
|
@@ -4139,11 +4120,11 @@ import {
|
|
|
4139
4120
|
} from "@xyo-network/sdk-js";
|
|
4140
4121
|
import { StepSizes as StepSizes10 } from "@xyo-network/xl1-protocol-lib";
|
|
4141
4122
|
async function schemasStepSummaryFromRange(context, semaphores, blockViewer, summaryMap, range) {
|
|
4142
|
-
const [frameHead] =
|
|
4123
|
+
const [frameHead] = assertEx30(await blockViewer.blockByNumber(range[1]), () => `Block not found for number: ${range[1]}`);
|
|
4143
4124
|
const frameSize = range[1] - range[0] + 1;
|
|
4144
4125
|
let result;
|
|
4145
4126
|
if (frameSize === 1) {
|
|
4146
|
-
const [block, payloads] =
|
|
4127
|
+
const [block, payloads] = assertEx30(await blockViewer.blockByNumber(range[0]), () => `Block not found for number: ${range[0]}`);
|
|
4147
4128
|
const boundWitnesses = [block, ...payloads.filter((x) => isBoundWitness2(x) && isHashMeta(x))];
|
|
4148
4129
|
const schemas = {};
|
|
4149
4130
|
for (const bw of boundWitnesses) {
|
|
@@ -4160,7 +4141,7 @@ async function schemasStepSummaryFromRange(context, semaphores, blockViewer, sum
|
|
|
4160
4141
|
});
|
|
4161
4142
|
} else {
|
|
4162
4143
|
const step = StepSizes10.indexOf(frameSize);
|
|
4163
|
-
|
|
4144
|
+
assertEx30(step !== -1, () => `Invalid step size: ${frameSize}. Must be one of ${StepSizes10.join(", ")}`);
|
|
4164
4145
|
const summaryResult = await summaryMap.get(`${frameHead._hash}|${frameSize}`);
|
|
4165
4146
|
if (isAnyPayload5(summaryResult)) {
|
|
4166
4147
|
result = summaryResult;
|
|
@@ -4199,7 +4180,7 @@ async function schemasStepSummaryFromRange(context, semaphores, blockViewer, sum
|
|
|
4199
4180
|
}
|
|
4200
4181
|
|
|
4201
4182
|
// src/summary/primitives/schemas/schemasSummary.ts
|
|
4202
|
-
import { assertEx as
|
|
4183
|
+
import { assertEx as assertEx31, spanRootAsync as spanRootAsync5 } from "@xylabs/sdk-js";
|
|
4203
4184
|
import {
|
|
4204
4185
|
asBlockBoundWitnessWithStorageMeta as asBlockBoundWitnessWithStorageMeta4,
|
|
4205
4186
|
asXL1BlockRange as asXL1BlockRange8,
|
|
@@ -4209,7 +4190,7 @@ import {
|
|
|
4209
4190
|
async function schemasSummary(context, semaphores, blockViewer, summaryMap, config) {
|
|
4210
4191
|
return await spanRootAsync5("schemasSummary", async () => {
|
|
4211
4192
|
const headHash = isChainQualifiedHeadConfig2(config) ? config.head : await blockViewer.currentBlockHash();
|
|
4212
|
-
const [head] =
|
|
4193
|
+
const [head] = assertEx31(await blockViewer.blockByHash(headHash), () => `Block not found for hash: ${headHash}`);
|
|
4213
4194
|
const headBoundWitness = asBlockBoundWitnessWithStorageMeta4(head, () => `Found Block not a BlockWithHashMeta: ${headHash}`);
|
|
4214
4195
|
const range = isChainQualifiedRangeConfig2(config) ? config.range : asXL1BlockRange8([0, headBoundWitness.block], true);
|
|
4215
4196
|
const ranges = deepCalculateFramesFromRange(asXL1BlockRange8(
|
|
@@ -4232,7 +4213,7 @@ async function schemasSummary(context, semaphores, blockViewer, summaryMap, conf
|
|
|
4232
4213
|
var transfersMaxStep = 4;
|
|
4233
4214
|
|
|
4234
4215
|
// src/summary/primitives/transfers/transfersStepSummaryFromRange.ts
|
|
4235
|
-
import { assertEx as
|
|
4216
|
+
import { assertEx as assertEx32, spanRootAsync as spanRootAsync6 } from "@xylabs/sdk-js";
|
|
4236
4217
|
import { isAnyPayload as isAnyPayload6 } from "@xyo-network/sdk-js";
|
|
4237
4218
|
import { asXL1BlockNumber as asXL1BlockNumber7, StepSizes as StepSizes11 } from "@xyo-network/xl1-protocol-lib";
|
|
4238
4219
|
function transfersSummaryKey(frameHeadHash, frameSize) {
|
|
@@ -4242,11 +4223,11 @@ async function transfersStepSummaryFromRange(context, semaphores, blockViewer, s
|
|
|
4242
4223
|
const cacheKey = `${range[0]}|${range[1]}`;
|
|
4243
4224
|
return await withContextCacheResponse(context, "transfersStepSummaryFromRange", cacheKey, async () => {
|
|
4244
4225
|
return await spanRootAsync6("transfersStepSummaryFromRange", async () => {
|
|
4245
|
-
const [frameHead] =
|
|
4226
|
+
const [frameHead] = assertEx32(await blockViewer.blockByNumber(range[1]), () => `Block not found for number: ${range[1]}`);
|
|
4246
4227
|
const frameSize = range[1] - range[0] + 1;
|
|
4247
4228
|
let result;
|
|
4248
4229
|
if (frameSize === 1) {
|
|
4249
|
-
const [, payloads] =
|
|
4230
|
+
const [, payloads] = assertEx32(await blockViewer.blockByNumber(range[0]), () => `Block not found for number: ${range[0]}`);
|
|
4250
4231
|
const transfers = {};
|
|
4251
4232
|
for (const [from, toMap] of Object.entries(netTransfersForPayloads(context, payloads))) {
|
|
4252
4233
|
transfers[from] = transfers[from] ?? {};
|
|
@@ -4262,7 +4243,7 @@ async function transfersStepSummaryFromRange(context, semaphores, blockViewer, s
|
|
|
4262
4243
|
};
|
|
4263
4244
|
} else {
|
|
4264
4245
|
const step = StepSizes11.indexOf(asXL1BlockNumber7(frameSize, true));
|
|
4265
|
-
|
|
4246
|
+
assertEx32(step !== -1, () => `Invalid step size: ${frameSize}. Must be one of ${StepSizes11.join(", ")}`);
|
|
4266
4247
|
const key = transfersSummaryKey(frameHead._hash, frameSize);
|
|
4267
4248
|
const summaryResult = await summaryMap.get(key);
|
|
4268
4249
|
if (isAnyPayload6(summaryResult)) {
|
|
@@ -4313,7 +4294,7 @@ async function transfersStepSummaryFromRange(context, semaphores, blockViewer, s
|
|
|
4313
4294
|
}
|
|
4314
4295
|
|
|
4315
4296
|
// src/summary/primitives/transfers/transfersSummary.ts
|
|
4316
|
-
import { assertEx as
|
|
4297
|
+
import { assertEx as assertEx33, spanRootAsync as spanRootAsync7 } from "@xylabs/sdk-js";
|
|
4317
4298
|
import { asXyoAddress as asXyoAddress2 } from "@xyo-network/sdk-js";
|
|
4318
4299
|
import {
|
|
4319
4300
|
asBlockBoundWitnessWithStorageMeta as asBlockBoundWitnessWithStorageMeta5,
|
|
@@ -4324,7 +4305,7 @@ import {
|
|
|
4324
4305
|
async function transfersSummary(context, semaphores, blockViewer, summaryMap, config) {
|
|
4325
4306
|
return await spanRootAsync7("transferSummary", async () => {
|
|
4326
4307
|
const headHash = isChainQualifiedHeadConfig3(config) ? config.head : await blockViewer.currentBlockHash();
|
|
4327
|
-
const [head] =
|
|
4308
|
+
const [head] = assertEx33(await blockViewer.blockByHash(headHash), () => `Block not found for hash: ${headHash}`);
|
|
4328
4309
|
const headBoundWitness = asBlockBoundWitnessWithStorageMeta5(head, () => `Found Block not a BlockWithHashMeta: ${headHash}`);
|
|
4329
4310
|
const range = isChainQualifiedRangeConfig3(config) ? config.range : asXL1BlockRange9([0, headBoundWitness.block], true);
|
|
4330
4311
|
const ranges = deepCalculateFramesFromRange(asXL1BlockRange9(
|
|
@@ -4365,8 +4346,8 @@ var SimpleAccountBalanceViewer = class extends AbstractCreatableProvider {
|
|
|
4365
4346
|
static async paramsHandler(params = {}) {
|
|
4366
4347
|
return {
|
|
4367
4348
|
...await super.paramsHandler(params),
|
|
4368
|
-
balancesSummaryMap:
|
|
4369
|
-
transfersSummaryMap:
|
|
4349
|
+
balancesSummaryMap: assertEx34(params.balancesSummaryMap, () => "balancesSummaryMap is required"),
|
|
4350
|
+
transfersSummaryMap: assertEx34(params.transfersSummaryMap, () => "transfersSummaryMap is required")
|
|
4370
4351
|
};
|
|
4371
4352
|
}
|
|
4372
4353
|
async accountBalance(address, config) {
|
|
@@ -4389,11 +4370,11 @@ var SimpleAccountBalanceViewer = class extends AbstractCreatableProvider {
|
|
|
4389
4370
|
const transferIndexes = block[0].payload_schemas.map((schema, index) => schema === TransferSchema2 ? index : void 0).filter(exists3);
|
|
4390
4371
|
const transfers = transferIndexes.map((index) => {
|
|
4391
4372
|
const hash = block[0].payload_hashes[index];
|
|
4392
|
-
return
|
|
4373
|
+
return assertEx34(
|
|
4393
4374
|
block[1].find((p) => p._hash === hash),
|
|
4394
4375
|
() => `Error: Could not find Transfer with hash ${hash} in block ${block[0]._hash}`
|
|
4395
4376
|
);
|
|
4396
|
-
}).filter(exists3).filter((t) => t.from === address ||
|
|
4377
|
+
}).filter(exists3).filter((t) => t.from === address || isDefined17(t.transfers[address]));
|
|
4397
4378
|
if (transfers.length === 0) {
|
|
4398
4379
|
continue;
|
|
4399
4380
|
}
|
|
@@ -4422,7 +4403,7 @@ var SimpleAccountBalanceViewer = class extends AbstractCreatableProvider {
|
|
|
4422
4403
|
const head = isChainQualifiedHeadConfig4(config) ? config.head : await this.blockViewer.currentBlockHash();
|
|
4423
4404
|
const range = isChainQualifiedRangeConfig4(config) ? config.range : asXL1BlockRange10([
|
|
4424
4405
|
0,
|
|
4425
|
-
|
|
4406
|
+
assertEx34(
|
|
4426
4407
|
await this.blockViewer.blockByHash(head),
|
|
4427
4408
|
() => `Error: Could not find block with hash ${head}`
|
|
4428
4409
|
)[0].block
|
|
@@ -4437,11 +4418,11 @@ var SimpleAccountBalanceViewer = class extends AbstractCreatableProvider {
|
|
|
4437
4418
|
const qualifiedRange = qualifiedEntries[0][1][1].range;
|
|
4438
4419
|
const qualifiedHeadHash = qualifiedEntries[0][1][1].head;
|
|
4439
4420
|
for (const [_, [__, { range: range2, head: head2 }]] of qualifiedEntries) {
|
|
4440
|
-
|
|
4421
|
+
assertEx34(
|
|
4441
4422
|
range2[0] === qualifiedRange[0] && range2[1] === qualifiedRange[1],
|
|
4442
4423
|
() => "Inconsistent ranges in qualifiedAccountBalanceHistories"
|
|
4443
4424
|
);
|
|
4444
|
-
|
|
4425
|
+
assertEx34(
|
|
4445
4426
|
head2 === qualifiedHeadHash,
|
|
4446
4427
|
() => "Inconsistent head hashes in qualifiedAccountBalanceHistories"
|
|
4447
4428
|
);
|
|
@@ -4512,7 +4493,7 @@ var SimpleAccountBalanceViewer = class extends AbstractCreatableProvider {
|
|
|
4512
4493
|
return await this.spanAsync("qualifiedAccountBalanceHistory", async () => {
|
|
4513
4494
|
const range = asRange(headOrRange);
|
|
4514
4495
|
const headHash = asHash4(headOrRange);
|
|
4515
|
-
const [head] =
|
|
4496
|
+
const [head] = assertEx34(isDefined17(headHash) ? await this.blockViewer.blockByHash(headHash) : await this.blockViewer.currentBlock(), () => "Could not resolve head block");
|
|
4516
4497
|
const startingRange = asXL1BlockRange10(range ?? [0, head.block], true);
|
|
4517
4498
|
const blockNumbers = await this.distillTransferHistory(address, startingRange);
|
|
4518
4499
|
const blockResults = await Promise.all(blockNumbers.map(async (bn) => await this.blockViewer.blockByNumber(bn)));
|
|
@@ -4522,11 +4503,11 @@ var SimpleAccountBalanceViewer = class extends AbstractCreatableProvider {
|
|
|
4522
4503
|
const transferIndexes = block[0].payload_schemas.map((schema, index) => schema === TransferSchema2 ? index : void 0).filter(exists3);
|
|
4523
4504
|
const transfers = transferIndexes.map((index) => {
|
|
4524
4505
|
const hash = block[0].payload_hashes[index];
|
|
4525
|
-
return
|
|
4506
|
+
return assertEx34(
|
|
4526
4507
|
block[1].find((p) => p._hash === hash),
|
|
4527
4508
|
() => `Error: Could not find Transfer with hash ${hash} in block ${block[0]._hash}`
|
|
4528
4509
|
);
|
|
4529
|
-
}).filter(exists3).filter((t) => t.from === address ||
|
|
4510
|
+
}).filter(exists3).filter((t) => t.from === address || isDefined17(t.transfers[address]));
|
|
4530
4511
|
if (transfers.length === 0) {
|
|
4531
4512
|
continue;
|
|
4532
4513
|
}
|
|
@@ -4554,7 +4535,7 @@ SimpleAccountBalanceViewer = __decorateClass([
|
|
|
4554
4535
|
|
|
4555
4536
|
// src/simple/block/SimpleBlockViewer.ts
|
|
4556
4537
|
import {
|
|
4557
|
-
assertEx as
|
|
4538
|
+
assertEx as assertEx35,
|
|
4558
4539
|
exists as exists4,
|
|
4559
4540
|
isUndefined as isUndefined7
|
|
4560
4541
|
} from "@xylabs/sdk-js";
|
|
@@ -4595,12 +4576,12 @@ var HydratedCache = class {
|
|
|
4595
4576
|
};
|
|
4596
4577
|
|
|
4597
4578
|
// src/utils/isZodError.ts
|
|
4598
|
-
import { z as
|
|
4579
|
+
import { z as z25 } from "zod";
|
|
4599
4580
|
var isZodError = (error) => {
|
|
4600
|
-
return error instanceof
|
|
4581
|
+
return error instanceof z25.ZodError;
|
|
4601
4582
|
};
|
|
4602
4583
|
var prettifyZodError = (error) => {
|
|
4603
|
-
return
|
|
4584
|
+
return z25.prettifyError(error);
|
|
4604
4585
|
};
|
|
4605
4586
|
|
|
4606
4587
|
// src/simple/block/SimpleBlockViewer.ts
|
|
@@ -4618,7 +4599,7 @@ var SimpleBlockViewer = class extends AbstractCreatableProvider {
|
|
|
4618
4599
|
_headPollTimer = null;
|
|
4619
4600
|
_signedHydratedBlockCache;
|
|
4620
4601
|
get finalizedArchivist() {
|
|
4621
|
-
return
|
|
4602
|
+
return assertEx35(this.params.finalizedArchivist, () => "finalizedArchivist is required \u2014 inject it or bind a connection");
|
|
4622
4603
|
}
|
|
4623
4604
|
get blocksSummaryMap() {
|
|
4624
4605
|
this._blocksSummaryMap ??= this.params.blocksSummaryMap ?? new LruCacheMap2({ max: 32 });
|
|
@@ -4642,14 +4623,14 @@ var SimpleBlockViewer = class extends AbstractCreatableProvider {
|
|
|
4642
4623
|
static async paramsHandler(params) {
|
|
4643
4624
|
const headPollIntervalMs = params.headPollIntervalMs;
|
|
4644
4625
|
if (headPollIntervalMs !== void 0) {
|
|
4645
|
-
|
|
4626
|
+
assertEx35(headPollIntervalMs >= MIN_HEAD_POLL_INTERVAL_MS, () => `headPollIntervalMs must be at least ${MIN_HEAD_POLL_INTERVAL_MS}ms`);
|
|
4646
4627
|
}
|
|
4647
4628
|
const connection = params.connection;
|
|
4648
4629
|
const finalizedArchivist = params.finalizedArchivist ?? (connection ? await connectArchivist(connection, { name: CHAIN_ARCHIVIST_ROLE }) : void 0);
|
|
4649
4630
|
return {
|
|
4650
4631
|
...await super.paramsHandler(params),
|
|
4651
4632
|
blocksSummaryMap: params.blocksSummaryMap,
|
|
4652
|
-
finalizedArchivist:
|
|
4633
|
+
finalizedArchivist: assertEx35(finalizedArchivist, () => "finalizedArchivist is required \u2014 inject it or bind a connection"),
|
|
4653
4634
|
headPollIntervalMs
|
|
4654
4635
|
};
|
|
4655
4636
|
}
|
|
@@ -4678,8 +4659,8 @@ var SimpleBlockViewer = class extends AbstractCreatableProvider {
|
|
|
4678
4659
|
}
|
|
4679
4660
|
async blocksByHash(hash, limit = 50) {
|
|
4680
4661
|
return await this.spanAsync("blocksByHash", async () => {
|
|
4681
|
-
|
|
4682
|
-
|
|
4662
|
+
assertEx35(limit > 0, () => "limit must be greater than 0");
|
|
4663
|
+
assertEx35(limit <= 100, () => "limit must be less than 100");
|
|
4683
4664
|
const blocks = [];
|
|
4684
4665
|
let current = await this.blockByHash(hash);
|
|
4685
4666
|
while (current && blocks.length < limit) {
|
|
@@ -4693,8 +4674,8 @@ var SimpleBlockViewer = class extends AbstractCreatableProvider {
|
|
|
4693
4674
|
}
|
|
4694
4675
|
async blocksByNumber(blockNumber, limit = 50) {
|
|
4695
4676
|
return await this.spanAsync("blocksByNumber", async () => {
|
|
4696
|
-
|
|
4697
|
-
|
|
4677
|
+
assertEx35(limit > 0, () => "limit must be greater than 0");
|
|
4678
|
+
assertEx35(limit <= 100, () => "limit must be less than 100");
|
|
4698
4679
|
const chainContext = await this.getChainContextRead();
|
|
4699
4680
|
if (isUndefined7(chainContext.head)) {
|
|
4700
4681
|
return [];
|
|
@@ -4712,9 +4693,9 @@ var SimpleBlockViewer = class extends AbstractCreatableProvider {
|
|
|
4712
4693
|
}
|
|
4713
4694
|
async blocksByStep(stepLevel, stepIndex) {
|
|
4714
4695
|
return await this.spanAsync("blocksByStep", async () => {
|
|
4715
|
-
|
|
4696
|
+
assertEx35(Number.isSafeInteger(stepIndex) && stepIndex >= 0, () => "stepIndex must be a non-negative integer");
|
|
4716
4697
|
const size = stepSize2(stepLevel);
|
|
4717
|
-
|
|
4698
|
+
assertEx35(
|
|
4718
4699
|
stepLevel <= blocksMaxStep,
|
|
4719
4700
|
() => `blocksByStep does not support step levels above ${blocksMaxStep} (requested ${stepLevel})`
|
|
4720
4701
|
);
|
|
@@ -4740,7 +4721,7 @@ var SimpleBlockViewer = class extends AbstractCreatableProvider {
|
|
|
4740
4721
|
const headBlock = await this.finalizationViewer.headBlock();
|
|
4741
4722
|
return headBlock.chain;
|
|
4742
4723
|
}
|
|
4743
|
-
const block =
|
|
4724
|
+
const block = assertEx35(await this.blockByNumber(blockNumber), () => `Block not found [${blockNumber}]`);
|
|
4744
4725
|
return block[0].chain;
|
|
4745
4726
|
}, this.context);
|
|
4746
4727
|
}
|
|
@@ -4876,7 +4857,7 @@ SimpleBlockRewardViewer = __decorateClass([
|
|
|
4876
4857
|
], SimpleBlockRewardViewer);
|
|
4877
4858
|
|
|
4878
4859
|
// src/simple/blockValidation/SimpleBlockValidationViewer.ts
|
|
4879
|
-
import { assertEx as
|
|
4860
|
+
import { assertEx as assertEx36 } from "@xylabs/sdk-js";
|
|
4880
4861
|
import { PayloadBuilder as PayloadBuilder18 } from "@xyo-network/sdk-js";
|
|
4881
4862
|
import {
|
|
4882
4863
|
AccountBalanceViewerMoniker as AccountBalanceViewerMoniker2,
|
|
@@ -4932,7 +4913,7 @@ var SimpleBlockValidationViewer = class extends AbstractCreatableProvider {
|
|
|
4932
4913
|
let head;
|
|
4933
4914
|
if (isChainQualifiedHeadConfig5(config)) {
|
|
4934
4915
|
const headBlockResult = await this.blockViewer.blockByHash(config.head);
|
|
4935
|
-
head = headBlockResult == null ?
|
|
4916
|
+
head = headBlockResult == null ? assertEx36(
|
|
4936
4917
|
void 0,
|
|
4937
4918
|
() => `Specified a head that is not in the chain [${config.head}]`
|
|
4938
4919
|
) : headBlockResult[0];
|
|
@@ -5020,7 +5001,7 @@ SimpleBlockValidationViewer = __decorateClass([
|
|
|
5020
5001
|
], SimpleBlockValidationViewer);
|
|
5021
5002
|
|
|
5022
5003
|
// src/simple/chainContractViewer/SimpleChainContractViewer.ts
|
|
5023
|
-
import { assertEx as
|
|
5004
|
+
import { assertEx as assertEx37 } from "@xylabs/sdk-js";
|
|
5024
5005
|
import { ChainContractViewerMoniker as ChainContractViewerMoniker2, FinalizationViewerMoniker as FinalizationViewerMoniker2 } from "@xyo-network/xl1-protocol-lib";
|
|
5025
5006
|
var SimpleChainContractViewer = class extends AbstractCreatableProvider {
|
|
5026
5007
|
moniker = SimpleChainContractViewer.defaultMoniker;
|
|
@@ -5037,7 +5018,7 @@ var SimpleChainContractViewer = class extends AbstractCreatableProvider {
|
|
|
5037
5018
|
let contractViewer = this;
|
|
5038
5019
|
let forkedAtBlockNumber = await contractViewer.forkedAtBlockNumber();
|
|
5039
5020
|
while (forkedAtBlockNumber !== null && blockNumber <= forkedAtBlockNumber) {
|
|
5040
|
-
contractViewer =
|
|
5021
|
+
contractViewer = assertEx37(await contractViewer.forkedChainContractViewer());
|
|
5041
5022
|
forkedAtBlockNumber = await contractViewer.forkedAtBlockNumber();
|
|
5042
5023
|
chainId = await contractViewer.chainId();
|
|
5043
5024
|
}
|
|
@@ -5092,15 +5073,17 @@ var SimpleXyoClient = class {
|
|
|
5092
5073
|
};
|
|
5093
5074
|
|
|
5094
5075
|
// src/simple/datalake/RestDataLakeRunner.ts
|
|
5095
|
-
import { assertEx as
|
|
5076
|
+
import { assertEx as assertEx39, exists as exists6 } from "@xylabs/sdk-js";
|
|
5096
5077
|
import { isAnyPayload as isAnyPayload8, PayloadZodLoose } from "@xyo-network/sdk-js";
|
|
5097
5078
|
import { DataLakeRunnerMoniker } from "@xyo-network/xl1-protocol-lib";
|
|
5098
|
-
import { z as
|
|
5079
|
+
import { z as z26 } from "zod/mini";
|
|
5099
5080
|
|
|
5100
5081
|
// src/simple/datalake/AbstractRestDataLake.ts
|
|
5101
5082
|
import { FetchClientError, FetchJsonClient } from "@xylabs/sdk-js";
|
|
5102
5083
|
import {
|
|
5103
|
-
|
|
5084
|
+
assertEx as assertEx38,
|
|
5085
|
+
exists as exists5,
|
|
5086
|
+
isDefined as isDefined18
|
|
5104
5087
|
} from "@xylabs/sdk-js";
|
|
5105
5088
|
import { asAnyPayload as asAnyPayload4, isAnyPayload as isAnyPayload7 } from "@xyo-network/sdk-js";
|
|
5106
5089
|
var AbstractRestDataLake = class extends AbstractCreatableProvider {
|
|
@@ -5114,7 +5097,18 @@ var AbstractRestDataLake = class extends AbstractCreatableProvider {
|
|
|
5114
5097
|
return this.params.disallowedSchemas;
|
|
5115
5098
|
}
|
|
5116
5099
|
get endpoint() {
|
|
5117
|
-
return this.params.endpoint;
|
|
5100
|
+
return this.params.endpoint ?? "";
|
|
5101
|
+
}
|
|
5102
|
+
static async paramsHandler(params = {}) {
|
|
5103
|
+
const moniker = this.defaultMoniker;
|
|
5104
|
+
const endpoint = isDefined18(params.endpoint) && params.endpoint !== "" ? params.endpoint : resolveRestConnectionEndpoint(
|
|
5105
|
+
assertEx38(params.context?.config, () => "Context config is required to resolve REST data lake endpoint"),
|
|
5106
|
+
moniker
|
|
5107
|
+
);
|
|
5108
|
+
return {
|
|
5109
|
+
...await super.paramsHandler(params),
|
|
5110
|
+
endpoint
|
|
5111
|
+
};
|
|
5118
5112
|
}
|
|
5119
5113
|
async get(hashes) {
|
|
5120
5114
|
const results = await Promise.all(hashes.map((hash) => this.getOne(hash)));
|
|
@@ -5163,14 +5157,14 @@ var RestDataLakeRunner = class extends AbstractRestDataLake {
|
|
|
5163
5157
|
async insert(items) {
|
|
5164
5158
|
const allowedItems = items.map((item) => {
|
|
5165
5159
|
if (isAnyPayload8(item) && this.isAllowed(item)) {
|
|
5166
|
-
|
|
5160
|
+
assertEx39(typeof item === "object" && item !== null, () => "Data must be an object");
|
|
5167
5161
|
return item;
|
|
5168
5162
|
}
|
|
5169
5163
|
return null;
|
|
5170
5164
|
}).filter(exists6);
|
|
5171
5165
|
if (allowedItems.length > 0) {
|
|
5172
5166
|
const result = await this.client.post(`${this.params.endpoint}/insert`, allowedItems);
|
|
5173
|
-
return
|
|
5167
|
+
return z26.array(PayloadZodLoose).parse(result.data);
|
|
5174
5168
|
}
|
|
5175
5169
|
return [];
|
|
5176
5170
|
}
|
|
@@ -5286,13 +5280,13 @@ SimpleDataLakeViewer = __decorateClass([
|
|
|
5286
5280
|
], SimpleDataLakeViewer);
|
|
5287
5281
|
|
|
5288
5282
|
// src/simple/finalization/SimpleFinalizationRunner.ts
|
|
5289
|
-
import { assertEx as
|
|
5283
|
+
import { assertEx as assertEx40 } from "@xylabs/sdk-js";
|
|
5290
5284
|
import { FinalizationRunnerMoniker } from "@xyo-network/xl1-protocol-lib";
|
|
5291
5285
|
var SimpleFinalizationRunner = class extends AbstractCreatableProvider {
|
|
5292
5286
|
moniker = SimpleFinalizationRunner.defaultMoniker;
|
|
5293
5287
|
_store;
|
|
5294
5288
|
get finalizedArchivist() {
|
|
5295
|
-
return
|
|
5289
|
+
return assertEx40(this.params.finalizedArchivist, () => "finalizedArchivist is required \u2014 inject it or bind a connection");
|
|
5296
5290
|
}
|
|
5297
5291
|
get store() {
|
|
5298
5292
|
return this._store;
|
|
@@ -5302,7 +5296,7 @@ var SimpleFinalizationRunner = class extends AbstractCreatableProvider {
|
|
|
5302
5296
|
const finalizedArchivist = params?.finalizedArchivist ?? (connection ? await connectArchivist(connection, { name: CHAIN_ARCHIVIST_ROLE }) : void 0);
|
|
5303
5297
|
return {
|
|
5304
5298
|
...await super.paramsHandler(params),
|
|
5305
|
-
finalizedArchivist:
|
|
5299
|
+
finalizedArchivist: assertEx40(finalizedArchivist, () => "finalizedArchivist is required \u2014 inject it or bind a connection")
|
|
5306
5300
|
};
|
|
5307
5301
|
}
|
|
5308
5302
|
async createHandler() {
|
|
@@ -5330,7 +5324,7 @@ SimpleFinalizationRunner = __decorateClass([
|
|
|
5330
5324
|
], SimpleFinalizationRunner);
|
|
5331
5325
|
|
|
5332
5326
|
// src/simple/finalization/SimpleFinalizationViewer.ts
|
|
5333
|
-
import { assertEx as
|
|
5327
|
+
import { assertEx as assertEx41 } from "@xylabs/sdk-js";
|
|
5334
5328
|
import {
|
|
5335
5329
|
asSignedHydratedBlockWithStorageMeta as asSignedHydratedBlockWithStorageMeta2,
|
|
5336
5330
|
ChainContractViewerMoniker as ChainContractViewerMoniker3,
|
|
@@ -5342,7 +5336,7 @@ var SimpleFinalizationViewer = class extends AbstractCreatableProvider {
|
|
|
5342
5336
|
_store;
|
|
5343
5337
|
_signedHydratedBlockCache;
|
|
5344
5338
|
get finalizedArchivist() {
|
|
5345
|
-
return
|
|
5339
|
+
return assertEx41(this.params.finalizedArchivist, () => "finalizedArchivist is required \u2014 inject it or bind a connection");
|
|
5346
5340
|
}
|
|
5347
5341
|
get hydratedBlockCache() {
|
|
5348
5342
|
if (this._signedHydratedBlockCache) return this._signedHydratedBlockCache;
|
|
@@ -5361,7 +5355,7 @@ var SimpleFinalizationViewer = class extends AbstractCreatableProvider {
|
|
|
5361
5355
|
const finalizedArchivist = params.finalizedArchivist ?? (connection ? await connectArchivist(connection, { name: CHAIN_ARCHIVIST_ROLE }) : void 0);
|
|
5362
5356
|
return {
|
|
5363
5357
|
...await super.paramsHandler(params),
|
|
5364
|
-
finalizedArchivist:
|
|
5358
|
+
finalizedArchivist: assertEx41(finalizedArchivist, () => "finalizedArchivist is required \u2014 inject it or bind a connection")
|
|
5365
5359
|
};
|
|
5366
5360
|
}
|
|
5367
5361
|
chainId() {
|
|
@@ -5371,18 +5365,18 @@ var SimpleFinalizationViewer = class extends AbstractCreatableProvider {
|
|
|
5371
5365
|
await super.createHandler();
|
|
5372
5366
|
const finalizedArchivist = this.finalizedArchivist;
|
|
5373
5367
|
const mostRecentBlock = await findMostRecentBlock(finalizedArchivist);
|
|
5374
|
-
this._chainId =
|
|
5368
|
+
this._chainId = assertEx41(this.config.chain.id ?? mostRecentBlock?.chain, () => "chain.id is required if empty archivist");
|
|
5375
5369
|
this._store = { chainMap: finalizedArchivist };
|
|
5376
5370
|
}
|
|
5377
5371
|
async head() {
|
|
5378
5372
|
return await this.spanAsync("head", async () => {
|
|
5379
|
-
const currentHead =
|
|
5373
|
+
const currentHead = assertEx41(await this.getCurrentHead(), () => "Could not find most recent block [currentBlock]");
|
|
5380
5374
|
const cache = this.hydratedBlockCache;
|
|
5381
5375
|
const block = await cache.get(currentHead._hash);
|
|
5382
5376
|
if (!block) {
|
|
5383
5377
|
this.logger?.error(`Could not find current block with hash ${currentHead._hash}`);
|
|
5384
5378
|
}
|
|
5385
|
-
return
|
|
5379
|
+
return assertEx41(block, () => "Could not find current block");
|
|
5386
5380
|
}, this.context);
|
|
5387
5381
|
}
|
|
5388
5382
|
async headBlock() {
|
|
@@ -5412,8 +5406,8 @@ var SimpleFinalizationViewer = class extends AbstractCreatableProvider {
|
|
|
5412
5406
|
}
|
|
5413
5407
|
async getCurrentHead() {
|
|
5414
5408
|
const chainArchivist = this.finalizedArchivist;
|
|
5415
|
-
const result =
|
|
5416
|
-
|
|
5409
|
+
const result = assertEx41(await findMostRecentBlock(chainArchivist), () => "Could not find most recent block [getCurrentHead]");
|
|
5410
|
+
assertEx41(result?.chain === this._chainId, () => "Chain ID does not match head block chain ID");
|
|
5417
5411
|
return result;
|
|
5418
5412
|
}
|
|
5419
5413
|
};
|
|
@@ -5445,9 +5439,9 @@ var SimpleXyoGateway = class _SimpleXyoGateway extends AbstractCreatableProvider
|
|
|
5445
5439
|
|
|
5446
5440
|
// src/simple/gateway/SimpleXyoGatewayRunner.ts
|
|
5447
5441
|
import {
|
|
5448
|
-
assertEx as
|
|
5442
|
+
assertEx as assertEx42,
|
|
5449
5443
|
BigIntToJsonZod,
|
|
5450
|
-
isDefined as
|
|
5444
|
+
isDefined as isDefined19
|
|
5451
5445
|
} from "@xylabs/sdk-js";
|
|
5452
5446
|
import { PayloadBuilder as PayloadBuilder20 } from "@xyo-network/sdk-js";
|
|
5453
5447
|
import {
|
|
@@ -5478,23 +5472,23 @@ var SimpleXyoGatewayRunner = class _SimpleXyoGatewayRunner extends AbstractCreat
|
|
|
5478
5472
|
return this._signer;
|
|
5479
5473
|
}
|
|
5480
5474
|
async addPayloadsToChain(onChain, offChain, options) {
|
|
5481
|
-
const viewer =
|
|
5475
|
+
const viewer = assertEx42(this.connection.viewer, () => "No viewer available on connection");
|
|
5482
5476
|
const {
|
|
5483
5477
|
nbf,
|
|
5484
5478
|
exp,
|
|
5485
5479
|
chain,
|
|
5486
5480
|
fees
|
|
5487
5481
|
} = options ?? {};
|
|
5488
|
-
const resolvedChainId =
|
|
5489
|
-
const resolvedNbf = asXL1BlockNumber10(
|
|
5490
|
-
const resolvedExp = asXL1BlockNumber10(
|
|
5482
|
+
const resolvedChainId = isDefined19(chain) ? chain : await viewer.chainId();
|
|
5483
|
+
const resolvedNbf = asXL1BlockNumber10(isDefined19(nbf) ? nbf : await viewer.currentBlockNumber(), true);
|
|
5484
|
+
const resolvedExp = asXL1BlockNumber10(isDefined19(exp) ? exp : resolvedNbf + 10, true);
|
|
5491
5485
|
const tx = await buildUnsignedTransaction(resolvedChainId, onChain, offChain, resolvedNbf, resolvedExp, await this.signer.address(), fees);
|
|
5492
5486
|
return await this.addTransactionToChain(tx, await PayloadBuilder20.addHashMeta(offChain));
|
|
5493
5487
|
}
|
|
5494
5488
|
async addTransactionToChain(tx, offChain = []) {
|
|
5495
5489
|
const connection = this.connection;
|
|
5496
5490
|
const signer = this.signer;
|
|
5497
|
-
const runner =
|
|
5491
|
+
const runner = assertEx42(connection.runner, () => "No runner available on connection");
|
|
5498
5492
|
let signedTx;
|
|
5499
5493
|
if (isSignedHydratedTransaction(tx)) {
|
|
5500
5494
|
const [bw, payloads] = tx;
|
|
@@ -5509,7 +5503,7 @@ var SimpleXyoGatewayRunner = class _SimpleXyoGatewayRunner extends AbstractCreat
|
|
|
5509
5503
|
}
|
|
5510
5504
|
async confirmSubmittedTransaction(txHash, options) {
|
|
5511
5505
|
return await confirmSubmittedTransaction(
|
|
5512
|
-
|
|
5506
|
+
assertEx42(this.connection.viewer, () => "Connection viewer is undefined"),
|
|
5513
5507
|
txHash,
|
|
5514
5508
|
options
|
|
5515
5509
|
);
|
|
@@ -5548,7 +5542,7 @@ var SimpleXyoGatewayRunner = class _SimpleXyoGatewayRunner extends AbstractCreat
|
|
|
5548
5542
|
|
|
5549
5543
|
// src/simple/mempool/SimpleMempoolRunner.ts
|
|
5550
5544
|
import {
|
|
5551
|
-
assertEx as
|
|
5545
|
+
assertEx as assertEx43,
|
|
5552
5546
|
exists as exists8
|
|
5553
5547
|
} from "@xylabs/sdk-js";
|
|
5554
5548
|
import { isPayloadBundle, PayloadBuilder as PayloadBuilder21 } from "@xyo-network/sdk-js";
|
|
@@ -5604,10 +5598,10 @@ var SimpleMempoolRunner = class extends AbstractCreatableProvider {
|
|
|
5604
5598
|
return this.params.maxPendingTransactions ?? 0;
|
|
5605
5599
|
}
|
|
5606
5600
|
get pendingBlocksArchivist() {
|
|
5607
|
-
return
|
|
5601
|
+
return assertEx43(this.params.pendingBlocksArchivist, () => "pendingBlocksArchivist is required \u2014 inject it or bind a connection");
|
|
5608
5602
|
}
|
|
5609
5603
|
get pendingTransactionsArchivist() {
|
|
5610
|
-
return
|
|
5604
|
+
return assertEx43(this.params.pendingTransactionsArchivist, () => "pendingTransactionsArchivist is required \u2014 inject it or bind a connection");
|
|
5611
5605
|
}
|
|
5612
5606
|
get syncInterval() {
|
|
5613
5607
|
return this.params.syncInterval ?? DEFAULT_SYNC_INTERVAL;
|
|
@@ -5627,8 +5621,8 @@ var SimpleMempoolRunner = class extends AbstractCreatableProvider {
|
|
|
5627
5621
|
const pendingTransactionsArchivist = params?.pendingTransactionsArchivist ?? (connection ? await connectArchivist(connection, { name: PENDING_TRANSACTIONS_ARCHIVIST_ROLE }) : void 0);
|
|
5628
5622
|
return {
|
|
5629
5623
|
...await super.paramsHandler(params),
|
|
5630
|
-
pendingBlocksArchivist:
|
|
5631
|
-
pendingTransactionsArchivist:
|
|
5624
|
+
pendingBlocksArchivist: assertEx43(pendingBlocksArchivist, () => "pendingBlocksArchivist is required \u2014 inject it or bind a connection"),
|
|
5625
|
+
pendingTransactionsArchivist: assertEx43(pendingTransactionsArchivist, () => "pendingTransactionsArchivist is required \u2014 inject it or bind a connection")
|
|
5632
5626
|
};
|
|
5633
5627
|
}
|
|
5634
5628
|
async createHandler() {
|
|
@@ -5667,7 +5661,7 @@ var SimpleMempoolRunner = class extends AbstractCreatableProvider {
|
|
|
5667
5661
|
remainingBlockMap.push(i);
|
|
5668
5662
|
return b;
|
|
5669
5663
|
}).filter(exists8);
|
|
5670
|
-
|
|
5664
|
+
assertEx43(
|
|
5671
5665
|
remainingBlockMap.length === remainingBlocks.length,
|
|
5672
5666
|
() => `remainingBlockMap length should match remainingBlocks length [${remainingBlockMap.length}/${remainingBlocks.length}]`
|
|
5673
5667
|
);
|
|
@@ -5730,7 +5724,7 @@ var SimpleMempoolRunner = class extends AbstractCreatableProvider {
|
|
|
5730
5724
|
remainingTransactionMap.push(i);
|
|
5731
5725
|
return t;
|
|
5732
5726
|
}).filter(exists8);
|
|
5733
|
-
|
|
5727
|
+
assertEx43(
|
|
5734
5728
|
remainingTransactionMap.length === remainingTransactions.length,
|
|
5735
5729
|
() => `remainingTransactionMap length should match remainingTransactions length [${remainingTransactionMap.length}/${remainingTransactions.length}]`
|
|
5736
5730
|
);
|
|
@@ -5983,9 +5977,9 @@ SimpleMempoolRunner = __decorateClass([
|
|
|
5983
5977
|
|
|
5984
5978
|
// src/simple/mempool/SimpleMempoolViewer.ts
|
|
5985
5979
|
import {
|
|
5986
|
-
assertEx as
|
|
5980
|
+
assertEx as assertEx44,
|
|
5987
5981
|
exists as exists9,
|
|
5988
|
-
isDefined as
|
|
5982
|
+
isDefined as isDefined20,
|
|
5989
5983
|
isHash as isHash2
|
|
5990
5984
|
} from "@xylabs/sdk-js";
|
|
5991
5985
|
import { isHashMeta as isHashMeta2, isPayloadBundle as isPayloadBundle2 } from "@xyo-network/sdk-js";
|
|
@@ -6004,10 +5998,10 @@ var SimpleMempoolViewer = class extends AbstractCreatableProvider {
|
|
|
6004
5998
|
return this.params.handoutStatsTtlBlocks ?? DEFAULT_HANDOUT_STATS_TTL_BLOCKS;
|
|
6005
5999
|
}
|
|
6006
6000
|
get pendingBlocksArchivist() {
|
|
6007
|
-
return
|
|
6001
|
+
return assertEx44(this.params.pendingBlocksArchivist, () => "pendingBlocksArchivist is required \u2014 inject it or bind a connection");
|
|
6008
6002
|
}
|
|
6009
6003
|
get pendingTransactionsArchivist() {
|
|
6010
|
-
return
|
|
6004
|
+
return assertEx44(this.params.pendingTransactionsArchivist, () => "pendingTransactionsArchivist is required \u2014 inject it or bind a connection");
|
|
6011
6005
|
}
|
|
6012
6006
|
get windowedBlockViewer() {
|
|
6013
6007
|
return this._windowedBlockViewer;
|
|
@@ -6056,7 +6050,7 @@ var SimpleMempoolViewer = class extends AbstractCreatableProvider {
|
|
|
6056
6050
|
let cursor = void 0;
|
|
6057
6051
|
if (isHash2(providedCursor)) {
|
|
6058
6052
|
const [p] = await this.pendingBlocksArchivist.get([providedCursor]);
|
|
6059
|
-
if (
|
|
6053
|
+
if (isDefined20(p)) {
|
|
6060
6054
|
cursor = p._sequence;
|
|
6061
6055
|
}
|
|
6062
6056
|
}
|
|
@@ -6076,7 +6070,7 @@ var SimpleMempoolViewer = class extends AbstractCreatableProvider {
|
|
|
6076
6070
|
let cursor = void 0;
|
|
6077
6071
|
if (isHash2(providedCursor)) {
|
|
6078
6072
|
const [p] = await this.pendingTransactionsArchivist.get([providedCursor]);
|
|
6079
|
-
if (
|
|
6073
|
+
if (isDefined20(p)) {
|
|
6080
6074
|
cursor = p._sequence;
|
|
6081
6075
|
}
|
|
6082
6076
|
}
|
|
@@ -6149,7 +6143,7 @@ var SimpleMempoolViewer = class extends AbstractCreatableProvider {
|
|
|
6149
6143
|
const hydratedResults = await Promise.all(
|
|
6150
6144
|
filteredBundles.map(async (bundle3) => {
|
|
6151
6145
|
const tx = await bundledPayloadToHydratedTransaction(bundle3);
|
|
6152
|
-
return
|
|
6146
|
+
return isDefined20(tx) ? { bundle: bundle3, tx } : void 0;
|
|
6153
6147
|
})
|
|
6154
6148
|
);
|
|
6155
6149
|
return hydratedResults.filter(exists9);
|
|
@@ -6293,7 +6287,7 @@ var SimpleXyoNetwork = class {
|
|
|
6293
6287
|
};
|
|
6294
6288
|
|
|
6295
6289
|
// src/simple/permissions/SimpleXyoPermissions.ts
|
|
6296
|
-
import { assertEx as
|
|
6290
|
+
import { assertEx as assertEx45 } from "@xylabs/sdk-js";
|
|
6297
6291
|
var SimpleXyoPermissions = class {
|
|
6298
6292
|
invoker;
|
|
6299
6293
|
_store;
|
|
@@ -6302,7 +6296,7 @@ var SimpleXyoPermissions = class {
|
|
|
6302
6296
|
this.invoker = store.invoker;
|
|
6303
6297
|
}
|
|
6304
6298
|
get store() {
|
|
6305
|
-
return
|
|
6299
|
+
return assertEx45(this._store, () => "Store must be defined to get permissions");
|
|
6306
6300
|
}
|
|
6307
6301
|
async getPermissions() {
|
|
6308
6302
|
return await this.store.getPermissions();
|
|
@@ -6355,7 +6349,7 @@ var SimpleXyoPermissions = class {
|
|
|
6355
6349
|
};
|
|
6356
6350
|
|
|
6357
6351
|
// src/simple/permissions/store/MemoryPermissions.ts
|
|
6358
|
-
import { assertEx as
|
|
6352
|
+
import { assertEx as assertEx46 } from "@xylabs/sdk-js";
|
|
6359
6353
|
var MemoryPermissionsStore = class {
|
|
6360
6354
|
_invoker;
|
|
6361
6355
|
permissions = [];
|
|
@@ -6363,7 +6357,7 @@ var MemoryPermissionsStore = class {
|
|
|
6363
6357
|
this._invoker = invoker;
|
|
6364
6358
|
}
|
|
6365
6359
|
get invoker() {
|
|
6366
|
-
return
|
|
6360
|
+
return assertEx46(this._invoker, () => "Invoker must be defined to get permissions");
|
|
6367
6361
|
}
|
|
6368
6362
|
async getPermissions() {
|
|
6369
6363
|
await Promise.resolve();
|
|
@@ -6455,7 +6449,7 @@ var SimpleXyoSigner = class _SimpleXyoSigner extends AbstractCreatableProvider {
|
|
|
6455
6449
|
};
|
|
6456
6450
|
|
|
6457
6451
|
// src/simple/StakeEventsViewer/SimpleStakeEventsViewer.ts
|
|
6458
|
-
import { isDefined as
|
|
6452
|
+
import { isDefined as isDefined21 } from "@xylabs/sdk-js";
|
|
6459
6453
|
import { StakeEventsViewerMoniker } from "@xyo-network/xl1-protocol-lib";
|
|
6460
6454
|
var SimpleStakeEventsViewer = class extends AbstractCreatableProvider {
|
|
6461
6455
|
moniker = SimpleStakeEventsViewer.defaultMoniker;
|
|
@@ -6468,7 +6462,7 @@ var SimpleStakeEventsViewer = class extends AbstractCreatableProvider {
|
|
|
6468
6462
|
stakeEvents(range, { name } = {}) {
|
|
6469
6463
|
const positions = this.positionsFromRange(range);
|
|
6470
6464
|
const events = this.eventsFromPositions(positions);
|
|
6471
|
-
if (
|
|
6465
|
+
if (isDefined21(name)) {
|
|
6472
6466
|
return events.filter((event) => event.name === name);
|
|
6473
6467
|
}
|
|
6474
6468
|
return events;
|
|
@@ -6535,7 +6529,7 @@ SimpleStakeEventsViewer = __decorateClass([
|
|
|
6535
6529
|
], SimpleStakeEventsViewer);
|
|
6536
6530
|
|
|
6537
6531
|
// src/simple/StakeTotalsViewer/SimpleStakeTotalsViewer.ts
|
|
6538
|
-
import { assertEx as
|
|
6532
|
+
import { assertEx as assertEx47 } from "@xylabs/sdk-js";
|
|
6539
6533
|
import { asXyoAddress as asXyoAddress3 } from "@xyo-network/sdk-js";
|
|
6540
6534
|
import {
|
|
6541
6535
|
StakeTotalsViewerMoniker,
|
|
@@ -6579,7 +6573,7 @@ var SimpleStakeTotalsViewer = class extends AbstractCreatableProvider {
|
|
|
6579
6573
|
}
|
|
6580
6574
|
async createHandler() {
|
|
6581
6575
|
await super.createHandler();
|
|
6582
|
-
this._stakeViewer =
|
|
6576
|
+
this._stakeViewer = assertEx47(
|
|
6583
6577
|
await this.locateAndCreate(StakeViewerMoniker),
|
|
6584
6578
|
() => "Failed to create StakeViewer"
|
|
6585
6579
|
);
|
|
@@ -6635,14 +6629,14 @@ SimpleStakeTotalsViewer = __decorateClass([
|
|
|
6635
6629
|
], SimpleStakeTotalsViewer);
|
|
6636
6630
|
|
|
6637
6631
|
// src/simple/StakeViewer/SimpleStakeViewer.ts
|
|
6638
|
-
import { assertEx as
|
|
6632
|
+
import { assertEx as assertEx48, toAddress } from "@xylabs/sdk-js";
|
|
6639
6633
|
import { asXyoAddress as asXyoAddress4 } from "@xyo-network/sdk-js";
|
|
6640
6634
|
import { StakeEventsViewerMoniker as StakeEventsViewerMoniker2, StakeViewerMoniker as StakeViewerMoniker2 } from "@xyo-network/xl1-protocol-lib";
|
|
6641
6635
|
var SimpleStakeViewer = class extends AbstractCreatableProvider {
|
|
6642
6636
|
moniker = SimpleStakeViewer.defaultMoniker;
|
|
6643
6637
|
_chainStakeEventsViewer;
|
|
6644
6638
|
get stakeEvents() {
|
|
6645
|
-
return
|
|
6639
|
+
return assertEx48(this._chainStakeEventsViewer, () => "Stake events viewer not set");
|
|
6646
6640
|
}
|
|
6647
6641
|
get positions() {
|
|
6648
6642
|
return this.params.positions;
|
|
@@ -6682,7 +6676,7 @@ var SimpleStakeViewer = class extends AbstractCreatableProvider {
|
|
|
6682
6676
|
}
|
|
6683
6677
|
async createHandler() {
|
|
6684
6678
|
await super.createHandler();
|
|
6685
|
-
this._chainStakeEventsViewer =
|
|
6679
|
+
this._chainStakeEventsViewer = assertEx48(
|
|
6686
6680
|
await this.locateAndCreate(StakeEventsViewerMoniker2),
|
|
6687
6681
|
() => "Failed to create StakeEventsViewer"
|
|
6688
6682
|
);
|
|
@@ -6717,7 +6711,7 @@ var SimpleStakeViewer = class extends AbstractCreatableProvider {
|
|
|
6717
6711
|
return toAddress(toAddress(1n));
|
|
6718
6712
|
}
|
|
6719
6713
|
stakeById(id) {
|
|
6720
|
-
return
|
|
6714
|
+
return assertEx48(this.positions[id], () => new Error(`Stake with id ${id} not found`));
|
|
6721
6715
|
}
|
|
6722
6716
|
stakeByStaker(staker, slot) {
|
|
6723
6717
|
return this.positions.filter((s) => asXyoAddress4(s.staker) === asXyoAddress4(staker))[slot];
|
|
@@ -6821,8 +6815,8 @@ RestSyncViewer = __decorateClass([
|
|
|
6821
6815
|
// src/simple/timeSync2/SimpleTimeSyncViewer.ts
|
|
6822
6816
|
import {
|
|
6823
6817
|
asHash as asHash5,
|
|
6824
|
-
assertEx as
|
|
6825
|
-
isDefined as
|
|
6818
|
+
assertEx as assertEx49,
|
|
6819
|
+
isDefined as isDefined22
|
|
6826
6820
|
} from "@xylabs/sdk-js";
|
|
6827
6821
|
import {
|
|
6828
6822
|
asTimePayload as asTimePayload2,
|
|
@@ -6843,10 +6837,10 @@ var SimpleTimeSyncViewer = class extends AbstractCreatableProvider {
|
|
|
6843
6837
|
async convertTime(fromDomain, toDomain, from) {
|
|
6844
6838
|
switch (fromDomain) {
|
|
6845
6839
|
case "xl1": {
|
|
6846
|
-
const [block, payloads] =
|
|
6840
|
+
const [block, payloads] = assertEx49(await this.blockViewer.blockByNumber(asXL1BlockNumber11(from, true)), () => "Block not found");
|
|
6847
6841
|
const timeSchemaIndex = block.payload_schemas.indexOf(TimeSchema);
|
|
6848
6842
|
const hash = timeSchemaIndex === -1 ? void 0 : block.payload_hashes[timeSchemaIndex];
|
|
6849
|
-
const timePayload = asTimePayload2(
|
|
6843
|
+
const timePayload = asTimePayload2(isDefined22(hash) ? payloads.find((p) => p._hash === hash) : void 0);
|
|
6850
6844
|
if (timePayload === void 0) return 0;
|
|
6851
6845
|
switch (toDomain) {
|
|
6852
6846
|
case "xl1": {
|
|
@@ -6899,10 +6893,10 @@ var SimpleTimeSyncViewer = class extends AbstractCreatableProvider {
|
|
|
6899
6893
|
return [Date.now(), null];
|
|
6900
6894
|
}
|
|
6901
6895
|
case "ethereum": {
|
|
6902
|
-
const provider =
|
|
6896
|
+
const provider = assertEx49(this.ethProvider, () => "Ethereum provider not configured");
|
|
6903
6897
|
const blockNumber = await provider.getBlockNumber() ?? 0;
|
|
6904
6898
|
const block = await provider.getBlock(blockNumber);
|
|
6905
|
-
const blockHash = asHash5(
|
|
6899
|
+
const blockHash = asHash5(assertEx49(block?.hash, () => "Block hash not found"), true);
|
|
6906
6900
|
return [blockNumber, blockHash];
|
|
6907
6901
|
}
|
|
6908
6902
|
default: {
|
|
@@ -6917,10 +6911,10 @@ var SimpleTimeSyncViewer = class extends AbstractCreatableProvider {
|
|
|
6917
6911
|
// this is for the previous block
|
|
6918
6912
|
xl1,
|
|
6919
6913
|
// this is for the previous block
|
|
6920
|
-
xl1Hash:
|
|
6914
|
+
xl1Hash: assertEx49(xl1Hash, () => "No xl1 hash available from time sync service"),
|
|
6921
6915
|
epoch: Date.now()
|
|
6922
6916
|
};
|
|
6923
|
-
if (
|
|
6917
|
+
if (isDefined22(this.ethProvider)) {
|
|
6924
6918
|
const [ethereum, ethHashOrNull] = await this.currentTimeAndHash("ethereum");
|
|
6925
6919
|
const ethereumHash = asHash5(ethHashOrNull, () => "No ethereum hash available from time sync service");
|
|
6926
6920
|
timePayload.ethereum = ethereum;
|
|
@@ -6939,7 +6933,7 @@ SimpleTimeSyncViewer = __decorateClass([
|
|
|
6939
6933
|
], SimpleTimeSyncViewer);
|
|
6940
6934
|
|
|
6941
6935
|
// src/simple/transactionValidation/SimpleTransactionValidationViewer.ts
|
|
6942
|
-
import { assertEx as
|
|
6936
|
+
import { assertEx as assertEx50 } from "@xylabs/sdk-js";
|
|
6943
6937
|
import { PayloadBuilder as PayloadBuilder24 } from "@xyo-network/sdk-js";
|
|
6944
6938
|
import {
|
|
6945
6939
|
AccountBalanceViewerMoniker as AccountBalanceViewerMoniker3,
|
|
@@ -6993,7 +6987,7 @@ var SimpleTransactionValidationViewer = class extends AbstractCreatableProvider
|
|
|
6993
6987
|
let head;
|
|
6994
6988
|
if (isChainQualifiedHeadConfig6(config)) {
|
|
6995
6989
|
const headBlockResult = await this.blockViewer.blockByHash(config.head);
|
|
6996
|
-
head = headBlockResult == null ?
|
|
6990
|
+
head = headBlockResult == null ? assertEx50(
|
|
6997
6991
|
void 0,
|
|
6998
6992
|
() => `Specified a head that is not in the chain [${config.head}]`
|
|
6999
6993
|
) : headBlockResult[0];
|
|
@@ -7065,7 +7059,7 @@ SimpleTransactionValidationViewer = __decorateClass([
|
|
|
7065
7059
|
], SimpleTransactionValidationViewer);
|
|
7066
7060
|
|
|
7067
7061
|
// src/simple/TransactionViewer/SimpleTransactionViewer.ts
|
|
7068
|
-
import { assertEx as
|
|
7062
|
+
import { assertEx as assertEx51, exists as exists10 } from "@xylabs/sdk-js";
|
|
7069
7063
|
import { BoundWitnessSchema } from "@xyo-network/sdk-js";
|
|
7070
7064
|
import {
|
|
7071
7065
|
asSignedHydratedTransactionWithHashMeta,
|
|
@@ -7082,7 +7076,7 @@ var SimpleTransactionViewer = class extends AbstractCreatableProvider {
|
|
|
7082
7076
|
}
|
|
7083
7077
|
async byBlockHashAndIndex(blockHash, transactionIndex) {
|
|
7084
7078
|
return await this.spanAsync("byBlockHashAndIndex", async () => {
|
|
7085
|
-
|
|
7079
|
+
assertEx51(transactionIndex >= 0, () => "transactionIndex must be greater than or equal to 0");
|
|
7086
7080
|
try {
|
|
7087
7081
|
const block = await this.blockViewer.blockByHash(blockHash);
|
|
7088
7082
|
if (!block) return null;
|
|
@@ -7147,7 +7141,7 @@ SimpleTransactionViewer = __decorateClass([
|
|
|
7147
7141
|
|
|
7148
7142
|
// src/simple/windowedBlock/SimpleWindowedBlockViewer.ts
|
|
7149
7143
|
import {
|
|
7150
|
-
assertEx as
|
|
7144
|
+
assertEx as assertEx52,
|
|
7151
7145
|
exists as exists11,
|
|
7152
7146
|
isNull as isNull2
|
|
7153
7147
|
} from "@xylabs/sdk-js";
|
|
@@ -7229,7 +7223,7 @@ var SimpleWindowedBlockViewer = class extends AbstractCreatableProvider {
|
|
|
7229
7223
|
}
|
|
7230
7224
|
async createHandler() {
|
|
7231
7225
|
await super.createHandler();
|
|
7232
|
-
this._blockViewer =
|
|
7226
|
+
this._blockViewer = assertEx52(
|
|
7233
7227
|
this.params.blockViewer ?? await this.locator.getInstance(BlockViewerMoniker7),
|
|
7234
7228
|
() => "BlockViewer instance is required"
|
|
7235
7229
|
);
|
|
@@ -7238,13 +7232,13 @@ var SimpleWindowedBlockViewer = class extends AbstractCreatableProvider {
|
|
|
7238
7232
|
this._transactionHashMap = new MemoryMap2();
|
|
7239
7233
|
}
|
|
7240
7234
|
currentBlock() {
|
|
7241
|
-
return
|
|
7235
|
+
return assertEx52(this._chain.at(-1));
|
|
7242
7236
|
}
|
|
7243
7237
|
currentBlockHash() {
|
|
7244
|
-
return
|
|
7238
|
+
return assertEx52(this._chain.at(-1)?.[0]._hash);
|
|
7245
7239
|
}
|
|
7246
7240
|
currentBlockNumber() {
|
|
7247
|
-
return
|
|
7241
|
+
return assertEx52(this._chain.at(-1)?.[0].block);
|
|
7248
7242
|
}
|
|
7249
7243
|
async payloadByHash(hash) {
|
|
7250
7244
|
const payloads = await this.payloadsByHash([hash]);
|
|
@@ -7405,7 +7399,7 @@ var RuntimeStatusMonitor = class extends LoggerStatusReporter {
|
|
|
7405
7399
|
};
|
|
7406
7400
|
|
|
7407
7401
|
// src/test/buildRandomChain.ts
|
|
7408
|
-
import { asAddress as asAddress2, assertEx as
|
|
7402
|
+
import { asAddress as asAddress2, assertEx as assertEx55 } from "@xylabs/sdk-js";
|
|
7409
7403
|
import {
|
|
7410
7404
|
Account as Account4,
|
|
7411
7405
|
asSchema as asSchema9,
|
|
@@ -7424,7 +7418,7 @@ import {
|
|
|
7424
7418
|
} from "@xyo-network/xl1-protocol-lib";
|
|
7425
7419
|
|
|
7426
7420
|
// src/test/buildBlock.ts
|
|
7427
|
-
import { assertEx as
|
|
7421
|
+
import { assertEx as assertEx53, isDefined as isDefined23 } from "@xylabs/sdk-js";
|
|
7428
7422
|
import {
|
|
7429
7423
|
asAnyPayload as asAnyPayload5,
|
|
7430
7424
|
BoundWitnessBuilder as BoundWitnessBuilder3,
|
|
@@ -7507,8 +7501,8 @@ function buildStepHashes(blockNumber, inStepHashes, previousBlockHash, chainStep
|
|
|
7507
7501
|
const completedStepReward = calculateCompletedStepReward(i, stepRewardPoolBalance);
|
|
7508
7502
|
completedStepRewardTransfers.push(createTransferPayload(chainStepRewardAddress2, { [completedStepRewardHolderAddress]: completedStepReward }));
|
|
7509
7503
|
}
|
|
7510
|
-
step_hashes.push(
|
|
7511
|
-
} else if (
|
|
7504
|
+
step_hashes.push(assertEx53(previousBlockHash, () => `Previous block hash is required for step ${step} at block ${blockNumber}`));
|
|
7505
|
+
} else if (isDefined23(inStepHashes.at(i))) {
|
|
7512
7506
|
step_hashes.push(inStepHashes[i]);
|
|
7513
7507
|
}
|
|
7514
7508
|
}
|
|
@@ -7561,7 +7555,7 @@ async function buildBlock(options) {
|
|
|
7561
7555
|
protocol
|
|
7562
7556
|
}).meta({ $epoch: Date.now(), $signatures: [] }).signers(signers).payloads(await PayloadBuilder25.addStorageMeta(payloads));
|
|
7563
7557
|
const [bw, txPayloads] = await builder.build();
|
|
7564
|
-
|
|
7558
|
+
assertEx53(isBlockBoundWitness(bw), () => "Build of BlockBoundWitness failed");
|
|
7565
7559
|
return [await PayloadBuilder25.addStorageMeta(bw), txPayloads.map((p) => asAnyPayload5(p, true))];
|
|
7566
7560
|
}
|
|
7567
7561
|
|
|
@@ -7582,7 +7576,7 @@ async function buildNextBlock(previousBlock, txs, blockPayloads, signers, chainS
|
|
|
7582
7576
|
}
|
|
7583
7577
|
|
|
7584
7578
|
// src/test/buildRandomGenesisBlock.ts
|
|
7585
|
-
import { asAddress, assertEx as
|
|
7579
|
+
import { asAddress, assertEx as assertEx54 } from "@xylabs/sdk-js";
|
|
7586
7580
|
import {
|
|
7587
7581
|
Account as Account3,
|
|
7588
7582
|
asAnyPayload as asAnyPayload6,
|
|
@@ -7626,7 +7620,7 @@ var buildRandomTransaction = async (chain, payloads, account, nbf = asXL1BlockNu
|
|
|
7626
7620
|
};
|
|
7627
7621
|
|
|
7628
7622
|
// src/test/buildRandomGenesisBlock.ts
|
|
7629
|
-
var TestChainId =
|
|
7623
|
+
var TestChainId = assertEx54(asAddress("c5fe2e6F6841Cbab12d8C0618Be2DF8C6156cC44"));
|
|
7630
7624
|
|
|
7631
7625
|
// src/test/createGenesisBlock.ts
|
|
7632
7626
|
import { PayloadBuilder as PayloadBuilder28 } from "@xyo-network/sdk-js";
|
|
@@ -7681,7 +7675,7 @@ var createGenesisBlock = async (initialBlockProducer, nextContractAddress, genes
|
|
|
7681
7675
|
};
|
|
7682
7676
|
|
|
7683
7677
|
// src/test/buildRandomChain.ts
|
|
7684
|
-
var TestGenesisBlockRewardAddress =
|
|
7678
|
+
var TestGenesisBlockRewardAddress = assertEx55(asAddress2("fa7f0bb865a4bfff3d5e2c726d3e063297014da9"));
|
|
7685
7679
|
var buildRandomChain = async (blockProducer, count = 10, previousBlock, chainId, transactionAccount, receiverAddresses) => {
|
|
7686
7680
|
const chainIdToUse = chainId ?? TestChainId;
|
|
7687
7681
|
const blocks = [];
|
|
@@ -7725,7 +7719,7 @@ var buildRandomChain = async (blockProducer, count = 10, previousBlock, chainId,
|
|
|
7725
7719
|
receiverAddress
|
|
7726
7720
|
));
|
|
7727
7721
|
}
|
|
7728
|
-
const previousBlock2 =
|
|
7722
|
+
const previousBlock2 = assertEx55(lastBlock?.[0], () => new Error("No last block"));
|
|
7729
7723
|
const block = await buildNextBlock(previousBlock2, txs, [], [blockProducer], transactionAccountToUse.address);
|
|
7730
7724
|
blocks.push(block);
|
|
7731
7725
|
remaining = remaining - 1;
|
|
@@ -7786,13 +7780,13 @@ function getTestProviderContext2(config) {
|
|
|
7786
7780
|
}
|
|
7787
7781
|
|
|
7788
7782
|
// src/time/primitives/xl1BlockNumberToEthBlockNumber.ts
|
|
7789
|
-
import { assertEx as
|
|
7783
|
+
import { assertEx as assertEx56 } from "@xylabs/sdk-js";
|
|
7790
7784
|
import { asTimePayload as asTimePayload3, TimeSchema as TimeSchema2 } from "@xyo-network/xl1-protocol-lib";
|
|
7791
7785
|
async function xl1BlockNumberToEthBlockNumber(context, xl1BlockNumber) {
|
|
7792
7786
|
const blockHash = await hashFromBlockNumber(context, xl1BlockNumber);
|
|
7793
7787
|
const hydratedBlock = await hydrateBlock(context, blockHash);
|
|
7794
7788
|
const timePayload = asTimePayload3(hydratedBlock[1].find((p) => p.schema === TimeSchema2), { required: true });
|
|
7795
|
-
return
|
|
7789
|
+
return assertEx56(timePayload.ethereum, () => "No ethereum timestamp found on block");
|
|
7796
7790
|
}
|
|
7797
7791
|
|
|
7798
7792
|
// src/validation/lib/isLocalhost.ts
|
|
@@ -7810,8 +7804,8 @@ var getUrl = (host, port) => {
|
|
|
7810
7804
|
var TODO = true;
|
|
7811
7805
|
|
|
7812
7806
|
// src/validation/schema/Mnemonic.ts
|
|
7813
|
-
import { z as
|
|
7814
|
-
var MnemonicStringZod =
|
|
7807
|
+
import { z as z27 } from "zod";
|
|
7808
|
+
var MnemonicStringZod = z27.string().transform((s) => s.trim().replaceAll(/\s+/g, " ")).refine(
|
|
7815
7809
|
(s) => [12, 15, 18, 21, 24].includes(s.split(" ").length),
|
|
7816
7810
|
{ message: "Mnemonic must contain 12, 15, 18, 21, or 24 words." }
|
|
7817
7811
|
).describe("BIP-39 mnemonic string");
|
|
@@ -7864,8 +7858,6 @@ export {
|
|
|
7864
7858
|
DEFAULT_MIN_CANDIDATES,
|
|
7865
7859
|
DEFAULT_TOLERANCE_MS,
|
|
7866
7860
|
DEFAULT_WALLET_PATH,
|
|
7867
|
-
DataLakeConfigZod,
|
|
7868
|
-
DataLakeDriverConfigBaseZod,
|
|
7869
7861
|
DefaultMetricsScrapePorts,
|
|
7870
7862
|
EIP712DataPayloadFieldsZod,
|
|
7871
7863
|
EIP712DataPayloadSchema,
|
|
@@ -7906,13 +7898,11 @@ export {
|
|
|
7906
7898
|
REJECTED_BLOCKS_ARCHIVIST_ROLE,
|
|
7907
7899
|
REJECTED_TRANSACTIONS_ARCHIVIST_ROLE,
|
|
7908
7900
|
RestTransportConfigZod as RestConnectionConfigZod,
|
|
7909
|
-
RestDataLakeConfigZod,
|
|
7910
7901
|
RestDataLakeRunner,
|
|
7911
7902
|
RestDataLakeViewer,
|
|
7912
7903
|
RestSyncViewer,
|
|
7913
7904
|
RestTransportConfigZod,
|
|
7914
7905
|
RewardMultipliers,
|
|
7915
|
-
RouterDataLakeConfigZod,
|
|
7916
7906
|
RpcTransportConfigZod as RpcConnectionConfigZod,
|
|
7917
7907
|
RpcRemoteConfigBaseZod,
|
|
7918
7908
|
RpcRemoteConfigZod,
|
|
@@ -8124,6 +8114,7 @@ export {
|
|
|
8124
8114
|
resolveConfig,
|
|
8125
8115
|
resolveProviders,
|
|
8126
8116
|
resolveProvidersFromConfig,
|
|
8117
|
+
resolveRestConnectionEndpoint,
|
|
8127
8118
|
rewardFromBlockNumber,
|
|
8128
8119
|
schemasMaxStep,
|
|
8129
8120
|
schemasStepSummaryFromRange,
|