@xyo-network/xl1-rpc 1.7.15 → 1.7.17
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/index.mjs +35 -34
- package/dist/neutral/index.mjs.map +1 -1
- package/dist/neutral/provider/client/MemoryXyoClient.d.ts +8 -0
- package/dist/neutral/provider/client/MemoryXyoClient.d.ts.map +1 -0
- package/dist/neutral/provider/client/XyoClient.d.ts +6 -0
- package/dist/neutral/provider/client/XyoClient.d.ts.map +1 -0
- package/dist/neutral/provider/client/index.d.ts +3 -0
- package/dist/neutral/provider/client/index.d.ts.map +1 -0
- package/dist/neutral/provider/client/spec/MemoryXyoClient.spec.d.ts +2 -0
- package/dist/neutral/provider/client/spec/MemoryXyoClient.spec.d.ts.map +1 -0
- package/dist/neutral/provider/provider/index.d.ts +1 -0
- package/dist/neutral/provider/provider/index.d.ts.map +1 -1
- package/dist/node/index-node.mjs +35 -34
- package/dist/node/index-node.mjs.map +1 -1
- package/dist/node/provider/client/MemoryXyoClient.d.ts +8 -0
- package/dist/node/provider/client/MemoryXyoClient.d.ts.map +1 -0
- package/dist/node/provider/client/XyoClient.d.ts +6 -0
- package/dist/node/provider/client/XyoClient.d.ts.map +1 -0
- package/dist/node/provider/client/index.d.ts +3 -0
- package/dist/node/provider/client/index.d.ts.map +1 -0
- package/dist/node/provider/client/spec/MemoryXyoClient.spec.d.ts +2 -0
- package/dist/node/provider/client/spec/MemoryXyoClient.spec.d.ts.map +1 -0
- package/dist/node/provider/provider/index.d.ts +1 -0
- package/dist/node/provider/provider/index.d.ts.map +1 -1
- package/package.json +4 -4
- package/src/provider/client/MemoryXyoClient.ts +12 -0
- package/src/provider/client/XyoClient.ts +6 -0
- package/src/provider/client/index.ts +2 -0
- package/src/provider/client/spec/MemoryXyoClient.spec.ts +68 -0
- package/src/provider/provider/index.ts +1 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MemoryXyoClient.spec.d.ts","sourceRoot":"","sources":["../../../../../src/provider/client/spec/MemoryXyoClient.spec.ts"],"names":[],"mappings":""}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/provider/provider/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAA;AACrC,cAAc,oBAAoB,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/provider/provider/index.ts"],"names":[],"mappings":"AAAA,cAAc,yBAAyB,CAAA;AACvC,cAAc,uBAAuB,CAAA;AACrC,cAAc,oBAAoB,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "http://json.schemastore.org/package.json",
|
|
3
3
|
"name": "@xyo-network/xl1-rpc",
|
|
4
|
-
"version": "1.7.
|
|
4
|
+
"version": "1.7.17",
|
|
5
5
|
"description": "XYO Layer One API",
|
|
6
6
|
"homepage": "https://xylabs.com",
|
|
7
7
|
"bugs": {
|
|
@@ -75,9 +75,9 @@
|
|
|
75
75
|
"@xyo-network/payload-builder": "^4.1.7",
|
|
76
76
|
"@xyo-network/payload-model": "^4.1.7",
|
|
77
77
|
"@xyo-network/payload-wrapper": "^4.1.7",
|
|
78
|
-
"@xyo-network/xl1-protocol": "^1.7.
|
|
79
|
-
"@xyo-network/xl1-protocol-sdk": "^1.7.
|
|
80
|
-
"@xyo-network/xl1-wrappers": "^1.7.
|
|
78
|
+
"@xyo-network/xl1-protocol": "^1.7.20",
|
|
79
|
+
"@xyo-network/xl1-protocol-sdk": "^1.7.17",
|
|
80
|
+
"@xyo-network/xl1-wrappers": "^1.7.17",
|
|
81
81
|
"axios": "^1.11.0",
|
|
82
82
|
"uuid": "^11.1.0",
|
|
83
83
|
"zod": "^3.25.76"
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { MemoryXyoGateway, PermissionsStore } from '../host/index.ts'
|
|
2
|
+
import type { XyoClient } from './XyoClient.ts'
|
|
3
|
+
|
|
4
|
+
export class MemoryXyoClient implements XyoClient {
|
|
5
|
+
readonly gateways: Readonly<Record<string, MemoryXyoGateway>>
|
|
6
|
+
readonly permissionsStore: PermissionsStore
|
|
7
|
+
|
|
8
|
+
constructor(permissionsStore: PermissionsStore, gateways: Readonly<Record<string, MemoryXyoGateway>>) {
|
|
9
|
+
this.permissionsStore = permissionsStore
|
|
10
|
+
this.gateways = gateways
|
|
11
|
+
}
|
|
12
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import type { AccountInstance } from '@xyo-network/account-model'
|
|
2
|
+
import { PayloadBuilder } from '@xyo-network/payload-builder'
|
|
3
|
+
import type { Payload } from '@xyo-network/payload-model'
|
|
4
|
+
import { HDWallet } from '@xyo-network/wallet'
|
|
5
|
+
import type { AllowedBlockPayload, HashPayload } from '@xyo-network/xl1-protocol'
|
|
6
|
+
import { HashSchema } from '@xyo-network/xl1-protocol'
|
|
7
|
+
import { ADDRESS_INDEX, generateXyoBaseWalletFromPhrase } from '@xyo-network/xl1-protocol-sdk'
|
|
8
|
+
import {
|
|
9
|
+
beforeAll, beforeEach, describe, expect, it,
|
|
10
|
+
} from 'vitest'
|
|
11
|
+
|
|
12
|
+
import { MemoryPermissionsStore, MemoryXyoGateway } from '../../host/index.ts'
|
|
13
|
+
import { RpcXyoConnection } from '../../provider/index.ts'
|
|
14
|
+
import { MemoryXyoSigner } from '../../signer/index.ts'
|
|
15
|
+
import { MemoryXyoClient } from '../MemoryXyoClient.ts'
|
|
16
|
+
import type { XyoClient } from '../XyoClient.ts'
|
|
17
|
+
|
|
18
|
+
type TestPayload = Payload<{
|
|
19
|
+
id: string
|
|
20
|
+
schema: 'network.xyo.test'
|
|
21
|
+
}>
|
|
22
|
+
|
|
23
|
+
describe('Client', () => {
|
|
24
|
+
const endpoint = 'http://localhost:8080/rpc'
|
|
25
|
+
const dataLakeEndpoint = 'http://localhost:8080/chain/archivist'
|
|
26
|
+
let account: AccountInstance
|
|
27
|
+
let signer: MemoryXyoSigner
|
|
28
|
+
let store: MemoryPermissionsStore
|
|
29
|
+
let gateway: MemoryXyoGateway
|
|
30
|
+
let client: XyoClient
|
|
31
|
+
|
|
32
|
+
beforeEach(async () => {
|
|
33
|
+
const mnemonic = process.env.XL1_PRODUCER__MNEMONIC ?? HDWallet.generateMnemonic()
|
|
34
|
+
const wallet = await generateXyoBaseWalletFromPhrase(mnemonic)
|
|
35
|
+
account = await wallet.derivePath(ADDRESS_INDEX.XYO)
|
|
36
|
+
signer = new MemoryXyoSigner(account)
|
|
37
|
+
store = new MemoryPermissionsStore()
|
|
38
|
+
gateway = new MemoryXyoGateway(signer, store)
|
|
39
|
+
await gateway.addConnection('localhost', new RpcXyoConnection({ endpoint, account }))
|
|
40
|
+
client = new MemoryXyoClient(store, { localhost: gateway })
|
|
41
|
+
})
|
|
42
|
+
|
|
43
|
+
describe('gateways', () => {
|
|
44
|
+
describe('activeConnection', () => {
|
|
45
|
+
let onChainPayloads: AllowedBlockPayload[]
|
|
46
|
+
let offChainPayloads: Payload[]
|
|
47
|
+
beforeAll(async () => {
|
|
48
|
+
const id = new PayloadBuilder<TestPayload>({ schema: 'network.xyo.test' }).fields({ id: Date.now().toString() }).build()
|
|
49
|
+
const hash = await PayloadBuilder.hash(id)
|
|
50
|
+
const hashPayload: HashPayload = new PayloadBuilder<HashPayload>({ schema: HashSchema }).fields({ hash }).build()
|
|
51
|
+
onChainPayloads = [hashPayload]
|
|
52
|
+
offChainPayloads = [id]
|
|
53
|
+
})
|
|
54
|
+
it('should be defined', () => {
|
|
55
|
+
const gateway = client.gateways.localhost.activeConnection()
|
|
56
|
+
expect(gateway).toBeDefined()
|
|
57
|
+
})
|
|
58
|
+
it('should allow retrieving the chain ID', async () => {
|
|
59
|
+
const chainId = await client.gateways.localhost?.activeConnection()?.viewer?.chainId()
|
|
60
|
+
expect(chainId).toBeDefined()
|
|
61
|
+
})
|
|
62
|
+
it.only('should allow for submitting transactions', async () => {
|
|
63
|
+
const transaction = await client.gateways.localhost?.activeConnection()?.submitTransaction?.(onChainPayloads, offChainPayloads)
|
|
64
|
+
expect(transaction).toBeDefined()
|
|
65
|
+
})
|
|
66
|
+
})
|
|
67
|
+
})
|
|
68
|
+
})
|