@xyo-network/api 2.47.5 → 2.47.6

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/package.json CHANGED
@@ -11,28 +11,28 @@
11
11
  "dependencies": {
12
12
  "@xylabs/assert": "^2.7.1",
13
13
  "@xylabs/delay": "^2.7.1",
14
- "@xyo-network/account": "^2.47.5",
15
- "@xyo-network/api-models": "^2.47.5",
16
- "@xyo-network/archivist": "^2.47.5",
17
- "@xyo-network/axios": "^2.47.5",
18
- "@xyo-network/boundwitness-builder": "^2.47.5",
19
- "@xyo-network/boundwitness-model": "^2.47.5",
20
- "@xyo-network/core": "^2.47.5",
21
- "@xyo-network/diviner": "^2.47.5",
22
- "@xyo-network/diviner-model": "^2.47.5",
23
- "@xyo-network/huri": "^2.47.5",
24
- "@xyo-network/module": "^2.47.5",
25
- "@xyo-network/payload-builder": "^2.47.5",
26
- "@xyo-network/payload-model": "^2.47.5",
27
- "@xyo-network/payload-wrapper": "^2.47.5",
28
- "@xyo-network/schema-payload-plugin": "^2.47.5",
14
+ "@xyo-network/account": "^2.47.6",
15
+ "@xyo-network/api-models": "^2.47.6",
16
+ "@xyo-network/archivist": "^2.47.6",
17
+ "@xyo-network/axios": "^2.47.6",
18
+ "@xyo-network/boundwitness-builder": "^2.47.6",
19
+ "@xyo-network/boundwitness-model": "^2.47.6",
20
+ "@xyo-network/core": "^2.47.6",
21
+ "@xyo-network/diviner": "^2.47.6",
22
+ "@xyo-network/diviner-model": "^2.47.6",
23
+ "@xyo-network/huri": "^2.47.6",
24
+ "@xyo-network/module": "^2.47.6",
25
+ "@xyo-network/payload-builder": "^2.47.6",
26
+ "@xyo-network/payload-model": "^2.47.6",
27
+ "@xyo-network/payload-wrapper": "^2.47.6",
28
+ "@xyo-network/schema-payload-plugin": "^2.47.6",
29
29
  "lodash": "^4.17.21"
30
30
  },
31
31
  "description": "Primary SDK for using XYO Protocol 2.0",
32
32
  "devDependencies": {
33
33
  "@types/lodash": "^4.14.191",
34
- "@xylabs/ts-scripts-yarn3": "^2.14.15",
35
- "@xylabs/tsconfig": "^2.14.15",
34
+ "@xylabs/ts-scripts-yarn3": "^2.14.16",
35
+ "@xylabs/tsconfig": "^2.14.16",
36
36
  "typescript": "^4.9.5"
37
37
  },
38
38
  "browser": "dist/esm/index.js",
@@ -68,5 +68,5 @@
68
68
  },
69
69
  "sideEffects": false,
70
70
  "types": "dist/types/index.d.ts",
71
- "version": "2.47.5"
71
+ "version": "2.47.6"
72
72
  }
@@ -0,0 +1,77 @@
1
+ import { assertEx } from '@xylabs/assert'
2
+ import { Account } from '@xyo-network/account'
3
+ import { XyoApiConfig, XyoApiResponseBody } from '@xyo-network/api-models'
4
+ import { XyoBoundWitness } from '@xyo-network/boundwitness-model'
5
+ import { BoundWitnessWrapper } from '@xyo-network/boundwitness-wrapper'
6
+ import { ModuleDescription } from '@xyo-network/module'
7
+
8
+ import { XyoApiSimple } from '../../../Simple'
9
+ import { XyoArchivistApi } from '../../Api'
10
+ import { XyoAddressesApi } from '../Api'
11
+ import { XyoAddressApi } from './Api'
12
+
13
+ const config: XyoApiConfig = {
14
+ apiDomain: process.env.API_DOMAIN || 'http://localhost:8080',
15
+ }
16
+
17
+ describe('XyoAddressApi', () => {
18
+ describe('get', () => {
19
+ let api: XyoAddressApi
20
+ let result: XyoApiResponseBody<ModuleDescription>
21
+ beforeAll(async () => {
22
+ const address = assertEx((await new XyoAddressesApi(config).get())?.children?.pop())
23
+ api = new XyoArchivistApi(config).addresses.address(address)
24
+ result = await api.get()
25
+ expect(result).toBeObject()
26
+ })
27
+ it('method exists', () => {
28
+ expect(api).toBeDefined()
29
+ expect(api.get).toBeFunction()
30
+ })
31
+ describe('returns module', () => {
32
+ it('address', () => {
33
+ expect(result?.address).toBeString()
34
+ })
35
+ it('supported queries', () => {
36
+ const queries = result?.queries
37
+ expect(queries).toBeArray()
38
+ expect(queries?.length).toBeGreaterThan(0)
39
+ queries?.map((query) => {
40
+ expect(query).toBeString()
41
+ })
42
+ })
43
+ })
44
+ })
45
+ describe('boundWitness', () => {
46
+ let address: string
47
+ let api: XyoApiSimple<XyoBoundWitness[]>
48
+ let history: XyoBoundWitness[]
49
+ beforeAll(async () => {
50
+ address = new Account({ phrase: 'test' }).addressValue.hex
51
+ api = new XyoArchivistApi(config).addresses.address(address).boundWitnesses
52
+ const result = await api.get()
53
+ expect(result).toBeArray()
54
+ history = assertEx(result)
55
+ })
56
+ it('method exists', () => {
57
+ expect(api).toBeDefined()
58
+ expect(api.get).toBeFunction()
59
+ })
60
+ describe('return BoundWitnesses', () => {
61
+ it('from the address specified', () => {
62
+ history?.map((block) => expect(block.addresses).toContain(address))
63
+ })
64
+ it('in sequential order', () => {
65
+ verifyBlockChainHistory(history)
66
+ })
67
+ })
68
+ })
69
+ })
70
+
71
+ const verifyBlockChainHistory = (history: XyoBoundWitness[]) => {
72
+ for (let i = 1; i < history.length; i++) {
73
+ const current = history[i - 1]
74
+ const previous = history[i]
75
+ expect(current.previous_hashes).toContain(new BoundWitnessWrapper(previous).hash)
76
+ }
77
+ }