@xyo-network/xl1-rpc 1.2.3 → 1.2.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/browser/index.mjs +4 -9
- package/dist/browser/index.mjs.map +1 -1
- package/dist/neutral/index.mjs +4 -9
- package/dist/neutral/index.mjs.map +1 -1
- package/dist/node/index.mjs +4 -9
- package/dist/node/index.mjs.map +1 -1
- package/dist/types/provider/viewer/NodeXyoViewer.d.ts +0 -29
- package/dist/types/provider/viewer/NodeXyoViewer.d.ts.map +1 -1
- package/package.json +7 -7
- package/src/provider/viewer/NodeXyoViewer.ts +5 -16
|
@@ -1,14 +1,11 @@
|
|
|
1
1
|
import { filterAs } from '@xylabs/array'
|
|
2
2
|
import { assertEx } from '@xylabs/assert'
|
|
3
3
|
import { exists } from '@xylabs/exists'
|
|
4
|
-
import {
|
|
5
|
-
type Address, asAddress, type Hash,
|
|
6
|
-
} from '@xylabs/hex'
|
|
4
|
+
import { type Address, type Hash } from '@xylabs/hex'
|
|
7
5
|
import { hexToBigInt } from '@xylabs/hex'
|
|
8
6
|
import type { ArchivistInstance } from '@xyo-network/archivist-model'
|
|
9
7
|
import { asArchivistInstance } from '@xyo-network/archivist-model'
|
|
10
8
|
import { BoundWitnessSchema, type Signed } from '@xyo-network/boundwitness-model'
|
|
11
|
-
import type { HeadValidationDiviner } from '@xyo-network/chain-modules'
|
|
12
9
|
import {
|
|
13
10
|
analyzeChain, BalanceAnalyzer, findMostRecentBlock, hydrateBlock, hydrateTransaction, isChainSummaryBalances,
|
|
14
11
|
} from '@xyo-network/chain-protocol'
|
|
@@ -32,7 +29,6 @@ export class NodeXyoViewer implements XyoViewer {
|
|
|
32
29
|
|
|
33
30
|
private _chainId: Address | undefined
|
|
34
31
|
private _finalizedArchivist: ArchivistInstance | undefined
|
|
35
|
-
private _headValidationDiviner: HeadValidationDiviner | undefined
|
|
36
32
|
|
|
37
33
|
constructor(node: NodeInstance) {
|
|
38
34
|
this.node = node
|
|
@@ -94,11 +90,10 @@ export class NodeXyoViewer implements XyoViewer {
|
|
|
94
90
|
|
|
95
91
|
async chainId(): Promise<Address> {
|
|
96
92
|
if (this._chainId) return this._chainId
|
|
97
|
-
const
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
)
|
|
93
|
+
const finalizedArchivist = await this.getFinalizedArchivist()
|
|
94
|
+
const block = await findMostRecentBlock(finalizedArchivist)
|
|
95
|
+
if (!block) throw new Error('Error: Could not find most recent block')
|
|
96
|
+
this._chainId = block.chain
|
|
102
97
|
return await Promise.resolve(this._chainId)
|
|
103
98
|
}
|
|
104
99
|
|
|
@@ -170,10 +165,4 @@ export class NodeXyoViewer implements XyoViewer {
|
|
|
170
165
|
this._finalizedArchivist = await this.getArchivist(this.finalizedArchivistPath)
|
|
171
166
|
return this._finalizedArchivist
|
|
172
167
|
}
|
|
173
|
-
|
|
174
|
-
protected getHeadValidationDiviner = async () => {
|
|
175
|
-
if (this._headValidationDiviner) return this._headValidationDiviner
|
|
176
|
-
this._headValidationDiviner = (await this.getDiviner(this.headValidationDivinerPath)) as HeadValidationDiviner
|
|
177
|
-
return this._headValidationDiviner
|
|
178
|
-
}
|
|
179
168
|
}
|