@xyo-network/xl1-protocol-sdk 3.0.3 → 3.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/neutral/Archivists/ArchivistConnectOptions.d.ts +8 -0
- package/dist/neutral/Archivists/ArchivistConnectOptions.d.ts.map +1 -0
- package/dist/neutral/Archivists/ArchivistFactory.d.ts +31 -0
- package/dist/neutral/Archivists/ArchivistFactory.d.ts.map +1 -0
- package/dist/neutral/Archivists/MemoryArchivistFactory.d.ts +16 -0
- package/dist/neutral/Archivists/MemoryArchivistFactory.d.ts.map +1 -0
- package/dist/neutral/Archivists/archivistRoles.d.ts +12 -0
- package/dist/neutral/Archivists/archivistRoles.d.ts.map +1 -0
- package/dist/neutral/Archivists/connectArchivist.d.ts +11 -0
- package/dist/neutral/Archivists/connectArchivist.d.ts.map +1 -0
- package/dist/neutral/Archivists/index.d.ts +6 -0
- package/dist/neutral/Archivists/index.d.ts.map +1 -0
- package/dist/neutral/CreatableProvider/AbstractCreatableProvider.d.ts +4 -0
- package/dist/neutral/CreatableProvider/AbstractCreatableProvider.d.ts.map +1 -1
- package/dist/neutral/config/Actor.d.ts +24 -0
- package/dist/neutral/config/Actor.d.ts.map +1 -1
- package/dist/neutral/config/Actors.d.ts +4 -0
- package/dist/neutral/config/Actors.d.ts.map +1 -1
- package/dist/neutral/config/Base.d.ts +4 -0
- package/dist/neutral/config/Base.d.ts.map +1 -1
- package/dist/neutral/config/Config.d.ts +16 -0
- package/dist/neutral/config/Config.d.ts.map +1 -1
- package/dist/neutral/config/HostActor.d.ts +24 -0
- package/dist/neutral/config/HostActor.d.ts.map +1 -1
- package/dist/neutral/config/transports/Transport.d.ts +9 -0
- package/dist/neutral/config/transports/Transport.d.ts.map +1 -1
- package/dist/neutral/context/Actor.d.ts +24 -0
- package/dist/neutral/context/Actor.d.ts.map +1 -1
- package/dist/neutral/context/HostActor.d.ts +24 -0
- package/dist/neutral/context/HostActor.d.ts.map +1 -1
- package/dist/neutral/getFileConfig.d.ts +8 -0
- package/dist/neutral/getFileConfig.d.ts.map +1 -1
- package/dist/neutral/getFileConfig.mjs +3 -1
- package/dist/neutral/getFileConfig.mjs.map +2 -2
- package/dist/neutral/index.d.ts +1 -0
- package/dist/neutral/index.d.ts.map +1 -1
- package/dist/neutral/index.mjs +195 -84
- package/dist/neutral/index.mjs.map +4 -4
- package/dist/neutral/model/CreatableProviderContext.zod.d.ts +24 -0
- package/dist/neutral/model/CreatableProviderContext.zod.d.ts.map +1 -1
- package/dist/neutral/simple/StakeTotalsViewer/SimpleStakeTotalsViewer.d.ts +1 -1
- package/dist/neutral/simple/StakeTotalsViewer/SimpleStakeTotalsViewer.d.ts.map +1 -1
- package/dist/neutral/simple/StakeViewer/SimpleStakeViewer.d.ts +1 -1
- package/dist/neutral/simple/StakeViewer/SimpleStakeViewer.d.ts.map +1 -1
- package/dist/neutral/simple/TransactionViewer/SimpleTransactionViewer.d.ts +1 -1
- package/dist/neutral/simple/TransactionViewer/SimpleTransactionViewer.d.ts.map +1 -1
- package/dist/neutral/simple/accountBalance/SimpleAccountBalanceViewer.d.ts +1 -1
- package/dist/neutral/simple/accountBalance/SimpleAccountBalanceViewer.d.ts.map +1 -1
- package/dist/neutral/simple/block/SimpleBlockViewer.d.ts +5 -2
- package/dist/neutral/simple/block/SimpleBlockViewer.d.ts.map +1 -1
- package/dist/neutral/simple/blockInvalidation/SimpleBlockInvalidationViewer.d.ts +1 -1
- package/dist/neutral/simple/blockInvalidation/SimpleBlockInvalidationViewer.d.ts.map +1 -1
- package/dist/neutral/simple/blockReward/SimpleBlockRewardViewer.d.ts +1 -1
- package/dist/neutral/simple/blockReward/SimpleBlockRewardViewer.d.ts.map +1 -1
- package/dist/neutral/simple/blockValidation/SimpleBlockValidationViewer.d.ts +1 -1
- package/dist/neutral/simple/blockValidation/SimpleBlockValidationViewer.d.ts.map +1 -1
- package/dist/neutral/simple/chainContractViewer/SimpleChainContractViewer.d.ts +1 -1
- package/dist/neutral/simple/chainContractViewer/SimpleChainContractViewer.d.ts.map +1 -1
- package/dist/neutral/simple/finalization/SimpleFinalizationRunner.d.ts +7 -2
- package/dist/neutral/simple/finalization/SimpleFinalizationRunner.d.ts.map +1 -1
- package/dist/neutral/simple/finalization/SimpleFinalizationViewer.d.ts +6 -3
- package/dist/neutral/simple/finalization/SimpleFinalizationViewer.d.ts.map +1 -1
- package/dist/neutral/simple/mempool/SimpleMempoolRunner.d.ts +9 -6
- package/dist/neutral/simple/mempool/SimpleMempoolRunner.d.ts.map +1 -1
- package/dist/neutral/simple/mempool/SimpleMempoolViewer.d.ts +9 -5
- package/dist/neutral/simple/mempool/SimpleMempoolViewer.d.ts.map +1 -1
- package/dist/neutral/simple/runner/SimpleXyoRunner.d.ts +1 -1
- package/dist/neutral/simple/runner/SimpleXyoRunner.d.ts.map +1 -1
- package/dist/neutral/simple/timeSync2/SimpleTimeSyncViewer.d.ts +1 -1
- package/dist/neutral/simple/timeSync2/SimpleTimeSyncViewer.d.ts.map +1 -1
- package/dist/neutral/simple/transactionValidation/SimpleTransactionValidationViewer.d.ts +1 -1
- package/dist/neutral/simple/transactionValidation/SimpleTransactionValidationViewer.d.ts.map +1 -1
- package/dist/neutral/simple/windowedBlock/SimpleWindowedBlockViewer.d.ts +1 -1
- package/dist/neutral/simple/windowedBlock/SimpleWindowedBlockViewer.d.ts.map +1 -1
- package/dist/neutral/test/index.mjs +82 -11
- package/dist/neutral/test/index.mjs.map +4 -4
- package/package.json +6 -6
package/dist/neutral/index.mjs
CHANGED
|
@@ -187,6 +187,74 @@ var XL1Amount = class _XL1Amount {
|
|
|
187
187
|
}
|
|
188
188
|
};
|
|
189
189
|
|
|
190
|
+
// src/Archivists/ArchivistFactory.ts
|
|
191
|
+
import { Mutex } from "async-mutex";
|
|
192
|
+
var KEY_SEPARATOR = "::";
|
|
193
|
+
function archivistCacheKey(connectionName, archivistName) {
|
|
194
|
+
return `${connectionName}${KEY_SEPARATOR}${archivistName}`;
|
|
195
|
+
}
|
|
196
|
+
var ArchivistInstanceCache = class {
|
|
197
|
+
cache = /* @__PURE__ */ new Map();
|
|
198
|
+
mutex = new Mutex();
|
|
199
|
+
async clear() {
|
|
200
|
+
await this.mutex.runExclusive(() => {
|
|
201
|
+
this.cache.clear();
|
|
202
|
+
});
|
|
203
|
+
}
|
|
204
|
+
async getOrCreate(connectionName, archivistName, create) {
|
|
205
|
+
const key = archivistCacheKey(connectionName, archivistName);
|
|
206
|
+
return await this.mutex.runExclusive(async () => {
|
|
207
|
+
const existing = this.cache.get(key);
|
|
208
|
+
if (existing !== void 0) return existing;
|
|
209
|
+
const created = await create();
|
|
210
|
+
this.cache.set(key, created);
|
|
211
|
+
return created;
|
|
212
|
+
});
|
|
213
|
+
}
|
|
214
|
+
has(connectionName, archivistName) {
|
|
215
|
+
return this.cache.has(archivistCacheKey(connectionName, archivistName));
|
|
216
|
+
}
|
|
217
|
+
};
|
|
218
|
+
|
|
219
|
+
// src/Archivists/archivistRoles.ts
|
|
220
|
+
var CHAIN_ARCHIVIST_ROLE = "chain";
|
|
221
|
+
var PENDING_TRANSACTIONS_ARCHIVIST_ROLE = "pending-transactions";
|
|
222
|
+
var PENDING_BLOCKS_ARCHIVIST_ROLE = "pending-blocks";
|
|
223
|
+
var REJECTED_BLOCKS_ARCHIVIST_ROLE = "rejected-blocks";
|
|
224
|
+
var REJECTED_TRANSACTIONS_ARCHIVIST_ROLE = "rejected-transactions";
|
|
225
|
+
|
|
226
|
+
// src/Archivists/MemoryArchivistFactory.ts
|
|
227
|
+
import { MemoryArchivist } from "@xyo-network/sdk-js";
|
|
228
|
+
var MemoryArchivistFactory = class _MemoryArchivistFactory {
|
|
229
|
+
static cache = new ArchivistInstanceCache();
|
|
230
|
+
static async connect(connectionName, _config, options) {
|
|
231
|
+
const { name, max } = options;
|
|
232
|
+
return await _MemoryArchivistFactory.cache.getOrCreate(
|
|
233
|
+
connectionName,
|
|
234
|
+
name,
|
|
235
|
+
// Omit `max` when unset so the chain store inherits MemoryArchivist's default
|
|
236
|
+
// (the node-backed memory fallback never capped it — a small cap would evict blocks).
|
|
237
|
+
async () => await MemoryArchivist.create({ account: "random", config: max === void 0 ? { name } : { max, name } })
|
|
238
|
+
);
|
|
239
|
+
}
|
|
240
|
+
/** Test-only: drop all cached memory archivists so a fresh process state can be simulated. */
|
|
241
|
+
static async reset() {
|
|
242
|
+
await _MemoryArchivistFactory.cache.clear();
|
|
243
|
+
}
|
|
244
|
+
};
|
|
245
|
+
|
|
246
|
+
// src/Archivists/connectArchivist.ts
|
|
247
|
+
async function connectArchivist(binding, options) {
|
|
248
|
+
switch (binding.config.type) {
|
|
249
|
+
case "memory": {
|
|
250
|
+
return await MemoryArchivistFactory.connect(binding.name, binding.config, options);
|
|
251
|
+
}
|
|
252
|
+
default: {
|
|
253
|
+
throw new Error(`connectArchivist: connection type '${binding.config.type}' is not self-provisioned \u2014 inject the archivist instead`);
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
|
|
190
258
|
// src/block/hydrate/allHashesPresent.ts
|
|
191
259
|
function allHashesPresent(hashes, payloads) {
|
|
192
260
|
const payloadHashes = new Set(payloads.map((p) => p._hash));
|
|
@@ -1822,13 +1890,15 @@ var EvmRpcTransportConfigZod = z6.object({
|
|
|
1822
1890
|
type: "string"
|
|
1823
1891
|
})
|
|
1824
1892
|
}).describe("EVM JSON-RPC transport");
|
|
1893
|
+
var MemoryTransportConfigZod = z6.object({ type: z6.literal("memory") }).describe("In-process memory transport");
|
|
1825
1894
|
var TransportConfigZod = z6.discriminatedUnion("type", [
|
|
1826
1895
|
LmdbTransportConfigZod,
|
|
1827
1896
|
MongoTransportConfigZod,
|
|
1828
1897
|
RpcTransportConfigZod,
|
|
1829
1898
|
RestTransportConfigZod,
|
|
1830
1899
|
S3TransportConfigZod,
|
|
1831
|
-
EvmRpcTransportConfigZod
|
|
1900
|
+
EvmRpcTransportConfigZod,
|
|
1901
|
+
MemoryTransportConfigZod
|
|
1832
1902
|
]);
|
|
1833
1903
|
var TransportsConfigZod = z6.record(z6.string(), TransportConfigZod).default({});
|
|
1834
1904
|
|
|
@@ -4708,7 +4778,7 @@ var SimpleAccountBalanceViewer = class extends AbstractCreatableProvider {
|
|
|
4708
4778
|
}, this.context);
|
|
4709
4779
|
}
|
|
4710
4780
|
};
|
|
4711
|
-
__publicField(SimpleAccountBalanceViewer, "connectionTypes", ["lmdb", "mongo"]);
|
|
4781
|
+
__publicField(SimpleAccountBalanceViewer, "connectionTypes", ["lmdb", "mongo", "memory"]);
|
|
4712
4782
|
__publicField(SimpleAccountBalanceViewer, "defaultMoniker", AccountBalanceViewerMoniker);
|
|
4713
4783
|
__publicField(SimpleAccountBalanceViewer, "dependencies", [BlockViewerMoniker]);
|
|
4714
4784
|
__publicField(SimpleAccountBalanceViewer, "monikers", [AccountBalanceViewerMoniker]);
|
|
@@ -4783,7 +4853,7 @@ var SimpleBlockViewer = class extends AbstractCreatableProvider {
|
|
|
4783
4853
|
_headPollTimer = null;
|
|
4784
4854
|
_signedHydratedBlockCache;
|
|
4785
4855
|
get finalizedArchivist() {
|
|
4786
|
-
return this.params.finalizedArchivist;
|
|
4856
|
+
return assertEx34(this.params.finalizedArchivist, () => "finalizedArchivist is required \u2014 inject it or bind a connection");
|
|
4787
4857
|
}
|
|
4788
4858
|
get blocksSummaryMap() {
|
|
4789
4859
|
this._blocksSummaryMap ??= this.params.blocksSummaryMap ?? new LruCacheMap2({ max: 32 });
|
|
@@ -4809,10 +4879,12 @@ var SimpleBlockViewer = class extends AbstractCreatableProvider {
|
|
|
4809
4879
|
if (headPollIntervalMs !== void 0) {
|
|
4810
4880
|
assertEx34(headPollIntervalMs >= MIN_HEAD_POLL_INTERVAL_MS, () => `headPollIntervalMs must be at least ${MIN_HEAD_POLL_INTERVAL_MS}ms`);
|
|
4811
4881
|
}
|
|
4882
|
+
const connection = params.connection;
|
|
4883
|
+
const finalizedArchivist = params.finalizedArchivist ?? (connection ? await connectArchivist(connection, { name: CHAIN_ARCHIVIST_ROLE }) : void 0);
|
|
4812
4884
|
return {
|
|
4813
4885
|
...await super.paramsHandler(params),
|
|
4814
4886
|
blocksSummaryMap: params.blocksSummaryMap,
|
|
4815
|
-
finalizedArchivist: assertEx34(
|
|
4887
|
+
finalizedArchivist: assertEx34(finalizedArchivist, () => "finalizedArchivist is required \u2014 inject it or bind a connection"),
|
|
4816
4888
|
headPollIntervalMs
|
|
4817
4889
|
};
|
|
4818
4890
|
}
|
|
@@ -4910,7 +4982,7 @@ var SimpleBlockViewer = class extends AbstractCreatableProvider {
|
|
|
4910
4982
|
async createHandler() {
|
|
4911
4983
|
await super.createHandler();
|
|
4912
4984
|
this.finalizationViewer = await this.locator.getInstance(FinalizationViewerMoniker);
|
|
4913
|
-
this._store = { chainMap: this.
|
|
4985
|
+
this._store = { chainMap: this.finalizedArchivist };
|
|
4914
4986
|
}
|
|
4915
4987
|
async currentBlock() {
|
|
4916
4988
|
return await this.finalizationViewer.head();
|
|
@@ -5010,7 +5082,7 @@ var SimpleBlockViewer = class extends AbstractCreatableProvider {
|
|
|
5010
5082
|
this._headPollTimer = null;
|
|
5011
5083
|
}
|
|
5012
5084
|
};
|
|
5013
|
-
__publicField(SimpleBlockViewer, "connectionTypes", ["lmdb", "mongo"]);
|
|
5085
|
+
__publicField(SimpleBlockViewer, "connectionTypes", ["lmdb", "mongo", "memory"]);
|
|
5014
5086
|
__publicField(SimpleBlockViewer, "defaultMoniker", BlockViewerMoniker2);
|
|
5015
5087
|
__publicField(SimpleBlockViewer, "dependencies", [FinalizationViewerMoniker]);
|
|
5016
5088
|
__publicField(SimpleBlockViewer, "monikers", [BlockViewerMoniker2]);
|
|
@@ -5029,7 +5101,7 @@ var SimpleBlockRewardViewer = class extends AbstractCreatableProvider {
|
|
|
5029
5101
|
);
|
|
5030
5102
|
}
|
|
5031
5103
|
};
|
|
5032
|
-
__publicField(SimpleBlockRewardViewer, "connectionTypes", ["lmdb", "mongo", "rpc"]);
|
|
5104
|
+
__publicField(SimpleBlockRewardViewer, "connectionTypes", ["lmdb", "mongo", "memory", "rpc"]);
|
|
5033
5105
|
__publicField(SimpleBlockRewardViewer, "defaultMoniker", BlockRewardViewerMoniker);
|
|
5034
5106
|
__publicField(SimpleBlockRewardViewer, "dependencies", []);
|
|
5035
5107
|
__publicField(SimpleBlockRewardViewer, "monikers", [BlockRewardViewerMoniker]);
|
|
@@ -5173,7 +5245,7 @@ var SimpleBlockValidationViewer = class extends AbstractCreatableProvider {
|
|
|
5173
5245
|
return [...this._uncleWindowedChainCache];
|
|
5174
5246
|
}
|
|
5175
5247
|
};
|
|
5176
|
-
__publicField(SimpleBlockValidationViewer, "connectionTypes", ["lmdb", "mongo", "rpc"]);
|
|
5248
|
+
__publicField(SimpleBlockValidationViewer, "connectionTypes", ["lmdb", "mongo", "memory", "rpc"]);
|
|
5177
5249
|
__publicField(SimpleBlockValidationViewer, "defaultMoniker", BlockValidationViewerMoniker);
|
|
5178
5250
|
__publicField(SimpleBlockValidationViewer, "dependencies", [AccountBalanceViewerMoniker2, BlockViewerMoniker3, ChainContractViewerMoniker]);
|
|
5179
5251
|
__publicField(SimpleBlockValidationViewer, "monikers", [BlockValidationViewerMoniker]);
|
|
@@ -5233,7 +5305,7 @@ var SimpleChainContractViewer = class extends AbstractCreatableProvider {
|
|
|
5233
5305
|
return this.params.stakingTokenAddress;
|
|
5234
5306
|
}
|
|
5235
5307
|
};
|
|
5236
|
-
__publicField(SimpleChainContractViewer, "connectionTypes", ["lmdb", "mongo"]);
|
|
5308
|
+
__publicField(SimpleChainContractViewer, "connectionTypes", ["lmdb", "mongo", "memory"]);
|
|
5237
5309
|
__publicField(SimpleChainContractViewer, "defaultMoniker", ChainContractViewerMoniker2);
|
|
5238
5310
|
__publicField(SimpleChainContractViewer, "dependencies", [FinalizationViewerMoniker2]);
|
|
5239
5311
|
__publicField(SimpleChainContractViewer, "monikers", [ChainContractViewerMoniker2]);
|
|
@@ -5449,16 +5521,28 @@ SimpleDataLakeViewer = __decorateClass([
|
|
|
5449
5521
|
], SimpleDataLakeViewer);
|
|
5450
5522
|
|
|
5451
5523
|
// src/simple/finalization/SimpleFinalizationRunner.ts
|
|
5524
|
+
import { assertEx as assertEx38 } from "@xylabs/sdk-js";
|
|
5452
5525
|
import { FinalizationRunnerMoniker } from "@xyo-network/xl1-protocol-lib";
|
|
5453
5526
|
var SimpleFinalizationRunner = class extends AbstractCreatableProvider {
|
|
5454
5527
|
moniker = SimpleFinalizationRunner.defaultMoniker;
|
|
5455
5528
|
_store;
|
|
5529
|
+
get finalizedArchivist() {
|
|
5530
|
+
return assertEx38(this.params.finalizedArchivist, () => "finalizedArchivist is required \u2014 inject it or bind a connection");
|
|
5531
|
+
}
|
|
5456
5532
|
get store() {
|
|
5457
5533
|
return this._store;
|
|
5458
5534
|
}
|
|
5535
|
+
static async paramsHandler(params) {
|
|
5536
|
+
const connection = params?.connection;
|
|
5537
|
+
const finalizedArchivist = params?.finalizedArchivist ?? (connection ? await connectArchivist(connection, { name: CHAIN_ARCHIVIST_ROLE }) : void 0);
|
|
5538
|
+
return {
|
|
5539
|
+
...await super.paramsHandler(params),
|
|
5540
|
+
finalizedArchivist: assertEx38(finalizedArchivist, () => "finalizedArchivist is required \u2014 inject it or bind a connection")
|
|
5541
|
+
};
|
|
5542
|
+
}
|
|
5459
5543
|
async createHandler() {
|
|
5460
5544
|
await super.createHandler();
|
|
5461
|
-
this._store = { chainMap: this.
|
|
5545
|
+
this._store = { chainMap: this.finalizedArchivist };
|
|
5462
5546
|
}
|
|
5463
5547
|
async finalizeBlock(block) {
|
|
5464
5548
|
const results = await this.finalizeBlocks([block]);
|
|
@@ -5471,7 +5555,7 @@ var SimpleFinalizationRunner = class extends AbstractCreatableProvider {
|
|
|
5471
5555
|
return sortedBlocks.map((b) => b[0]._hash);
|
|
5472
5556
|
}
|
|
5473
5557
|
};
|
|
5474
|
-
__publicField(SimpleFinalizationRunner, "connectionTypes", ["lmdb", "mongo"]);
|
|
5558
|
+
__publicField(SimpleFinalizationRunner, "connectionTypes", ["lmdb", "mongo", "memory"]);
|
|
5475
5559
|
__publicField(SimpleFinalizationRunner, "defaultMoniker", FinalizationRunnerMoniker);
|
|
5476
5560
|
__publicField(SimpleFinalizationRunner, "dependencies", []);
|
|
5477
5561
|
__publicField(SimpleFinalizationRunner, "monikers", [FinalizationRunnerMoniker]);
|
|
@@ -5481,7 +5565,7 @@ SimpleFinalizationRunner = __decorateClass([
|
|
|
5481
5565
|
], SimpleFinalizationRunner);
|
|
5482
5566
|
|
|
5483
5567
|
// src/simple/finalization/SimpleFinalizationViewer.ts
|
|
5484
|
-
import { assertEx as
|
|
5568
|
+
import { assertEx as assertEx39 } from "@xylabs/sdk-js";
|
|
5485
5569
|
import {
|
|
5486
5570
|
asSignedHydratedBlockWithStorageMeta as asSignedHydratedBlockWithStorageMeta2,
|
|
5487
5571
|
ChainContractViewerMoniker as ChainContractViewerMoniker3,
|
|
@@ -5493,7 +5577,7 @@ var SimpleFinalizationViewer = class extends AbstractCreatableProvider {
|
|
|
5493
5577
|
_store;
|
|
5494
5578
|
_signedHydratedBlockCache;
|
|
5495
5579
|
get finalizedArchivist() {
|
|
5496
|
-
return this.params.finalizedArchivist;
|
|
5580
|
+
return assertEx39(this.params.finalizedArchivist, () => "finalizedArchivist is required \u2014 inject it or bind a connection");
|
|
5497
5581
|
}
|
|
5498
5582
|
get hydratedBlockCache() {
|
|
5499
5583
|
if (this._signedHydratedBlockCache) return this._signedHydratedBlockCache;
|
|
@@ -5508,9 +5592,11 @@ var SimpleFinalizationViewer = class extends AbstractCreatableProvider {
|
|
|
5508
5592
|
return this._store;
|
|
5509
5593
|
}
|
|
5510
5594
|
static async paramsHandler(params) {
|
|
5595
|
+
const connection = params.connection;
|
|
5596
|
+
const finalizedArchivist = params.finalizedArchivist ?? (connection ? await connectArchivist(connection, { name: CHAIN_ARCHIVIST_ROLE }) : void 0);
|
|
5511
5597
|
return {
|
|
5512
5598
|
...await super.paramsHandler(params),
|
|
5513
|
-
finalizedArchivist:
|
|
5599
|
+
finalizedArchivist: assertEx39(finalizedArchivist, () => "finalizedArchivist is required \u2014 inject it or bind a connection")
|
|
5514
5600
|
};
|
|
5515
5601
|
}
|
|
5516
5602
|
chainId() {
|
|
@@ -5518,19 +5604,20 @@ var SimpleFinalizationViewer = class extends AbstractCreatableProvider {
|
|
|
5518
5604
|
}
|
|
5519
5605
|
async createHandler() {
|
|
5520
5606
|
await super.createHandler();
|
|
5521
|
-
const
|
|
5522
|
-
|
|
5523
|
-
this.
|
|
5607
|
+
const finalizedArchivist = this.finalizedArchivist;
|
|
5608
|
+
const mostRecentBlock = await findMostRecentBlock(finalizedArchivist);
|
|
5609
|
+
this._chainId = assertEx39(this.config.chain.id ?? mostRecentBlock?.chain, () => "chain.id is required if empty archivist");
|
|
5610
|
+
this._store = { chainMap: finalizedArchivist };
|
|
5524
5611
|
}
|
|
5525
5612
|
async head() {
|
|
5526
5613
|
return await this.spanAsync("head", async () => {
|
|
5527
|
-
const currentHead =
|
|
5614
|
+
const currentHead = assertEx39(await this.getCurrentHead(), () => "Could not find most recent block [currentBlock]");
|
|
5528
5615
|
const cache = this.hydratedBlockCache;
|
|
5529
5616
|
const block = await cache.get(currentHead._hash);
|
|
5530
5617
|
if (!block) {
|
|
5531
5618
|
this.logger?.error(`Could not find current block with hash ${currentHead._hash}`);
|
|
5532
5619
|
}
|
|
5533
|
-
return
|
|
5620
|
+
return assertEx39(block, () => "Could not find current block");
|
|
5534
5621
|
}, this.context);
|
|
5535
5622
|
}
|
|
5536
5623
|
async headBlock() {
|
|
@@ -5560,12 +5647,12 @@ var SimpleFinalizationViewer = class extends AbstractCreatableProvider {
|
|
|
5560
5647
|
}
|
|
5561
5648
|
async getCurrentHead() {
|
|
5562
5649
|
const chainArchivist = this.finalizedArchivist;
|
|
5563
|
-
const result =
|
|
5564
|
-
|
|
5650
|
+
const result = assertEx39(await findMostRecentBlock(chainArchivist), () => "Could not find most recent block [getCurrentHead]");
|
|
5651
|
+
assertEx39(result?.chain === this._chainId, () => "Chain ID does not match head block chain ID");
|
|
5565
5652
|
return result;
|
|
5566
5653
|
}
|
|
5567
5654
|
};
|
|
5568
|
-
__publicField(SimpleFinalizationViewer, "connectionTypes", ["lmdb", "mongo"]);
|
|
5655
|
+
__publicField(SimpleFinalizationViewer, "connectionTypes", ["lmdb", "mongo", "memory"]);
|
|
5569
5656
|
__publicField(SimpleFinalizationViewer, "defaultMoniker", FinalizationViewerMoniker3);
|
|
5570
5657
|
__publicField(SimpleFinalizationViewer, "dependencies", [ChainContractViewerMoniker3]);
|
|
5571
5658
|
__publicField(SimpleFinalizationViewer, "monikers", [FinalizationViewerMoniker3]);
|
|
@@ -5593,7 +5680,7 @@ var SimpleXyoGateway = class _SimpleXyoGateway extends AbstractCreatableProvider
|
|
|
5593
5680
|
|
|
5594
5681
|
// src/simple/gateway/SimpleXyoGatewayRunner.ts
|
|
5595
5682
|
import {
|
|
5596
|
-
assertEx as
|
|
5683
|
+
assertEx as assertEx40,
|
|
5597
5684
|
BigIntToJsonZod,
|
|
5598
5685
|
isDefined as isDefined20
|
|
5599
5686
|
} from "@xylabs/sdk-js";
|
|
@@ -5626,7 +5713,7 @@ var SimpleXyoGatewayRunner = class _SimpleXyoGatewayRunner extends AbstractCreat
|
|
|
5626
5713
|
return this._signer;
|
|
5627
5714
|
}
|
|
5628
5715
|
async addPayloadsToChain(onChain, offChain, options) {
|
|
5629
|
-
const viewer =
|
|
5716
|
+
const viewer = assertEx40(this.connection.viewer, () => "No viewer available on connection");
|
|
5630
5717
|
const {
|
|
5631
5718
|
nbf,
|
|
5632
5719
|
exp,
|
|
@@ -5642,7 +5729,7 @@ var SimpleXyoGatewayRunner = class _SimpleXyoGatewayRunner extends AbstractCreat
|
|
|
5642
5729
|
async addTransactionToChain(tx, offChain = []) {
|
|
5643
5730
|
const connection = this.connection;
|
|
5644
5731
|
const signer = this.signer;
|
|
5645
|
-
const runner =
|
|
5732
|
+
const runner = assertEx40(connection.runner, () => "No runner available on connection");
|
|
5646
5733
|
let signedTx;
|
|
5647
5734
|
if (isSignedHydratedTransaction(tx)) {
|
|
5648
5735
|
const [bw, payloads] = tx;
|
|
@@ -5657,7 +5744,7 @@ var SimpleXyoGatewayRunner = class _SimpleXyoGatewayRunner extends AbstractCreat
|
|
|
5657
5744
|
}
|
|
5658
5745
|
async confirmSubmittedTransaction(txHash, options) {
|
|
5659
5746
|
return await confirmSubmittedTransaction(
|
|
5660
|
-
|
|
5747
|
+
assertEx40(this.connection.viewer, () => "Connection viewer is undefined"),
|
|
5661
5748
|
txHash,
|
|
5662
5749
|
options
|
|
5663
5750
|
);
|
|
@@ -5696,7 +5783,7 @@ var SimpleXyoGatewayRunner = class _SimpleXyoGatewayRunner extends AbstractCreat
|
|
|
5696
5783
|
|
|
5697
5784
|
// src/simple/mempool/SimpleMempoolRunner.ts
|
|
5698
5785
|
import {
|
|
5699
|
-
assertEx as
|
|
5786
|
+
assertEx as assertEx41,
|
|
5700
5787
|
exists as exists8
|
|
5701
5788
|
} from "@xylabs/sdk-js";
|
|
5702
5789
|
import { isPayloadBundle, PayloadBuilder as PayloadBuilder21 } from "@xyo-network/sdk-js";
|
|
@@ -5714,7 +5801,7 @@ import {
|
|
|
5714
5801
|
TransactionRejectionSchema,
|
|
5715
5802
|
TransactionValidationViewerMoniker
|
|
5716
5803
|
} from "@xyo-network/xl1-protocol-lib";
|
|
5717
|
-
import { Mutex } from "async-mutex";
|
|
5804
|
+
import { Mutex as Mutex2 } from "async-mutex";
|
|
5718
5805
|
var DEFAULT_SYNC_INTERVAL = 3e4;
|
|
5719
5806
|
var DEFAULT_SYNC_LIMIT = 100;
|
|
5720
5807
|
var ENFORCE_CAP_BATCH_SIZE = 1e3;
|
|
@@ -5731,7 +5818,7 @@ var SimpleMempoolRunner = class extends AbstractCreatableProvider {
|
|
|
5731
5818
|
_finalizationViewer;
|
|
5732
5819
|
_mempoolViewer;
|
|
5733
5820
|
_transactionValidationViewer;
|
|
5734
|
-
_syncMutex = new
|
|
5821
|
+
_syncMutex = new Mutex2();
|
|
5735
5822
|
_syncTimerId = null;
|
|
5736
5823
|
get blockValidationViewer() {
|
|
5737
5824
|
return this._blockValidationViewer;
|
|
@@ -5752,10 +5839,10 @@ var SimpleMempoolRunner = class extends AbstractCreatableProvider {
|
|
|
5752
5839
|
return this.params.maxPendingTransactions ?? 0;
|
|
5753
5840
|
}
|
|
5754
5841
|
get pendingBlocksArchivist() {
|
|
5755
|
-
return this.params.pendingBlocksArchivist;
|
|
5842
|
+
return assertEx41(this.params.pendingBlocksArchivist, () => "pendingBlocksArchivist is required \u2014 inject it or bind a connection");
|
|
5756
5843
|
}
|
|
5757
5844
|
get pendingTransactionsArchivist() {
|
|
5758
|
-
return this.params.pendingTransactionsArchivist;
|
|
5845
|
+
return assertEx41(this.params.pendingTransactionsArchivist, () => "pendingTransactionsArchivist is required \u2014 inject it or bind a connection");
|
|
5759
5846
|
}
|
|
5760
5847
|
get syncInterval() {
|
|
5761
5848
|
return this.params.syncInterval ?? DEFAULT_SYNC_INTERVAL;
|
|
@@ -5770,10 +5857,13 @@ var SimpleMempoolRunner = class extends AbstractCreatableProvider {
|
|
|
5770
5857
|
return this.params.validateOnSubmit ?? true;
|
|
5771
5858
|
}
|
|
5772
5859
|
static async paramsHandler(params) {
|
|
5860
|
+
const connection = params?.connection;
|
|
5861
|
+
const pendingBlocksArchivist = params?.pendingBlocksArchivist ?? (connection ? await connectArchivist(connection, { name: PENDING_BLOCKS_ARCHIVIST_ROLE }) : void 0);
|
|
5862
|
+
const pendingTransactionsArchivist = params?.pendingTransactionsArchivist ?? (connection ? await connectArchivist(connection, { name: PENDING_TRANSACTIONS_ARCHIVIST_ROLE }) : void 0);
|
|
5773
5863
|
return {
|
|
5774
5864
|
...await super.paramsHandler(params),
|
|
5775
|
-
pendingBlocksArchivist:
|
|
5776
|
-
pendingTransactionsArchivist:
|
|
5865
|
+
pendingBlocksArchivist: assertEx41(pendingBlocksArchivist, () => "pendingBlocksArchivist is required \u2014 inject it or bind a connection"),
|
|
5866
|
+
pendingTransactionsArchivist: assertEx41(pendingTransactionsArchivist, () => "pendingTransactionsArchivist is required \u2014 inject it or bind a connection")
|
|
5777
5867
|
};
|
|
5778
5868
|
}
|
|
5779
5869
|
async createHandler() {
|
|
@@ -5812,7 +5902,7 @@ var SimpleMempoolRunner = class extends AbstractCreatableProvider {
|
|
|
5812
5902
|
remainingBlockMap.push(i);
|
|
5813
5903
|
return b;
|
|
5814
5904
|
}).filter(exists8);
|
|
5815
|
-
|
|
5905
|
+
assertEx41(
|
|
5816
5906
|
remainingBlockMap.length === remainingBlocks.length,
|
|
5817
5907
|
() => `remainingBlockMap length should match remainingBlocks length [${remainingBlockMap.length}/${remainingBlocks.length}]`
|
|
5818
5908
|
);
|
|
@@ -5875,7 +5965,7 @@ var SimpleMempoolRunner = class extends AbstractCreatableProvider {
|
|
|
5875
5965
|
remainingTransactionMap.push(i);
|
|
5876
5966
|
return t;
|
|
5877
5967
|
}).filter(exists8);
|
|
5878
|
-
|
|
5968
|
+
assertEx41(
|
|
5879
5969
|
remainingTransactionMap.length === remainingTransactions.length,
|
|
5880
5970
|
() => `remainingTransactionMap length should match remainingTransactions length [${remainingTransactionMap.length}/${remainingTransactions.length}]`
|
|
5881
5971
|
);
|
|
@@ -6117,7 +6207,7 @@ var SimpleMempoolRunner = class extends AbstractCreatableProvider {
|
|
|
6117
6207
|
this.logger?.debug(`Synced ${externalTxs.length} transactions from external mempool`);
|
|
6118
6208
|
}
|
|
6119
6209
|
};
|
|
6120
|
-
__publicField(SimpleMempoolRunner, "connectionTypes", ["lmdb", "mongo"]);
|
|
6210
|
+
__publicField(SimpleMempoolRunner, "connectionTypes", ["lmdb", "mongo", "memory"]);
|
|
6121
6211
|
__publicField(SimpleMempoolRunner, "defaultMoniker", MempoolRunnerMoniker);
|
|
6122
6212
|
__publicField(SimpleMempoolRunner, "dependencies", [FinalizationViewerMoniker4, BlockValidationViewerMoniker2, TransactionValidationViewerMoniker, ChainContractViewerMoniker4]);
|
|
6123
6213
|
__publicField(SimpleMempoolRunner, "monikers", [MempoolRunnerMoniker]);
|
|
@@ -6128,6 +6218,7 @@ SimpleMempoolRunner = __decorateClass([
|
|
|
6128
6218
|
|
|
6129
6219
|
// src/simple/mempool/SimpleMempoolViewer.ts
|
|
6130
6220
|
import {
|
|
6221
|
+
assertEx as assertEx42,
|
|
6131
6222
|
exists as exists9,
|
|
6132
6223
|
isDefined as isDefined21,
|
|
6133
6224
|
isHash as isHash2
|
|
@@ -6148,14 +6239,24 @@ var SimpleMempoolViewer = class extends AbstractCreatableProvider {
|
|
|
6148
6239
|
return this.params.handoutStatsTtlBlocks ?? DEFAULT_HANDOUT_STATS_TTL_BLOCKS;
|
|
6149
6240
|
}
|
|
6150
6241
|
get pendingBlocksArchivist() {
|
|
6151
|
-
return this.params.pendingBlocksArchivist;
|
|
6242
|
+
return assertEx42(this.params.pendingBlocksArchivist, () => "pendingBlocksArchivist is required \u2014 inject it or bind a connection");
|
|
6152
6243
|
}
|
|
6153
6244
|
get pendingTransactionsArchivist() {
|
|
6154
|
-
return this.params.pendingTransactionsArchivist;
|
|
6245
|
+
return assertEx42(this.params.pendingTransactionsArchivist, () => "pendingTransactionsArchivist is required \u2014 inject it or bind a connection");
|
|
6155
6246
|
}
|
|
6156
6247
|
get windowedBlockViewer() {
|
|
6157
6248
|
return this._windowedBlockViewer;
|
|
6158
6249
|
}
|
|
6250
|
+
static async paramsHandler(params) {
|
|
6251
|
+
const { connection } = params;
|
|
6252
|
+
const pendingBlocksArchivist = params.pendingBlocksArchivist ?? (connection ? await connectArchivist(connection, { name: PENDING_BLOCKS_ARCHIVIST_ROLE }) : void 0);
|
|
6253
|
+
const pendingTransactionsArchivist = params.pendingTransactionsArchivist ?? (connection ? await connectArchivist(connection, { name: PENDING_TRANSACTIONS_ARCHIVIST_ROLE }) : void 0);
|
|
6254
|
+
return {
|
|
6255
|
+
...await super.paramsHandler(params),
|
|
6256
|
+
pendingBlocksArchivist,
|
|
6257
|
+
pendingTransactionsArchivist
|
|
6258
|
+
};
|
|
6259
|
+
}
|
|
6159
6260
|
async createHandler() {
|
|
6160
6261
|
await super.createHandler();
|
|
6161
6262
|
this._windowedBlockViewer = await this.locator.getInstance(WindowedBlockViewerMoniker);
|
|
@@ -6336,7 +6437,7 @@ var SimpleMempoolViewer = class extends AbstractCreatableProvider {
|
|
|
6336
6437
|
return deduplicateWithBundleBySigner(randomSelected).slice(0, effectiveLimit);
|
|
6337
6438
|
}
|
|
6338
6439
|
};
|
|
6339
|
-
__publicField(SimpleMempoolViewer, "connectionTypes", ["lmdb", "mongo"]);
|
|
6440
|
+
__publicField(SimpleMempoolViewer, "connectionTypes", ["lmdb", "mongo", "memory"]);
|
|
6340
6441
|
__publicField(SimpleMempoolViewer, "defaultMoniker", MempoolViewerMoniker2);
|
|
6341
6442
|
__publicField(SimpleMempoolViewer, "dependencies", [WindowedBlockViewerMoniker]);
|
|
6342
6443
|
__publicField(SimpleMempoolViewer, "monikers", [MempoolViewerMoniker2]);
|
|
@@ -6427,7 +6528,7 @@ var SimpleXyoNetwork = class {
|
|
|
6427
6528
|
};
|
|
6428
6529
|
|
|
6429
6530
|
// src/simple/permissions/SimpleXyoPermissions.ts
|
|
6430
|
-
import { assertEx as
|
|
6531
|
+
import { assertEx as assertEx43 } from "@xylabs/sdk-js";
|
|
6431
6532
|
var SimpleXyoPermissions = class {
|
|
6432
6533
|
invoker;
|
|
6433
6534
|
_store;
|
|
@@ -6436,7 +6537,7 @@ var SimpleXyoPermissions = class {
|
|
|
6436
6537
|
this.invoker = store.invoker;
|
|
6437
6538
|
}
|
|
6438
6539
|
get store() {
|
|
6439
|
-
return
|
|
6540
|
+
return assertEx43(this._store, () => "Store must be defined to get permissions");
|
|
6440
6541
|
}
|
|
6441
6542
|
async getPermissions() {
|
|
6442
6543
|
return await this.store.getPermissions();
|
|
@@ -6489,7 +6590,7 @@ var SimpleXyoPermissions = class {
|
|
|
6489
6590
|
};
|
|
6490
6591
|
|
|
6491
6592
|
// src/simple/permissions/store/MemoryPermissions.ts
|
|
6492
|
-
import { assertEx as
|
|
6593
|
+
import { assertEx as assertEx44 } from "@xylabs/sdk-js";
|
|
6493
6594
|
var MemoryPermissionsStore = class {
|
|
6494
6595
|
_invoker;
|
|
6495
6596
|
permissions = [];
|
|
@@ -6497,7 +6598,7 @@ var MemoryPermissionsStore = class {
|
|
|
6497
6598
|
this._invoker = invoker;
|
|
6498
6599
|
}
|
|
6499
6600
|
get invoker() {
|
|
6500
|
-
return
|
|
6601
|
+
return assertEx44(this._invoker, () => "Invoker must be defined to get permissions");
|
|
6501
6602
|
}
|
|
6502
6603
|
async getPermissions() {
|
|
6503
6604
|
await Promise.resolve();
|
|
@@ -6529,7 +6630,7 @@ var SimpleXyoRunner = class extends AbstractCreatableProvider {
|
|
|
6529
6630
|
this._mempoolRunner = await this.locator.getInstance(MempoolRunnerMoniker2);
|
|
6530
6631
|
}
|
|
6531
6632
|
};
|
|
6532
|
-
__publicField(SimpleXyoRunner, "connectionTypes", ["lmdb", "mongo"]);
|
|
6633
|
+
__publicField(SimpleXyoRunner, "connectionTypes", ["lmdb", "mongo", "memory"]);
|
|
6533
6634
|
__publicField(SimpleXyoRunner, "defaultMoniker", XyoRunnerMoniker);
|
|
6534
6635
|
__publicField(SimpleXyoRunner, "dependencies", [MempoolRunnerMoniker2]);
|
|
6535
6636
|
__publicField(SimpleXyoRunner, "monikers", [XyoRunnerMoniker]);
|
|
@@ -6669,7 +6770,7 @@ SimpleStakeEventsViewer = __decorateClass([
|
|
|
6669
6770
|
], SimpleStakeEventsViewer);
|
|
6670
6771
|
|
|
6671
6772
|
// src/simple/StakeTotalsViewer/SimpleStakeTotalsViewer.ts
|
|
6672
|
-
import { assertEx as
|
|
6773
|
+
import { assertEx as assertEx45 } from "@xylabs/sdk-js";
|
|
6673
6774
|
import { asXyoAddress as asXyoAddress3 } from "@xyo-network/sdk-js";
|
|
6674
6775
|
import {
|
|
6675
6776
|
StakeTotalsViewerMoniker,
|
|
@@ -6713,7 +6814,7 @@ var SimpleStakeTotalsViewer = class extends AbstractCreatableProvider {
|
|
|
6713
6814
|
}
|
|
6714
6815
|
async createHandler() {
|
|
6715
6816
|
await super.createHandler();
|
|
6716
|
-
this._stakeViewer =
|
|
6817
|
+
this._stakeViewer = assertEx45(
|
|
6717
6818
|
await this.locateAndCreate(StakeViewerMoniker),
|
|
6718
6819
|
() => "Failed to create StakeViewer"
|
|
6719
6820
|
);
|
|
@@ -6759,7 +6860,7 @@ var SimpleStakeTotalsViewer = class extends AbstractCreatableProvider {
|
|
|
6759
6860
|
return withdrawn;
|
|
6760
6861
|
}
|
|
6761
6862
|
};
|
|
6762
|
-
__publicField(SimpleStakeTotalsViewer, "connectionTypes", ["lmdb", "mongo"]);
|
|
6863
|
+
__publicField(SimpleStakeTotalsViewer, "connectionTypes", ["lmdb", "mongo", "memory"]);
|
|
6763
6864
|
__publicField(SimpleStakeTotalsViewer, "defaultMoniker", StakeTotalsViewerMoniker);
|
|
6764
6865
|
__publicField(SimpleStakeTotalsViewer, "dependencies", [StakeTotalsViewerMoniker]);
|
|
6765
6866
|
__publicField(SimpleStakeTotalsViewer, "monikers", [StakeTotalsViewerMoniker]);
|
|
@@ -6769,14 +6870,14 @@ SimpleStakeTotalsViewer = __decorateClass([
|
|
|
6769
6870
|
], SimpleStakeTotalsViewer);
|
|
6770
6871
|
|
|
6771
6872
|
// src/simple/StakeViewer/SimpleStakeViewer.ts
|
|
6772
|
-
import { assertEx as
|
|
6873
|
+
import { assertEx as assertEx46, toAddress } from "@xylabs/sdk-js";
|
|
6773
6874
|
import { asXyoAddress as asXyoAddress4 } from "@xyo-network/sdk-js";
|
|
6774
6875
|
import { StakeEventsViewerMoniker as StakeEventsViewerMoniker2, StakeViewerMoniker as StakeViewerMoniker2 } from "@xyo-network/xl1-protocol-lib";
|
|
6775
6876
|
var SimpleStakeViewer = class extends AbstractCreatableProvider {
|
|
6776
6877
|
moniker = SimpleStakeViewer.defaultMoniker;
|
|
6777
6878
|
_chainStakeEventsViewer;
|
|
6778
6879
|
get stakeEvents() {
|
|
6779
|
-
return
|
|
6880
|
+
return assertEx46(this._chainStakeEventsViewer, () => "Stake events viewer not set");
|
|
6780
6881
|
}
|
|
6781
6882
|
get positions() {
|
|
6782
6883
|
return this.params.positions;
|
|
@@ -6816,7 +6917,7 @@ var SimpleStakeViewer = class extends AbstractCreatableProvider {
|
|
|
6816
6917
|
}
|
|
6817
6918
|
async createHandler() {
|
|
6818
6919
|
await super.createHandler();
|
|
6819
|
-
this._chainStakeEventsViewer =
|
|
6920
|
+
this._chainStakeEventsViewer = assertEx46(
|
|
6820
6921
|
await this.locateAndCreate(StakeEventsViewerMoniker2),
|
|
6821
6922
|
() => "Failed to create StakeEventsViewer"
|
|
6822
6923
|
);
|
|
@@ -6851,7 +6952,7 @@ var SimpleStakeViewer = class extends AbstractCreatableProvider {
|
|
|
6851
6952
|
return toAddress(toAddress(1n));
|
|
6852
6953
|
}
|
|
6853
6954
|
stakeById(id) {
|
|
6854
|
-
return
|
|
6955
|
+
return assertEx46(this.positions[id], () => new Error(`Stake with id ${id} not found`));
|
|
6855
6956
|
}
|
|
6856
6957
|
stakeByStaker(staker, slot) {
|
|
6857
6958
|
return this.positions.filter((s) => asXyoAddress4(s.staker) === asXyoAddress4(staker))[slot];
|
|
@@ -6891,7 +6992,7 @@ var SimpleStakeViewer = class extends AbstractCreatableProvider {
|
|
|
6891
6992
|
return this.positions.filter((s) => s.withdrawBlock !== 0);
|
|
6892
6993
|
}
|
|
6893
6994
|
};
|
|
6894
|
-
__publicField(SimpleStakeViewer, "connectionTypes", ["lmdb", "mongo"]);
|
|
6995
|
+
__publicField(SimpleStakeViewer, "connectionTypes", ["lmdb", "mongo", "memory"]);
|
|
6895
6996
|
__publicField(SimpleStakeViewer, "defaultMoniker", StakeViewerMoniker2);
|
|
6896
6997
|
__publicField(SimpleStakeViewer, "dependencies", [StakeEventsViewerMoniker2]);
|
|
6897
6998
|
__publicField(SimpleStakeViewer, "monikers", [StakeViewerMoniker2]);
|
|
@@ -6955,7 +7056,7 @@ RestSyncViewer = __decorateClass([
|
|
|
6955
7056
|
// src/simple/timeSync2/SimpleTimeSyncViewer.ts
|
|
6956
7057
|
import {
|
|
6957
7058
|
asHash as asHash5,
|
|
6958
|
-
assertEx as
|
|
7059
|
+
assertEx as assertEx47,
|
|
6959
7060
|
isDefined as isDefined23
|
|
6960
7061
|
} from "@xylabs/sdk-js";
|
|
6961
7062
|
import {
|
|
@@ -6977,7 +7078,7 @@ var SimpleTimeSyncViewer = class extends AbstractCreatableProvider {
|
|
|
6977
7078
|
async convertTime(fromDomain, toDomain, from) {
|
|
6978
7079
|
switch (fromDomain) {
|
|
6979
7080
|
case "xl1": {
|
|
6980
|
-
const [block, payloads] =
|
|
7081
|
+
const [block, payloads] = assertEx47(await this.blockViewer.blockByNumber(asXL1BlockNumber11(from, true)), () => "Block not found");
|
|
6981
7082
|
const timeSchemaIndex = block.payload_schemas.indexOf(TimeSchema);
|
|
6982
7083
|
const hash = timeSchemaIndex === -1 ? void 0 : block.payload_hashes[timeSchemaIndex];
|
|
6983
7084
|
const timePayload = asTimePayload2(isDefined23(hash) ? payloads.find((p) => p._hash === hash) : void 0);
|
|
@@ -7033,10 +7134,10 @@ var SimpleTimeSyncViewer = class extends AbstractCreatableProvider {
|
|
|
7033
7134
|
return [Date.now(), null];
|
|
7034
7135
|
}
|
|
7035
7136
|
case "ethereum": {
|
|
7036
|
-
const provider =
|
|
7137
|
+
const provider = assertEx47(this.ethProvider, () => "Ethereum provider not configured");
|
|
7037
7138
|
const blockNumber = await provider.getBlockNumber() ?? 0;
|
|
7038
7139
|
const block = await provider.getBlock(blockNumber);
|
|
7039
|
-
const blockHash = asHash5(
|
|
7140
|
+
const blockHash = asHash5(assertEx47(block?.hash, () => "Block hash not found"), true);
|
|
7040
7141
|
return [blockNumber, blockHash];
|
|
7041
7142
|
}
|
|
7042
7143
|
default: {
|
|
@@ -7051,7 +7152,7 @@ var SimpleTimeSyncViewer = class extends AbstractCreatableProvider {
|
|
|
7051
7152
|
// this is for the previous block
|
|
7052
7153
|
xl1,
|
|
7053
7154
|
// this is for the previous block
|
|
7054
|
-
xl1Hash:
|
|
7155
|
+
xl1Hash: assertEx47(xl1Hash, () => "No xl1 hash available from time sync service"),
|
|
7055
7156
|
epoch: Date.now()
|
|
7056
7157
|
};
|
|
7057
7158
|
if (isDefined23(this.ethProvider)) {
|
|
@@ -7063,7 +7164,7 @@ var SimpleTimeSyncViewer = class extends AbstractCreatableProvider {
|
|
|
7063
7164
|
return timePayload;
|
|
7064
7165
|
}
|
|
7065
7166
|
};
|
|
7066
|
-
__publicField(SimpleTimeSyncViewer, "connectionTypes", ["lmdb", "mongo"]);
|
|
7167
|
+
__publicField(SimpleTimeSyncViewer, "connectionTypes", ["lmdb", "mongo", "memory"]);
|
|
7067
7168
|
__publicField(SimpleTimeSyncViewer, "defaultMoniker", TimeSyncViewerMoniker);
|
|
7068
7169
|
__publicField(SimpleTimeSyncViewer, "dependencies", [BlockViewerMoniker4]);
|
|
7069
7170
|
__publicField(SimpleTimeSyncViewer, "monikers", [TimeSyncViewerMoniker]);
|
|
@@ -7073,7 +7174,7 @@ SimpleTimeSyncViewer = __decorateClass([
|
|
|
7073
7174
|
], SimpleTimeSyncViewer);
|
|
7074
7175
|
|
|
7075
7176
|
// src/simple/transactionValidation/SimpleTransactionValidationViewer.ts
|
|
7076
|
-
import { assertEx as
|
|
7177
|
+
import { assertEx as assertEx48 } from "@xylabs/sdk-js";
|
|
7077
7178
|
import { PayloadBuilder as PayloadBuilder24 } from "@xyo-network/sdk-js";
|
|
7078
7179
|
import {
|
|
7079
7180
|
AccountBalanceViewerMoniker as AccountBalanceViewerMoniker3,
|
|
@@ -7127,7 +7228,7 @@ var SimpleTransactionValidationViewer = class extends AbstractCreatableProvider
|
|
|
7127
7228
|
let head;
|
|
7128
7229
|
if (isChainQualifiedHeadConfig6(config)) {
|
|
7129
7230
|
const headBlockResult = await this.blockViewer.blockByHash(config.head);
|
|
7130
|
-
head = headBlockResult == null ?
|
|
7231
|
+
head = headBlockResult == null ? assertEx48(
|
|
7131
7232
|
void 0,
|
|
7132
7233
|
() => `Specified a head that is not in the chain [${config.head}]`
|
|
7133
7234
|
) : headBlockResult[0];
|
|
@@ -7189,7 +7290,7 @@ var SimpleTransactionValidationViewer = class extends AbstractCreatableProvider
|
|
|
7189
7290
|
}));
|
|
7190
7291
|
}
|
|
7191
7292
|
};
|
|
7192
|
-
__publicField(SimpleTransactionValidationViewer, "connectionTypes", ["lmdb", "mongo", "rpc"]);
|
|
7293
|
+
__publicField(SimpleTransactionValidationViewer, "connectionTypes", ["lmdb", "mongo", "memory", "rpc"]);
|
|
7193
7294
|
__publicField(SimpleTransactionValidationViewer, "defaultMoniker", TransactionValidationViewerMoniker2);
|
|
7194
7295
|
__publicField(SimpleTransactionValidationViewer, "dependencies", [AccountBalanceViewerMoniker3, ChainContractViewerMoniker5, BlockViewerMoniker5]);
|
|
7195
7296
|
__publicField(SimpleTransactionValidationViewer, "monikers", [TransactionValidationViewerMoniker2]);
|
|
@@ -7199,7 +7300,7 @@ SimpleTransactionValidationViewer = __decorateClass([
|
|
|
7199
7300
|
], SimpleTransactionValidationViewer);
|
|
7200
7301
|
|
|
7201
7302
|
// src/simple/TransactionViewer/SimpleTransactionViewer.ts
|
|
7202
|
-
import { assertEx as
|
|
7303
|
+
import { assertEx as assertEx49, exists as exists10 } from "@xylabs/sdk-js";
|
|
7203
7304
|
import { BoundWitnessSchema } from "@xyo-network/sdk-js";
|
|
7204
7305
|
import {
|
|
7205
7306
|
asSignedHydratedTransactionWithHashMeta,
|
|
@@ -7216,7 +7317,7 @@ var SimpleTransactionViewer = class extends AbstractCreatableProvider {
|
|
|
7216
7317
|
}
|
|
7217
7318
|
async byBlockHashAndIndex(blockHash, transactionIndex) {
|
|
7218
7319
|
return await this.spanAsync("byBlockHashAndIndex", async () => {
|
|
7219
|
-
|
|
7320
|
+
assertEx49(transactionIndex >= 0, () => "transactionIndex must be greater than or equal to 0");
|
|
7220
7321
|
try {
|
|
7221
7322
|
const block = await this.blockViewer.blockByHash(blockHash);
|
|
7222
7323
|
if (!block) return null;
|
|
@@ -7271,7 +7372,7 @@ var SimpleTransactionViewer = class extends AbstractCreatableProvider {
|
|
|
7271
7372
|
return await this.byHash(transactionHash);
|
|
7272
7373
|
}
|
|
7273
7374
|
};
|
|
7274
|
-
__publicField(SimpleTransactionViewer, "connectionTypes", ["lmdb", "mongo"]);
|
|
7375
|
+
__publicField(SimpleTransactionViewer, "connectionTypes", ["lmdb", "mongo", "memory"]);
|
|
7275
7376
|
__publicField(SimpleTransactionViewer, "defaultMoniker", TransactionViewerMoniker);
|
|
7276
7377
|
__publicField(SimpleTransactionViewer, "dependencies", [BlockViewerMoniker6]);
|
|
7277
7378
|
__publicField(SimpleTransactionViewer, "monikers", [TransactionViewerMoniker]);
|
|
@@ -7281,7 +7382,7 @@ SimpleTransactionViewer = __decorateClass([
|
|
|
7281
7382
|
|
|
7282
7383
|
// src/simple/windowedBlock/SimpleWindowedBlockViewer.ts
|
|
7283
7384
|
import {
|
|
7284
|
-
assertEx as
|
|
7385
|
+
assertEx as assertEx50,
|
|
7285
7386
|
exists as exists11,
|
|
7286
7387
|
isNull as isNull2
|
|
7287
7388
|
} from "@xylabs/sdk-js";
|
|
@@ -7292,7 +7393,7 @@ import {
|
|
|
7292
7393
|
stepSize as stepSize3,
|
|
7293
7394
|
WindowedBlockViewerMoniker as WindowedBlockViewerMoniker2
|
|
7294
7395
|
} from "@xyo-network/xl1-protocol-lib";
|
|
7295
|
-
import { Mutex as
|
|
7396
|
+
import { Mutex as Mutex3 } from "async-mutex";
|
|
7296
7397
|
var SimpleWindowedBlockViewer = class extends AbstractCreatableProvider {
|
|
7297
7398
|
moniker = WindowedBlockViewerMoniker2;
|
|
7298
7399
|
_blockHashMap;
|
|
@@ -7300,7 +7401,7 @@ var SimpleWindowedBlockViewer = class extends AbstractCreatableProvider {
|
|
|
7300
7401
|
// the external BlockViewer
|
|
7301
7402
|
_blockViewer;
|
|
7302
7403
|
_chain = [];
|
|
7303
|
-
_syncMutex = new
|
|
7404
|
+
_syncMutex = new Mutex3();
|
|
7304
7405
|
_timerId = null;
|
|
7305
7406
|
_transactionHashMap;
|
|
7306
7407
|
get maxWindowSize() {
|
|
@@ -7363,7 +7464,7 @@ var SimpleWindowedBlockViewer = class extends AbstractCreatableProvider {
|
|
|
7363
7464
|
}
|
|
7364
7465
|
async createHandler() {
|
|
7365
7466
|
await super.createHandler();
|
|
7366
|
-
this._blockViewer =
|
|
7467
|
+
this._blockViewer = assertEx50(
|
|
7367
7468
|
this.params.blockViewer ?? await this.locator.getInstance(BlockViewerMoniker7),
|
|
7368
7469
|
() => "BlockViewer instance is required"
|
|
7369
7470
|
);
|
|
@@ -7372,13 +7473,13 @@ var SimpleWindowedBlockViewer = class extends AbstractCreatableProvider {
|
|
|
7372
7473
|
this._transactionHashMap = new MemoryMap2();
|
|
7373
7474
|
}
|
|
7374
7475
|
currentBlock() {
|
|
7375
|
-
return
|
|
7476
|
+
return assertEx50(this._chain.at(-1));
|
|
7376
7477
|
}
|
|
7377
7478
|
currentBlockHash() {
|
|
7378
|
-
return
|
|
7479
|
+
return assertEx50(this._chain.at(-1)?.[0]._hash);
|
|
7379
7480
|
}
|
|
7380
7481
|
currentBlockNumber() {
|
|
7381
|
-
return
|
|
7482
|
+
return assertEx50(this._chain.at(-1)?.[0].block);
|
|
7382
7483
|
}
|
|
7383
7484
|
async payloadByHash(hash) {
|
|
7384
7485
|
const payloads = await this.payloadsByHash([hash]);
|
|
@@ -7448,7 +7549,7 @@ var SimpleWindowedBlockViewer = class extends AbstractCreatableProvider {
|
|
|
7448
7549
|
});
|
|
7449
7550
|
}
|
|
7450
7551
|
};
|
|
7451
|
-
__publicField(SimpleWindowedBlockViewer, "connectionTypes", ["lmdb", "mongo", "rpc"]);
|
|
7552
|
+
__publicField(SimpleWindowedBlockViewer, "connectionTypes", ["lmdb", "mongo", "memory", "rpc"]);
|
|
7452
7553
|
__publicField(SimpleWindowedBlockViewer, "defaultMoniker", WindowedBlockViewerMoniker2);
|
|
7453
7554
|
__publicField(SimpleWindowedBlockViewer, "dependencies", [BlockViewerMoniker7]);
|
|
7454
7555
|
__publicField(SimpleWindowedBlockViewer, "monikers", [WindowedBlockViewerMoniker2]);
|
|
@@ -7539,12 +7640,12 @@ var RuntimeStatusMonitor = class extends LoggerStatusReporter {
|
|
|
7539
7640
|
};
|
|
7540
7641
|
|
|
7541
7642
|
// src/test/buildRandomChain.ts
|
|
7542
|
-
import { asAddress as asAddress2, assertEx as
|
|
7643
|
+
import { asAddress as asAddress2, assertEx as assertEx53 } from "@xylabs/sdk-js";
|
|
7543
7644
|
import {
|
|
7544
7645
|
Account as Account4,
|
|
7545
7646
|
asSchema as asSchema9,
|
|
7546
7647
|
IdSchema as IdSchema2,
|
|
7547
|
-
MemoryArchivist,
|
|
7648
|
+
MemoryArchivist as MemoryArchivist2,
|
|
7548
7649
|
PayloadBuilder as PayloadBuilder29
|
|
7549
7650
|
} from "@xyo-network/sdk-js";
|
|
7550
7651
|
import {
|
|
@@ -7558,7 +7659,7 @@ import {
|
|
|
7558
7659
|
} from "@xyo-network/xl1-protocol-lib";
|
|
7559
7660
|
|
|
7560
7661
|
// src/test/buildBlock.ts
|
|
7561
|
-
import { assertEx as
|
|
7662
|
+
import { assertEx as assertEx51, isDefined as isDefined24 } from "@xylabs/sdk-js";
|
|
7562
7663
|
import {
|
|
7563
7664
|
asAnyPayload as asAnyPayload5,
|
|
7564
7665
|
BoundWitnessBuilder as BoundWitnessBuilder3,
|
|
@@ -7641,7 +7742,7 @@ function buildStepHashes(blockNumber, inStepHashes, previousBlockHash, chainStep
|
|
|
7641
7742
|
const completedStepReward = calculateCompletedStepReward(i, stepRewardPoolBalance);
|
|
7642
7743
|
completedStepRewardTransfers.push(createTransferPayload(chainStepRewardAddress2, { [completedStepRewardHolderAddress]: completedStepReward }));
|
|
7643
7744
|
}
|
|
7644
|
-
step_hashes.push(
|
|
7745
|
+
step_hashes.push(assertEx51(previousBlockHash, () => `Previous block hash is required for step ${step} at block ${blockNumber}`));
|
|
7645
7746
|
} else if (isDefined24(inStepHashes.at(i))) {
|
|
7646
7747
|
step_hashes.push(inStepHashes[i]);
|
|
7647
7748
|
}
|
|
@@ -7695,7 +7796,7 @@ async function buildBlock(options) {
|
|
|
7695
7796
|
protocol
|
|
7696
7797
|
}).meta({ $epoch: Date.now(), $signatures: [] }).signers(signers).payloads(await PayloadBuilder25.addStorageMeta(payloads));
|
|
7697
7798
|
const [bw, txPayloads] = await builder.build();
|
|
7698
|
-
|
|
7799
|
+
assertEx51(isBlockBoundWitness(bw), () => "Build of BlockBoundWitness failed");
|
|
7699
7800
|
return [await PayloadBuilder25.addStorageMeta(bw), txPayloads.map((p) => asAnyPayload5(p, true))];
|
|
7700
7801
|
}
|
|
7701
7802
|
|
|
@@ -7716,7 +7817,7 @@ async function buildNextBlock(previousBlock, txs, blockPayloads, signers, chainS
|
|
|
7716
7817
|
}
|
|
7717
7818
|
|
|
7718
7819
|
// src/test/buildRandomGenesisBlock.ts
|
|
7719
|
-
import { asAddress, assertEx as
|
|
7820
|
+
import { asAddress, assertEx as assertEx52 } from "@xylabs/sdk-js";
|
|
7720
7821
|
import {
|
|
7721
7822
|
Account as Account3,
|
|
7722
7823
|
asAnyPayload as asAnyPayload6,
|
|
@@ -7760,7 +7861,7 @@ var buildRandomTransaction = async (chain, payloads, account, nbf = asXL1BlockNu
|
|
|
7760
7861
|
};
|
|
7761
7862
|
|
|
7762
7863
|
// src/test/buildRandomGenesisBlock.ts
|
|
7763
|
-
var TestChainId =
|
|
7864
|
+
var TestChainId = assertEx52(asAddress("c5fe2e6F6841Cbab12d8C0618Be2DF8C6156cC44"));
|
|
7764
7865
|
|
|
7765
7866
|
// src/test/createGenesisBlock.ts
|
|
7766
7867
|
import { PayloadBuilder as PayloadBuilder28 } from "@xyo-network/sdk-js";
|
|
@@ -7815,7 +7916,7 @@ var createGenesisBlock = async (initialBlockProducer, nextContractAddress, genes
|
|
|
7815
7916
|
};
|
|
7816
7917
|
|
|
7817
7918
|
// src/test/buildRandomChain.ts
|
|
7818
|
-
var TestGenesisBlockRewardAddress =
|
|
7919
|
+
var TestGenesisBlockRewardAddress = assertEx53(asAddress2("fa7f0bb865a4bfff3d5e2c726d3e063297014da9"));
|
|
7819
7920
|
var buildRandomChain = async (blockProducer, count = 10, previousBlock, chainId, transactionAccount, receiverAddresses) => {
|
|
7820
7921
|
const chainIdToUse = chainId ?? TestChainId;
|
|
7821
7922
|
const blocks = [];
|
|
@@ -7859,7 +7960,7 @@ var buildRandomChain = async (blockProducer, count = 10, previousBlock, chainId,
|
|
|
7859
7960
|
receiverAddress
|
|
7860
7961
|
));
|
|
7861
7962
|
}
|
|
7862
|
-
const previousBlock2 =
|
|
7963
|
+
const previousBlock2 = assertEx53(lastBlock?.[0], () => new Error("No last block"));
|
|
7863
7964
|
const block = await buildNextBlock(previousBlock2, txs, [], [blockProducer], transactionAccountToUse.address);
|
|
7864
7965
|
blocks.push(block);
|
|
7865
7966
|
remaining = remaining - 1;
|
|
@@ -7870,7 +7971,7 @@ var buildRandomChain = async (blockProducer, count = 10, previousBlock, chainId,
|
|
|
7870
7971
|
async function buildRandomChainArchivist(count = 20) {
|
|
7871
7972
|
const producerAccount = await Account4.random();
|
|
7872
7973
|
const blocks = await buildRandomChain(producerAccount, count);
|
|
7873
|
-
const archivist = await
|
|
7974
|
+
const archivist = await MemoryArchivist2.create();
|
|
7874
7975
|
const payloads = flattenHydratedBlocks(blocks);
|
|
7875
7976
|
await archivist.insert(payloads);
|
|
7876
7977
|
return archivist;
|
|
@@ -7920,13 +8021,13 @@ function getTestProviderContext2(config) {
|
|
|
7920
8021
|
}
|
|
7921
8022
|
|
|
7922
8023
|
// src/time/primitives/xl1BlockNumberToEthBlockNumber.ts
|
|
7923
|
-
import { assertEx as
|
|
8024
|
+
import { assertEx as assertEx54 } from "@xylabs/sdk-js";
|
|
7924
8025
|
import { asTimePayload as asTimePayload3, TimeSchema as TimeSchema2 } from "@xyo-network/xl1-protocol-lib";
|
|
7925
8026
|
async function xl1BlockNumberToEthBlockNumber(context, xl1BlockNumber) {
|
|
7926
8027
|
const blockHash = await hashFromBlockNumber(context, xl1BlockNumber);
|
|
7927
8028
|
const hydratedBlock = await hydrateBlock(context, blockHash);
|
|
7928
8029
|
const timePayload = asTimePayload3(hydratedBlock[1].find((p) => p.schema === TimeSchema2), { required: true });
|
|
7929
|
-
return
|
|
8030
|
+
return assertEx54(timePayload.ethereum, () => "No ethereum timestamp found on block");
|
|
7930
8031
|
}
|
|
7931
8032
|
|
|
7932
8033
|
// src/validation/lib/isLocalhost.ts
|
|
@@ -7979,11 +8080,13 @@ export {
|
|
|
7979
8080
|
ActorsConfigZod,
|
|
7980
8081
|
AddressPairSchema,
|
|
7981
8082
|
AmbiguousProviderError,
|
|
8083
|
+
ArchivistInstanceCache,
|
|
7982
8084
|
BalancesStepSummarySchema,
|
|
7983
8085
|
BaseConfigContextZod,
|
|
7984
8086
|
BaseConfigZod,
|
|
7985
8087
|
BoundWitnessHydrator,
|
|
7986
8088
|
BoundWitnessWithStorageMetaZod,
|
|
8089
|
+
CHAIN_ARCHIVIST_ROLE,
|
|
7987
8090
|
CHANGE_ADDRESS,
|
|
7988
8091
|
COIN_TYPES,
|
|
7989
8092
|
ChainIndexingServiceStateSchema,
|
|
@@ -8015,11 +8118,15 @@ export {
|
|
|
8015
8118
|
LmdbTransportConfigZod as LmdbConnectionConfigZod,
|
|
8016
8119
|
LmdbTransportConfigZod,
|
|
8017
8120
|
LoggerStatusReporter,
|
|
8121
|
+
MemoryArchivistFactory,
|
|
8018
8122
|
MemoryPermissionsStore,
|
|
8123
|
+
MemoryTransportConfigZod,
|
|
8019
8124
|
MissingCapabilityError,
|
|
8020
8125
|
MnemonicStringZod,
|
|
8021
8126
|
MongoTransportConfigZod as MongoConnectionConfigZod,
|
|
8022
8127
|
MongoTransportConfigZod,
|
|
8128
|
+
PENDING_BLOCKS_ARCHIVIST_ROLE,
|
|
8129
|
+
PENDING_TRANSACTIONS_ARCHIVIST_ROLE,
|
|
8023
8130
|
PRODUCER_DIVERSITY_BONUS,
|
|
8024
8131
|
PayloadLocator,
|
|
8025
8132
|
PostMessageRpcRemoteConfigZod,
|
|
@@ -8030,6 +8137,8 @@ export {
|
|
|
8030
8137
|
ProviderFactoryLocator,
|
|
8031
8138
|
ProviderFactoryLocatorZod,
|
|
8032
8139
|
ProvidersConfigZod,
|
|
8140
|
+
REJECTED_BLOCKS_ARCHIVIST_ROLE,
|
|
8141
|
+
REJECTED_TRANSACTIONS_ARCHIVIST_ROLE,
|
|
8033
8142
|
RemoteConfigZod,
|
|
8034
8143
|
RestTransportConfigZod as RestConnectionConfigZod,
|
|
8035
8144
|
RestDataLakeConfigZod,
|
|
@@ -8103,6 +8212,7 @@ export {
|
|
|
8103
8212
|
allHashesPresent,
|
|
8104
8213
|
allStakersForRange,
|
|
8105
8214
|
allStakersForStep,
|
|
8215
|
+
archivistCacheKey,
|
|
8106
8216
|
asActorConfig,
|
|
8107
8217
|
asActorConfigContext,
|
|
8108
8218
|
asAddressPairPayload,
|
|
@@ -8149,6 +8259,7 @@ export {
|
|
|
8149
8259
|
calculateTimeRate,
|
|
8150
8260
|
chainStepRewardAddress,
|
|
8151
8261
|
confirmSubmittedTransaction,
|
|
8262
|
+
connectArchivist,
|
|
8152
8263
|
connectionSubsetBySurface,
|
|
8153
8264
|
contextCache,
|
|
8154
8265
|
crackOperation,
|