@xyo-network/chain-services 1.8.3 → 1.9.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/BlockReward/EvmBlockRewardService.d.ts.map +1 -1
- package/dist/neutral/ChainService/Evm/Evm.d.ts.map +1 -1
- package/dist/neutral/DataLake/AbstractXyoDataLake.d.ts +10 -0
- package/dist/neutral/DataLake/AbstractXyoDataLake.d.ts.map +1 -0
- package/dist/neutral/DataLake/ArchivistXyoDataLake.d.ts +11 -0
- package/dist/neutral/DataLake/ArchivistXyoDataLake.d.ts.map +1 -0
- package/dist/neutral/{XyoDataLake.d.ts → DataLake/HttpXyoDataLake.d.ts} +4 -5
- package/dist/neutral/DataLake/HttpXyoDataLake.d.ts.map +1 -0
- package/dist/neutral/DataLake/index.d.ts +4 -0
- package/dist/neutral/DataLake/index.d.ts.map +1 -0
- package/dist/neutral/index.d.ts +1 -1
- package/dist/neutral/index.d.ts.map +1 -1
- package/dist/neutral/index.mjs +222 -174
- package/dist/neutral/index.mjs.map +1 -1
- package/package.json +38 -38
- package/src/BlockReward/EvmBlockRewardService.ts +1 -1
- package/src/ChainService/Evm/Evm.ts +1 -2
- package/src/DataLake/AbstractXyoDataLake.ts +38 -0
- package/src/DataLake/ArchivistXyoDataLake.ts +26 -0
- package/src/{XyoDataLake.ts → DataLake/HttpXyoDataLake.ts} +5 -19
- package/src/DataLake/index.ts +3 -0
- package/src/index.ts +1 -1
- package/dist/neutral/XyoDataLake.d.ts.map +0 -1
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "http://json.schemastore.org/package.json",
|
|
3
3
|
"name": "@xyo-network/chain-services",
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.9.0",
|
|
5
5
|
"description": "XYO Layer One SDK Services",
|
|
6
6
|
"homepage": "https://xylabs.com",
|
|
7
7
|
"bugs": {
|
|
@@ -37,36 +37,36 @@
|
|
|
37
37
|
],
|
|
38
38
|
"dependencies": {
|
|
39
39
|
"@opentelemetry/api": "^1.9.0",
|
|
40
|
-
"@xylabs/array": "^
|
|
41
|
-
"@xylabs/assert": "^
|
|
42
|
-
"@xylabs/axios": "^
|
|
43
|
-
"@xylabs/creatable": "^
|
|
44
|
-
"@xylabs/decimal-precision": "^
|
|
45
|
-
"@xylabs/events": "^
|
|
46
|
-
"@xylabs/exists": "^
|
|
47
|
-
"@xylabs/forget": "^
|
|
48
|
-
"@xylabs/hex": "^
|
|
49
|
-
"@xylabs/promise": "^
|
|
50
|
-
"@xylabs/telemetry": "^
|
|
51
|
-
"@xylabs/typeof": "^
|
|
52
|
-
"@xyo-network/account-model": "^
|
|
53
|
-
"@xyo-network/archivist-memory": "^
|
|
54
|
-
"@xyo-network/archivist-model": "^
|
|
55
|
-
"@xyo-network/boundwitness-model": "^
|
|
56
|
-
"@xyo-network/boundwitness-validator": "^
|
|
57
|
-
"@xyo-network/boundwitness-wrapper": "^
|
|
58
|
-
"@xyo-network/chain-analyze": "^1.
|
|
59
|
-
"@xyo-network/chain-
|
|
60
|
-
"@xyo-network/chain-
|
|
61
|
-
"@xyo-network/chain-
|
|
62
|
-
"@xyo-network/
|
|
63
|
-
"@xyo-network/payload-builder": "^
|
|
64
|
-
"@xyo-network/payload-model": "^
|
|
40
|
+
"@xylabs/array": "^5.0.0",
|
|
41
|
+
"@xylabs/assert": "^5.0.0",
|
|
42
|
+
"@xylabs/axios": "^5.0.0",
|
|
43
|
+
"@xylabs/creatable": "^5.0.0",
|
|
44
|
+
"@xylabs/decimal-precision": "^5.0.0",
|
|
45
|
+
"@xylabs/events": "^5.0.0",
|
|
46
|
+
"@xylabs/exists": "^5.0.0",
|
|
47
|
+
"@xylabs/forget": "^5.0.0",
|
|
48
|
+
"@xylabs/hex": "^5.0.0",
|
|
49
|
+
"@xylabs/promise": "^5.0.0",
|
|
50
|
+
"@xylabs/telemetry": "^5.0.0",
|
|
51
|
+
"@xylabs/typeof": "^5.0.0",
|
|
52
|
+
"@xyo-network/account-model": "^5.0.0",
|
|
53
|
+
"@xyo-network/archivist-memory": "^5.0.0",
|
|
54
|
+
"@xyo-network/archivist-model": "^5.0.0",
|
|
55
|
+
"@xyo-network/boundwitness-model": "^5.0.0",
|
|
56
|
+
"@xyo-network/boundwitness-validator": "^5.0.0",
|
|
57
|
+
"@xyo-network/boundwitness-wrapper": "^5.0.0",
|
|
58
|
+
"@xyo-network/chain-analyze": "^1.9.0",
|
|
59
|
+
"@xyo-network/chain-modules": "^1.9.0",
|
|
60
|
+
"@xyo-network/chain-protocol": "^1.9.0",
|
|
61
|
+
"@xyo-network/chain-utils": "^1.9.0",
|
|
62
|
+
"@xyo-network/hash": "^5.0.0",
|
|
63
|
+
"@xyo-network/payload-builder": "^5.0.0",
|
|
64
|
+
"@xyo-network/payload-model": "^5.0.0",
|
|
65
65
|
"@xyo-network/typechain": "^3.5.4",
|
|
66
|
-
"@xyo-network/xl1-protocol": "^1.
|
|
67
|
-
"@xyo-network/xl1-protocol-sdk": "^1.
|
|
68
|
-
"@xyo-network/xl1-validation": "^1.
|
|
69
|
-
"@xyo-network/xl1-wrappers": "^1.
|
|
66
|
+
"@xyo-network/xl1-protocol": "^1.8.0",
|
|
67
|
+
"@xyo-network/xl1-protocol-sdk": "^1.9.0",
|
|
68
|
+
"@xyo-network/xl1-validation": "^1.9.0",
|
|
69
|
+
"@xyo-network/xl1-wrappers": "^1.9.0",
|
|
70
70
|
"async-mutex": "^0.5.0",
|
|
71
71
|
"axios": "^1.11.0",
|
|
72
72
|
"ethers": "6.15.0",
|
|
@@ -74,14 +74,14 @@
|
|
|
74
74
|
},
|
|
75
75
|
"devDependencies": {
|
|
76
76
|
"@types/node": "^24.1.0",
|
|
77
|
-
"@xylabs/delay": "^
|
|
78
|
-
"@xylabs/ts-scripts-yarn3": "^7.0.
|
|
79
|
-
"@xylabs/tsconfig": "^7.0.
|
|
80
|
-
"@xylabs/vitest-extended": "^
|
|
81
|
-
"@xyo-network/account": "^
|
|
82
|
-
"@xyo-network/account-model": "^
|
|
83
|
-
"@xyo-network/chain-validation": "^1.
|
|
84
|
-
"@xyo-network/wallet": "^
|
|
77
|
+
"@xylabs/delay": "^5.0.0",
|
|
78
|
+
"@xylabs/ts-scripts-yarn3": "^7.0.2",
|
|
79
|
+
"@xylabs/tsconfig": "^7.0.2",
|
|
80
|
+
"@xylabs/vitest-extended": "^5.0.0",
|
|
81
|
+
"@xyo-network/account": "^5.0.0",
|
|
82
|
+
"@xyo-network/account-model": "^5.0.0",
|
|
83
|
+
"@xyo-network/chain-validation": "^1.9.0",
|
|
84
|
+
"@xyo-network/wallet": "^5.0.0",
|
|
85
85
|
"knip": "^5.62.0",
|
|
86
86
|
"typescript": "^5.8.3",
|
|
87
87
|
"vitest": "^3.2.4",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { assertEx } from '@xylabs/assert'
|
|
2
2
|
import { creatable } from '@xylabs/creatable'
|
|
3
|
+
import { toEthAddress } from '@xylabs/hex'
|
|
3
4
|
import { AccountInstance } from '@xyo-network/account-model'
|
|
4
|
-
import { toEthAddress } from '@xyo-network/chain-ethereum'
|
|
5
5
|
import { XyoChainRewards__factory as XyoChainRewardsFactory } from '@xyo-network/typechain'
|
|
6
6
|
import { BlockRewardService, ChainService } from '@xyo-network/xl1-protocol'
|
|
7
7
|
import { Provider } from 'ethers/providers'
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { assertEx } from '@xylabs/assert'
|
|
2
2
|
import type { Address } from '@xylabs/hex'
|
|
3
|
-
import { toAddress } from '@xylabs/hex'
|
|
4
|
-
import { toEthAddress } from '@xyo-network/chain-ethereum'
|
|
3
|
+
import { toAddress, toEthAddress } from '@xylabs/hex'
|
|
5
4
|
import type { StakedXyoChain } from '@xyo-network/typechain'
|
|
6
5
|
import { StakedXyoChain__factory as StakedXyoChainFactory } from '@xyo-network/typechain'
|
|
7
6
|
import type { ChainService } from '@xyo-network/xl1-protocol'
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { Hash } from '@xylabs/hex'
|
|
2
|
+
import { ObjectHasher } from '@xyo-network/hash'
|
|
3
|
+
import { PayloadBuilder } from '@xyo-network/payload-builder'
|
|
4
|
+
import type { Payload } from '@xyo-network/payload-model'
|
|
5
|
+
import { isAnyPayload } from '@xyo-network/payload-model'
|
|
6
|
+
import {
|
|
7
|
+
type DataLakeData,
|
|
8
|
+
isHashPayload,
|
|
9
|
+
type XyoDataLakeProvider,
|
|
10
|
+
} from '@xyo-network/xl1-protocol'
|
|
11
|
+
|
|
12
|
+
export abstract class AbstractXyoDataLake implements XyoDataLakeProvider {
|
|
13
|
+
async fetch(hashes: Hash[], maxDepth: number = 10): Promise<DataLakeData[]> {
|
|
14
|
+
const results: DataLakeData[] = await this.get(hashes)
|
|
15
|
+
if (maxDepth > 0) {
|
|
16
|
+
const hashPayloads = results.filter(isHashPayload)
|
|
17
|
+
const otherPayloads = results.filter(item => !isHashPayload(item))
|
|
18
|
+
const found = await this.fetch(hashPayloads.map(item => item.hash), maxDepth - 1)
|
|
19
|
+
const foundHashes = await Promise.all(found.map(async item => isAnyPayload(item) ? await PayloadBuilder.hash(item) : ObjectHasher.hashBytes(item)))
|
|
20
|
+
const notFound = hashPayloads.filter(item => !foundHashes.includes(item.hash))
|
|
21
|
+
return [...otherPayloads, ...found, ...notFound]
|
|
22
|
+
}
|
|
23
|
+
return results
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
async trace(hash: Hash): Promise<[DataLakeData | undefined, Payload[]]> {
|
|
27
|
+
const [result] = await this.get([hash])
|
|
28
|
+
if (isHashPayload(result)) {
|
|
29
|
+
const [payload, route] = await this.trace(result.hash)
|
|
30
|
+
return [payload, [result, ...route]]
|
|
31
|
+
}
|
|
32
|
+
return [result, []]
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
abstract add(items: DataLakeData[]): Promise<DataLakeData[]>
|
|
36
|
+
|
|
37
|
+
abstract get(hashes: Hash[]): Promise<DataLakeData[]>
|
|
38
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { assertEx } from '@xylabs/assert'
|
|
2
|
+
import type { Hash } from '@xylabs/hex'
|
|
3
|
+
import type { ReadWriteArchivist } from '@xyo-network/archivist-model'
|
|
4
|
+
import { isAnyPayload } from '@xyo-network/payload-model'
|
|
5
|
+
import { type DataLakeData } from '@xyo-network/xl1-protocol'
|
|
6
|
+
|
|
7
|
+
import { AbstractXyoDataLake } from './AbstractXyoDataLake.ts'
|
|
8
|
+
|
|
9
|
+
export class ArchivistXyoDataLake extends AbstractXyoDataLake {
|
|
10
|
+
private _archivist: ReadWriteArchivist
|
|
11
|
+
|
|
12
|
+
constructor(archivist: ReadWriteArchivist) {
|
|
13
|
+
super()
|
|
14
|
+
this._archivist = archivist
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
async add(items: DataLakeData[]): Promise<DataLakeData[]> {
|
|
18
|
+
const payloads = items.filter(isAnyPayload)
|
|
19
|
+
assertEx(payloads.length === items.length, () => 'Some items are not payloads')
|
|
20
|
+
return await this._archivist.insert(payloads)
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
async get(hashes: Hash[]): Promise<DataLakeData[]> {
|
|
24
|
+
return await this._archivist.get(hashes)
|
|
25
|
+
}
|
|
26
|
+
}
|
|
@@ -5,18 +5,19 @@ import type { Hash } from '@xylabs/hex'
|
|
|
5
5
|
import type { Promisable } from '@xylabs/promise'
|
|
6
6
|
import { isArrayBuffer, isDefined } from '@xylabs/typeof'
|
|
7
7
|
import { isAnyPayload, type Payload } from '@xyo-network/payload-model'
|
|
8
|
-
import {
|
|
9
|
-
type DataLakeData, isHashPayload, type XyoDataLakeProvider,
|
|
10
|
-
} from '@xyo-network/xl1-protocol'
|
|
8
|
+
import { type DataLakeData, isHashPayload } from '@xyo-network/xl1-protocol'
|
|
11
9
|
import { Axios } from 'axios'
|
|
12
10
|
|
|
13
|
-
|
|
11
|
+
import { AbstractXyoDataLake } from './AbstractXyoDataLake.ts'
|
|
12
|
+
|
|
13
|
+
export class HttpXyoDataLake extends AbstractXyoDataLake {
|
|
14
14
|
private _axiosGet: Axios
|
|
15
15
|
private _axiosInsertBlob: Axios
|
|
16
16
|
private _axiosInsertJson: AxiosJson
|
|
17
17
|
private _endpoint: string
|
|
18
18
|
|
|
19
19
|
constructor(endpoint: string) {
|
|
20
|
+
super()
|
|
20
21
|
this._endpoint = endpoint
|
|
21
22
|
this._axiosInsertJson = new AxiosJson({ baseURL: endpoint })
|
|
22
23
|
this._axiosInsertBlob = new Axios({ baseURL: endpoint, headers: { 'Content-Type': 'application/octet-stream', 'Accept': 'application/octet-stream' } })
|
|
@@ -49,27 +50,12 @@ export class XyoDataLake implements XyoDataLakeProvider {
|
|
|
49
50
|
return results
|
|
50
51
|
}
|
|
51
52
|
|
|
52
|
-
async fetch(hashes: Hash[], maxDepth?: number): Promise<DataLakeData[]> {
|
|
53
|
-
return (await Promise.all(hashes.map(async (hash) => {
|
|
54
|
-
return await this.fetchOne(hash, maxDepth)
|
|
55
|
-
}))).filter(exists)
|
|
56
|
-
}
|
|
57
|
-
|
|
58
53
|
async get(hashes: Hash[]): Promise<DataLakeData[]> {
|
|
59
54
|
return (await Promise.all(hashes.map(async (hash) => {
|
|
60
55
|
return await this.getOne(hash)
|
|
61
56
|
}))).filter(exists)
|
|
62
57
|
}
|
|
63
58
|
|
|
64
|
-
async trace(hash: Hash): Promise<[DataLakeData | undefined, Payload[]]> {
|
|
65
|
-
const result = await this.getOne(hash)
|
|
66
|
-
if (isHashPayload(result)) {
|
|
67
|
-
const [payload, route] = await this.trace(result.hash)
|
|
68
|
-
return [payload, [result, ...route]]
|
|
69
|
-
}
|
|
70
|
-
return [result, []]
|
|
71
|
-
}
|
|
72
|
-
|
|
73
59
|
protected async addArrayBuffer(item: ArrayBuffer): Promise<ArrayBuffer | undefined> {
|
|
74
60
|
const result = await this._axiosInsertBlob.post('/insert', item)
|
|
75
61
|
if (result.status < 200 || result.status >= 300) {
|
package/src/index.ts
CHANGED
|
@@ -5,8 +5,8 @@ export * from './BlockReward/index.ts'
|
|
|
5
5
|
export * from './ChainBlockNumberIteration/index.ts'
|
|
6
6
|
export * from './ChainService/index.ts'
|
|
7
7
|
export * from './ChainValidator/index.ts'
|
|
8
|
+
export * from './DataLake/index.ts'
|
|
8
9
|
export * from './Election/index.ts'
|
|
9
10
|
export * from './model/index.ts'
|
|
10
11
|
export * from './PendingTransactions/index.ts'
|
|
11
12
|
export * from './StakeIntent/index.ts'
|
|
12
|
-
export * from './XyoDataLake.ts'
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"XyoDataLake.d.ts","sourceRoot":"","sources":["../../src/XyoDataLake.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,aAAa,CAAA;AACvC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAEjD,OAAO,EAAgB,KAAK,OAAO,EAAE,MAAM,4BAA4B,CAAA;AACvE,OAAO,EACL,KAAK,YAAY,EAAiB,KAAK,mBAAmB,EAC3D,MAAM,2BAA2B,CAAA;AAGlC,qBAAa,WAAY,YAAW,mBAAmB;IACrD,OAAO,CAAC,SAAS,CAAO;IACxB,OAAO,CAAC,gBAAgB,CAAO;IAC/B,OAAO,CAAC,gBAAgB,CAAW;IACnC,OAAO,CAAC,SAAS,CAAQ;gBAEb,QAAQ,EAAE,MAAM;IAO5B,IAAI,QAAQ,IAAI,MAAM,CAErB;IAEK,GAAG,CAAC,KAAK,EAAE,YAAY,EAAE,GAAG,OAAO,CAAC,YAAY,EAAE,CAAC;IAsBnD,KAAK,CAAC,MAAM,EAAE,IAAI,EAAE,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,EAAE,CAAC;IAMjE,GAAG,CAAC,MAAM,EAAE,IAAI,EAAE,GAAG,OAAO,CAAC,YAAY,EAAE,CAAC;IAM5C,KAAK,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAAC,CAAC,YAAY,GAAG,SAAS,EAAE,OAAO,EAAE,CAAC,CAAC;cASvD,cAAc,CAAC,IAAI,EAAE,WAAW,GAAG,OAAO,CAAC,WAAW,GAAG,SAAS,CAAC;cAYnE,UAAU,CAAC,IAAI,EAAE,OAAO,GAAG,OAAO,CAAC,OAAO,GAAG,SAAS,CAAC;cAYvD,QAAQ,CAAC,IAAI,EAAE,IAAI,EAAE,QAAQ,GAAE,MAAgC,GAAG,OAAO,CAAC,YAAY,GAAG,SAAS,CAAC;IAWnH,SAAS,CAAC,MAAM,CAAC,IAAI,EAAE,IAAI,GAAG,UAAU,CAAC,YAAY,GAAG,SAAS,CAAC;CAWnE"}
|