@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
@@ -1,47 +0,0 @@
1
- import { AddressZod, HexZod } from '@xylabs/sdk-js'
2
- import { z } from 'zod'
3
-
4
- import {
5
- AttoToJsonZod, AttoZod, JsonToAttoZod,
6
- } from '../transaction/index.ts'
7
- import type { PositionId } from './PositionId.ts'
8
-
9
- /** StakeZod constant. */
10
- export const StakeZod = z.object({
11
- amount: AttoZod,
12
- // the block number when the stake was added
13
- addBlock: z.number(),
14
- // the unique id for the stake item
15
- id: z.number(),
16
- // the block number when the stake was removed (set to 0 if not removed)
17
- removeBlock: z.number(),
18
- // the address that is being staked
19
- staked: AddressZod,
20
- // the address that owns the stake
21
- staker: AddressZod,
22
- // the block number when the stake was withdrawn (set to 0 if not withdrawn)
23
- withdrawBlock: z.number(),
24
- })
25
-
26
- /** StakeToJsonZod constant. */
27
- export const StakeToJsonZod = StakeZod.transform(val => ({
28
- addBlock: val.addBlock,
29
- amount: AttoToJsonZod.parse(val.amount),
30
- id: val.id,
31
- removeBlock: val.removeBlock,
32
- staked: AddressZod.parse(val.staked),
33
- staker: AddressZod.parse(val.staker),
34
- withdrawBlock: val.withdrawBlock,
35
- }))
36
-
37
- // we intentionally use extend and not safeExtend here to ensure all fields are present
38
- /** JsonToStakeZod constant. */
39
- export const JsonToStakeZod = StakeZod.extend({ amount: HexZod }).transform(val => ({
40
- addBlock: val.addBlock,
41
- amount: JsonToAttoZod.parse(val.amount),
42
- id: val.id as PositionId,
43
- removeBlock: val.removeBlock,
44
- staked: val.staked,
45
- staker: val.staker,
46
- withdrawBlock: val.withdrawBlock,
47
- }))
@@ -1,2 +0,0 @@
1
- /** StakeShare type. */
2
- export type StakeShare = [bigint, bigint] // [share, total]
@@ -1,8 +0,0 @@
1
- import { z } from 'zod'
2
-
3
- /** TimeDomainZod constant. */
4
- export const TimeDomainZod = z.union([
5
- z.literal('xl1'),
6
- z.literal('epoch'),
7
- z.literal('ethereum'),
8
- ])
@@ -1,7 +0,0 @@
1
- import { AddressZod } from '@xylabs/sdk-js'
2
- import { z } from 'zod'
3
-
4
- /** TransferPairZod constant. */
5
- export const TransferPairZod = z.tuple([
6
- AddressZod, AddressZod,
7
- ])
@@ -1,36 +0,0 @@
1
- import type { Address, EthAddress } from '@xylabs/sdk-js'
2
-
3
- /**
4
- * The Zero Address is used as a marker address for various protocol operations.
5
- */
6
- export const XYO_ZERO_ADDRESS = '0000000000000000000000000000000000000000' as const as Address
7
-
8
- /**
9
- * The Bridge Address is used as a marker address for bridge transactions.
10
- */
11
- export const XYO_BRIDGE_ADDRESS = '3012193230121932301219323012193230121932' as const as Address
12
-
13
- /**
14
- * The Network Staking Address is used as a marker address for staking the network.
15
- */
16
- export const XYO_NETWORK_STAKING_ADDRESS = '1969196919691969196919691969196919691969' as const as Address
17
-
18
- /**
19
- * The Step Reward Address is used as a marker address for step rewards.
20
- */
21
- export const XYO_STEP_REWARD_ADDRESS = '1216197612161976121619761216197612161976' as const as Address
22
-
23
- /** XL1_ETH_MAIN_ERC20_CONTRACT_ADDRESS constant. */
24
- export const XL1_ETH_MAIN_ERC20_CONTRACT_ADDRESS = '0xf72aE3E0DA743033AbD7A407557D684c1aE66aed' as const as EthAddress
25
-
26
- /** XL1_ETH_MAIN_SUB_GOVERNOR_ADDRESS constant. */
27
- export const XL1_ETH_MAIN_SUB_GOVERNOR_ADDRESS = '0xbA296Bc5D0949C0484f08c56c30FB95CC4675A29' as const as EthAddress
28
-
29
- /** XL1_ETH_MAIN_REWARDS_ADDRESS constant. */
30
- export const XL1_ETH_MAIN_REWARDS_ADDRESS = '0x1a546e091FB4EFb274DC584334a28b8754c4ece7' as const as EthAddress
31
-
32
- /** XL1_ETH_MAIN_STAKED_XYO_CHAIN_ADDRESS constant. */
33
- export const XL1_ETH_MAIN_STAKED_XYO_CHAIN_ADDRESS = '0x319e667cED10452A117472811130444dED357F26' as const as EthAddress
34
-
35
- /** XL1_ETH_MAIN_GOVERNANCE_ADDRESS constant. */
36
- export const XL1_ETH_MAIN_GOVERNANCE_ADDRESS = '0x7595710956d6B14b4f2F51a8dF41379eEeC9074E' as const as EthAddress
@@ -1,3 +0,0 @@
1
- // the percent of the block rewards the producer gets
2
- /** defaultRewardRatio value. */
3
- export const defaultRewardRatio = 0.05 as const // 5.0% goes to block producer
@@ -1,11 +0,0 @@
1
- import type { TransactionFeesBigInt } from '../transaction/index.ts'
2
- import { AttoXL1, AttoXL1ConvertFactor } from '../xl1/index.ts'
3
- import { minTransactionFees } from './minTransactionFees.ts'
4
-
5
- /** defaultTransactionFees value. */
6
- export const defaultTransactionFees: TransactionFeesBigInt = {
7
- base: minTransactionFees.base,
8
- gasPrice: AttoXL1(10n * AttoXL1ConvertFactor.nano),
9
- gasLimit: AttoXL1(1_000_000n * AttoXL1ConvertFactor.nano),
10
- priority: minTransactionFees.priority,
11
- } as const
@@ -1,27 +0,0 @@
1
- export * from './AccountBalance.ts'
2
- export * from './addresses.ts'
3
- export * from './ArrayBuffer.ts'
4
- export * from './BlockRange/index.ts'
5
- export * from './BlockRate.ts'
6
- export * from './ChainQualification.ts'
7
- export * from './Context/index.ts'
8
- export * from './defaultRewardRatio.ts'
9
- export * from './defaultTransactionFees.ts'
10
- export * from './GatewayName.ts'
11
- export * from './HydratedTransaction.ts'
12
- export * from './minTransactionFees.ts'
13
- export * from './OpCodes.ts'
14
- export * from './PayloadMap.ts'
15
- export * from './Permission.ts'
16
- export * from './Position.ts'
17
- export * from './PositionId.ts'
18
- export * from './PositionId.ts'
19
- export * from './RangeMultipliers.ts'
20
- export * from './rewards.ts'
21
- export * from './RewardShare.ts'
22
- export * from './RewardsRangeOptions.ts'
23
- export * from './Sequence.ts'
24
- export * from './Stake.ts'
25
- export * from './TimeDomain.ts'
26
- export * from './TransferPair.ts'
27
- export * from './version.ts'
@@ -1,10 +0,0 @@
1
- import type { TransactionFeesBigInt } from '../transaction/index.ts'
2
- import { AttoXL1, AttoXL1ConvertFactor } from '../xl1/index.ts'
3
-
4
- /** minTransactionFees value. */
5
- export const minTransactionFees: TransactionFeesBigInt = {
6
- base: AttoXL1(1000n * AttoXL1ConvertFactor.nano),
7
- gasPrice: AttoXL1(10n * AttoXL1ConvertFactor.nano),
8
- gasLimit: AttoXL1(1_000_000n * AttoXL1ConvertFactor.nano),
9
- priority: AttoXL1(0n * AttoXL1ConvertFactor.nano),
10
- } as const
@@ -1,18 +0,0 @@
1
- import { toFixedPoint } from '@xylabs/sdk-js'
2
-
3
- import { asAttoXL1 } from '../xl1/index.ts'
4
-
5
- /** XL1_REWARDS_PLACES constant. */
6
- export const XL1_REWARDS_PLACES = 18 as const
7
- /** XL1_REWARDS_STARTING_REWARD constant. */
8
- export const XL1_REWARDS_STARTING_REWARD = asAttoXL1(toFixedPoint(500n, XL1_REWARDS_PLACES))
9
- /** XL1_REWARDS_BLOCKS_PER_STEP constant. */
10
- export const XL1_REWARDS_BLOCKS_PER_STEP = 1_000_000
11
- /** XL1_REWARDS_STEP_FACTOR_NUMERATOR constant. */
12
- export const XL1_REWARDS_STEP_FACTOR_NUMERATOR = 95n
13
- /** XL1_REWARDS_STEP_FACTOR_DENOMINATOR constant. */
14
- export const XL1_REWARDS_STEP_FACTOR_DENOMINATOR = 100n
15
- /** XL1_REWARDS_MIN_BLOCK_REWARD constant. */
16
- export const XL1_REWARDS_MIN_BLOCK_REWARD = asAttoXL1(toFixedPoint(10n, XL1_REWARDS_PLACES))
17
- /** XL1_REWARDS_CREATOR_REWARD constant. */
18
- export const XL1_REWARDS_CREATOR_REWARD = asAttoXL1(toFixedPoint(20_000_000_000n, XL1_REWARDS_PLACES))
@@ -1,2 +0,0 @@
1
- export * from './signedHydratedTransaction.ts'
2
- export * from './unsignedHydratedTransaction.ts'
@@ -1,58 +0,0 @@
1
- export const signedHydratedTransactionWithHashMeta = [
2
- {
3
- schema: 'network.xyo.boundwitness',
4
- addresses: [
5
- 'ae2966ff28d3b82e91dbec3fb1e285152ba2e782',
6
- ],
7
- payload_hashes: [
8
- '7c4deb6830f9c2f45d61691467825dd1ec08c22b1ac178d8b0737af714a4a636',
9
- 'b0a65744aac6d5a1cc79af5e51d6631618c2b6672f294b1972760019a9b4e174',
10
- ],
11
- payload_schemas: [
12
- 'network.xyo.boundwitness',
13
- 'network.xyo.stock.market.tzero.snapshot',
14
- ],
15
- previous_hashes: [
16
- null,
17
- ],
18
- $signatures: [
19
- 'fa229bc173704cdbe226f44e15f1f7a7df44fdfe575ffc96ce6f24574b21065f02c3a4d8f84beb01dfd26d70128ca0cb2f69b4f9ec912c2310e4ee5f999619d3',
20
- ],
21
- nbf: 250_042,
22
- exp: 250_052,
23
- fees: {
24
- base: 'e8d4a51000',
25
- gasLimit: '038d7ea4c68000',
26
- gasPrice: '02540be400',
27
- priority: '00',
28
- },
29
- chain: 'dd381fbb392c85160d8b0453e446757b12384046',
30
- from: 'ae2966ff28d3b82e91dbec3fb1e285152ba2e782',
31
- _dataHash: 'c3afe940115d0bc2581567d59586f42e5be3f2fe6b42520834a0ec3920dee98b',
32
- _hash: 'f8b6222c9361e60ddff5982b4e88d3746c2e072edaf58611368b0ad651ee67c2',
33
- _sequence: '00000000000000000000000051ee67c2',
34
- },
35
- [{
36
- askPrice: 0.28,
37
- askPriceRate: null,
38
- askQtyBookTotal: 140_619,
39
- askQuantity: 716,
40
- bidPrice: 0.18,
41
- bidPriceRate: null,
42
- bidQtyBookTotal: 7688,
43
- bidQuantity: 2,
44
- high: null,
45
- lastPrice: null,
46
- lastQuantity: null,
47
- low: null,
48
- open: null,
49
- prevClosePx: 0.28,
50
- schema: 'network.xyo.stock.market.tzero.snapshot',
51
- symbol: 'XYLB',
52
- timestamp: '2026-01-19T17:22:02.108746148-05:00',
53
- volume: 0,
54
- _dataHash: 'b0a65744aac6d5a1cc79af5e51d6631618c2b6672f294b1972760019a9b4e174',
55
- _hash: 'b0a65744aac6d5a1cc79af5e51d6631618c2b6672f294b1972760019a9b4e174',
56
- _sequence: '0000019bd859cdf500000001a9b4e174',
57
- }],
58
- ]
@@ -1,62 +0,0 @@
1
- export const unsignedHydratedTransactionWithHashMeta = [
2
- {
3
- $signatures: [],
4
- addresses: [],
5
- chain: '944ac6a2ffc27ab773f34193e43f20ab7542b0ea',
6
- exp: 11,
7
- fees: {
8
- base: 'e8d4a51000',
9
- gasLimit: '038d7ea4c68000',
10
- gasPrice: '02540be400',
11
- priority: '00',
12
- },
13
- from: 'c5c9d2a8e8d0b0eba521aec623ffcb9e0982f513',
14
- nbf: 1,
15
- payload_hashes: [
16
- '01bbcd4c58fd88488882ba54e13e92603f13c34695eda64780502acc80c3fcc1',
17
- 'ff127a824dc672ff5b7a32d2c7deffcdde3cc417ad112510532f24a2e948516a',
18
- '92693e6fefeed94eb80872ba9e2c86d7861fc84e4bc5b775ebe9966e68c26767',
19
- '85009387d332dffa781bbf6fa107715f36f9d6b3294c5cc8fd1ce8ada207d2bb',
20
- ],
21
- payload_schemas: [
22
- 'network.xyo.hash',
23
- 'network.xyo.hash',
24
- 'network.xyo.id',
25
- 'network.xyo.id',
26
- ],
27
- previous_hashes: [],
28
- schema: 'network.xyo.boundwitness',
29
- script: [
30
- 'elevate|01bbcd4c58fd88488882ba54e13e92603f13c34695eda64780502acc80c3fcc1',
31
- 'elevate|ff127a824dc672ff5b7a32d2c7deffcdde3cc417ad112510532f24a2e948516a',
32
- ],
33
- _dataHash: '214029ca586455e66fea02896c6d69739e400917c08e4e8ec1e9818c4a19bb17',
34
- _hash: '59aacdd66055a63e6a0686a33f155be5b6afca0630a9abfee7ae9e79f057eec8',
35
- },
36
- [
37
- {
38
- hash: '92693e6fefeed94eb80872ba9e2c86d7861fc84e4bc5b775ebe9966e68c26767',
39
- schema: 'network.xyo.hash',
40
- _dataHash: '01bbcd4c58fd88488882ba54e13e92603f13c34695eda64780502acc80c3fcc1',
41
- _hash: '01bbcd4c58fd88488882ba54e13e92603f13c34695eda64780502acc80c3fcc1',
42
- },
43
- {
44
- hash: '85009387d332dffa781bbf6fa107715f36f9d6b3294c5cc8fd1ce8ada207d2bb',
45
- schema: 'network.xyo.hash',
46
- _dataHash: 'ff127a824dc672ff5b7a32d2c7deffcdde3cc417ad112510532f24a2e948516a',
47
- _hash: 'ff127a824dc672ff5b7a32d2c7deffcdde3cc417ad112510532f24a2e948516a',
48
- },
49
- {
50
- salt: 'Hello from Sample 0 - 2026-01-15T22:41:36.587Z',
51
- schema: 'network.xyo.id',
52
- _dataHash: '92693e6fefeed94eb80872ba9e2c86d7861fc84e4bc5b775ebe9966e68c26767',
53
- _hash: '92693e6fefeed94eb80872ba9e2c86d7861fc84e4bc5b775ebe9966e68c26767',
54
- },
55
- {
56
- salt: 'Hello from Sample 1 - 2026-01-15T22:41:36.587Z',
57
- schema: 'network.xyo.id',
58
- _dataHash: '85009387d332dffa781bbf6fa107715f36f9d6b3294c5cc8fd1ce8ada207d2bb',
59
- _hash: '85009387d332dffa781bbf6fa107715f36f9d6b3294c5cc8fd1ce8ada207d2bb',
60
- },
61
- ],
62
- ]
@@ -1,10 +0,0 @@
1
- /** XL1_PROTOCOL_VERSION_MAJOR constant. */
2
- export const XL1_PROTOCOL_VERSION_MAJOR = 1 as const
3
- /** XL1_PROTOCOL_VERSION_MINOR constant. */
4
- export const XL1_PROTOCOL_VERSION_MINOR = 2 as const
5
- /** XL1_PROTOCOL_VERSION_PATCH constant. */
6
- export const XL1_PROTOCOL_VERSION_PATCH = 0 as const
7
- /** XL1_PROTOCOL_VERSION_STRING constant. */
8
- export const XL1_PROTOCOL_VERSION_STRING = `${XL1_PROTOCOL_VERSION_MAJOR}.${XL1_PROTOCOL_VERSION_MINOR}.${XL1_PROTOCOL_VERSION_PATCH}` as const
9
- /** XL1_PROTOCOL_VERSION constant. */
10
- export const XL1_PROTOCOL_VERSION = XL1_PROTOCOL_VERSION_MAJOR * 1_000_000 + XL1_PROTOCOL_VERSION_MINOR * 1000 + XL1_PROTOCOL_VERSION_PATCH
@@ -1,25 +0,0 @@
1
- import { AsObjectFactory } from '@xylabs/sdk-js'
2
- import type { Payload } from '@xyo-network/sdk-js'
3
- import { asSchema, isPayloadOfZodType } from '@xyo-network/sdk-js'
4
- import type { z } from 'zod'
5
-
6
- import { StepIdentityZod } from '../Step/index.ts'
7
-
8
- /** Schema identifier for step identity payloads. */
9
- export const StepIdentitySchema = asSchema('network.xyo.chain.step.identity', true)
10
- /** Schema type for StepIdentity payloads. */
11
- export type StepIdentitySchema = typeof StepIdentitySchema
12
-
13
- /** Fields for a step identity, inferred from the StepIdentityZod schema. */
14
- export type StepIdentityFields = z.infer<typeof StepIdentityZod>
15
-
16
- /**
17
- * A Step Identity Payload
18
- */
19
- export type StepIdentityPayload = Payload<StepIdentityFields, StepIdentitySchema>
20
-
21
- /** Type guard that checks whether a value is a StepIdentityPayload. */
22
- export const isStepIdentityPayload = isPayloadOfZodType<StepIdentityPayload>(StepIdentityZod, StepIdentitySchema)
23
-
24
- /** Casts a value to StepIdentityPayload or returns undefined if it does not match. */
25
- export const asStepIdentityPayload = AsObjectFactory.create(isStepIdentityPayload)
@@ -1,28 +0,0 @@
1
- import type { Hash } from '@xylabs/sdk-js'
2
-
3
- /**
4
- * Final confirmation tying the intent and the observation together.
5
- */
6
- export interface BridgeCompletionFields {
7
-
8
- /**
9
- * Block number, event ID, or timestamp when the bridge was completed
10
- */
11
- completedAt?: Hash
12
-
13
- /**
14
- * Reference to observed destination confirmation hash
15
- */
16
- destObservation: Hash
17
-
18
- /**
19
- * Reference to source intent hash
20
- */
21
- srcIntent?: Hash
22
-
23
- /**
24
- * Reference to observed source confirmation hash
25
- */
26
- srcObservation: Hash
27
-
28
- }
@@ -1,38 +0,0 @@
1
- import { AsObjectFactory, HexZod } from '@xylabs/sdk-js'
2
- import type { Payload } from '@xyo-network/sdk-js'
3
- import { asSchema, isPayloadOfZodType } from '@xyo-network/sdk-js'
4
- import type { z } from 'zod'
5
-
6
- import { BridgeDetailsFieldsZod } from './BridgeDetails.ts'
7
-
8
- /** Schema identifier for BridgeDestinationObservation payloads. */
9
- export const BridgeDestinationObservationSchema = asSchema('network.xyo.chain.bridge.observation.destination', true)
10
- /** Schema type for BridgeDestinationObservation payloads. */
11
- export type BridgeDestinationObservationSchema = typeof BridgeDestinationObservationSchema
12
-
13
- /**
14
- * Represents an observation that confirms a bridge action occurred on the destination chain.
15
- */
16
- export const BridgeDestinationObservationFieldsZod = BridgeDetailsFieldsZod.extend({
17
- /**
18
- * Destination chain confirmation
19
- */
20
- destConfirmation: HexZod.optional().describe('Destination chain confirmation'),
21
- })
22
-
23
- /** BridgeDestinationObservationFields type. */
24
- export type BridgeDestinationObservationFields = z.infer<typeof BridgeDestinationObservationFieldsZod>
25
-
26
- /**
27
- * Represents an observation that confirms a bridge action occurred on the destination chain.
28
- */
29
- export type BridgeDestinationObservation = Payload<BridgeDestinationObservationFields, BridgeDestinationObservationSchema>
30
-
31
- /** Type guard that checks if a value is a valid BridgeDestinationObservation. */
32
- export const isBridgeDestinationObservation = isPayloadOfZodType<BridgeDestinationObservation>(
33
- BridgeDestinationObservationFieldsZod,
34
- BridgeDestinationObservationSchema,
35
- )
36
-
37
- /** Converts a value to BridgeDestinationObservation, throwing if invalid. */
38
- export const asBridgeDestinationObservation = AsObjectFactory.create(isBridgeDestinationObservation)
@@ -1,69 +0,0 @@
1
- import { HexZod } from '@xylabs/sdk-js'
2
- import { z } from 'zod'
3
-
4
- /**
5
- * Represents a transfer destination
6
- */
7
- export const BridgeDetailsDestinationFieldsZod = z.object({
8
- /**
9
- * Destination network
10
- */
11
- dest: HexZod.describe('The destination network identifier'),
12
- /**
13
- * Destination address (EOA or contract)
14
- */
15
- destAddress: HexZod.describe('The destination address (EOA or contract)'),
16
- /**
17
- * Token amount to bridge to destination
18
- */
19
- destAmount: HexZod.describe('The token amount to bridge to destination'),
20
- /**
21
- * Token being bridged to
22
- */
23
- destToken: HexZod.describe('The token being bridged to'),
24
- })
25
-
26
- /**
27
- * Represents a transfer destination
28
- */
29
- export type BridgeDetailsDestinationFields = z.infer<typeof BridgeDetailsDestinationFieldsZod>
30
-
31
- /**
32
- * Represents a transfer source
33
- */
34
- export const BridgeDetailsSourceFieldsZod = z.object({
35
- /**
36
- * Source network
37
- */
38
- src: HexZod.describe('The source network identifier'),
39
-
40
- /**
41
- * Source address (EOA or contract)
42
- */
43
- srcAddress: HexZod.describe('The source address (EOA or contract)'),
44
- /**
45
- * Token amount to bridge from source
46
- */
47
- srcAmount: HexZod.describe('The token amount to bridge from source'),
48
- /**
49
- * Token being bridged from
50
- */
51
- srcToken: HexZod.describe('The token being bridged from'),
52
- })
53
-
54
- /**
55
- * Represents a transfer source
56
- */
57
- export type BridgeDetailsSourceFields = z.infer<typeof BridgeDetailsSourceFieldsZod>
58
-
59
- /**
60
- * Represents a transfer from a source chain/token/address/amount to a destination chain/token/address/amount.
61
- */
62
- export const BridgeDetailsFieldsZod = BridgeDetailsSourceFieldsZod.extend(
63
- BridgeDetailsDestinationFieldsZod.shape,
64
- )
65
-
66
- /**
67
- * Represents a transfer from a source chain/token/address/amount to a destination chain/token/address/amount.
68
- */
69
- export type BridgeDetailsFields = z.infer<typeof BridgeDetailsFieldsZod>
@@ -1,36 +0,0 @@
1
- import { AsObjectFactory } from '@xylabs/sdk-js'
2
- import type { Payload } from '@xyo-network/sdk-js'
3
- import { asSchema, isPayloadOfZodType } from '@xyo-network/sdk-js'
4
- import { z } from 'zod'
5
-
6
- import { BridgeDetailsFieldsZod } from './BridgeDetails.ts'
7
-
8
- /** Schema identifier for BridgeIntent payloads. */
9
- export const BridgeIntentSchema = asSchema('network.xyo.chain.bridge.intent', true)
10
- /** Schema type for BridgeIntent payloads. */
11
- export type BridgeIntentSchema = typeof BridgeIntentSchema
12
-
13
- /**
14
- * Represents an Address's intent to initiate a token bridge.
15
- */
16
- export const BridgeIntentFieldsZod = BridgeDetailsFieldsZod.extend({
17
- /**
18
- * Unique identifier for replay protection
19
- */
20
- nonce: z.string().describe('Unique identifier for replay protection'),
21
- })
22
-
23
- /** BridgeIntentFields type. */
24
- export type BridgeIntentFields = z.infer<typeof BridgeIntentFieldsZod>
25
-
26
- /** BridgeIntent type. */
27
- export type BridgeIntent = Payload<BridgeIntentFields, BridgeIntentSchema>
28
-
29
- /** Type guard that checks if a value is a valid BridgeIntent. */
30
- export const isBridgeIntent = isPayloadOfZodType<BridgeIntent>(
31
- BridgeIntentFieldsZod,
32
- BridgeIntentSchema,
33
- )
34
-
35
- /** Converts a value to BridgeIntent, throwing if invalid. */
36
- export const asBridgeIntent = AsObjectFactory.create(isBridgeIntent)
@@ -1,37 +0,0 @@
1
- import { AsObjectFactory, HexZod } from '@xylabs/sdk-js'
2
- import type { Payload } from '@xyo-network/sdk-js'
3
- import { asSchema, isPayloadOfZodType } from '@xyo-network/sdk-js'
4
- import type { z } from 'zod'
5
-
6
- import { BridgeDetailsFieldsZod } from './BridgeDetails.ts'
7
-
8
- /** Schema identifier for BridgeSourceObservation payloads. */
9
- export const BridgeSourceObservationSchema = asSchema('network.xyo.chain.bridge.observation.source', true)
10
- /** Schema type for BridgeSourceObservation payloads. */
11
- export type BridgeSourceObservationSchema = typeof BridgeSourceObservationSchema
12
-
13
- /**
14
- * Represents an observation that confirms a bridge action occurred on the source chain.
15
- */
16
- export const BridgeSourceObservationFieldsZod = BridgeDetailsFieldsZod.extend({
17
- /**
18
- * Source chain confirmation
19
- */
20
- srcConfirmation: HexZod.optional().describe('Source chain confirmation'),
21
- })
22
-
23
- /** BridgeSourceObservationFields type. */
24
- export type BridgeSourceObservationFields = z.infer<typeof BridgeSourceObservationFieldsZod>
25
- /**
26
- * Represents an observation that confirms a bridge action occurred on the source chain.
27
- */
28
- export type BridgeSourceObservation = Payload<BridgeSourceObservationFields, BridgeSourceObservationSchema>
29
-
30
- /** Type guard that checks if a value is a valid BridgeSourceObservation. */
31
- export const isBridgeSourceObservation = isPayloadOfZodType<BridgeSourceObservation>(
32
- BridgeSourceObservationFieldsZod,
33
- BridgeSourceObservationSchema,
34
- )
35
-
36
- /** Converts a value to BridgeSourceObservation, throwing if invalid. */
37
- export const asBridgeSourceObservation = AsObjectFactory.create(isBridgeSourceObservation)
@@ -1,5 +0,0 @@
1
- export * from './BridgeCompletion.ts'
2
- export * from './BridgeDestinationObservation.ts'
3
- export * from './BridgeDetails.ts'
4
- export * from './BridgeIntent.ts'
5
- export * from './BridgeSourceObservation.ts'
@@ -1,45 +0,0 @@
1
- import { AsObjectFactory } from '@xylabs/sdk-js'
2
- import type { Payload, WithStorageMeta } from '@xyo-network/sdk-js'
3
- import {
4
- asSchema, isPayloadOfSchemaType, isStorageMeta,
5
- } from '@xyo-network/sdk-js'
6
-
7
- import type { BlockDuration } from '../../fields/index.ts'
8
- import type { FromFields } from './Executable.ts'
9
-
10
- /** Schema identifier for chain stake intent payloads. */
11
- export const ChainStakeIntentSchema = asSchema('network.xyo.chain.stake.intent', true)
12
- /** Schema type for ChainStakeIntent payloads. */
13
- export type ChainStakeIntentSchema = typeof ChainStakeIntentSchema
14
-
15
- /** The type of staking intent, currently limited to 'producer'. */
16
- export type Intent = 'producer' // | 'bank'
17
-
18
- /** Fields for a chain stake intent, including the staking intent type and source address. */
19
- export interface ChainStakeIntentFields extends BlockDuration, FromFields {
20
- /*
21
- * The intent of the staking
22
- */
23
- intent: Intent
24
- }
25
-
26
- /** A payload representing an intent to stake on the chain. */
27
- export type ChainStakeIntent = Payload<ChainStakeIntentFields, ChainStakeIntentSchema>
28
-
29
- /** Type guard that checks whether a value is a valid ChainStakeIntent with non-negative nbf and exp. */
30
- export const isChainStakeIntent = (x?: unknown | null): x is ChainStakeIntent => {
31
- return isPayloadOfSchemaType<ChainStakeIntent>(ChainStakeIntentSchema)(x)
32
- && asNonNegativeInteger(x.nbf) !== undefined
33
- && asNonNegativeInteger(x.exp) !== undefined
34
- }
35
- /** Casts a value to ChainStakeIntent or returns undefined if it does not match. */
36
- export const asChainStakeIntent = AsObjectFactory.create(isChainStakeIntent)
37
-
38
- /** Type guard that checks whether a value is a ChainStakeIntent with storage metadata. */
39
- export const isChainStakeIntentWithStorageMeta = (x?: unknown | null): x is WithStorageMeta<ChainStakeIntent> => {
40
- return isChainStakeIntent(x) && isStorageMeta(x)
41
- }
42
-
43
- const asNonNegativeInteger = (num: number) => {
44
- return (Number.isInteger(num) && num >= 0) ? num : undefined
45
- }
@@ -1,35 +0,0 @@
1
- import type { Address, EmptyObject } from '@xylabs/sdk-js'
2
- import { isAnyPayload } from '@xyo-network/sdk-js'
3
-
4
- /** FromFields interface. */
5
- export interface FromFields {
6
- // the address that is treated as the source of this action
7
- from: Address
8
- }
9
-
10
- /** hasFrom constant. */
11
- export const hasFrom = (value: unknown): value is FromFields => {
12
- return (value as FromFields).from !== undefined
13
- }
14
-
15
- /** ExecutableFields interface. */
16
- export interface ExecutableFields {
17
- script: string[]
18
- }
19
-
20
- /** Executable type. */
21
- export type Executable<T extends EmptyObject = EmptyObject> = T & ExecutableFields
22
- /** OptionalExecutable type. */
23
- export type OptionalExecutable<T extends EmptyObject = EmptyObject> = T & Partial<ExecutableFields>
24
-
25
- /** Type guard that checks if a value is a valid Executable. */
26
- export const isExecutable = <T extends EmptyObject>(value: T | undefined): value is Executable<T> => {
27
- return isAnyPayload(value) && Array.isArray((value as unknown as ExecutableFields).script)
28
- }
29
-
30
- /** Converts a value to Executable, throwing if invalid. */
31
- export const asExecutable = <T extends EmptyObject>(value: T | undefined): Executable<T> | undefined => {
32
- return isExecutable(value)
33
- ? value as unknown as Executable<T>
34
- : undefined
35
- }