@xyo-network/xl1-validation 1.16.16 → 1.16.18

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
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "http://json.schemastore.org/package.json",
3
3
  "name": "@xyo-network/xl1-validation",
4
- "version": "1.16.16",
4
+ "version": "1.16.18",
5
5
  "description": "XYO Layer One SDK Validation",
6
6
  "homepage": "https://xylabs.com",
7
7
  "bugs": {
@@ -33,7 +33,10 @@
33
33
  "types": "./dist/neutral/index.d.ts",
34
34
  "files": [
35
35
  "dist",
36
- "src"
36
+ "src",
37
+ "!**/*.bench.*",
38
+ "!**/*.spec.*",
39
+ "!**/*.test.*"
37
40
  ],
38
41
  "dependencies": {
39
42
  "@xylabs/sdk-js": "~5.0.34",
@@ -43,8 +46,8 @@
43
46
  "@xyo-network/payload-builder": "~5.1.23",
44
47
  "@xyo-network/payload-model": "~5.1.23",
45
48
  "@xyo-network/xl1-protocol": "~1.13.11",
46
- "@xyo-network/xl1-protocol-sdk": "~1.16.16",
47
- "@xyo-network/xl1-schema": "~1.16.16",
49
+ "@xyo-network/xl1-protocol-sdk": "~1.16.18",
50
+ "@xyo-network/xl1-schema": "~1.16.18",
48
51
  "ajv": "~8.17.1"
49
52
  },
50
53
  "devDependencies": {
@@ -56,7 +59,7 @@
56
59
  "@xyo-network/account-model": "~5.1.23",
57
60
  "@xyo-network/archivist-memory": "~5.1.23",
58
61
  "@xyo-network/archivist-model": "~5.1.23",
59
- "@xyo-network/chain-protocol": "~1.16.16",
62
+ "@xyo-network/chain-protocol": "~1.16.18",
60
63
  "@xyo-network/wallet": "~5.1.23",
61
64
  "eslint": "^9.39.1",
62
65
  "typescript": "~5.9.3",
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=TransactionDurationValidator.spec.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"TransactionDurationValidator.spec.d.ts","sourceRoot":"","sources":["../../../../../src/transaction/validators/spec/TransactionDurationValidator.spec.ts"],"names":[],"mappings":""}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=TransactionElevationValidator.spec.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"TransactionElevationValidator.spec.d.ts","sourceRoot":"","sources":["../../../../../src/transaction/validators/spec/TransactionElevationValidator.spec.ts"],"names":[],"mappings":""}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=TransactionFromValidator.spec.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"TransactionFromValidator.spec.d.ts","sourceRoot":"","sources":["../../../../../src/transaction/validators/spec/TransactionFromValidator.spec.ts"],"names":[],"mappings":""}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=TransactionGasValidator.spec.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"TransactionGasValidator.spec.d.ts","sourceRoot":"","sources":["../../../../../src/transaction/validators/spec/TransactionGasValidator.spec.ts"],"names":[],"mappings":""}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=TransactionJsonSchemaValidator.spec.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"TransactionJsonSchemaValidator.spec.d.ts","sourceRoot":"","sources":["../../../../../src/transaction/validators/spec/TransactionJsonSchemaValidator.spec.ts"],"names":[],"mappings":""}
@@ -1,50 +0,0 @@
1
- import type { Address } from '@xylabs/sdk-js'
2
- import { Account } from '@xyo-network/account'
3
- import type { AccountInstance } from '@xyo-network/account-model'
4
- import { buildTransaction } from '@xyo-network/xl1-protocol-sdk'
5
- import {
6
- beforeAll, describe, expect, it,
7
- } from 'vitest'
8
-
9
- import { TransactionDurationValidator } from '../TransactionDurationValidator.ts'
10
-
11
- describe('TransactionDurationValidator', () => {
12
- const chain = 'a82920051db4fcbb804463440dd45e03f72442fd' as Address
13
- let signer: AccountInstance
14
- beforeAll(async () => {
15
- signer = await Account.random()
16
- })
17
- describe('with valid duration', () => {
18
- it('should return no errors', async () => {
19
- const hydratedTransaction = await buildTransaction(chain, [], [], signer, 0, 1000)
20
- const errors = await TransactionDurationValidator(hydratedTransaction, chain)
21
- expect(errors.length).toBe(0)
22
- })
23
- })
24
- describe('with invalid', () => {
25
- describe('nbf', () => {
26
- it('should return error if nbf too low', async () => {
27
- const hydratedTransaction = await buildTransaction(chain, [], [], signer, -1, 1000)
28
- const errors = await TransactionDurationValidator(hydratedTransaction, chain)
29
- expect(errors.length).toBeGreaterThan(0)
30
- })
31
- })
32
- describe('exp', () => {
33
- it('should return error if exp less than nbf', async () => {
34
- const hydratedTransaction = await buildTransaction(chain, [], [], signer, 1, 0)
35
- const errors = await TransactionDurationValidator(hydratedTransaction, chain)
36
- expect(errors.length).toBeGreaterThan(0)
37
- })
38
- it('should return error if exp is equal to nbf', async () => {
39
- const hydratedTransaction = await buildTransaction(chain, [], [], signer, 0, 0)
40
- const errors = await TransactionDurationValidator(hydratedTransaction, chain)
41
- expect(errors.length).toBeGreaterThan(0)
42
- })
43
- it('should return error if exp too high', async () => {
44
- const hydratedTransaction = await buildTransaction(chain, [], [], signer, 0, Number.MAX_SAFE_INTEGER)
45
- const errors = await TransactionDurationValidator(hydratedTransaction, chain)
46
- expect(errors.length).toBeGreaterThan(0)
47
- })
48
- })
49
- })
50
- })
@@ -1,40 +0,0 @@
1
- import type { Address } from '@xylabs/sdk-js'
2
- import { Account } from '@xyo-network/account'
3
- import type { AccountInstance } from '@xyo-network/account-model'
4
- import { buildRandomTransaction } from '@xyo-network/chain-protocol'
5
- import type { SignedHydratedTransactionWithStorageMeta, TransactionBoundWitness } from '@xyo-network/xl1-protocol'
6
- import { buildTransaction } from '@xyo-network/xl1-protocol-sdk'
7
- import {
8
- beforeAll, describe, expect, it,
9
- } from 'vitest'
10
-
11
- import { TransactionElevationValidator } from '../TransactionElevationValidator.ts'
12
-
13
- describe('TransactionDurationValidator', () => {
14
- const chain = 'a82920051db4fcbb804463440dd45e03f72442fd' as Address
15
- let signer: AccountInstance
16
- beforeAll(async () => {
17
- signer = await Account.random()
18
- })
19
- describe('should return no errors', () => {
20
- it('if all script hash payloads are supplied', async () => {
21
- const tx = await buildRandomTransaction(chain, [], signer)
22
- const result = await TransactionElevationValidator(tx, chain)
23
- expect(result.length).toBe(0)
24
- })
25
- it('when no payloads referenced in script hash', async () => {
26
- const sample = await buildRandomTransaction(chain, [], signer)
27
- const tx = await buildTransaction(chain, [], sample[1], signer, 1, 2)
28
- const result = await TransactionElevationValidator(tx, chain)
29
- expect(result.length).toBe(0)
30
- })
31
- })
32
- describe('should return errors', () => {
33
- it('if not all script hash payloads are supplied', async () => {
34
- const [bw] = await buildRandomTransaction(chain, [], signer)
35
- const tx = [bw, []] as SignedHydratedTransactionWithStorageMeta<TransactionBoundWitness>
36
- const result = await TransactionElevationValidator(tx, chain)
37
- expect(result.length).toBe(1)
38
- })
39
- })
40
- })
@@ -1,44 +0,0 @@
1
- import type { Address } from '@xylabs/sdk-js'
2
- import { Account } from '@xyo-network/account'
3
- import type { AccountInstance } from '@xyo-network/account-model'
4
- import type { WithStorageMeta } from '@xyo-network/payload-model'
5
- import type { SignedHydratedTransactionWithStorageMeta, TransactionBoundWitness } from '@xyo-network/xl1-protocol'
6
- import { buildTransaction } from '@xyo-network/xl1-protocol-sdk'
7
- import {
8
- beforeAll,
9
- beforeEach,
10
- describe, expect, it,
11
- } from 'vitest'
12
-
13
- import { TransactionFromValidator } from '../TransactionFromValidator.ts'
14
-
15
- describe('TransactionFromValidator', () => {
16
- const chain = 'a82920051db4fcbb804463440dd45e03f72442fd' as Address
17
- let signer: AccountInstance
18
- beforeAll(async () => {
19
- signer = await Account.random()
20
- })
21
- describe('with from empty', () => {
22
- let hydratedTransaction: SignedHydratedTransactionWithStorageMeta
23
- beforeEach(async () => {
24
- const transaction = await buildTransaction(chain, [], [], signer, 0, Number.MAX_SAFE_INTEGER)
25
- const { from, ...tx } = transaction[0]
26
- hydratedTransaction = [tx as WithStorageMeta<TransactionBoundWitness>, transaction[1]]
27
- })
28
- it('should return error', async () => {
29
- const errors = await TransactionFromValidator(hydratedTransaction, chain)
30
- expect(errors.length).toBeGreaterThan(0)
31
- })
32
- })
33
- describe('with from not in addresses', () => {
34
- let hydratedTransaction: SignedHydratedTransactionWithStorageMeta
35
- beforeEach(async () => {
36
- const from = await Account.random()
37
- hydratedTransaction = await buildTransaction(chain, [], [], signer, 0, Number.MAX_SAFE_INTEGER, from.address)
38
- })
39
- it('should return error', async () => {
40
- const errors = await TransactionFromValidator(hydratedTransaction, chain)
41
- expect(errors.length).toBeGreaterThan(0)
42
- })
43
- })
44
- })
@@ -1,89 +0,0 @@
1
- import { hexFromBigInt } from '@xylabs/sdk-js'
2
- import { Account } from '@xyo-network/account'
3
- import { buildRandomTransaction } from '@xyo-network/chain-protocol'
4
- import type {
5
- ChainId,
6
- SignedHydratedTransactionWithStorageMeta, TransactionBoundWitness, TransactionFeesHex,
7
- } from '@xyo-network/xl1-protocol'
8
- import {
9
- beforeAll, beforeEach, describe, expect, it,
10
- } from 'vitest'
11
-
12
- import { TransactionGasValidator } from '../TransactionGasValidator.ts'
13
-
14
- describe('TransactionGasValidator', () => {
15
- let chainId: ChainId
16
- let transaction: SignedHydratedTransactionWithStorageMeta
17
-
18
- beforeAll(async () => {
19
- chainId = (await Account.random()).address
20
- })
21
-
22
- beforeEach(async () => {
23
- transaction = await buildRandomTransaction(chainId)
24
- })
25
-
26
- describe('with valid transaction', () => {
27
- it('should return no errors for valid fees', async () => {
28
- const result = await TransactionGasValidator(transaction, chainId)
29
- expect(result).toEqual([])
30
- })
31
- })
32
-
33
- describe('with invalid transaction', () => {
34
- describe('fees', () => {
35
- it('should return an error if fees are missing', async () => {
36
- delete (transaction[0] as Partial<TransactionBoundWitness>).fees
37
- const result = await TransactionGasValidator(transaction, chainId)
38
- expect(result[0].message).toEqual('Missing fees')
39
- })
40
- })
41
-
42
- describe('base', () => {
43
- it('should return an error if fees.base is undefined', async () => {
44
- delete (transaction[0].fees as Partial<TransactionFeesHex>)?.base
45
- const result = await TransactionGasValidator(transaction, chainId)
46
- expect(result[0].message).toEqual('fees.base must be defined and a valid number')
47
- })
48
- it('should return an error if fees.base is less than or equal to 0', async () => {
49
- transaction[0].fees.base = hexFromBigInt(0n)
50
- const result = await TransactionGasValidator(transaction, chainId)
51
- expect(result.length).toEqual(1)
52
- })
53
- })
54
-
55
- describe('gasLimit', () => {
56
- it('should return an error if fees.gasLimit is undefined', async () => {
57
- delete (transaction[0].fees as Partial<TransactionFeesHex>)?.gasLimit
58
- const result = await TransactionGasValidator(transaction, chainId)
59
- expect(result[0].message).toEqual('fees.gasLimit must be defined and a valid number')
60
- })
61
- it('should return an error if fees.gasLimit is less than or equal to 0', async () => {
62
- transaction[0].fees.gasLimit = hexFromBigInt(0n)
63
- const result = await TransactionGasValidator(transaction, chainId)
64
- expect(result.length).toEqual(1)
65
- })
66
- })
67
- })
68
-
69
- describe('gasPrice', () => {
70
- it('should return an error if fees.gasPrice is undefined', async () => {
71
- delete (transaction[0].fees as Partial<TransactionFeesHex>)?.gasPrice
72
- const result = await TransactionGasValidator(transaction, chainId)
73
- expect(result[0].message).toEqual('fees.gasPrice must be defined and a valid number')
74
- })
75
- it('should return an error if fees.gasPrice is less than or equal to 0', async () => {
76
- transaction[0].fees.gasPrice = hexFromBigInt(0n)
77
- const result = await TransactionGasValidator(transaction, chainId)
78
- expect(result.length).toEqual(1)
79
- })
80
- })
81
-
82
- describe('priority', () => {
83
- it('should return an error if fees.priority is undefined', async () => {
84
- delete (transaction[0].fees as Partial<TransactionFeesHex>)?.priority
85
- const result = await TransactionGasValidator(transaction, chainId)
86
- expect(result[0].message).toEqual('fees.priority must be defined and a valid number')
87
- })
88
- })
89
- })
@@ -1,34 +0,0 @@
1
- import type { Address } from '@xylabs/sdk-js'
2
- import { buildRandomTransaction } from '@xyo-network/chain-protocol'
3
- import type { SignedHydratedTransactionWithStorageMeta } from '@xyo-network/xl1-protocol'
4
- import {
5
- beforeEach, describe, expect, it,
6
- } from 'vitest'
7
-
8
- import { TransactionJsonSchemaValidator } from '../TransactionJsonSchemaValidator.ts'
9
-
10
- describe('TransactionJsonSchemaValidator', () => {
11
- const chain = 'a82920051db4fcbb804463440dd45e03f72442fd' as Address
12
-
13
- describe('with valid transaction', () => {
14
- let hydratedTransaction: SignedHydratedTransactionWithStorageMeta
15
- beforeEach(async () => {
16
- hydratedTransaction = await buildRandomTransaction(chain)
17
- })
18
- it('should return no errors', async () => {
19
- const errors = await TransactionJsonSchemaValidator(hydratedTransaction, chain)
20
- expect(errors).toEqual([])
21
- })
22
- })
23
- describe('with invalid transaction', () => {
24
- let hydratedTransaction: SignedHydratedTransactionWithStorageMeta
25
- beforeEach(async () => {
26
- hydratedTransaction = await buildRandomTransaction(chain)
27
- hydratedTransaction[0].chain = 'invalid' as Address // intentionally invalid chain
28
- })
29
- it('should return error', async () => {
30
- const errors = await TransactionJsonSchemaValidator(hydratedTransaction, chain)
31
- expect(errors.length).toBeGreaterThan(0)
32
- })
33
- })
34
- })