@xyo-network/xl1-protocol-sdk 3.0.0 → 3.0.2
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/CreatableProvider.d.ts +8 -0
- package/dist/neutral/CreatableProvider/CreatableProvider.d.ts.map +1 -1
- package/dist/neutral/capabilities/Provider.d.ts +13 -38
- package/dist/neutral/capabilities/Provider.d.ts.map +1 -1
- package/dist/neutral/capabilities/connectionTypes.d.ts +2 -1
- package/dist/neutral/capabilities/connectionTypes.d.ts.map +1 -1
- package/dist/neutral/capabilities/index.d.ts +3 -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 +3 -3
- package/dist/neutral/capabilities/resolveProviders.d.ts.map +1 -1
- package/dist/neutral/config/adaptLegacyConfig.d.ts.map +1 -1
- package/dist/neutral/index.mjs +572 -451
- package/dist/neutral/index.mjs.map +4 -4
- 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 +2 -0
- 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 +6 -0
- package/dist/neutral/test/index.mjs.map +2 -2
- package/package.json +9 -9
package/dist/neutral/index.mjs
CHANGED
|
@@ -1040,6 +1040,337 @@ function factoryBackingsCompatible(declared, available) {
|
|
|
1040
1040
|
return backingsSatisfied(declared, available);
|
|
1041
1041
|
}
|
|
1042
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
|
+
|
|
1043
1374
|
// src/capabilities/resolveProviders.ts
|
|
1044
1375
|
import { isDefined as isDefined4 } from "@xylabs/sdk-js";
|
|
1045
1376
|
var MissingCapabilityError = class extends Error {
|
|
@@ -1086,14 +1417,12 @@ var UnknownConnectionError = class extends Error {
|
|
|
1086
1417
|
this.connectionName = connectionName;
|
|
1087
1418
|
}
|
|
1088
1419
|
};
|
|
1089
|
-
function resolveProviders(needs, candidates,
|
|
1420
|
+
function resolveProviders(needs, candidates, options = {}) {
|
|
1090
1421
|
const rejected = [];
|
|
1091
|
-
const { preconditionFiltered, preconditionRejected } = filterByPreconditions(candidates, ctx);
|
|
1092
|
-
rejected.push(...preconditionRejected);
|
|
1093
1422
|
const wanted = new Set(needs);
|
|
1094
1423
|
const bindings = {};
|
|
1095
1424
|
const selectedById = /* @__PURE__ */ new Map();
|
|
1096
|
-
const candidatesByMoniker = indexCandidatesByMoniker(
|
|
1425
|
+
const candidatesByMoniker = indexCandidatesByMoniker(candidates);
|
|
1097
1426
|
expandBindingClosure(
|
|
1098
1427
|
wanted,
|
|
1099
1428
|
bindings,
|
|
@@ -1195,25 +1524,6 @@ function filterByConnection(group, connectionType, connectionName) {
|
|
|
1195
1524
|
});
|
|
1196
1525
|
return { filtered, rejected };
|
|
1197
1526
|
}
|
|
1198
|
-
function filterByPreconditions(candidates, ctx) {
|
|
1199
|
-
const preconditionFiltered = [];
|
|
1200
|
-
const preconditionRejected = [];
|
|
1201
|
-
for (const descriptor of candidates) {
|
|
1202
|
-
try {
|
|
1203
|
-
if (descriptor.preconditions(ctx)) {
|
|
1204
|
-
preconditionFiltered.push(descriptor);
|
|
1205
|
-
} else {
|
|
1206
|
-
preconditionRejected.push({ descriptor, reason: "preconditions returned false" });
|
|
1207
|
-
}
|
|
1208
|
-
} catch (err) {
|
|
1209
|
-
preconditionRejected.push({
|
|
1210
|
-
descriptor,
|
|
1211
|
-
reason: `preconditions threw: ${err instanceof Error ? err.message : String(err)}`
|
|
1212
|
-
});
|
|
1213
|
-
}
|
|
1214
|
-
}
|
|
1215
|
-
return { preconditionFiltered, preconditionRejected };
|
|
1216
|
-
}
|
|
1217
1527
|
function reasonsFor(moniker, rejected, allCandidates) {
|
|
1218
1528
|
const candidatesForMoniker = allCandidates.filter((candidate) => candidate.satisfies.includes(moniker));
|
|
1219
1529
|
if (candidatesForMoniker.length === 0) {
|
|
@@ -1256,6 +1566,70 @@ function topoSort(descriptors, bindings, selectedById) {
|
|
|
1256
1566
|
return order;
|
|
1257
1567
|
}
|
|
1258
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
|
+
|
|
1259
1633
|
// src/config/Actor.ts
|
|
1260
1634
|
import {
|
|
1261
1635
|
zodAsFactory as zodAsFactory3,
|
|
@@ -1667,7 +2041,7 @@ import { isDefined as isDefined8, isFalsy } from "@xylabs/sdk-js";
|
|
|
1667
2041
|
import { asXL1BlockRange } from "@xyo-network/xl1-protocol-lib";
|
|
1668
2042
|
|
|
1669
2043
|
// src/primitives/block/rate/timeHelpers.ts
|
|
1670
|
-
import { assertEx as
|
|
2044
|
+
import { assertEx as assertEx10, isDefined as isDefined7 } from "@xylabs/sdk-js";
|
|
1671
2045
|
var rateMultipliers = {
|
|
1672
2046
|
millis: 1,
|
|
1673
2047
|
seconds: 1e3,
|
|
@@ -1685,7 +2059,7 @@ var timeDurations = (timeInMs) => ({
|
|
|
1685
2059
|
weeks: timeInMs / (1e3 * 60 * 60 * 24 * 7)
|
|
1686
2060
|
});
|
|
1687
2061
|
var getTimeConfigInMilliseconds = (timeConfig) => {
|
|
1688
|
-
const assertedTimeConfig =
|
|
2062
|
+
const assertedTimeConfig = assertEx10(isDefined7(timeConfig) ? timeConfig : void 0, () => "Time configuration must be provided");
|
|
1689
2063
|
let totalMilliseconds = 0;
|
|
1690
2064
|
if ("years" in assertedTimeConfig) {
|
|
1691
2065
|
totalMilliseconds += assertedTimeConfig.years * 31536e6;
|
|
@@ -1758,7 +2132,7 @@ var calculateBlockRate = async (viewer, range, timeUnit) => {
|
|
|
1758
2132
|
};
|
|
1759
2133
|
|
|
1760
2134
|
// src/primitives/block/rate/stepRate.ts
|
|
1761
|
-
import { assertEx as
|
|
2135
|
+
import { assertEx as assertEx11 } from "@xylabs/sdk-js";
|
|
1762
2136
|
import {
|
|
1763
2137
|
asXL1BlockRange as asXL1BlockRange2,
|
|
1764
2138
|
isValidStep,
|
|
@@ -1770,14 +2144,14 @@ var stepRate = async (viewer, start, step, count = 1, timeUnit) => {
|
|
|
1770
2144
|
return await calculateBlockRate(viewer, range, timeUnit);
|
|
1771
2145
|
};
|
|
1772
2146
|
var calculateStepSizeRate = async (viewer, start, stepIndex, count = 1, timeUnit) => {
|
|
1773
|
-
|
|
2147
|
+
assertEx11(isValidStep(stepIndex), () => `Invalid step index: ${stepIndex}`);
|
|
1774
2148
|
const step = StepSizes4[stepIndex];
|
|
1775
2149
|
return await stepRate(viewer, start, step, count, timeUnit);
|
|
1776
2150
|
};
|
|
1777
2151
|
|
|
1778
2152
|
// src/primitives/block/rate/timeRate.ts
|
|
1779
2153
|
import {
|
|
1780
|
-
assertEx as
|
|
2154
|
+
assertEx as assertEx12,
|
|
1781
2155
|
isDefined as isDefined9,
|
|
1782
2156
|
isDefinedNotNull
|
|
1783
2157
|
} from "@xylabs/sdk-js";
|
|
@@ -1785,13 +2159,13 @@ import { asXL1BlockNumber as asXL1BlockNumber3, asXL1BlockRange as asXL1BlockRan
|
|
|
1785
2159
|
var DEFAULT_TOLERANCE_MS = 3e4;
|
|
1786
2160
|
var DEFAULT_MAX_ATTEMPTS = 10;
|
|
1787
2161
|
var calculateTimeRate = async (viewer, timeConfig, startBlockNumber, timeUnit, toleranceMs = DEFAULT_TOLERANCE_MS, maxAttempts = DEFAULT_MAX_ATTEMPTS) => {
|
|
1788
|
-
|
|
2162
|
+
assertEx12(Object.keys(timeConfig ?? {}).length === 1, () => "Only one time unit should be specified in timeConfig");
|
|
1789
2163
|
const startBlock = isDefinedNotNull(startBlockNumber) ? await viewer.blockByNumber(startBlockNumber) : null;
|
|
1790
2164
|
const currentBlockResult = await viewer.currentBlock();
|
|
1791
2165
|
const blockResult = isDefinedNotNull(startBlock) ? startBlock : currentBlockResult;
|
|
1792
2166
|
const resolvedStartBlock = blockResult[0];
|
|
1793
2167
|
const timeInMilliseconds = getTimeConfigInMilliseconds(timeConfig);
|
|
1794
|
-
|
|
2168
|
+
assertEx12(timeInMilliseconds > 0, () => "Time duration must be greater than zero");
|
|
1795
2169
|
const blocksPerMillisecondRate = 1 / (12 * 1e3);
|
|
1796
2170
|
const initialBlocksInDuration = Math.floor(blocksPerMillisecondRate * timeInMilliseconds);
|
|
1797
2171
|
const endBlockNumber = await findEndBlockRecursive(
|
|
@@ -1809,14 +2183,14 @@ var calculateTimeRate = async (viewer, timeConfig, startBlockNumber, timeUnit, t
|
|
|
1809
2183
|
);
|
|
1810
2184
|
};
|
|
1811
2185
|
var findEndBlockRecursive = async (viewer, startBlock, targetTimeMs, estimatedBlocksBack, toleranceMs, attemptsRemaining) => {
|
|
1812
|
-
|
|
2186
|
+
assertEx12(attemptsRemaining >= 0, () => "Maximum attempts reached while searching for end block");
|
|
1813
2187
|
const startBlockEpoch = startBlock.$epoch;
|
|
1814
2188
|
const estimatedEndBlockNumber = asXL1BlockNumber3(startBlock.block - estimatedBlocksBack, true);
|
|
1815
2189
|
if (estimatedEndBlockNumber < 0) {
|
|
1816
2190
|
throw new Error("Estimated end block number is less than zero");
|
|
1817
2191
|
}
|
|
1818
2192
|
const endBlock = await viewer.blockByNumber(estimatedEndBlockNumber);
|
|
1819
|
-
const resolvedEndBlock =
|
|
2193
|
+
const resolvedEndBlock = assertEx12(
|
|
1820
2194
|
isDefined9(endBlock?.[0]) ? endBlock[0] : void 0,
|
|
1821
2195
|
() => `Could not retrieve block ${estimatedEndBlockNumber} for time rate calculation`
|
|
1822
2196
|
);
|
|
@@ -1853,7 +2227,7 @@ var findEndBlockRecursive = async (viewer, startBlock, targetTimeMs, estimatedBl
|
|
|
1853
2227
|
|
|
1854
2228
|
// src/primitives/chain/getWindowedChain.ts
|
|
1855
2229
|
import {
|
|
1856
|
-
assertEx as
|
|
2230
|
+
assertEx as assertEx13,
|
|
1857
2231
|
isDefined as isDefined10,
|
|
1858
2232
|
isNull,
|
|
1859
2233
|
spanRootAsync
|
|
@@ -1870,12 +2244,12 @@ async function getWindowedChain(context, blockViewer, maxWindowSize, previousCha
|
|
|
1870
2244
|
const nextBlock = newChain[0];
|
|
1871
2245
|
if (isDefined10(nextBlock)) {
|
|
1872
2246
|
const nextBlockNumber = nextBlock[0].block;
|
|
1873
|
-
|
|
2247
|
+
assertEx13(
|
|
1874
2248
|
currentBlockNumber === nextBlockNumber - 1,
|
|
1875
2249
|
() => `[getWindowedChain] Non-monotonic block sequence detected: current=${currentBlockNumber}, next=${nextBlockNumber}`
|
|
1876
2250
|
);
|
|
1877
2251
|
}
|
|
1878
|
-
|
|
2252
|
+
assertEx13(
|
|
1879
2253
|
currentBlockNumber <= head[0].block,
|
|
1880
2254
|
() => `[getWindowedChain] Current block number (${currentBlockNumber}) exceeds head block number (${head[0].block})`
|
|
1881
2255
|
);
|
|
@@ -1889,7 +2263,7 @@ async function getWindowedChain(context, blockViewer, maxWindowSize, previousCha
|
|
|
1889
2263
|
}
|
|
1890
2264
|
|
|
1891
2265
|
// src/primitives/chain/step/chainStepRewardAddress.ts
|
|
1892
|
-
import { assertEx as
|
|
2266
|
+
import { assertEx as assertEx16, exists } from "@xylabs/sdk-js";
|
|
1893
2267
|
import { toXyoAddress as toXyoAddress2 } from "@xyo-network/sdk-js";
|
|
1894
2268
|
import {
|
|
1895
2269
|
asTransfer,
|
|
@@ -1921,7 +2295,7 @@ function stepBlockRange({ block, step }) {
|
|
|
1921
2295
|
}
|
|
1922
2296
|
|
|
1923
2297
|
// src/primitives/step/stepTransferIndex.ts
|
|
1924
|
-
import { assertEx as
|
|
2298
|
+
import { assertEx as assertEx14 } from "@xylabs/sdk-js";
|
|
1925
2299
|
import { StepSizes as StepSizes6 } from "@xyo-network/xl1-protocol-lib";
|
|
1926
2300
|
function stepTransferIndex(block, step) {
|
|
1927
2301
|
let rewardTransferCount = 0;
|
|
@@ -1935,16 +2309,16 @@ function stepTransferIndex(block, step) {
|
|
|
1935
2309
|
rewardTransferCount++;
|
|
1936
2310
|
}
|
|
1937
2311
|
}
|
|
1938
|
-
|
|
2312
|
+
assertEx14(rewardTransferIndex >= 0, () => `Could not find step size for step ${step} at block ${block}`);
|
|
1939
2313
|
return [rewardTransferIndex, rewardTransferCount];
|
|
1940
2314
|
}
|
|
1941
2315
|
|
|
1942
2316
|
// src/primitives/chain/step/stepRewardBlock.ts
|
|
1943
|
-
import { assertEx as
|
|
2317
|
+
import { assertEx as assertEx15 } from "@xylabs/sdk-js";
|
|
1944
2318
|
import { StepSizes as StepSizes7 } from "@xyo-network/xl1-protocol-lib";
|
|
1945
2319
|
async function stepRewardBlock(context, blockViewer, { block, step }) {
|
|
1946
|
-
|
|
1947
|
-
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}`);
|
|
1948
2322
|
}
|
|
1949
2323
|
|
|
1950
2324
|
// src/primitives/chain/step/chainStepRewardAddress.ts
|
|
@@ -1957,7 +2331,7 @@ async function chainStepRewardAddress(context, blockViewer, { block, step }) {
|
|
|
1957
2331
|
const rewardEntry = Object.entries(mergedTransfers).find(([address]) => address === XYO_STEP_REWARD_ADDRESS);
|
|
1958
2332
|
const fromEntries = Object.entries(rewardEntry?.[1] ?? {});
|
|
1959
2333
|
const sortedTransferAmounts = fromEntries.toSorted(([, a], [, b]) => a > b ? -1 : a < b ? 1 : 0);
|
|
1960
|
-
|
|
2334
|
+
assertEx16(
|
|
1961
2335
|
sortedTransferAmounts.length === transferCount,
|
|
1962
2336
|
() => `Step Transfers mismatch ${block} (${blockBw._hash}) [${sortedTransferAmounts.length} - ${transferCount}]`
|
|
1963
2337
|
);
|
|
@@ -1965,7 +2339,7 @@ async function chainStepRewardAddress(context, blockViewer, { block, step }) {
|
|
|
1965
2339
|
}
|
|
1966
2340
|
|
|
1967
2341
|
// src/primitives/chain/step/stepRewardTotal.ts
|
|
1968
|
-
import { assertEx as
|
|
2342
|
+
import { assertEx as assertEx17, isDefined as isDefined11 } from "@xylabs/sdk-js";
|
|
1969
2343
|
import {
|
|
1970
2344
|
asAttoXL1,
|
|
1971
2345
|
asXL1BlockRange as asXL1BlockRange5,
|
|
@@ -2061,15 +2435,15 @@ async function stepRewardTotal(context, blockViewer, { block, step }, multiplier
|
|
|
2061
2435
|
const cacheKey = `${block}|${step}|${isDefined11(multipliers)}`;
|
|
2062
2436
|
return await withContextCacheResponse(context, "stepRewardTotal", cacheKey, async () => {
|
|
2063
2437
|
const [blockBw, payloads] = await stepRewardBlock(context, blockViewer, { block, step });
|
|
2064
|
-
|
|
2438
|
+
assertEx17(blockBw.block === block, () => `Block Mismatch: expected ${block}, got ${blockBw.block}`);
|
|
2065
2439
|
const [transferIndex] = stepTransferIndex(block, step);
|
|
2066
|
-
const stepTransfer =
|
|
2440
|
+
const stepTransfer = assertEx17(
|
|
2067
2441
|
payloads.find((p) => isTransfer5(p) && p.from === XYO_STEP_REWARD_ADDRESS2),
|
|
2068
2442
|
() => `No step transfer found for step ${step} at block ${block} (${blockBw._hash})`
|
|
2069
2443
|
);
|
|
2070
2444
|
const netTransfers = netTransfersForPayloads(context, [stepTransfer]);
|
|
2071
2445
|
const rewardEntry = Object.entries(netTransfers).find(([address]) => address === XYO_STEP_REWARD_ADDRESS2);
|
|
2072
|
-
const rewards =
|
|
2446
|
+
const rewards = assertEx17(
|
|
2073
2447
|
rewardEntry?.[1],
|
|
2074
2448
|
() => `No rewards found for step reward address ${XYO_STEP_REWARD_ADDRESS2} at block ${block} (${blockBw._hash})`
|
|
2075
2449
|
);
|
|
@@ -2112,7 +2486,7 @@ async function stepsRewardTotal(context, blockViewer, steps, multipliers) {
|
|
|
2112
2486
|
}
|
|
2113
2487
|
|
|
2114
2488
|
// src/primitives/chain/time/externalBlockNumberFromXl1BlockNumber.ts
|
|
2115
|
-
import { assertEx as
|
|
2489
|
+
import { assertEx as assertEx18, isArray } from "@xylabs/sdk-js";
|
|
2116
2490
|
import {
|
|
2117
2491
|
asBlockNumber,
|
|
2118
2492
|
asTimePayload,
|
|
@@ -2123,7 +2497,7 @@ async function externalBlockNumberFromXL1BlockNumber(context, blockViewer, xl1Bl
|
|
|
2123
2497
|
const cacheKey = `${xl1BlockNumber}-${externalTimeName}-${externalGenesisTime ?? "default"}`;
|
|
2124
2498
|
return await withContextCacheResponse(context, functionName, cacheKey, async () => {
|
|
2125
2499
|
const [, payloads = []] = await blockViewer.blockByNumber(xl1BlockNumber) ?? [];
|
|
2126
|
-
|
|
2500
|
+
assertEx18(isArray(payloads));
|
|
2127
2501
|
const timePayload = asTimePayload(payloads.find(isTimePayload));
|
|
2128
2502
|
return asBlockNumber(
|
|
2129
2503
|
timePayload?.[externalTimeName] ?? externalGenesisTime ?? 23372716,
|
|
@@ -2440,7 +2814,7 @@ var findMostRecentBlock = async (chainArchivist, nextOptions = DEFAULT_NEXT_OPTI
|
|
|
2440
2814
|
};
|
|
2441
2815
|
|
|
2442
2816
|
// src/primitives/state/hydratedBlockByNumber.ts
|
|
2443
|
-
import { assertEx as
|
|
2817
|
+
import { assertEx as assertEx19, spanAsync as spanAsync2 } from "@xylabs/sdk-js";
|
|
2444
2818
|
async function hydratedBlockByNumber(context, blockNumber) {
|
|
2445
2819
|
return await spanAsync2("hydratedBlockByNumber", async () => {
|
|
2446
2820
|
if (blockNumber < 0) throw new Error(`Block number ${blockNumber} is less than 0`);
|
|
@@ -2448,7 +2822,7 @@ async function hydratedBlockByNumber(context, blockNumber) {
|
|
|
2448
2822
|
if (blockNumber % 1 !== 0) throw new Error(`Block number ${blockNumber} is not an integer`);
|
|
2449
2823
|
const cacheKey = String(blockNumber);
|
|
2450
2824
|
return await withContextCacheResponse(context, "hydratedBlockByNumber", cacheKey, async () => {
|
|
2451
|
-
const block =
|
|
2825
|
+
const block = assertEx19(
|
|
2452
2826
|
await blockFromBlockNumber(context, blockNumber),
|
|
2453
2827
|
() => `Could not find block for block number ${blockNumber}`
|
|
2454
2828
|
);
|
|
@@ -2499,7 +2873,7 @@ function findBestUncle(finalizedWindowedChain, uncles, options) {
|
|
|
2499
2873
|
|
|
2500
2874
|
// src/primitives/uncle/findUncles.ts
|
|
2501
2875
|
import {
|
|
2502
|
-
assertEx as
|
|
2876
|
+
assertEx as assertEx20,
|
|
2503
2877
|
exists as exists2
|
|
2504
2878
|
} from "@xylabs/sdk-js";
|
|
2505
2879
|
import { isTransactionBoundWitness as isTransactionBoundWitness2 } from "@xyo-network/xl1-protocol-lib";
|
|
@@ -2532,7 +2906,7 @@ function blocksToChains(blocks) {
|
|
|
2532
2906
|
}
|
|
2533
2907
|
function toValidUncle(_context, finalizedWindowedChain, possibleUncle) {
|
|
2534
2908
|
const finalizedWindowStartBlockNumber = finalizedWindowedChain.at(0)?.[0].block ?? -1;
|
|
2535
|
-
const finalizedHead =
|
|
2909
|
+
const finalizedHead = assertEx20(finalizedWindowedChain.at(-1), () => "finalizedWindowedChain is empty");
|
|
2536
2910
|
const prunedPossibleUncle = possibleUncle.filter((b) => b[0].block > finalizedHead[0].block);
|
|
2537
2911
|
if (prunedPossibleUncle.length === 0) {
|
|
2538
2912
|
return;
|
|
@@ -2651,44 +3025,6 @@ function resolveConfig(config) {
|
|
|
2651
3025
|
return parsedConfig;
|
|
2652
3026
|
}
|
|
2653
3027
|
|
|
2654
|
-
// src/config/normalizeConnectionsConfig.ts
|
|
2655
|
-
function mergeConnectionMaps(transports, connections) {
|
|
2656
|
-
return { ...transports, ...connections };
|
|
2657
|
-
}
|
|
2658
|
-
function normalizeProviderBinding(binding) {
|
|
2659
|
-
const connectionName = binding.connection ?? binding.transport;
|
|
2660
|
-
if (connectionName === void 0 || connectionName === "") {
|
|
2661
|
-
return binding;
|
|
2662
|
-
}
|
|
2663
|
-
return {
|
|
2664
|
-
...binding,
|
|
2665
|
-
connection: connectionName,
|
|
2666
|
-
transport: connectionName
|
|
2667
|
-
};
|
|
2668
|
-
}
|
|
2669
|
-
function normalizeProviderBindings(bindings) {
|
|
2670
|
-
const normalized = {};
|
|
2671
|
-
for (const [moniker, binding] of Object.entries(bindings)) {
|
|
2672
|
-
if (binding === void 0) continue;
|
|
2673
|
-
normalized[moniker] = normalizeProviderBinding(binding);
|
|
2674
|
-
}
|
|
2675
|
-
return normalized;
|
|
2676
|
-
}
|
|
2677
|
-
function normalizeConnectionsConfig(config) {
|
|
2678
|
-
const transports = config.transports ?? {};
|
|
2679
|
-
const connections = config.connections ?? {};
|
|
2680
|
-
const merged = mergeConnectionMaps(transports, connections);
|
|
2681
|
-
return {
|
|
2682
|
-
...config,
|
|
2683
|
-
connections: merged,
|
|
2684
|
-
providerBindings: normalizeProviderBindings(config.providerBindings ?? {}),
|
|
2685
|
-
transports: merged
|
|
2686
|
-
};
|
|
2687
|
-
}
|
|
2688
|
-
function hasDeclaredConnectionProfiles(config) {
|
|
2689
|
-
return Object.keys(config.transports ?? {}).length > 0 || Object.keys(config.connections ?? {}).length > 0;
|
|
2690
|
-
}
|
|
2691
|
-
|
|
2692
3028
|
// src/config/adaptLegacyConfig.ts
|
|
2693
3029
|
var DEFAULT_LMDB_TRANSPORT = "local-store";
|
|
2694
3030
|
var DEFAULT_RPC_TRANSPORT = "default-rpc";
|
|
@@ -2767,9 +3103,16 @@ var LMDB_MONIKERS = [
|
|
|
2767
3103
|
"FinalizationViewer",
|
|
2768
3104
|
"MempoolRunner",
|
|
2769
3105
|
"MempoolViewer",
|
|
3106
|
+
"NetworkStakeViewer",
|
|
3107
|
+
"NetworkStakeStepRewardsByPositionViewer",
|
|
3108
|
+
"NetworkStakeStepRewardsByStakerViewer",
|
|
3109
|
+
"NetworkStakeStepRewardsByStepViewer",
|
|
3110
|
+
"NetworkStakeStepRewardsTotalViewer",
|
|
3111
|
+
"NetworkStakeStepRewardsViewer",
|
|
2770
3112
|
"StakeEventsViewer",
|
|
2771
3113
|
"StakeTotalsViewer",
|
|
2772
3114
|
"StakeViewer",
|
|
3115
|
+
"StepViewer",
|
|
2773
3116
|
"TimeSyncViewer",
|
|
2774
3117
|
"TransactionValidationViewer",
|
|
2775
3118
|
"TransactionViewer",
|
|
@@ -2779,6 +3122,27 @@ var LMDB_MONIKERS = [
|
|
|
2779
3122
|
"XyoRunner",
|
|
2780
3123
|
"XyoViewer"
|
|
2781
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
|
+
];
|
|
2782
3146
|
function synthesizeLmdbProviderBindings(transports) {
|
|
2783
3147
|
const bindings = {};
|
|
2784
3148
|
if (!hasTransport(transports, DEFAULT_LMDB_TRANSPORT)) {
|
|
@@ -2792,11 +3156,9 @@ function synthesizeLmdbProviderBindings(transports) {
|
|
|
2792
3156
|
function synthesizeProviderBindings(transports) {
|
|
2793
3157
|
const bindings = {};
|
|
2794
3158
|
if (hasTransport(transports, DEFAULT_RPC_TRANSPORT)) {
|
|
2795
|
-
|
|
2796
|
-
|
|
2797
|
-
|
|
2798
|
-
bindMoniker2(bindings, "TransactionViewer", DEFAULT_RPC_TRANSPORT);
|
|
2799
|
-
bindMoniker2(bindings, "AccountBalanceViewer", DEFAULT_RPC_TRANSPORT);
|
|
3159
|
+
for (const moniker of RPC_MONIKERS) {
|
|
3160
|
+
bindMoniker2(bindings, moniker, DEFAULT_RPC_TRANSPORT);
|
|
3161
|
+
}
|
|
2800
3162
|
}
|
|
2801
3163
|
if (hasTransport(transports, S3_FINALIZED_TRANSPORT)) {
|
|
2802
3164
|
bindMoniker2(bindings, "BlockPublishRunner", S3_FINALIZED_TRANSPORT);
|
|
@@ -2989,7 +3351,7 @@ import { PayloadBundleSchema as PayloadBundleSchema2 } from "@xyo-network/sdk-js
|
|
|
2989
3351
|
import { PayloadBuilder as PayloadBuilder12 } from "@xyo-network/sdk-js";
|
|
2990
3352
|
|
|
2991
3353
|
// src/transaction/buildTransaction.ts
|
|
2992
|
-
import { assertEx as
|
|
3354
|
+
import { assertEx as assertEx21, toHex } from "@xylabs/sdk-js";
|
|
2993
3355
|
import {
|
|
2994
3356
|
asAnyPayload as asAnyPayload2,
|
|
2995
3357
|
BoundWitnessBuilder,
|
|
@@ -3015,7 +3377,7 @@ async function buildTransaction(chain, onChainPayloads, offChainPayloads, signer
|
|
|
3015
3377
|
const script = Array.from(elevatedHashes, (elevatedHash) => `elevate|${elevatedHash}`);
|
|
3016
3378
|
const fields = {
|
|
3017
3379
|
...txBoundWitnessFields,
|
|
3018
|
-
from: from ?? (Array.isArray(signer) ?
|
|
3380
|
+
from: from ?? (Array.isArray(signer) ? assertEx21(signer.at(0)?.address) : signer.address)
|
|
3019
3381
|
};
|
|
3020
3382
|
if (script.length > 0) {
|
|
3021
3383
|
fields.script = script;
|
|
@@ -3100,7 +3462,7 @@ var confirmSubmittedTransaction = async (viewer, txHash, options) => {
|
|
|
3100
3462
|
};
|
|
3101
3463
|
|
|
3102
3464
|
// src/transaction/hydrateTransaction.ts
|
|
3103
|
-
import { assertEx as
|
|
3465
|
+
import { assertEx as assertEx22 } from "@xylabs/sdk-js";
|
|
3104
3466
|
import {
|
|
3105
3467
|
asAnyPayload as asAnyPayload3,
|
|
3106
3468
|
hydrateTypedBoundWitness,
|
|
@@ -3171,7 +3533,7 @@ var tryHydrateElevatedTransaction = async ({ chainMap }, hash) => {
|
|
|
3171
3533
|
return void 0;
|
|
3172
3534
|
};
|
|
3173
3535
|
var hydrateElevatedTransaction = async (context, hash) => {
|
|
3174
|
-
return
|
|
3536
|
+
return assertEx22(await tryHydrateElevatedTransaction(context, hash), () => "Hydration failed");
|
|
3175
3537
|
};
|
|
3176
3538
|
|
|
3177
3539
|
// src/transaction/primitives/transactionBlockByteCount.ts
|
|
@@ -3224,13 +3586,13 @@ function transactionRequiredGas(hydratedTransaction) {
|
|
|
3224
3586
|
|
|
3225
3587
|
// src/transaction/signTransaction.ts
|
|
3226
3588
|
import {
|
|
3227
|
-
assertEx as
|
|
3589
|
+
assertEx as assertEx23,
|
|
3228
3590
|
hexFromArrayBuffer,
|
|
3229
3591
|
toArrayBuffer
|
|
3230
3592
|
} from "@xylabs/sdk-js";
|
|
3231
3593
|
import { PayloadBuilder as PayloadBuilder10 } from "@xyo-network/sdk-js";
|
|
3232
3594
|
async function signTransaction(tx, account) {
|
|
3233
|
-
|
|
3595
|
+
assertEx23(tx.from === account.address, () => "Signer address does not match transaction from address");
|
|
3234
3596
|
const unsignedTx = structuredClone(tx);
|
|
3235
3597
|
unsignedTx.addresses = [account.address];
|
|
3236
3598
|
unsignedTx.previous_hashes = [account.previousHash ?? null];
|
|
@@ -3245,7 +3607,7 @@ async function signTransaction(tx, account) {
|
|
|
3245
3607
|
}
|
|
3246
3608
|
|
|
3247
3609
|
// src/transaction/TransactionBuilder.ts
|
|
3248
|
-
import { assertEx as
|
|
3610
|
+
import { assertEx as assertEx24, Base } from "@xylabs/sdk-js";
|
|
3249
3611
|
import { PayloadBuilder as PayloadBuilder11 } from "@xyo-network/sdk-js";
|
|
3250
3612
|
import {
|
|
3251
3613
|
asXL1BlockNumber as asXL1BlockNumber4,
|
|
@@ -3265,9 +3627,9 @@ var TransactionBuilder = class extends Base {
|
|
|
3265
3627
|
super(options);
|
|
3266
3628
|
}
|
|
3267
3629
|
async build() {
|
|
3268
|
-
const chain =
|
|
3269
|
-
const fees =
|
|
3270
|
-
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");
|
|
3271
3633
|
return await buildTransaction(
|
|
3272
3634
|
chain,
|
|
3273
3635
|
this._elevatedPayloads,
|
|
@@ -3297,7 +3659,7 @@ var TransactionBuilder = class extends Base {
|
|
|
3297
3659
|
}
|
|
3298
3660
|
elevatedPayload(payload) {
|
|
3299
3661
|
const allowedPayload = isAllowedBlockPayload2(payload) ? payload : void 0;
|
|
3300
|
-
const allowPayloadExists =
|
|
3662
|
+
const allowPayloadExists = assertEx24(allowedPayload, () => "Payload must be an AllowedBlockPayload");
|
|
3301
3663
|
this._elevatedPayloads.push(allowPayloadExists);
|
|
3302
3664
|
return this;
|
|
3303
3665
|
}
|
|
@@ -3346,158 +3708,64 @@ var TransactionBuilder = class extends Base {
|
|
|
3346
3708
|
async removeElevatedPayload(payload) {
|
|
3347
3709
|
const hash = await PayloadBuilder11.hash(payload);
|
|
3348
3710
|
const existingHashes = await PayloadBuilder11.hashes(this._elevatedPayloads);
|
|
3349
|
-
const existingPayloadIndex = existingHashes.indexOf(hash);
|
|
3350
|
-
if (existingPayloadIndex === -1) {
|
|
3351
|
-
throw new Error("Payload not found in the transaction");
|
|
3352
|
-
}
|
|
3353
|
-
this._elevatedPayloads = this._elevatedPayloads.filter((_, index) => index !== existingPayloadIndex);
|
|
3354
|
-
return this;
|
|
3355
|
-
}
|
|
3356
|
-
async removePayload(payload) {
|
|
3357
|
-
const hash = await PayloadBuilder11.hash(payload);
|
|
3358
|
-
const existingHashes = await PayloadBuilder11.hashes(this._payloads);
|
|
3359
|
-
const existingPayloadIndex = existingHashes.indexOf(hash);
|
|
3360
|
-
if (existingPayloadIndex === -1) {
|
|
3361
|
-
throw new Error("Payload not found in the transaction");
|
|
3362
|
-
}
|
|
3363
|
-
this._payloads = this._payloads.filter((_, index) => index !== existingPayloadIndex);
|
|
3364
|
-
return this;
|
|
3365
|
-
}
|
|
3366
|
-
signer(signer) {
|
|
3367
|
-
if (signer) {
|
|
3368
|
-
this._signers.push(signer);
|
|
3369
|
-
}
|
|
3370
|
-
return this;
|
|
3371
|
-
}
|
|
3372
|
-
signers(signers) {
|
|
3373
|
-
if (signers)
|
|
3374
|
-
for (const signer of signers) {
|
|
3375
|
-
if (signer !== null) {
|
|
3376
|
-
this.signer(signer);
|
|
3377
|
-
}
|
|
3378
|
-
}
|
|
3379
|
-
return this;
|
|
3380
|
-
}
|
|
3381
|
-
};
|
|
3382
|
-
|
|
3383
|
-
// src/model/PayloadBundle/hydratedTransactionToPayloadBundle.ts
|
|
3384
|
-
var hydratedTransactionToPayloadBundle = (transaction) => {
|
|
3385
|
-
const root = transaction[0]._hash;
|
|
3386
|
-
return bundle2(root, transaction);
|
|
3387
|
-
};
|
|
3388
|
-
var bundle2 = (root, transaction) => {
|
|
3389
|
-
const payloads = flattenHydratedTransaction(transaction);
|
|
3390
|
-
const payloadBuilder = new PayloadBuilder12({ schema: PayloadBundleSchema2 });
|
|
3391
|
-
const builder = payloadBuilder.fields({ payloads, root });
|
|
3392
|
-
return builder.build();
|
|
3393
|
-
};
|
|
3394
|
-
|
|
3395
|
-
// src/context/Actor.ts
|
|
3396
|
-
var ActorConfigContext = z26.extend(BaseConfigContextZod, { config: ActorConfigZod });
|
|
3397
|
-
var isActorConfigContext = zodIsFactory5(ActorConfigContext);
|
|
3398
|
-
var asActorConfigContext = zodAsFactory6(ActorConfigContext, "asActorConfigContext");
|
|
3399
|
-
var toActorConfigContext = zodToFactory5(ActorConfigContext, "toActorConfigContext");
|
|
3400
|
-
|
|
3401
|
-
// src/CreatableProvider/AbstractCreatableProvider.ts
|
|
3402
|
-
import {
|
|
3403
|
-
AbstractCreatable,
|
|
3404
|
-
assertEx as assertEx24,
|
|
3405
|
-
IdLogger
|
|
3406
|
-
} from "@xylabs/sdk-js";
|
|
3407
|
-
|
|
3408
|
-
// src/CreatableProvider/ProviderFactory.ts
|
|
3409
|
-
import { assertEx as assertEx23 } from "@xylabs/sdk-js";
|
|
3410
|
-
function providerFactoryDescription(factory, labels) {
|
|
3411
|
-
return `${factory.providerName}:${factory.defaultMoniker}:${JSON.stringify(labels ?? factory.labels ?? {})}`;
|
|
3412
|
-
}
|
|
3413
|
-
var ProviderFactory = class _ProviderFactory {
|
|
3414
|
-
creatableProvider;
|
|
3415
|
-
defaultMoniker;
|
|
3416
|
-
defaultParams;
|
|
3417
|
-
dependencies;
|
|
3418
|
-
labels;
|
|
3419
|
-
monikers;
|
|
3420
|
-
providerName;
|
|
3421
|
-
scope;
|
|
3422
|
-
_uniqueId;
|
|
3423
|
-
constructor(creatableProvider2, dependencies, params, labels = {}, scope = "context") {
|
|
3424
|
-
this.creatableProvider = creatableProvider2;
|
|
3425
|
-
this.defaultParams = params;
|
|
3426
|
-
this.defaultMoniker = creatableProvider2.defaultMoniker;
|
|
3427
|
-
this.dependencies = dependencies;
|
|
3428
|
-
this.monikers = creatableProvider2.monikers;
|
|
3429
|
-
this.scope = scope;
|
|
3430
|
-
assertEx23(this.monikers.includes(this.defaultMoniker), () => "defaultMoniker must be in monikers");
|
|
3431
|
-
this.labels = Object.assign({}, creatableProvider2.labels ?? {}, labels ?? {});
|
|
3432
|
-
this.providerName = creatableProvider2.name;
|
|
3433
|
-
this._uniqueId = Symbol(providerFactoryDescription(this));
|
|
3434
|
-
}
|
|
3435
|
-
get resolvedMoniker() {
|
|
3436
|
-
const labels = this.labels ?? {};
|
|
3437
|
-
const labelString = Object.entries(labels).map(([key, value]) => `${key}=${value}`).join(",");
|
|
3438
|
-
return labelString.length === 0 ? this.defaultMoniker : `${this.defaultMoniker}|${labelString}`;
|
|
3439
|
-
}
|
|
3440
|
-
get uniqueId() {
|
|
3441
|
-
return this._uniqueId;
|
|
3442
|
-
}
|
|
3443
|
-
static withParams(creatableProvider2, dependencies, params, labels = {}) {
|
|
3444
|
-
return new _ProviderFactory(creatableProvider2, dependencies, params, labels);
|
|
3445
|
-
}
|
|
3446
|
-
factory(dependencies, params, labels = {}) {
|
|
3447
|
-
return new _ProviderFactory(this.creatableProvider, dependencies, params, labels);
|
|
3448
|
-
}
|
|
3449
|
-
async getInstance(params, { start = true }) {
|
|
3450
|
-
let scopeObject;
|
|
3451
|
-
switch (this.scope) {
|
|
3452
|
-
case "global": {
|
|
3453
|
-
scopeObject = getOrCreateGlobalSingletons();
|
|
3454
|
-
break;
|
|
3455
|
-
}
|
|
3456
|
-
case "context": {
|
|
3457
|
-
const context = assertEx23(
|
|
3458
|
-
params?.context,
|
|
3459
|
-
() => "Context is required for context-scoped providers"
|
|
3460
|
-
);
|
|
3461
|
-
context.singletons ??= {};
|
|
3462
|
-
scopeObject = context.singletons;
|
|
3463
|
-
break;
|
|
3464
|
-
}
|
|
3465
|
-
default: {
|
|
3466
|
-
scopeObject = {};
|
|
3467
|
-
break;
|
|
3468
|
-
}
|
|
3469
|
-
}
|
|
3470
|
-
const mergedParams = {
|
|
3471
|
-
...this.defaultParams,
|
|
3472
|
-
...params
|
|
3473
|
-
};
|
|
3474
|
-
const resultPromise = scopeObject[this.resolvedMoniker] ?? this.creatableProvider.create(mergedParams);
|
|
3475
|
-
scopeObject[this.resolvedMoniker] = resultPromise;
|
|
3476
|
-
const result = await resultPromise;
|
|
3477
|
-
if (start) {
|
|
3478
|
-
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");
|
|
3479
3714
|
}
|
|
3480
|
-
|
|
3715
|
+
this._elevatedPayloads = this._elevatedPayloads.filter((_, index) => index !== existingPayloadIndex);
|
|
3716
|
+
return this;
|
|
3481
3717
|
}
|
|
3482
|
-
async
|
|
3483
|
-
|
|
3484
|
-
|
|
3485
|
-
|
|
3486
|
-
|
|
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");
|
|
3487
3724
|
}
|
|
3725
|
+
this._payloads = this._payloads.filter((_, index) => index !== existingPayloadIndex);
|
|
3726
|
+
return this;
|
|
3488
3727
|
}
|
|
3489
|
-
|
|
3490
|
-
|
|
3491
|
-
|
|
3492
|
-
|
|
3493
|
-
return
|
|
3728
|
+
signer(signer) {
|
|
3729
|
+
if (signer) {
|
|
3730
|
+
this._signers.push(signer);
|
|
3731
|
+
}
|
|
3732
|
+
return this;
|
|
3494
3733
|
}
|
|
3495
|
-
|
|
3496
|
-
|
|
3497
|
-
|
|
3498
|
-
|
|
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");
|
|
3499
3762
|
|
|
3500
3763
|
// src/CreatableProvider/AbstractCreatableProvider.ts
|
|
3764
|
+
import {
|
|
3765
|
+
AbstractCreatable,
|
|
3766
|
+
assertEx as assertEx25,
|
|
3767
|
+
IdLogger
|
|
3768
|
+
} from "@xylabs/sdk-js";
|
|
3501
3769
|
var AbstractCreatableProvider = class extends AbstractCreatable {
|
|
3502
3770
|
dependencies = {};
|
|
3503
3771
|
_contextCache;
|
|
@@ -3529,9 +3797,9 @@ var AbstractCreatableProvider = class extends AbstractCreatable {
|
|
|
3529
3797
|
return factory;
|
|
3530
3798
|
}
|
|
3531
3799
|
static async paramsHandler(params = {}) {
|
|
3532
|
-
const context =
|
|
3533
|
-
const config =
|
|
3534
|
-
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"));
|
|
3535
3803
|
return await super.paramsHandler({
|
|
3536
3804
|
...params,
|
|
3537
3805
|
statusReporter: params.statusReporter ?? context.statusReporter,
|
|
@@ -3573,203 +3841,6 @@ function labeledCreatableProvider() {
|
|
|
3573
3841
|
};
|
|
3574
3842
|
}
|
|
3575
3843
|
|
|
3576
|
-
// src/CreatableProvider/CreatableProviderRegistry.ts
|
|
3577
|
-
import { isTruthy } from "@xylabs/sdk-js";
|
|
3578
|
-
var buildProviderFactory = (provider, defaultParams, labels) => {
|
|
3579
|
-
const factory = {
|
|
3580
|
-
monikers: provider.monikers,
|
|
3581
|
-
uniqueId: Symbol(providerFactoryDescription(provider, labels)),
|
|
3582
|
-
// Merge module & supplied labels
|
|
3583
|
-
labels: { ...provider.labels, ...labels },
|
|
3584
|
-
creatableProvider: provider.creatableProvider,
|
|
3585
|
-
dependencies: provider.dependencies,
|
|
3586
|
-
resolvedMoniker: provider.resolvedMoniker,
|
|
3587
|
-
providerName: provider.providerName,
|
|
3588
|
-
scope: provider.scope,
|
|
3589
|
-
defaultParams,
|
|
3590
|
-
getInstance: provider.getInstance.bind(provider),
|
|
3591
|
-
tryGetInstance: provider.tryGetInstance?.bind(provider),
|
|
3592
|
-
defaultMoniker: provider.defaultMoniker,
|
|
3593
|
-
factory: provider.factory.bind(provider)
|
|
3594
|
-
};
|
|
3595
|
-
return factory;
|
|
3596
|
-
};
|
|
3597
|
-
var registerCreatableProviderFactory = (registry, factory, labels, primary = false) => {
|
|
3598
|
-
const primaryMonikers = primary !== true && isTruthy(primary) ? Array.isArray(primary) ? primary : [primary] : [];
|
|
3599
|
-
for (const primaryMoniker of primaryMonikers) {
|
|
3600
|
-
if (!factory.monikers.includes(primaryMoniker)) {
|
|
3601
|
-
throw new Error(`Primary moniker ${String(primaryMoniker)} not found in factory monikers`);
|
|
3602
|
-
}
|
|
3603
|
-
}
|
|
3604
|
-
const isPrimaryForMoniker = (moniker) => {
|
|
3605
|
-
switch (typeof primary) {
|
|
3606
|
-
case "boolean": {
|
|
3607
|
-
return primary;
|
|
3608
|
-
}
|
|
3609
|
-
case "string": {
|
|
3610
|
-
return moniker === primary;
|
|
3611
|
-
}
|
|
3612
|
-
case "object": {
|
|
3613
|
-
if (Array.isArray(primary)) {
|
|
3614
|
-
return primary.includes(moniker);
|
|
3615
|
-
}
|
|
3616
|
-
}
|
|
3617
|
-
}
|
|
3618
|
-
throw new Error(`Invalid primary value: ${String(primary)}`);
|
|
3619
|
-
};
|
|
3620
|
-
const factoryClone = buildProviderFactory(factory, factory.defaultParams, labels);
|
|
3621
|
-
registry[factoryClone.defaultMoniker] = [factoryClone, ...registry[factoryClone.defaultMoniker] ?? []];
|
|
3622
|
-
for (const moniker of factoryClone.monikers) {
|
|
3623
|
-
if (moniker === factoryClone.defaultMoniker) continue;
|
|
3624
|
-
registry[moniker] = isPrimaryForMoniker(moniker) ? [factoryClone, ...registry[moniker] ?? []] : [...registry[moniker] ?? [], factoryClone];
|
|
3625
|
-
}
|
|
3626
|
-
};
|
|
3627
|
-
var registerCreatableProviderFactories = (factories, registry = {}, primary = false) => {
|
|
3628
|
-
for (const factory of factories) {
|
|
3629
|
-
registerCreatableProviderFactory(registry, factory, void 0, primary);
|
|
3630
|
-
}
|
|
3631
|
-
return registry;
|
|
3632
|
-
};
|
|
3633
|
-
|
|
3634
|
-
// src/CreatableProvider/LabeledCreatableProviderFactory.ts
|
|
3635
|
-
var hasLabels = (factory) => {
|
|
3636
|
-
return factory.labels !== void 0;
|
|
3637
|
-
};
|
|
3638
|
-
function labeledCreatableProviderFactory() {
|
|
3639
|
-
return (constructor) => {
|
|
3640
|
-
constructor;
|
|
3641
|
-
};
|
|
3642
|
-
}
|
|
3643
|
-
|
|
3644
|
-
// src/CreatableProvider/ProviderFactoryLocator.ts
|
|
3645
|
-
import { hasAllLabels } from "@xylabs/sdk-js";
|
|
3646
|
-
import { assertEx as assertEx25 } from "@xylabs/sdk-js";
|
|
3647
|
-
var ProviderFactoryLocator = class _ProviderFactoryLocator {
|
|
3648
|
-
_context;
|
|
3649
|
-
_registry;
|
|
3650
|
-
_frozen = false;
|
|
3651
|
-
_parent;
|
|
3652
|
-
_validateDepsOnRegister;
|
|
3653
|
-
constructor(context, registry = {}, validateDepsOnRegister = false) {
|
|
3654
|
-
this._registry = registry;
|
|
3655
|
-
this._context = { ...context, locator: this };
|
|
3656
|
-
this._parent = context.locator;
|
|
3657
|
-
this._validateDepsOnRegister = validateDepsOnRegister;
|
|
3658
|
-
}
|
|
3659
|
-
get context() {
|
|
3660
|
-
return this._context;
|
|
3661
|
-
}
|
|
3662
|
-
get logger() {
|
|
3663
|
-
return this.context.logger;
|
|
3664
|
-
}
|
|
3665
|
-
/**
|
|
3666
|
-
* The current registry for the module factory
|
|
3667
|
-
*/
|
|
3668
|
-
get registry() {
|
|
3669
|
-
return this._registry;
|
|
3670
|
-
}
|
|
3671
|
-
get validateDepsOnRegister() {
|
|
3672
|
-
return this._validateDepsOnRegister;
|
|
3673
|
-
}
|
|
3674
|
-
freeze() {
|
|
3675
|
-
this._frozen = true;
|
|
3676
|
-
}
|
|
3677
|
-
async getInstance(moniker, { start = true, labels } = {}) {
|
|
3678
|
-
return assertEx25(
|
|
3679
|
-
await this.tryGetInstance(moniker, { start, labels }),
|
|
3680
|
-
() => `No provider instance for the supplied config moniker [${moniker}]${labels ? ` & labels [${JSON.stringify(labels)}]` : ""} could be created`
|
|
3681
|
-
);
|
|
3682
|
-
}
|
|
3683
|
-
has(moniker) {
|
|
3684
|
-
return Object.hasOwn(this._registry, moniker);
|
|
3685
|
-
}
|
|
3686
|
-
/**
|
|
3687
|
-
* Locates a provider factory that matches the supplied moniker and labels
|
|
3688
|
-
* @param moniker The config moniker for the provider
|
|
3689
|
-
* @param labels The labels for the provider factory
|
|
3690
|
-
* @returns A provider factory that matches the supplied moniker and labels or throws if one is not found
|
|
3691
|
-
*/
|
|
3692
|
-
locate(moniker, labels) {
|
|
3693
|
-
return assertEx25(
|
|
3694
|
-
this.tryLocate(moniker, labels),
|
|
3695
|
-
() => `No module factory for the supplied config moniker [${moniker}]${labels ? ` & labels [${JSON.stringify(labels)}]` : ""} registered`
|
|
3696
|
-
);
|
|
3697
|
-
}
|
|
3698
|
-
merge(locator) {
|
|
3699
|
-
const registry = { ...this.registry };
|
|
3700
|
-
for (const moniker in locator.registry) {
|
|
3701
|
-
const existing = registry[moniker];
|
|
3702
|
-
if (existing === void 0) {
|
|
3703
|
-
registry[moniker] = locator.registry[moniker];
|
|
3704
|
-
} else {
|
|
3705
|
-
existing.push(...locator.registry[moniker] ?? []);
|
|
3706
|
-
}
|
|
3707
|
-
}
|
|
3708
|
-
return new _ProviderFactoryLocator(this.context, registry);
|
|
3709
|
-
}
|
|
3710
|
-
/**
|
|
3711
|
-
* Registers a single module factory (with optional tags) with the locator
|
|
3712
|
-
* @param factory The factory to register
|
|
3713
|
-
* @param labels The labels for the module factory
|
|
3714
|
-
*/
|
|
3715
|
-
register(factory, labels, primary = false) {
|
|
3716
|
-
assertEx25(!this._frozen, () => "Cannot register a module factory after the locator has been frozen");
|
|
3717
|
-
if (this.validateDepsOnRegister) {
|
|
3718
|
-
const missingDeps = factory.dependencies.filter((dep) => !this.registered(dep));
|
|
3719
|
-
assertEx25(missingDeps.length === 0, () => `Cannot register module factory [${factory.uniqueId.description}] due to missing dependencies: ${missingDeps.join(", ")}`);
|
|
3720
|
-
}
|
|
3721
|
-
registerCreatableProviderFactory(this._registry, factory, labels, primary);
|
|
3722
|
-
return this;
|
|
3723
|
-
}
|
|
3724
|
-
/**
|
|
3725
|
-
* Registers multiple module factories with the locator
|
|
3726
|
-
* @param factories The factories to register
|
|
3727
|
-
*/
|
|
3728
|
-
registerMany(factories) {
|
|
3729
|
-
for (const factory of factories) {
|
|
3730
|
-
this.register(factory);
|
|
3731
|
-
}
|
|
3732
|
-
return this;
|
|
3733
|
-
}
|
|
3734
|
-
registered(moniker) {
|
|
3735
|
-
return Object.hasOwn(this.registry, moniker) || (this._parent?.registered(moniker) ?? false);
|
|
3736
|
-
}
|
|
3737
|
-
async tryGetInstance(moniker, { start = true, labels } = {}) {
|
|
3738
|
-
const resolvedParams = { context: this.context };
|
|
3739
|
-
const factory = this.tryLocate(moniker, labels);
|
|
3740
|
-
if (factory !== void 0) {
|
|
3741
|
-
if (Object.hasOwn(this.context.singletons, factory.uniqueId)) {
|
|
3742
|
-
return this.context.singletons[factory.uniqueId];
|
|
3743
|
-
}
|
|
3744
|
-
this.logger?.debug(`Creating provider instance for moniker [${moniker}]${labels ? ` with labels [${JSON.stringify(labels)}]` : ""} using factory [${factory.uniqueId.description}]`);
|
|
3745
|
-
const result = await factory.getInstance(resolvedParams, { start });
|
|
3746
|
-
this.context.singletons[factory.uniqueId] = result;
|
|
3747
|
-
return result;
|
|
3748
|
-
}
|
|
3749
|
-
}
|
|
3750
|
-
/**
|
|
3751
|
-
* Tries to locate a module factory that matches the supplied moniker and labels
|
|
3752
|
-
* @param moniker The config moniker for the module
|
|
3753
|
-
* @param labels The labels for the module factory
|
|
3754
|
-
* @returns A module factory that matches the supplied moniker and labels or undefined
|
|
3755
|
-
*/
|
|
3756
|
-
tryLocate(moniker, labels) {
|
|
3757
|
-
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);
|
|
3758
|
-
return result;
|
|
3759
|
-
}
|
|
3760
|
-
validateDependencies(recursive = false) {
|
|
3761
|
-
if (recursive) {
|
|
3762
|
-
this._parent?.validateDependencies();
|
|
3763
|
-
}
|
|
3764
|
-
for (const moniker in this.registry) {
|
|
3765
|
-
for (const factory of this.registry[moniker] ?? []) {
|
|
3766
|
-
const missingDeps = factory.dependencies.filter((dep) => !this.registered(dep));
|
|
3767
|
-
assertEx25(missingDeps.length === 0, () => `Module factory [${factory.uniqueId.description}] is missing dependencies: ${missingDeps.join(", ")}`);
|
|
3768
|
-
}
|
|
3769
|
-
}
|
|
3770
|
-
}
|
|
3771
|
-
};
|
|
3772
|
-
|
|
3773
3844
|
// src/context/getEmptyProviderContext.ts
|
|
3774
3845
|
function getEmptyProviderContext(config) {
|
|
3775
3846
|
const singletons = {};
|
|
@@ -4638,9 +4709,11 @@ var SimpleAccountBalanceViewer = class extends AbstractCreatableProvider {
|
|
|
4638
4709
|
}, this.context);
|
|
4639
4710
|
}
|
|
4640
4711
|
};
|
|
4712
|
+
__publicField(SimpleAccountBalanceViewer, "connectionTypes", ["lmdb", "mongo"]);
|
|
4641
4713
|
__publicField(SimpleAccountBalanceViewer, "defaultMoniker", AccountBalanceViewerMoniker);
|
|
4642
4714
|
__publicField(SimpleAccountBalanceViewer, "dependencies", [BlockViewerMoniker]);
|
|
4643
4715
|
__publicField(SimpleAccountBalanceViewer, "monikers", [AccountBalanceViewerMoniker]);
|
|
4716
|
+
__publicField(SimpleAccountBalanceViewer, "surface", "node");
|
|
4644
4717
|
SimpleAccountBalanceViewer = __decorateClass([
|
|
4645
4718
|
creatableProvider()
|
|
4646
4719
|
], SimpleAccountBalanceViewer);
|
|
@@ -4938,9 +5011,11 @@ var SimpleBlockViewer = class extends AbstractCreatableProvider {
|
|
|
4938
5011
|
this._headPollTimer = null;
|
|
4939
5012
|
}
|
|
4940
5013
|
};
|
|
5014
|
+
__publicField(SimpleBlockViewer, "connectionTypes", ["lmdb", "mongo"]);
|
|
4941
5015
|
__publicField(SimpleBlockViewer, "defaultMoniker", BlockViewerMoniker2);
|
|
4942
5016
|
__publicField(SimpleBlockViewer, "dependencies", [FinalizationViewerMoniker]);
|
|
4943
5017
|
__publicField(SimpleBlockViewer, "monikers", [BlockViewerMoniker2]);
|
|
5018
|
+
__publicField(SimpleBlockViewer, "surface", "node");
|
|
4944
5019
|
SimpleBlockViewer = __decorateClass([
|
|
4945
5020
|
creatableProvider()
|
|
4946
5021
|
], SimpleBlockViewer);
|
|
@@ -4955,9 +5030,11 @@ var SimpleBlockRewardViewer = class extends AbstractCreatableProvider {
|
|
|
4955
5030
|
);
|
|
4956
5031
|
}
|
|
4957
5032
|
};
|
|
5033
|
+
__publicField(SimpleBlockRewardViewer, "connectionTypes", ["lmdb", "mongo", "rpc"]);
|
|
4958
5034
|
__publicField(SimpleBlockRewardViewer, "defaultMoniker", BlockRewardViewerMoniker);
|
|
4959
5035
|
__publicField(SimpleBlockRewardViewer, "dependencies", []);
|
|
4960
5036
|
__publicField(SimpleBlockRewardViewer, "monikers", [BlockRewardViewerMoniker]);
|
|
5037
|
+
__publicField(SimpleBlockRewardViewer, "surface", "node");
|
|
4961
5038
|
SimpleBlockRewardViewer = __decorateClass([
|
|
4962
5039
|
creatableProvider()
|
|
4963
5040
|
], SimpleBlockRewardViewer);
|
|
@@ -5097,9 +5174,11 @@ var SimpleBlockValidationViewer = class extends AbstractCreatableProvider {
|
|
|
5097
5174
|
return [...this._uncleWindowedChainCache];
|
|
5098
5175
|
}
|
|
5099
5176
|
};
|
|
5177
|
+
__publicField(SimpleBlockValidationViewer, "connectionTypes", ["lmdb", "mongo", "rpc"]);
|
|
5100
5178
|
__publicField(SimpleBlockValidationViewer, "defaultMoniker", BlockValidationViewerMoniker);
|
|
5101
5179
|
__publicField(SimpleBlockValidationViewer, "dependencies", [AccountBalanceViewerMoniker2, BlockViewerMoniker3, ChainContractViewerMoniker]);
|
|
5102
5180
|
__publicField(SimpleBlockValidationViewer, "monikers", [BlockValidationViewerMoniker]);
|
|
5181
|
+
__publicField(SimpleBlockValidationViewer, "surface", "node");
|
|
5103
5182
|
SimpleBlockValidationViewer = __decorateClass([
|
|
5104
5183
|
creatableProvider()
|
|
5105
5184
|
], SimpleBlockValidationViewer);
|
|
@@ -5155,9 +5234,11 @@ var SimpleChainContractViewer = class extends AbstractCreatableProvider {
|
|
|
5155
5234
|
return this.params.stakingTokenAddress;
|
|
5156
5235
|
}
|
|
5157
5236
|
};
|
|
5237
|
+
__publicField(SimpleChainContractViewer, "connectionTypes", ["lmdb", "mongo"]);
|
|
5158
5238
|
__publicField(SimpleChainContractViewer, "defaultMoniker", ChainContractViewerMoniker2);
|
|
5159
5239
|
__publicField(SimpleChainContractViewer, "dependencies", [FinalizationViewerMoniker2]);
|
|
5160
5240
|
__publicField(SimpleChainContractViewer, "monikers", [ChainContractViewerMoniker2]);
|
|
5241
|
+
__publicField(SimpleChainContractViewer, "surface", "node");
|
|
5161
5242
|
SimpleChainContractViewer = __decorateClass([
|
|
5162
5243
|
creatableProvider()
|
|
5163
5244
|
], SimpleChainContractViewer);
|
|
@@ -5258,9 +5339,11 @@ var RestDataLakeRunner = class extends AbstractRestDataLake {
|
|
|
5258
5339
|
return [];
|
|
5259
5340
|
}
|
|
5260
5341
|
};
|
|
5342
|
+
__publicField(RestDataLakeRunner, "connectionTypes", ["rest"]);
|
|
5261
5343
|
__publicField(RestDataLakeRunner, "defaultMoniker", DataLakeRunnerMoniker);
|
|
5262
5344
|
__publicField(RestDataLakeRunner, "dependencies", []);
|
|
5263
5345
|
__publicField(RestDataLakeRunner, "monikers", [DataLakeRunnerMoniker]);
|
|
5346
|
+
__publicField(RestDataLakeRunner, "surface", "node");
|
|
5264
5347
|
RestDataLakeRunner = __decorateClass([
|
|
5265
5348
|
creatableProvider()
|
|
5266
5349
|
], RestDataLakeRunner);
|
|
@@ -5270,9 +5353,11 @@ import { DataLakeViewerMoniker } from "@xyo-network/xl1-protocol-lib";
|
|
|
5270
5353
|
var RestDataLakeViewer = class extends AbstractRestDataLake {
|
|
5271
5354
|
moniker = RestDataLakeViewer.defaultMoniker;
|
|
5272
5355
|
};
|
|
5356
|
+
__publicField(RestDataLakeViewer, "connectionTypes", ["rest"]);
|
|
5273
5357
|
__publicField(RestDataLakeViewer, "defaultMoniker", DataLakeViewerMoniker);
|
|
5274
5358
|
__publicField(RestDataLakeViewer, "dependencies", []);
|
|
5275
5359
|
__publicField(RestDataLakeViewer, "monikers", [DataLakeViewerMoniker]);
|
|
5360
|
+
__publicField(RestDataLakeViewer, "surface", "node");
|
|
5276
5361
|
RestDataLakeViewer = __decorateClass([
|
|
5277
5362
|
creatableProvider()
|
|
5278
5363
|
], RestDataLakeViewer);
|
|
@@ -5341,9 +5426,11 @@ var SimpleDataLakeRunner = class extends AbstractSimpleDataLake {
|
|
|
5341
5426
|
return hashPairs.map(([payload]) => payload);
|
|
5342
5427
|
}
|
|
5343
5428
|
};
|
|
5429
|
+
__publicField(SimpleDataLakeRunner, "connectionTypes", []);
|
|
5344
5430
|
__publicField(SimpleDataLakeRunner, "defaultMoniker", DataLakeRunnerMoniker2);
|
|
5345
5431
|
__publicField(SimpleDataLakeRunner, "dependencies", []);
|
|
5346
5432
|
__publicField(SimpleDataLakeRunner, "monikers", [DataLakeRunnerMoniker2]);
|
|
5433
|
+
__publicField(SimpleDataLakeRunner, "surface", "node");
|
|
5347
5434
|
SimpleDataLakeRunner = __decorateClass([
|
|
5348
5435
|
creatableProvider()
|
|
5349
5436
|
], SimpleDataLakeRunner);
|
|
@@ -5353,9 +5440,11 @@ import { DataLakeViewerMoniker as DataLakeViewerMoniker2 } from "@xyo-network/xl
|
|
|
5353
5440
|
var SimpleDataLakeViewer = class extends AbstractSimpleDataLake {
|
|
5354
5441
|
moniker = SimpleDataLakeViewer.defaultMoniker;
|
|
5355
5442
|
};
|
|
5443
|
+
__publicField(SimpleDataLakeViewer, "connectionTypes", []);
|
|
5356
5444
|
__publicField(SimpleDataLakeViewer, "defaultMoniker", DataLakeViewerMoniker2);
|
|
5357
5445
|
__publicField(SimpleDataLakeViewer, "dependencies", []);
|
|
5358
5446
|
__publicField(SimpleDataLakeViewer, "monikers", [DataLakeViewerMoniker2]);
|
|
5447
|
+
__publicField(SimpleDataLakeViewer, "surface", "node");
|
|
5359
5448
|
SimpleDataLakeViewer = __decorateClass([
|
|
5360
5449
|
creatableProvider()
|
|
5361
5450
|
], SimpleDataLakeViewer);
|
|
@@ -5383,9 +5472,11 @@ var SimpleFinalizationRunner = class extends AbstractCreatableProvider {
|
|
|
5383
5472
|
return sortedBlocks.map((b) => b[0]._hash);
|
|
5384
5473
|
}
|
|
5385
5474
|
};
|
|
5475
|
+
__publicField(SimpleFinalizationRunner, "connectionTypes", ["lmdb", "mongo"]);
|
|
5386
5476
|
__publicField(SimpleFinalizationRunner, "defaultMoniker", FinalizationRunnerMoniker);
|
|
5387
5477
|
__publicField(SimpleFinalizationRunner, "dependencies", []);
|
|
5388
5478
|
__publicField(SimpleFinalizationRunner, "monikers", [FinalizationRunnerMoniker]);
|
|
5479
|
+
__publicField(SimpleFinalizationRunner, "surface", "node");
|
|
5389
5480
|
SimpleFinalizationRunner = __decorateClass([
|
|
5390
5481
|
creatableProvider()
|
|
5391
5482
|
], SimpleFinalizationRunner);
|
|
@@ -5475,9 +5566,11 @@ var SimpleFinalizationViewer = class extends AbstractCreatableProvider {
|
|
|
5475
5566
|
return result;
|
|
5476
5567
|
}
|
|
5477
5568
|
};
|
|
5569
|
+
__publicField(SimpleFinalizationViewer, "connectionTypes", ["lmdb", "mongo"]);
|
|
5478
5570
|
__publicField(SimpleFinalizationViewer, "defaultMoniker", FinalizationViewerMoniker3);
|
|
5479
5571
|
__publicField(SimpleFinalizationViewer, "dependencies", [ChainContractViewerMoniker3]);
|
|
5480
5572
|
__publicField(SimpleFinalizationViewer, "monikers", [FinalizationViewerMoniker3]);
|
|
5573
|
+
__publicField(SimpleFinalizationViewer, "surface", "node");
|
|
5481
5574
|
SimpleFinalizationViewer = __decorateClass([
|
|
5482
5575
|
creatableProvider()
|
|
5483
5576
|
], SimpleFinalizationViewer);
|
|
@@ -6025,9 +6118,11 @@ var SimpleMempoolRunner = class extends AbstractCreatableProvider {
|
|
|
6025
6118
|
this.logger?.debug(`Synced ${externalTxs.length} transactions from external mempool`);
|
|
6026
6119
|
}
|
|
6027
6120
|
};
|
|
6121
|
+
__publicField(SimpleMempoolRunner, "connectionTypes", ["lmdb", "mongo"]);
|
|
6028
6122
|
__publicField(SimpleMempoolRunner, "defaultMoniker", MempoolRunnerMoniker);
|
|
6029
6123
|
__publicField(SimpleMempoolRunner, "dependencies", [FinalizationViewerMoniker4, BlockValidationViewerMoniker2, TransactionValidationViewerMoniker, ChainContractViewerMoniker4]);
|
|
6030
6124
|
__publicField(SimpleMempoolRunner, "monikers", [MempoolRunnerMoniker]);
|
|
6125
|
+
__publicField(SimpleMempoolRunner, "surface", "node");
|
|
6031
6126
|
SimpleMempoolRunner = __decorateClass([
|
|
6032
6127
|
creatableProvider()
|
|
6033
6128
|
], SimpleMempoolRunner);
|
|
@@ -6242,9 +6337,11 @@ var SimpleMempoolViewer = class extends AbstractCreatableProvider {
|
|
|
6242
6337
|
return deduplicateWithBundleBySigner(randomSelected).slice(0, effectiveLimit);
|
|
6243
6338
|
}
|
|
6244
6339
|
};
|
|
6340
|
+
__publicField(SimpleMempoolViewer, "connectionTypes", ["lmdb", "mongo"]);
|
|
6245
6341
|
__publicField(SimpleMempoolViewer, "defaultMoniker", MempoolViewerMoniker2);
|
|
6246
6342
|
__publicField(SimpleMempoolViewer, "dependencies", [WindowedBlockViewerMoniker]);
|
|
6247
6343
|
__publicField(SimpleMempoolViewer, "monikers", [MempoolViewerMoniker2]);
|
|
6344
|
+
__publicField(SimpleMempoolViewer, "surface", "node");
|
|
6248
6345
|
SimpleMempoolViewer = __decorateClass([
|
|
6249
6346
|
creatableProvider()
|
|
6250
6347
|
], SimpleMempoolViewer);
|
|
@@ -6433,9 +6530,11 @@ var SimpleXyoRunner = class extends AbstractCreatableProvider {
|
|
|
6433
6530
|
this._mempoolRunner = await this.locator.getInstance(MempoolRunnerMoniker2);
|
|
6434
6531
|
}
|
|
6435
6532
|
};
|
|
6533
|
+
__publicField(SimpleXyoRunner, "connectionTypes", ["lmdb", "mongo"]);
|
|
6436
6534
|
__publicField(SimpleXyoRunner, "defaultMoniker", XyoRunnerMoniker);
|
|
6437
6535
|
__publicField(SimpleXyoRunner, "dependencies", [MempoolRunnerMoniker2]);
|
|
6438
6536
|
__publicField(SimpleXyoRunner, "monikers", [XyoRunnerMoniker]);
|
|
6537
|
+
__publicField(SimpleXyoRunner, "surface", "node");
|
|
6439
6538
|
SimpleXyoRunner = __decorateClass([
|
|
6440
6539
|
creatableProvider()
|
|
6441
6540
|
], SimpleXyoRunner);
|
|
@@ -6447,9 +6546,11 @@ import {
|
|
|
6447
6546
|
XyoSignerMoniker as XyoSignerMoniker2
|
|
6448
6547
|
} from "@xyo-network/xl1-protocol-lib";
|
|
6449
6548
|
var SimpleXyoSigner = class _SimpleXyoSigner extends AbstractCreatableProvider {
|
|
6549
|
+
static connectionTypes = ["wallet"];
|
|
6450
6550
|
static defaultMoniker = XyoSignerMoniker2;
|
|
6451
6551
|
static dependencies = [];
|
|
6452
6552
|
static monikers = [XyoSignerMoniker2];
|
|
6553
|
+
static surface = "node";
|
|
6453
6554
|
moniker = _SimpleXyoSigner.defaultMoniker;
|
|
6454
6555
|
static async paramsHandler(params) {
|
|
6455
6556
|
let account;
|
|
@@ -6559,9 +6660,11 @@ var SimpleStakeEventsViewer = class extends AbstractCreatableProvider {
|
|
|
6559
6660
|
return filteredPositions;
|
|
6560
6661
|
}
|
|
6561
6662
|
};
|
|
6663
|
+
__publicField(SimpleStakeEventsViewer, "connectionTypes", []);
|
|
6562
6664
|
__publicField(SimpleStakeEventsViewer, "defaultMoniker", StakeEventsViewerMoniker);
|
|
6563
6665
|
__publicField(SimpleStakeEventsViewer, "dependencies", []);
|
|
6564
6666
|
__publicField(SimpleStakeEventsViewer, "monikers", [StakeEventsViewerMoniker]);
|
|
6667
|
+
__publicField(SimpleStakeEventsViewer, "surface", "node");
|
|
6565
6668
|
SimpleStakeEventsViewer = __decorateClass([
|
|
6566
6669
|
creatableProvider()
|
|
6567
6670
|
], SimpleStakeEventsViewer);
|
|
@@ -6657,9 +6760,11 @@ var SimpleStakeTotalsViewer = class extends AbstractCreatableProvider {
|
|
|
6657
6760
|
return withdrawn;
|
|
6658
6761
|
}
|
|
6659
6762
|
};
|
|
6763
|
+
__publicField(SimpleStakeTotalsViewer, "connectionTypes", ["lmdb", "mongo"]);
|
|
6660
6764
|
__publicField(SimpleStakeTotalsViewer, "defaultMoniker", StakeTotalsViewerMoniker);
|
|
6661
6765
|
__publicField(SimpleStakeTotalsViewer, "dependencies", [StakeTotalsViewerMoniker]);
|
|
6662
6766
|
__publicField(SimpleStakeTotalsViewer, "monikers", [StakeTotalsViewerMoniker]);
|
|
6767
|
+
__publicField(SimpleStakeTotalsViewer, "surface", "node");
|
|
6663
6768
|
SimpleStakeTotalsViewer = __decorateClass([
|
|
6664
6769
|
creatableProvider()
|
|
6665
6770
|
], SimpleStakeTotalsViewer);
|
|
@@ -6787,9 +6892,11 @@ var SimpleStakeViewer = class extends AbstractCreatableProvider {
|
|
|
6787
6892
|
return this.positions.filter((s) => s.withdrawBlock !== 0);
|
|
6788
6893
|
}
|
|
6789
6894
|
};
|
|
6895
|
+
__publicField(SimpleStakeViewer, "connectionTypes", ["lmdb", "mongo"]);
|
|
6790
6896
|
__publicField(SimpleStakeViewer, "defaultMoniker", StakeViewerMoniker2);
|
|
6791
6897
|
__publicField(SimpleStakeViewer, "dependencies", [StakeEventsViewerMoniker2]);
|
|
6792
6898
|
__publicField(SimpleStakeViewer, "monikers", [StakeViewerMoniker2]);
|
|
6899
|
+
__publicField(SimpleStakeViewer, "surface", "node");
|
|
6793
6900
|
SimpleStakeViewer = __decorateClass([
|
|
6794
6901
|
creatableProvider()
|
|
6795
6902
|
], SimpleStakeViewer);
|
|
@@ -6957,9 +7064,11 @@ var SimpleTimeSyncViewer = class extends AbstractCreatableProvider {
|
|
|
6957
7064
|
return timePayload;
|
|
6958
7065
|
}
|
|
6959
7066
|
};
|
|
7067
|
+
__publicField(SimpleTimeSyncViewer, "connectionTypes", ["lmdb", "mongo"]);
|
|
6960
7068
|
__publicField(SimpleTimeSyncViewer, "defaultMoniker", TimeSyncViewerMoniker);
|
|
6961
7069
|
__publicField(SimpleTimeSyncViewer, "dependencies", [BlockViewerMoniker4]);
|
|
6962
7070
|
__publicField(SimpleTimeSyncViewer, "monikers", [TimeSyncViewerMoniker]);
|
|
7071
|
+
__publicField(SimpleTimeSyncViewer, "surface", "node");
|
|
6963
7072
|
SimpleTimeSyncViewer = __decorateClass([
|
|
6964
7073
|
creatableProvider()
|
|
6965
7074
|
], SimpleTimeSyncViewer);
|
|
@@ -7081,9 +7190,11 @@ var SimpleTransactionValidationViewer = class extends AbstractCreatableProvider
|
|
|
7081
7190
|
}));
|
|
7082
7191
|
}
|
|
7083
7192
|
};
|
|
7193
|
+
__publicField(SimpleTransactionValidationViewer, "connectionTypes", ["lmdb", "mongo", "rpc"]);
|
|
7084
7194
|
__publicField(SimpleTransactionValidationViewer, "defaultMoniker", TransactionValidationViewerMoniker2);
|
|
7085
7195
|
__publicField(SimpleTransactionValidationViewer, "dependencies", [AccountBalanceViewerMoniker3, ChainContractViewerMoniker5, BlockViewerMoniker5]);
|
|
7086
7196
|
__publicField(SimpleTransactionValidationViewer, "monikers", [TransactionValidationViewerMoniker2]);
|
|
7197
|
+
__publicField(SimpleTransactionValidationViewer, "surface", "node");
|
|
7087
7198
|
SimpleTransactionValidationViewer = __decorateClass([
|
|
7088
7199
|
creatableProvider()
|
|
7089
7200
|
], SimpleTransactionValidationViewer);
|
|
@@ -7161,6 +7272,7 @@ var SimpleTransactionViewer = class extends AbstractCreatableProvider {
|
|
|
7161
7272
|
return await this.byHash(transactionHash);
|
|
7162
7273
|
}
|
|
7163
7274
|
};
|
|
7275
|
+
__publicField(SimpleTransactionViewer, "connectionTypes", ["lmdb", "mongo"]);
|
|
7164
7276
|
__publicField(SimpleTransactionViewer, "defaultMoniker", TransactionViewerMoniker);
|
|
7165
7277
|
__publicField(SimpleTransactionViewer, "dependencies", [BlockViewerMoniker6]);
|
|
7166
7278
|
__publicField(SimpleTransactionViewer, "monikers", [TransactionViewerMoniker]);
|
|
@@ -7337,9 +7449,11 @@ var SimpleWindowedBlockViewer = class extends AbstractCreatableProvider {
|
|
|
7337
7449
|
});
|
|
7338
7450
|
}
|
|
7339
7451
|
};
|
|
7452
|
+
__publicField(SimpleWindowedBlockViewer, "connectionTypes", ["lmdb", "mongo", "rpc"]);
|
|
7340
7453
|
__publicField(SimpleWindowedBlockViewer, "defaultMoniker", WindowedBlockViewerMoniker2);
|
|
7341
7454
|
__publicField(SimpleWindowedBlockViewer, "dependencies", [BlockViewerMoniker7]);
|
|
7342
7455
|
__publicField(SimpleWindowedBlockViewer, "monikers", [WindowedBlockViewerMoniker2]);
|
|
7456
|
+
__publicField(SimpleWindowedBlockViewer, "surface", "node");
|
|
7343
7457
|
SimpleWindowedBlockViewer = __decorateClass([
|
|
7344
7458
|
creatableProvider()
|
|
7345
7459
|
], SimpleWindowedBlockViewer);
|
|
@@ -8110,9 +8224,12 @@ export {
|
|
|
8110
8224
|
isZodError,
|
|
8111
8225
|
labeledCreatableProvider,
|
|
8112
8226
|
labeledCreatableProviderFactory,
|
|
8227
|
+
locatorFromConfig,
|
|
8113
8228
|
mapToMapType,
|
|
8114
8229
|
mergeTransfers,
|
|
8115
8230
|
mergedAddRemoveStakeEventsByPosition,
|
|
8231
|
+
needsFromConnectionTypes,
|
|
8232
|
+
needsFromProviderBindings,
|
|
8116
8233
|
netBalancesForPayloads,
|
|
8117
8234
|
netSchemasForPayloads,
|
|
8118
8235
|
netTransfersForPayloads,
|
|
@@ -8122,13 +8239,17 @@ export {
|
|
|
8122
8239
|
parseSignedBigInt,
|
|
8123
8240
|
payloadMapFromStore,
|
|
8124
8241
|
prettifyZodError,
|
|
8242
|
+
providerCandidateFromClass,
|
|
8243
|
+
providerCandidatesFromClasses,
|
|
8125
8244
|
providerFactoryDescription,
|
|
8126
8245
|
rateMultipliers,
|
|
8127
8246
|
readPayloadMapFromStore,
|
|
8128
8247
|
registerCreatableProviderFactories,
|
|
8129
8248
|
registerCreatableProviderFactory,
|
|
8249
|
+
registerFactoriesFromPlan,
|
|
8130
8250
|
resolveConfig,
|
|
8131
8251
|
resolveProviders,
|
|
8252
|
+
resolveProvidersFromConfig,
|
|
8132
8253
|
resolveS3Bucket,
|
|
8133
8254
|
rewardFromBlockNumber,
|
|
8134
8255
|
schemasMaxStep,
|