@xyo-network/xl1-protocol-sdk 2.2.3 → 3.0.1
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 +35 -2
- package/dist/neutral/CreatableProvider/AbstractCreatableProvider.d.ts.map +1 -1
- package/dist/neutral/CreatableProvider/CreatableProvider.d.ts +8 -0
- package/dist/neutral/CreatableProvider/CreatableProvider.d.ts.map +1 -1
- package/dist/neutral/capabilities/Capability.d.ts +1 -8
- package/dist/neutral/capabilities/Capability.d.ts.map +1 -1
- package/dist/neutral/capabilities/Provider.d.ts +20 -54
- package/dist/neutral/capabilities/Provider.d.ts.map +1 -1
- package/dist/neutral/capabilities/connectionTypes.d.ts +10 -0
- package/dist/neutral/capabilities/connectionTypes.d.ts.map +1 -0
- package/dist/neutral/capabilities/index.d.ts +4 -0
- package/dist/neutral/capabilities/index.d.ts.map +1 -1
- package/dist/neutral/capabilities/locatorFromConfig.d.ts +29 -0
- package/dist/neutral/capabilities/locatorFromConfig.d.ts.map +1 -0
- package/dist/neutral/capabilities/needsFromProviderBindings.d.ts +8 -0
- package/dist/neutral/capabilities/needsFromProviderBindings.d.ts.map +1 -0
- package/dist/neutral/capabilities/providerCandidateFromClass.d.ts +7 -0
- package/dist/neutral/capabilities/providerCandidateFromClass.d.ts.map +1 -0
- package/dist/neutral/capabilities/resolveProviders.d.ts +29 -22
- package/dist/neutral/capabilities/resolveProviders.d.ts.map +1 -1
- package/dist/neutral/config/Actor.d.ts +216 -12
- package/dist/neutral/config/Actor.d.ts.map +1 -1
- package/dist/neutral/config/Actors.d.ts +41 -2
- package/dist/neutral/config/Actors.d.ts.map +1 -1
- package/dist/neutral/config/Base.d.ts +41 -2
- package/dist/neutral/config/Base.d.ts.map +1 -1
- package/dist/neutral/config/Config.d.ts +152 -8
- package/dist/neutral/config/Config.d.ts.map +1 -1
- package/dist/neutral/config/HostActor.d.ts +216 -12
- package/dist/neutral/config/HostActor.d.ts.map +1 -1
- package/dist/neutral/config/ProviderBinding.d.ts +4 -5
- package/dist/neutral/config/ProviderBinding.d.ts.map +1 -1
- package/dist/neutral/config/adaptLegacyConfig.d.ts +2 -3
- package/dist/neutral/config/adaptLegacyConfig.d.ts.map +1 -1
- package/dist/neutral/config/connections/index.d.ts +6 -0
- package/dist/neutral/config/connections/index.d.ts.map +1 -0
- package/dist/neutral/config/index.d.ts +2 -0
- package/dist/neutral/config/index.d.ts.map +1 -1
- package/dist/neutral/config/normalizeConnectionsConfig.d.ts +20 -0
- package/dist/neutral/config/normalizeConnectionsConfig.d.ts.map +1 -0
- package/dist/neutral/config/transports/Transport.d.ts +18 -3
- package/dist/neutral/config/transports/Transport.d.ts.map +1 -1
- package/dist/neutral/context/Actor.d.ts +216 -12
- package/dist/neutral/context/Actor.d.ts.map +1 -1
- package/dist/neutral/context/HostActor.d.ts +216 -12
- package/dist/neutral/context/HostActor.d.ts.map +1 -1
- package/dist/neutral/getFileConfig.d.ts +70 -4
- package/dist/neutral/getFileConfig.d.ts.map +1 -1
- package/dist/neutral/getFileConfig.mjs +204 -191
- package/dist/neutral/getFileConfig.mjs.map +4 -4
- package/dist/neutral/index.mjs +1120 -822
- package/dist/neutral/index.mjs.map +4 -4
- package/dist/neutral/model/CreatableProviderContext.zod.d.ts +216 -12
- package/dist/neutral/model/CreatableProviderContext.zod.d.ts.map +1 -1
- package/dist/neutral/simple/StakeEventsViewer/SimpleStakeEventsViewer.d.ts +2 -0
- package/dist/neutral/simple/StakeEventsViewer/SimpleStakeEventsViewer.d.ts.map +1 -1
- package/dist/neutral/simple/StakeTotalsViewer/SimpleStakeTotalsViewer.d.ts +2 -0
- package/dist/neutral/simple/StakeTotalsViewer/SimpleStakeTotalsViewer.d.ts.map +1 -1
- package/dist/neutral/simple/StakeViewer/SimpleStakeViewer.d.ts +2 -0
- package/dist/neutral/simple/StakeViewer/SimpleStakeViewer.d.ts.map +1 -1
- package/dist/neutral/simple/TransactionViewer/SimpleTransactionViewer.d.ts +1 -0
- package/dist/neutral/simple/TransactionViewer/SimpleTransactionViewer.d.ts.map +1 -1
- package/dist/neutral/simple/accountBalance/SimpleAccountBalanceViewer.d.ts +2 -0
- package/dist/neutral/simple/accountBalance/SimpleAccountBalanceViewer.d.ts.map +1 -1
- package/dist/neutral/simple/block/SimpleBlockViewer.d.ts +2 -0
- package/dist/neutral/simple/block/SimpleBlockViewer.d.ts.map +1 -1
- package/dist/neutral/simple/blockInvalidation/SimpleBlockInvalidationViewer.d.ts +2 -0
- package/dist/neutral/simple/blockInvalidation/SimpleBlockInvalidationViewer.d.ts.map +1 -1
- package/dist/neutral/simple/blockReward/SimpleBlockRewardViewer.d.ts +2 -0
- package/dist/neutral/simple/blockReward/SimpleBlockRewardViewer.d.ts.map +1 -1
- package/dist/neutral/simple/blockValidation/SimpleBlockValidationViewer.d.ts +2 -0
- package/dist/neutral/simple/blockValidation/SimpleBlockValidationViewer.d.ts.map +1 -1
- package/dist/neutral/simple/chainContractViewer/SimpleChainContractViewer.d.ts +2 -0
- package/dist/neutral/simple/chainContractViewer/SimpleChainContractViewer.d.ts.map +1 -1
- package/dist/neutral/simple/datalake/RestDataLakeRunner.d.ts +2 -0
- package/dist/neutral/simple/datalake/RestDataLakeRunner.d.ts.map +1 -1
- package/dist/neutral/simple/datalake/RestDataLakeViewer.d.ts +2 -0
- package/dist/neutral/simple/datalake/RestDataLakeViewer.d.ts.map +1 -1
- package/dist/neutral/simple/datalake/SimpleDataLakeRunner.d.ts +2 -0
- package/dist/neutral/simple/datalake/SimpleDataLakeRunner.d.ts.map +1 -1
- package/dist/neutral/simple/datalake/SimpleDataLakeViewer.d.ts +2 -0
- package/dist/neutral/simple/datalake/SimpleDataLakeViewer.d.ts.map +1 -1
- package/dist/neutral/simple/finalization/SimpleFinalizationRunner.d.ts +2 -0
- package/dist/neutral/simple/finalization/SimpleFinalizationRunner.d.ts.map +1 -1
- package/dist/neutral/simple/finalization/SimpleFinalizationViewer.d.ts +2 -0
- package/dist/neutral/simple/finalization/SimpleFinalizationViewer.d.ts.map +1 -1
- package/dist/neutral/simple/mempool/SimpleMempoolRunner.d.ts +3 -1
- package/dist/neutral/simple/mempool/SimpleMempoolRunner.d.ts.map +1 -1
- package/dist/neutral/simple/mempool/SimpleMempoolViewer.d.ts +2 -0
- package/dist/neutral/simple/mempool/SimpleMempoolViewer.d.ts.map +1 -1
- package/dist/neutral/simple/runner/SimpleXyoRunner.d.ts +2 -0
- package/dist/neutral/simple/runner/SimpleXyoRunner.d.ts.map +1 -1
- package/dist/neutral/simple/signer/SimpleXyoSigner.d.ts +2 -0
- package/dist/neutral/simple/signer/SimpleXyoSigner.d.ts.map +1 -1
- package/dist/neutral/simple/timeSync2/SimpleTimeSyncViewer.d.ts +2 -0
- package/dist/neutral/simple/timeSync2/SimpleTimeSyncViewer.d.ts.map +1 -1
- package/dist/neutral/simple/transactionValidation/SimpleTransactionValidationViewer.d.ts +2 -0
- package/dist/neutral/simple/transactionValidation/SimpleTransactionValidationViewer.d.ts.map +1 -1
- package/dist/neutral/simple/windowedBlock/SimpleWindowedBlockViewer.d.ts +2 -0
- package/dist/neutral/simple/windowedBlock/SimpleWindowedBlockViewer.d.ts.map +1 -1
- package/dist/neutral/test/index.mjs +210 -191
- package/dist/neutral/test/index.mjs.map +4 -4
- package/package.json +9 -9
package/dist/neutral/index.mjs
CHANGED
|
@@ -1017,6 +1017,18 @@ function filterViewerBySurface(viewer, surface) {
|
|
|
1017
1017
|
};
|
|
1018
1018
|
}
|
|
1019
1019
|
|
|
1020
|
+
// src/capabilities/connectionTypes.ts
|
|
1021
|
+
function descriptorConnectionTypes(descriptor) {
|
|
1022
|
+
return descriptor.connectionTypes ?? [];
|
|
1023
|
+
}
|
|
1024
|
+
function descriptorMatchesConnectionType(descriptor, connectionType) {
|
|
1025
|
+
const types = descriptorConnectionTypes(descriptor);
|
|
1026
|
+
if (types.length === 0) {
|
|
1027
|
+
return true;
|
|
1028
|
+
}
|
|
1029
|
+
return types.includes(connectionType);
|
|
1030
|
+
}
|
|
1031
|
+
|
|
1020
1032
|
// src/capabilities/factoryBrand.ts
|
|
1021
1033
|
function backedFactory(_backings, factory) {
|
|
1022
1034
|
return factory;
|
|
@@ -1028,7 +1040,339 @@ function factoryBackingsCompatible(declared, available) {
|
|
|
1028
1040
|
return backingsSatisfied(declared, available);
|
|
1029
1041
|
}
|
|
1030
1042
|
|
|
1043
|
+
// src/config/normalizeConnectionsConfig.ts
|
|
1044
|
+
function mergeConnectionMaps(transports, connections) {
|
|
1045
|
+
return { ...transports, ...connections };
|
|
1046
|
+
}
|
|
1047
|
+
function normalizeProviderBinding(binding) {
|
|
1048
|
+
const connectionName = binding.connection ?? binding.transport;
|
|
1049
|
+
if (connectionName === void 0 || connectionName === "") {
|
|
1050
|
+
return binding;
|
|
1051
|
+
}
|
|
1052
|
+
return {
|
|
1053
|
+
...binding,
|
|
1054
|
+
connection: connectionName,
|
|
1055
|
+
transport: connectionName
|
|
1056
|
+
};
|
|
1057
|
+
}
|
|
1058
|
+
function normalizeProviderBindings(bindings) {
|
|
1059
|
+
const normalized = {};
|
|
1060
|
+
for (const [moniker, binding] of Object.entries(bindings)) {
|
|
1061
|
+
if (binding === void 0) continue;
|
|
1062
|
+
normalized[moniker] = normalizeProviderBinding(binding);
|
|
1063
|
+
}
|
|
1064
|
+
return normalized;
|
|
1065
|
+
}
|
|
1066
|
+
function normalizeConnectionsConfig(config) {
|
|
1067
|
+
const transports = config.transports ?? {};
|
|
1068
|
+
const connections = config.connections ?? {};
|
|
1069
|
+
const merged = mergeConnectionMaps(transports, connections);
|
|
1070
|
+
return {
|
|
1071
|
+
...config,
|
|
1072
|
+
connections: merged,
|
|
1073
|
+
providerBindings: normalizeProviderBindings(config.providerBindings ?? {}),
|
|
1074
|
+
transports: merged
|
|
1075
|
+
};
|
|
1076
|
+
}
|
|
1077
|
+
function hasDeclaredConnectionProfiles(config) {
|
|
1078
|
+
return Object.keys(config.transports ?? {}).length > 0 || Object.keys(config.connections ?? {}).length > 0;
|
|
1079
|
+
}
|
|
1080
|
+
|
|
1081
|
+
// src/CreatableProvider/ProviderFactoryLocator.ts
|
|
1082
|
+
import { hasAllLabels } from "@xylabs/sdk-js";
|
|
1083
|
+
import { assertEx as assertEx9 } from "@xylabs/sdk-js";
|
|
1084
|
+
|
|
1085
|
+
// src/CreatableProvider/CreatableProviderRegistry.ts
|
|
1086
|
+
import { isTruthy } from "@xylabs/sdk-js";
|
|
1087
|
+
|
|
1088
|
+
// src/CreatableProvider/ProviderFactory.ts
|
|
1089
|
+
import { assertEx as assertEx8 } from "@xylabs/sdk-js";
|
|
1090
|
+
function providerFactoryDescription(factory, labels) {
|
|
1091
|
+
return `${factory.providerName}:${factory.defaultMoniker}:${JSON.stringify(labels ?? factory.labels ?? {})}`;
|
|
1092
|
+
}
|
|
1093
|
+
var ProviderFactory = class _ProviderFactory {
|
|
1094
|
+
creatableProvider;
|
|
1095
|
+
defaultMoniker;
|
|
1096
|
+
defaultParams;
|
|
1097
|
+
dependencies;
|
|
1098
|
+
labels;
|
|
1099
|
+
monikers;
|
|
1100
|
+
providerName;
|
|
1101
|
+
scope;
|
|
1102
|
+
_uniqueId;
|
|
1103
|
+
constructor(creatableProvider2, dependencies, params, labels = {}, scope = "context") {
|
|
1104
|
+
this.creatableProvider = creatableProvider2;
|
|
1105
|
+
this.defaultParams = params;
|
|
1106
|
+
this.defaultMoniker = creatableProvider2.defaultMoniker;
|
|
1107
|
+
this.dependencies = dependencies;
|
|
1108
|
+
this.monikers = creatableProvider2.monikers;
|
|
1109
|
+
this.scope = scope;
|
|
1110
|
+
assertEx8(this.monikers.includes(this.defaultMoniker), () => "defaultMoniker must be in monikers");
|
|
1111
|
+
this.labels = Object.assign({}, creatableProvider2.labels ?? {}, labels ?? {});
|
|
1112
|
+
this.providerName = creatableProvider2.name;
|
|
1113
|
+
this._uniqueId = Symbol(providerFactoryDescription(this));
|
|
1114
|
+
}
|
|
1115
|
+
get resolvedMoniker() {
|
|
1116
|
+
const labels = this.labels ?? {};
|
|
1117
|
+
const labelString = Object.entries(labels).map(([key, value]) => `${key}=${value}`).join(",");
|
|
1118
|
+
return labelString.length === 0 ? this.defaultMoniker : `${this.defaultMoniker}|${labelString}`;
|
|
1119
|
+
}
|
|
1120
|
+
get uniqueId() {
|
|
1121
|
+
return this._uniqueId;
|
|
1122
|
+
}
|
|
1123
|
+
static withParams(creatableProvider2, dependencies, params, labels = {}) {
|
|
1124
|
+
return new _ProviderFactory(creatableProvider2, dependencies, params, labels);
|
|
1125
|
+
}
|
|
1126
|
+
factory(dependencies, params, labels = {}) {
|
|
1127
|
+
return new _ProviderFactory(this.creatableProvider, dependencies, params, labels);
|
|
1128
|
+
}
|
|
1129
|
+
async getInstance(params, { start = true }) {
|
|
1130
|
+
let scopeObject;
|
|
1131
|
+
switch (this.scope) {
|
|
1132
|
+
case "global": {
|
|
1133
|
+
scopeObject = getOrCreateGlobalSingletons();
|
|
1134
|
+
break;
|
|
1135
|
+
}
|
|
1136
|
+
case "context": {
|
|
1137
|
+
const context = assertEx8(
|
|
1138
|
+
params?.context,
|
|
1139
|
+
() => "Context is required for context-scoped providers"
|
|
1140
|
+
);
|
|
1141
|
+
context.singletons ??= {};
|
|
1142
|
+
scopeObject = context.singletons;
|
|
1143
|
+
break;
|
|
1144
|
+
}
|
|
1145
|
+
default: {
|
|
1146
|
+
scopeObject = {};
|
|
1147
|
+
break;
|
|
1148
|
+
}
|
|
1149
|
+
}
|
|
1150
|
+
const mergedParams = {
|
|
1151
|
+
...this.defaultParams,
|
|
1152
|
+
...params
|
|
1153
|
+
};
|
|
1154
|
+
const resultPromise = scopeObject[this.resolvedMoniker] ?? this.creatableProvider.create(mergedParams);
|
|
1155
|
+
scopeObject[this.resolvedMoniker] = resultPromise;
|
|
1156
|
+
const result = await resultPromise;
|
|
1157
|
+
if (start) {
|
|
1158
|
+
assertEx8(await result.start(), () => `Failed to start provider instance [${this.resolvedMoniker}]`);
|
|
1159
|
+
}
|
|
1160
|
+
return result;
|
|
1161
|
+
}
|
|
1162
|
+
async tryGetInstance(params, options) {
|
|
1163
|
+
try {
|
|
1164
|
+
return await this.getInstance(params, options);
|
|
1165
|
+
} catch {
|
|
1166
|
+
return;
|
|
1167
|
+
}
|
|
1168
|
+
}
|
|
1169
|
+
};
|
|
1170
|
+
function getOrCreateGlobalSingletons() {
|
|
1171
|
+
const existing = globalThis.xyoServiceSingletons;
|
|
1172
|
+
if (existing !== void 0) {
|
|
1173
|
+
return existing;
|
|
1174
|
+
}
|
|
1175
|
+
const singletons = {};
|
|
1176
|
+
Reflect.set(globalThis, "xyoServiceSingletons", singletons);
|
|
1177
|
+
return singletons;
|
|
1178
|
+
}
|
|
1179
|
+
|
|
1180
|
+
// src/CreatableProvider/CreatableProviderRegistry.ts
|
|
1181
|
+
var buildProviderFactory = (provider, defaultParams, labels) => {
|
|
1182
|
+
const factory = {
|
|
1183
|
+
monikers: provider.monikers,
|
|
1184
|
+
uniqueId: Symbol(providerFactoryDescription(provider, labels)),
|
|
1185
|
+
// Merge module & supplied labels
|
|
1186
|
+
labels: { ...provider.labels, ...labels },
|
|
1187
|
+
creatableProvider: provider.creatableProvider,
|
|
1188
|
+
dependencies: provider.dependencies,
|
|
1189
|
+
resolvedMoniker: provider.resolvedMoniker,
|
|
1190
|
+
providerName: provider.providerName,
|
|
1191
|
+
scope: provider.scope,
|
|
1192
|
+
defaultParams,
|
|
1193
|
+
getInstance: provider.getInstance.bind(provider),
|
|
1194
|
+
tryGetInstance: provider.tryGetInstance?.bind(provider),
|
|
1195
|
+
defaultMoniker: provider.defaultMoniker,
|
|
1196
|
+
factory: provider.factory.bind(provider)
|
|
1197
|
+
};
|
|
1198
|
+
return factory;
|
|
1199
|
+
};
|
|
1200
|
+
var registerCreatableProviderFactory = (registry, factory, labels, primary = false) => {
|
|
1201
|
+
const primaryMonikers = primary !== true && isTruthy(primary) ? Array.isArray(primary) ? primary : [primary] : [];
|
|
1202
|
+
for (const primaryMoniker of primaryMonikers) {
|
|
1203
|
+
if (!factory.monikers.includes(primaryMoniker)) {
|
|
1204
|
+
throw new Error(`Primary moniker ${String(primaryMoniker)} not found in factory monikers`);
|
|
1205
|
+
}
|
|
1206
|
+
}
|
|
1207
|
+
const isPrimaryForMoniker = (moniker) => {
|
|
1208
|
+
switch (typeof primary) {
|
|
1209
|
+
case "boolean": {
|
|
1210
|
+
return primary;
|
|
1211
|
+
}
|
|
1212
|
+
case "string": {
|
|
1213
|
+
return moniker === primary;
|
|
1214
|
+
}
|
|
1215
|
+
case "object": {
|
|
1216
|
+
if (Array.isArray(primary)) {
|
|
1217
|
+
return primary.includes(moniker);
|
|
1218
|
+
}
|
|
1219
|
+
}
|
|
1220
|
+
}
|
|
1221
|
+
throw new Error(`Invalid primary value: ${String(primary)}`);
|
|
1222
|
+
};
|
|
1223
|
+
const factoryClone = buildProviderFactory(factory, factory.defaultParams, labels);
|
|
1224
|
+
registry[factoryClone.defaultMoniker] = [factoryClone, ...registry[factoryClone.defaultMoniker] ?? []];
|
|
1225
|
+
for (const moniker of factoryClone.monikers) {
|
|
1226
|
+
if (moniker === factoryClone.defaultMoniker) continue;
|
|
1227
|
+
registry[moniker] = isPrimaryForMoniker(moniker) ? [factoryClone, ...registry[moniker] ?? []] : [...registry[moniker] ?? [], factoryClone];
|
|
1228
|
+
}
|
|
1229
|
+
};
|
|
1230
|
+
var registerCreatableProviderFactories = (factories, registry = {}, primary = false) => {
|
|
1231
|
+
for (const factory of factories) {
|
|
1232
|
+
registerCreatableProviderFactory(registry, factory, void 0, primary);
|
|
1233
|
+
}
|
|
1234
|
+
return registry;
|
|
1235
|
+
};
|
|
1236
|
+
|
|
1237
|
+
// src/CreatableProvider/LabeledCreatableProviderFactory.ts
|
|
1238
|
+
var hasLabels = (factory) => {
|
|
1239
|
+
return factory.labels !== void 0;
|
|
1240
|
+
};
|
|
1241
|
+
function labeledCreatableProviderFactory() {
|
|
1242
|
+
return (constructor) => {
|
|
1243
|
+
constructor;
|
|
1244
|
+
};
|
|
1245
|
+
}
|
|
1246
|
+
|
|
1247
|
+
// src/CreatableProvider/ProviderFactoryLocator.ts
|
|
1248
|
+
var ProviderFactoryLocator = class _ProviderFactoryLocator {
|
|
1249
|
+
_context;
|
|
1250
|
+
_registry;
|
|
1251
|
+
_frozen = false;
|
|
1252
|
+
_parent;
|
|
1253
|
+
_validateDepsOnRegister;
|
|
1254
|
+
constructor(context, registry = {}, validateDepsOnRegister = false) {
|
|
1255
|
+
this._registry = registry;
|
|
1256
|
+
this._context = { ...context, locator: this };
|
|
1257
|
+
this._parent = context.locator;
|
|
1258
|
+
this._validateDepsOnRegister = validateDepsOnRegister;
|
|
1259
|
+
}
|
|
1260
|
+
get context() {
|
|
1261
|
+
return this._context;
|
|
1262
|
+
}
|
|
1263
|
+
get logger() {
|
|
1264
|
+
return this.context.logger;
|
|
1265
|
+
}
|
|
1266
|
+
/**
|
|
1267
|
+
* The current registry for the module factory
|
|
1268
|
+
*/
|
|
1269
|
+
get registry() {
|
|
1270
|
+
return this._registry;
|
|
1271
|
+
}
|
|
1272
|
+
get validateDepsOnRegister() {
|
|
1273
|
+
return this._validateDepsOnRegister;
|
|
1274
|
+
}
|
|
1275
|
+
freeze() {
|
|
1276
|
+
this._frozen = true;
|
|
1277
|
+
}
|
|
1278
|
+
async getInstance(moniker, { start = true, labels } = {}) {
|
|
1279
|
+
return assertEx9(
|
|
1280
|
+
await this.tryGetInstance(moniker, { start, labels }),
|
|
1281
|
+
() => `No provider instance for the supplied config moniker [${moniker}]${labels ? ` & labels [${JSON.stringify(labels)}]` : ""} could be created`
|
|
1282
|
+
);
|
|
1283
|
+
}
|
|
1284
|
+
has(moniker) {
|
|
1285
|
+
return Object.hasOwn(this._registry, moniker);
|
|
1286
|
+
}
|
|
1287
|
+
/**
|
|
1288
|
+
* Locates a provider factory that matches the supplied moniker and labels
|
|
1289
|
+
* @param moniker The config moniker for the provider
|
|
1290
|
+
* @param labels The labels for the provider factory
|
|
1291
|
+
* @returns A provider factory that matches the supplied moniker and labels or throws if one is not found
|
|
1292
|
+
*/
|
|
1293
|
+
locate(moniker, labels) {
|
|
1294
|
+
return assertEx9(
|
|
1295
|
+
this.tryLocate(moniker, labels),
|
|
1296
|
+
() => `No module factory for the supplied config moniker [${moniker}]${labels ? ` & labels [${JSON.stringify(labels)}]` : ""} registered`
|
|
1297
|
+
);
|
|
1298
|
+
}
|
|
1299
|
+
merge(locator) {
|
|
1300
|
+
const registry = { ...this.registry };
|
|
1301
|
+
for (const moniker in locator.registry) {
|
|
1302
|
+
const existing = registry[moniker];
|
|
1303
|
+
if (existing === void 0) {
|
|
1304
|
+
registry[moniker] = locator.registry[moniker];
|
|
1305
|
+
} else {
|
|
1306
|
+
existing.push(...locator.registry[moniker] ?? []);
|
|
1307
|
+
}
|
|
1308
|
+
}
|
|
1309
|
+
return new _ProviderFactoryLocator(this.context, registry);
|
|
1310
|
+
}
|
|
1311
|
+
/**
|
|
1312
|
+
* Registers a single module factory (with optional tags) with the locator
|
|
1313
|
+
* @param factory The factory to register
|
|
1314
|
+
* @param labels The labels for the module factory
|
|
1315
|
+
*/
|
|
1316
|
+
register(factory, labels, primary = false) {
|
|
1317
|
+
assertEx9(!this._frozen, () => "Cannot register a module factory after the locator has been frozen");
|
|
1318
|
+
if (this.validateDepsOnRegister) {
|
|
1319
|
+
const missingDeps = factory.dependencies.filter((dep) => !this.registered(dep));
|
|
1320
|
+
assertEx9(missingDeps.length === 0, () => `Cannot register module factory [${factory.uniqueId.description}] due to missing dependencies: ${missingDeps.join(", ")}`);
|
|
1321
|
+
}
|
|
1322
|
+
registerCreatableProviderFactory(this._registry, factory, labels, primary);
|
|
1323
|
+
return this;
|
|
1324
|
+
}
|
|
1325
|
+
/**
|
|
1326
|
+
* Registers multiple module factories with the locator
|
|
1327
|
+
* @param factories The factories to register
|
|
1328
|
+
*/
|
|
1329
|
+
registerMany(factories) {
|
|
1330
|
+
for (const factory of factories) {
|
|
1331
|
+
this.register(factory);
|
|
1332
|
+
}
|
|
1333
|
+
return this;
|
|
1334
|
+
}
|
|
1335
|
+
registered(moniker) {
|
|
1336
|
+
return Object.hasOwn(this.registry, moniker) || (this._parent?.registered(moniker) ?? false);
|
|
1337
|
+
}
|
|
1338
|
+
async tryGetInstance(moniker, { start = true, labels } = {}) {
|
|
1339
|
+
const resolvedParams = { context: this.context };
|
|
1340
|
+
const factory = this.tryLocate(moniker, labels);
|
|
1341
|
+
if (factory !== void 0) {
|
|
1342
|
+
if (Object.hasOwn(this.context.singletons, factory.uniqueId)) {
|
|
1343
|
+
return this.context.singletons[factory.uniqueId];
|
|
1344
|
+
}
|
|
1345
|
+
this.logger?.debug(`Creating provider instance for moniker [${moniker}]${labels ? ` with labels [${JSON.stringify(labels)}]` : ""} using factory [${factory.uniqueId.description}]`);
|
|
1346
|
+
const result = await factory.getInstance(resolvedParams, { start });
|
|
1347
|
+
this.context.singletons[factory.uniqueId] = result;
|
|
1348
|
+
return result;
|
|
1349
|
+
}
|
|
1350
|
+
}
|
|
1351
|
+
/**
|
|
1352
|
+
* Tries to locate a module factory that matches the supplied moniker and labels
|
|
1353
|
+
* @param moniker The config moniker for the module
|
|
1354
|
+
* @param labels The labels for the module factory
|
|
1355
|
+
* @returns A module factory that matches the supplied moniker and labels or undefined
|
|
1356
|
+
*/
|
|
1357
|
+
tryLocate(moniker, labels) {
|
|
1358
|
+
const result = (labels ? this._registry[moniker]?.filter(hasLabels).find((factory) => hasAllLabels(factory?.labels, labels)) ?? this._registry[moniker]?.[0] : this._registry[moniker]?.[0]) ?? this._parent?.tryLocate(moniker, labels);
|
|
1359
|
+
return result;
|
|
1360
|
+
}
|
|
1361
|
+
validateDependencies(recursive = false) {
|
|
1362
|
+
if (recursive) {
|
|
1363
|
+
this._parent?.validateDependencies();
|
|
1364
|
+
}
|
|
1365
|
+
for (const moniker in this.registry) {
|
|
1366
|
+
for (const factory of this.registry[moniker] ?? []) {
|
|
1367
|
+
const missingDeps = factory.dependencies.filter((dep) => !this.registered(dep));
|
|
1368
|
+
assertEx9(missingDeps.length === 0, () => `Module factory [${factory.uniqueId.description}] is missing dependencies: ${missingDeps.join(", ")}`);
|
|
1369
|
+
}
|
|
1370
|
+
}
|
|
1371
|
+
}
|
|
1372
|
+
};
|
|
1373
|
+
|
|
1031
1374
|
// src/capabilities/resolveProviders.ts
|
|
1375
|
+
import { isDefined as isDefined4 } from "@xylabs/sdk-js";
|
|
1032
1376
|
var MissingCapabilityError = class extends Error {
|
|
1033
1377
|
moniker;
|
|
1034
1378
|
reasons;
|
|
@@ -1040,158 +1384,252 @@ var MissingCapabilityError = class extends Error {
|
|
|
1040
1384
|
this.reasons = reasons;
|
|
1041
1385
|
}
|
|
1042
1386
|
};
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1387
|
+
var AmbiguousProviderError = class extends Error {
|
|
1388
|
+
candidates;
|
|
1389
|
+
moniker;
|
|
1390
|
+
constructor(moniker, candidates) {
|
|
1391
|
+
const ids = candidates.map((descriptor) => descriptor.id);
|
|
1392
|
+
super(
|
|
1393
|
+
`Multiple providers satisfy capability '${moniker}' for the requested connection: ${ids.join(", ")}`
|
|
1394
|
+
);
|
|
1395
|
+
this.name = "AmbiguousProviderError";
|
|
1396
|
+
this.moniker = moniker;
|
|
1397
|
+
this.candidates = ids;
|
|
1398
|
+
}
|
|
1399
|
+
};
|
|
1400
|
+
var UnboundProviderError = class extends Error {
|
|
1401
|
+
moniker;
|
|
1402
|
+
constructor(moniker) {
|
|
1403
|
+
super(`Provider "${moniker}" has no providerBindings.connection`);
|
|
1404
|
+
this.name = "UnboundProviderError";
|
|
1405
|
+
this.moniker = moniker;
|
|
1406
|
+
}
|
|
1407
|
+
};
|
|
1408
|
+
var UnknownConnectionError = class extends Error {
|
|
1409
|
+
connectionName;
|
|
1410
|
+
moniker;
|
|
1411
|
+
constructor(moniker, connectionName) {
|
|
1412
|
+
super(
|
|
1413
|
+
`providerBindings.${moniker}.connection references unknown connection "${connectionName}"`
|
|
1414
|
+
);
|
|
1415
|
+
this.name = "UnknownConnectionError";
|
|
1416
|
+
this.moniker = moniker;
|
|
1417
|
+
this.connectionName = connectionName;
|
|
1418
|
+
}
|
|
1419
|
+
};
|
|
1420
|
+
function resolveProviders(needs, candidates, options = {}) {
|
|
1421
|
+
const rejected = [];
|
|
1422
|
+
const wanted = new Set(needs);
|
|
1423
|
+
const bindings = {};
|
|
1424
|
+
const selectedById = /* @__PURE__ */ new Map();
|
|
1425
|
+
const candidatesByMoniker = indexCandidatesByMoniker(candidates);
|
|
1426
|
+
expandBindingClosure(
|
|
1427
|
+
wanted,
|
|
1428
|
+
bindings,
|
|
1429
|
+
selectedById,
|
|
1430
|
+
candidatesByMoniker,
|
|
1431
|
+
rejected,
|
|
1432
|
+
candidates,
|
|
1433
|
+
options
|
|
1434
|
+
);
|
|
1435
|
+
const selected = topoSort(selectedById.values().toArray(), bindings, selectedById);
|
|
1051
1436
|
return {
|
|
1052
1437
|
bindings,
|
|
1053
1438
|
rejected,
|
|
1054
1439
|
selected
|
|
1055
1440
|
};
|
|
1056
1441
|
}
|
|
1057
|
-
function
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
}
|
|
1074
|
-
function expandNeeds(needs, ctx) {
|
|
1075
|
-
const wanted = new Set(needs);
|
|
1076
|
-
const stack = [...needs];
|
|
1077
|
-
while (stack.length > 0) {
|
|
1078
|
-
const moniker = stack.pop();
|
|
1079
|
-
const cap = ctx.capabilities.tryGet(moniker);
|
|
1080
|
-
if (!cap?.implies) continue;
|
|
1081
|
-
for (const dep of cap.implies) {
|
|
1082
|
-
if (!wanted.has(dep)) {
|
|
1083
|
-
wanted.add(dep);
|
|
1084
|
-
stack.push(dep);
|
|
1442
|
+
function expandBindingClosure(wanted, bindings, selectedById, candidatesByMoniker, rejected, allCandidates, options) {
|
|
1443
|
+
let grew = true;
|
|
1444
|
+
while (grew) {
|
|
1445
|
+
grew = false;
|
|
1446
|
+
for (const moniker of [...wanted].toSorted((a, b) => a.localeCompare(b))) {
|
|
1447
|
+
if (!Object.hasOwn(bindings, moniker)) {
|
|
1448
|
+
grew = bindMoniker(
|
|
1449
|
+
moniker,
|
|
1450
|
+
wanted,
|
|
1451
|
+
bindings,
|
|
1452
|
+
selectedById,
|
|
1453
|
+
candidatesByMoniker,
|
|
1454
|
+
rejected,
|
|
1455
|
+
allCandidates,
|
|
1456
|
+
options
|
|
1457
|
+
) || grew;
|
|
1085
1458
|
}
|
|
1086
1459
|
}
|
|
1087
1460
|
}
|
|
1088
|
-
return wanted;
|
|
1089
1461
|
}
|
|
1090
|
-
function
|
|
1091
|
-
const
|
|
1092
|
-
const
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
}
|
|
1462
|
+
function bindMoniker(moniker, wanted, bindings, selectedById, candidatesByMoniker, rejected, allCandidates, options) {
|
|
1463
|
+
const connectionName = connectionNameForMoniker(moniker, options);
|
|
1464
|
+
const connection = options.connections?.[connectionName];
|
|
1465
|
+
if (!isDefined4(connection)) {
|
|
1466
|
+
throw new UnknownConnectionError(moniker, connectionName);
|
|
1467
|
+
}
|
|
1468
|
+
const group = candidatesByMoniker.get(moniker) ?? [];
|
|
1469
|
+
const { filtered, rejected: connectionRejected } = filterByConnection(
|
|
1470
|
+
group,
|
|
1471
|
+
connection.type,
|
|
1472
|
+
connectionName
|
|
1473
|
+
);
|
|
1474
|
+
rejected.push(...connectionRejected);
|
|
1475
|
+
if (filtered.length === 0) {
|
|
1476
|
+
throw new MissingCapabilityError(moniker, reasonsFor(moniker, rejected, allCandidates));
|
|
1106
1477
|
}
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1478
|
+
if (filtered.length > 1) {
|
|
1479
|
+
throw new AmbiguousProviderError(moniker, filtered);
|
|
1480
|
+
}
|
|
1481
|
+
const winner = filtered[0];
|
|
1482
|
+
bindings[moniker] = winner.id;
|
|
1483
|
+
selectedById.set(winner.id, winner);
|
|
1484
|
+
let grew = false;
|
|
1485
|
+
for (const dep of winner.dependencies ?? []) {
|
|
1486
|
+
if (!wanted.has(dep)) {
|
|
1487
|
+
wanted.add(dep);
|
|
1488
|
+
grew = true;
|
|
1113
1489
|
}
|
|
1114
|
-
const list = byCapability.get(moniker) ?? [];
|
|
1115
|
-
list.push(descriptor);
|
|
1116
|
-
byCapability.set(moniker, list);
|
|
1117
1490
|
}
|
|
1491
|
+
return grew;
|
|
1118
1492
|
}
|
|
1119
|
-
function
|
|
1120
|
-
const
|
|
1121
|
-
|
|
1122
|
-
|
|
1493
|
+
function connectionNameForMoniker(moniker, options) {
|
|
1494
|
+
const binding = options.providerBindings?.[moniker];
|
|
1495
|
+
const connectionName = binding?.connection ?? binding?.transport;
|
|
1496
|
+
if (!isDefined4(connectionName) || connectionName === "") {
|
|
1497
|
+
throw new UnboundProviderError(moniker);
|
|
1123
1498
|
}
|
|
1124
|
-
return
|
|
1499
|
+
return connectionName;
|
|
1125
1500
|
}
|
|
1126
|
-
function
|
|
1127
|
-
const
|
|
1128
|
-
const
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
const pinnedGroup = group?.filter((descriptor) => descriptor.id === pinned);
|
|
1134
|
-
if (!pinnedGroup || pinnedGroup.length === 0) {
|
|
1135
|
-
throw new MissingCapabilityError(moniker, [`requested implementation '${pinned}' not available`]);
|
|
1136
|
-
}
|
|
1137
|
-
group = pinnedGroup;
|
|
1138
|
-
}
|
|
1139
|
-
if (!group || group.length === 0) {
|
|
1140
|
-
throw new MissingCapabilityError(moniker, reasonsFor(moniker, rejected, allCandidates));
|
|
1501
|
+
function indexCandidatesByMoniker(candidates) {
|
|
1502
|
+
const byMoniker = /* @__PURE__ */ new Map();
|
|
1503
|
+
for (const descriptor of candidates) {
|
|
1504
|
+
for (const moniker of descriptor.satisfies) {
|
|
1505
|
+
const list = byMoniker.get(moniker) ?? [];
|
|
1506
|
+
list.push(descriptor);
|
|
1507
|
+
byMoniker.set(moniker, list);
|
|
1141
1508
|
}
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1509
|
+
}
|
|
1510
|
+
return byMoniker;
|
|
1511
|
+
}
|
|
1512
|
+
function filterByConnection(group, connectionType, connectionName) {
|
|
1513
|
+
const rejected = [];
|
|
1514
|
+
const filtered = group.filter((descriptor) => {
|
|
1515
|
+
const matches = descriptorMatchesConnectionType(descriptor, connectionType);
|
|
1516
|
+
if (!matches) {
|
|
1517
|
+
const types = descriptor.connectionTypes;
|
|
1147
1518
|
rejected.push({
|
|
1148
|
-
descriptor
|
|
1149
|
-
reason: `
|
|
1519
|
+
descriptor,
|
|
1520
|
+
reason: `connection "${connectionName}" is type "${connectionType}" but descriptor supports [${types.join(", ")}]`
|
|
1150
1521
|
});
|
|
1151
1522
|
}
|
|
1152
|
-
|
|
1153
|
-
|
|
1523
|
+
return matches;
|
|
1524
|
+
});
|
|
1525
|
+
return { filtered, rejected };
|
|
1154
1526
|
}
|
|
1155
1527
|
function reasonsFor(moniker, rejected, allCandidates) {
|
|
1156
|
-
const candidatesForMoniker = allCandidates.filter((
|
|
1157
|
-
if (candidatesForMoniker.length === 0)
|
|
1158
|
-
|
|
1159
|
-
}
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
const
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1528
|
+
const candidatesForMoniker = allCandidates.filter((candidate) => candidate.satisfies.includes(moniker));
|
|
1529
|
+
if (candidatesForMoniker.length === 0) {
|
|
1530
|
+
return [];
|
|
1531
|
+
}
|
|
1532
|
+
return rejected.filter((rejection) => rejection.descriptor.satisfies.includes(moniker)).map((rejection) => `${rejection.descriptor.id}: ${rejection.reason}`);
|
|
1533
|
+
}
|
|
1534
|
+
function topoSort(descriptors, bindings, selectedById) {
|
|
1535
|
+
const monikerToDescriptor = /* @__PURE__ */ new Map();
|
|
1536
|
+
for (const [moniker, id] of Object.entries(bindings)) {
|
|
1537
|
+
const descriptor = selectedById.get(id);
|
|
1538
|
+
if (descriptor !== void 0) {
|
|
1539
|
+
monikerToDescriptor.set(moniker, descriptor);
|
|
1540
|
+
}
|
|
1541
|
+
}
|
|
1170
1542
|
const order = [];
|
|
1171
1543
|
const seen = /* @__PURE__ */ new Set();
|
|
1172
1544
|
const visiting = /* @__PURE__ */ new Set();
|
|
1173
|
-
const visit = (
|
|
1174
|
-
if (seen.has(
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1545
|
+
const visit = (descriptor) => {
|
|
1546
|
+
if (seen.has(descriptor.id)) {
|
|
1547
|
+
return;
|
|
1548
|
+
}
|
|
1549
|
+
if (visiting.has(descriptor.id)) {
|
|
1550
|
+
return;
|
|
1551
|
+
}
|
|
1552
|
+
visiting.add(descriptor.id);
|
|
1553
|
+
for (const depMoniker of descriptor.dependencies ?? []) {
|
|
1554
|
+
const depDescriptor = monikerToDescriptor.get(depMoniker);
|
|
1555
|
+
if (depDescriptor !== void 0) {
|
|
1556
|
+
visit(depDescriptor);
|
|
1185
1557
|
}
|
|
1186
1558
|
}
|
|
1187
|
-
visiting.delete(
|
|
1188
|
-
seen.add(
|
|
1189
|
-
order.push(
|
|
1559
|
+
visiting.delete(descriptor.id);
|
|
1560
|
+
seen.add(descriptor.id);
|
|
1561
|
+
order.push(descriptor);
|
|
1190
1562
|
};
|
|
1191
|
-
for (const
|
|
1563
|
+
for (const descriptor of descriptors) {
|
|
1564
|
+
visit(descriptor);
|
|
1565
|
+
}
|
|
1192
1566
|
return order;
|
|
1193
1567
|
}
|
|
1194
1568
|
|
|
1569
|
+
// src/capabilities/locatorFromConfig.ts
|
|
1570
|
+
function resolveProvidersFromConfig(needs, candidates, config) {
|
|
1571
|
+
const normalized = normalizeConnectionsConfig(config);
|
|
1572
|
+
return resolveProviders(needs, candidates, {
|
|
1573
|
+
connections: normalized.connections,
|
|
1574
|
+
providerBindings: normalized.providerBindings
|
|
1575
|
+
});
|
|
1576
|
+
}
|
|
1577
|
+
function registerFactoriesFromPlan(locator, plan) {
|
|
1578
|
+
for (const descriptor of plan.selected) {
|
|
1579
|
+
const { creatableProvider: creatableProvider2 } = descriptor;
|
|
1580
|
+
const dependencies = [...descriptor.dependencies ?? creatableProvider2.dependencies];
|
|
1581
|
+
locator.register(creatableProvider2.factory(dependencies, {}));
|
|
1582
|
+
}
|
|
1583
|
+
}
|
|
1584
|
+
function locatorFromConfig(options) {
|
|
1585
|
+
const normalized = normalizeConnectionsConfig(options.config);
|
|
1586
|
+
const plan = resolveProvidersFromConfig(options.needs, options.candidates, normalized);
|
|
1587
|
+
const locator = new ProviderFactoryLocator({
|
|
1588
|
+
singletons: {},
|
|
1589
|
+
caches: {},
|
|
1590
|
+
...options.context,
|
|
1591
|
+
config: normalized
|
|
1592
|
+
});
|
|
1593
|
+
registerFactoriesFromPlan(locator, plan);
|
|
1594
|
+
return locator;
|
|
1595
|
+
}
|
|
1596
|
+
|
|
1597
|
+
// src/capabilities/needsFromProviderBindings.ts
|
|
1598
|
+
function needsFromProviderBindings(config) {
|
|
1599
|
+
return new Set(Object.keys(config.providerBindings));
|
|
1600
|
+
}
|
|
1601
|
+
function needsFromConnectionTypes(config, connectionTypes) {
|
|
1602
|
+
const allowed = new Set(connectionTypes);
|
|
1603
|
+
const needs = /* @__PURE__ */ new Set();
|
|
1604
|
+
for (const moniker of Object.keys(config.providerBindings)) {
|
|
1605
|
+
const binding = config.providerBindings[moniker];
|
|
1606
|
+
const connectionName = binding?.connection ?? binding?.transport;
|
|
1607
|
+
if (connectionName === void 0 || connectionName === "") {
|
|
1608
|
+
continue;
|
|
1609
|
+
}
|
|
1610
|
+
const connection = config.connections[connectionName];
|
|
1611
|
+
if (connection !== void 0 && allowed.has(connection.type)) {
|
|
1612
|
+
needs.add(moniker);
|
|
1613
|
+
}
|
|
1614
|
+
}
|
|
1615
|
+
return needs;
|
|
1616
|
+
}
|
|
1617
|
+
|
|
1618
|
+
// src/capabilities/providerCandidateFromClass.ts
|
|
1619
|
+
function providerCandidateFromClass(creatableProvider2, id = creatableProvider2.name) {
|
|
1620
|
+
return {
|
|
1621
|
+
connectionTypes: creatableProvider2.connectionTypes ?? [],
|
|
1622
|
+
creatableProvider: creatableProvider2,
|
|
1623
|
+
dependencies: creatableProvider2.dependencies,
|
|
1624
|
+
id,
|
|
1625
|
+
satisfies: creatableProvider2.monikers,
|
|
1626
|
+
surface: creatableProvider2.surface ?? "node"
|
|
1627
|
+
};
|
|
1628
|
+
}
|
|
1629
|
+
function providerCandidatesFromClasses(creatableProviders) {
|
|
1630
|
+
return creatableProviders.map((provider) => providerCandidateFromClass(provider));
|
|
1631
|
+
}
|
|
1632
|
+
|
|
1195
1633
|
// src/config/Actor.ts
|
|
1196
1634
|
import {
|
|
1197
1635
|
zodAsFactory as zodAsFactory3,
|
|
@@ -1220,16 +1658,191 @@ var ChainConfigZod = z2.object({
|
|
|
1220
1658
|
})
|
|
1221
1659
|
});
|
|
1222
1660
|
|
|
1661
|
+
// src/config/transports/Transport.ts
|
|
1662
|
+
import { globalRegistry as globalRegistry4, z as z6 } from "zod";
|
|
1663
|
+
|
|
1664
|
+
// src/config/Remote.ts
|
|
1665
|
+
import { globalRegistry as globalRegistry2, z as z3 } from "zod";
|
|
1666
|
+
var RpcRemoteConfigBaseZod = z3.object({
|
|
1667
|
+
protocol: z3.string("http").register(globalRegistry2, {
|
|
1668
|
+
description: "Protocol for the RPC connection",
|
|
1669
|
+
type: "string"
|
|
1670
|
+
})
|
|
1671
|
+
}).describe("Base configuration for the remote RPC");
|
|
1672
|
+
var HttpRpcRemoteConfigZod = RpcRemoteConfigBaseZod.extend({
|
|
1673
|
+
protocol: z3.string("http").register(globalRegistry2, {
|
|
1674
|
+
description: "Protocol for the RPC connection",
|
|
1675
|
+
type: "string"
|
|
1676
|
+
}).default("http"),
|
|
1677
|
+
url: z3.string().register(globalRegistry2, {
|
|
1678
|
+
description: "URL for the Chain RPC API",
|
|
1679
|
+
type: "string"
|
|
1680
|
+
})
|
|
1681
|
+
}).describe("Configuration for the remote RPC using Http");
|
|
1682
|
+
var PostMessageRpcRemoteConfigZod = RpcRemoteConfigBaseZod.extend({
|
|
1683
|
+
protocol: z3.string().register(globalRegistry2, {
|
|
1684
|
+
description: "Protocol for the RPC connection",
|
|
1685
|
+
type: "string"
|
|
1686
|
+
}).default("postMessage"),
|
|
1687
|
+
networkId: z3.string().register(globalRegistry2, {
|
|
1688
|
+
description: "Network ID to use for the postMessage RPC connection",
|
|
1689
|
+
type: "string"
|
|
1690
|
+
}),
|
|
1691
|
+
sessionId: z3.string().register(globalRegistry2, {
|
|
1692
|
+
description: "Session ID to use for the postMessage RPC connection",
|
|
1693
|
+
type: "string"
|
|
1694
|
+
})
|
|
1695
|
+
}).describe("Configuration for the remote RPC using postMessage");
|
|
1696
|
+
var RpcRemoteConfigZod = z3.union([HttpRpcRemoteConfigZod, PostMessageRpcRemoteConfigZod]).describe("Configuration for a remote RPC connection, either Http or postMessage");
|
|
1697
|
+
var RemoteConfigZod = z3.object({ rpc: RpcRemoteConfigZod.optional() }).describe("Configuration for remote connections, including RPC");
|
|
1698
|
+
|
|
1699
|
+
// src/config/storage/driver/Mongo.ts
|
|
1700
|
+
import { isDefined as isDefined5, isUndefined as isUndefined5 } from "@xylabs/sdk-js";
|
|
1701
|
+
import { globalRegistry as globalRegistry3, z as z4 } from "zod";
|
|
1702
|
+
var hasMongoConfig = (config) => {
|
|
1703
|
+
if (isUndefined5(config)) return false;
|
|
1704
|
+
return isDefined5(config.connectionString) && isDefined5(config.database) && isDefined5(config.domain);
|
|
1705
|
+
};
|
|
1706
|
+
var MongoConfigZod = z4.object({
|
|
1707
|
+
// TODO: Create from other arguments
|
|
1708
|
+
connectionString: z4.string().nonempty().optional().register(globalRegistry3, {
|
|
1709
|
+
description: "MongoDB connection string",
|
|
1710
|
+
title: "storage.mongo.connectionString",
|
|
1711
|
+
type: "string"
|
|
1712
|
+
}),
|
|
1713
|
+
database: z4.string().nonempty().optional().register(globalRegistry3, {
|
|
1714
|
+
description: "MongoDB database name",
|
|
1715
|
+
title: "storage.mongo.database",
|
|
1716
|
+
type: "string"
|
|
1717
|
+
}),
|
|
1718
|
+
domain: z4.string().nonempty().optional().register(globalRegistry3, {
|
|
1719
|
+
description: "MongoDB domain",
|
|
1720
|
+
title: "storage.mongo.domain",
|
|
1721
|
+
type: "string"
|
|
1722
|
+
}),
|
|
1723
|
+
password: z4.string().nonempty().optional().register(globalRegistry3, {
|
|
1724
|
+
description: "MongoDB password",
|
|
1725
|
+
title: "storage.mongo.password",
|
|
1726
|
+
type: "string"
|
|
1727
|
+
}),
|
|
1728
|
+
username: z4.string().nonempty().optional().register(globalRegistry3, {
|
|
1729
|
+
description: "MongoDB username",
|
|
1730
|
+
title: "storage.mongo.username",
|
|
1731
|
+
type: "string"
|
|
1732
|
+
})
|
|
1733
|
+
});
|
|
1734
|
+
|
|
1735
|
+
// src/config/storage/driver/S3.ts
|
|
1736
|
+
import { isDefined as isDefined6 } from "@xylabs/sdk-js";
|
|
1737
|
+
import { z as z5 } from "zod";
|
|
1738
|
+
var S3BucketConfigZod = z5.object({
|
|
1739
|
+
accessKeyId: z5.string().nonempty().optional().describe("S3-compatible access key id for this bucket (overrides the shared default)"),
|
|
1740
|
+
accountId: z5.string().nonempty().optional().describe("Account id for this bucket; on Cloudflare R2 it forms the endpoint (overrides the shared default)"),
|
|
1741
|
+
bucket: z5.string().nonempty().optional().describe("S3-compatible bucket name"),
|
|
1742
|
+
prefix: z5.string().nonempty().optional().describe("Optional key prefix within the bucket"),
|
|
1743
|
+
readUrl: z5.string().nonempty().optional().describe("Public HTTP/CDN base URL for anonymous reads of this bucket"),
|
|
1744
|
+
secretAccessKey: z5.string().nonempty().optional().describe("S3-compatible secret access key for this bucket (overrides the shared default)")
|
|
1745
|
+
});
|
|
1746
|
+
var S3ConfigZod = z5.object({
|
|
1747
|
+
accessKeyId: z5.string().nonempty().optional().describe("Shared S3-compatible access key id (default for all buckets)"),
|
|
1748
|
+
accountId: z5.string().nonempty().optional().describe("Shared account id (default for all buckets; on Cloudflare R2 it forms the endpoint)"),
|
|
1749
|
+
chainState: S3BucketConfigZod.optional().describe("Bucket for the mutable chain state (the head pointer)"),
|
|
1750
|
+
finalized: S3BucketConfigZod.optional().describe("Bucket for the finalized files (blocks, payloads, manifest)"),
|
|
1751
|
+
index: S3BucketConfigZod.optional().describe("Bucket for the chain index (the step-summary families)"),
|
|
1752
|
+
prefix: z5.string().nonempty().optional().describe("Shared key prefix (default for all buckets)"),
|
|
1753
|
+
secretAccessKey: z5.string().nonempty().optional().describe("Shared S3-compatible secret access key (default for all buckets)")
|
|
1754
|
+
});
|
|
1755
|
+
function resolveS3Bucket(config, which) {
|
|
1756
|
+
if (config === void 0) return void 0;
|
|
1757
|
+
const entry = config[which];
|
|
1758
|
+
const accessKeyId = entry?.accessKeyId ?? config.accessKeyId;
|
|
1759
|
+
const accountId = entry?.accountId ?? config.accountId;
|
|
1760
|
+
const secretAccessKey = entry?.secretAccessKey ?? config.secretAccessKey;
|
|
1761
|
+
const bucket = entry?.bucket ?? config.finalized?.bucket;
|
|
1762
|
+
if (!isDefined6(accessKeyId) || !isDefined6(accountId) || !isDefined6(secretAccessKey) || !isDefined6(bucket)) return void 0;
|
|
1763
|
+
return {
|
|
1764
|
+
accessKeyId,
|
|
1765
|
+
accountId,
|
|
1766
|
+
bucket,
|
|
1767
|
+
prefix: entry?.prefix ?? config.prefix,
|
|
1768
|
+
readUrl: entry?.readUrl,
|
|
1769
|
+
secretAccessKey
|
|
1770
|
+
};
|
|
1771
|
+
}
|
|
1772
|
+
function hasS3Config(config, which = "finalized") {
|
|
1773
|
+
return resolveS3Bucket(config, which) !== void 0;
|
|
1774
|
+
}
|
|
1775
|
+
|
|
1776
|
+
// src/config/transports/Transport.ts
|
|
1777
|
+
var LmdbTransportConfigZod = z6.object({
|
|
1778
|
+
access: z6.enum(["read", "write"]).optional().register(globalRegistry4, {
|
|
1779
|
+
description: "Access mode for this LMDB connection (read or write)",
|
|
1780
|
+
title: "transports.lmdb.access",
|
|
1781
|
+
type: "string"
|
|
1782
|
+
}),
|
|
1783
|
+
root: z6.string().register(globalRegistry4, {
|
|
1784
|
+
description: "Root directory for local LMDB storage",
|
|
1785
|
+
title: "transports.lmdb.root",
|
|
1786
|
+
type: "string"
|
|
1787
|
+
}),
|
|
1788
|
+
store: z6.string().optional().register(globalRegistry4, {
|
|
1789
|
+
description: "Logical store name within the LMDB root (e.g. finalized-chain, mempool)",
|
|
1790
|
+
title: "transports.lmdb.store",
|
|
1791
|
+
type: "string"
|
|
1792
|
+
}),
|
|
1793
|
+
type: z6.literal("lmdb")
|
|
1794
|
+
}).describe("LMDB local storage transport");
|
|
1795
|
+
var MongoTransportConfigZod = z6.object({
|
|
1796
|
+
type: z6.literal("mongo"),
|
|
1797
|
+
connectionString: MongoConfigZod.shape.connectionString,
|
|
1798
|
+
database: MongoConfigZod.shape.database,
|
|
1799
|
+
domain: MongoConfigZod.shape.domain,
|
|
1800
|
+
password: MongoConfigZod.shape.password,
|
|
1801
|
+
username: MongoConfigZod.shape.username
|
|
1802
|
+
}).describe("MongoDB storage transport");
|
|
1803
|
+
var RpcTransportConfigZod = HttpRpcRemoteConfigZod.extend({ type: z6.literal("rpc") }).describe("XL1 JSON-RPC transport");
|
|
1804
|
+
var RestTransportConfigZod = z6.object({
|
|
1805
|
+
type: z6.literal("rest"),
|
|
1806
|
+
baseUrl: z6.string().register(globalRegistry4, {
|
|
1807
|
+
description: "HTTP base URL for REST reads",
|
|
1808
|
+
title: "transports.rest.baseUrl",
|
|
1809
|
+
type: "string"
|
|
1810
|
+
})
|
|
1811
|
+
}).describe("HTTP REST read transport");
|
|
1812
|
+
var S3TransportConfigZod = S3BucketConfigZod.extend({
|
|
1813
|
+
type: z6.literal("s3"),
|
|
1814
|
+
accessKeyId: z6.string().optional(),
|
|
1815
|
+
accountId: z6.string().optional(),
|
|
1816
|
+
secretAccessKey: z6.string().optional()
|
|
1817
|
+
}).describe("S3-compatible object storage transport");
|
|
1818
|
+
var EvmRpcTransportConfigZod = z6.object({
|
|
1819
|
+
type: z6.literal("evm-rpc"),
|
|
1820
|
+
url: z6.string().register(globalRegistry4, {
|
|
1821
|
+
description: "EVM JSON-RPC URL",
|
|
1822
|
+
title: "transports.evm-rpc.url",
|
|
1823
|
+
type: "string"
|
|
1824
|
+
})
|
|
1825
|
+
}).describe("EVM JSON-RPC transport");
|
|
1826
|
+
var TransportConfigZod = z6.discriminatedUnion("type", [
|
|
1827
|
+
LmdbTransportConfigZod,
|
|
1828
|
+
MongoTransportConfigZod,
|
|
1829
|
+
RpcTransportConfigZod,
|
|
1830
|
+
RestTransportConfigZod,
|
|
1831
|
+
S3TransportConfigZod,
|
|
1832
|
+
EvmRpcTransportConfigZod
|
|
1833
|
+
]);
|
|
1834
|
+
var TransportsConfigZod = z6.record(z6.string(), TransportConfigZod).default({});
|
|
1835
|
+
|
|
1223
1836
|
// src/config/DataLake/DataLake.ts
|
|
1224
|
-
import { z as
|
|
1837
|
+
import { z as z10 } from "zod";
|
|
1225
1838
|
|
|
1226
1839
|
// src/config/DataLake/RestDataLakeConfig.ts
|
|
1227
|
-
import { globalRegistry as
|
|
1840
|
+
import { globalRegistry as globalRegistry6, z as z8 } from "zod";
|
|
1228
1841
|
|
|
1229
1842
|
// src/config/DataLake/DataLakeRemoteConfig.ts
|
|
1230
|
-
import { globalRegistry as
|
|
1231
|
-
var DataLakeDriverConfigBaseZod =
|
|
1232
|
-
driver:
|
|
1843
|
+
import { globalRegistry as globalRegistry5, z as z7 } from "zod";
|
|
1844
|
+
var DataLakeDriverConfigBaseZod = z7.object({
|
|
1845
|
+
driver: z7.string().register(globalRegistry5, {
|
|
1233
1846
|
description: "Driver for the data lake",
|
|
1234
1847
|
type: "string"
|
|
1235
1848
|
})
|
|
@@ -1237,237 +1850,125 @@ var DataLakeDriverConfigBaseZod = z3.object({
|
|
|
1237
1850
|
|
|
1238
1851
|
// src/config/DataLake/RestDataLakeConfig.ts
|
|
1239
1852
|
var RestDataLakeConfigZod = DataLakeDriverConfigBaseZod.extend({
|
|
1240
|
-
driver:
|
|
1853
|
+
driver: z8.literal("rest").register(globalRegistry6, {
|
|
1241
1854
|
description: "Driver for the REST data lake",
|
|
1242
1855
|
type: "string"
|
|
1243
1856
|
}),
|
|
1244
|
-
url:
|
|
1857
|
+
url: z8.string().register(globalRegistry6, {
|
|
1245
1858
|
description: "URL for the REST data lake",
|
|
1246
1859
|
type: "string"
|
|
1247
1860
|
})
|
|
1248
1861
|
}).describe("Configuration for the REST data lake driver");
|
|
1249
1862
|
|
|
1250
1863
|
// src/config/DataLake/RouterDataLakeConfig.ts
|
|
1251
|
-
import { globalRegistry as
|
|
1252
|
-
var RouterDataLakeConfigZod =
|
|
1253
|
-
driver:
|
|
1864
|
+
import { globalRegistry as globalRegistry7, z as z9 } from "zod";
|
|
1865
|
+
var RouterDataLakeConfigZod = z9.object({
|
|
1866
|
+
driver: z9.literal("router").register(globalRegistry7, {
|
|
1254
1867
|
description: "Driver for the router data lake",
|
|
1255
1868
|
type: "string"
|
|
1256
1869
|
}),
|
|
1257
|
-
children:
|
|
1870
|
+
children: z9.array(z9.lazy(() => DataLakeConfigZod)).register(globalRegistry7, {
|
|
1258
1871
|
description: "Child data lake drivers",
|
|
1259
1872
|
type: "array"
|
|
1260
1873
|
})
|
|
1261
1874
|
}).describe("Configuration for the router data lake driver");
|
|
1262
1875
|
|
|
1263
1876
|
// src/config/DataLake/DataLake.ts
|
|
1264
|
-
var DataLakeConfigZod =
|
|
1877
|
+
var DataLakeConfigZod = z10.lazy(() => z10.union([RestDataLakeConfigZod, RouterDataLakeConfigZod])).describe("Configuration for a data lake");
|
|
1265
1878
|
|
|
1266
1879
|
// src/config/Evm.ts
|
|
1267
|
-
import { globalRegistry as
|
|
1268
|
-
var EvmInfuraConfigZod =
|
|
1269
|
-
projectId:
|
|
1880
|
+
import { globalRegistry as globalRegistry8, z as z11 } from "zod";
|
|
1881
|
+
var EvmInfuraConfigZod = z11.object({
|
|
1882
|
+
projectId: z11.string().optional().register(globalRegistry8, {
|
|
1270
1883
|
description: "Infura project ID",
|
|
1271
1884
|
title: "evm.infura.projectId",
|
|
1272
1885
|
type: "string"
|
|
1273
1886
|
}),
|
|
1274
|
-
projectSecret:
|
|
1887
|
+
projectSecret: z11.string().optional().register(globalRegistry8, {
|
|
1275
1888
|
description: "Infura project secret",
|
|
1276
1889
|
title: "evm.infura.projectSecret",
|
|
1277
1890
|
type: "string"
|
|
1278
1891
|
})
|
|
1279
1892
|
});
|
|
1280
|
-
var EvmJsonRpcConfigZod =
|
|
1281
|
-
url:
|
|
1893
|
+
var EvmJsonRpcConfigZod = z11.object({
|
|
1894
|
+
url: z11.url().optional().register(globalRegistry8, {
|
|
1282
1895
|
description: "JSON-RPC URL",
|
|
1283
|
-
title: "evm.jsonRpc.url",
|
|
1284
|
-
type: "string"
|
|
1285
|
-
})
|
|
1286
|
-
});
|
|
1287
|
-
var EvmConfigZod = z7.object({
|
|
1288
|
-
chainId: z7.string().optional().register(globalRegistry5, {
|
|
1289
|
-
description: "EVM chain ID",
|
|
1290
|
-
title: "evm.chainId",
|
|
1291
|
-
type: "string"
|
|
1292
|
-
}),
|
|
1293
|
-
infura: EvmInfuraConfigZod.optional().describe("Infura Provider configuration"),
|
|
1294
|
-
jsonRpc: EvmJsonRpcConfigZod.optional().describe("JSON-RPC Provider configuration")
|
|
1295
|
-
});
|
|
1296
|
-
|
|
1297
|
-
// src/config/Log.ts
|
|
1298
|
-
import { LogLevel } from "@xylabs/sdk-js";
|
|
1299
|
-
import { globalRegistry as globalRegistry6, z as z8 } from "zod";
|
|
1300
|
-
var LogLevelNames = Object.keys(LogLevel);
|
|
1301
|
-
var LogConfigZod = z8.object({
|
|
1302
|
-
logLevel: z8.enum(LogLevelNames).default("info").register(globalRegistry6, {
|
|
1303
|
-
choices: LogLevelNames,
|
|
1304
|
-
default: "info",
|
|
1305
|
-
description: "Desired process verbosity",
|
|
1306
|
-
title: "logLevel",
|
|
1307
|
-
type: "string"
|
|
1308
|
-
}),
|
|
1309
|
-
silent: z8.boolean().default(false).register(globalRegistry6, {
|
|
1310
|
-
default: false,
|
|
1311
|
-
description: "Whether to run in silent mode",
|
|
1312
|
-
title: "silent",
|
|
1313
|
-
type: "boolean"
|
|
1314
|
-
})
|
|
1315
|
-
});
|
|
1316
|
-
|
|
1317
|
-
// src/config/ProviderBinding.ts
|
|
1318
|
-
import { globalRegistry as globalRegistry7, z as z9 } from "zod";
|
|
1319
|
-
var ProviderBindingConfigZod = z9.object({
|
|
1320
|
-
implementation: z9.string().optional().register(globalRegistry7, {
|
|
1321
|
-
description: "Installed provider implementation id (descriptor id)",
|
|
1322
|
-
title: "providerBindings.implementation",
|
|
1323
|
-
type: "string"
|
|
1324
|
-
}),
|
|
1325
|
-
transport: z9.string().optional().register(globalRegistry7, {
|
|
1326
|
-
description: "Named transport from the top-level transports map",
|
|
1327
|
-
title: "providerBindings.transport",
|
|
1328
|
-
type: "string"
|
|
1329
|
-
})
|
|
1330
|
-
}).describe("Provider implementation and transport binding");
|
|
1331
|
-
var ProviderBindingsConfigZod = z9.record(z9.string(), ProviderBindingConfigZod).default({});
|
|
1332
|
-
|
|
1333
|
-
// src/config/Providers.ts
|
|
1334
|
-
import z11 from "zod";
|
|
1335
|
-
|
|
1336
|
-
// src/config/Provider.ts
|
|
1337
|
-
import {
|
|
1338
|
-
zodAsFactory as zodAsFactory2,
|
|
1339
|
-
zodIsFactory,
|
|
1340
|
-
zodToFactory
|
|
1341
|
-
} from "@xylabs/sdk-js";
|
|
1342
|
-
import { z as z10 } from "zod";
|
|
1343
|
-
var ProviderConfigZod = z10.object({
|
|
1344
|
-
moniker: z10.string(),
|
|
1345
|
-
labels: z10.array(z10.string()).optional()
|
|
1346
|
-
}).describe("Configuration for a Provider");
|
|
1347
|
-
var isProviderConfig = zodIsFactory(ProviderConfigZod);
|
|
1348
|
-
var asProviderConfig = zodAsFactory2(ProviderConfigZod, "asProviderConfig");
|
|
1349
|
-
var toProviderConfig = zodToFactory(ProviderConfigZod, "toProviderConfig");
|
|
1350
|
-
|
|
1351
|
-
// src/config/Providers.ts
|
|
1352
|
-
var ProvidersConfigZod = z11.array(ProviderConfigZod.loose()).describe("Configuration for providers").default([]);
|
|
1353
|
-
|
|
1354
|
-
// src/config/Remote.ts
|
|
1355
|
-
import { globalRegistry as globalRegistry8, z as z12 } from "zod";
|
|
1356
|
-
var RpcRemoteConfigBaseZod = z12.object({
|
|
1357
|
-
protocol: z12.string("http").register(globalRegistry8, {
|
|
1358
|
-
description: "Protocol for the RPC connection",
|
|
1359
|
-
type: "string"
|
|
1360
|
-
})
|
|
1361
|
-
}).describe("Base configuration for the remote RPC");
|
|
1362
|
-
var HttpRpcRemoteConfigZod = RpcRemoteConfigBaseZod.extend({
|
|
1363
|
-
protocol: z12.string("http").register(globalRegistry8, {
|
|
1364
|
-
description: "Protocol for the RPC connection",
|
|
1365
|
-
type: "string"
|
|
1366
|
-
}).default("http"),
|
|
1367
|
-
url: z12.string().register(globalRegistry8, {
|
|
1368
|
-
description: "URL for the Chain RPC API",
|
|
1369
|
-
type: "string"
|
|
1370
|
-
})
|
|
1371
|
-
}).describe("Configuration for the remote RPC using Http");
|
|
1372
|
-
var PostMessageRpcRemoteConfigZod = RpcRemoteConfigBaseZod.extend({
|
|
1373
|
-
protocol: z12.string().register(globalRegistry8, {
|
|
1374
|
-
description: "Protocol for the RPC connection",
|
|
1375
|
-
type: "string"
|
|
1376
|
-
}).default("postMessage"),
|
|
1377
|
-
networkId: z12.string().register(globalRegistry8, {
|
|
1378
|
-
description: "Network ID to use for the postMessage RPC connection",
|
|
1379
|
-
type: "string"
|
|
1380
|
-
}),
|
|
1381
|
-
sessionId: z12.string().register(globalRegistry8, {
|
|
1382
|
-
description: "Session ID to use for the postMessage RPC connection",
|
|
1383
|
-
type: "string"
|
|
1384
|
-
})
|
|
1385
|
-
}).describe("Configuration for the remote RPC using postMessage");
|
|
1386
|
-
var RpcRemoteConfigZod = z12.union([HttpRpcRemoteConfigZod, PostMessageRpcRemoteConfigZod]).describe("Configuration for a remote RPC connection, either Http or postMessage");
|
|
1387
|
-
var RemoteConfigZod = z12.object({ rpc: RpcRemoteConfigZod.optional() }).describe("Configuration for remote connections, including RPC");
|
|
1388
|
-
|
|
1389
|
-
// src/config/storage/driver/Mongo.ts
|
|
1390
|
-
import { isDefined as isDefined4, isUndefined as isUndefined5 } from "@xylabs/sdk-js";
|
|
1391
|
-
import { globalRegistry as globalRegistry9, z as z13 } from "zod";
|
|
1392
|
-
var hasMongoConfig = (config) => {
|
|
1393
|
-
if (isUndefined5(config)) return false;
|
|
1394
|
-
return isDefined4(config.connectionString) && isDefined4(config.database) && isDefined4(config.domain);
|
|
1395
|
-
};
|
|
1396
|
-
var MongoConfigZod = z13.object({
|
|
1397
|
-
// TODO: Create from other arguments
|
|
1398
|
-
connectionString: z13.string().nonempty().optional().register(globalRegistry9, {
|
|
1399
|
-
description: "MongoDB connection string",
|
|
1400
|
-
title: "storage.mongo.connectionString",
|
|
1896
|
+
title: "evm.jsonRpc.url",
|
|
1401
1897
|
type: "string"
|
|
1402
|
-
})
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1898
|
+
})
|
|
1899
|
+
});
|
|
1900
|
+
var EvmConfigZod = z11.object({
|
|
1901
|
+
chainId: z11.string().optional().register(globalRegistry8, {
|
|
1902
|
+
description: "EVM chain ID",
|
|
1903
|
+
title: "evm.chainId",
|
|
1406
1904
|
type: "string"
|
|
1407
1905
|
}),
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1906
|
+
infura: EvmInfuraConfigZod.optional().describe("Infura Provider configuration"),
|
|
1907
|
+
jsonRpc: EvmJsonRpcConfigZod.optional().describe("JSON-RPC Provider configuration")
|
|
1908
|
+
});
|
|
1909
|
+
|
|
1910
|
+
// src/config/Log.ts
|
|
1911
|
+
import { LogLevel } from "@xylabs/sdk-js";
|
|
1912
|
+
import { globalRegistry as globalRegistry9, z as z12 } from "zod";
|
|
1913
|
+
var LogLevelNames = Object.keys(LogLevel);
|
|
1914
|
+
var LogConfigZod = z12.object({
|
|
1915
|
+
logLevel: z12.enum(LogLevelNames).default("info").register(globalRegistry9, {
|
|
1916
|
+
choices: LogLevelNames,
|
|
1917
|
+
default: "info",
|
|
1918
|
+
description: "Desired process verbosity",
|
|
1919
|
+
title: "logLevel",
|
|
1411
1920
|
type: "string"
|
|
1412
1921
|
}),
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1922
|
+
silent: z12.boolean().default(false).register(globalRegistry9, {
|
|
1923
|
+
default: false,
|
|
1924
|
+
description: "Whether to run in silent mode",
|
|
1925
|
+
title: "silent",
|
|
1926
|
+
type: "boolean"
|
|
1927
|
+
})
|
|
1928
|
+
});
|
|
1929
|
+
|
|
1930
|
+
// src/config/ProviderBinding.ts
|
|
1931
|
+
import { globalRegistry as globalRegistry10, z as z13 } from "zod";
|
|
1932
|
+
var ProviderBindingConfigZod = z13.object({
|
|
1933
|
+
connection: z13.string().optional().register(globalRegistry10, {
|
|
1934
|
+
description: "Named connection from the top-level connections map",
|
|
1935
|
+
title: "providerBindings.connection",
|
|
1416
1936
|
type: "string"
|
|
1417
1937
|
}),
|
|
1418
|
-
|
|
1419
|
-
description: "
|
|
1420
|
-
title: "
|
|
1938
|
+
transport: z13.string().optional().register(globalRegistry10, {
|
|
1939
|
+
description: "Deprecated alias for connection (kept in sync during migration)",
|
|
1940
|
+
title: "providerBindings.transport",
|
|
1421
1941
|
type: "string"
|
|
1422
1942
|
})
|
|
1423
|
-
});
|
|
1943
|
+
}).describe("Provider connection binding");
|
|
1944
|
+
var ProviderBindingsConfigZod = z13.record(z13.string(), ProviderBindingConfigZod).default({});
|
|
1424
1945
|
|
|
1425
|
-
// src/config/
|
|
1426
|
-
import
|
|
1946
|
+
// src/config/Providers.ts
|
|
1947
|
+
import z15 from "zod";
|
|
1948
|
+
|
|
1949
|
+
// src/config/Provider.ts
|
|
1950
|
+
import {
|
|
1951
|
+
zodAsFactory as zodAsFactory2,
|
|
1952
|
+
zodIsFactory,
|
|
1953
|
+
zodToFactory
|
|
1954
|
+
} from "@xylabs/sdk-js";
|
|
1427
1955
|
import { z as z14 } from "zod";
|
|
1428
|
-
var
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
accountId: z14.string().nonempty().optional().describe("Shared account id (default for all buckets; on Cloudflare R2 it forms the endpoint)"),
|
|
1439
|
-
chainState: S3BucketConfigZod.optional().describe("Bucket for the mutable chain state (the head pointer)"),
|
|
1440
|
-
finalized: S3BucketConfigZod.optional().describe("Bucket for the finalized files (blocks, payloads, manifest)"),
|
|
1441
|
-
index: S3BucketConfigZod.optional().describe("Bucket for the chain index (the step-summary families)"),
|
|
1442
|
-
prefix: z14.string().nonempty().optional().describe("Shared key prefix (default for all buckets)"),
|
|
1443
|
-
secretAccessKey: z14.string().nonempty().optional().describe("Shared S3-compatible secret access key (default for all buckets)")
|
|
1444
|
-
});
|
|
1445
|
-
function resolveS3Bucket(config, which) {
|
|
1446
|
-
if (config === void 0) return void 0;
|
|
1447
|
-
const entry = config[which];
|
|
1448
|
-
const accessKeyId = entry?.accessKeyId ?? config.accessKeyId;
|
|
1449
|
-
const accountId = entry?.accountId ?? config.accountId;
|
|
1450
|
-
const secretAccessKey = entry?.secretAccessKey ?? config.secretAccessKey;
|
|
1451
|
-
const bucket = entry?.bucket ?? config.finalized?.bucket;
|
|
1452
|
-
if (!isDefined5(accessKeyId) || !isDefined5(accountId) || !isDefined5(secretAccessKey) || !isDefined5(bucket)) return void 0;
|
|
1453
|
-
return {
|
|
1454
|
-
accessKeyId,
|
|
1455
|
-
accountId,
|
|
1456
|
-
bucket,
|
|
1457
|
-
prefix: entry?.prefix ?? config.prefix,
|
|
1458
|
-
readUrl: entry?.readUrl,
|
|
1459
|
-
secretAccessKey
|
|
1460
|
-
};
|
|
1461
|
-
}
|
|
1462
|
-
function hasS3Config(config, which = "finalized") {
|
|
1463
|
-
return resolveS3Bucket(config, which) !== void 0;
|
|
1464
|
-
}
|
|
1956
|
+
var ProviderConfigZod = z14.object({
|
|
1957
|
+
moniker: z14.string(),
|
|
1958
|
+
labels: z14.array(z14.string()).optional()
|
|
1959
|
+
}).describe("Configuration for a Provider");
|
|
1960
|
+
var isProviderConfig = zodIsFactory(ProviderConfigZod);
|
|
1961
|
+
var asProviderConfig = zodAsFactory2(ProviderConfigZod, "asProviderConfig");
|
|
1962
|
+
var toProviderConfig = zodToFactory(ProviderConfigZod, "toProviderConfig");
|
|
1963
|
+
|
|
1964
|
+
// src/config/Providers.ts
|
|
1965
|
+
var ProvidersConfigZod = z15.array(ProviderConfigZod.loose()).describe("Configuration for providers").default([]);
|
|
1465
1966
|
|
|
1466
1967
|
// src/config/storage/Storage.ts
|
|
1467
|
-
import { globalRegistry as
|
|
1468
|
-
var StorageConfigZod =
|
|
1968
|
+
import { globalRegistry as globalRegistry11, z as z16 } from "zod";
|
|
1969
|
+
var StorageConfigZod = z16.object({
|
|
1469
1970
|
mongo: MongoConfigZod.optional().describe("Configuration for the MongoD storage driver"),
|
|
1470
|
-
root:
|
|
1971
|
+
root: z16.string().optional().register(globalRegistry11, {
|
|
1471
1972
|
description: "Root directory for local storage",
|
|
1472
1973
|
title: "storage.root",
|
|
1473
1974
|
type: "string"
|
|
@@ -1476,7 +1977,7 @@ var StorageConfigZod = z15.object({
|
|
|
1476
1977
|
}).describe("Storage configuration options");
|
|
1477
1978
|
|
|
1478
1979
|
// src/config/Telemetry.ts
|
|
1479
|
-
import { globalRegistry as
|
|
1980
|
+
import { globalRegistry as globalRegistry12, z as z17 } from "zod";
|
|
1480
1981
|
var DefaultMetricsScrapePorts = {
|
|
1481
1982
|
api: 9465,
|
|
1482
1983
|
bridge: 9468,
|
|
@@ -1484,86 +1985,35 @@ var DefaultMetricsScrapePorts = {
|
|
|
1484
1985
|
producer: 9464,
|
|
1485
1986
|
rewardRedemptionApi: 9467
|
|
1486
1987
|
};
|
|
1487
|
-
var MetricsScrapeConfigZod =
|
|
1488
|
-
path:
|
|
1988
|
+
var MetricsScrapeConfigZod = z17.object({
|
|
1989
|
+
path: z17.string().default("/metrics").register(globalRegistry12, {
|
|
1489
1990
|
default: "/metrics",
|
|
1490
1991
|
description: "Path for the metrics scrape endpoint",
|
|
1491
1992
|
title: "telemetry.metrics.scrape.path",
|
|
1492
1993
|
type: "string"
|
|
1493
1994
|
}),
|
|
1494
|
-
port:
|
|
1995
|
+
port: z17.coerce.number().int().positive().optional().register(globalRegistry12, {
|
|
1495
1996
|
description: "Port for the metrics scrape endpoint",
|
|
1496
1997
|
title: "telemetry.metrics.scrape.port",
|
|
1497
1998
|
type: "number"
|
|
1498
1999
|
})
|
|
1499
2000
|
}).describe("Metrics scrape configuration");
|
|
1500
|
-
var MetricsConfigZod =
|
|
1501
|
-
var OpenTelemetryConfigZod =
|
|
2001
|
+
var MetricsConfigZod = z17.object({ scrape: MetricsScrapeConfigZod }).describe("Metrics configuration options");
|
|
2002
|
+
var OpenTelemetryConfigZod = z17.object({
|
|
1502
2003
|
// OpenTelemetry options
|
|
1503
|
-
otlpEndpoint:
|
|
2004
|
+
otlpEndpoint: z17.url().optional().register(globalRegistry12, {
|
|
1504
2005
|
description: "OTLP endpoint for exporting telemetry data",
|
|
1505
2006
|
title: "telemetry.otel.otlpEndpoint",
|
|
1506
2007
|
type: "string"
|
|
1507
2008
|
})
|
|
1508
2009
|
});
|
|
1509
|
-
var TelemetryConfigZod =
|
|
2010
|
+
var TelemetryConfigZod = z17.object({
|
|
1510
2011
|
// Metrics configuration
|
|
1511
2012
|
metrics: MetricsConfigZod.optional().describe("Metrics configuration"),
|
|
1512
2013
|
// OpenTelemetry configuration
|
|
1513
2014
|
otel: OpenTelemetryConfigZod.optional().describe("OpenTelemetry configuration")
|
|
1514
2015
|
}).describe("Telemetry configuration options");
|
|
1515
2016
|
|
|
1516
|
-
// src/config/transports/Transport.ts
|
|
1517
|
-
import { globalRegistry as globalRegistry12, z as z17 } from "zod";
|
|
1518
|
-
var LmdbTransportConfigZod = z17.object({
|
|
1519
|
-
type: z17.literal("lmdb"),
|
|
1520
|
-
root: z17.string().register(globalRegistry12, {
|
|
1521
|
-
description: "Root directory for local LMDB storage",
|
|
1522
|
-
title: "transports.lmdb.root",
|
|
1523
|
-
type: "string"
|
|
1524
|
-
})
|
|
1525
|
-
}).describe("LMDB local storage transport");
|
|
1526
|
-
var MongoTransportConfigZod = z17.object({
|
|
1527
|
-
type: z17.literal("mongo"),
|
|
1528
|
-
connectionString: MongoConfigZod.shape.connectionString,
|
|
1529
|
-
database: MongoConfigZod.shape.database,
|
|
1530
|
-
domain: MongoConfigZod.shape.domain,
|
|
1531
|
-
password: MongoConfigZod.shape.password,
|
|
1532
|
-
username: MongoConfigZod.shape.username
|
|
1533
|
-
}).describe("MongoDB storage transport");
|
|
1534
|
-
var RpcTransportConfigZod = HttpRpcRemoteConfigZod.extend({ type: z17.literal("rpc") }).describe("XL1 JSON-RPC transport");
|
|
1535
|
-
var RestTransportConfigZod = z17.object({
|
|
1536
|
-
type: z17.literal("rest"),
|
|
1537
|
-
baseUrl: z17.string().register(globalRegistry12, {
|
|
1538
|
-
description: "HTTP base URL for REST reads",
|
|
1539
|
-
title: "transports.rest.baseUrl",
|
|
1540
|
-
type: "string"
|
|
1541
|
-
})
|
|
1542
|
-
}).describe("HTTP REST read transport");
|
|
1543
|
-
var S3TransportConfigZod = S3BucketConfigZod.extend({
|
|
1544
|
-
type: z17.literal("s3"),
|
|
1545
|
-
accessKeyId: z17.string().optional(),
|
|
1546
|
-
accountId: z17.string().optional(),
|
|
1547
|
-
secretAccessKey: z17.string().optional()
|
|
1548
|
-
}).describe("S3-compatible object storage transport");
|
|
1549
|
-
var EvmRpcTransportConfigZod = z17.object({
|
|
1550
|
-
type: z17.literal("evm-rpc"),
|
|
1551
|
-
url: z17.string().register(globalRegistry12, {
|
|
1552
|
-
description: "EVM JSON-RPC URL",
|
|
1553
|
-
title: "transports.evm-rpc.url",
|
|
1554
|
-
type: "string"
|
|
1555
|
-
})
|
|
1556
|
-
}).describe("EVM JSON-RPC transport");
|
|
1557
|
-
var TransportConfigZod = z17.discriminatedUnion("type", [
|
|
1558
|
-
LmdbTransportConfigZod,
|
|
1559
|
-
MongoTransportConfigZod,
|
|
1560
|
-
RpcTransportConfigZod,
|
|
1561
|
-
RestTransportConfigZod,
|
|
1562
|
-
S3TransportConfigZod,
|
|
1563
|
-
EvmRpcTransportConfigZod
|
|
1564
|
-
]);
|
|
1565
|
-
var TransportsConfigZod = z17.record(z17.string(), TransportConfigZod).default({});
|
|
1566
|
-
|
|
1567
2017
|
// src/config/Validation.ts
|
|
1568
2018
|
import { XyoAddressZod as XyoAddressZod2 } from "@xyo-network/sdk-js";
|
|
1569
2019
|
import { globalRegistry as globalRegistry13, z as z18 } from "zod";
|
|
@@ -1587,11 +2037,11 @@ function blockRangeSteps(range, steps) {
|
|
|
1587
2037
|
}
|
|
1588
2038
|
|
|
1589
2039
|
// src/primitives/block/rate/blockRate.ts
|
|
1590
|
-
import { isDefined as
|
|
2040
|
+
import { isDefined as isDefined8, isFalsy } from "@xylabs/sdk-js";
|
|
1591
2041
|
import { asXL1BlockRange } from "@xyo-network/xl1-protocol-lib";
|
|
1592
2042
|
|
|
1593
2043
|
// src/primitives/block/rate/timeHelpers.ts
|
|
1594
|
-
import { assertEx as
|
|
2044
|
+
import { assertEx as assertEx10, isDefined as isDefined7 } from "@xylabs/sdk-js";
|
|
1595
2045
|
var rateMultipliers = {
|
|
1596
2046
|
millis: 1,
|
|
1597
2047
|
seconds: 1e3,
|
|
@@ -1609,7 +2059,7 @@ var timeDurations = (timeInMs) => ({
|
|
|
1609
2059
|
weeks: timeInMs / (1e3 * 60 * 60 * 24 * 7)
|
|
1610
2060
|
});
|
|
1611
2061
|
var getTimeConfigInMilliseconds = (timeConfig) => {
|
|
1612
|
-
const assertedTimeConfig =
|
|
2062
|
+
const assertedTimeConfig = assertEx10(isDefined7(timeConfig) ? timeConfig : void 0, () => "Time configuration must be provided");
|
|
1613
2063
|
let totalMilliseconds = 0;
|
|
1614
2064
|
if ("years" in assertedTimeConfig) {
|
|
1615
2065
|
totalMilliseconds += assertedTimeConfig.years * 31536e6;
|
|
@@ -1648,13 +2098,13 @@ var blockRate = (startBlock, endBlock, timeUnit) => {
|
|
|
1648
2098
|
throw new Error("Time difference must be greater than 0");
|
|
1649
2099
|
}
|
|
1650
2100
|
const rate = heightDifference / timeDifference;
|
|
1651
|
-
const timeUnitValue =
|
|
1652
|
-
const returnedTimeDifference =
|
|
2101
|
+
const timeUnitValue = isDefined8(timeUnit) ? timeUnit : "millis";
|
|
2102
|
+
const returnedTimeDifference = isDefined8(timeUnit) ? timeDurations(timeDifference)[timeUnit] : timeDifference;
|
|
1653
2103
|
const timePerBlock = returnedTimeDifference / heightDifference;
|
|
1654
2104
|
return {
|
|
1655
2105
|
range: asXL1BlockRange([startingBlock.block, endingBlock.block], true),
|
|
1656
2106
|
span: heightDifference,
|
|
1657
|
-
rate:
|
|
2107
|
+
rate: isDefined8(timeUnit) ? rate * rateMultipliers[timeUnit] : rate,
|
|
1658
2108
|
timeUnit: timeUnitValue,
|
|
1659
2109
|
timeDifference: returnedTimeDifference,
|
|
1660
2110
|
timePerBlock
|
|
@@ -1682,7 +2132,7 @@ var calculateBlockRate = async (viewer, range, timeUnit) => {
|
|
|
1682
2132
|
};
|
|
1683
2133
|
|
|
1684
2134
|
// src/primitives/block/rate/stepRate.ts
|
|
1685
|
-
import { assertEx as
|
|
2135
|
+
import { assertEx as assertEx11 } from "@xylabs/sdk-js";
|
|
1686
2136
|
import {
|
|
1687
2137
|
asXL1BlockRange as asXL1BlockRange2,
|
|
1688
2138
|
isValidStep,
|
|
@@ -1694,28 +2144,28 @@ var stepRate = async (viewer, start, step, count = 1, timeUnit) => {
|
|
|
1694
2144
|
return await calculateBlockRate(viewer, range, timeUnit);
|
|
1695
2145
|
};
|
|
1696
2146
|
var calculateStepSizeRate = async (viewer, start, stepIndex, count = 1, timeUnit) => {
|
|
1697
|
-
|
|
2147
|
+
assertEx11(isValidStep(stepIndex), () => `Invalid step index: ${stepIndex}`);
|
|
1698
2148
|
const step = StepSizes4[stepIndex];
|
|
1699
2149
|
return await stepRate(viewer, start, step, count, timeUnit);
|
|
1700
2150
|
};
|
|
1701
2151
|
|
|
1702
2152
|
// src/primitives/block/rate/timeRate.ts
|
|
1703
2153
|
import {
|
|
1704
|
-
assertEx as
|
|
1705
|
-
isDefined as
|
|
2154
|
+
assertEx as assertEx12,
|
|
2155
|
+
isDefined as isDefined9,
|
|
1706
2156
|
isDefinedNotNull
|
|
1707
2157
|
} from "@xylabs/sdk-js";
|
|
1708
2158
|
import { asXL1BlockNumber as asXL1BlockNumber3, asXL1BlockRange as asXL1BlockRange3 } from "@xyo-network/xl1-protocol-lib";
|
|
1709
2159
|
var DEFAULT_TOLERANCE_MS = 3e4;
|
|
1710
2160
|
var DEFAULT_MAX_ATTEMPTS = 10;
|
|
1711
2161
|
var calculateTimeRate = async (viewer, timeConfig, startBlockNumber, timeUnit, toleranceMs = DEFAULT_TOLERANCE_MS, maxAttempts = DEFAULT_MAX_ATTEMPTS) => {
|
|
1712
|
-
|
|
2162
|
+
assertEx12(Object.keys(timeConfig ?? {}).length === 1, () => "Only one time unit should be specified in timeConfig");
|
|
1713
2163
|
const startBlock = isDefinedNotNull(startBlockNumber) ? await viewer.blockByNumber(startBlockNumber) : null;
|
|
1714
2164
|
const currentBlockResult = await viewer.currentBlock();
|
|
1715
2165
|
const blockResult = isDefinedNotNull(startBlock) ? startBlock : currentBlockResult;
|
|
1716
2166
|
const resolvedStartBlock = blockResult[0];
|
|
1717
2167
|
const timeInMilliseconds = getTimeConfigInMilliseconds(timeConfig);
|
|
1718
|
-
|
|
2168
|
+
assertEx12(timeInMilliseconds > 0, () => "Time duration must be greater than zero");
|
|
1719
2169
|
const blocksPerMillisecondRate = 1 / (12 * 1e3);
|
|
1720
2170
|
const initialBlocksInDuration = Math.floor(blocksPerMillisecondRate * timeInMilliseconds);
|
|
1721
2171
|
const endBlockNumber = await findEndBlockRecursive(
|
|
@@ -1733,15 +2183,15 @@ var calculateTimeRate = async (viewer, timeConfig, startBlockNumber, timeUnit, t
|
|
|
1733
2183
|
);
|
|
1734
2184
|
};
|
|
1735
2185
|
var findEndBlockRecursive = async (viewer, startBlock, targetTimeMs, estimatedBlocksBack, toleranceMs, attemptsRemaining) => {
|
|
1736
|
-
|
|
2186
|
+
assertEx12(attemptsRemaining >= 0, () => "Maximum attempts reached while searching for end block");
|
|
1737
2187
|
const startBlockEpoch = startBlock.$epoch;
|
|
1738
2188
|
const estimatedEndBlockNumber = asXL1BlockNumber3(startBlock.block - estimatedBlocksBack, true);
|
|
1739
2189
|
if (estimatedEndBlockNumber < 0) {
|
|
1740
2190
|
throw new Error("Estimated end block number is less than zero");
|
|
1741
2191
|
}
|
|
1742
2192
|
const endBlock = await viewer.blockByNumber(estimatedEndBlockNumber);
|
|
1743
|
-
const resolvedEndBlock =
|
|
1744
|
-
|
|
2193
|
+
const resolvedEndBlock = assertEx12(
|
|
2194
|
+
isDefined9(endBlock?.[0]) ? endBlock[0] : void 0,
|
|
1745
2195
|
() => `Could not retrieve block ${estimatedEndBlockNumber} for time rate calculation`
|
|
1746
2196
|
);
|
|
1747
2197
|
const endBlockEpoch = resolvedEndBlock.$epoch;
|
|
@@ -1777,8 +2227,8 @@ var findEndBlockRecursive = async (viewer, startBlock, targetTimeMs, estimatedBl
|
|
|
1777
2227
|
|
|
1778
2228
|
// src/primitives/chain/getWindowedChain.ts
|
|
1779
2229
|
import {
|
|
1780
|
-
assertEx as
|
|
1781
|
-
isDefined as
|
|
2230
|
+
assertEx as assertEx13,
|
|
2231
|
+
isDefined as isDefined10,
|
|
1782
2232
|
isNull,
|
|
1783
2233
|
spanRootAsync
|
|
1784
2234
|
} from "@xylabs/sdk-js";
|
|
@@ -1792,14 +2242,14 @@ async function getWindowedChain(context, blockViewer, maxWindowSize, previousCha
|
|
|
1792
2242
|
while (currentBlock !== null && newChain.length < maxWindowSize) {
|
|
1793
2243
|
const currentBlockNumber = currentBlock[0].block;
|
|
1794
2244
|
const nextBlock = newChain[0];
|
|
1795
|
-
if (
|
|
2245
|
+
if (isDefined10(nextBlock)) {
|
|
1796
2246
|
const nextBlockNumber = nextBlock[0].block;
|
|
1797
|
-
|
|
2247
|
+
assertEx13(
|
|
1798
2248
|
currentBlockNumber === nextBlockNumber - 1,
|
|
1799
2249
|
() => `[getWindowedChain] Non-monotonic block sequence detected: current=${currentBlockNumber}, next=${nextBlockNumber}`
|
|
1800
2250
|
);
|
|
1801
2251
|
}
|
|
1802
|
-
|
|
2252
|
+
assertEx13(
|
|
1803
2253
|
currentBlockNumber <= head[0].block,
|
|
1804
2254
|
() => `[getWindowedChain] Current block number (${currentBlockNumber}) exceeds head block number (${head[0].block})`
|
|
1805
2255
|
);
|
|
@@ -1813,7 +2263,7 @@ async function getWindowedChain(context, blockViewer, maxWindowSize, previousCha
|
|
|
1813
2263
|
}
|
|
1814
2264
|
|
|
1815
2265
|
// src/primitives/chain/step/chainStepRewardAddress.ts
|
|
1816
|
-
import { assertEx as
|
|
2266
|
+
import { assertEx as assertEx16, exists } from "@xylabs/sdk-js";
|
|
1817
2267
|
import { toXyoAddress as toXyoAddress2 } from "@xyo-network/sdk-js";
|
|
1818
2268
|
import {
|
|
1819
2269
|
asTransfer,
|
|
@@ -1845,7 +2295,7 @@ function stepBlockRange({ block, step }) {
|
|
|
1845
2295
|
}
|
|
1846
2296
|
|
|
1847
2297
|
// src/primitives/step/stepTransferIndex.ts
|
|
1848
|
-
import { assertEx as
|
|
2298
|
+
import { assertEx as assertEx14 } from "@xylabs/sdk-js";
|
|
1849
2299
|
import { StepSizes as StepSizes6 } from "@xyo-network/xl1-protocol-lib";
|
|
1850
2300
|
function stepTransferIndex(block, step) {
|
|
1851
2301
|
let rewardTransferCount = 0;
|
|
@@ -1859,16 +2309,16 @@ function stepTransferIndex(block, step) {
|
|
|
1859
2309
|
rewardTransferCount++;
|
|
1860
2310
|
}
|
|
1861
2311
|
}
|
|
1862
|
-
|
|
2312
|
+
assertEx14(rewardTransferIndex >= 0, () => `Could not find step size for step ${step} at block ${block}`);
|
|
1863
2313
|
return [rewardTransferIndex, rewardTransferCount];
|
|
1864
2314
|
}
|
|
1865
2315
|
|
|
1866
2316
|
// src/primitives/chain/step/stepRewardBlock.ts
|
|
1867
|
-
import { assertEx as
|
|
2317
|
+
import { assertEx as assertEx15 } from "@xylabs/sdk-js";
|
|
1868
2318
|
import { StepSizes as StepSizes7 } from "@xyo-network/xl1-protocol-lib";
|
|
1869
2319
|
async function stepRewardBlock(context, blockViewer, { block, step }) {
|
|
1870
|
-
|
|
1871
|
-
return
|
|
2320
|
+
assertEx15(block % StepSizes7[step] === 0, () => `Block must be the first block of the step [${StepSizes7[step]}], got ${block}`);
|
|
2321
|
+
return assertEx15(await blockViewer.blockByNumber(block), () => `Could not find block for block number ${block}`);
|
|
1872
2322
|
}
|
|
1873
2323
|
|
|
1874
2324
|
// src/primitives/chain/step/chainStepRewardAddress.ts
|
|
@@ -1881,7 +2331,7 @@ async function chainStepRewardAddress(context, blockViewer, { block, step }) {
|
|
|
1881
2331
|
const rewardEntry = Object.entries(mergedTransfers).find(([address]) => address === XYO_STEP_REWARD_ADDRESS);
|
|
1882
2332
|
const fromEntries = Object.entries(rewardEntry?.[1] ?? {});
|
|
1883
2333
|
const sortedTransferAmounts = fromEntries.toSorted(([, a], [, b]) => a > b ? -1 : a < b ? 1 : 0);
|
|
1884
|
-
|
|
2334
|
+
assertEx16(
|
|
1885
2335
|
sortedTransferAmounts.length === transferCount,
|
|
1886
2336
|
() => `Step Transfers mismatch ${block} (${blockBw._hash}) [${sortedTransferAmounts.length} - ${transferCount}]`
|
|
1887
2337
|
);
|
|
@@ -1889,7 +2339,7 @@ async function chainStepRewardAddress(context, blockViewer, { block, step }) {
|
|
|
1889
2339
|
}
|
|
1890
2340
|
|
|
1891
2341
|
// src/primitives/chain/step/stepRewardTotal.ts
|
|
1892
|
-
import { assertEx as
|
|
2342
|
+
import { assertEx as assertEx17, isDefined as isDefined11 } from "@xylabs/sdk-js";
|
|
1893
2343
|
import {
|
|
1894
2344
|
asAttoXL1,
|
|
1895
2345
|
asXL1BlockRange as asXL1BlockRange5,
|
|
@@ -1982,18 +2432,18 @@ function stepInRange(step, range) {
|
|
|
1982
2432
|
return stepRange[0] >= range[0] && stepRange[1] <= range[1];
|
|
1983
2433
|
}
|
|
1984
2434
|
async function stepRewardTotal(context, blockViewer, { block, step }, multipliers) {
|
|
1985
|
-
const cacheKey = `${block}|${step}|${
|
|
2435
|
+
const cacheKey = `${block}|${step}|${isDefined11(multipliers)}`;
|
|
1986
2436
|
return await withContextCacheResponse(context, "stepRewardTotal", cacheKey, async () => {
|
|
1987
2437
|
const [blockBw, payloads] = await stepRewardBlock(context, blockViewer, { block, step });
|
|
1988
|
-
|
|
2438
|
+
assertEx17(blockBw.block === block, () => `Block Mismatch: expected ${block}, got ${blockBw.block}`);
|
|
1989
2439
|
const [transferIndex] = stepTransferIndex(block, step);
|
|
1990
|
-
const stepTransfer =
|
|
2440
|
+
const stepTransfer = assertEx17(
|
|
1991
2441
|
payloads.find((p) => isTransfer5(p) && p.from === XYO_STEP_REWARD_ADDRESS2),
|
|
1992
2442
|
() => `No step transfer found for step ${step} at block ${block} (${blockBw._hash})`
|
|
1993
2443
|
);
|
|
1994
2444
|
const netTransfers = netTransfersForPayloads(context, [stepTransfer]);
|
|
1995
2445
|
const rewardEntry = Object.entries(netTransfers).find(([address]) => address === XYO_STEP_REWARD_ADDRESS2);
|
|
1996
|
-
const rewards =
|
|
2446
|
+
const rewards = assertEx17(
|
|
1997
2447
|
rewardEntry?.[1],
|
|
1998
2448
|
() => `No rewards found for step reward address ${XYO_STEP_REWARD_ADDRESS2} at block ${block} (${blockBw._hash})`
|
|
1999
2449
|
);
|
|
@@ -2036,7 +2486,7 @@ async function stepsRewardTotal(context, blockViewer, steps, multipliers) {
|
|
|
2036
2486
|
}
|
|
2037
2487
|
|
|
2038
2488
|
// src/primitives/chain/time/externalBlockNumberFromXl1BlockNumber.ts
|
|
2039
|
-
import { assertEx as
|
|
2489
|
+
import { assertEx as assertEx18, isArray } from "@xylabs/sdk-js";
|
|
2040
2490
|
import {
|
|
2041
2491
|
asBlockNumber,
|
|
2042
2492
|
asTimePayload,
|
|
@@ -2047,7 +2497,7 @@ async function externalBlockNumberFromXL1BlockNumber(context, blockViewer, xl1Bl
|
|
|
2047
2497
|
const cacheKey = `${xl1BlockNumber}-${externalTimeName}-${externalGenesisTime ?? "default"}`;
|
|
2048
2498
|
return await withContextCacheResponse(context, functionName, cacheKey, async () => {
|
|
2049
2499
|
const [, payloads = []] = await blockViewer.blockByNumber(xl1BlockNumber) ?? [];
|
|
2050
|
-
|
|
2500
|
+
assertEx18(isArray(payloads));
|
|
2051
2501
|
const timePayload = asTimePayload(payloads.find(isTimePayload));
|
|
2052
2502
|
return asBlockNumber(
|
|
2053
2503
|
timePayload?.[externalTimeName] ?? externalGenesisTime ?? 23372716,
|
|
@@ -2073,7 +2523,7 @@ async function externalBlockRangeFromStep(context, blockViewer, stepIdentity) {
|
|
|
2073
2523
|
}
|
|
2074
2524
|
|
|
2075
2525
|
// src/primitives/mapToMapType.ts
|
|
2076
|
-
import { isDefined as
|
|
2526
|
+
import { isDefined as isDefined12 } from "@xylabs/sdk-js";
|
|
2077
2527
|
function mapToMapType(map) {
|
|
2078
2528
|
return {
|
|
2079
2529
|
get: (key) => map.get(key),
|
|
@@ -2092,7 +2542,7 @@ function mapToMapType(map) {
|
|
|
2092
2542
|
const result = [];
|
|
2093
2543
|
for (const key of keys) {
|
|
2094
2544
|
const value = map.get(key);
|
|
2095
|
-
if (
|
|
2545
|
+
if (isDefined12(value)) {
|
|
2096
2546
|
result.push(value);
|
|
2097
2547
|
}
|
|
2098
2548
|
}
|
|
@@ -2107,7 +2557,7 @@ function mapToMapType(map) {
|
|
|
2107
2557
|
}
|
|
2108
2558
|
|
|
2109
2559
|
// src/primitives/readPayloadMapFromStore.ts
|
|
2110
|
-
import { isDefined as
|
|
2560
|
+
import { isDefined as isDefined13 } from "@xylabs/sdk-js";
|
|
2111
2561
|
function readPayloadMapFromStore(store) {
|
|
2112
2562
|
if (isReadArchivist(store)) {
|
|
2113
2563
|
return {
|
|
@@ -2120,7 +2570,7 @@ function readPayloadMapFromStore(store) {
|
|
|
2120
2570
|
},
|
|
2121
2571
|
has: async (hash) => {
|
|
2122
2572
|
const results = await store.get([hash]);
|
|
2123
|
-
return
|
|
2573
|
+
return isDefined13(results[0]);
|
|
2124
2574
|
}
|
|
2125
2575
|
};
|
|
2126
2576
|
}
|
|
@@ -2138,7 +2588,7 @@ function payloadMapFromStore(store) {
|
|
|
2138
2588
|
},
|
|
2139
2589
|
has: async (hash) => {
|
|
2140
2590
|
const results = await store.get([hash]);
|
|
2141
|
-
return
|
|
2591
|
+
return isDefined13(results[0]);
|
|
2142
2592
|
},
|
|
2143
2593
|
clear: async () => {
|
|
2144
2594
|
return await store.clear();
|
|
@@ -2184,7 +2634,7 @@ function rewardFromBlockNumber(blockNumber) {
|
|
|
2184
2634
|
import { XYO_NETWORK_STAKING_ADDRESS } from "@xyo-network/xl1-protocol-lib";
|
|
2185
2635
|
|
|
2186
2636
|
// src/primitives/stake/activeStakeAtTimeByAddress.ts
|
|
2187
|
-
import { isDefined as
|
|
2637
|
+
import { isDefined as isDefined14 } from "@xylabs/sdk-js";
|
|
2188
2638
|
|
|
2189
2639
|
// src/primitives/stake/mergedAddRemoveStakeEventsByStaker.ts
|
|
2190
2640
|
async function mergedAddRemoveStakeEventsByStaker(chainEvents, range, staked, staker) {
|
|
@@ -2204,7 +2654,7 @@ async function activeStakeAtTimeByAddress(chain, staked, time, staker) {
|
|
|
2204
2654
|
for (const event of stakeEvents) {
|
|
2205
2655
|
if (event.time > time) break;
|
|
2206
2656
|
if (event.args.staked !== staked) continue;
|
|
2207
|
-
if (
|
|
2657
|
+
if (isDefined14(staker) && event.args.staker !== staker) continue;
|
|
2208
2658
|
if (event.name === "StakeAdded") {
|
|
2209
2659
|
result += event.args.amount;
|
|
2210
2660
|
} else if (event.name === "StakeRemoved") {
|
|
@@ -2278,20 +2728,20 @@ async function allStakersForStep(context, blockViewer, stakeEventsViewer, stepCo
|
|
|
2278
2728
|
}
|
|
2279
2729
|
|
|
2280
2730
|
// src/primitives/stake/weightedStakeForRangeByPosition.ts
|
|
2281
|
-
import { isDefined as
|
|
2731
|
+
import { isDefined as isDefined15 } from "@xylabs/sdk-js";
|
|
2282
2732
|
import { asBlockNumber as asBlockNumber2 } from "@xyo-network/xl1-protocol-lib";
|
|
2283
2733
|
async function weightedStakeForRangeByPosition(context, blockViewer, stakeEventsViewer, externalRange, staked, positionId) {
|
|
2284
|
-
const cacheKey =
|
|
2734
|
+
const cacheKey = isDefined15(positionId) ? `${externalRange[0]}-${externalRange[1]}-${positionId}` : `${externalRange[0]}-${externalRange[1]}-all`;
|
|
2285
2735
|
return await withContextCacheResponse(context, "weightedStakeForRangeByPosition", cacheKey, async () => {
|
|
2286
2736
|
let weightedStakeSum = 0n;
|
|
2287
|
-
if (
|
|
2737
|
+
if (isDefined15(positionId)) {
|
|
2288
2738
|
const mergedEventsResult = await mergedAddRemoveStakeEventsByPosition(
|
|
2289
2739
|
stakeEventsViewer,
|
|
2290
2740
|
[0, externalRange[1]],
|
|
2291
2741
|
positionId
|
|
2292
2742
|
);
|
|
2293
2743
|
const mergedEvents = mergedEventsResult.toSorted((a, b) => a.time - b.time);
|
|
2294
|
-
if (
|
|
2744
|
+
if (isDefined15(staked) && mergedEvents.at(0)?.args.staked !== staked) {
|
|
2295
2745
|
return 0n;
|
|
2296
2746
|
}
|
|
2297
2747
|
let currentTime = externalRange[0];
|
|
@@ -2364,7 +2814,7 @@ var findMostRecentBlock = async (chainArchivist, nextOptions = DEFAULT_NEXT_OPTI
|
|
|
2364
2814
|
};
|
|
2365
2815
|
|
|
2366
2816
|
// src/primitives/state/hydratedBlockByNumber.ts
|
|
2367
|
-
import { assertEx as
|
|
2817
|
+
import { assertEx as assertEx19, spanAsync as spanAsync2 } from "@xylabs/sdk-js";
|
|
2368
2818
|
async function hydratedBlockByNumber(context, blockNumber) {
|
|
2369
2819
|
return await spanAsync2("hydratedBlockByNumber", async () => {
|
|
2370
2820
|
if (blockNumber < 0) throw new Error(`Block number ${blockNumber} is less than 0`);
|
|
@@ -2372,7 +2822,7 @@ async function hydratedBlockByNumber(context, blockNumber) {
|
|
|
2372
2822
|
if (blockNumber % 1 !== 0) throw new Error(`Block number ${blockNumber} is not an integer`);
|
|
2373
2823
|
const cacheKey = String(blockNumber);
|
|
2374
2824
|
return await withContextCacheResponse(context, "hydratedBlockByNumber", cacheKey, async () => {
|
|
2375
|
-
const block =
|
|
2825
|
+
const block = assertEx19(
|
|
2376
2826
|
await blockFromBlockNumber(context, blockNumber),
|
|
2377
2827
|
() => `Could not find block for block number ${blockNumber}`
|
|
2378
2828
|
);
|
|
@@ -2423,7 +2873,7 @@ function findBestUncle(finalizedWindowedChain, uncles, options) {
|
|
|
2423
2873
|
|
|
2424
2874
|
// src/primitives/uncle/findUncles.ts
|
|
2425
2875
|
import {
|
|
2426
|
-
assertEx as
|
|
2876
|
+
assertEx as assertEx20,
|
|
2427
2877
|
exists as exists2
|
|
2428
2878
|
} from "@xylabs/sdk-js";
|
|
2429
2879
|
import { isTransactionBoundWitness as isTransactionBoundWitness2 } from "@xyo-network/xl1-protocol-lib";
|
|
@@ -2456,7 +2906,7 @@ function blocksToChains(blocks) {
|
|
|
2456
2906
|
}
|
|
2457
2907
|
function toValidUncle(_context, finalizedWindowedChain, possibleUncle) {
|
|
2458
2908
|
const finalizedWindowStartBlockNumber = finalizedWindowedChain.at(0)?.[0].block ?? -1;
|
|
2459
|
-
const finalizedHead =
|
|
2909
|
+
const finalizedHead = assertEx20(finalizedWindowedChain.at(-1), () => "finalizedWindowedChain is empty");
|
|
2460
2910
|
const prunedPossibleUncle = possibleUncle.filter((b) => b[0].block > finalizedHead[0].block);
|
|
2461
2911
|
if (prunedPossibleUncle.length === 0) {
|
|
2462
2912
|
return;
|
|
@@ -2515,10 +2965,11 @@ var BaseConfigZod = z19.object({
|
|
|
2515
2965
|
dataLake: z19.optional(DataLakeConfigZod).check(z19.describe("Configuration for data lakes")),
|
|
2516
2966
|
evm: z19._default(EvmConfigZod, EvmConfigZod.parse({})).check(z19.describe("Configuration for EVM-backed services")),
|
|
2517
2967
|
log: z19._default(LogConfigZod, LogConfigZod.parse({})).check(z19.describe("Configuration for logging")),
|
|
2518
|
-
|
|
2968
|
+
connections: z19._default(TransportsConfigZod, TransportsConfigZod.parse({})).check(z19.describe("Named connection profiles (rpc, rest, s3, lmdb, mongo, evm-rpc)")),
|
|
2969
|
+
providerBindings: z19._default(ProviderBindingsConfigZod, ProviderBindingsConfigZod.parse({})).check(z19.describe("Per-moniker provider connection bindings")),
|
|
2519
2970
|
providers: z19._default(ProvidersConfigZod, ProvidersConfigZod.parse([])).check(z19.describe("Configuration for providers")),
|
|
2520
2971
|
remote: z19._default(RemoteConfigZod, RemoteConfigZod.parse({})).check(z19.describe("Configuration for remote services")),
|
|
2521
|
-
transports: z19._default(TransportsConfigZod, TransportsConfigZod.parse({})).check(z19.describe("
|
|
2972
|
+
transports: z19._default(TransportsConfigZod, TransportsConfigZod.parse({})).check(z19.describe("Deprecated alias for connections (kept in sync during migration)")),
|
|
2522
2973
|
storage: z19._default(StorageConfigZod, StorageConfigZod.parse({})).check(z19.describe("Configuration for the storage")),
|
|
2523
2974
|
telemetry: z19._default(TelemetryConfigZod, TelemetryConfigZod.parse({})).check(z19.describe("Configuration for telemetry")),
|
|
2524
2975
|
validation: z19._default(ValidationConfigZod, ValidationConfigZod.parse({})).check(z19.describe("Configuration for validation"))
|
|
@@ -2549,7 +3000,7 @@ var ActorsConfigZod = z21._default(
|
|
|
2549
3000
|
);
|
|
2550
3001
|
|
|
2551
3002
|
// src/config/adaptLegacyConfig.ts
|
|
2552
|
-
import { isDefined as
|
|
3003
|
+
import { isDefined as isDefined16 } from "@xylabs/sdk-js";
|
|
2553
3004
|
|
|
2554
3005
|
// src/config/Config.ts
|
|
2555
3006
|
import { globalRegistry as globalRegistry15, z as z22 } from "zod/mini";
|
|
@@ -2597,7 +3048,7 @@ function rpcTransportFromRemote(rpc) {
|
|
|
2597
3048
|
};
|
|
2598
3049
|
}
|
|
2599
3050
|
function s3TransportFromBucket(shared, entry, fallbackBucket) {
|
|
2600
|
-
if (!
|
|
3051
|
+
if (!isDefined16(entry?.bucket) && !isDefined16(entry?.readUrl)) {
|
|
2601
3052
|
return void 0;
|
|
2602
3053
|
}
|
|
2603
3054
|
return {
|
|
@@ -2636,34 +3087,105 @@ function synthesizeS3Transports(s3) {
|
|
|
2636
3087
|
function hasTransport(transports, key) {
|
|
2637
3088
|
return Object.hasOwn(transports, key) && transports[key] !== void 0;
|
|
2638
3089
|
}
|
|
3090
|
+
function bindMoniker2(bindings, moniker, connectionName) {
|
|
3091
|
+
bindings[moniker] = { connection: connectionName, transport: connectionName };
|
|
3092
|
+
}
|
|
3093
|
+
var LMDB_MONIKERS = [
|
|
3094
|
+
"AccountBalanceViewer",
|
|
3095
|
+
"BlockRewardViewer",
|
|
3096
|
+
"BlockRunner",
|
|
3097
|
+
"BlockValidationViewer",
|
|
3098
|
+
"BlockViewer",
|
|
3099
|
+
"ChainContractViewer",
|
|
3100
|
+
"DeadLetterQueueRunner",
|
|
3101
|
+
"DeadLetterQueueViewer",
|
|
3102
|
+
"FinalizationRunner",
|
|
3103
|
+
"FinalizationViewer",
|
|
3104
|
+
"MempoolRunner",
|
|
3105
|
+
"MempoolViewer",
|
|
3106
|
+
"NetworkStakeViewer",
|
|
3107
|
+
"NetworkStakeStepRewardsByPositionViewer",
|
|
3108
|
+
"NetworkStakeStepRewardsByStakerViewer",
|
|
3109
|
+
"NetworkStakeStepRewardsByStepViewer",
|
|
3110
|
+
"NetworkStakeStepRewardsTotalViewer",
|
|
3111
|
+
"NetworkStakeStepRewardsViewer",
|
|
3112
|
+
"StakeEventsViewer",
|
|
3113
|
+
"StakeTotalsViewer",
|
|
3114
|
+
"StakeViewer",
|
|
3115
|
+
"StepViewer",
|
|
3116
|
+
"TimeSyncViewer",
|
|
3117
|
+
"TransactionValidationViewer",
|
|
3118
|
+
"TransactionViewer",
|
|
3119
|
+
"WindowedBlockViewer",
|
|
3120
|
+
"XyoConnection",
|
|
3121
|
+
"XyoGateway",
|
|
3122
|
+
"XyoRunner",
|
|
3123
|
+
"XyoViewer"
|
|
3124
|
+
];
|
|
3125
|
+
var RPC_MONIKERS = [
|
|
3126
|
+
"AccountBalanceViewer",
|
|
3127
|
+
"BlockRewardViewer",
|
|
3128
|
+
"BlockViewer",
|
|
3129
|
+
"FinalizationViewer",
|
|
3130
|
+
"MempoolRunner",
|
|
3131
|
+
"MempoolViewer",
|
|
3132
|
+
"NetworkStakeViewer",
|
|
3133
|
+
"NetworkStakeStepRewardsByPositionViewer",
|
|
3134
|
+
"NetworkStakeStepRewardsByStakerViewer",
|
|
3135
|
+
"NetworkStakeStepRewardsByStepViewer",
|
|
3136
|
+
"NetworkStakeStepRewardsTotalViewer",
|
|
3137
|
+
"NetworkStakeStepRewardsViewer",
|
|
3138
|
+
"StakeEventsViewer",
|
|
3139
|
+
"StakeViewer",
|
|
3140
|
+
"StepViewer",
|
|
3141
|
+
"TimeSyncViewer",
|
|
3142
|
+
"TransactionViewer",
|
|
3143
|
+
"WindowedBlockViewer",
|
|
3144
|
+
"XyoViewer"
|
|
3145
|
+
];
|
|
3146
|
+
function synthesizeLmdbProviderBindings(transports) {
|
|
3147
|
+
const bindings = {};
|
|
3148
|
+
if (!hasTransport(transports, DEFAULT_LMDB_TRANSPORT)) {
|
|
3149
|
+
return bindings;
|
|
3150
|
+
}
|
|
3151
|
+
for (const moniker of LMDB_MONIKERS) {
|
|
3152
|
+
bindMoniker2(bindings, moniker, DEFAULT_LMDB_TRANSPORT);
|
|
3153
|
+
}
|
|
3154
|
+
return bindings;
|
|
3155
|
+
}
|
|
2639
3156
|
function synthesizeProviderBindings(transports) {
|
|
2640
3157
|
const bindings = {};
|
|
2641
3158
|
if (hasTransport(transports, DEFAULT_RPC_TRANSPORT)) {
|
|
2642
|
-
|
|
2643
|
-
|
|
2644
|
-
|
|
2645
|
-
bindings.TransactionViewer = { transport: DEFAULT_RPC_TRANSPORT };
|
|
2646
|
-
bindings.AccountBalanceViewer = { transport: DEFAULT_RPC_TRANSPORT };
|
|
3159
|
+
for (const moniker of RPC_MONIKERS) {
|
|
3160
|
+
bindMoniker2(bindings, moniker, DEFAULT_RPC_TRANSPORT);
|
|
3161
|
+
}
|
|
2647
3162
|
}
|
|
2648
3163
|
if (hasTransport(transports, S3_FINALIZED_TRANSPORT)) {
|
|
2649
|
-
bindings
|
|
3164
|
+
bindMoniker2(bindings, "BlockPublishRunner", S3_FINALIZED_TRANSPORT);
|
|
2650
3165
|
}
|
|
2651
3166
|
if (hasTransport(transports, S3_CHAIN_STATE_TRANSPORT)) {
|
|
2652
|
-
bindings
|
|
2653
|
-
bindings
|
|
3167
|
+
bindMoniker2(bindings, "ChainStateViewer", S3_CHAIN_STATE_TRANSPORT);
|
|
3168
|
+
bindMoniker2(bindings, "ChainStatePublishRunner", S3_CHAIN_STATE_TRANSPORT);
|
|
2654
3169
|
}
|
|
2655
3170
|
if (hasTransport(transports, S3_INDEX_TRANSPORT)) {
|
|
2656
|
-
bindings
|
|
3171
|
+
bindMoniker2(bindings, "IndexPublishRunner", S3_INDEX_TRANSPORT);
|
|
3172
|
+
}
|
|
3173
|
+
if (hasTransport(transports, DEFAULT_EVM_RPC_TRANSPORT)) {
|
|
3174
|
+
bindMoniker2(bindings, "ChainContractViewer", DEFAULT_EVM_RPC_TRANSPORT);
|
|
3175
|
+
bindMoniker2(bindings, "StakeEventsViewer", DEFAULT_EVM_RPC_TRANSPORT);
|
|
3176
|
+
bindMoniker2(bindings, "StakeTotalsViewer", DEFAULT_EVM_RPC_TRANSPORT);
|
|
3177
|
+
bindMoniker2(bindings, "StakeViewer", DEFAULT_EVM_RPC_TRANSPORT);
|
|
3178
|
+
bindMoniker2(bindings, "TimeSyncViewer", DEFAULT_EVM_RPC_TRANSPORT);
|
|
2657
3179
|
}
|
|
2658
3180
|
return bindings;
|
|
2659
3181
|
}
|
|
2660
3182
|
function adaptLegacyConfig(config) {
|
|
2661
3183
|
const parsed = ConfigZod.parse(config);
|
|
2662
|
-
if (
|
|
2663
|
-
return parsed;
|
|
3184
|
+
if (hasDeclaredConnectionProfiles(parsed)) {
|
|
3185
|
+
return ConfigZod.parse(normalizeConnectionsConfig(parsed));
|
|
2664
3186
|
}
|
|
2665
|
-
const transports = { ...parsed.transports };
|
|
2666
|
-
if (
|
|
3187
|
+
const transports = { ...parsed.transports, ...parsed.connections };
|
|
3188
|
+
if (isDefined16(parsed.storage?.root) && parsed.storage.root !== "") {
|
|
2667
3189
|
transports[DEFAULT_LMDB_TRANSPORT] = { type: "lmdb", root: parsed.storage.root };
|
|
2668
3190
|
}
|
|
2669
3191
|
if (hasMongoConfig(parsed.storage?.mongo)) {
|
|
@@ -2676,24 +3198,26 @@ function adaptLegacyConfig(config) {
|
|
|
2676
3198
|
username: parsed.storage.mongo.username
|
|
2677
3199
|
};
|
|
2678
3200
|
}
|
|
2679
|
-
if (
|
|
3201
|
+
if (isDefined16(parsed.remote?.rpc)) {
|
|
2680
3202
|
transports[DEFAULT_RPC_TRANSPORT] = rpcTransportFromRemote(parsed.remote.rpc);
|
|
2681
3203
|
}
|
|
2682
|
-
if (
|
|
3204
|
+
if (isDefined16(parsed.evm?.jsonRpc?.url)) {
|
|
2683
3205
|
transports[DEFAULT_EVM_RPC_TRANSPORT] = { type: "evm-rpc", url: parsed.evm.jsonRpc.url };
|
|
2684
3206
|
}
|
|
2685
|
-
if (
|
|
3207
|
+
if (isDefined16(parsed.storage?.s3)) {
|
|
2686
3208
|
Object.assign(transports, synthesizeS3Transports(parsed.storage.s3));
|
|
2687
3209
|
}
|
|
2688
3210
|
const providerBindings = {
|
|
3211
|
+
...synthesizeLmdbProviderBindings(transports),
|
|
2689
3212
|
...synthesizeProviderBindings(transports),
|
|
2690
3213
|
...parsed.providerBindings
|
|
2691
3214
|
};
|
|
2692
|
-
return ConfigZod.parse({
|
|
3215
|
+
return ConfigZod.parse(normalizeConnectionsConfig({
|
|
2693
3216
|
...parsed,
|
|
3217
|
+
connections: transports,
|
|
2694
3218
|
providerBindings,
|
|
2695
3219
|
transports
|
|
2696
|
-
});
|
|
3220
|
+
}));
|
|
2697
3221
|
}
|
|
2698
3222
|
|
|
2699
3223
|
// src/config/HostActor.ts
|
|
@@ -2827,7 +3351,7 @@ import { PayloadBundleSchema as PayloadBundleSchema2 } from "@xyo-network/sdk-js
|
|
|
2827
3351
|
import { PayloadBuilder as PayloadBuilder12 } from "@xyo-network/sdk-js";
|
|
2828
3352
|
|
|
2829
3353
|
// src/transaction/buildTransaction.ts
|
|
2830
|
-
import { assertEx as
|
|
3354
|
+
import { assertEx as assertEx21, toHex } from "@xylabs/sdk-js";
|
|
2831
3355
|
import {
|
|
2832
3356
|
asAnyPayload as asAnyPayload2,
|
|
2833
3357
|
BoundWitnessBuilder,
|
|
@@ -2853,7 +3377,7 @@ async function buildTransaction(chain, onChainPayloads, offChainPayloads, signer
|
|
|
2853
3377
|
const script = Array.from(elevatedHashes, (elevatedHash) => `elevate|${elevatedHash}`);
|
|
2854
3378
|
const fields = {
|
|
2855
3379
|
...txBoundWitnessFields,
|
|
2856
|
-
from: from ?? (Array.isArray(signer) ?
|
|
3380
|
+
from: from ?? (Array.isArray(signer) ? assertEx21(signer.at(0)?.address) : signer.address)
|
|
2857
3381
|
};
|
|
2858
3382
|
if (script.length > 0) {
|
|
2859
3383
|
fields.script = script;
|
|
@@ -2898,7 +3422,7 @@ async function buildUnsignedTransaction(chain, onChainPayloads, offChainPayloads
|
|
|
2898
3422
|
// src/transaction/confirmSubmittedTransaction.ts
|
|
2899
3423
|
import {
|
|
2900
3424
|
delay,
|
|
2901
|
-
isDefined as
|
|
3425
|
+
isDefined as isDefined17,
|
|
2902
3426
|
isNumber
|
|
2903
3427
|
} from "@xylabs/sdk-js";
|
|
2904
3428
|
var DEFAULT_CONFIRMATION_ATTEMPTS = 20;
|
|
@@ -2920,7 +3444,7 @@ var confirmSubmittedTransaction = async (viewer, txHash, options) => {
|
|
|
2920
3444
|
let attempts = 0;
|
|
2921
3445
|
while (true) {
|
|
2922
3446
|
const tx = await viewer.transaction.byHash(txHash) ?? void 0;
|
|
2923
|
-
if (
|
|
3447
|
+
if (isDefined17(tx)) {
|
|
2924
3448
|
options?.logger?.debug("Transaction confirmed", txHash);
|
|
2925
3449
|
return tx;
|
|
2926
3450
|
}
|
|
@@ -2938,7 +3462,7 @@ var confirmSubmittedTransaction = async (viewer, txHash, options) => {
|
|
|
2938
3462
|
};
|
|
2939
3463
|
|
|
2940
3464
|
// src/transaction/hydrateTransaction.ts
|
|
2941
|
-
import { assertEx as
|
|
3465
|
+
import { assertEx as assertEx22 } from "@xylabs/sdk-js";
|
|
2942
3466
|
import {
|
|
2943
3467
|
asAnyPayload as asAnyPayload3,
|
|
2944
3468
|
hydrateTypedBoundWitness,
|
|
@@ -3009,7 +3533,7 @@ var tryHydrateElevatedTransaction = async ({ chainMap }, hash) => {
|
|
|
3009
3533
|
return void 0;
|
|
3010
3534
|
};
|
|
3011
3535
|
var hydrateElevatedTransaction = async (context, hash) => {
|
|
3012
|
-
return
|
|
3536
|
+
return assertEx22(await tryHydrateElevatedTransaction(context, hash), () => "Hydration failed");
|
|
3013
3537
|
};
|
|
3014
3538
|
|
|
3015
3539
|
// src/transaction/primitives/transactionBlockByteCount.ts
|
|
@@ -3062,13 +3586,13 @@ function transactionRequiredGas(hydratedTransaction) {
|
|
|
3062
3586
|
|
|
3063
3587
|
// src/transaction/signTransaction.ts
|
|
3064
3588
|
import {
|
|
3065
|
-
assertEx as
|
|
3589
|
+
assertEx as assertEx23,
|
|
3066
3590
|
hexFromArrayBuffer,
|
|
3067
3591
|
toArrayBuffer
|
|
3068
3592
|
} from "@xylabs/sdk-js";
|
|
3069
3593
|
import { PayloadBuilder as PayloadBuilder10 } from "@xyo-network/sdk-js";
|
|
3070
3594
|
async function signTransaction(tx, account) {
|
|
3071
|
-
|
|
3595
|
+
assertEx23(tx.from === account.address, () => "Signer address does not match transaction from address");
|
|
3072
3596
|
const unsignedTx = structuredClone(tx);
|
|
3073
3597
|
unsignedTx.addresses = [account.address];
|
|
3074
3598
|
unsignedTx.previous_hashes = [account.previousHash ?? null];
|
|
@@ -3083,7 +3607,7 @@ async function signTransaction(tx, account) {
|
|
|
3083
3607
|
}
|
|
3084
3608
|
|
|
3085
3609
|
// src/transaction/TransactionBuilder.ts
|
|
3086
|
-
import { assertEx as
|
|
3610
|
+
import { assertEx as assertEx24, Base } from "@xylabs/sdk-js";
|
|
3087
3611
|
import { PayloadBuilder as PayloadBuilder11 } from "@xyo-network/sdk-js";
|
|
3088
3612
|
import {
|
|
3089
3613
|
asXL1BlockNumber as asXL1BlockNumber4,
|
|
@@ -3103,9 +3627,9 @@ var TransactionBuilder = class extends Base {
|
|
|
3103
3627
|
super(options);
|
|
3104
3628
|
}
|
|
3105
3629
|
async build() {
|
|
3106
|
-
const chain =
|
|
3107
|
-
const fees =
|
|
3108
|
-
const blockRange =
|
|
3630
|
+
const chain = assertEx24(this._chain, () => "Chain must be set before building the transaction");
|
|
3631
|
+
const fees = assertEx24(this._fees, () => "Fees must be set before building the transaction");
|
|
3632
|
+
const blockRange = assertEx24(this._blockRange, () => "Block range must be set before building the transaction");
|
|
3109
3633
|
return await buildTransaction(
|
|
3110
3634
|
chain,
|
|
3111
3635
|
this._elevatedPayloads,
|
|
@@ -3135,7 +3659,7 @@ var TransactionBuilder = class extends Base {
|
|
|
3135
3659
|
}
|
|
3136
3660
|
elevatedPayload(payload) {
|
|
3137
3661
|
const allowedPayload = isAllowedBlockPayload2(payload) ? payload : void 0;
|
|
3138
|
-
const allowPayloadExists =
|
|
3662
|
+
const allowPayloadExists = assertEx24(allowedPayload, () => "Payload must be an AllowedBlockPayload");
|
|
3139
3663
|
this._elevatedPayloads.push(allowPayloadExists);
|
|
3140
3664
|
return this;
|
|
3141
3665
|
}
|
|
@@ -3184,158 +3708,64 @@ var TransactionBuilder = class extends Base {
|
|
|
3184
3708
|
async removeElevatedPayload(payload) {
|
|
3185
3709
|
const hash = await PayloadBuilder11.hash(payload);
|
|
3186
3710
|
const existingHashes = await PayloadBuilder11.hashes(this._elevatedPayloads);
|
|
3187
|
-
const existingPayloadIndex = existingHashes.indexOf(hash);
|
|
3188
|
-
if (existingPayloadIndex === -1) {
|
|
3189
|
-
throw new Error("Payload not found in the transaction");
|
|
3190
|
-
}
|
|
3191
|
-
this._elevatedPayloads = this._elevatedPayloads.filter((_, index) => index !== existingPayloadIndex);
|
|
3192
|
-
return this;
|
|
3193
|
-
}
|
|
3194
|
-
async removePayload(payload) {
|
|
3195
|
-
const hash = await PayloadBuilder11.hash(payload);
|
|
3196
|
-
const existingHashes = await PayloadBuilder11.hashes(this._payloads);
|
|
3197
|
-
const existingPayloadIndex = existingHashes.indexOf(hash);
|
|
3198
|
-
if (existingPayloadIndex === -1) {
|
|
3199
|
-
throw new Error("Payload not found in the transaction");
|
|
3200
|
-
}
|
|
3201
|
-
this._payloads = this._payloads.filter((_, index) => index !== existingPayloadIndex);
|
|
3202
|
-
return this;
|
|
3203
|
-
}
|
|
3204
|
-
signer(signer) {
|
|
3205
|
-
if (signer) {
|
|
3206
|
-
this._signers.push(signer);
|
|
3207
|
-
}
|
|
3208
|
-
return this;
|
|
3209
|
-
}
|
|
3210
|
-
signers(signers) {
|
|
3211
|
-
if (signers)
|
|
3212
|
-
for (const signer of signers) {
|
|
3213
|
-
if (signer !== null) {
|
|
3214
|
-
this.signer(signer);
|
|
3215
|
-
}
|
|
3216
|
-
}
|
|
3217
|
-
return this;
|
|
3218
|
-
}
|
|
3219
|
-
};
|
|
3220
|
-
|
|
3221
|
-
// src/model/PayloadBundle/hydratedTransactionToPayloadBundle.ts
|
|
3222
|
-
var hydratedTransactionToPayloadBundle = (transaction) => {
|
|
3223
|
-
const root = transaction[0]._hash;
|
|
3224
|
-
return bundle2(root, transaction);
|
|
3225
|
-
};
|
|
3226
|
-
var bundle2 = (root, transaction) => {
|
|
3227
|
-
const payloads = flattenHydratedTransaction(transaction);
|
|
3228
|
-
const payloadBuilder = new PayloadBuilder12({ schema: PayloadBundleSchema2 });
|
|
3229
|
-
const builder = payloadBuilder.fields({ payloads, root });
|
|
3230
|
-
return builder.build();
|
|
3231
|
-
};
|
|
3232
|
-
|
|
3233
|
-
// src/context/Actor.ts
|
|
3234
|
-
var ActorConfigContext = z26.extend(BaseConfigContextZod, { config: ActorConfigZod });
|
|
3235
|
-
var isActorConfigContext = zodIsFactory5(ActorConfigContext);
|
|
3236
|
-
var asActorConfigContext = zodAsFactory6(ActorConfigContext, "asActorConfigContext");
|
|
3237
|
-
var toActorConfigContext = zodToFactory5(ActorConfigContext, "toActorConfigContext");
|
|
3238
|
-
|
|
3239
|
-
// src/CreatableProvider/AbstractCreatableProvider.ts
|
|
3240
|
-
import {
|
|
3241
|
-
AbstractCreatable,
|
|
3242
|
-
assertEx as assertEx24,
|
|
3243
|
-
IdLogger
|
|
3244
|
-
} from "@xylabs/sdk-js";
|
|
3245
|
-
|
|
3246
|
-
// src/CreatableProvider/ProviderFactory.ts
|
|
3247
|
-
import { assertEx as assertEx23 } from "@xylabs/sdk-js";
|
|
3248
|
-
function providerFactoryDescription(factory, labels) {
|
|
3249
|
-
return `${factory.providerName}:${factory.defaultMoniker}:${JSON.stringify(labels ?? factory.labels ?? {})}`;
|
|
3250
|
-
}
|
|
3251
|
-
var ProviderFactory = class _ProviderFactory {
|
|
3252
|
-
creatableProvider;
|
|
3253
|
-
defaultMoniker;
|
|
3254
|
-
defaultParams;
|
|
3255
|
-
dependencies;
|
|
3256
|
-
labels;
|
|
3257
|
-
monikers;
|
|
3258
|
-
providerName;
|
|
3259
|
-
scope;
|
|
3260
|
-
_uniqueId;
|
|
3261
|
-
constructor(creatableProvider2, dependencies, params, labels = {}, scope = "context") {
|
|
3262
|
-
this.creatableProvider = creatableProvider2;
|
|
3263
|
-
this.defaultParams = params;
|
|
3264
|
-
this.defaultMoniker = creatableProvider2.defaultMoniker;
|
|
3265
|
-
this.dependencies = dependencies;
|
|
3266
|
-
this.monikers = creatableProvider2.monikers;
|
|
3267
|
-
this.scope = scope;
|
|
3268
|
-
assertEx23(this.monikers.includes(this.defaultMoniker), () => "defaultMoniker must be in monikers");
|
|
3269
|
-
this.labels = Object.assign({}, creatableProvider2.labels ?? {}, labels ?? {});
|
|
3270
|
-
this.providerName = creatableProvider2.name;
|
|
3271
|
-
this._uniqueId = Symbol(providerFactoryDescription(this));
|
|
3272
|
-
}
|
|
3273
|
-
get resolvedMoniker() {
|
|
3274
|
-
const labels = this.labels ?? {};
|
|
3275
|
-
const labelString = Object.entries(labels).map(([key, value]) => `${key}=${value}`).join(",");
|
|
3276
|
-
return labelString.length === 0 ? this.defaultMoniker : `${this.defaultMoniker}|${labelString}`;
|
|
3277
|
-
}
|
|
3278
|
-
get uniqueId() {
|
|
3279
|
-
return this._uniqueId;
|
|
3280
|
-
}
|
|
3281
|
-
static withParams(creatableProvider2, dependencies, params, labels = {}) {
|
|
3282
|
-
return new _ProviderFactory(creatableProvider2, dependencies, params, labels);
|
|
3283
|
-
}
|
|
3284
|
-
factory(dependencies, params, labels = {}) {
|
|
3285
|
-
return new _ProviderFactory(this.creatableProvider, dependencies, params, labels);
|
|
3286
|
-
}
|
|
3287
|
-
async getInstance(params, { start = true }) {
|
|
3288
|
-
let scopeObject;
|
|
3289
|
-
switch (this.scope) {
|
|
3290
|
-
case "global": {
|
|
3291
|
-
scopeObject = getOrCreateGlobalSingletons();
|
|
3292
|
-
break;
|
|
3293
|
-
}
|
|
3294
|
-
case "context": {
|
|
3295
|
-
const context = assertEx23(
|
|
3296
|
-
params?.context,
|
|
3297
|
-
() => "Context is required for context-scoped providers"
|
|
3298
|
-
);
|
|
3299
|
-
context.singletons ??= {};
|
|
3300
|
-
scopeObject = context.singletons;
|
|
3301
|
-
break;
|
|
3302
|
-
}
|
|
3303
|
-
default: {
|
|
3304
|
-
scopeObject = {};
|
|
3305
|
-
break;
|
|
3306
|
-
}
|
|
3307
|
-
}
|
|
3308
|
-
const mergedParams = {
|
|
3309
|
-
...this.defaultParams,
|
|
3310
|
-
...params
|
|
3311
|
-
};
|
|
3312
|
-
const resultPromise = scopeObject[this.resolvedMoniker] ?? this.creatableProvider.create(mergedParams);
|
|
3313
|
-
scopeObject[this.resolvedMoniker] = resultPromise;
|
|
3314
|
-
const result = await resultPromise;
|
|
3315
|
-
if (start) {
|
|
3316
|
-
assertEx23(await result.start(), () => `Failed to start provider instance [${this.resolvedMoniker}]`);
|
|
3711
|
+
const existingPayloadIndex = existingHashes.indexOf(hash);
|
|
3712
|
+
if (existingPayloadIndex === -1) {
|
|
3713
|
+
throw new Error("Payload not found in the transaction");
|
|
3317
3714
|
}
|
|
3318
|
-
|
|
3715
|
+
this._elevatedPayloads = this._elevatedPayloads.filter((_, index) => index !== existingPayloadIndex);
|
|
3716
|
+
return this;
|
|
3319
3717
|
}
|
|
3320
|
-
async
|
|
3321
|
-
|
|
3322
|
-
|
|
3323
|
-
|
|
3324
|
-
|
|
3718
|
+
async removePayload(payload) {
|
|
3719
|
+
const hash = await PayloadBuilder11.hash(payload);
|
|
3720
|
+
const existingHashes = await PayloadBuilder11.hashes(this._payloads);
|
|
3721
|
+
const existingPayloadIndex = existingHashes.indexOf(hash);
|
|
3722
|
+
if (existingPayloadIndex === -1) {
|
|
3723
|
+
throw new Error("Payload not found in the transaction");
|
|
3325
3724
|
}
|
|
3725
|
+
this._payloads = this._payloads.filter((_, index) => index !== existingPayloadIndex);
|
|
3726
|
+
return this;
|
|
3326
3727
|
}
|
|
3327
|
-
|
|
3328
|
-
|
|
3329
|
-
|
|
3330
|
-
|
|
3331
|
-
return
|
|
3728
|
+
signer(signer) {
|
|
3729
|
+
if (signer) {
|
|
3730
|
+
this._signers.push(signer);
|
|
3731
|
+
}
|
|
3732
|
+
return this;
|
|
3332
3733
|
}
|
|
3333
|
-
|
|
3334
|
-
|
|
3335
|
-
|
|
3336
|
-
|
|
3734
|
+
signers(signers) {
|
|
3735
|
+
if (signers)
|
|
3736
|
+
for (const signer of signers) {
|
|
3737
|
+
if (signer !== null) {
|
|
3738
|
+
this.signer(signer);
|
|
3739
|
+
}
|
|
3740
|
+
}
|
|
3741
|
+
return this;
|
|
3742
|
+
}
|
|
3743
|
+
};
|
|
3744
|
+
|
|
3745
|
+
// src/model/PayloadBundle/hydratedTransactionToPayloadBundle.ts
|
|
3746
|
+
var hydratedTransactionToPayloadBundle = (transaction) => {
|
|
3747
|
+
const root = transaction[0]._hash;
|
|
3748
|
+
return bundle2(root, transaction);
|
|
3749
|
+
};
|
|
3750
|
+
var bundle2 = (root, transaction) => {
|
|
3751
|
+
const payloads = flattenHydratedTransaction(transaction);
|
|
3752
|
+
const payloadBuilder = new PayloadBuilder12({ schema: PayloadBundleSchema2 });
|
|
3753
|
+
const builder = payloadBuilder.fields({ payloads, root });
|
|
3754
|
+
return builder.build();
|
|
3755
|
+
};
|
|
3756
|
+
|
|
3757
|
+
// src/context/Actor.ts
|
|
3758
|
+
var ActorConfigContext = z26.extend(BaseConfigContextZod, { config: ActorConfigZod });
|
|
3759
|
+
var isActorConfigContext = zodIsFactory5(ActorConfigContext);
|
|
3760
|
+
var asActorConfigContext = zodAsFactory6(ActorConfigContext, "asActorConfigContext");
|
|
3761
|
+
var toActorConfigContext = zodToFactory5(ActorConfigContext, "toActorConfigContext");
|
|
3337
3762
|
|
|
3338
3763
|
// src/CreatableProvider/AbstractCreatableProvider.ts
|
|
3764
|
+
import {
|
|
3765
|
+
AbstractCreatable,
|
|
3766
|
+
assertEx as assertEx25,
|
|
3767
|
+
IdLogger
|
|
3768
|
+
} from "@xylabs/sdk-js";
|
|
3339
3769
|
var AbstractCreatableProvider = class extends AbstractCreatable {
|
|
3340
3770
|
dependencies = {};
|
|
3341
3771
|
_contextCache;
|
|
@@ -3367,9 +3797,9 @@ var AbstractCreatableProvider = class extends AbstractCreatable {
|
|
|
3367
3797
|
return factory;
|
|
3368
3798
|
}
|
|
3369
3799
|
static async paramsHandler(params = {}) {
|
|
3370
|
-
const context =
|
|
3371
|
-
const config =
|
|
3372
|
-
const locator =
|
|
3800
|
+
const context = assertEx25(params.context, () => new Error("Context is required"));
|
|
3801
|
+
const config = assertEx25(context.config, () => new Error("Context config is required"));
|
|
3802
|
+
const locator = assertEx25(context.locator, () => new Error("Context locator is required"));
|
|
3373
3803
|
return await super.paramsHandler({
|
|
3374
3804
|
...params,
|
|
3375
3805
|
statusReporter: params.statusReporter ?? context.statusReporter,
|
|
@@ -3411,203 +3841,6 @@ function labeledCreatableProvider() {
|
|
|
3411
3841
|
};
|
|
3412
3842
|
}
|
|
3413
3843
|
|
|
3414
|
-
// src/CreatableProvider/CreatableProviderRegistry.ts
|
|
3415
|
-
import { isTruthy } from "@xylabs/sdk-js";
|
|
3416
|
-
var buildProviderFactory = (provider, defaultParams, labels) => {
|
|
3417
|
-
const factory = {
|
|
3418
|
-
monikers: provider.monikers,
|
|
3419
|
-
uniqueId: Symbol(providerFactoryDescription(provider, labels)),
|
|
3420
|
-
// Merge module & supplied labels
|
|
3421
|
-
labels: { ...provider.labels, ...labels },
|
|
3422
|
-
creatableProvider: provider.creatableProvider,
|
|
3423
|
-
dependencies: provider.dependencies,
|
|
3424
|
-
resolvedMoniker: provider.resolvedMoniker,
|
|
3425
|
-
providerName: provider.providerName,
|
|
3426
|
-
scope: provider.scope,
|
|
3427
|
-
defaultParams,
|
|
3428
|
-
getInstance: provider.getInstance.bind(provider),
|
|
3429
|
-
tryGetInstance: provider.tryGetInstance?.bind(provider),
|
|
3430
|
-
defaultMoniker: provider.defaultMoniker,
|
|
3431
|
-
factory: provider.factory.bind(provider)
|
|
3432
|
-
};
|
|
3433
|
-
return factory;
|
|
3434
|
-
};
|
|
3435
|
-
var registerCreatableProviderFactory = (registry, factory, labels, primary = false) => {
|
|
3436
|
-
const primaryMonikers = primary !== true && isTruthy(primary) ? Array.isArray(primary) ? primary : [primary] : [];
|
|
3437
|
-
for (const primaryMoniker of primaryMonikers) {
|
|
3438
|
-
if (!factory.monikers.includes(primaryMoniker)) {
|
|
3439
|
-
throw new Error(`Primary moniker ${String(primaryMoniker)} not found in factory monikers`);
|
|
3440
|
-
}
|
|
3441
|
-
}
|
|
3442
|
-
const isPrimaryForMoniker = (moniker) => {
|
|
3443
|
-
switch (typeof primary) {
|
|
3444
|
-
case "boolean": {
|
|
3445
|
-
return primary;
|
|
3446
|
-
}
|
|
3447
|
-
case "string": {
|
|
3448
|
-
return moniker === primary;
|
|
3449
|
-
}
|
|
3450
|
-
case "object": {
|
|
3451
|
-
if (Array.isArray(primary)) {
|
|
3452
|
-
return primary.includes(moniker);
|
|
3453
|
-
}
|
|
3454
|
-
}
|
|
3455
|
-
}
|
|
3456
|
-
throw new Error(`Invalid primary value: ${String(primary)}`);
|
|
3457
|
-
};
|
|
3458
|
-
const factoryClone = buildProviderFactory(factory, factory.defaultParams, labels);
|
|
3459
|
-
registry[factoryClone.defaultMoniker] = [factoryClone, ...registry[factoryClone.defaultMoniker] ?? []];
|
|
3460
|
-
for (const moniker of factoryClone.monikers) {
|
|
3461
|
-
if (moniker === factoryClone.defaultMoniker) continue;
|
|
3462
|
-
registry[moniker] = isPrimaryForMoniker(moniker) ? [factoryClone, ...registry[moniker] ?? []] : [...registry[moniker] ?? [], factoryClone];
|
|
3463
|
-
}
|
|
3464
|
-
};
|
|
3465
|
-
var registerCreatableProviderFactories = (factories, registry = {}, primary = false) => {
|
|
3466
|
-
for (const factory of factories) {
|
|
3467
|
-
registerCreatableProviderFactory(registry, factory, void 0, primary);
|
|
3468
|
-
}
|
|
3469
|
-
return registry;
|
|
3470
|
-
};
|
|
3471
|
-
|
|
3472
|
-
// src/CreatableProvider/LabeledCreatableProviderFactory.ts
|
|
3473
|
-
var hasLabels = (factory) => {
|
|
3474
|
-
return factory.labels !== void 0;
|
|
3475
|
-
};
|
|
3476
|
-
function labeledCreatableProviderFactory() {
|
|
3477
|
-
return (constructor) => {
|
|
3478
|
-
constructor;
|
|
3479
|
-
};
|
|
3480
|
-
}
|
|
3481
|
-
|
|
3482
|
-
// src/CreatableProvider/ProviderFactoryLocator.ts
|
|
3483
|
-
import { hasAllLabels } from "@xylabs/sdk-js";
|
|
3484
|
-
import { assertEx as assertEx25 } from "@xylabs/sdk-js";
|
|
3485
|
-
var ProviderFactoryLocator = class _ProviderFactoryLocator {
|
|
3486
|
-
_context;
|
|
3487
|
-
_registry;
|
|
3488
|
-
_frozen = false;
|
|
3489
|
-
_parent;
|
|
3490
|
-
_validateDepsOnRegister;
|
|
3491
|
-
constructor(context, registry = {}, validateDepsOnRegister = false) {
|
|
3492
|
-
this._registry = registry;
|
|
3493
|
-
this._context = { ...context, locator: this };
|
|
3494
|
-
this._parent = context.locator;
|
|
3495
|
-
this._validateDepsOnRegister = validateDepsOnRegister;
|
|
3496
|
-
}
|
|
3497
|
-
get context() {
|
|
3498
|
-
return this._context;
|
|
3499
|
-
}
|
|
3500
|
-
get logger() {
|
|
3501
|
-
return this.context.logger;
|
|
3502
|
-
}
|
|
3503
|
-
/**
|
|
3504
|
-
* The current registry for the module factory
|
|
3505
|
-
*/
|
|
3506
|
-
get registry() {
|
|
3507
|
-
return this._registry;
|
|
3508
|
-
}
|
|
3509
|
-
get validateDepsOnRegister() {
|
|
3510
|
-
return this._validateDepsOnRegister;
|
|
3511
|
-
}
|
|
3512
|
-
freeze() {
|
|
3513
|
-
this._frozen = true;
|
|
3514
|
-
}
|
|
3515
|
-
async getInstance(moniker, { start = true, labels } = {}) {
|
|
3516
|
-
return assertEx25(
|
|
3517
|
-
await this.tryGetInstance(moniker, { start, labels }),
|
|
3518
|
-
() => `No provider instance for the supplied config moniker [${moniker}]${labels ? ` & labels [${JSON.stringify(labels)}]` : ""} could be created`
|
|
3519
|
-
);
|
|
3520
|
-
}
|
|
3521
|
-
has(moniker) {
|
|
3522
|
-
return Object.hasOwn(this._registry, moniker);
|
|
3523
|
-
}
|
|
3524
|
-
/**
|
|
3525
|
-
* Locates a provider factory that matches the supplied moniker and labels
|
|
3526
|
-
* @param moniker The config moniker for the provider
|
|
3527
|
-
* @param labels The labels for the provider factory
|
|
3528
|
-
* @returns A provider factory that matches the supplied moniker and labels or throws if one is not found
|
|
3529
|
-
*/
|
|
3530
|
-
locate(moniker, labels) {
|
|
3531
|
-
return assertEx25(
|
|
3532
|
-
this.tryLocate(moniker, labels),
|
|
3533
|
-
() => `No module factory for the supplied config moniker [${moniker}]${labels ? ` & labels [${JSON.stringify(labels)}]` : ""} registered`
|
|
3534
|
-
);
|
|
3535
|
-
}
|
|
3536
|
-
merge(locator) {
|
|
3537
|
-
const registry = { ...this.registry };
|
|
3538
|
-
for (const moniker in locator.registry) {
|
|
3539
|
-
const existing = registry[moniker];
|
|
3540
|
-
if (existing === void 0) {
|
|
3541
|
-
registry[moniker] = locator.registry[moniker];
|
|
3542
|
-
} else {
|
|
3543
|
-
existing.push(...locator.registry[moniker] ?? []);
|
|
3544
|
-
}
|
|
3545
|
-
}
|
|
3546
|
-
return new _ProviderFactoryLocator(this.context, registry);
|
|
3547
|
-
}
|
|
3548
|
-
/**
|
|
3549
|
-
* Registers a single module factory (with optional tags) with the locator
|
|
3550
|
-
* @param factory The factory to register
|
|
3551
|
-
* @param labels The labels for the module factory
|
|
3552
|
-
*/
|
|
3553
|
-
register(factory, labels, primary = false) {
|
|
3554
|
-
assertEx25(!this._frozen, () => "Cannot register a module factory after the locator has been frozen");
|
|
3555
|
-
if (this.validateDepsOnRegister) {
|
|
3556
|
-
const missingDeps = factory.dependencies.filter((dep) => !this.registered(dep));
|
|
3557
|
-
assertEx25(missingDeps.length === 0, () => `Cannot register module factory [${factory.uniqueId.description}] due to missing dependencies: ${missingDeps.join(", ")}`);
|
|
3558
|
-
}
|
|
3559
|
-
registerCreatableProviderFactory(this._registry, factory, labels, primary);
|
|
3560
|
-
return this;
|
|
3561
|
-
}
|
|
3562
|
-
/**
|
|
3563
|
-
* Registers multiple module factories with the locator
|
|
3564
|
-
* @param factories The factories to register
|
|
3565
|
-
*/
|
|
3566
|
-
registerMany(factories) {
|
|
3567
|
-
for (const factory of factories) {
|
|
3568
|
-
this.register(factory);
|
|
3569
|
-
}
|
|
3570
|
-
return this;
|
|
3571
|
-
}
|
|
3572
|
-
registered(moniker) {
|
|
3573
|
-
return Object.hasOwn(this.registry, moniker) || (this._parent?.registered(moniker) ?? false);
|
|
3574
|
-
}
|
|
3575
|
-
async tryGetInstance(moniker, { start = true, labels } = {}) {
|
|
3576
|
-
const resolvedParams = { context: this.context };
|
|
3577
|
-
const factory = this.tryLocate(moniker, labels);
|
|
3578
|
-
if (factory !== void 0) {
|
|
3579
|
-
if (Object.hasOwn(this.context.singletons, factory.uniqueId)) {
|
|
3580
|
-
return this.context.singletons[factory.uniqueId];
|
|
3581
|
-
}
|
|
3582
|
-
this.logger?.debug(`Creating provider instance for moniker [${moniker}]${labels ? ` with labels [${JSON.stringify(labels)}]` : ""} using factory [${factory.uniqueId.description}]`);
|
|
3583
|
-
const result = await factory.getInstance(resolvedParams, { start });
|
|
3584
|
-
this.context.singletons[factory.uniqueId] = result;
|
|
3585
|
-
return result;
|
|
3586
|
-
}
|
|
3587
|
-
}
|
|
3588
|
-
/**
|
|
3589
|
-
* Tries to locate a module factory that matches the supplied moniker and labels
|
|
3590
|
-
* @param moniker The config moniker for the module
|
|
3591
|
-
* @param labels The labels for the module factory
|
|
3592
|
-
* @returns A module factory that matches the supplied moniker and labels or undefined
|
|
3593
|
-
*/
|
|
3594
|
-
tryLocate(moniker, labels) {
|
|
3595
|
-
const result = (labels ? this._registry[moniker]?.filter(hasLabels).find((factory) => hasAllLabels(factory?.labels, labels)) ?? this._registry[moniker]?.[0] : this._registry[moniker]?.[0]) ?? this._parent?.tryLocate(moniker, labels);
|
|
3596
|
-
return result;
|
|
3597
|
-
}
|
|
3598
|
-
validateDependencies(recursive = false) {
|
|
3599
|
-
if (recursive) {
|
|
3600
|
-
this._parent?.validateDependencies();
|
|
3601
|
-
}
|
|
3602
|
-
for (const moniker in this.registry) {
|
|
3603
|
-
for (const factory of this.registry[moniker] ?? []) {
|
|
3604
|
-
const missingDeps = factory.dependencies.filter((dep) => !this.registered(dep));
|
|
3605
|
-
assertEx25(missingDeps.length === 0, () => `Module factory [${factory.uniqueId.description}] is missing dependencies: ${missingDeps.join(", ")}`);
|
|
3606
|
-
}
|
|
3607
|
-
}
|
|
3608
|
-
}
|
|
3609
|
-
};
|
|
3610
|
-
|
|
3611
3844
|
// src/context/getEmptyProviderContext.ts
|
|
3612
3845
|
function getEmptyProviderContext(config) {
|
|
3613
3846
|
const singletons = {};
|
|
@@ -3637,13 +3870,13 @@ var asHostActorConfigContext = zodAsFactory7(HostActorConfigContext, "asHostActo
|
|
|
3637
3870
|
var toHostActorConfigContext = zodToFactory6(HostActorConfigContext, "toHostActorConfigContext");
|
|
3638
3871
|
|
|
3639
3872
|
// src/createDeclarationPayload.ts
|
|
3640
|
-
import { isDefined as
|
|
3873
|
+
import { isDefined as isDefined18 } from "@xylabs/sdk-js";
|
|
3641
3874
|
import { PayloadBuilder as PayloadBuilder13 } from "@xyo-network/sdk-js";
|
|
3642
3875
|
import {
|
|
3643
3876
|
ChainStakeIntentSchema
|
|
3644
3877
|
} from "@xyo-network/xl1-protocol-lib";
|
|
3645
3878
|
var createDeclarationIntent = (address, intent, nbf, exp) => {
|
|
3646
|
-
const expiration =
|
|
3879
|
+
const expiration = isDefined18(exp) ? exp : nbf + 1e4;
|
|
3647
3880
|
const payloadBuilder = new PayloadBuilder13({ schema: ChainStakeIntentSchema });
|
|
3648
3881
|
const builder = payloadBuilder.fields({
|
|
3649
3882
|
from: address,
|
|
@@ -3827,7 +4060,7 @@ import {
|
|
|
3827
4060
|
asHash as asHash4,
|
|
3828
4061
|
assertEx as assertEx33,
|
|
3829
4062
|
exists as exists3,
|
|
3830
|
-
isDefined as
|
|
4063
|
+
isDefined as isDefined19,
|
|
3831
4064
|
ZERO_ADDRESS
|
|
3832
4065
|
} from "@xylabs/sdk-js";
|
|
3833
4066
|
import {
|
|
@@ -4326,7 +4559,7 @@ var SimpleAccountBalanceViewer = class extends AbstractCreatableProvider {
|
|
|
4326
4559
|
block[1].find((p) => p._hash === hash),
|
|
4327
4560
|
() => `Error: Could not find Transfer with hash ${hash} in block ${block[0]._hash}`
|
|
4328
4561
|
);
|
|
4329
|
-
}).filter(exists3).filter((t) => t.from === address ||
|
|
4562
|
+
}).filter(exists3).filter((t) => t.from === address || isDefined19(t.transfers[address]));
|
|
4330
4563
|
if (transfers.length === 0) {
|
|
4331
4564
|
continue;
|
|
4332
4565
|
}
|
|
@@ -4445,7 +4678,7 @@ var SimpleAccountBalanceViewer = class extends AbstractCreatableProvider {
|
|
|
4445
4678
|
return await this.spanAsync("qualifiedAccountBalanceHistory", async () => {
|
|
4446
4679
|
const range = asRange(headOrRange);
|
|
4447
4680
|
const headHash = asHash4(headOrRange);
|
|
4448
|
-
const [head] = assertEx33(
|
|
4681
|
+
const [head] = assertEx33(isDefined19(headHash) ? await this.blockViewer.blockByHash(headHash) : await this.blockViewer.currentBlock(), () => "Could not resolve head block");
|
|
4449
4682
|
const startingRange = asXL1BlockRange10(range ?? [0, head.block], true);
|
|
4450
4683
|
const blockNumbers = await this.distillTransferHistory(address, startingRange);
|
|
4451
4684
|
const blockResults = await Promise.all(blockNumbers.map(async (bn) => await this.blockViewer.blockByNumber(bn)));
|
|
@@ -4459,7 +4692,7 @@ var SimpleAccountBalanceViewer = class extends AbstractCreatableProvider {
|
|
|
4459
4692
|
block[1].find((p) => p._hash === hash),
|
|
4460
4693
|
() => `Error: Could not find Transfer with hash ${hash} in block ${block[0]._hash}`
|
|
4461
4694
|
);
|
|
4462
|
-
}).filter(exists3).filter((t) => t.from === address ||
|
|
4695
|
+
}).filter(exists3).filter((t) => t.from === address || isDefined19(t.transfers[address]));
|
|
4463
4696
|
if (transfers.length === 0) {
|
|
4464
4697
|
continue;
|
|
4465
4698
|
}
|
|
@@ -4476,9 +4709,11 @@ var SimpleAccountBalanceViewer = class extends AbstractCreatableProvider {
|
|
|
4476
4709
|
}, this.context);
|
|
4477
4710
|
}
|
|
4478
4711
|
};
|
|
4712
|
+
__publicField(SimpleAccountBalanceViewer, "connectionTypes", ["lmdb", "mongo"]);
|
|
4479
4713
|
__publicField(SimpleAccountBalanceViewer, "defaultMoniker", AccountBalanceViewerMoniker);
|
|
4480
4714
|
__publicField(SimpleAccountBalanceViewer, "dependencies", [BlockViewerMoniker]);
|
|
4481
4715
|
__publicField(SimpleAccountBalanceViewer, "monikers", [AccountBalanceViewerMoniker]);
|
|
4716
|
+
__publicField(SimpleAccountBalanceViewer, "surface", "node");
|
|
4482
4717
|
SimpleAccountBalanceViewer = __decorateClass([
|
|
4483
4718
|
creatableProvider()
|
|
4484
4719
|
], SimpleAccountBalanceViewer);
|
|
@@ -4776,9 +5011,11 @@ var SimpleBlockViewer = class extends AbstractCreatableProvider {
|
|
|
4776
5011
|
this._headPollTimer = null;
|
|
4777
5012
|
}
|
|
4778
5013
|
};
|
|
5014
|
+
__publicField(SimpleBlockViewer, "connectionTypes", ["lmdb", "mongo"]);
|
|
4779
5015
|
__publicField(SimpleBlockViewer, "defaultMoniker", BlockViewerMoniker2);
|
|
4780
5016
|
__publicField(SimpleBlockViewer, "dependencies", [FinalizationViewerMoniker]);
|
|
4781
5017
|
__publicField(SimpleBlockViewer, "monikers", [BlockViewerMoniker2]);
|
|
5018
|
+
__publicField(SimpleBlockViewer, "surface", "node");
|
|
4782
5019
|
SimpleBlockViewer = __decorateClass([
|
|
4783
5020
|
creatableProvider()
|
|
4784
5021
|
], SimpleBlockViewer);
|
|
@@ -4793,9 +5030,11 @@ var SimpleBlockRewardViewer = class extends AbstractCreatableProvider {
|
|
|
4793
5030
|
);
|
|
4794
5031
|
}
|
|
4795
5032
|
};
|
|
5033
|
+
__publicField(SimpleBlockRewardViewer, "connectionTypes", ["lmdb", "mongo", "rpc"]);
|
|
4796
5034
|
__publicField(SimpleBlockRewardViewer, "defaultMoniker", BlockRewardViewerMoniker);
|
|
4797
5035
|
__publicField(SimpleBlockRewardViewer, "dependencies", []);
|
|
4798
5036
|
__publicField(SimpleBlockRewardViewer, "monikers", [BlockRewardViewerMoniker]);
|
|
5037
|
+
__publicField(SimpleBlockRewardViewer, "surface", "node");
|
|
4799
5038
|
SimpleBlockRewardViewer = __decorateClass([
|
|
4800
5039
|
creatableProvider()
|
|
4801
5040
|
], SimpleBlockRewardViewer);
|
|
@@ -4935,9 +5174,11 @@ var SimpleBlockValidationViewer = class extends AbstractCreatableProvider {
|
|
|
4935
5174
|
return [...this._uncleWindowedChainCache];
|
|
4936
5175
|
}
|
|
4937
5176
|
};
|
|
5177
|
+
__publicField(SimpleBlockValidationViewer, "connectionTypes", ["lmdb", "mongo", "rpc"]);
|
|
4938
5178
|
__publicField(SimpleBlockValidationViewer, "defaultMoniker", BlockValidationViewerMoniker);
|
|
4939
5179
|
__publicField(SimpleBlockValidationViewer, "dependencies", [AccountBalanceViewerMoniker2, BlockViewerMoniker3, ChainContractViewerMoniker]);
|
|
4940
5180
|
__publicField(SimpleBlockValidationViewer, "monikers", [BlockValidationViewerMoniker]);
|
|
5181
|
+
__publicField(SimpleBlockValidationViewer, "surface", "node");
|
|
4941
5182
|
SimpleBlockValidationViewer = __decorateClass([
|
|
4942
5183
|
creatableProvider()
|
|
4943
5184
|
], SimpleBlockValidationViewer);
|
|
@@ -4993,9 +5234,11 @@ var SimpleChainContractViewer = class extends AbstractCreatableProvider {
|
|
|
4993
5234
|
return this.params.stakingTokenAddress;
|
|
4994
5235
|
}
|
|
4995
5236
|
};
|
|
5237
|
+
__publicField(SimpleChainContractViewer, "connectionTypes", ["lmdb", "mongo"]);
|
|
4996
5238
|
__publicField(SimpleChainContractViewer, "defaultMoniker", ChainContractViewerMoniker2);
|
|
4997
5239
|
__publicField(SimpleChainContractViewer, "dependencies", [FinalizationViewerMoniker2]);
|
|
4998
5240
|
__publicField(SimpleChainContractViewer, "monikers", [ChainContractViewerMoniker2]);
|
|
5241
|
+
__publicField(SimpleChainContractViewer, "surface", "node");
|
|
4999
5242
|
SimpleChainContractViewer = __decorateClass([
|
|
5000
5243
|
creatableProvider()
|
|
5001
5244
|
], SimpleChainContractViewer);
|
|
@@ -5096,9 +5339,11 @@ var RestDataLakeRunner = class extends AbstractRestDataLake {
|
|
|
5096
5339
|
return [];
|
|
5097
5340
|
}
|
|
5098
5341
|
};
|
|
5342
|
+
__publicField(RestDataLakeRunner, "connectionTypes", ["rest"]);
|
|
5099
5343
|
__publicField(RestDataLakeRunner, "defaultMoniker", DataLakeRunnerMoniker);
|
|
5100
5344
|
__publicField(RestDataLakeRunner, "dependencies", []);
|
|
5101
5345
|
__publicField(RestDataLakeRunner, "monikers", [DataLakeRunnerMoniker]);
|
|
5346
|
+
__publicField(RestDataLakeRunner, "surface", "node");
|
|
5102
5347
|
RestDataLakeRunner = __decorateClass([
|
|
5103
5348
|
creatableProvider()
|
|
5104
5349
|
], RestDataLakeRunner);
|
|
@@ -5108,9 +5353,11 @@ import { DataLakeViewerMoniker } from "@xyo-network/xl1-protocol-lib";
|
|
|
5108
5353
|
var RestDataLakeViewer = class extends AbstractRestDataLake {
|
|
5109
5354
|
moniker = RestDataLakeViewer.defaultMoniker;
|
|
5110
5355
|
};
|
|
5356
|
+
__publicField(RestDataLakeViewer, "connectionTypes", ["rest"]);
|
|
5111
5357
|
__publicField(RestDataLakeViewer, "defaultMoniker", DataLakeViewerMoniker);
|
|
5112
5358
|
__publicField(RestDataLakeViewer, "dependencies", []);
|
|
5113
5359
|
__publicField(RestDataLakeViewer, "monikers", [DataLakeViewerMoniker]);
|
|
5360
|
+
__publicField(RestDataLakeViewer, "surface", "node");
|
|
5114
5361
|
RestDataLakeViewer = __decorateClass([
|
|
5115
5362
|
creatableProvider()
|
|
5116
5363
|
], RestDataLakeViewer);
|
|
@@ -5179,9 +5426,11 @@ var SimpleDataLakeRunner = class extends AbstractSimpleDataLake {
|
|
|
5179
5426
|
return hashPairs.map(([payload]) => payload);
|
|
5180
5427
|
}
|
|
5181
5428
|
};
|
|
5429
|
+
__publicField(SimpleDataLakeRunner, "connectionTypes", []);
|
|
5182
5430
|
__publicField(SimpleDataLakeRunner, "defaultMoniker", DataLakeRunnerMoniker2);
|
|
5183
5431
|
__publicField(SimpleDataLakeRunner, "dependencies", []);
|
|
5184
5432
|
__publicField(SimpleDataLakeRunner, "monikers", [DataLakeRunnerMoniker2]);
|
|
5433
|
+
__publicField(SimpleDataLakeRunner, "surface", "node");
|
|
5185
5434
|
SimpleDataLakeRunner = __decorateClass([
|
|
5186
5435
|
creatableProvider()
|
|
5187
5436
|
], SimpleDataLakeRunner);
|
|
@@ -5191,9 +5440,11 @@ import { DataLakeViewerMoniker as DataLakeViewerMoniker2 } from "@xyo-network/xl
|
|
|
5191
5440
|
var SimpleDataLakeViewer = class extends AbstractSimpleDataLake {
|
|
5192
5441
|
moniker = SimpleDataLakeViewer.defaultMoniker;
|
|
5193
5442
|
};
|
|
5443
|
+
__publicField(SimpleDataLakeViewer, "connectionTypes", []);
|
|
5194
5444
|
__publicField(SimpleDataLakeViewer, "defaultMoniker", DataLakeViewerMoniker2);
|
|
5195
5445
|
__publicField(SimpleDataLakeViewer, "dependencies", []);
|
|
5196
5446
|
__publicField(SimpleDataLakeViewer, "monikers", [DataLakeViewerMoniker2]);
|
|
5447
|
+
__publicField(SimpleDataLakeViewer, "surface", "node");
|
|
5197
5448
|
SimpleDataLakeViewer = __decorateClass([
|
|
5198
5449
|
creatableProvider()
|
|
5199
5450
|
], SimpleDataLakeViewer);
|
|
@@ -5221,9 +5472,11 @@ var SimpleFinalizationRunner = class extends AbstractCreatableProvider {
|
|
|
5221
5472
|
return sortedBlocks.map((b) => b[0]._hash);
|
|
5222
5473
|
}
|
|
5223
5474
|
};
|
|
5475
|
+
__publicField(SimpleFinalizationRunner, "connectionTypes", ["lmdb", "mongo"]);
|
|
5224
5476
|
__publicField(SimpleFinalizationRunner, "defaultMoniker", FinalizationRunnerMoniker);
|
|
5225
5477
|
__publicField(SimpleFinalizationRunner, "dependencies", []);
|
|
5226
5478
|
__publicField(SimpleFinalizationRunner, "monikers", [FinalizationRunnerMoniker]);
|
|
5479
|
+
__publicField(SimpleFinalizationRunner, "surface", "node");
|
|
5227
5480
|
SimpleFinalizationRunner = __decorateClass([
|
|
5228
5481
|
creatableProvider()
|
|
5229
5482
|
], SimpleFinalizationRunner);
|
|
@@ -5313,9 +5566,11 @@ var SimpleFinalizationViewer = class extends AbstractCreatableProvider {
|
|
|
5313
5566
|
return result;
|
|
5314
5567
|
}
|
|
5315
5568
|
};
|
|
5569
|
+
__publicField(SimpleFinalizationViewer, "connectionTypes", ["lmdb", "mongo"]);
|
|
5316
5570
|
__publicField(SimpleFinalizationViewer, "defaultMoniker", FinalizationViewerMoniker3);
|
|
5317
5571
|
__publicField(SimpleFinalizationViewer, "dependencies", [ChainContractViewerMoniker3]);
|
|
5318
5572
|
__publicField(SimpleFinalizationViewer, "monikers", [FinalizationViewerMoniker3]);
|
|
5573
|
+
__publicField(SimpleFinalizationViewer, "surface", "node");
|
|
5319
5574
|
SimpleFinalizationViewer = __decorateClass([
|
|
5320
5575
|
creatableProvider()
|
|
5321
5576
|
], SimpleFinalizationViewer);
|
|
@@ -5341,7 +5596,7 @@ var SimpleXyoGateway = class _SimpleXyoGateway extends AbstractCreatableProvider
|
|
|
5341
5596
|
import {
|
|
5342
5597
|
assertEx as assertEx39,
|
|
5343
5598
|
BigIntToJsonZod,
|
|
5344
|
-
isDefined as
|
|
5599
|
+
isDefined as isDefined20
|
|
5345
5600
|
} from "@xylabs/sdk-js";
|
|
5346
5601
|
import { PayloadBuilder as PayloadBuilder20 } from "@xyo-network/sdk-js";
|
|
5347
5602
|
import {
|
|
@@ -5379,9 +5634,9 @@ var SimpleXyoGatewayRunner = class _SimpleXyoGatewayRunner extends AbstractCreat
|
|
|
5379
5634
|
chain,
|
|
5380
5635
|
fees
|
|
5381
5636
|
} = options ?? {};
|
|
5382
|
-
const resolvedChainId =
|
|
5383
|
-
const resolvedNbf = asXL1BlockNumber10(
|
|
5384
|
-
const resolvedExp = asXL1BlockNumber10(
|
|
5637
|
+
const resolvedChainId = isDefined20(chain) ? chain : await viewer.chainId();
|
|
5638
|
+
const resolvedNbf = asXL1BlockNumber10(isDefined20(nbf) ? nbf : await viewer.currentBlockNumber(), true);
|
|
5639
|
+
const resolvedExp = asXL1BlockNumber10(isDefined20(exp) ? exp : resolvedNbf + 10, true);
|
|
5385
5640
|
const tx = await buildUnsignedTransaction(resolvedChainId, onChain, offChain, resolvedNbf, resolvedExp, await this.signer.address(), fees);
|
|
5386
5641
|
return await this.addTransactionToChain(tx, await PayloadBuilder20.addHashMeta(offChain));
|
|
5387
5642
|
}
|
|
@@ -5863,9 +6118,11 @@ var SimpleMempoolRunner = class extends AbstractCreatableProvider {
|
|
|
5863
6118
|
this.logger?.debug(`Synced ${externalTxs.length} transactions from external mempool`);
|
|
5864
6119
|
}
|
|
5865
6120
|
};
|
|
6121
|
+
__publicField(SimpleMempoolRunner, "connectionTypes", ["lmdb", "mongo"]);
|
|
5866
6122
|
__publicField(SimpleMempoolRunner, "defaultMoniker", MempoolRunnerMoniker);
|
|
5867
6123
|
__publicField(SimpleMempoolRunner, "dependencies", [FinalizationViewerMoniker4, BlockValidationViewerMoniker2, TransactionValidationViewerMoniker, ChainContractViewerMoniker4]);
|
|
5868
6124
|
__publicField(SimpleMempoolRunner, "monikers", [MempoolRunnerMoniker]);
|
|
6125
|
+
__publicField(SimpleMempoolRunner, "surface", "node");
|
|
5869
6126
|
SimpleMempoolRunner = __decorateClass([
|
|
5870
6127
|
creatableProvider()
|
|
5871
6128
|
], SimpleMempoolRunner);
|
|
@@ -5873,7 +6130,7 @@ SimpleMempoolRunner = __decorateClass([
|
|
|
5873
6130
|
// src/simple/mempool/SimpleMempoolViewer.ts
|
|
5874
6131
|
import {
|
|
5875
6132
|
exists as exists9,
|
|
5876
|
-
isDefined as
|
|
6133
|
+
isDefined as isDefined21,
|
|
5877
6134
|
isHash as isHash2
|
|
5878
6135
|
} from "@xylabs/sdk-js";
|
|
5879
6136
|
import { isHashMeta as isHashMeta2, isPayloadBundle as isPayloadBundle2 } from "@xyo-network/sdk-js";
|
|
@@ -5934,7 +6191,7 @@ var SimpleMempoolViewer = class extends AbstractCreatableProvider {
|
|
|
5934
6191
|
let cursor = void 0;
|
|
5935
6192
|
if (isHash2(providedCursor)) {
|
|
5936
6193
|
const [p] = await this.pendingBlocksArchivist.get([providedCursor]);
|
|
5937
|
-
if (
|
|
6194
|
+
if (isDefined21(p)) {
|
|
5938
6195
|
cursor = p._sequence;
|
|
5939
6196
|
}
|
|
5940
6197
|
}
|
|
@@ -5954,7 +6211,7 @@ var SimpleMempoolViewer = class extends AbstractCreatableProvider {
|
|
|
5954
6211
|
let cursor = void 0;
|
|
5955
6212
|
if (isHash2(providedCursor)) {
|
|
5956
6213
|
const [p] = await this.pendingTransactionsArchivist.get([providedCursor]);
|
|
5957
|
-
if (
|
|
6214
|
+
if (isDefined21(p)) {
|
|
5958
6215
|
cursor = p._sequence;
|
|
5959
6216
|
}
|
|
5960
6217
|
}
|
|
@@ -6027,7 +6284,7 @@ var SimpleMempoolViewer = class extends AbstractCreatableProvider {
|
|
|
6027
6284
|
const hydratedResults = await Promise.all(
|
|
6028
6285
|
filteredBundles.map(async (bundle3) => {
|
|
6029
6286
|
const tx = await bundledPayloadToHydratedTransaction(bundle3);
|
|
6030
|
-
return
|
|
6287
|
+
return isDefined21(tx) ? { bundle: bundle3, tx } : void 0;
|
|
6031
6288
|
})
|
|
6032
6289
|
);
|
|
6033
6290
|
return hydratedResults.filter(exists9);
|
|
@@ -6080,9 +6337,11 @@ var SimpleMempoolViewer = class extends AbstractCreatableProvider {
|
|
|
6080
6337
|
return deduplicateWithBundleBySigner(randomSelected).slice(0, effectiveLimit);
|
|
6081
6338
|
}
|
|
6082
6339
|
};
|
|
6340
|
+
__publicField(SimpleMempoolViewer, "connectionTypes", ["lmdb", "mongo"]);
|
|
6083
6341
|
__publicField(SimpleMempoolViewer, "defaultMoniker", MempoolViewerMoniker2);
|
|
6084
6342
|
__publicField(SimpleMempoolViewer, "dependencies", [WindowedBlockViewerMoniker]);
|
|
6085
6343
|
__publicField(SimpleMempoolViewer, "monikers", [MempoolViewerMoniker2]);
|
|
6344
|
+
__publicField(SimpleMempoolViewer, "surface", "node");
|
|
6086
6345
|
SimpleMempoolViewer = __decorateClass([
|
|
6087
6346
|
creatableProvider()
|
|
6088
6347
|
], SimpleMempoolViewer);
|
|
@@ -6271,9 +6530,11 @@ var SimpleXyoRunner = class extends AbstractCreatableProvider {
|
|
|
6271
6530
|
this._mempoolRunner = await this.locator.getInstance(MempoolRunnerMoniker2);
|
|
6272
6531
|
}
|
|
6273
6532
|
};
|
|
6533
|
+
__publicField(SimpleXyoRunner, "connectionTypes", ["lmdb", "mongo"]);
|
|
6274
6534
|
__publicField(SimpleXyoRunner, "defaultMoniker", XyoRunnerMoniker);
|
|
6275
6535
|
__publicField(SimpleXyoRunner, "dependencies", [MempoolRunnerMoniker2]);
|
|
6276
6536
|
__publicField(SimpleXyoRunner, "monikers", [XyoRunnerMoniker]);
|
|
6537
|
+
__publicField(SimpleXyoRunner, "surface", "node");
|
|
6277
6538
|
SimpleXyoRunner = __decorateClass([
|
|
6278
6539
|
creatableProvider()
|
|
6279
6540
|
], SimpleXyoRunner);
|
|
@@ -6285,9 +6546,11 @@ import {
|
|
|
6285
6546
|
XyoSignerMoniker as XyoSignerMoniker2
|
|
6286
6547
|
} from "@xyo-network/xl1-protocol-lib";
|
|
6287
6548
|
var SimpleXyoSigner = class _SimpleXyoSigner extends AbstractCreatableProvider {
|
|
6549
|
+
static connectionTypes = ["wallet"];
|
|
6288
6550
|
static defaultMoniker = XyoSignerMoniker2;
|
|
6289
6551
|
static dependencies = [];
|
|
6290
6552
|
static monikers = [XyoSignerMoniker2];
|
|
6553
|
+
static surface = "node";
|
|
6291
6554
|
moniker = _SimpleXyoSigner.defaultMoniker;
|
|
6292
6555
|
static async paramsHandler(params) {
|
|
6293
6556
|
let account;
|
|
@@ -6327,7 +6590,7 @@ var SimpleXyoSigner = class _SimpleXyoSigner extends AbstractCreatableProvider {
|
|
|
6327
6590
|
};
|
|
6328
6591
|
|
|
6329
6592
|
// src/simple/StakeEventsViewer/SimpleStakeEventsViewer.ts
|
|
6330
|
-
import { isDefined as
|
|
6593
|
+
import { isDefined as isDefined22 } from "@xylabs/sdk-js";
|
|
6331
6594
|
import { StakeEventsViewerMoniker } from "@xyo-network/xl1-protocol-lib";
|
|
6332
6595
|
var SimpleStakeEventsViewer = class extends AbstractCreatableProvider {
|
|
6333
6596
|
moniker = SimpleStakeEventsViewer.defaultMoniker;
|
|
@@ -6340,7 +6603,7 @@ var SimpleStakeEventsViewer = class extends AbstractCreatableProvider {
|
|
|
6340
6603
|
stakeEvents(range, { name } = {}) {
|
|
6341
6604
|
const positions = this.positionsFromRange(range);
|
|
6342
6605
|
const events = this.eventsFromPositions(positions);
|
|
6343
|
-
if (
|
|
6606
|
+
if (isDefined22(name)) {
|
|
6344
6607
|
return events.filter((event) => event.name === name);
|
|
6345
6608
|
}
|
|
6346
6609
|
return events;
|
|
@@ -6397,9 +6660,11 @@ var SimpleStakeEventsViewer = class extends AbstractCreatableProvider {
|
|
|
6397
6660
|
return filteredPositions;
|
|
6398
6661
|
}
|
|
6399
6662
|
};
|
|
6663
|
+
__publicField(SimpleStakeEventsViewer, "connectionTypes", []);
|
|
6400
6664
|
__publicField(SimpleStakeEventsViewer, "defaultMoniker", StakeEventsViewerMoniker);
|
|
6401
6665
|
__publicField(SimpleStakeEventsViewer, "dependencies", []);
|
|
6402
6666
|
__publicField(SimpleStakeEventsViewer, "monikers", [StakeEventsViewerMoniker]);
|
|
6667
|
+
__publicField(SimpleStakeEventsViewer, "surface", "node");
|
|
6403
6668
|
SimpleStakeEventsViewer = __decorateClass([
|
|
6404
6669
|
creatableProvider()
|
|
6405
6670
|
], SimpleStakeEventsViewer);
|
|
@@ -6495,9 +6760,11 @@ var SimpleStakeTotalsViewer = class extends AbstractCreatableProvider {
|
|
|
6495
6760
|
return withdrawn;
|
|
6496
6761
|
}
|
|
6497
6762
|
};
|
|
6763
|
+
__publicField(SimpleStakeTotalsViewer, "connectionTypes", ["lmdb", "mongo"]);
|
|
6498
6764
|
__publicField(SimpleStakeTotalsViewer, "defaultMoniker", StakeTotalsViewerMoniker);
|
|
6499
6765
|
__publicField(SimpleStakeTotalsViewer, "dependencies", [StakeTotalsViewerMoniker]);
|
|
6500
6766
|
__publicField(SimpleStakeTotalsViewer, "monikers", [StakeTotalsViewerMoniker]);
|
|
6767
|
+
__publicField(SimpleStakeTotalsViewer, "surface", "node");
|
|
6501
6768
|
SimpleStakeTotalsViewer = __decorateClass([
|
|
6502
6769
|
creatableProvider()
|
|
6503
6770
|
], SimpleStakeTotalsViewer);
|
|
@@ -6625,9 +6892,11 @@ var SimpleStakeViewer = class extends AbstractCreatableProvider {
|
|
|
6625
6892
|
return this.positions.filter((s) => s.withdrawBlock !== 0);
|
|
6626
6893
|
}
|
|
6627
6894
|
};
|
|
6895
|
+
__publicField(SimpleStakeViewer, "connectionTypes", ["lmdb", "mongo"]);
|
|
6628
6896
|
__publicField(SimpleStakeViewer, "defaultMoniker", StakeViewerMoniker2);
|
|
6629
6897
|
__publicField(SimpleStakeViewer, "dependencies", [StakeEventsViewerMoniker2]);
|
|
6630
6898
|
__publicField(SimpleStakeViewer, "monikers", [StakeViewerMoniker2]);
|
|
6899
|
+
__publicField(SimpleStakeViewer, "surface", "node");
|
|
6631
6900
|
SimpleStakeViewer = __decorateClass([
|
|
6632
6901
|
creatableProvider()
|
|
6633
6902
|
], SimpleStakeViewer);
|
|
@@ -6688,7 +6957,7 @@ RestSyncViewer = __decorateClass([
|
|
|
6688
6957
|
import {
|
|
6689
6958
|
asHash as asHash5,
|
|
6690
6959
|
assertEx as assertEx45,
|
|
6691
|
-
isDefined as
|
|
6960
|
+
isDefined as isDefined23
|
|
6692
6961
|
} from "@xylabs/sdk-js";
|
|
6693
6962
|
import {
|
|
6694
6963
|
asTimePayload as asTimePayload2,
|
|
@@ -6712,7 +6981,7 @@ var SimpleTimeSyncViewer = class extends AbstractCreatableProvider {
|
|
|
6712
6981
|
const [block, payloads] = assertEx45(await this.blockViewer.blockByNumber(asXL1BlockNumber11(from, true)), () => "Block not found");
|
|
6713
6982
|
const timeSchemaIndex = block.payload_schemas.indexOf(TimeSchema);
|
|
6714
6983
|
const hash = timeSchemaIndex === -1 ? void 0 : block.payload_hashes[timeSchemaIndex];
|
|
6715
|
-
const timePayload = asTimePayload2(
|
|
6984
|
+
const timePayload = asTimePayload2(isDefined23(hash) ? payloads.find((p) => p._hash === hash) : void 0);
|
|
6716
6985
|
if (timePayload === void 0) return 0;
|
|
6717
6986
|
switch (toDomain) {
|
|
6718
6987
|
case "xl1": {
|
|
@@ -6786,7 +7055,7 @@ var SimpleTimeSyncViewer = class extends AbstractCreatableProvider {
|
|
|
6786
7055
|
xl1Hash: assertEx45(xl1Hash, () => "No xl1 hash available from time sync service"),
|
|
6787
7056
|
epoch: Date.now()
|
|
6788
7057
|
};
|
|
6789
|
-
if (
|
|
7058
|
+
if (isDefined23(this.ethProvider)) {
|
|
6790
7059
|
const [ethereum, ethHashOrNull] = await this.currentTimeAndHash("ethereum");
|
|
6791
7060
|
const ethereumHash = asHash5(ethHashOrNull, () => "No ethereum hash available from time sync service");
|
|
6792
7061
|
timePayload.ethereum = ethereum;
|
|
@@ -6795,9 +7064,11 @@ var SimpleTimeSyncViewer = class extends AbstractCreatableProvider {
|
|
|
6795
7064
|
return timePayload;
|
|
6796
7065
|
}
|
|
6797
7066
|
};
|
|
7067
|
+
__publicField(SimpleTimeSyncViewer, "connectionTypes", ["lmdb", "mongo"]);
|
|
6798
7068
|
__publicField(SimpleTimeSyncViewer, "defaultMoniker", TimeSyncViewerMoniker);
|
|
6799
7069
|
__publicField(SimpleTimeSyncViewer, "dependencies", [BlockViewerMoniker4]);
|
|
6800
7070
|
__publicField(SimpleTimeSyncViewer, "monikers", [TimeSyncViewerMoniker]);
|
|
7071
|
+
__publicField(SimpleTimeSyncViewer, "surface", "node");
|
|
6801
7072
|
SimpleTimeSyncViewer = __decorateClass([
|
|
6802
7073
|
creatableProvider()
|
|
6803
7074
|
], SimpleTimeSyncViewer);
|
|
@@ -6919,9 +7190,11 @@ var SimpleTransactionValidationViewer = class extends AbstractCreatableProvider
|
|
|
6919
7190
|
}));
|
|
6920
7191
|
}
|
|
6921
7192
|
};
|
|
7193
|
+
__publicField(SimpleTransactionValidationViewer, "connectionTypes", ["lmdb", "mongo", "rpc"]);
|
|
6922
7194
|
__publicField(SimpleTransactionValidationViewer, "defaultMoniker", TransactionValidationViewerMoniker2);
|
|
6923
7195
|
__publicField(SimpleTransactionValidationViewer, "dependencies", [AccountBalanceViewerMoniker3, ChainContractViewerMoniker5, BlockViewerMoniker5]);
|
|
6924
7196
|
__publicField(SimpleTransactionValidationViewer, "monikers", [TransactionValidationViewerMoniker2]);
|
|
7197
|
+
__publicField(SimpleTransactionValidationViewer, "surface", "node");
|
|
6925
7198
|
SimpleTransactionValidationViewer = __decorateClass([
|
|
6926
7199
|
creatableProvider()
|
|
6927
7200
|
], SimpleTransactionValidationViewer);
|
|
@@ -6999,6 +7272,7 @@ var SimpleTransactionViewer = class extends AbstractCreatableProvider {
|
|
|
6999
7272
|
return await this.byHash(transactionHash);
|
|
7000
7273
|
}
|
|
7001
7274
|
};
|
|
7275
|
+
__publicField(SimpleTransactionViewer, "connectionTypes", ["lmdb", "mongo"]);
|
|
7002
7276
|
__publicField(SimpleTransactionViewer, "defaultMoniker", TransactionViewerMoniker);
|
|
7003
7277
|
__publicField(SimpleTransactionViewer, "dependencies", [BlockViewerMoniker6]);
|
|
7004
7278
|
__publicField(SimpleTransactionViewer, "monikers", [TransactionViewerMoniker]);
|
|
@@ -7175,9 +7449,11 @@ var SimpleWindowedBlockViewer = class extends AbstractCreatableProvider {
|
|
|
7175
7449
|
});
|
|
7176
7450
|
}
|
|
7177
7451
|
};
|
|
7452
|
+
__publicField(SimpleWindowedBlockViewer, "connectionTypes", ["lmdb", "mongo", "rpc"]);
|
|
7178
7453
|
__publicField(SimpleWindowedBlockViewer, "defaultMoniker", WindowedBlockViewerMoniker2);
|
|
7179
7454
|
__publicField(SimpleWindowedBlockViewer, "dependencies", [BlockViewerMoniker7]);
|
|
7180
7455
|
__publicField(SimpleWindowedBlockViewer, "monikers", [WindowedBlockViewerMoniker2]);
|
|
7456
|
+
__publicField(SimpleWindowedBlockViewer, "surface", "node");
|
|
7181
7457
|
SimpleWindowedBlockViewer = __decorateClass([
|
|
7182
7458
|
creatableProvider()
|
|
7183
7459
|
], SimpleWindowedBlockViewer);
|
|
@@ -7283,7 +7559,7 @@ import {
|
|
|
7283
7559
|
} from "@xyo-network/xl1-protocol-lib";
|
|
7284
7560
|
|
|
7285
7561
|
// src/test/buildBlock.ts
|
|
7286
|
-
import { assertEx as assertEx49, isDefined as
|
|
7562
|
+
import { assertEx as assertEx49, isDefined as isDefined24 } from "@xylabs/sdk-js";
|
|
7287
7563
|
import {
|
|
7288
7564
|
asAnyPayload as asAnyPayload5,
|
|
7289
7565
|
BoundWitnessBuilder as BoundWitnessBuilder3,
|
|
@@ -7367,7 +7643,7 @@ function buildStepHashes(blockNumber, inStepHashes, previousBlockHash, chainStep
|
|
|
7367
7643
|
completedStepRewardTransfers.push(createTransferPayload(chainStepRewardAddress2, { [completedStepRewardHolderAddress]: completedStepReward }));
|
|
7368
7644
|
}
|
|
7369
7645
|
step_hashes.push(assertEx49(previousBlockHash, () => `Previous block hash is required for step ${step} at block ${blockNumber}`));
|
|
7370
|
-
} else if (
|
|
7646
|
+
} else if (isDefined24(inStepHashes.at(i))) {
|
|
7371
7647
|
step_hashes.push(inStepHashes[i]);
|
|
7372
7648
|
}
|
|
7373
7649
|
}
|
|
@@ -7703,6 +7979,7 @@ export {
|
|
|
7703
7979
|
ActorConfigZod,
|
|
7704
7980
|
ActorsConfigZod,
|
|
7705
7981
|
AddressPairSchema,
|
|
7982
|
+
AmbiguousProviderError,
|
|
7706
7983
|
BalancesStepSummarySchema,
|
|
7707
7984
|
BaseConfigContextZod,
|
|
7708
7985
|
BaseConfigZod,
|
|
@@ -7712,6 +7989,8 @@ export {
|
|
|
7712
7989
|
COIN_TYPES,
|
|
7713
7990
|
ChainIndexingServiceStateSchema,
|
|
7714
7991
|
ConfigZod,
|
|
7992
|
+
TransportConfigZod as ConnectionConfigZod,
|
|
7993
|
+
TransportsConfigZod as ConnectionsConfigZod,
|
|
7715
7994
|
CreatableProviderContextZod,
|
|
7716
7995
|
DEFAULT_BACKOFF_MS,
|
|
7717
7996
|
DEFAULT_MAX_ATTEMPTS,
|
|
@@ -7725,6 +8004,7 @@ export {
|
|
|
7725
8004
|
EIP712DataPayloadSchema,
|
|
7726
8005
|
EIP712SignaturePayloadFieldsZod,
|
|
7727
8006
|
EIP712SignaturePayloadSchema,
|
|
8007
|
+
EvmRpcTransportConfigZod as EvmConnectionConfigZod,
|
|
7728
8008
|
EvmRpcTransportConfigZod,
|
|
7729
8009
|
GlobalMetaSchema,
|
|
7730
8010
|
HostActorConfigContext,
|
|
@@ -7733,11 +8013,13 @@ export {
|
|
|
7733
8013
|
HydratedBoundWitnessWithStorageMetaZod,
|
|
7734
8014
|
HydratedCache,
|
|
7735
8015
|
JSONSchemaMetaSchema,
|
|
8016
|
+
LmdbTransportConfigZod as LmdbConnectionConfigZod,
|
|
7736
8017
|
LmdbTransportConfigZod,
|
|
7737
8018
|
LoggerStatusReporter,
|
|
7738
8019
|
MemoryPermissionsStore,
|
|
7739
8020
|
MissingCapabilityError,
|
|
7740
8021
|
MnemonicStringZod,
|
|
8022
|
+
MongoTransportConfigZod as MongoConnectionConfigZod,
|
|
7741
8023
|
MongoTransportConfigZod,
|
|
7742
8024
|
PRODUCER_DIVERSITY_BONUS,
|
|
7743
8025
|
PayloadLocator,
|
|
@@ -7750,6 +8032,7 @@ export {
|
|
|
7750
8032
|
ProviderFactoryLocatorZod,
|
|
7751
8033
|
ProvidersConfigZod,
|
|
7752
8034
|
RemoteConfigZod,
|
|
8035
|
+
RestTransportConfigZod as RestConnectionConfigZod,
|
|
7753
8036
|
RestDataLakeConfigZod,
|
|
7754
8037
|
RestDataLakeRunner,
|
|
7755
8038
|
RestDataLakeViewer,
|
|
@@ -7757,11 +8040,13 @@ export {
|
|
|
7757
8040
|
RestTransportConfigZod,
|
|
7758
8041
|
RewardMultipliers,
|
|
7759
8042
|
RouterDataLakeConfigZod,
|
|
8043
|
+
RpcTransportConfigZod as RpcConnectionConfigZod,
|
|
7760
8044
|
RpcRemoteConfigBaseZod,
|
|
7761
8045
|
RpcRemoteConfigZod,
|
|
7762
8046
|
RpcTransportConfigZod,
|
|
7763
8047
|
RuntimeStatusMonitor,
|
|
7764
8048
|
RuntimeStatusMonitorZod,
|
|
8049
|
+
S3TransportConfigZod as S3ConnectionConfigZod,
|
|
7765
8050
|
S3TransportConfigZod,
|
|
7766
8051
|
SchemasStepSummarySchema,
|
|
7767
8052
|
ShiftedBigInt,
|
|
@@ -7800,6 +8085,8 @@ export {
|
|
|
7800
8085
|
TypedDataFieldZod,
|
|
7801
8086
|
TypedDataTypesZod,
|
|
7802
8087
|
TypedDataValueZod,
|
|
8088
|
+
UnboundProviderError,
|
|
8089
|
+
UnknownConnectionError,
|
|
7803
8090
|
UsageMetaSchema,
|
|
7804
8091
|
VIEWER_BRANCH_KEYS,
|
|
7805
8092
|
WALLET_COMPLIANCE,
|
|
@@ -7875,6 +8162,8 @@ export {
|
|
|
7875
8162
|
createTransactionHydrator,
|
|
7876
8163
|
createTransferPayload,
|
|
7877
8164
|
deepCalculateFramesFromRange,
|
|
8165
|
+
descriptorConnectionTypes,
|
|
8166
|
+
descriptorMatchesConnectionType,
|
|
7878
8167
|
externalBlockNumberFromXL1BlockNumber,
|
|
7879
8168
|
externalBlockRangeFromStep,
|
|
7880
8169
|
externalBlockRangeFromXL1BlockRange,
|
|
@@ -7896,6 +8185,7 @@ export {
|
|
|
7896
8185
|
getTimeConfigInMilliseconds,
|
|
7897
8186
|
getUrl,
|
|
7898
8187
|
getWindowedChain,
|
|
8188
|
+
hasDeclaredConnectionProfiles,
|
|
7899
8189
|
hasLabels,
|
|
7900
8190
|
hasMongoConfig,
|
|
7901
8191
|
hasS3Config,
|
|
@@ -7934,24 +8224,32 @@ export {
|
|
|
7934
8224
|
isZodError,
|
|
7935
8225
|
labeledCreatableProvider,
|
|
7936
8226
|
labeledCreatableProviderFactory,
|
|
8227
|
+
locatorFromConfig,
|
|
7937
8228
|
mapToMapType,
|
|
7938
8229
|
mergeTransfers,
|
|
7939
8230
|
mergedAddRemoveStakeEventsByPosition,
|
|
8231
|
+
needsFromConnectionTypes,
|
|
8232
|
+
needsFromProviderBindings,
|
|
7940
8233
|
netBalancesForPayloads,
|
|
7941
8234
|
netSchemasForPayloads,
|
|
7942
8235
|
netTransfersForPayloads,
|
|
7943
8236
|
networkBackedFactory,
|
|
7944
8237
|
networkStakeStepRewardPositionWeight,
|
|
8238
|
+
normalizeConnectionsConfig,
|
|
7945
8239
|
parseSignedBigInt,
|
|
7946
8240
|
payloadMapFromStore,
|
|
7947
8241
|
prettifyZodError,
|
|
8242
|
+
providerCandidateFromClass,
|
|
8243
|
+
providerCandidatesFromClasses,
|
|
7948
8244
|
providerFactoryDescription,
|
|
7949
8245
|
rateMultipliers,
|
|
7950
8246
|
readPayloadMapFromStore,
|
|
7951
8247
|
registerCreatableProviderFactories,
|
|
7952
8248
|
registerCreatableProviderFactory,
|
|
8249
|
+
registerFactoriesFromPlan,
|
|
7953
8250
|
resolveConfig,
|
|
7954
8251
|
resolveProviders,
|
|
8252
|
+
resolveProvidersFromConfig,
|
|
7955
8253
|
resolveS3Bucket,
|
|
7956
8254
|
rewardFromBlockNumber,
|
|
7957
8255
|
schemasMaxStep,
|