@xyo-network/xl1-protocol-model 1.26.11 → 1.26.13

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.
Files changed (117) hide show
  1. package/package.json +28 -9
  2. package/src/BlockNumber/BlockNumber.ts +0 -24
  3. package/src/BlockNumber/EthBlockNumber.ts +0 -25
  4. package/src/BlockNumber/Numberish.ts +0 -9
  5. package/src/BlockNumber/XL1BlockNumber.ts +0 -25
  6. package/src/BlockNumber/index.ts +0 -4
  7. package/src/RecordKeyType.ts +0 -5
  8. package/src/Step/StepHash.ts +0 -10
  9. package/src/Step/StepIdentity.ts +0 -46
  10. package/src/Step/StepSizes.ts +0 -47
  11. package/src/Step/index.ts +0 -3
  12. package/src/TransferPayload.ts +0 -35
  13. package/src/amount/ShiftedBigIntConfig.ts +0 -8
  14. package/src/amount/XL1AmountInstance.ts +0 -19
  15. package/src/amount/index.ts +0 -2
  16. package/src/block/AllowedBlockPayload.ts +0 -73
  17. package/src/block/BlockBoundWitness.ts +0 -72
  18. package/src/block/HydratedBlock.ts +0 -135
  19. package/src/block/index.ts +0 -5
  20. package/src/block/signed/SignedBlockBoundWitness.ts +0 -22
  21. package/src/block/signed/SignedBlockBoundWitnessWithHashMeta.ts +0 -35
  22. package/src/block/signed/SignedBlockBoundWitnessWithStorageMeta.ts +0 -41
  23. package/src/block/signed/index.ts +0 -3
  24. package/src/block/unsigned/UnsignedBlockBoundWitness.ts +0 -22
  25. package/src/block/unsigned/index.ts +0 -1
  26. package/src/chain/Chain.ts +0 -7
  27. package/src/chain/ChainAnalyzer.ts +0 -11
  28. package/src/chain/ChainId.ts +0 -4
  29. package/src/chain/index.ts +0 -3
  30. package/src/fields/Addressable.ts +0 -7
  31. package/src/fields/BlockDuration.ts +0 -25
  32. package/src/fields/BlockNumber.ts +0 -40
  33. package/src/fields/ChainReference.ts +0 -11
  34. package/src/fields/index.ts +0 -4
  35. package/src/index.ts +0 -14
  36. package/src/map/AsyncMap.ts +0 -38
  37. package/src/map/MapType.ts +0 -27
  38. package/src/map/SyncMap.ts +0 -38
  39. package/src/map/index.ts +0 -3
  40. package/src/model/AccountBalance.ts +0 -58
  41. package/src/model/ArrayBuffer.ts +0 -44
  42. package/src/model/BlockRange/BlockRange.ts +0 -43
  43. package/src/model/BlockRange/EthBlockRange.ts +0 -43
  44. package/src/model/BlockRange/Numberish.ts +0 -6
  45. package/src/model/BlockRange/Range.ts +0 -17
  46. package/src/model/BlockRange/XL1BlockRange.ts +0 -43
  47. package/src/model/BlockRange/index.ts +0 -4
  48. package/src/model/BlockRate.ts +0 -108
  49. package/src/model/ChainQualification.ts +0 -48
  50. package/src/model/Context/BaseContext.ts +0 -6
  51. package/src/model/Context/BaseContext.zod.ts +0 -36
  52. package/src/model/Context/BlockContext.ts +0 -12
  53. package/src/model/Context/BlockContext.zod.ts +0 -20
  54. package/src/model/Context/CachingContext.ts +0 -6
  55. package/src/model/Context/CachingContext.zod.ts +0 -4
  56. package/src/model/Context/ChainContext.ts +0 -12
  57. package/src/model/Context/ChainContext.zod.ts +0 -17
  58. package/src/model/Context/HeadContext.ts +0 -6
  59. package/src/model/Context/HeadContext.zod.ts +0 -13
  60. package/src/model/Context/index.ts +0 -10
  61. package/src/model/GatewayName.ts +0 -4
  62. package/src/model/HydratedTransaction.ts +0 -169
  63. package/src/model/OpCodes.ts +0 -2
  64. package/src/model/PayloadMap.ts +0 -13
  65. package/src/model/Permission.ts +0 -29
  66. package/src/model/Position.ts +0 -21
  67. package/src/model/PositionId.ts +0 -4
  68. package/src/model/RangeMultipliers.ts +0 -13
  69. package/src/model/RewardShare.ts +0 -2
  70. package/src/model/RewardsRangeOptions.ts +0 -13
  71. package/src/model/Sequence.ts +0 -21
  72. package/src/model/Stake.ts +0 -47
  73. package/src/model/StakeShare.ts +0 -2
  74. package/src/model/TimeDomain.ts +0 -8
  75. package/src/model/TransferPair.ts +0 -7
  76. package/src/model/addresses.ts +0 -36
  77. package/src/model/defaultRewardRatio.ts +0 -3
  78. package/src/model/defaultTransactionFees.ts +0 -11
  79. package/src/model/index.ts +0 -27
  80. package/src/model/minTransactionFees.ts +0 -10
  81. package/src/model/rewards.ts +0 -18
  82. package/src/model/spec/fixtures/index.ts +0 -2
  83. package/src/model/spec/fixtures/signedHydratedTransaction.ts +0 -58
  84. package/src/model/spec/fixtures/unsignedHydratedTransaction.ts +0 -62
  85. package/src/model/version.ts +0 -10
  86. package/src/payload/StepIdentityPayload.ts +0 -25
  87. package/src/payload/elevatable/Bridge/BridgeCompletion.ts +0 -28
  88. package/src/payload/elevatable/Bridge/BridgeDestinationObservation.ts +0 -38
  89. package/src/payload/elevatable/Bridge/BridgeDetails.ts +0 -69
  90. package/src/payload/elevatable/Bridge/BridgeIntent.ts +0 -36
  91. package/src/payload/elevatable/Bridge/BridgeSourceObservation.ts +0 -37
  92. package/src/payload/elevatable/Bridge/index.ts +0 -5
  93. package/src/payload/elevatable/ChainStakeIntent.ts +0 -45
  94. package/src/payload/elevatable/Executable.ts +0 -35
  95. package/src/payload/elevatable/Hash.ts +0 -25
  96. package/src/payload/elevatable/StepComplete.ts +0 -31
  97. package/src/payload/elevatable/Time.ts +0 -61
  98. package/src/payload/elevatable/index.ts +0 -6
  99. package/src/payload/index.ts +0 -2
  100. package/src/provider/Provider.ts +0 -6
  101. package/src/provider/ProviderMoniker.ts +0 -15
  102. package/src/provider/index.ts +0 -2
  103. package/src/transaction/TransactionBoundWitness.ts +0 -187
  104. package/src/transaction/TransactionFees.ts +0 -73
  105. package/src/transaction/TransactionGasCosts.ts +0 -42
  106. package/src/transaction/index.ts +0 -3
  107. package/src/xl1/AttoXL1.ts +0 -19
  108. package/src/xl1/FemtoXL1.ts +0 -20
  109. package/src/xl1/MicroXL1.ts +0 -20
  110. package/src/xl1/MilliXL1.ts +0 -20
  111. package/src/xl1/NanoXL1.ts +0 -20
  112. package/src/xl1/PicoXL1.ts +0 -20
  113. package/src/xl1/XL1.ts +0 -20
  114. package/src/xl1/XL1Units.ts +0 -26
  115. package/src/xl1/index.ts +0 -8
  116. package/src/xl1/isXL1Factory.ts +0 -56
  117. package/src/xl1/xl1MaxValue.ts +0 -2
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xyo-network/xl1-protocol-model",
3
- "version": "1.26.11",
3
+ "version": "1.26.13",
4
4
  "description": "XYO Layer One Protocol Model Types",
