@xyo-network/xl1-protocol-sdk 3.0.2 → 3.0.4
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/capabilities/needsFromProviderBindings.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/context/getEmptyProviderContext.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 +185 -75
- 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/block/SimpleBlockViewer.d.ts +5 -2
- package/dist/neutral/simple/block/SimpleBlockViewer.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/test/index.mjs +81 -10
- package/dist/neutral/test/index.mjs.map +4 -4
- package/package.json +8 -8
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));
|
|
@@ -1601,8 +1669,7 @@ function needsFromProviderBindings(config) {
|
|
|
1601
1669
|
function needsFromConnectionTypes(config, connectionTypes) {
|
|
1602
1670
|
const allowed = new Set(connectionTypes);
|
|
1603
1671
|
const needs = /* @__PURE__ */ new Set();
|
|
1604
|
-
for (const moniker of Object.
|
|
1605
|
-
const binding = config.providerBindings[moniker];
|
|
1672
|
+
for (const [moniker, binding] of Object.entries(config.providerBindings)) {
|
|
1606
1673
|
const connectionName = binding?.connection ?? binding?.transport;
|
|
1607
1674
|
if (connectionName === void 0 || connectionName === "") {
|
|
1608
1675
|
continue;
|
|
@@ -1823,13 +1890,15 @@ var EvmRpcTransportConfigZod = z6.object({
|
|
|
1823
1890
|
type: "string"
|
|
1824
1891
|
})
|
|
1825
1892
|
}).describe("EVM JSON-RPC transport");
|
|
1893
|
+
var MemoryTransportConfigZod = z6.object({ type: z6.literal("memory") }).describe("In-process memory transport");
|
|
1826
1894
|
var TransportConfigZod = z6.discriminatedUnion("type", [
|
|
1827
1895
|
LmdbTransportConfigZod,
|
|
1828
1896
|
MongoTransportConfigZod,
|
|
1829
1897
|
RpcTransportConfigZod,
|
|
1830
1898
|
RestTransportConfigZod,
|
|
1831
1899
|
S3TransportConfigZod,
|
|
1832
|
-
EvmRpcTransportConfigZod
|
|
1900
|
+
EvmRpcTransportConfigZod,
|
|
1901
|
+
MemoryTransportConfigZod
|
|
1833
1902
|
]);
|
|
1834
1903
|
var TransportsConfigZod = z6.record(z6.string(), TransportConfigZod).default({});
|
|
1835
1904
|
|
|
@@ -4784,7 +4853,7 @@ var SimpleBlockViewer = class extends AbstractCreatableProvider {
|
|
|
4784
4853
|
_headPollTimer = null;
|
|
4785
4854
|
_signedHydratedBlockCache;
|
|
4786
4855
|
get finalizedArchivist() {
|
|
4787
|
-
return this.params.finalizedArchivist;
|
|
4856
|
+
return assertEx34(this.params.finalizedArchivist, () => "finalizedArchivist is required \u2014 inject it or bind a connection");
|
|
4788
4857
|
}
|
|
4789
4858
|
get blocksSummaryMap() {
|
|
4790
4859
|
this._blocksSummaryMap ??= this.params.blocksSummaryMap ?? new LruCacheMap2({ max: 32 });
|
|
@@ -4810,10 +4879,12 @@ var SimpleBlockViewer = class extends AbstractCreatableProvider {
|
|
|
4810
4879
|
if (headPollIntervalMs !== void 0) {
|
|
4811
4880
|
assertEx34(headPollIntervalMs >= MIN_HEAD_POLL_INTERVAL_MS, () => `headPollIntervalMs must be at least ${MIN_HEAD_POLL_INTERVAL_MS}ms`);
|
|
4812
4881
|
}
|
|
4882
|
+
const connection = params.connection;
|
|
4883
|
+
const finalizedArchivist = params.finalizedArchivist ?? (connection ? await connectArchivist(connection, { name: CHAIN_ARCHIVIST_ROLE }) : void 0);
|
|
4813
4884
|
return {
|
|
4814
4885
|
...await super.paramsHandler(params),
|
|
4815
4886
|
blocksSummaryMap: params.blocksSummaryMap,
|
|
4816
|
-
finalizedArchivist: assertEx34(
|
|
4887
|
+
finalizedArchivist: assertEx34(finalizedArchivist, () => "finalizedArchivist is required \u2014 inject it or bind a connection"),
|
|
4817
4888
|
headPollIntervalMs
|
|
4818
4889
|
};
|
|
4819
4890
|
}
|
|
@@ -4911,7 +4982,7 @@ var SimpleBlockViewer = class extends AbstractCreatableProvider {
|
|
|
4911
4982
|
async createHandler() {
|
|
4912
4983
|
await super.createHandler();
|
|
4913
4984
|
this.finalizationViewer = await this.locator.getInstance(FinalizationViewerMoniker);
|
|
4914
|
-
this._store = { chainMap: this.
|
|
4985
|
+
this._store = { chainMap: this.finalizedArchivist };
|
|
4915
4986
|
}
|
|
4916
4987
|
async currentBlock() {
|
|
4917
4988
|
return await this.finalizationViewer.head();
|
|
@@ -5011,7 +5082,7 @@ var SimpleBlockViewer = class extends AbstractCreatableProvider {
|
|
|
5011
5082
|
this._headPollTimer = null;
|
|
5012
5083
|
}
|
|
5013
5084
|
};
|
|
5014
|
-
__publicField(SimpleBlockViewer, "connectionTypes", ["lmdb", "mongo"]);
|
|
5085
|
+
__publicField(SimpleBlockViewer, "connectionTypes", ["lmdb", "mongo", "memory"]);
|
|
5015
5086
|
__publicField(SimpleBlockViewer, "defaultMoniker", BlockViewerMoniker2);
|
|
5016
5087
|
__publicField(SimpleBlockViewer, "dependencies", [FinalizationViewerMoniker]);
|
|
5017
5088
|
__publicField(SimpleBlockViewer, "monikers", [BlockViewerMoniker2]);
|
|
@@ -5450,16 +5521,28 @@ SimpleDataLakeViewer = __decorateClass([
|
|
|
5450
5521
|
], SimpleDataLakeViewer);
|
|
5451
5522
|
|
|
5452
5523
|
// src/simple/finalization/SimpleFinalizationRunner.ts
|
|
5524
|
+
import { assertEx as assertEx38 } from "@xylabs/sdk-js";
|
|
5453
5525
|
import { FinalizationRunnerMoniker } from "@xyo-network/xl1-protocol-lib";
|
|
5454
5526
|
var SimpleFinalizationRunner = class extends AbstractCreatableProvider {
|
|
5455
5527
|
moniker = SimpleFinalizationRunner.defaultMoniker;
|
|
5456
5528
|
_store;
|
|
5529
|
+
get finalizedArchivist() {
|
|
5530
|
+
return assertEx38(this.params.finalizedArchivist, () => "finalizedArchivist is required \u2014 inject it or bind a connection");
|
|
5531
|
+
}
|
|
5457
5532
|
get store() {
|
|
5458
5533
|
return this._store;
|
|
5459
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
|
+
}
|
|
5460
5543
|
async createHandler() {
|
|
5461
5544
|
await super.createHandler();
|
|
5462
|
-
this._store = { chainMap: this.
|
|
5545
|
+
this._store = { chainMap: this.finalizedArchivist };
|
|
5463
5546
|
}
|
|
5464
5547
|
async finalizeBlock(block) {
|
|
5465
5548
|
const results = await this.finalizeBlocks([block]);
|
|
@@ -5472,7 +5555,7 @@ var SimpleFinalizationRunner = class extends AbstractCreatableProvider {
|
|
|
5472
5555
|
return sortedBlocks.map((b) => b[0]._hash);
|
|
5473
5556
|
}
|
|
5474
5557
|
};
|
|
5475
|
-
__publicField(SimpleFinalizationRunner, "connectionTypes", ["lmdb", "mongo"]);
|
|
5558
|
+
__publicField(SimpleFinalizationRunner, "connectionTypes", ["lmdb", "mongo", "memory"]);
|
|
5476
5559
|
__publicField(SimpleFinalizationRunner, "defaultMoniker", FinalizationRunnerMoniker);
|
|
5477
5560
|
__publicField(SimpleFinalizationRunner, "dependencies", []);
|
|
5478
5561
|
__publicField(SimpleFinalizationRunner, "monikers", [FinalizationRunnerMoniker]);
|
|
@@ -5482,7 +5565,7 @@ SimpleFinalizationRunner = __decorateClass([
|
|
|
5482
5565
|
], SimpleFinalizationRunner);
|
|
5483
5566
|
|
|
5484
5567
|
// src/simple/finalization/SimpleFinalizationViewer.ts
|
|
5485
|
-
import { assertEx as
|
|
5568
|
+
import { assertEx as assertEx39 } from "@xylabs/sdk-js";
|
|
5486
5569
|
import {
|
|
5487
5570
|
asSignedHydratedBlockWithStorageMeta as asSignedHydratedBlockWithStorageMeta2,
|
|
5488
5571
|
ChainContractViewerMoniker as ChainContractViewerMoniker3,
|
|
@@ -5494,7 +5577,7 @@ var SimpleFinalizationViewer = class extends AbstractCreatableProvider {
|
|
|
5494
5577
|
_store;
|
|
5495
5578
|
_signedHydratedBlockCache;
|
|
5496
5579
|
get finalizedArchivist() {
|
|
5497
|
-
return this.params.finalizedArchivist;
|
|
5580
|
+
return assertEx39(this.params.finalizedArchivist, () => "finalizedArchivist is required \u2014 inject it or bind a connection");
|
|
5498
5581
|
}
|
|
5499
5582
|
get hydratedBlockCache() {
|
|
5500
5583
|
if (this._signedHydratedBlockCache) return this._signedHydratedBlockCache;
|
|
@@ -5509,9 +5592,11 @@ var SimpleFinalizationViewer = class extends AbstractCreatableProvider {
|
|
|
5509
5592
|
return this._store;
|
|
5510
5593
|
}
|
|
5511
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);
|
|
5512
5597
|
return {
|
|
5513
5598
|
...await super.paramsHandler(params),
|
|
5514
|
-
finalizedArchivist:
|
|
5599
|
+
finalizedArchivist: assertEx39(finalizedArchivist, () => "finalizedArchivist is required \u2014 inject it or bind a connection")
|
|
5515
5600
|
};
|
|
5516
5601
|
}
|
|
5517
5602
|
chainId() {
|
|
@@ -5519,19 +5604,20 @@ var SimpleFinalizationViewer = class extends AbstractCreatableProvider {
|
|
|
5519
5604
|
}
|
|
5520
5605
|
async createHandler() {
|
|
5521
5606
|
await super.createHandler();
|
|
5522
|
-
const
|
|
5523
|
-
|
|
5524
|
-
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 };
|
|
5525
5611
|
}
|
|
5526
5612
|
async head() {
|
|
5527
5613
|
return await this.spanAsync("head", async () => {
|
|
5528
|
-
const currentHead =
|
|
5614
|
+
const currentHead = assertEx39(await this.getCurrentHead(), () => "Could not find most recent block [currentBlock]");
|
|
5529
5615
|
const cache = this.hydratedBlockCache;
|
|
5530
5616
|
const block = await cache.get(currentHead._hash);
|
|
5531
5617
|
if (!block) {
|
|
5532
5618
|
this.logger?.error(`Could not find current block with hash ${currentHead._hash}`);
|
|
5533
5619
|
}
|
|
5534
|
-
return
|
|
5620
|
+
return assertEx39(block, () => "Could not find current block");
|
|
5535
5621
|
}, this.context);
|
|
5536
5622
|
}
|
|
5537
5623
|
async headBlock() {
|
|
@@ -5561,12 +5647,12 @@ var SimpleFinalizationViewer = class extends AbstractCreatableProvider {
|
|
|
5561
5647
|
}
|
|
5562
5648
|
async getCurrentHead() {
|
|
5563
5649
|
const chainArchivist = this.finalizedArchivist;
|
|
5564
|
-
const result =
|
|
5565
|
-
|
|
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");
|
|
5566
5652
|
return result;
|
|
5567
5653
|
}
|
|
5568
5654
|
};
|
|
5569
|
-
__publicField(SimpleFinalizationViewer, "connectionTypes", ["lmdb", "mongo"]);
|
|
5655
|
+
__publicField(SimpleFinalizationViewer, "connectionTypes", ["lmdb", "mongo", "memory"]);
|
|
5570
5656
|
__publicField(SimpleFinalizationViewer, "defaultMoniker", FinalizationViewerMoniker3);
|
|
5571
5657
|
__publicField(SimpleFinalizationViewer, "dependencies", [ChainContractViewerMoniker3]);
|
|
5572
5658
|
__publicField(SimpleFinalizationViewer, "monikers", [FinalizationViewerMoniker3]);
|
|
@@ -5594,7 +5680,7 @@ var SimpleXyoGateway = class _SimpleXyoGateway extends AbstractCreatableProvider
|
|
|
5594
5680
|
|
|
5595
5681
|
// src/simple/gateway/SimpleXyoGatewayRunner.ts
|
|
5596
5682
|
import {
|
|
5597
|
-
assertEx as
|
|
5683
|
+
assertEx as assertEx40,
|
|
5598
5684
|
BigIntToJsonZod,
|
|
5599
5685
|
isDefined as isDefined20
|
|
5600
5686
|
} from "@xylabs/sdk-js";
|
|
@@ -5627,7 +5713,7 @@ var SimpleXyoGatewayRunner = class _SimpleXyoGatewayRunner extends AbstractCreat
|
|
|
5627
5713
|
return this._signer;
|
|
5628
5714
|
}
|
|
5629
5715
|
async addPayloadsToChain(onChain, offChain, options) {
|
|
5630
|
-
const viewer =
|
|
5716
|
+
const viewer = assertEx40(this.connection.viewer, () => "No viewer available on connection");
|
|
5631
5717
|
const {
|
|
5632
5718
|
nbf,
|
|
5633
5719
|
exp,
|
|
@@ -5643,7 +5729,7 @@ var SimpleXyoGatewayRunner = class _SimpleXyoGatewayRunner extends AbstractCreat
|
|
|
5643
5729
|
async addTransactionToChain(tx, offChain = []) {
|
|
5644
5730
|
const connection = this.connection;
|
|
5645
5731
|
const signer = this.signer;
|
|
5646
|
-
const runner =
|
|
5732
|
+
const runner = assertEx40(connection.runner, () => "No runner available on connection");
|
|
5647
5733
|
let signedTx;
|
|
5648
5734
|
if (isSignedHydratedTransaction(tx)) {
|
|
5649
5735
|
const [bw, payloads] = tx;
|
|
@@ -5658,7 +5744,7 @@ var SimpleXyoGatewayRunner = class _SimpleXyoGatewayRunner extends AbstractCreat
|
|
|
5658
5744
|
}
|
|
5659
5745
|
async confirmSubmittedTransaction(txHash, options) {
|
|
5660
5746
|
return await confirmSubmittedTransaction(
|
|
5661
|
-
|
|
5747
|
+
assertEx40(this.connection.viewer, () => "Connection viewer is undefined"),
|
|
5662
5748
|
txHash,
|
|
5663
5749
|
options
|
|
5664
5750
|
);
|
|
@@ -5697,7 +5783,7 @@ var SimpleXyoGatewayRunner = class _SimpleXyoGatewayRunner extends AbstractCreat
|
|
|
5697
5783
|
|
|
5698
5784
|
// src/simple/mempool/SimpleMempoolRunner.ts
|
|
5699
5785
|
import {
|
|
5700
|
-
assertEx as
|
|
5786
|
+
assertEx as assertEx41,
|
|
5701
5787
|
exists as exists8
|
|
5702
5788
|
} from "@xylabs/sdk-js";
|
|
5703
5789
|
import { isPayloadBundle, PayloadBuilder as PayloadBuilder21 } from "@xyo-network/sdk-js";
|
|
@@ -5715,7 +5801,7 @@ import {
|
|
|
5715
5801
|
TransactionRejectionSchema,
|
|
5716
5802
|
TransactionValidationViewerMoniker
|
|
5717
5803
|
} from "@xyo-network/xl1-protocol-lib";
|
|
5718
|
-
import { Mutex } from "async-mutex";
|
|
5804
|
+
import { Mutex as Mutex2 } from "async-mutex";
|
|
5719
5805
|
var DEFAULT_SYNC_INTERVAL = 3e4;
|
|
5720
5806
|
var DEFAULT_SYNC_LIMIT = 100;
|
|
5721
5807
|
var ENFORCE_CAP_BATCH_SIZE = 1e3;
|
|
@@ -5732,7 +5818,7 @@ var SimpleMempoolRunner = class extends AbstractCreatableProvider {
|
|
|
5732
5818
|
_finalizationViewer;
|
|
5733
5819
|
_mempoolViewer;
|
|
5734
5820
|
_transactionValidationViewer;
|
|
5735
|
-
_syncMutex = new
|
|
5821
|
+
_syncMutex = new Mutex2();
|
|
5736
5822
|
_syncTimerId = null;
|
|
5737
5823
|
get blockValidationViewer() {
|
|
5738
5824
|
return this._blockValidationViewer;
|
|
@@ -5753,10 +5839,10 @@ var SimpleMempoolRunner = class extends AbstractCreatableProvider {
|
|
|
5753
5839
|
return this.params.maxPendingTransactions ?? 0;
|
|
5754
5840
|
}
|
|
5755
5841
|
get pendingBlocksArchivist() {
|
|
5756
|
-
return this.params.pendingBlocksArchivist;
|
|
5842
|
+
return assertEx41(this.params.pendingBlocksArchivist, () => "pendingBlocksArchivist is required \u2014 inject it or bind a connection");
|
|
5757
5843
|
}
|
|
5758
5844
|
get pendingTransactionsArchivist() {
|
|
5759
|
-
return this.params.pendingTransactionsArchivist;
|
|
5845
|
+
return assertEx41(this.params.pendingTransactionsArchivist, () => "pendingTransactionsArchivist is required \u2014 inject it or bind a connection");
|
|
5760
5846
|
}
|
|
5761
5847
|
get syncInterval() {
|
|
5762
5848
|
return this.params.syncInterval ?? DEFAULT_SYNC_INTERVAL;
|
|
@@ -5771,10 +5857,13 @@ var SimpleMempoolRunner = class extends AbstractCreatableProvider {
|
|
|
5771
5857
|
return this.params.validateOnSubmit ?? true;
|
|
5772
5858
|
}
|
|
5773
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);
|
|
5774
5863
|
return {
|
|
5775
5864
|
...await super.paramsHandler(params),
|
|
5776
|
-
pendingBlocksArchivist:
|
|
5777
|
-
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")
|
|
5778
5867
|
};
|
|
5779
5868
|
}
|
|
5780
5869
|
async createHandler() {
|
|
@@ -5813,7 +5902,7 @@ var SimpleMempoolRunner = class extends AbstractCreatableProvider {
|
|
|
5813
5902
|
remainingBlockMap.push(i);
|
|
5814
5903
|
return b;
|
|
5815
5904
|
}).filter(exists8);
|
|
5816
|
-
|
|
5905
|
+
assertEx41(
|
|
5817
5906
|
remainingBlockMap.length === remainingBlocks.length,
|
|
5818
5907
|
() => `remainingBlockMap length should match remainingBlocks length [${remainingBlockMap.length}/${remainingBlocks.length}]`
|
|
5819
5908
|
);
|
|
@@ -5876,7 +5965,7 @@ var SimpleMempoolRunner = class extends AbstractCreatableProvider {
|
|
|
5876
5965
|
remainingTransactionMap.push(i);
|
|
5877
5966
|
return t;
|
|
5878
5967
|
}).filter(exists8);
|
|
5879
|
-
|
|
5968
|
+
assertEx41(
|
|
5880
5969
|
remainingTransactionMap.length === remainingTransactions.length,
|
|
5881
5970
|
() => `remainingTransactionMap length should match remainingTransactions length [${remainingTransactionMap.length}/${remainingTransactions.length}]`
|
|
5882
5971
|
);
|
|
@@ -6118,7 +6207,7 @@ var SimpleMempoolRunner = class extends AbstractCreatableProvider {
|
|
|
6118
6207
|
this.logger?.debug(`Synced ${externalTxs.length} transactions from external mempool`);
|
|
6119
6208
|
}
|
|
6120
6209
|
};
|
|
6121
|
-
__publicField(SimpleMempoolRunner, "connectionTypes", ["lmdb", "mongo"]);
|
|
6210
|
+
__publicField(SimpleMempoolRunner, "connectionTypes", ["lmdb", "mongo", "memory"]);
|
|
6122
6211
|
__publicField(SimpleMempoolRunner, "defaultMoniker", MempoolRunnerMoniker);
|
|
6123
6212
|
__publicField(SimpleMempoolRunner, "dependencies", [FinalizationViewerMoniker4, BlockValidationViewerMoniker2, TransactionValidationViewerMoniker, ChainContractViewerMoniker4]);
|
|
6124
6213
|
__publicField(SimpleMempoolRunner, "monikers", [MempoolRunnerMoniker]);
|
|
@@ -6129,6 +6218,7 @@ SimpleMempoolRunner = __decorateClass([
|
|
|
6129
6218
|
|
|
6130
6219
|
// src/simple/mempool/SimpleMempoolViewer.ts
|
|
6131
6220
|
import {
|
|
6221
|
+
assertEx as assertEx42,
|
|
6132
6222
|
exists as exists9,
|
|
6133
6223
|
isDefined as isDefined21,
|
|
6134
6224
|
isHash as isHash2
|
|
@@ -6149,14 +6239,24 @@ var SimpleMempoolViewer = class extends AbstractCreatableProvider {
|
|
|
6149
6239
|
return this.params.handoutStatsTtlBlocks ?? DEFAULT_HANDOUT_STATS_TTL_BLOCKS;
|
|
6150
6240
|
}
|
|
6151
6241
|
get pendingBlocksArchivist() {
|
|
6152
|
-
return this.params.pendingBlocksArchivist;
|
|
6242
|
+
return assertEx42(this.params.pendingBlocksArchivist, () => "pendingBlocksArchivist is required \u2014 inject it or bind a connection");
|
|
6153
6243
|
}
|
|
6154
6244
|
get pendingTransactionsArchivist() {
|
|
6155
|
-
return this.params.pendingTransactionsArchivist;
|
|
6245
|
+
return assertEx42(this.params.pendingTransactionsArchivist, () => "pendingTransactionsArchivist is required \u2014 inject it or bind a connection");
|
|
6156
6246
|
}
|
|
6157
6247
|
get windowedBlockViewer() {
|
|
6158
6248
|
return this._windowedBlockViewer;
|
|
6159
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
|
+
}
|
|
6160
6260
|
async createHandler() {
|
|
6161
6261
|
await super.createHandler();
|
|
6162
6262
|
this._windowedBlockViewer = await this.locator.getInstance(WindowedBlockViewerMoniker);
|
|
@@ -6337,7 +6437,7 @@ var SimpleMempoolViewer = class extends AbstractCreatableProvider {
|
|
|
6337
6437
|
return deduplicateWithBundleBySigner(randomSelected).slice(0, effectiveLimit);
|
|
6338
6438
|
}
|
|
6339
6439
|
};
|
|
6340
|
-
__publicField(SimpleMempoolViewer, "connectionTypes", ["lmdb", "mongo"]);
|
|
6440
|
+
__publicField(SimpleMempoolViewer, "connectionTypes", ["lmdb", "mongo", "memory"]);
|
|
6341
6441
|
__publicField(SimpleMempoolViewer, "defaultMoniker", MempoolViewerMoniker2);
|
|
6342
6442
|
__publicField(SimpleMempoolViewer, "dependencies", [WindowedBlockViewerMoniker]);
|
|
6343
6443
|
__publicField(SimpleMempoolViewer, "monikers", [MempoolViewerMoniker2]);
|
|
@@ -6428,7 +6528,7 @@ var SimpleXyoNetwork = class {
|
|
|
6428
6528
|
};
|
|
6429
6529
|
|
|
6430
6530
|
// src/simple/permissions/SimpleXyoPermissions.ts
|
|
6431
|
-
import { assertEx as
|
|
6531
|
+
import { assertEx as assertEx43 } from "@xylabs/sdk-js";
|
|
6432
6532
|
var SimpleXyoPermissions = class {
|
|
6433
6533
|
invoker;
|
|
6434
6534
|
_store;
|
|
@@ -6437,7 +6537,7 @@ var SimpleXyoPermissions = class {
|
|
|
6437
6537
|
this.invoker = store.invoker;
|
|
6438
6538
|
}
|
|
6439
6539
|
get store() {
|
|
6440
|
-
return
|
|
6540
|
+
return assertEx43(this._store, () => "Store must be defined to get permissions");
|
|
6441
6541
|
}
|
|
6442
6542
|
async getPermissions() {
|
|
6443
6543
|
return await this.store.getPermissions();
|
|
@@ -6490,7 +6590,7 @@ var SimpleXyoPermissions = class {
|
|
|
6490
6590
|
};
|
|
6491
6591
|
|
|
6492
6592
|
// src/simple/permissions/store/MemoryPermissions.ts
|
|
6493
|
-
import { assertEx as
|
|
6593
|
+
import { assertEx as assertEx44 } from "@xylabs/sdk-js";
|
|
6494
6594
|
var MemoryPermissionsStore = class {
|
|
6495
6595
|
_invoker;
|
|
6496
6596
|
permissions = [];
|
|
@@ -6498,7 +6598,7 @@ var MemoryPermissionsStore = class {
|
|
|
6498
6598
|
this._invoker = invoker;
|
|
6499
6599
|
}
|
|
6500
6600
|
get invoker() {
|
|
6501
|
-
return
|
|
6601
|
+
return assertEx44(this._invoker, () => "Invoker must be defined to get permissions");
|
|
6502
6602
|
}
|
|
6503
6603
|
async getPermissions() {
|
|
6504
6604
|
await Promise.resolve();
|
|
@@ -6670,7 +6770,7 @@ SimpleStakeEventsViewer = __decorateClass([
|
|
|
6670
6770
|
], SimpleStakeEventsViewer);
|
|
6671
6771
|
|
|
6672
6772
|
// src/simple/StakeTotalsViewer/SimpleStakeTotalsViewer.ts
|
|
6673
|
-
import { assertEx as
|
|
6773
|
+
import { assertEx as assertEx45 } from "@xylabs/sdk-js";
|
|
6674
6774
|
import { asXyoAddress as asXyoAddress3 } from "@xyo-network/sdk-js";
|
|
6675
6775
|
import {
|
|
6676
6776
|
StakeTotalsViewerMoniker,
|
|
@@ -6714,7 +6814,7 @@ var SimpleStakeTotalsViewer = class extends AbstractCreatableProvider {
|
|
|
6714
6814
|
}
|
|
6715
6815
|
async createHandler() {
|
|
6716
6816
|
await super.createHandler();
|
|
6717
|
-
this._stakeViewer =
|
|
6817
|
+
this._stakeViewer = assertEx45(
|
|
6718
6818
|
await this.locateAndCreate(StakeViewerMoniker),
|
|
6719
6819
|
() => "Failed to create StakeViewer"
|
|
6720
6820
|
);
|
|
@@ -6770,14 +6870,14 @@ SimpleStakeTotalsViewer = __decorateClass([
|
|
|
6770
6870
|
], SimpleStakeTotalsViewer);
|
|
6771
6871
|
|
|
6772
6872
|
// src/simple/StakeViewer/SimpleStakeViewer.ts
|
|
6773
|
-
import { assertEx as
|
|
6873
|
+
import { assertEx as assertEx46, toAddress } from "@xylabs/sdk-js";
|
|
6774
6874
|
import { asXyoAddress as asXyoAddress4 } from "@xyo-network/sdk-js";
|
|
6775
6875
|
import { StakeEventsViewerMoniker as StakeEventsViewerMoniker2, StakeViewerMoniker as StakeViewerMoniker2 } from "@xyo-network/xl1-protocol-lib";
|
|
6776
6876
|
var SimpleStakeViewer = class extends AbstractCreatableProvider {
|
|
6777
6877
|
moniker = SimpleStakeViewer.defaultMoniker;
|
|
6778
6878
|
_chainStakeEventsViewer;
|
|
6779
6879
|
get stakeEvents() {
|
|
6780
|
-
return
|
|
6880
|
+
return assertEx46(this._chainStakeEventsViewer, () => "Stake events viewer not set");
|
|
6781
6881
|
}
|
|
6782
6882
|
get positions() {
|
|
6783
6883
|
return this.params.positions;
|
|
@@ -6817,7 +6917,7 @@ var SimpleStakeViewer = class extends AbstractCreatableProvider {
|
|
|
6817
6917
|
}
|
|
6818
6918
|
async createHandler() {
|
|
6819
6919
|
await super.createHandler();
|
|
6820
|
-
this._chainStakeEventsViewer =
|
|
6920
|
+
this._chainStakeEventsViewer = assertEx46(
|
|
6821
6921
|
await this.locateAndCreate(StakeEventsViewerMoniker2),
|
|
6822
6922
|
() => "Failed to create StakeEventsViewer"
|
|
6823
6923
|
);
|
|
@@ -6852,7 +6952,7 @@ var SimpleStakeViewer = class extends AbstractCreatableProvider {
|
|
|
6852
6952
|
return toAddress(toAddress(1n));
|
|
6853
6953
|
}
|
|
6854
6954
|
stakeById(id) {
|
|
6855
|
-
return
|
|
6955
|
+
return assertEx46(this.positions[id], () => new Error(`Stake with id ${id} not found`));
|
|
6856
6956
|
}
|
|
6857
6957
|
stakeByStaker(staker, slot) {
|
|
6858
6958
|
return this.positions.filter((s) => asXyoAddress4(s.staker) === asXyoAddress4(staker))[slot];
|
|
@@ -6956,7 +7056,7 @@ RestSyncViewer = __decorateClass([
|
|
|
6956
7056
|
// src/simple/timeSync2/SimpleTimeSyncViewer.ts
|
|
6957
7057
|
import {
|
|
6958
7058
|
asHash as asHash5,
|
|
6959
|
-
assertEx as
|
|
7059
|
+
assertEx as assertEx47,
|
|
6960
7060
|
isDefined as isDefined23
|
|
6961
7061
|
} from "@xylabs/sdk-js";
|
|
6962
7062
|
import {
|
|
@@ -6978,7 +7078,7 @@ var SimpleTimeSyncViewer = class extends AbstractCreatableProvider {
|
|
|
6978
7078
|
async convertTime(fromDomain, toDomain, from) {
|
|
6979
7079
|
switch (fromDomain) {
|
|
6980
7080
|
case "xl1": {
|
|
6981
|
-
const [block, payloads] =
|
|
7081
|
+
const [block, payloads] = assertEx47(await this.blockViewer.blockByNumber(asXL1BlockNumber11(from, true)), () => "Block not found");
|
|
6982
7082
|
const timeSchemaIndex = block.payload_schemas.indexOf(TimeSchema);
|
|
6983
7083
|
const hash = timeSchemaIndex === -1 ? void 0 : block.payload_hashes[timeSchemaIndex];
|
|
6984
7084
|
const timePayload = asTimePayload2(isDefined23(hash) ? payloads.find((p) => p._hash === hash) : void 0);
|
|
@@ -7034,10 +7134,10 @@ var SimpleTimeSyncViewer = class extends AbstractCreatableProvider {
|
|
|
7034
7134
|
return [Date.now(), null];
|
|
7035
7135
|
}
|
|
7036
7136
|
case "ethereum": {
|
|
7037
|
-
const provider =
|
|
7137
|
+
const provider = assertEx47(this.ethProvider, () => "Ethereum provider not configured");
|
|
7038
7138
|
const blockNumber = await provider.getBlockNumber() ?? 0;
|
|
7039
7139
|
const block = await provider.getBlock(blockNumber);
|
|
7040
|
-
const blockHash = asHash5(
|
|
7140
|
+
const blockHash = asHash5(assertEx47(block?.hash, () => "Block hash not found"), true);
|
|
7041
7141
|
return [blockNumber, blockHash];
|
|
7042
7142
|
}
|
|
7043
7143
|
default: {
|
|
@@ -7052,7 +7152,7 @@ var SimpleTimeSyncViewer = class extends AbstractCreatableProvider {
|
|
|
7052
7152
|
// this is for the previous block
|
|
7053
7153
|
xl1,
|
|
7054
7154
|
// this is for the previous block
|
|
7055
|
-
xl1Hash:
|
|
7155
|
+
xl1Hash: assertEx47(xl1Hash, () => "No xl1 hash available from time sync service"),
|
|
7056
7156
|
epoch: Date.now()
|
|
7057
7157
|
};
|
|
7058
7158
|
if (isDefined23(this.ethProvider)) {
|
|
@@ -7074,7 +7174,7 @@ SimpleTimeSyncViewer = __decorateClass([
|
|
|
7074
7174
|
], SimpleTimeSyncViewer);
|
|
7075
7175
|
|
|
7076
7176
|
// src/simple/transactionValidation/SimpleTransactionValidationViewer.ts
|
|
7077
|
-
import { assertEx as
|
|
7177
|
+
import { assertEx as assertEx48 } from "@xylabs/sdk-js";
|
|
7078
7178
|
import { PayloadBuilder as PayloadBuilder24 } from "@xyo-network/sdk-js";
|
|
7079
7179
|
import {
|
|
7080
7180
|
AccountBalanceViewerMoniker as AccountBalanceViewerMoniker3,
|
|
@@ -7128,7 +7228,7 @@ var SimpleTransactionValidationViewer = class extends AbstractCreatableProvider
|
|
|
7128
7228
|
let head;
|
|
7129
7229
|
if (isChainQualifiedHeadConfig6(config)) {
|
|
7130
7230
|
const headBlockResult = await this.blockViewer.blockByHash(config.head);
|
|
7131
|
-
head = headBlockResult == null ?
|
|
7231
|
+
head = headBlockResult == null ? assertEx48(
|
|
7132
7232
|
void 0,
|
|
7133
7233
|
() => `Specified a head that is not in the chain [${config.head}]`
|
|
7134
7234
|
) : headBlockResult[0];
|
|
@@ -7200,7 +7300,7 @@ SimpleTransactionValidationViewer = __decorateClass([
|
|
|
7200
7300
|
], SimpleTransactionValidationViewer);
|
|
7201
7301
|
|
|
7202
7302
|
// src/simple/TransactionViewer/SimpleTransactionViewer.ts
|
|
7203
|
-
import { assertEx as
|
|
7303
|
+
import { assertEx as assertEx49, exists as exists10 } from "@xylabs/sdk-js";
|
|
7204
7304
|
import { BoundWitnessSchema } from "@xyo-network/sdk-js";
|
|
7205
7305
|
import {
|
|
7206
7306
|
asSignedHydratedTransactionWithHashMeta,
|
|
@@ -7217,7 +7317,7 @@ var SimpleTransactionViewer = class extends AbstractCreatableProvider {
|
|
|
7217
7317
|
}
|
|
7218
7318
|
async byBlockHashAndIndex(blockHash, transactionIndex) {
|
|
7219
7319
|
return await this.spanAsync("byBlockHashAndIndex", async () => {
|
|
7220
|
-
|
|
7320
|
+
assertEx49(transactionIndex >= 0, () => "transactionIndex must be greater than or equal to 0");
|
|
7221
7321
|
try {
|
|
7222
7322
|
const block = await this.blockViewer.blockByHash(blockHash);
|
|
7223
7323
|
if (!block) return null;
|
|
@@ -7282,7 +7382,7 @@ SimpleTransactionViewer = __decorateClass([
|
|
|
7282
7382
|
|
|
7283
7383
|
// src/simple/windowedBlock/SimpleWindowedBlockViewer.ts
|
|
7284
7384
|
import {
|
|
7285
|
-
assertEx as
|
|
7385
|
+
assertEx as assertEx50,
|
|
7286
7386
|
exists as exists11,
|
|
7287
7387
|
isNull as isNull2
|
|
7288
7388
|
} from "@xylabs/sdk-js";
|
|
@@ -7293,7 +7393,7 @@ import {
|
|
|
7293
7393
|
stepSize as stepSize3,
|
|
7294
7394
|
WindowedBlockViewerMoniker as WindowedBlockViewerMoniker2
|
|
7295
7395
|
} from "@xyo-network/xl1-protocol-lib";
|
|
7296
|
-
import { Mutex as
|
|
7396
|
+
import { Mutex as Mutex3 } from "async-mutex";
|
|
7297
7397
|
var SimpleWindowedBlockViewer = class extends AbstractCreatableProvider {
|
|
7298
7398
|
moniker = WindowedBlockViewerMoniker2;
|
|
7299
7399
|
_blockHashMap;
|
|
@@ -7301,7 +7401,7 @@ var SimpleWindowedBlockViewer = class extends AbstractCreatableProvider {
|
|
|
7301
7401
|
// the external BlockViewer
|
|
7302
7402
|
_blockViewer;
|
|
7303
7403
|
_chain = [];
|
|
7304
|
-
_syncMutex = new
|
|
7404
|
+
_syncMutex = new Mutex3();
|
|
7305
7405
|
_timerId = null;
|
|
7306
7406
|
_transactionHashMap;
|
|
7307
7407
|
get maxWindowSize() {
|
|
@@ -7364,7 +7464,7 @@ var SimpleWindowedBlockViewer = class extends AbstractCreatableProvider {
|
|
|
7364
7464
|
}
|
|
7365
7465
|
async createHandler() {
|
|
7366
7466
|
await super.createHandler();
|
|
7367
|
-
this._blockViewer =
|
|
7467
|
+
this._blockViewer = assertEx50(
|
|
7368
7468
|
this.params.blockViewer ?? await this.locator.getInstance(BlockViewerMoniker7),
|
|
7369
7469
|
() => "BlockViewer instance is required"
|
|
7370
7470
|
);
|
|
@@ -7373,13 +7473,13 @@ var SimpleWindowedBlockViewer = class extends AbstractCreatableProvider {
|
|
|
7373
7473
|
this._transactionHashMap = new MemoryMap2();
|
|
7374
7474
|
}
|
|
7375
7475
|
currentBlock() {
|
|
7376
|
-
return
|
|
7476
|
+
return assertEx50(this._chain.at(-1));
|
|
7377
7477
|
}
|
|
7378
7478
|
currentBlockHash() {
|
|
7379
|
-
return
|
|
7479
|
+
return assertEx50(this._chain.at(-1)?.[0]._hash);
|
|
7380
7480
|
}
|
|
7381
7481
|
currentBlockNumber() {
|
|
7382
|
-
return
|
|
7482
|
+
return assertEx50(this._chain.at(-1)?.[0].block);
|
|
7383
7483
|
}
|
|
7384
7484
|
async payloadByHash(hash) {
|
|
7385
7485
|
const payloads = await this.payloadsByHash([hash]);
|
|
@@ -7540,12 +7640,12 @@ var RuntimeStatusMonitor = class extends LoggerStatusReporter {
|
|
|
7540
7640
|
};
|
|
7541
7641
|
|
|
7542
7642
|
// src/test/buildRandomChain.ts
|
|
7543
|
-
import { asAddress as asAddress2, assertEx as
|
|
7643
|
+
import { asAddress as asAddress2, assertEx as assertEx53 } from "@xylabs/sdk-js";
|
|
7544
7644
|
import {
|
|
7545
7645
|
Account as Account4,
|
|
7546
7646
|
asSchema as asSchema9,
|
|
7547
7647
|
IdSchema as IdSchema2,
|
|
7548
|
-
MemoryArchivist,
|
|
7648
|
+
MemoryArchivist as MemoryArchivist2,
|
|
7549
7649
|
PayloadBuilder as PayloadBuilder29
|
|
7550
7650
|
} from "@xyo-network/sdk-js";
|
|
7551
7651
|
import {
|
|
@@ -7559,7 +7659,7 @@ import {
|
|
|
7559
7659
|
} from "@xyo-network/xl1-protocol-lib";
|
|
7560
7660
|
|
|
7561
7661
|
// src/test/buildBlock.ts
|
|
7562
|
-
import { assertEx as
|
|
7662
|
+
import { assertEx as assertEx51, isDefined as isDefined24 } from "@xylabs/sdk-js";
|
|
7563
7663
|
import {
|
|
7564
7664
|
asAnyPayload as asAnyPayload5,
|
|
7565
7665
|
BoundWitnessBuilder as BoundWitnessBuilder3,
|
|
@@ -7642,7 +7742,7 @@ function buildStepHashes(blockNumber, inStepHashes, previousBlockHash, chainStep
|
|
|
7642
7742
|
const completedStepReward = calculateCompletedStepReward(i, stepRewardPoolBalance);
|
|
7643
7743
|
completedStepRewardTransfers.push(createTransferPayload(chainStepRewardAddress2, { [completedStepRewardHolderAddress]: completedStepReward }));
|
|
7644
7744
|
}
|
|
7645
|
-
step_hashes.push(
|
|
7745
|
+
step_hashes.push(assertEx51(previousBlockHash, () => `Previous block hash is required for step ${step} at block ${blockNumber}`));
|
|
7646
7746
|
} else if (isDefined24(inStepHashes.at(i))) {
|
|
7647
7747
|
step_hashes.push(inStepHashes[i]);
|
|
7648
7748
|
}
|
|
@@ -7696,7 +7796,7 @@ async function buildBlock(options) {
|
|
|
7696
7796
|
protocol
|
|
7697
7797
|
}).meta({ $epoch: Date.now(), $signatures: [] }).signers(signers).payloads(await PayloadBuilder25.addStorageMeta(payloads));
|
|
7698
7798
|
const [bw, txPayloads] = await builder.build();
|
|
7699
|
-
|
|
7799
|
+
assertEx51(isBlockBoundWitness(bw), () => "Build of BlockBoundWitness failed");
|
|
7700
7800
|
return [await PayloadBuilder25.addStorageMeta(bw), txPayloads.map((p) => asAnyPayload5(p, true))];
|
|
7701
7801
|
}
|
|
7702
7802
|
|
|
@@ -7717,7 +7817,7 @@ async function buildNextBlock(previousBlock, txs, blockPayloads, signers, chainS
|
|
|
7717
7817
|
}
|
|
7718
7818
|
|
|
7719
7819
|
// src/test/buildRandomGenesisBlock.ts
|
|
7720
|
-
import { asAddress, assertEx as
|
|
7820
|
+
import { asAddress, assertEx as assertEx52 } from "@xylabs/sdk-js";
|
|
7721
7821
|
import {
|
|
7722
7822
|
Account as Account3,
|
|
7723
7823
|
asAnyPayload as asAnyPayload6,
|
|
@@ -7761,7 +7861,7 @@ var buildRandomTransaction = async (chain, payloads, account, nbf = asXL1BlockNu
|
|
|
7761
7861
|
};
|
|
7762
7862
|
|
|
7763
7863
|
// src/test/buildRandomGenesisBlock.ts
|
|
7764
|
-
var TestChainId =
|
|
7864
|
+
var TestChainId = assertEx52(asAddress("c5fe2e6F6841Cbab12d8C0618Be2DF8C6156cC44"));
|
|
7765
7865
|
|
|
7766
7866
|
// src/test/createGenesisBlock.ts
|
|
7767
7867
|
import { PayloadBuilder as PayloadBuilder28 } from "@xyo-network/sdk-js";
|
|
@@ -7816,7 +7916,7 @@ var createGenesisBlock = async (initialBlockProducer, nextContractAddress, genes
|
|
|
7816
7916
|
};
|
|
7817
7917
|
|
|
7818
7918
|
// src/test/buildRandomChain.ts
|
|
7819
|
-
var TestGenesisBlockRewardAddress =
|
|
7919
|
+
var TestGenesisBlockRewardAddress = assertEx53(asAddress2("fa7f0bb865a4bfff3d5e2c726d3e063297014da9"));
|
|
7820
7920
|
var buildRandomChain = async (blockProducer, count = 10, previousBlock, chainId, transactionAccount, receiverAddresses) => {
|
|
7821
7921
|
const chainIdToUse = chainId ?? TestChainId;
|
|
7822
7922
|
const blocks = [];
|
|
@@ -7860,7 +7960,7 @@ var buildRandomChain = async (blockProducer, count = 10, previousBlock, chainId,
|
|
|
7860
7960
|
receiverAddress
|
|
7861
7961
|
));
|
|
7862
7962
|
}
|
|
7863
|
-
const previousBlock2 =
|
|
7963
|
+
const previousBlock2 = assertEx53(lastBlock?.[0], () => new Error("No last block"));
|
|
7864
7964
|
const block = await buildNextBlock(previousBlock2, txs, [], [blockProducer], transactionAccountToUse.address);
|
|
7865
7965
|
blocks.push(block);
|
|
7866
7966
|
remaining = remaining - 1;
|
|
@@ -7871,7 +7971,7 @@ var buildRandomChain = async (blockProducer, count = 10, previousBlock, chainId,
|
|
|
7871
7971
|
async function buildRandomChainArchivist(count = 20) {
|
|
7872
7972
|
const producerAccount = await Account4.random();
|
|
7873
7973
|
const blocks = await buildRandomChain(producerAccount, count);
|
|
7874
|
-
const archivist = await
|
|
7974
|
+
const archivist = await MemoryArchivist2.create();
|
|
7875
7975
|
const payloads = flattenHydratedBlocks(blocks);
|
|
7876
7976
|
await archivist.insert(payloads);
|
|
7877
7977
|
return archivist;
|
|
@@ -7921,13 +8021,13 @@ function getTestProviderContext2(config) {
|
|
|
7921
8021
|
}
|
|
7922
8022
|
|
|
7923
8023
|
// src/time/primitives/xl1BlockNumberToEthBlockNumber.ts
|
|
7924
|
-
import { assertEx as
|
|
8024
|
+
import { assertEx as assertEx54 } from "@xylabs/sdk-js";
|
|
7925
8025
|
import { asTimePayload as asTimePayload3, TimeSchema as TimeSchema2 } from "@xyo-network/xl1-protocol-lib";
|
|
7926
8026
|
async function xl1BlockNumberToEthBlockNumber(context, xl1BlockNumber) {
|
|
7927
8027
|
const blockHash = await hashFromBlockNumber(context, xl1BlockNumber);
|
|
7928
8028
|
const hydratedBlock = await hydrateBlock(context, blockHash);
|
|
7929
8029
|
const timePayload = asTimePayload3(hydratedBlock[1].find((p) => p.schema === TimeSchema2), { required: true });
|
|
7930
|
-
return
|
|
8030
|
+
return assertEx54(timePayload.ethereum, () => "No ethereum timestamp found on block");
|
|
7931
8031
|
}
|
|
7932
8032
|
|
|
7933
8033
|
// src/validation/lib/isLocalhost.ts
|
|
@@ -7980,11 +8080,13 @@ export {
|
|
|
7980
8080
|
ActorsConfigZod,
|
|
7981
8081
|
AddressPairSchema,
|
|
7982
8082
|
AmbiguousProviderError,
|
|
8083
|
+
ArchivistInstanceCache,
|
|
7983
8084
|
BalancesStepSummarySchema,
|
|
7984
8085
|
BaseConfigContextZod,
|
|
7985
8086
|
BaseConfigZod,
|
|
7986
8087
|
BoundWitnessHydrator,
|
|
7987
8088
|
BoundWitnessWithStorageMetaZod,
|
|
8089
|
+
CHAIN_ARCHIVIST_ROLE,
|
|
7988
8090
|
CHANGE_ADDRESS,
|
|
7989
8091
|
COIN_TYPES,
|
|
7990
8092
|
ChainIndexingServiceStateSchema,
|
|
@@ -8016,11 +8118,15 @@ export {
|
|
|
8016
8118
|
LmdbTransportConfigZod as LmdbConnectionConfigZod,
|
|
8017
8119
|
LmdbTransportConfigZod,
|
|
8018
8120
|
LoggerStatusReporter,
|
|
8121
|
+
MemoryArchivistFactory,
|
|
8019
8122
|
MemoryPermissionsStore,
|
|
8123
|
+
MemoryTransportConfigZod,
|
|
8020
8124
|
MissingCapabilityError,
|
|
8021
8125
|
MnemonicStringZod,
|
|
8022
8126
|
MongoTransportConfigZod as MongoConnectionConfigZod,
|
|
8023
8127
|
MongoTransportConfigZod,
|
|
8128
|
+
PENDING_BLOCKS_ARCHIVIST_ROLE,
|
|
8129
|
+
PENDING_TRANSACTIONS_ARCHIVIST_ROLE,
|
|
8024
8130
|
PRODUCER_DIVERSITY_BONUS,
|
|
8025
8131
|
PayloadLocator,
|
|
8026
8132
|
PostMessageRpcRemoteConfigZod,
|
|
@@ -8031,6 +8137,8 @@ export {
|
|
|
8031
8137
|
ProviderFactoryLocator,
|
|
8032
8138
|
ProviderFactoryLocatorZod,
|
|
8033
8139
|
ProvidersConfigZod,
|
|
8140
|
+
REJECTED_BLOCKS_ARCHIVIST_ROLE,
|
|
8141
|
+
REJECTED_TRANSACTIONS_ARCHIVIST_ROLE,
|
|
8034
8142
|
RemoteConfigZod,
|
|
8035
8143
|
RestTransportConfigZod as RestConnectionConfigZod,
|
|
8036
8144
|
RestDataLakeConfigZod,
|
|
@@ -8104,6 +8212,7 @@ export {
|
|
|
8104
8212
|
allHashesPresent,
|
|
8105
8213
|
allStakersForRange,
|
|
8106
8214
|
allStakersForStep,
|
|
8215
|
+
archivistCacheKey,
|
|
8107
8216
|
asActorConfig,
|
|
8108
8217
|
asActorConfigContext,
|
|
8109
8218
|
asAddressPairPayload,
|
|
@@ -8150,6 +8259,7 @@ export {
|
|
|
8150
8259
|
calculateTimeRate,
|
|
8151
8260
|
chainStepRewardAddress,
|
|
8152
8261
|
confirmSubmittedTransaction,
|
|
8262
|
+
connectArchivist,
|
|
8153
8263
|
connectionSubsetBySurface,
|
|
8154
8264
|
contextCache,
|
|
8155
8265
|
crackOperation,
|