@xyo-network/boundwitness-validator 5.1.21 → 5.1.23
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 +20 -17
- package/dist/browser/lib/addresses/spec/addressesContains.spec.d.ts +0 -2
- package/dist/browser/lib/addresses/spec/addressesContains.spec.d.ts.map +0 -1
- package/dist/browser/lib/addresses/spec/addressesContainsAll.spec.d.ts +0 -2
- package/dist/browser/lib/addresses/spec/addressesContainsAll.spec.d.ts.map +0 -1
- package/dist/browser/lib/addresses/spec/addressesContainsAny.spec.d.ts +0 -2
- package/dist/browser/lib/addresses/spec/addressesContainsAny.spec.d.ts.map +0 -1
- package/dist/browser/lib/util/spec/boundWitnessArrayPropertyContains.spec.d.ts +0 -2
- package/dist/browser/lib/util/spec/boundWitnessArrayPropertyContains.spec.d.ts.map +0 -1
- package/dist/browser/lib/util/spec/boundWitnessArrayPropertyContainsAll.spec.d.ts +0 -2
- package/dist/browser/lib/util/spec/boundWitnessArrayPropertyContainsAll.spec.d.ts.map +0 -1
- package/dist/browser/lib/util/spec/boundWitnessArrayPropertyContainsAny.spec.d.ts +0 -2
- package/dist/browser/lib/util/spec/boundWitnessArrayPropertyContainsAny.spec.d.ts.map +0 -1
- package/dist/browser/spec/Validator.spec.d.ts +0 -2
- package/dist/browser/spec/Validator.spec.d.ts.map +0 -1
- package/dist/neutral/lib/addresses/spec/addressesContains.spec.d.ts +0 -2
- package/dist/neutral/lib/addresses/spec/addressesContains.spec.d.ts.map +0 -1
- package/dist/neutral/lib/addresses/spec/addressesContainsAll.spec.d.ts +0 -2
- package/dist/neutral/lib/addresses/spec/addressesContainsAll.spec.d.ts.map +0 -1
- package/dist/neutral/lib/addresses/spec/addressesContainsAny.spec.d.ts +0 -2
- package/dist/neutral/lib/addresses/spec/addressesContainsAny.spec.d.ts.map +0 -1
- package/dist/neutral/lib/util/spec/boundWitnessArrayPropertyContains.spec.d.ts +0 -2
- package/dist/neutral/lib/util/spec/boundWitnessArrayPropertyContains.spec.d.ts.map +0 -1
- package/dist/neutral/lib/util/spec/boundWitnessArrayPropertyContainsAll.spec.d.ts +0 -2
- package/dist/neutral/lib/util/spec/boundWitnessArrayPropertyContainsAll.spec.d.ts.map +0 -1
- package/dist/neutral/lib/util/spec/boundWitnessArrayPropertyContainsAny.spec.d.ts +0 -2
- package/dist/neutral/lib/util/spec/boundWitnessArrayPropertyContainsAny.spec.d.ts.map +0 -1
- package/dist/neutral/spec/Validator.spec.d.ts +0 -2
- package/dist/neutral/spec/Validator.spec.d.ts.map +0 -1
- package/dist/node/lib/addresses/spec/addressesContains.spec.d.ts +0 -2
- package/dist/node/lib/addresses/spec/addressesContains.spec.d.ts.map +0 -1
- package/dist/node/lib/addresses/spec/addressesContainsAll.spec.d.ts +0 -2
- package/dist/node/lib/addresses/spec/addressesContainsAll.spec.d.ts.map +0 -1
- package/dist/node/lib/addresses/spec/addressesContainsAny.spec.d.ts +0 -2
- package/dist/node/lib/addresses/spec/addressesContainsAny.spec.d.ts.map +0 -1
- package/dist/node/lib/util/spec/boundWitnessArrayPropertyContains.spec.d.ts +0 -2
- package/dist/node/lib/util/spec/boundWitnessArrayPropertyContains.spec.d.ts.map +0 -1
- package/dist/node/lib/util/spec/boundWitnessArrayPropertyContainsAll.spec.d.ts +0 -2
- package/dist/node/lib/util/spec/boundWitnessArrayPropertyContainsAll.spec.d.ts.map +0 -1
- package/dist/node/lib/util/spec/boundWitnessArrayPropertyContainsAny.spec.d.ts +0 -2
- package/dist/node/lib/util/spec/boundWitnessArrayPropertyContainsAny.spec.d.ts.map +0 -1
- package/dist/node/spec/Validator.spec.d.ts +0 -2
- package/dist/node/spec/Validator.spec.d.ts.map +0 -1
- package/src/lib/addresses/spec/addressesContains.spec.ts +0 -68
- package/src/lib/addresses/spec/addressesContainsAll.spec.ts +0 -85
- package/src/lib/addresses/spec/addressesContainsAny.spec.ts +0 -84
- package/src/lib/util/spec/boundWitnessArrayPropertyContains.spec.ts +0 -68
- package/src/lib/util/spec/boundWitnessArrayPropertyContainsAll.spec.ts +0 -85
- package/src/lib/util/spec/boundWitnessArrayPropertyContainsAny.spec.ts +0 -84
- package/src/spec/Validator.spec.ts +0 -41
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xyo-network/boundwitness-validator",
|
|
3
|
-
"version": "5.1.
|
|
3
|
+
"version": "5.1.23",
|
|
4
4
|
"description": "Primary SDK for using XYO Protocol 2.0",
|
|
5
5
|
"homepage": "https://xyo.network",
|
|
6
6
|
"bugs": {
|
|
@@ -30,29 +30,32 @@
|
|
|
30
30
|
"types": "dist/neutral/index.d.ts",
|
|
31
31
|
"files": [
|
|
32
32
|
"dist",
|
|
33
|
-
"src"
|
|
33
|
+
"src",
|
|
34
|
+
"!**/*.bench.*",
|
|
35
|
+
"!**/*.spec.*",
|
|
36
|
+
"!**/*.test.*"
|
|
34
37
|
],
|
|
35
38
|
"dependencies": {
|
|
36
|
-
"@xylabs/array": "~5.0.
|
|
37
|
-
"@xylabs/arraybuffer": "~5.0.
|
|
38
|
-
"@xylabs/hex": "~5.0.
|
|
39
|
-
"@xylabs/typeof": "~5.0.
|
|
40
|
-
"@xyo-network/boundwitness-model": "~5.1.
|
|
41
|
-
"@xyo-network/elliptic": "~5.1.
|
|
42
|
-
"@xyo-network/payload": "~5.1.
|
|
43
|
-
"@xyo-network/payload-model": "~5.1.
|
|
44
|
-
"@xyo-network/payload-validator": "~5.1.
|
|
39
|
+
"@xylabs/array": "~5.0.33",
|
|
40
|
+
"@xylabs/arraybuffer": "~5.0.33",
|
|
41
|
+
"@xylabs/hex": "~5.0.33",
|
|
42
|
+
"@xylabs/typeof": "~5.0.33",
|
|
43
|
+
"@xyo-network/boundwitness-model": "~5.1.23",
|
|
44
|
+
"@xyo-network/elliptic": "~5.1.23",
|
|
45
|
+
"@xyo-network/payload": "~5.1.23",
|
|
46
|
+
"@xyo-network/payload-model": "~5.1.23",
|
|
47
|
+
"@xyo-network/payload-validator": "~5.1.23"
|
|
45
48
|
},
|
|
46
49
|
"devDependencies": {
|
|
47
50
|
"@xylabs/ts-scripts-yarn3": "~7.2.8",
|
|
48
51
|
"@xylabs/tsconfig": "~7.2.8",
|
|
49
|
-
"@xylabs/vitest-extended": "~5.0.
|
|
50
|
-
"@xyo-network/boundwitness-builder": "~5.1.
|
|
51
|
-
"@xyo-network/schema-name-validator": "~5.1.
|
|
52
|
-
"@xyo-network/wallet": "~5.1.
|
|
53
|
-
"@xyo-network/wallet-model": "~5.1.
|
|
52
|
+
"@xylabs/vitest-extended": "~5.0.33",
|
|
53
|
+
"@xyo-network/boundwitness-builder": "~5.1.23",
|
|
54
|
+
"@xyo-network/schema-name-validator": "~5.1.23",
|
|
55
|
+
"@xyo-network/wallet": "~5.1.23",
|
|
56
|
+
"@xyo-network/wallet-model": "~5.1.23",
|
|
54
57
|
"typescript": "~5.9.3",
|
|
55
|
-
"vitest": "~4.0.
|
|
58
|
+
"vitest": "~4.0.9"
|
|
56
59
|
},
|
|
57
60
|
"publishConfig": {
|
|
58
61
|
"access": "public"
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"addressesContains.spec.d.ts","sourceRoot":"","sources":["../../../../../src/lib/addresses/spec/addressesContains.spec.ts"],"names":[],"mappings":"AAAA,OAAO,yBAAyB,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"addressesContainsAll.spec.d.ts","sourceRoot":"","sources":["../../../../../src/lib/addresses/spec/addressesContainsAll.spec.ts"],"names":[],"mappings":"AAAA,OAAO,yBAAyB,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"addressesContainsAny.spec.d.ts","sourceRoot":"","sources":["../../../../../src/lib/addresses/spec/addressesContainsAny.spec.ts"],"names":[],"mappings":"AAAA,OAAO,yBAAyB,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"boundWitnessArrayPropertyContains.spec.d.ts","sourceRoot":"","sources":["../../../../../src/lib/util/spec/boundWitnessArrayPropertyContains.spec.ts"],"names":[],"mappings":"AAAA,OAAO,yBAAyB,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"boundWitnessArrayPropertyContainsAll.spec.d.ts","sourceRoot":"","sources":["../../../../../src/lib/util/spec/boundWitnessArrayPropertyContainsAll.spec.ts"],"names":[],"mappings":"AAAA,OAAO,yBAAyB,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"boundWitnessArrayPropertyContainsAny.spec.d.ts","sourceRoot":"","sources":["../../../../../src/lib/util/spec/boundWitnessArrayPropertyContainsAny.spec.ts"],"names":[],"mappings":"AAAA,OAAO,yBAAyB,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Validator.spec.d.ts","sourceRoot":"","sources":["../../../src/spec/Validator.spec.ts"],"names":[],"mappings":"AAAA,OAAO,yBAAyB,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"addressesContains.spec.d.ts","sourceRoot":"","sources":["../../../../../src/lib/addresses/spec/addressesContains.spec.ts"],"names":[],"mappings":"AAAA,OAAO,yBAAyB,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"addressesContainsAll.spec.d.ts","sourceRoot":"","sources":["../../../../../src/lib/addresses/spec/addressesContainsAll.spec.ts"],"names":[],"mappings":"AAAA,OAAO,yBAAyB,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"addressesContainsAny.spec.d.ts","sourceRoot":"","sources":["../../../../../src/lib/addresses/spec/addressesContainsAny.spec.ts"],"names":[],"mappings":"AAAA,OAAO,yBAAyB,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"boundWitnessArrayPropertyContains.spec.d.ts","sourceRoot":"","sources":["../../../../../src/lib/util/spec/boundWitnessArrayPropertyContains.spec.ts"],"names":[],"mappings":"AAAA,OAAO,yBAAyB,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"boundWitnessArrayPropertyContainsAll.spec.d.ts","sourceRoot":"","sources":["../../../../../src/lib/util/spec/boundWitnessArrayPropertyContainsAll.spec.ts"],"names":[],"mappings":"AAAA,OAAO,yBAAyB,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"boundWitnessArrayPropertyContainsAny.spec.d.ts","sourceRoot":"","sources":["../../../../../src/lib/util/spec/boundWitnessArrayPropertyContainsAny.spec.ts"],"names":[],"mappings":"AAAA,OAAO,yBAAyB,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Validator.spec.d.ts","sourceRoot":"","sources":["../../../src/spec/Validator.spec.ts"],"names":[],"mappings":"AAAA,OAAO,yBAAyB,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"addressesContains.spec.d.ts","sourceRoot":"","sources":["../../../../../src/lib/addresses/spec/addressesContains.spec.ts"],"names":[],"mappings":"AAAA,OAAO,yBAAyB,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"addressesContainsAll.spec.d.ts","sourceRoot":"","sources":["../../../../../src/lib/addresses/spec/addressesContainsAll.spec.ts"],"names":[],"mappings":"AAAA,OAAO,yBAAyB,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"addressesContainsAny.spec.d.ts","sourceRoot":"","sources":["../../../../../src/lib/addresses/spec/addressesContainsAny.spec.ts"],"names":[],"mappings":"AAAA,OAAO,yBAAyB,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"boundWitnessArrayPropertyContains.spec.d.ts","sourceRoot":"","sources":["../../../../../src/lib/util/spec/boundWitnessArrayPropertyContains.spec.ts"],"names":[],"mappings":"AAAA,OAAO,yBAAyB,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"boundWitnessArrayPropertyContainsAll.spec.d.ts","sourceRoot":"","sources":["../../../../../src/lib/util/spec/boundWitnessArrayPropertyContainsAll.spec.ts"],"names":[],"mappings":"AAAA,OAAO,yBAAyB,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"boundWitnessArrayPropertyContainsAny.spec.d.ts","sourceRoot":"","sources":["../../../../../src/lib/util/spec/boundWitnessArrayPropertyContainsAny.spec.ts"],"names":[],"mappings":"AAAA,OAAO,yBAAyB,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Validator.spec.d.ts","sourceRoot":"","sources":["../../../src/spec/Validator.spec.ts"],"names":[],"mappings":"AAAA,OAAO,yBAAyB,CAAA"}
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
import '@xylabs/vitest-extended'
|
|
2
|
-
|
|
3
|
-
import { BoundWitnessBuilder } from '@xyo-network/boundwitness-builder'
|
|
4
|
-
import { HDWallet } from '@xyo-network/wallet'
|
|
5
|
-
import type { WalletInstance } from '@xyo-network/wallet-model'
|
|
6
|
-
import {
|
|
7
|
-
beforeAll,
|
|
8
|
-
describe, expect, it,
|
|
9
|
-
} from 'vitest'
|
|
10
|
-
|
|
11
|
-
import { addressesContains } from '../addressesContains.ts'
|
|
12
|
-
|
|
13
|
-
describe('addressesContains', () => {
|
|
14
|
-
const payload = { schema: 'network.xyo.test', value: Date.now() }
|
|
15
|
-
let oneWallet: WalletInstance[] = []
|
|
16
|
-
let twoWallets: WalletInstance[] = []
|
|
17
|
-
|
|
18
|
-
beforeAll(async () => {
|
|
19
|
-
oneWallet = [await HDWallet.random()]
|
|
20
|
-
twoWallets = [await HDWallet.random(), await HDWallet.random()]
|
|
21
|
-
})
|
|
22
|
-
|
|
23
|
-
const buildBoundWitness = async (signers: WalletInstance[]) => {
|
|
24
|
-
const [bw] = await new BoundWitnessBuilder().signers(signers).payload(payload).build()
|
|
25
|
-
return bw
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
describe('returns true', () => {
|
|
29
|
-
it('with a single wallet and the address is present', async () => {
|
|
30
|
-
const bw = await buildBoundWitness(oneWallet)
|
|
31
|
-
const address = oneWallet[0].address
|
|
32
|
-
expect(addressesContains(bw, address)).toBeTrue()
|
|
33
|
-
})
|
|
34
|
-
|
|
35
|
-
it('with multiple wallets and the address is present', async () => {
|
|
36
|
-
const bw = await buildBoundWitness(twoWallets)
|
|
37
|
-
const address = twoWallets[0].address
|
|
38
|
-
expect(addressesContains(bw, address)).toBeTrue()
|
|
39
|
-
})
|
|
40
|
-
|
|
41
|
-
it('with extra signers and the address is present', async () => {
|
|
42
|
-
const extraSigners = [...twoWallets, await HDWallet.random()]
|
|
43
|
-
const bw = await buildBoundWitness(extraSigners)
|
|
44
|
-
const address = twoWallets[1].address
|
|
45
|
-
expect(addressesContains(bw, address)).toBeTrue()
|
|
46
|
-
})
|
|
47
|
-
})
|
|
48
|
-
|
|
49
|
-
describe('returns false', () => {
|
|
50
|
-
it('with no signers', async () => {
|
|
51
|
-
const [bw] = await new BoundWitnessBuilder().payload(payload).build()
|
|
52
|
-
const address = oneWallet[0].address
|
|
53
|
-
expect(addressesContains(bw, address)).toBeFalse()
|
|
54
|
-
})
|
|
55
|
-
|
|
56
|
-
it('with a single wallet but a different address is checked', async () => {
|
|
57
|
-
const bw = await buildBoundWitness(oneWallet)
|
|
58
|
-
const randomAddress = (await HDWallet.random()).address
|
|
59
|
-
expect(addressesContains(bw, randomAddress)).toBeFalse()
|
|
60
|
-
})
|
|
61
|
-
|
|
62
|
-
it('with multiple wallets but a non-existing address is checked', async () => {
|
|
63
|
-
const bw = await buildBoundWitness(twoWallets)
|
|
64
|
-
const randomAddress = (await HDWallet.random()).address
|
|
65
|
-
expect(addressesContains(bw, randomAddress)).toBeFalse()
|
|
66
|
-
})
|
|
67
|
-
})
|
|
68
|
-
})
|
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
import '@xylabs/vitest-extended'
|
|
2
|
-
|
|
3
|
-
import type { Address } from '@xylabs/hex'
|
|
4
|
-
import { BoundWitnessBuilder } from '@xyo-network/boundwitness-builder'
|
|
5
|
-
import { HDWallet } from '@xyo-network/wallet'
|
|
6
|
-
import type { WalletInstance } from '@xyo-network/wallet-model'
|
|
7
|
-
import {
|
|
8
|
-
beforeAll,
|
|
9
|
-
describe, expect, it,
|
|
10
|
-
} from 'vitest'
|
|
11
|
-
|
|
12
|
-
import { addressesContainsAll } from '../addressesContainsAll.ts'
|
|
13
|
-
|
|
14
|
-
describe('addressesContainsAll', () => {
|
|
15
|
-
const payload = { schema: 'network.xyo.test', value: Date.now() }
|
|
16
|
-
let oneWallet: WalletInstance[] = []
|
|
17
|
-
let twoWallets: WalletInstance[] = []
|
|
18
|
-
|
|
19
|
-
beforeAll(async () => {
|
|
20
|
-
oneWallet = [await HDWallet.random()]
|
|
21
|
-
twoWallets = [await HDWallet.random(), await HDWallet.random()]
|
|
22
|
-
})
|
|
23
|
-
|
|
24
|
-
const buildBoundWitness = async (signers: WalletInstance[]) => {
|
|
25
|
-
const [bw] = await new BoundWitnessBuilder().signers(signers).payload(payload).build()
|
|
26
|
-
return bw
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
describe('returns true', () => {
|
|
30
|
-
const cases: [string, () => WalletInstance[]][] = [
|
|
31
|
-
['with no wallets', () => []],
|
|
32
|
-
['with single wallet', () => oneWallet],
|
|
33
|
-
['with multiple wallets', () => twoWallets],
|
|
34
|
-
]
|
|
35
|
-
it('with no signers and empty addresses supplied', async () => {
|
|
36
|
-
const bw = await buildBoundWitness([])
|
|
37
|
-
expect(addressesContainsAll(bw, [])).toBeTrue()
|
|
38
|
-
})
|
|
39
|
-
describe.each(cases)('%s', (_, wallets) => {
|
|
40
|
-
let addresses: Address[]
|
|
41
|
-
beforeAll(() => {
|
|
42
|
-
addresses = wallets().map(x => x.address)
|
|
43
|
-
})
|
|
44
|
-
it('with all wallets as signers and empty addresses supplied', async () => {
|
|
45
|
-
const bw = await buildBoundWitness(wallets())
|
|
46
|
-
expect(addressesContainsAll(bw, [])).toBeTrue()
|
|
47
|
-
})
|
|
48
|
-
it('with all wallets as signers and all wallet addresses supplied', async () => {
|
|
49
|
-
const bw = await buildBoundWitness(wallets())
|
|
50
|
-
expect(addressesContainsAll(bw, addresses)).toBeTrue()
|
|
51
|
-
})
|
|
52
|
-
it('with all wallets (and extra wallets) as signers and all wallet addresses supplied', async () => {
|
|
53
|
-
const extraSigners = [...wallets(), await HDWallet.random()]
|
|
54
|
-
const bw = await buildBoundWitness(extraSigners)
|
|
55
|
-
expect(addressesContainsAll(bw, addresses)).toBeTrue()
|
|
56
|
-
})
|
|
57
|
-
})
|
|
58
|
-
})
|
|
59
|
-
describe('returns false', () => {
|
|
60
|
-
const cases: [string, () => WalletInstance[]][] = [
|
|
61
|
-
['with single wallet', () => oneWallet],
|
|
62
|
-
['with multiple wallets', () => twoWallets],
|
|
63
|
-
]
|
|
64
|
-
describe.each(cases)('%s', (_, wallets) => {
|
|
65
|
-
let addresses: Address[]
|
|
66
|
-
beforeAll(() => {
|
|
67
|
-
addresses = wallets().map(x => x.address)
|
|
68
|
-
})
|
|
69
|
-
it('with no signers and all wallet addresses supplied', async () => {
|
|
70
|
-
const [bw] = await new BoundWitnessBuilder().payload(payload).build()
|
|
71
|
-
expect(addressesContainsAll(bw, addresses)).toBeFalse()
|
|
72
|
-
})
|
|
73
|
-
it('with all signers except one and all wallet addresses supplied', async () => {
|
|
74
|
-
const lessSigners = [...wallets().slice(0, -1), await HDWallet.random()]
|
|
75
|
-
const bw = await buildBoundWitness(lessSigners)
|
|
76
|
-
expect(addressesContainsAll(bw, addresses)).toBeFalse()
|
|
77
|
-
})
|
|
78
|
-
it('with all different signers and all wallet addresses supplied', async () => {
|
|
79
|
-
const differentSigners = [await HDWallet.random(), await HDWallet.random()]
|
|
80
|
-
const bw = await buildBoundWitness(differentSigners)
|
|
81
|
-
expect(addressesContainsAll(bw, addresses)).toBeFalse()
|
|
82
|
-
})
|
|
83
|
-
})
|
|
84
|
-
})
|
|
85
|
-
})
|
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
import '@xylabs/vitest-extended'
|
|
2
|
-
|
|
3
|
-
import type { Address } from '@xylabs/hex'
|
|
4
|
-
import { BoundWitnessBuilder } from '@xyo-network/boundwitness-builder'
|
|
5
|
-
import { HDWallet } from '@xyo-network/wallet'
|
|
6
|
-
import type { WalletInstance } from '@xyo-network/wallet-model'
|
|
7
|
-
import {
|
|
8
|
-
beforeAll,
|
|
9
|
-
describe, expect, it,
|
|
10
|
-
} from 'vitest'
|
|
11
|
-
|
|
12
|
-
import { addressesContainsAny } from '../addressesContainsAny.ts'
|
|
13
|
-
|
|
14
|
-
describe('addressesContainsAny', () => {
|
|
15
|
-
const payload = { schema: 'network.xyo.test', value: Date.now() }
|
|
16
|
-
let oneWallet: WalletInstance[] = []
|
|
17
|
-
let twoWallets: WalletInstance[] = []
|
|
18
|
-
beforeAll(async () => {
|
|
19
|
-
oneWallet = [await HDWallet.random()]
|
|
20
|
-
twoWallets = [await HDWallet.random(), await HDWallet.random()]
|
|
21
|
-
})
|
|
22
|
-
const buildBoundWitness = async (signers: WalletInstance[]) => {
|
|
23
|
-
const [bw] = await new BoundWitnessBuilder().signers(signers).payload(payload).build()
|
|
24
|
-
return bw
|
|
25
|
-
}
|
|
26
|
-
describe('returns true', () => {
|
|
27
|
-
const cases: [string, () => WalletInstance[]][] = [
|
|
28
|
-
['with no wallets', () => []],
|
|
29
|
-
['with single wallet', () => oneWallet],
|
|
30
|
-
['with multiple wallets', () => twoWallets],
|
|
31
|
-
]
|
|
32
|
-
it('with no signers and empty addresses supplied', async () => {
|
|
33
|
-
const bw = await buildBoundWitness([])
|
|
34
|
-
expect(addressesContainsAny(bw, [])).toBeTrue() // No signers and no addresses should return true
|
|
35
|
-
})
|
|
36
|
-
describe.each(cases)('%s', (_, wallets) => {
|
|
37
|
-
let addresses: Address[]
|
|
38
|
-
beforeAll(() => {
|
|
39
|
-
addresses = wallets().map(x => x.address)
|
|
40
|
-
})
|
|
41
|
-
it('with all wallets as signers and all wallet addresses supplied', async () => {
|
|
42
|
-
const bw = await buildBoundWitness(wallets())
|
|
43
|
-
expect(addressesContainsAny(bw, addresses)).toBeTrue() // Should be true if wallets exist
|
|
44
|
-
})
|
|
45
|
-
it('with all wallets (and extra wallets) as signers and all wallet addresses supplied', async () => {
|
|
46
|
-
const extraSigners = [...wallets(), await HDWallet.random()]
|
|
47
|
-
const bw = await buildBoundWitness(extraSigners)
|
|
48
|
-
expect(addressesContainsAny(bw, addresses)).toBeTrue() // Should still be true with extras
|
|
49
|
-
})
|
|
50
|
-
it('with only one matching signer', async () => {
|
|
51
|
-
const extraSigners = [await HDWallet.random(), ...wallets()]
|
|
52
|
-
const bw = await buildBoundWitness(extraSigners)
|
|
53
|
-
expect(addressesContainsAny(bw, addresses)).toBeTrue() // Should return true with one match
|
|
54
|
-
})
|
|
55
|
-
})
|
|
56
|
-
})
|
|
57
|
-
describe('returns false', () => {
|
|
58
|
-
const cases: [string, () => WalletInstance[]][] = [
|
|
59
|
-
// ['with no wallets', () => []],
|
|
60
|
-
['with single wallet', () => oneWallet],
|
|
61
|
-
['with multiple wallets', () => twoWallets],
|
|
62
|
-
]
|
|
63
|
-
describe.each(cases)('%s', (_, wallets) => {
|
|
64
|
-
let addresses: Address[]
|
|
65
|
-
beforeAll(() => {
|
|
66
|
-
addresses = wallets().map(x => x.address)
|
|
67
|
-
})
|
|
68
|
-
it('with no signers and all wallet addresses supplied', async () => {
|
|
69
|
-
const [bw] = await new BoundWitnessBuilder().payload(payload).build()
|
|
70
|
-
expect(addressesContainsAny(bw, addresses)).toBeFalse() // No signers, no match
|
|
71
|
-
})
|
|
72
|
-
it('with signers that do not include any of the wallet addresses supplied', async () => {
|
|
73
|
-
const differentSigners = [await HDWallet.random(), await HDWallet.random()]
|
|
74
|
-
const bw = await buildBoundWitness(differentSigners)
|
|
75
|
-
expect(addressesContainsAny(bw, addresses)).toBeFalse() // None of the wallet addresses are in the bound witness
|
|
76
|
-
})
|
|
77
|
-
it('with extra signers and no wallet addresses supplied', async () => {
|
|
78
|
-
const extraSigners = [await HDWallet.random(), await HDWallet.random()]
|
|
79
|
-
const bw = await buildBoundWitness(extraSigners)
|
|
80
|
-
expect(addressesContainsAny(bw, addresses)).toBeFalse() // None of the supplied addresses match
|
|
81
|
-
})
|
|
82
|
-
})
|
|
83
|
-
})
|
|
84
|
-
})
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
import '@xylabs/vitest-extended'
|
|
2
|
-
|
|
3
|
-
import { BoundWitnessBuilder } from '@xyo-network/boundwitness-builder'
|
|
4
|
-
import { HDWallet } from '@xyo-network/wallet'
|
|
5
|
-
import type { WalletInstance } from '@xyo-network/wallet-model'
|
|
6
|
-
import {
|
|
7
|
-
beforeAll,
|
|
8
|
-
describe, expect, it,
|
|
9
|
-
} from 'vitest'
|
|
10
|
-
|
|
11
|
-
import { boundWitnessArrayPropertyContains } from '../boundWitnessArrayPropertyContains.ts'
|
|
12
|
-
|
|
13
|
-
describe('boundWitnessArrayPropertyContains', () => {
|
|
14
|
-
const payload = { schema: 'network.xyo.test', value: Date.now() }
|
|
15
|
-
let oneWallet: WalletInstance[] = []
|
|
16
|
-
let twoWallets: WalletInstance[] = []
|
|
17
|
-
|
|
18
|
-
beforeAll(async () => {
|
|
19
|
-
oneWallet = [await HDWallet.random()]
|
|
20
|
-
twoWallets = [await HDWallet.random(), await HDWallet.random()]
|
|
21
|
-
})
|
|
22
|
-
|
|
23
|
-
const buildBoundWitness = async (signers: WalletInstance[]) => {
|
|
24
|
-
const [bw] = await new BoundWitnessBuilder().signers(signers).payload(payload).build()
|
|
25
|
-
return bw
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
describe('returns true', () => {
|
|
29
|
-
it('with a single wallet and the address is present', async () => {
|
|
30
|
-
const bw = await buildBoundWitness(oneWallet)
|
|
31
|
-
const address = oneWallet[0].address
|
|
32
|
-
expect(boundWitnessArrayPropertyContains(bw, 'addresses', address)).toBeTrue()
|
|
33
|
-
})
|
|
34
|
-
|
|
35
|
-
it('with multiple wallets and the address is present', async () => {
|
|
36
|
-
const bw = await buildBoundWitness(twoWallets)
|
|
37
|
-
const address = twoWallets[0].address
|
|
38
|
-
expect(boundWitnessArrayPropertyContains(bw, 'addresses', address)).toBeTrue()
|
|
39
|
-
})
|
|
40
|
-
|
|
41
|
-
it('with extra signers and the address is present', async () => {
|
|
42
|
-
const extraSigners = [...twoWallets, await HDWallet.random()]
|
|
43
|
-
const bw = await buildBoundWitness(extraSigners)
|
|
44
|
-
const address = twoWallets[1].address
|
|
45
|
-
expect(boundWitnessArrayPropertyContains(bw, 'addresses', address)).toBeTrue()
|
|
46
|
-
})
|
|
47
|
-
})
|
|
48
|
-
|
|
49
|
-
describe('returns false', () => {
|
|
50
|
-
it('with no signers', async () => {
|
|
51
|
-
const [bw] = await new BoundWitnessBuilder().payload(payload).build()
|
|
52
|
-
const address = oneWallet[0].address
|
|
53
|
-
expect(boundWitnessArrayPropertyContains(bw, 'addresses', address)).toBeFalse()
|
|
54
|
-
})
|
|
55
|
-
|
|
56
|
-
it('with a single wallet but a different address is checked', async () => {
|
|
57
|
-
const bw = await buildBoundWitness(oneWallet)
|
|
58
|
-
const randomAddress = (await HDWallet.random()).address
|
|
59
|
-
expect(boundWitnessArrayPropertyContains(bw, 'addresses', randomAddress)).toBeFalse()
|
|
60
|
-
})
|
|
61
|
-
|
|
62
|
-
it('with multiple wallets but a non-existing address is checked', async () => {
|
|
63
|
-
const bw = await buildBoundWitness(twoWallets)
|
|
64
|
-
const randomAddress = (await HDWallet.random()).address
|
|
65
|
-
expect(boundWitnessArrayPropertyContains(bw, 'addresses', randomAddress)).toBeFalse()
|
|
66
|
-
})
|
|
67
|
-
})
|
|
68
|
-
})
|
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
import '@xylabs/vitest-extended'
|
|
2
|
-
|
|
3
|
-
import type { Address } from '@xylabs/hex'
|
|
4
|
-
import { BoundWitnessBuilder } from '@xyo-network/boundwitness-builder'
|
|
5
|
-
import { HDWallet } from '@xyo-network/wallet'
|
|
6
|
-
import type { WalletInstance } from '@xyo-network/wallet-model'
|
|
7
|
-
import {
|
|
8
|
-
beforeAll,
|
|
9
|
-
describe, expect, it,
|
|
10
|
-
} from 'vitest'
|
|
11
|
-
|
|
12
|
-
import { boundWitnessArrayPropertyContainsAll } from '../boundWitnessArrayPropertyContainsAll.ts'
|
|
13
|
-
|
|
14
|
-
describe('boundWitnessArrayPropertyContainsAll', () => {
|
|
15
|
-
const payload = { schema: 'network.xyo.test', value: Date.now() }
|
|
16
|
-
let oneWallet: WalletInstance[] = []
|
|
17
|
-
let twoWallets: WalletInstance[] = []
|
|
18
|
-
|
|
19
|
-
beforeAll(async () => {
|
|
20
|
-
oneWallet = [await HDWallet.random()]
|
|
21
|
-
twoWallets = [await HDWallet.random(), await HDWallet.random()]
|
|
22
|
-
})
|
|
23
|
-
|
|
24
|
-
const buildBoundWitness = async (signers: WalletInstance[]) => {
|
|
25
|
-
const [bw] = await new BoundWitnessBuilder().signers(signers).payload(payload).build()
|
|
26
|
-
return bw
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
describe('returns true', () => {
|
|
30
|
-
const cases: [string, () => WalletInstance[]][] = [
|
|
31
|
-
['with no wallets', () => []],
|
|
32
|
-
['with single wallet', () => oneWallet],
|
|
33
|
-
['with multiple wallets', () => twoWallets],
|
|
34
|
-
]
|
|
35
|
-
it('with no signers and empty addresses supplied', async () => {
|
|
36
|
-
const bw = await buildBoundWitness([])
|
|
37
|
-
expect(boundWitnessArrayPropertyContainsAll(bw, 'addresses', [])).toBeTrue()
|
|
38
|
-
})
|
|
39
|
-
describe.each(cases)('%s', (_, wallets) => {
|
|
40
|
-
let addresses: Address[]
|
|
41
|
-
beforeAll(() => {
|
|
42
|
-
addresses = wallets().map(x => x.address)
|
|
43
|
-
})
|
|
44
|
-
it('with all wallets as signers and empty addresses supplied', async () => {
|
|
45
|
-
const bw = await buildBoundWitness(wallets())
|
|
46
|
-
expect(boundWitnessArrayPropertyContainsAll(bw, 'addresses', [])).toBeTrue()
|
|
47
|
-
})
|
|
48
|
-
it('with all wallets as signers and all wallet addresses supplied', async () => {
|
|
49
|
-
const bw = await buildBoundWitness(wallets())
|
|
50
|
-
expect(boundWitnessArrayPropertyContainsAll(bw, 'addresses', addresses)).toBeTrue()
|
|
51
|
-
})
|
|
52
|
-
it('with all wallets (and extra wallets) as signers and all wallet addresses supplied', async () => {
|
|
53
|
-
const extraSigners = [...wallets(), await HDWallet.random()]
|
|
54
|
-
const bw = await buildBoundWitness(extraSigners)
|
|
55
|
-
expect(boundWitnessArrayPropertyContainsAll(bw, 'addresses', addresses)).toBeTrue()
|
|
56
|
-
})
|
|
57
|
-
})
|
|
58
|
-
})
|
|
59
|
-
describe('returns false', () => {
|
|
60
|
-
const cases: [string, () => WalletInstance[]][] = [
|
|
61
|
-
['with single wallet', () => oneWallet],
|
|
62
|
-
['with multiple wallets', () => twoWallets],
|
|
63
|
-
]
|
|
64
|
-
describe.each(cases)('%s', (_, wallets) => {
|
|
65
|
-
let addresses: Address[]
|
|
66
|
-
beforeAll(() => {
|
|
67
|
-
addresses = wallets().map(x => x.address)
|
|
68
|
-
})
|
|
69
|
-
it('with no signers and all wallet addresses supplied', async () => {
|
|
70
|
-
const [bw] = await new BoundWitnessBuilder().payload(payload).build()
|
|
71
|
-
expect(boundWitnessArrayPropertyContainsAll(bw, 'addresses', addresses)).toBeFalse()
|
|
72
|
-
})
|
|
73
|
-
it('with all signers except one and all wallet addresses supplied', async () => {
|
|
74
|
-
const lessSigners = [...wallets().slice(0, -1), await HDWallet.random()]
|
|
75
|
-
const bw = await buildBoundWitness(lessSigners)
|
|
76
|
-
expect(boundWitnessArrayPropertyContainsAll(bw, 'addresses', addresses)).toBeFalse()
|
|
77
|
-
})
|
|
78
|
-
it('with all different signers and all wallet addresses supplied', async () => {
|
|
79
|
-
const differentSigners = [await HDWallet.random(), await HDWallet.random()]
|
|
80
|
-
const bw = await buildBoundWitness(differentSigners)
|
|
81
|
-
expect(boundWitnessArrayPropertyContainsAll(bw, 'addresses', addresses)).toBeFalse()
|
|
82
|
-
})
|
|
83
|
-
})
|
|
84
|
-
})
|
|
85
|
-
})
|
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
import '@xylabs/vitest-extended'
|
|
2
|
-
|
|
3
|
-
import type { Address } from '@xylabs/hex'
|
|
4
|
-
import { BoundWitnessBuilder } from '@xyo-network/boundwitness-builder'
|
|
5
|
-
import { HDWallet } from '@xyo-network/wallet'
|
|
6
|
-
import type { WalletInstance } from '@xyo-network/wallet-model'
|
|
7
|
-
import {
|
|
8
|
-
beforeAll,
|
|
9
|
-
describe, expect, it,
|
|
10
|
-
} from 'vitest'
|
|
11
|
-
|
|
12
|
-
import { boundWitnessArrayPropertyContainsAny } from '../boundWitnessArrayPropertyContainsAny.ts'
|
|
13
|
-
|
|
14
|
-
describe('boundWitnessArrayPropertyContainsAny', () => {
|
|
15
|
-
const payload = { schema: 'network.xyo.test', value: Date.now() }
|
|
16
|
-
let oneWallet: WalletInstance[] = []
|
|
17
|
-
let twoWallets: WalletInstance[] = []
|
|
18
|
-
beforeAll(async () => {
|
|
19
|
-
oneWallet = [await HDWallet.random()]
|
|
20
|
-
twoWallets = [await HDWallet.random(), await HDWallet.random()]
|
|
21
|
-
})
|
|
22
|
-
const buildBoundWitness = async (signers: WalletInstance[]) => {
|
|
23
|
-
const [bw] = await new BoundWitnessBuilder().signers(signers).payload(payload).build()
|
|
24
|
-
return bw
|
|
25
|
-
}
|
|
26
|
-
describe('returns true', () => {
|
|
27
|
-
const cases: [string, () => WalletInstance[]][] = [
|
|
28
|
-
['with no wallets', () => []],
|
|
29
|
-
['with single wallet', () => oneWallet],
|
|
30
|
-
['with multiple wallets', () => twoWallets],
|
|
31
|
-
]
|
|
32
|
-
it('with no signers and empty addresses supplied', async () => {
|
|
33
|
-
const bw = await buildBoundWitness([])
|
|
34
|
-
expect(boundWitnessArrayPropertyContainsAny(bw, 'addresses', [])).toBeTrue() // No signers and no addresses should return true
|
|
35
|
-
})
|
|
36
|
-
describe.each(cases)('%s', (_, wallets) => {
|
|
37
|
-
let addresses: Address[]
|
|
38
|
-
beforeAll(() => {
|
|
39
|
-
addresses = wallets().map(x => x.address)
|
|
40
|
-
})
|
|
41
|
-
it('with all wallets as signers and all wallet addresses supplied', async () => {
|
|
42
|
-
const bw = await buildBoundWitness(wallets())
|
|
43
|
-
expect(boundWitnessArrayPropertyContainsAny(bw, 'addresses', addresses)).toBeTrue() // Should be true if wallets exist
|
|
44
|
-
})
|
|
45
|
-
it('with all wallets (and extra wallets) as signers and all wallet addresses supplied', async () => {
|
|
46
|
-
const extraSigners = [...wallets(), await HDWallet.random()]
|
|
47
|
-
const bw = await buildBoundWitness(extraSigners)
|
|
48
|
-
expect(boundWitnessArrayPropertyContainsAny(bw, 'addresses', addresses)).toBeTrue() // Should still be true with extras
|
|
49
|
-
})
|
|
50
|
-
it('with only one matching signer', async () => {
|
|
51
|
-
const extraSigners = [await HDWallet.random(), ...wallets()]
|
|
52
|
-
const bw = await buildBoundWitness(extraSigners)
|
|
53
|
-
expect(boundWitnessArrayPropertyContainsAny(bw, 'addresses', addresses)).toBeTrue() // Should return true with one match
|
|
54
|
-
})
|
|
55
|
-
})
|
|
56
|
-
})
|
|
57
|
-
describe('returns false', () => {
|
|
58
|
-
const cases: [string, () => WalletInstance[]][] = [
|
|
59
|
-
// ['with no wallets', () => []],
|
|
60
|
-
['with single wallet', () => oneWallet],
|
|
61
|
-
['with multiple wallets', () => twoWallets],
|
|
62
|
-
]
|
|
63
|
-
describe.each(cases)('%s', (_, wallets) => {
|
|
64
|
-
let addresses: Address[]
|
|
65
|
-
beforeAll(() => {
|
|
66
|
-
addresses = wallets().map(x => x.address)
|
|
67
|
-
})
|
|
68
|
-
it('with no signers and all wallet addresses supplied', async () => {
|
|
69
|
-
const [bw] = await new BoundWitnessBuilder().payload(payload).build()
|
|
70
|
-
expect(boundWitnessArrayPropertyContainsAny(bw, 'addresses', addresses)).toBeFalse() // No signers, no match
|
|
71
|
-
})
|
|
72
|
-
it('with signers that do not include any of the wallet addresses supplied', async () => {
|
|
73
|
-
const differentSigners = [await HDWallet.random(), await HDWallet.random()]
|
|
74
|
-
const bw = await buildBoundWitness(differentSigners)
|
|
75
|
-
expect(boundWitnessArrayPropertyContainsAny(bw, 'addresses', addresses)).toBeFalse() // None of the wallet addresses are in the bound witness
|
|
76
|
-
})
|
|
77
|
-
it('with extra signers and no wallet addresses supplied', async () => {
|
|
78
|
-
const extraSigners = [await HDWallet.random(), await HDWallet.random()]
|
|
79
|
-
const bw = await buildBoundWitness(extraSigners)
|
|
80
|
-
expect(boundWitnessArrayPropertyContainsAny(bw, 'addresses', addresses)).toBeFalse() // None of the supplied addresses match
|
|
81
|
-
})
|
|
82
|
-
})
|
|
83
|
-
})
|
|
84
|
-
})
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import '@xylabs/vitest-extended'
|
|
2
|
-
|
|
3
|
-
import { BoundWitnessBuilder } from '@xyo-network/boundwitness-builder'
|
|
4
|
-
import type { Payload } from '@xyo-network/payload'
|
|
5
|
-
import { PayloadBuilder } from '@xyo-network/payload'
|
|
6
|
-
import { SchemaNameValidator } from '@xyo-network/schema-name-validator'
|
|
7
|
-
import { HDWallet } from '@xyo-network/wallet'
|
|
8
|
-
import type { WalletInstance } from '@xyo-network/wallet-model'
|
|
9
|
-
import { expect, test } from 'vitest'
|
|
10
|
-
|
|
11
|
-
import { BoundWitnessValidator } from '../Validator.ts'
|
|
12
|
-
|
|
13
|
-
const dumpErrors = (errors: Error[]) => {
|
|
14
|
-
for (const error of errors) {
|
|
15
|
-
console.log(error)
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
test('valid', async () => {
|
|
20
|
-
const wallet: WalletInstance = await HDWallet.random()
|
|
21
|
-
const payload: Payload = { schema: 'network.xyo.test' }
|
|
22
|
-
const [bw] = await new BoundWitnessBuilder().signers([wallet]).payloads([payload]).build()
|
|
23
|
-
BoundWitnessValidator.setSchemaNameValidatorFactory(schema => new SchemaNameValidator(schema))
|
|
24
|
-
const validator = new BoundWitnessValidator(bw)
|
|
25
|
-
const errors = await validator.validate()
|
|
26
|
-
dumpErrors(errors)
|
|
27
|
-
expect(errors.length).toBe(0)
|
|
28
|
-
})
|
|
29
|
-
|
|
30
|
-
test('invalid', async () => {
|
|
31
|
-
const wallet: WalletInstance = await HDWallet.random()
|
|
32
|
-
const payload = { schema: 'network.xyo.test' }
|
|
33
|
-
const [bw] = await new BoundWitnessBuilder().signers([wallet]).payloads([payload]).build()
|
|
34
|
-
bw.payload_hashes.push(await PayloadBuilder.dataHash(bw)) // this should make it invalid
|
|
35
|
-
bw.payload_schemas.push(bw.schema) // this should make it invalid
|
|
36
|
-
BoundWitnessValidator.setSchemaNameValidatorFactory(schema => new SchemaNameValidator(schema))
|
|
37
|
-
const validator = new BoundWitnessValidator(bw)
|
|
38
|
-
const errors = await validator.validate()
|
|
39
|
-
dumpErrors(errors)
|
|
40
|
-
expect(errors.length).toBeGreaterThan(0)
|
|
41
|
-
})
|