5
5
  "homepage": "https://xylabs.com",
6
6
  "bugs": {
@@ -22,7 +22,6 @@
22
22
  "exports": {
23
23
  ".": {
24
24
  "types": "./dist/neutral/index.d.ts",
25
- "source": "./src/index.ts",
26
25
  "default": "./dist/neutral/index.mjs"
27
26
  },
28
27
  "./package.json": "./package.json"
@@ -32,21 +31,41 @@
32
31
  "types": "./dist/neutral/index.d.ts",
33
32
  "files": [
34
33
  "dist",
35
- "src",
36
34
  "!**/*.bench.*",
37
35
  "!**/*.spec.*",
38
- "!**/*.test.*"
36
+ "!**/*.test.*",
37
+ "README.md"
39
38
  ],
40
39
  "devDependencies": {
40
+ "@firebase/app": "0.x",
41
+ "@firebase/app-compat": "0.x",
42
+ "@firebase/app-types": "0.x",
43
+ "@firebase/util": "1.x",
44
+ "@metamask/providers": "^22",
41
45
  "@opentelemetry/api": "^1.9.1",
42
46
  "@types/node": "^25.5.0",
43
- "@xylabs/sdk-js": "^5.0.90",
44
- "@xylabs/ts-scripts-common": "~7.5.6",
45
- "@xylabs/ts-scripts-yarn3": "~7.5.6",
46
- "@xylabs/tsconfig": "~7.5.6",
47
- "@xyo-network/sdk-js": "^5.3.17",
47
+ "@xylabs/geo": "^5",
48
+ "@xylabs/sdk-js": "^5.0.91",
49
+ "@xylabs/ts-scripts-common": "~7.6.13",
50
+ "@xylabs/ts-scripts-yarn3": "~7.6.13",
51
+ "@xylabs/tsconfig": "~7.6.13",
52
+ "@xyo-network/sdk-js": "^5.3.22",
53
+ "acorn": "^6.0.0 || ^7.0.0 || ^8.0.0",
54
+ "ajv": "^8",
55
+ "axios": "^1.14.0",
56
+ "cosmiconfig": ">=9",
57
+ "esbuild": ">=0.18",
58
+ "eslint": "^6.0.0 || ^7.0.0 || >=8.0.0",
59
+ "ethers": "^6.16.0",
60
+ "firebase": "^12",
61
+ "lru-cache": "^11",
62
+ "mapbox-gl": "^3",
63
+ "rollup": "^3.29.4 || ^4",
64
+ "tslib": "^2.8.1",
48
65
  "typescript": "~5.9.3",
66
+ "vite": "^8.0.3",
49
67
  "vitest": "~4.1.2",
68
+ "webextension-polyfill": "^0.10.0 || ^0.11.0 || ^0.12.0",
50
69
  "zod": "~4.3.6"
51
70
  },
52
71
  "peerDependencies": {
@@ -1,24 +0,0 @@
1
- import { type Brand } from '@xylabs/sdk-js'
2
- import { zodAsFactory, zodToFactory } from '@xylabs/sdk-js'
3
- import { z } from 'zod'
4
-
5
- import { NumberishZod } from './Numberish.ts'
6
-
7
- /** Branded number type representing a generic block number */
8
- export type BlockNumber = Brand<number, { readonly __blockNumber: true }>
9
-
10
- /** Zod schema that validates and brands a number as a BlockNumber */
11
- export const BlockNumberZod = z.number().transform(v => v as BlockNumber)
12
- /** Zod schema that coerces a Numberish value into a BlockNumber */
13
- export const BlockNumberishZod = NumberishZod.transform(v => v as BlockNumber)
14
-
15
- /** Input type for BlockNumberishZod, accepting number, string, or bigint */
16
- export type BlockNumberish = z.input<typeof BlockNumberishZod>
17
-
18
- /** Casts a number to BlockNumber, returning undefined if validation fails */
19
- export const asBlockNumber = zodAsFactory<BlockNumber>(BlockNumberZod, 'asBlockNumber')
20
- /** Coerces a Numberish value to BlockNumber, returning undefined if conversion fails */
21
- export const toBlockNumber = zodToFactory<BlockNumber>(BlockNumberishZod, 'toBlockNumber')
22
-
23
- /** The zero block number constant */
24
- export const BLOCK_NUMBER_ZERO = asBlockNumber(0)
@@ -1,25 +0,0 @@
1
- import { type Brand } from '@xylabs/sdk-js'
2
- import { zodAsFactory, zodToFactory } from '@xylabs/sdk-js'
3
- import { z } from 'zod'
4
-
5
- import type { BlockNumber } from './BlockNumber.ts'
6
- import { BlockNumberishZod } from './BlockNumber.ts'
7
-
8
- /** Branded type representing a block number on the Ethereum chain */
9
- export type EthBlockNumber = Brand<BlockNumber, { readonly __ethBlockNumber: true }>
10
-
11
- /** Zod schema that validates and brands a number as an EthBlockNumber */
12
- export const EthBlockNumberZod = z.number().transform(v => v as EthBlockNumber)
13
- /** Zod schema that coerces a Numberish value into an EthBlockNumber */
14
- export const EthBlockNumberishZod = BlockNumberishZod.transform(v => v as EthBlockNumber)
15
-
16
- /** Input type for EthBlockNumberishZod, accepting number, string, or bigint */
17
- export type EthBlockNumberish = z.input<typeof EthBlockNumberishZod>
18
-
19
- /** Casts a number to EthBlockNumber, returning undefined if validation fails */
20
- export const asEthBlockNumber = zodAsFactory<EthBlockNumber>(EthBlockNumberZod, 'asEthBlockNumber')
21
- /** Coerces a Numberish value to EthBlockNumber, returning undefined if conversion fails */
22
- export const toEthBlockNumber = zodToFactory<EthBlockNumber>(EthBlockNumberishZod, 'toEthBlockNumber')
23
-
24
- /** The zero block number constant for the Ethereum chain */
25
- export const ETH_BLOCK_NUMBER_ZERO = asEthBlockNumber(0)
@@ -1,9 +0,0 @@
1
- import { z } from 'zod'
2
-
3
- /** Zod schema that accepts number, string, or bigint and coerces to number */
4
- export const NumberishZod = z.union([z.number(), z.string(), z.bigint()])
5
- .transform(v => (typeof v === 'bigint' ? Number(v) : typeof v === 'string' ? Number(v) : v))
6
- .pipe(z.number())
7
-
8
- /** A value that can be coerced to a number: number, string, or bigint */
9
- export type Numberish = z.input<typeof NumberishZod>
@@ -1,25 +0,0 @@
1
- import { type Brand } from '@xylabs/sdk-js'
2
- import { zodAsFactory, zodToFactory } from '@xylabs/sdk-js'
3
- import { z } from 'zod'
4
-
5
- import type { BlockNumber } from './BlockNumber.ts'
6
- import { BlockNumberishZod } from './BlockNumber.ts'
7
-
8
- /** Branded type representing a block number on the XL1 chain */
9
- export type XL1BlockNumber = Brand<BlockNumber, { readonly __xl1BlockNumber: true }>
10
-
11
- /** Zod schema that validates and brands a number as an XL1BlockNumber */
12
- export const XL1BlockNumberZod = z.number().transform(v => v as XL1BlockNumber)
13
- /** Zod schema that coerces a Numberish value into an XL1BlockNumber */
14
- export const XL1BlockNumberishZod = BlockNumberishZod.transform(v => v as XL1BlockNumber)
15
-
16
- /** Input type for XL1BlockNumberishZod, accepting number, string, or bigint */
17
- export type XL1BlockNumberish = z.input<typeof XL1BlockNumberishZod>
18
-
19
- /** Casts a number to XL1BlockNumber, returning undefined if validation fails */
20
- export const asXL1BlockNumber = zodAsFactory<XL1BlockNumber>(XL1BlockNumberZod, 'asXL1BlockNumber')
21
- /** Coerces a Numberish value to XL1BlockNumber, returning undefined if conversion fails */
22
- export const toXL1BlockNumber = zodToFactory<XL1BlockNumber>(XL1BlockNumberishZod, 'toXL1BlockNumber')
23
-
24
- /** The zero block number constant for the XL1 chain */
25
- export const XL1_BLOCK_NUMBER_ZERO = asXL1BlockNumber(0)
@@ -1,4 +0,0 @@
1
- export * from './BlockNumber.ts'
2
- export * from './EthBlockNumber.ts'
3
- export * from './Numberish.ts'
4
- export * from './XL1BlockNumber.ts'
@@ -1,5 +0,0 @@
1
- /* eslint-disable @typescript-eslint/no-explicit-any */
2
- /** Utility type that constrains T to valid record key types (string, number, or symbol) */
3
-
4
- /** RecordKeyType type. */
5
- export type RecordKeyType<T = keyof any> = T extends keyof any ? T : never
@@ -1,10 +0,0 @@
1
- import type { Brand, Hash } from '@xylabs/sdk-js'
2
-
3
- /** A block hash paired with its step index */
4
- export interface StepHash {
5
- block: Hash
6
- step: number
7
- }
8
-
9
- /** Branded string representing a hash and step index separated by a pipe character */
10
- export type StepHashString = Brand<string, { readonly __stepHashString: true }>
@@ -1,46 +0,0 @@
1
- import { type Brand, isUndefined } from '@xylabs/sdk-js'
2
- import { z } from 'zod'
3
-
4
- import { toXL1BlockNumber, XL1BlockNumberZod } from '../BlockNumber/index.ts'
5
-
6
- /** Zod schema for a step identity combining a block number and step index */
7
- export const StepIdentityZod = z.object({
8
- block: XL1BlockNumberZod.describe('The block number at which the step occurs'),
9
- step: z.number().int().nonnegative().describe('The index of the step into the StepSize array'),
10
- })
11
- /** Identifies a specific step by its block number and step index */
12
- export type StepIdentity = z.infer<typeof StepIdentityZod>
13
-
14
- /** @deprecated use StepIdentity instead */
15
- export interface StepContext extends StepIdentity {}
16
-
17
- /** Branded string representing a block number and step index separated by a pipe character */
18
- export type StepIdentityString = Brand<string, { readonly __stepIdentityString: true }>
19
-
20
- function tryParseInt(value: string): number | undefined {
21
- // Prevent coercion of empty strings to 0
22
- if (value === '') return undefined
23
- // Parse number
24
- const num = Number(value)
25
- // Check if integer
26
- return Number.isInteger(num) ? num : undefined
27
- }
28
-
29
- /** Parses a pipe-separated string into a StepIdentity, returning undefined if invalid */
30
- export const asStepIdentity = (stepIdentityString: string): StepIdentity | undefined => {
31
- try {
32
- const [blockNumberString, stepString] = stepIdentityString.split('|')
33
- if (isUndefined(blockNumberString) || isUndefined(stepString)) {
34
- return undefined
35
- }
36
- const step = tryParseInt(stepString)
37
- const block = toXL1BlockNumber(blockNumberString)
38
- if (isUndefined(block) || isUndefined(step)) {
39
- return undefined
40
- }
41
-
42
- return { block, step }
43
- } catch {
44
- return undefined
45
- }
46
- }
@@ -1,47 +0,0 @@
1
- import { AsTypeFactory } from '@xylabs/sdk-js'
2
-
3
- import { asXL1BlockNumber, type XL1BlockNumber } from '../BlockNumber/index.ts'
4
-
5
- // StepsV2 are primorial(n+2) + 1, where n is the index of the step size
6
- // primorial(n+2) = 2 → 2×3=6 → 6×5=30 → 30×7=210 → 210×11=2310
7
-
8
- /** Array of step sizes based on primorial(n+2) + 1, defining the block intervals for each step level */
9
- export const StepSizes: XL1BlockNumber[] = [
10
- asXL1BlockNumber(7, true),
11
- asXL1BlockNumber(31, true),
12
- asXL1BlockNumber(211, true),
13
- asXL1BlockNumber(2311, true),
14
- asXL1BlockNumber(30_031, true),
15
- asXL1BlockNumber(510_511, true),
16
- asXL1BlockNumber(9_699_691, true),
17
- asXL1BlockNumber(223_092_871, true),
18
- asXL1BlockNumber(6_469_693_231, true),
19
- ]
20
-
21
- /** Type guard that checks if a value is a valid step index within the StepSizes array */
22
- export function isValidStep(step: unknown): step is number {
23
- if (typeof step === 'number' && Number.isInteger(step)) {
24
- return ((step >= 0) && (step < StepSizes.length))
25
- }
26
- return false
27
- }
28
-
29
- /** Casts a value to a valid step index, returning undefined if invalid */
30
- export const asValidStep = AsTypeFactory.create<number>(isValidStep)
31
-
32
- /** Returns the block interval size for a given step index */
33
- export function stepSize(step: number): number {
34
- const validatedStep = asValidStep(step, () => `Invalid step (${step}), must be an integer between 0 and ${StepSizes.length - 1}`, { required: true })
35
- return StepSizes[validatedStep]
36
- }
37
-
38
- /** Fraction of block rewards allocated at each step level, expressed as [numerator, denominator] pairs */
39
- export const StepRewardFractions = [
40
- [0n, 1n], // 0%
41
- [0n, 1n], // 0%
42
- [0n, 1n], // 0%
43
- [1n, 10_000n], // 0.01%
44
- [2n, 1000n], // 0.2%
45
- [3n, 100n], // 3%
46
- [45n, 100n], // 45%
47
- ] as const
package/src/Step/index.ts DELETED
@@ -1,3 +0,0 @@
1
- export * from './StepHash.ts'
2
- export * from './StepIdentity.ts'
3
- export * from './StepSizes.ts'
@@ -1,35 +0,0 @@
1
- import {
2
- AddressZod,
3
- AsObjectFactory, HexZod, JsonObjectZod,
4
- } from '@xylabs/sdk-js'
5
- import {
6
- asSchema, isPayloadOfSchemaType, PayloadZodOfSchema,
7
- } from '@xyo-network/sdk-js'
8
- import { z } from 'zod'
9
-
10
- /** Schema identifier for XYO transfer payloads */
11
- export const TransferSchema = asSchema('network.xyo.transfer', true)
12
- /** The literal type of the transfer schema string */
13
- export type TransferSchema = typeof TransferSchema
14
-
15
- /** Zod schema for the fields specific to a transfer payload */
16
- export const TransferFieldsZod = z.object({
17
- // Removed as only transaction have opCodes
18
- // $opCodes: z.array(z.string()).optional(),
19
- context: JsonObjectZod.optional(),
20
- epoch: z.number(),
21
- from: AddressZod,
22
- transfers: z.record(AddressZod, HexZod),
23
- })
24
-
25
- /** Zod schema for a complete transfer payload including schema and fields */
26
- export const TransferZod = PayloadZodOfSchema(TransferSchema).extend(TransferFieldsZod.shape)
27
-
28
- /** A transfer payload representing the movement of XL1 tokens between addresses */
29
- export type Transfer = z.infer<typeof TransferZod>
30
-
31
- /** Type guard that checks if a value is a Transfer payload */
32
- export const isTransfer = isPayloadOfSchemaType<Transfer>(TransferSchema)
33
-
34
- /** Casts a value to Transfer or returns undefined if invalid */
35
- export const asTransfer = AsObjectFactory.create(isTransfer)
@@ -1,8 +0,0 @@
1
- /** Configuration for formatting a ShiftedBigInt as a decimal string */
2
- export interface ShiftedBigIntConfig {
3
- locale: Intl.LocalesArgument
4
- maxCharacters: number
5
- maxDecimal: number
6
- minDecimals: number
7
- places: number
8
- }
@@ -1,19 +0,0 @@
1
- import type {
2
- AttoXL1, FemtoXL1, MicroXL1, MilliXL1, NanoXL1, PicoXL1, XL1,
3
- } from '../xl1/index.ts'
4
- import type { ShiftedBigIntConfig } from './ShiftedBigIntConfig.ts'
5
-
6
- /** Interface for an XL1 token amount with conversion accessors for various denominations */
7
- export interface XL1AmountInstance {
8
- atto: AttoXL1
9
- femto: FemtoXL1
10
- micro: MicroXL1
11
- milli: MilliXL1
12
- nano: NanoXL1
13
- pico: PicoXL1
14
- value: AttoXL1
15
- xl1: XL1
16
-
17
- to(places: bigint | number): bigint
18
- toString(places: number, config: Partial<ShiftedBigIntConfig>): string
19
- }
@@ -1,2 +0,0 @@
1
- export * from './ShiftedBigIntConfig.ts'
2
- export * from './XL1AmountInstance.ts'
@@ -1,73 +0,0 @@
1
- import { zodIsFactory } from '@xylabs/sdk-js'
2
- import type {
3
- Schema, SchemaPayload, WithStorageMeta,
4
- } from '@xyo-network/sdk-js'
5
- import {
6
- BoundWitnessSchema, isHashMeta, isSchemaPayload, SchemaSchema,
7
- } from '@xyo-network/sdk-js'
8
- import { z } from 'zod'
9
-
10
- import type {
11
- BridgeDestinationObservation, BridgeIntent, BridgeSourceObservation, ChainStakeIntent, HashPayload, StepComplete, TimePayload,
12
- } from '../payload/index.ts'
13
- import {
14
- BridgeDestinationObservationSchema, BridgeIntentSchema, BridgeSourceObservationSchema, ChainStakeIntentSchema, HashSchema,
15
- isBridgeDestinationObservation, isBridgeIntent, isBridgeSourceObservation, isChainStakeIntent, isHashPayload, isTimePayload, StepCompleteSchema,
16
- TimeSchema,
17
- } from '../payload/index.ts'
18
- import { isTransactionBoundWitness, type TransactionBoundWitness } from '../transaction/index.ts'
19
- import {
20
- isTransfer, type Transfer, TransferSchema,
21
- } from '../TransferPayload.ts'
22
-
23
- /** AllowedBlockPayload type. */
24
- export type AllowedBlockPayload
25
- = | BridgeDestinationObservation
26
- | BridgeIntent
27
- | BridgeSourceObservation
28
- | ChainStakeIntent
29
- | HashPayload
30
- | SchemaPayload
31
- | StepComplete
32
- | TimePayload
33
- | TransactionBoundWitness
34
- | Transfer
35
-
36
- /** AllowedBlockPayloadSchemas constant. */
37
- export const AllowedBlockPayloadSchemas = [
38
- BoundWitnessSchema,
39
- BridgeDestinationObservationSchema,
40
- BridgeIntentSchema,
41
- BridgeSourceObservationSchema,
42
- ChainStakeIntentSchema,
43
- HashSchema,
44
- SchemaSchema,
45
- StepCompleteSchema,
46
- TimeSchema,
47
- TransferSchema,
48
- ] satisfies Schema[]
49
-
50
- /** AllowedBlockPayloadSchemaZod constant. */
51
- export const AllowedBlockPayloadSchemaZod = z.enum(AllowedBlockPayloadSchemas)
52
- /** Schema type for AllowedBlockPayload payloads. */
53
- export type AllowedBlockPayloadSchema = z.infer<typeof AllowedBlockPayloadSchemaZod>
54
- /** Schema identifier for isAllowedBlockPayload payloads. */
55
- export const isAllowedBlockPayloadSchema = zodIsFactory(AllowedBlockPayloadSchemaZod)
56
-
57
- /** Type guard that checks if a value is a valid AllowedBlockPayload. */
58
- export const isAllowedBlockPayload = <T>(value: T): value is AllowedBlockPayload & T => {
59
- return isTransfer(value)
60
- || isBridgeDestinationObservation(value)
61
- || isBridgeIntent(value)
62
- || isBridgeSourceObservation(value)
63
- || isChainStakeIntent(value)
64
- || isHashPayload(value)
65
- || isSchemaPayload(value)
66
- || isTimePayload(value)
67
- || isTransactionBoundWitness(value)
68
- }
69
-
70
- /** Type guard that checks if a value is a valid AllowedBlockPayloadWithHashMeta. */
71
- export const isAllowedBlockPayloadWithHashMeta = <T>(value: T): value is WithStorageMeta<AllowedBlockPayload & T> => {
72
- return isAllowedBlockPayload(value) && isHashMeta(value)
73
- }
@@ -1,72 +0,0 @@
1
- import {
2
- HashZod,
3
- zodAsFactory, zodIsFactory, zodToFactory,
4
- } from '@xylabs/sdk-js'
5
- import {
6
- BoundWitnessZod,
7
- WithHashMetaZod,
8
- WithStorageMetaZod,
9
- } from '@xyo-network/sdk-js'
10
- import { z } from 'zod'
11
-
12
- import { XL1BlockNumberZod } from '../BlockNumber/index.ts'
13
- import { ChainZod } from '../chain/index.ts'
14
-
15
- /** BlockBoundWitnessFieldsZod constant. */
16
- export const BlockBoundWitnessFieldsZod = z.object({
17
- block: XL1BlockNumberZod,
18
- chain: ChainZod,
19
- previous: HashZod.nullable(),
20
- protocol: z.number().optional(),
21
- step_hashes: z.array(HashZod).optional(),
22
- })
23
-
24
- /** BlockBoundWitnessMetaZod constant. */
25
- export const BlockBoundWitnessMetaZod = z.object({ $epoch: z.number() })
26
-
27
- /** BlockBoundWitnessZod constant. */
28
- export const BlockBoundWitnessZod = z.object({
29
- ...BoundWitnessZod.shape,
30
- ...BlockBoundWitnessFieldsZod.shape,
31
- ...BlockBoundWitnessMetaZod.shape,
32
- })
33
-
34
- /** BlockBoundWitness type. */
35
- export type BlockBoundWitness = z.infer<typeof BlockBoundWitnessZod>
36
-
37
- /** Type guard that checks if a value is a valid BlockBoundWitness. */
38
- export const isBlockBoundWitness = zodIsFactory(BlockBoundWitnessZod)
39
- /** Converts a value to BlockBoundWitness, throwing if invalid. */
40
- export const asBlockBoundWitness = zodAsFactory(BlockBoundWitnessZod, 'asBlockBoundWitness')
41
- /** toBlockBoundWitness constant. */
42
- export const toBlockBoundWitness = zodToFactory(BlockBoundWitnessZod, 'toBlockBoundWitness')
43
-
44
- /** @deprecated use WithHashMetaZod(BlockBoundWitnessZod) instead */
45
- export const BlockBoundWitnessWithHashMetaZod = WithHashMetaZod(BlockBoundWitnessZod)
46
-
47
- /** @deprecated use WithHashMeta(BlockBoundWitness) instead */
48
-
49
- /** BlockBoundWitnessWithHashMeta type. */
50
- export type BlockBoundWitnessWithHashMeta = z.infer<typeof BlockBoundWitnessWithHashMetaZod>
51
-
52
- /** Type guard that checks if a value is a valid BlockBoundWitnessWithHashMeta. */
53
- export const isBlockBoundWitnessWithHashMeta = zodIsFactory(WithHashMetaZod(BlockBoundWitnessZod))
54
- /** Converts a value to BlockBoundWitnessWithHashMeta, throwing if invalid. */
55
- export const asBlockBoundWitnessWithHashMeta = zodAsFactory(WithHashMetaZod(BlockBoundWitnessZod), 'asBlockBoundWitnessWithHashMeta')
56
- /** toBlockBoundWitnessWithHashMeta constant. */
57
- export const toBlockBoundWitnessWithHashMeta = zodToFactory(WithHashMetaZod(BlockBoundWitnessZod), 'toBlockBoundWitnessWithHashMeta')
58
-
59
- /** @deprecated use WithStorageMetaZod(BlockBoundWitnessZod) instead */
60
- export const BlockBoundWitnessWithStorageMetaZod = WithStorageMetaZod(BlockBoundWitnessZod)
61
-
62
- /** @deprecated use WithStorageMeta(BlockBoundWitness) instead */
63
-
64
- /** BlockBoundWitnessWithStorageMeta type. */
65
- export type BlockBoundWitnessWithStorageMeta = z.infer<typeof BlockBoundWitnessWithStorageMetaZod>
66
-
67
- /** Type guard that checks if a value is a valid BlockBoundWitnessWithStorageMeta. */
68
- export const isBlockBoundWitnessWithStorageMeta = zodIsFactory(WithStorageMetaZod(BlockBoundWitnessZod))
69
- /** Converts a value to BlockBoundWitnessWithStorageMeta, throwing if invalid. */
70
- export const asBlockBoundWitnessWithStorageMeta = zodAsFactory(WithStorageMetaZod(BlockBoundWitnessZod), 'asBlockBoundWitnessWithStorageMeta')
71
- /** toBlockBoundWitnessWithStorageMeta constant. */
72
- export const toBlockBoundWitnessWithStorageMeta = zodToFactory(WithStorageMetaZod(BlockBoundWitnessZod), 'toBlockBoundWitnessWithStorageMeta')
@@ -1,135 +0,0 @@
1
- import {
2
- zodAsFactory, zodIsFactory, zodToFactory,
3
- } from '@xylabs/sdk-js'
4
- import {
5
- PayloadZod,
6
- PayloadZodLoose, WithHashMetaZod, WithStorageMetaZod,
7
- } from '@xyo-network/sdk-js'
8
- import { z } from 'zod'
9
-
10
- import { BlockBoundWitnessZod } from './BlockBoundWitness.ts'
11
- import { SignedBlockBoundWitnessZod } from './signed/index.ts'
12
-
13
- /** HydratedBlockZod constant. */
14
- export const HydratedBlockZod = z.tuple([
15
- BlockBoundWitnessZod,
16
- z.array(PayloadZodLoose),
17
- ])
18
-
19
- /** Type representing a hydrated Block with resolved payloads. */
20
- export type HydratedBlock = z.infer<typeof HydratedBlockZod>
21
-
22
- /** Type guard that checks if a value is a valid HydratedBlock. */
23
- export const isHydratedBlock = zodIsFactory(HydratedBlockZod)
24
- /** Converts a value to HydratedBlock, throwing if invalid. */
25
- export const asHydratedBlock = zodAsFactory(HydratedBlockZod, 'asHydratedBlock')
26
- /** toHydratedBlock constant. */
27
- export const toHydratedBlock = zodToFactory(HydratedBlockZod, 'toHydratedBlock')
28
-
29
- /** HydratedBlockWithHashMetaZod constant. */
30
- export const HydratedBlockWithHashMetaZod = z.tuple([
31
- WithHashMetaZod(BlockBoundWitnessZod),
32
- z.array(WithHashMetaZod(PayloadZod).loose()),
33
- ])
34
-
35
- /** Type representing a hydrated BlockWithHashMeta with resolved payloads. */
36
- export type HydratedBlockWithHashMeta = z.infer<typeof HydratedBlockWithHashMetaZod>
37
-
38
- /** Type guard that checks if a value is a valid HydratedBlockWithHashMeta. */
39
- export const isHydratedBlockWithHashMeta = zodIsFactory(HydratedBlockWithHashMetaZod)
40
- /** Converts a value to HydratedBlockWithHashMeta, throwing if invalid. */
41
- export const asHydratedBlockWithHashMeta = zodAsFactory(HydratedBlockWithHashMetaZod, 'asHydratedBlockWithHashMeta')
42
- /** toHydratedBlockWithHashMeta constant. */
43
- export const toHydratedBlockWithHashMeta = zodToFactory(HydratedBlockWithHashMetaZod, 'toHydratedBlockWithHashMeta')
44
-
45
- /** HydratedBlockWithStorageMetaZod constant. */
46
- export const HydratedBlockWithStorageMetaZod = z.tuple([
47
- WithStorageMetaZod(BlockBoundWitnessZod),
48
- z.array(WithStorageMetaZod(PayloadZod).loose()),
49
- ])
50
-
51
- /** Type representing a hydrated BlockWithStorageMeta with resolved payloads. */
52
- export type HydratedBlockWithStorageMeta = z.infer<typeof HydratedBlockWithStorageMetaZod>
53
-
54
- /** Type guard that checks if a value is a valid HydratedBlockWithStorageMeta. */
55
- export const isHydratedBlockWithStorageMeta = zodIsFactory(HydratedBlockWithStorageMetaZod)
56
- /** Converts a value to HydratedBlockWithStorageMeta, throwing if invalid. */
57
- export const asHydratedBlockWithStorageMeta = zodAsFactory(HydratedBlockWithStorageMetaZod, 'asHydratedBlockWithStorageMeta')
58
- /** toHydratedBlockWithStorageMeta constant. */
59
- export const toHydratedBlockWithStorageMeta = zodToFactory(HydratedBlockWithStorageMetaZod, 'toHydratedBlockWithStorageMeta')
60
-
61
- /** SignedHydratedBlockZod constant. */
62
- export const SignedHydratedBlockZod = z.tuple([
63
- SignedBlockBoundWitnessZod,
64
- z.array(PayloadZod.loose()),
65
- ])
66
-
67
- /** Type representing a hydrated SignedBlock with resolved payloads. */
68
- export type SignedHydratedBlock = z.infer<typeof SignedHydratedBlockZod>
69
-
70
- /** Type guard that checks if a value is a valid SignedHydratedBlock. */
71
- export const isSignedHydratedBlock = zodIsFactory(SignedHydratedBlockZod)
72
- /** Converts a value to SignedHydratedBlock, throwing if invalid. */
73
- export const asSignedHydratedBlock = zodAsFactory(SignedHydratedBlockZod, 'asSignedHydratedBlock')
74
- /** toSignedHydratedBlock constant. */
75
- export const toSignedHydratedBlock = zodToFactory(SignedHydratedBlockZod, 'toSignedHydratedBlock')
76
-
77
- /** SignedHydratedBlockToJsonZod constant. */
78
- export const SignedHydratedBlockToJsonZod = z.tuple([
79
- SignedBlockBoundWitnessZod,
80
- z.array(PayloadZod.loose()),
81
- ])
82
-
83
- /** Type representing a hydrated SignedBlockToJson with resolved payloads. */
84
- export type SignedHydratedBlockToJson = z.infer<typeof SignedHydratedBlockToJsonZod>
85
-
86
- /** Type guard that checks if a value is a valid SignedHydratedBlockToJson. */
87
- export const isSignedHydratedBlockToJson = zodIsFactory(SignedHydratedBlockToJsonZod)
88
- /** Converts a value to SignedHydratedBlockToJson, throwing if invalid. */
89
- export const asSignedHydratedBlockToJson = zodAsFactory(SignedHydratedBlockToJsonZod, 'asSignedHydratedBlockToJson')
90
- /** toSignedHydratedBlockToJson constant. */
91
- export const toSignedHydratedBlockToJson = zodToFactory(SignedHydratedBlockToJsonZod, 'toSignedHydratedBlockToJson')
92
-
93
- /** SignedHydratedBlockWithHashMetaZod constant. */
94
- export const SignedHydratedBlockWithHashMetaZod = z.tuple([
95
- WithHashMetaZod(SignedBlockBoundWitnessZod),
96
- z.array(WithHashMetaZod(PayloadZod).loose()),
97
- ])
98
-
99
- /** Type representing a hydrated SignedBlockWithHashMeta with resolved payloads. */
100
- export type SignedHydratedBlockWithHashMeta = z.infer<typeof SignedHydratedBlockWithHashMetaZod>
101
-
102
- /** SignedHydratedBlockWithHashMetaishZod constant. */
103
- export const SignedHydratedBlockWithHashMetaishZod = z.tuple([
104
- z.union([WithHashMetaZod(SignedBlockBoundWitnessZod)]),
105
- z.array(WithHashMetaZod(PayloadZod).loose()),
106
- ])
107
-
108
- /** Type guard that checks if a value is a valid SignedHydratedBlockWithHashMeta. */
109
- export const isSignedHydratedBlockWithHashMeta = zodIsFactory(SignedHydratedBlockWithHashMetaZod)
110
- /** Converts a value to SignedHydratedBlockWithHashMeta, throwing if invalid. */
111
- export const asSignedHydratedBlockWithHashMeta = zodAsFactory(SignedHydratedBlockWithHashMetaZod, 'asSignedHydratedBlockWithHashMeta')
112
-
113
- /** toSignedHydratedBlockWithHashMeta constant. */
114
- export const toSignedHydratedBlockWithHashMeta = zodToFactory(SignedHydratedBlockWithHashMetaZod, 'toSignedHydratedBlockWithHashMeta')
115
-
116
- /** SignedHydratedBlockWithStorageMetaZod constant. */
117
- export const SignedHydratedBlockWithStorageMetaZod = z.tuple([
118
- WithStorageMetaZod(SignedBlockBoundWitnessZod),
119
- z.array(WithStorageMetaZod(PayloadZod).loose()),
120
- ])
121
- /** Type representing a hydrated SignedBlockWithStorageMeta with resolved payloads. */
122
- export type SignedHydratedBlockWithStorageMeta = z.infer<typeof SignedHydratedBlockWithStorageMetaZod>
123
-
124
- /** Type guard that checks if a value is a valid SignedHydratedBlockWithStorageMeta. */
125
- export const isSignedHydratedBlockWithStorageMeta = zodIsFactory(SignedHydratedBlockWithStorageMetaZod)
126
- /** Converts a value to SignedHydratedBlockWithStorageMeta, throwing if invalid. */
127
- export const asSignedHydratedBlockWithStorageMeta = zodAsFactory(SignedHydratedBlockWithStorageMetaZod, 'asSignedHydratedBlockWithStorageMeta')
128
- /** toSignedHydratedBlockWithStorageMeta constant. */
129
- export const toSignedHydratedBlockWithStorageMeta = zodToFactory(SignedHydratedBlockWithStorageMetaZod, 'toSignedHydratedBlockWithStorageMeta')
130
-
131
- /** SignedHydratedBlockWithStorageMetaishZod constant. */
132
- export const SignedHydratedBlockWithStorageMetaishZod = z.tuple([
133
- z.union([WithStorageMetaZod(SignedBlockBoundWitnessZod)]),
134
- z.array(WithStorageMetaZod(PayloadZod).loose()),
135
- ])
@@ -1,5 +0,0 @@
1
- export * from './AllowedBlockPayload.ts'
2
- export * from './BlockBoundWitness.ts'
3
- export * from './HydratedBlock.ts'
4
- export * from './signed/index.ts'
5
- export * from './unsigned/index.ts'
@@ -1,22 +0,0 @@
1
- import {
2
- zodAsFactory, zodIsFactory, zodToFactory,
3
- } from '@xylabs/sdk-js'
4
- import { SignedBoundWitnessZod } from '@xyo-network/sdk-js'
5
- import type { z } from 'zod'
6
-
7
- import { BlockBoundWitnessFieldsZod, BlockBoundWitnessMetaZod } from '../BlockBoundWitness.ts'
8
-
9
- /** SignedBlockBoundWitnessZod constant. */
10
- export const SignedBlockBoundWitnessZod = SignedBoundWitnessZod
11
- .safeExtend(BlockBoundWitnessFieldsZod.shape)
12
- .safeExtend(BlockBoundWitnessMetaZod.shape)
13
-
14
- /** SignedBlockBoundWitness type. */
15
- export type SignedBlockBoundWitness = z.infer<typeof SignedBlockBoundWitnessZod>
16
-
17
- /** Type guard that checks if a value is a valid SignedBlockBoundWitness. */
18
- export const isSignedBlockBoundWitness = zodIsFactory(SignedBlockBoundWitnessZod)
19
- /** Converts a value to SignedBlockBoundWitness, throwing if invalid. */
20
- export const asSignedBlockBoundWitness = zodAsFactory(SignedBlockBoundWitnessZod, 'asSignedBlockBoundWitness')
21
- /** toSignedBlockBoundWitness constant. */
22
- export const toSignedBlockBoundWitness = zodToFactory(SignedBlockBoundWitnessZod, 'toSignedBlockBoundWitness')