@xyo-network/chain-services 1.16.26 → 1.17.0
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/AccountBalance/BaseAccountBalanceService.d.ts +2 -3
- package/dist/neutral/AccountBalance/BaseAccountBalanceService.d.ts.map +1 -1
- package/dist/neutral/AccountBalance/accountBalanceServiceFromArchivist.d.ts.map +1 -1
- package/dist/neutral/BlockProducer/BaseBlockProducerService.d.ts +4 -4
- package/dist/neutral/BlockProducer/BaseBlockProducerService.d.ts.map +1 -1
- package/dist/neutral/ChainBlockNumberIteration/ChainBlockNumberIterationService.d.ts +20 -10
- package/dist/neutral/ChainBlockNumberIteration/ChainBlockNumberIterationService.d.ts.map +1 -1
- package/dist/neutral/ChainService/Evm/Evm.d.ts +4 -4
- package/dist/neutral/ChainService/Evm/Evm.d.ts.map +1 -1
- package/dist/neutral/ChainService/Memory/Memory.d.ts +4 -4
- package/dist/neutral/ChainService/Memory/Memory.d.ts.map +1 -1
- package/dist/neutral/ChainValidator/XyoValidator.d.ts +4 -4
- package/dist/neutral/ChainValidator/XyoValidator.d.ts.map +1 -1
- package/dist/neutral/Election/BaseElectionService.d.ts +3 -3
- package/dist/neutral/Election/BaseElectionService.d.ts.map +1 -1
- package/dist/neutral/PendingTransactions/BasePendingTransactions.d.ts +3 -4
- package/dist/neutral/PendingTransactions/BasePendingTransactions.d.ts.map +1 -1
- package/dist/neutral/StakeIntent/XyoStakeIntentService.d.ts +3 -3
- package/dist/neutral/StakeIntent/XyoStakeIntentService.d.ts.map +1 -1
- package/dist/neutral/Time/BaseTimeSyncService.d.ts +3 -6
- package/dist/neutral/Time/BaseTimeSyncService.d.ts.map +1 -1
- package/dist/neutral/blockViewerFromChainIteratorAndArchivist.d.ts.map +1 -1
- package/dist/neutral/index.mjs +115 -67
- package/dist/neutral/index.mjs.map +1 -1
- package/package.json +10 -10
- package/src/AccountBalance/BaseAccountBalanceService.ts +2 -4
- package/src/AccountBalance/accountBalanceServiceFromArchivist.ts +3 -2
- package/src/BlockProducer/BaseBlockProducerService.ts +5 -5
- package/src/ChainBlockNumberIteration/ChainBlockNumberIterationService.ts +61 -5
- package/src/ChainService/Evm/Evm.ts +34 -32
- package/src/ChainService/Memory/Memory.ts +9 -7
- package/src/ChainValidator/XyoValidator.ts +6 -6
- package/src/Election/BaseElectionService.ts +5 -4
- package/src/PendingTransactions/BasePendingTransactions.ts +6 -5
- package/src/StakeIntent/XyoStakeIntentService.ts +9 -13
- package/src/Time/BaseTimeSyncService.ts +6 -16
- package/src/blockViewerFromChainIteratorAndArchivist.ts +12 -0
package/dist/neutral/index.mjs
CHANGED
|
@@ -3,9 +3,8 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
|
|
|
3
3
|
|
|
4
4
|
// src/AccountBalance/accountBalanceServiceFromArchivist.ts
|
|
5
5
|
import { assertEx as assertEx2 } from "@xylabs/sdk-js";
|
|
6
|
-
import { findMostRecentBlock } from "@xyo-network/chain-protocol";
|
|
7
6
|
import { StepSizes } from "@xyo-network/xl1-protocol";
|
|
8
|
-
import { LruCacheMap, readPayloadMapFromStore } from "@xyo-network/xl1-protocol-sdk";
|
|
7
|
+
import { findMostRecentBlock, LruCacheMap, readPayloadMapFromStore } from "@xyo-network/xl1-protocol-sdk";
|
|
9
8
|
import { Semaphore } from "async-mutex";
|
|
10
9
|
|
|
11
10
|
// src/AccountBalance/BaseAccountBalanceService.ts
|
|
@@ -129,7 +128,7 @@ var BaseAccountBalanceService = class extends BaseService {
|
|
|
129
128
|
async createHandler() {
|
|
130
129
|
this.accountBalanceViewer = await SimpleAccountBalanceViewer.create({
|
|
131
130
|
context: this.params.context,
|
|
132
|
-
|
|
131
|
+
transfersSummaryContext: this.params.transfersSummaryContext,
|
|
133
132
|
blockViewer: this.blockViewer
|
|
134
133
|
});
|
|
135
134
|
}
|
|
@@ -309,8 +308,8 @@ var BaseBlockProducerService = class _BaseBlockProducerService extends BaseServi
|
|
|
309
308
|
get balanceService() {
|
|
310
309
|
return assertEx4(this.params.balanceService, () => "balanceService is required");
|
|
311
310
|
}
|
|
312
|
-
get
|
|
313
|
-
return assertEx4(this.params.
|
|
311
|
+
get blockViewer() {
|
|
312
|
+
return assertEx4(this.params.blockViewer, () => "blockViewer is required");
|
|
314
313
|
}
|
|
315
314
|
get chainId() {
|
|
316
315
|
return assertEx4(this.params.chainId, () => "chainId is required");
|
|
@@ -401,7 +400,9 @@ var BaseBlockProducerService = class _BaseBlockProducerService extends BaseServi
|
|
|
401
400
|
const { block: previousBlock } = assertEx4(asBlockBoundWitness(head), () => "Invalid head block");
|
|
402
401
|
const nextBlock = previousBlock + 1;
|
|
403
402
|
const nextBlockTransactionsStart = Date.now();
|
|
404
|
-
const nextBlockTransactions = await this.pendingTransactionsService.
|
|
403
|
+
const nextBlockTransactions = await this.pendingTransactionsService.pendingTransactions({
|
|
404
|
+
limit: _BaseBlockProducerService.DefaultBlockSize
|
|
405
|
+
});
|
|
405
406
|
const nextBlockTransactionsDuration = Date.now() - nextBlockTransactionsStart;
|
|
406
407
|
if (nextBlockTransactionsDuration > 200) {
|
|
407
408
|
this.logger?.warn(`[Slow] Fetched ${nextBlockTransactions.length} pending transactions in ${nextBlockTransactionsDuration}ms}`);
|
|
@@ -664,6 +665,18 @@ function blockViewerFromChainIteratorAndArchivist(chainIterator, chainArchivist)
|
|
|
664
665
|
}
|
|
665
666
|
return results;
|
|
666
667
|
}, "blocksByHash"),
|
|
668
|
+
blocksByNumber: /* @__PURE__ */ __name(async function(number, limit = 10) {
|
|
669
|
+
const results = [];
|
|
670
|
+
for (let i = 0; i < limit; i++) {
|
|
671
|
+
const block = await this.blockByNumber(number);
|
|
672
|
+
if (block) {
|
|
673
|
+
results.push(block);
|
|
674
|
+
} else {
|
|
675
|
+
break;
|
|
676
|
+
}
|
|
677
|
+
}
|
|
678
|
+
return results;
|
|
679
|
+
}, "blocksByNumber"),
|
|
667
680
|
currentBlock: /* @__PURE__ */ __name(async function() {
|
|
668
681
|
const head = await chainIterator.head();
|
|
669
682
|
return this.blockByHash(head._hash);
|
|
@@ -684,7 +697,8 @@ __name(blockViewerFromChainIteratorAndArchivist, "blockViewerFromChainIteratorAn
|
|
|
684
697
|
// src/ChainBlockNumberIteration/ChainBlockNumberIterationService.ts
|
|
685
698
|
import { assertEx as assertEx7, isDefined as isDefined3, isNull, isUndefined } from "@xylabs/sdk-js";
|
|
686
699
|
import { PayloadBuilder as PayloadBuilder4 } from "@xyo-network/payload-builder";
|
|
687
|
-
import { asBlockBoundWitness as asBlockBoundWitness2, asBlockBoundWitnessWithStorageMeta, isBlockBoundWitnessWithHashMeta } from "@xyo-network/xl1-protocol";
|
|
700
|
+
import { asBlockBoundWitness as asBlockBoundWitness2, asBlockBoundWitnessWithStorageMeta, asSignedHydratedBlockWithHashMeta, asXL1BlockNumber, isBlockBoundWitnessWithHashMeta } from "@xyo-network/xl1-protocol";
|
|
701
|
+
import { hydrateBlock } from "@xyo-network/xl1-protocol-sdk";
|
|
688
702
|
import { LRUCache } from "lru-cache";
|
|
689
703
|
var ChainBlockNumberIterationService = class extends BaseService {
|
|
690
704
|
static {
|
|
@@ -700,6 +714,50 @@ var ChainBlockNumberIterationService = class extends BaseService {
|
|
|
700
714
|
get chainMap() {
|
|
701
715
|
return assertEx7(this.params.chainMap);
|
|
702
716
|
}
|
|
717
|
+
get chainStoreRead() {
|
|
718
|
+
return {
|
|
719
|
+
chainMap: this.chainMap
|
|
720
|
+
};
|
|
721
|
+
}
|
|
722
|
+
async blockByHash(hash) {
|
|
723
|
+
return asSignedHydratedBlockWithHashMeta(await hydrateBlock(this.chainStoreRead, hash)) ?? null;
|
|
724
|
+
}
|
|
725
|
+
async blockByNumber(block) {
|
|
726
|
+
return asSignedHydratedBlockWithHashMeta(await this.get(block)) ?? null;
|
|
727
|
+
}
|
|
728
|
+
async blocksByHash(hash, limit = 100) {
|
|
729
|
+
const results = [];
|
|
730
|
+
let currentBlock = await this.blockByHash(hash);
|
|
731
|
+
while (currentBlock !== null && (isUndefined(limit) || results.length < limit)) {
|
|
732
|
+
results.push(currentBlock);
|
|
733
|
+
const previousHash = currentBlock[0].previous;
|
|
734
|
+
if (isNull(previousHash)) break;
|
|
735
|
+
currentBlock = await this.blockByHash(previousHash);
|
|
736
|
+
}
|
|
737
|
+
return results;
|
|
738
|
+
}
|
|
739
|
+
async blocksByNumber(blockNumber, limit = 100) {
|
|
740
|
+
const results = [];
|
|
741
|
+
let currentBlock = await this.blockByNumber(blockNumber);
|
|
742
|
+
while (currentBlock !== null && (isUndefined(limit) || results.length < limit)) {
|
|
743
|
+
results.push(currentBlock);
|
|
744
|
+
if (currentBlock[0].block === 0) break;
|
|
745
|
+
const previousNumber = asXL1BlockNumber(currentBlock[0].block - 1, true);
|
|
746
|
+
currentBlock = await this.blockByNumber(previousNumber);
|
|
747
|
+
}
|
|
748
|
+
return results;
|
|
749
|
+
}
|
|
750
|
+
async currentBlock() {
|
|
751
|
+
return assertEx7(await this.blockByHash(await this.currentBlockHash()), () => "Current block not found");
|
|
752
|
+
}
|
|
753
|
+
async currentBlockHash() {
|
|
754
|
+
const head = assertEx7(await this.head(), () => "Head is not set");
|
|
755
|
+
return head._hash;
|
|
756
|
+
}
|
|
757
|
+
async currentBlockNumber() {
|
|
758
|
+
const head = assertEx7(await this.head(), () => "Head is not set");
|
|
759
|
+
return head.block;
|
|
760
|
+
}
|
|
703
761
|
async get(block) {
|
|
704
762
|
const head = await this.head();
|
|
705
763
|
assertEx7(head.block >= block, () => `Block requested is newer than the current head [${block}]`);
|
|
@@ -781,71 +839,71 @@ var EvmChainService = class extends BaseService {
|
|
|
781
839
|
static {
|
|
782
840
|
__name(this, "EvmChainService");
|
|
783
841
|
}
|
|
784
|
-
get chainId() {
|
|
785
|
-
return assertEx8(this.params.id);
|
|
786
|
-
}
|
|
787
|
-
get contract() {
|
|
788
|
-
if (this.params.contract === void 0) {
|
|
789
|
-
this.params.contract = StakedXyoChainFactory.connect(toEthAddress2(this.chainId), this.params.runner);
|
|
790
|
-
}
|
|
791
|
-
return assertEx8(this.params.contract);
|
|
792
|
-
}
|
|
793
842
|
get runner() {
|
|
794
843
|
return assertEx8(this.params.runner);
|
|
795
844
|
}
|
|
796
845
|
async active() {
|
|
797
|
-
return await this.contract.active();
|
|
846
|
+
return await (await this.contract()).active();
|
|
798
847
|
}
|
|
799
848
|
async activeByStaked(staked) {
|
|
800
|
-
return await this.contract.activeByAddressStaked(getAddress(toEthAddress2(staked)));
|
|
849
|
+
return await (await this.contract()).activeByAddressStaked(getAddress(toEthAddress2(staked)));
|
|
801
850
|
}
|
|
802
851
|
async activeByStaker(address) {
|
|
803
|
-
return await this.contract.activeByStaker(getAddress(toEthAddress2(address)));
|
|
852
|
+
return await (await this.contract()).activeByStaker(getAddress(toEthAddress2(address)));
|
|
804
853
|
}
|
|
805
854
|
async addStake(staked, amount) {
|
|
806
|
-
const result = await this.contract.addStake(getAddress(toEthAddress2(staked)), amount);
|
|
855
|
+
const result = await (await this.contract()).addStake(getAddress(toEthAddress2(staked)), amount);
|
|
807
856
|
await result.wait();
|
|
808
857
|
return true;
|
|
809
858
|
}
|
|
859
|
+
chainId() {
|
|
860
|
+
return assertEx8(this.params.id);
|
|
861
|
+
}
|
|
862
|
+
async contract() {
|
|
863
|
+
if (this.params.contract === void 0) {
|
|
864
|
+
this.params.contract = StakedXyoChainFactory.connect(toEthAddress2(await this.chainId()), this.params.runner);
|
|
865
|
+
}
|
|
866
|
+
return assertEx8(this.params.contract);
|
|
867
|
+
}
|
|
810
868
|
async forkedAtBlockNumber() {
|
|
811
|
-
return await this.contract.forkedAtBlockNumber();
|
|
869
|
+
return await (await this.contract()).forkedAtBlockNumber();
|
|
812
870
|
}
|
|
813
871
|
async forkedAtHash() {
|
|
814
|
-
return await this.contract.forkedAtHash();
|
|
872
|
+
return await (await this.contract()).forkedAtHash();
|
|
815
873
|
}
|
|
816
874
|
async forkedChainId() {
|
|
817
|
-
return toAddress(await this.contract.forkedChainId());
|
|
875
|
+
return toAddress(await (await this.contract()).forkedChainId());
|
|
818
876
|
}
|
|
819
877
|
async minWithdrawalBlocks() {
|
|
820
|
-
return await this.contract.minWithdrawalBlocks();
|
|
878
|
+
return await (await this.contract()).minWithdrawalBlocks();
|
|
821
879
|
}
|
|
822
880
|
async pending() {
|
|
823
|
-
return await this.contract.pending();
|
|
881
|
+
return await (await this.contract()).pending();
|
|
824
882
|
}
|
|
825
883
|
async pendingByStaker(staker) {
|
|
826
|
-
return await this.contract.pendingByStaker(getAddress(toEthAddress2(staker)));
|
|
884
|
+
return await (await this.contract()).pendingByStaker(getAddress(toEthAddress2(staker)));
|
|
827
885
|
}
|
|
828
886
|
async removeStake(slot) {
|
|
829
|
-
const result = await this.contract.removeStake(slot);
|
|
887
|
+
const result = await (await this.contract()).removeStake(slot);
|
|
830
888
|
await result.wait();
|
|
831
889
|
return true;
|
|
832
890
|
}
|
|
833
891
|
async rewardsContract() {
|
|
834
|
-
return await this.contract.rewardsContract();
|
|
892
|
+
return await (await this.contract()).rewardsContract();
|
|
835
893
|
}
|
|
836
894
|
async stakingTokenAddress() {
|
|
837
|
-
return await this.contract.stakingTokenAddress();
|
|
895
|
+
return await (await this.contract()).stakingTokenAddress();
|
|
838
896
|
}
|
|
839
897
|
async withdrawStake(slot) {
|
|
840
|
-
const result = await this.contract.withdrawStake(slot);
|
|
898
|
+
const result = await (await this.contract()).withdrawStake(slot);
|
|
841
899
|
await result.wait();
|
|
842
900
|
return true;
|
|
843
901
|
}
|
|
844
902
|
async withdrawn() {
|
|
845
|
-
return await this.contract.withdrawn();
|
|
903
|
+
return await (await this.contract()).withdrawn();
|
|
846
904
|
}
|
|
847
905
|
async withdrawnByStaker(staker) {
|
|
848
|
-
return await this.contract.withdrawnByStaker(getAddress(staker));
|
|
906
|
+
return await (await this.contract()).withdrawnByStaker(getAddress(staker));
|
|
849
907
|
}
|
|
850
908
|
};
|
|
851
909
|
|
|
@@ -857,9 +915,6 @@ var MemoryChainService = class extends BaseService {
|
|
|
857
915
|
}
|
|
858
916
|
_chainId;
|
|
859
917
|
_simulatedStake = 1n;
|
|
860
|
-
get chainId() {
|
|
861
|
-
return assertEx9(this._chainId, () => "Chain ID not set");
|
|
862
|
-
}
|
|
863
918
|
async active() {
|
|
864
919
|
return await Promise.resolve(this._simulatedStake);
|
|
865
920
|
}
|
|
@@ -872,6 +927,9 @@ var MemoryChainService = class extends BaseService {
|
|
|
872
927
|
async addStake(_staked, _amount) {
|
|
873
928
|
return await Promise.resolve(true);
|
|
874
929
|
}
|
|
930
|
+
chainId() {
|
|
931
|
+
return assertEx9(this._chainId, () => "Chain ID not set");
|
|
932
|
+
}
|
|
875
933
|
createHandler() {
|
|
876
934
|
const { minStake = 1 } = this.params.config.producer ?? {};
|
|
877
935
|
this._simulatedStake = BigInt(minStake);
|
|
@@ -937,8 +995,8 @@ var XyoValidator = class extends BaseService {
|
|
|
937
995
|
get account() {
|
|
938
996
|
return assertEx10(this.params.account, () => "account is required");
|
|
939
997
|
}
|
|
940
|
-
get
|
|
941
|
-
return assertEx10(this.params.
|
|
998
|
+
get blockViewer() {
|
|
999
|
+
return assertEx10(this.params.blockViewer, () => "blockViewer is required");
|
|
942
1000
|
}
|
|
943
1001
|
get chainInfo() {
|
|
944
1002
|
return assertEx10(this.params.chainId, () => "chainInfo is required");
|
|
@@ -958,9 +1016,7 @@ var XyoValidator = class extends BaseService {
|
|
|
958
1016
|
// TODO: Move to validator and inherit this class from validator
|
|
959
1017
|
async validatePendingTransaction(hydratedTransaction) {
|
|
960
1018
|
const [tx] = hydratedTransaction;
|
|
961
|
-
if (
|
|
962
|
-
tx._hash
|
|
963
|
-
])).length > 0) return false;
|
|
1019
|
+
if (await this.blockViewer.blockByHash(tx._hash) !== void 0) return false;
|
|
964
1020
|
return await Promise.resolve(true);
|
|
965
1021
|
}
|
|
966
1022
|
};
|
|
@@ -982,8 +1038,8 @@ var BaseElectionService = class extends BaseService {
|
|
|
982
1038
|
static {
|
|
983
1039
|
__name(this, "BaseElectionService");
|
|
984
1040
|
}
|
|
985
|
-
get
|
|
986
|
-
return assertEx11(this.params.
|
|
1041
|
+
get blockViewer() {
|
|
1042
|
+
return assertEx11(this.params.blockViewer, () => "No block viewer");
|
|
987
1043
|
}
|
|
988
1044
|
get chainStakeViewer() {
|
|
989
1045
|
return assertEx11(this.params.chainStakeViewer, () => "No chain stake viewer");
|
|
@@ -1086,8 +1142,8 @@ BaseNetworkStakeStepRewardService = _ts_decorate10([
|
|
|
1086
1142
|
import { ValueType } from "@opentelemetry/api";
|
|
1087
1143
|
import { assertEx as assertEx12, creatable as creatable11, exists as exists2, filterAs, filterAsync, forget, isDefined as isDefined4, isUndefined as isUndefined2 } from "@xylabs/sdk-js";
|
|
1088
1144
|
import { MemoryArchivist } from "@xyo-network/archivist-memory";
|
|
1089
|
-
import {
|
|
1090
|
-
import {
|
|
1145
|
+
import { asBlockBoundWitnessWithHashMeta, asXL1BlockNumber as asXL1BlockNumber2, isTransactionBoundWitnessWithStorageMeta } from "@xyo-network/xl1-protocol";
|
|
1146
|
+
import { findMostRecentBlock as findMostRecentBlock2 } from "@xyo-network/xl1-protocol-sdk";
|
|
1091
1147
|
import { TransactionJsonSchemaValidator, validateTransaction } from "@xyo-network/xl1-validation";
|
|
1092
1148
|
import { Mutex as Mutex2 } from "async-mutex";
|
|
1093
1149
|
|
|
@@ -1221,12 +1277,12 @@ var BasePendingTransactionsService = class _BasePendingTransactionsService exten
|
|
|
1221
1277
|
observer.observe(this.pendingTransactionsCount);
|
|
1222
1278
|
});
|
|
1223
1279
|
}
|
|
1224
|
-
async
|
|
1280
|
+
async pendingTransactions({ limit = 100 } = {}) {
|
|
1225
1281
|
return await this.spanAsync("getPendingTransactions", async () => {
|
|
1226
1282
|
return await this._updateCuratedPendingTransactionsArchivistMutex.runExclusive(async () => {
|
|
1227
|
-
let
|
|
1228
|
-
|
|
1229
|
-
|
|
1283
|
+
let lastHead = filterAs(await this.chainArchivist.next({
|
|
1284
|
+
limit: 100
|
|
1285
|
+
}), (x) => asBlockBoundWitnessWithHashMeta(x)).at(-1);
|
|
1230
1286
|
if (isUndefined2(lastHead)) return [];
|
|
1231
1287
|
await this.pruneCuratedPendingTransactionsArchivist(lastHead._hash);
|
|
1232
1288
|
const foundPendingTransactions = [];
|
|
@@ -1241,7 +1297,7 @@ var BasePendingTransactionsService = class _BasePendingTransactionsService exten
|
|
|
1241
1297
|
cursor = pendingBundledTransactions.at(-1)?._sequence;
|
|
1242
1298
|
const undeletedTransactionBundles = pendingBundledTransactions.filter((tx) => !this._removablePendingTransactionHashes.has(tx.root));
|
|
1243
1299
|
const transactions = (await Promise.all(undeletedTransactionBundles.map((p) => bundledPayloadToHydratedTransaction(p)))).filter(exists2);
|
|
1244
|
-
const activeTransactions = transactions.filter(isTransactionActive(
|
|
1300
|
+
const activeTransactions = transactions.filter(isTransactionActive(asXL1BlockNumber2(lastHead.block + 1, true)));
|
|
1245
1301
|
const txValidationResults = await Promise.all(activeTransactions.map(async (tx) => [
|
|
1246
1302
|
tx,
|
|
1247
1303
|
await validateTransaction(tx, {
|
|
@@ -1347,7 +1403,7 @@ var BasePendingTransactionsService = class _BasePendingTransactionsService exten
|
|
|
1347
1403
|
foundPendingTransactionsToDeleteHashes.push(...deletedTransactionBundles.map((tx) => tx._hash).filter(exists2));
|
|
1348
1404
|
const undeletedTransactionBundles = pendingBundledTransactions.filter((tx) => !this._removablePendingTransactionHashes.has(tx.root));
|
|
1349
1405
|
const transactions = (await Promise.all(undeletedTransactionBundles.map((p) => bundledPayloadToHydratedTransaction(p)))).filter(exists2);
|
|
1350
|
-
const expiredTransactions = transactions.filter(isTransactionExpired(
|
|
1406
|
+
const expiredTransactions = transactions.filter(isTransactionExpired(asXL1BlockNumber2(lastHead.block + 1, true)));
|
|
1351
1407
|
const expiredBundleHashes = expiredTransactions.map((expiredHydratedTx) => (
|
|
1352
1408
|
// Find the corresponding payload bundle hash for the expired transaction
|
|
1353
1409
|
pendingBundledTransactions.find((bundledTx) => bundledTx.root === expiredHydratedTx[0]._hash)?._hash
|
|
@@ -1472,12 +1528,12 @@ var XyoStakeIntentService = class extends BaseService {
|
|
|
1472
1528
|
max: STAKE_CACHE_MAX_ENTRIES
|
|
1473
1529
|
});
|
|
1474
1530
|
_updateMutex = new Mutex3();
|
|
1531
|
+
get blockViewer() {
|
|
1532
|
+
return assertEx13(this.params.blockViewer, () => "blockViewer not set");
|
|
1533
|
+
}
|
|
1475
1534
|
get chainArchivist() {
|
|
1476
1535
|
return assertEx13(this.params.chainArchivist, () => "chainArchivist not set");
|
|
1477
1536
|
}
|
|
1478
|
-
get chainIterator() {
|
|
1479
|
-
return assertEx13(this.params.chainIterator, () => "chainIterator not set");
|
|
1480
|
-
}
|
|
1481
1537
|
get chainStakeViewer() {
|
|
1482
1538
|
return assertEx13(this.params.chainStakeViewer, () => "chainStakeViewer not set");
|
|
1483
1539
|
}
|
|
@@ -1485,13 +1541,9 @@ var XyoStakeIntentService = class extends BaseService {
|
|
|
1485
1541
|
return assertEx13(this.params.stakeIntentStateArchivist, () => "stakeIntentStateArchivist not set");
|
|
1486
1542
|
}
|
|
1487
1543
|
async createHandler() {
|
|
1488
|
-
this.
|
|
1489
|
-
await this.updateIndex();
|
|
1490
|
-
});
|
|
1491
|
-
const head = await this.chainIterator.head();
|
|
1544
|
+
const head = await this.blockViewer.currentBlock();
|
|
1492
1545
|
if (isUndefined3(head)) return;
|
|
1493
|
-
|
|
1494
|
-
await this.recoverState(headHash);
|
|
1546
|
+
await this.recoverState(head[0]._hash);
|
|
1495
1547
|
}
|
|
1496
1548
|
async getDeclaredCandidateRanges(address, intent) {
|
|
1497
1549
|
await Promise.resolve();
|
|
@@ -1607,7 +1659,7 @@ var XyoStakeIntentService = class extends BaseService {
|
|
|
1607
1659
|
}
|
|
1608
1660
|
await this._updateMutex.runExclusive(async () => {
|
|
1609
1661
|
return await this.spanAsync("updateIndex", async () => {
|
|
1610
|
-
const currentHead = await this.
|
|
1662
|
+
const currentHead = (await this.blockViewer.currentBlock())[0];
|
|
1611
1663
|
if (isUndefined3(currentHead)) return;
|
|
1612
1664
|
return await timeBudget("XyoStakeIntentService.updateIndex", console, async () => {
|
|
1613
1665
|
const currentHeadHash = currentHead._hash;
|
|
@@ -1679,11 +1731,8 @@ var BaseTimeSyncService = class extends BaseService {
|
|
|
1679
1731
|
__name(this, "BaseTimeSyncService");
|
|
1680
1732
|
}
|
|
1681
1733
|
timeSyncViewer;
|
|
1682
|
-
get
|
|
1683
|
-
return this.params.
|
|
1684
|
-
}
|
|
1685
|
-
get chainIterator() {
|
|
1686
|
-
return this.params.chainIterator;
|
|
1734
|
+
get blockViewer() {
|
|
1735
|
+
return this.params.blockViewer;
|
|
1687
1736
|
}
|
|
1688
1737
|
get ethProvider() {
|
|
1689
1738
|
return this.params.ethProvider;
|
|
@@ -1693,8 +1742,7 @@ var BaseTimeSyncService = class extends BaseService {
|
|
|
1693
1742
|
}
|
|
1694
1743
|
async createHandler() {
|
|
1695
1744
|
await super.createHandler();
|
|
1696
|
-
|
|
1697
|
-
this.timeSyncViewer = new SimpleTimeSyncViewer(blockViewer, this.ethProvider);
|
|
1745
|
+
this.timeSyncViewer = new SimpleTimeSyncViewer(this.blockViewer, this.ethProvider);
|
|
1698
1746
|
}
|
|
1699
1747
|
async currentTime(domain) {
|
|
1700
1748
|
return await this.timeSyncViewer.currentTime(domain);
|