@xyo-network/xl1-rpc 1.11.0 → 1.12.1

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 (273) hide show
  1. package/dist/neutral/engine/requestSchemas.d.ts +2 -2
  2. package/dist/neutral/engine/requestSchemas.d.ts.map +1 -1
  3. package/dist/neutral/index.mjs +805 -455
  4. package/dist/neutral/index.mjs.map +1 -1
  5. package/dist/neutral/provider/connection/XyoConnection.d.ts +2 -2
  6. package/dist/neutral/provider/connection/XyoConnection.d.ts.map +1 -1
  7. package/dist/neutral/provider/runner/JsonRpcXyoRunner.d.ts +2 -2
  8. package/dist/neutral/provider/runner/JsonRpcXyoRunner.d.ts.map +1 -1
  9. package/dist/neutral/provider/runner/MemoryXyoRunner.d.ts +2 -2
  10. package/dist/neutral/provider/runner/MemoryXyoRunner.d.ts.map +1 -1
  11. package/dist/neutral/provider/runner/NodeXyoRunner.d.ts +2 -2
  12. package/dist/neutral/provider/runner/NodeXyoRunner.d.ts.map +1 -1
  13. package/dist/neutral/provider/signer/JsonRpcXyoSigner.d.ts +5 -5
  14. package/dist/neutral/provider/signer/JsonRpcXyoSigner.d.ts.map +1 -1
  15. package/dist/neutral/provider/signer/MemoryXyoSigner.d.ts +2 -2
  16. package/dist/neutral/provider/signer/MemoryXyoSigner.d.ts.map +1 -1
  17. package/dist/neutral/provider/viewer/JsonRpcXyoViewer.d.ts +5 -5
  18. package/dist/neutral/provider/viewer/JsonRpcXyoViewer.d.ts.map +1 -1
  19. package/dist/neutral/transport/HttpRpcTransport.d.ts +1 -1
  20. package/dist/neutral/transport/HttpRpcTransport.d.ts.map +1 -1
  21. package/dist/neutral/transport/MemoryRpcTransport.d.ts +6 -7
  22. package/dist/neutral/transport/MemoryRpcTransport.d.ts.map +1 -1
  23. package/dist/neutral/transport/RpcTransport.d.ts +1 -1
  24. package/dist/neutral/transport/RpcTransport.d.ts.map +1 -1
  25. package/dist/neutral/transport/post-message/LegacyPostMessageRpcTransport.d.ts +5 -5
  26. package/dist/neutral/transport/post-message/LegacyPostMessageRpcTransport.d.ts.map +1 -1
  27. package/dist/neutral/types/schema/AllRpcSchemas.d.ts +2965 -2
  28. package/dist/neutral/types/schema/AllRpcSchemas.d.ts.map +1 -1
  29. package/dist/neutral/types/schema/XyoGatewayRpcSchemas.d.ts +422 -76
  30. package/dist/neutral/types/schema/XyoGatewayRpcSchemas.d.ts.map +1 -1
  31. package/dist/neutral/types/schema/XyoProviderRpcSchemas.d.ts +297 -3
  32. package/dist/neutral/types/schema/XyoProviderRpcSchemas.d.ts.map +1 -1
  33. package/dist/neutral/types/schema/XyoRunnerRpcSchemas.d.ts +231 -3
  34. package/dist/neutral/types/schema/XyoRunnerRpcSchemas.d.ts.map +1 -1
  35. package/dist/neutral/types/schema/XyoSignerRpcSchemas.d.ts +838 -3
  36. package/dist/neutral/types/schema/XyoSignerRpcSchemas.d.ts.map +1 -1
  37. package/dist/neutral/types/schema/XyoViewerRpcSchemas.d.ts +1611 -3
  38. package/dist/neutral/types/schema/XyoViewerRpcSchemas.d.ts.map +1 -1
  39. package/dist/neutral/types/schema/common/Address.d.ts +7 -0
  40. package/dist/neutral/types/schema/common/Address.d.ts.map +1 -0
  41. package/dist/neutral/types/schema/common/AllowedBlockPayload.d.ts +11 -0
  42. package/dist/neutral/types/schema/common/AllowedBlockPayload.d.ts.map +1 -0
  43. package/dist/neutral/types/schema/common/BlockBoundWitness.d.ts +324 -0
  44. package/dist/neutral/types/schema/common/BlockBoundWitness.d.ts.map +1 -0
  45. package/dist/neutral/types/schema/common/BoundWitness.d.ts +420 -0
  46. package/dist/neutral/types/schema/common/BoundWitness.d.ts.map +1 -0
  47. package/dist/neutral/types/schema/common/Chain.d.ts +4 -0
  48. package/dist/neutral/types/schema/common/Chain.d.ts.map +1 -0
  49. package/dist/neutral/types/schema/common/HydratedBlock.d.ts +474 -0
  50. package/dist/neutral/types/schema/common/HydratedBlock.d.ts.map +1 -0
  51. package/dist/neutral/types/schema/common/HydratedTransaction.d.ts +624 -0
  52. package/dist/neutral/types/schema/common/HydratedTransaction.d.ts.map +1 -0
  53. package/dist/neutral/types/schema/common/Json.d.ts +7 -0
  54. package/dist/neutral/types/schema/common/Json.d.ts.map +1 -0
  55. package/dist/neutral/types/schema/common/Payload.d.ts +134 -0
  56. package/dist/neutral/types/schema/common/Payload.d.ts.map +1 -0
  57. package/dist/neutral/types/schema/common/Sequence.d.ts +9 -0
  58. package/dist/neutral/types/schema/common/Sequence.d.ts.map +1 -0
  59. package/dist/neutral/types/schema/common/TransactionBoundWitness.d.ts +239 -0
  60. package/dist/neutral/types/schema/common/TransactionBoundWitness.d.ts.map +1 -0
  61. package/dist/neutral/types/schema/common/TransactionFees.d.ts +93 -24
  62. package/dist/neutral/types/schema/common/TransactionFees.d.ts.map +1 -1
  63. package/dist/neutral/types/schema/common/index.d.ts +11 -13
  64. package/dist/neutral/types/schema/common/index.d.ts.map +1 -1
  65. package/dist/neutral/types/schema/common/spec/BigIntZod.spec.d.ts +2 -0
  66. package/dist/neutral/types/schema/common/spec/BigIntZod.spec.d.ts.map +1 -0
  67. package/dist/neutral/types/schema/common/spec/HydratedTransaction.spec.d.ts +2 -0
  68. package/dist/neutral/types/schema/common/spec/HydratedTransaction.spec.d.ts.map +1 -0
  69. package/dist/neutral/types/schema/common/spec/Payload.spec.d.ts +2 -0
  70. package/dist/neutral/types/schema/common/spec/Payload.spec.d.ts.map +1 -0
  71. package/dist/neutral/types/schema/common/spec/TransactionBoundWitnessZod.spec.d.ts +2 -0
  72. package/dist/neutral/types/schema/common/spec/TransactionBoundWitnessZod.spec.d.ts.map +1 -0
  73. package/dist/neutral/types/schema/common/spec/UnsignedHydratedTransactionSchema.spec copy.d.ts +2 -0
  74. package/dist/neutral/types/schema/common/spec/UnsignedHydratedTransactionSchema.spec copy.d.ts.map +1 -0
  75. package/dist/neutral/types/schema/createRequestSchema.d.ts +2 -22
  76. package/dist/neutral/types/schema/createRequestSchema.d.ts.map +1 -1
  77. package/dist/neutral/types/schema/createResponseSchema.d.ts +2 -18
  78. package/dist/neutral/types/schema/createResponseSchema.d.ts.map +1 -1
  79. package/dist/neutral/types/schema/index.d.ts +1 -0
  80. package/dist/neutral/types/schema/index.d.ts.map +1 -1
  81. package/dist/node/engine/requestSchemas.d.ts +2 -2
  82. package/dist/node/engine/requestSchemas.d.ts.map +1 -1
  83. package/dist/node/index-node.mjs +834 -486
  84. package/dist/node/index-node.mjs.map +1 -1
  85. package/dist/node/provider/connection/XyoConnection.d.ts +2 -2
  86. package/dist/node/provider/connection/XyoConnection.d.ts.map +1 -1
  87. package/dist/node/provider/runner/JsonRpcXyoRunner.d.ts +2 -2
  88. package/dist/node/provider/runner/JsonRpcXyoRunner.d.ts.map +1 -1
  89. package/dist/node/provider/runner/MemoryXyoRunner.d.ts +2 -2
  90. package/dist/node/provider/runner/MemoryXyoRunner.d.ts.map +1 -1
  91. package/dist/node/provider/runner/NodeXyoRunner.d.ts +2 -2
  92. package/dist/node/provider/runner/NodeXyoRunner.d.ts.map +1 -1
  93. package/dist/node/provider/signer/JsonRpcXyoSigner.d.ts +5 -5
  94. package/dist/node/provider/signer/JsonRpcXyoSigner.d.ts.map +1 -1
  95. package/dist/node/provider/signer/MemoryXyoSigner.d.ts +2 -2
  96. package/dist/node/provider/signer/MemoryXyoSigner.d.ts.map +1 -1
  97. package/dist/node/provider/viewer/JsonRpcXyoViewer.d.ts +5 -5
  98. package/dist/node/provider/viewer/JsonRpcXyoViewer.d.ts.map +1 -1
  99. package/dist/node/transport/HttpRpcTransport.d.ts +1 -1
  100. package/dist/node/transport/HttpRpcTransport.d.ts.map +1 -1
  101. package/dist/node/transport/MemoryRpcTransport.d.ts +6 -7
  102. package/dist/node/transport/MemoryRpcTransport.d.ts.map +1 -1
  103. package/dist/node/transport/RpcTransport.d.ts +1 -1
  104. package/dist/node/transport/RpcTransport.d.ts.map +1 -1
  105. package/dist/node/transport/post-message/LegacyPostMessageRpcTransport.d.ts +5 -5
  106. package/dist/node/transport/post-message/LegacyPostMessageRpcTransport.d.ts.map +1 -1
  107. package/dist/node/types/schema/AllRpcSchemas.d.ts +2965 -2
  108. package/dist/node/types/schema/AllRpcSchemas.d.ts.map +1 -1
  109. package/dist/node/types/schema/XyoGatewayRpcSchemas.d.ts +422 -76
  110. package/dist/node/types/schema/XyoGatewayRpcSchemas.d.ts.map +1 -1
  111. package/dist/node/types/schema/XyoProviderRpcSchemas.d.ts +297 -3
  112. package/dist/node/types/schema/XyoProviderRpcSchemas.d.ts.map +1 -1
  113. package/dist/node/types/schema/XyoRunnerRpcSchemas.d.ts +231 -3
  114. package/dist/node/types/schema/XyoRunnerRpcSchemas.d.ts.map +1 -1
  115. package/dist/node/types/schema/XyoSignerRpcSchemas.d.ts +838 -3
  116. package/dist/node/types/schema/XyoSignerRpcSchemas.d.ts.map +1 -1
  117. package/dist/node/types/schema/XyoViewerRpcSchemas.d.ts +1611 -3
  118. package/dist/node/types/schema/XyoViewerRpcSchemas.d.ts.map +1 -1
  119. package/dist/node/types/schema/common/Address.d.ts +7 -0
  120. package/dist/node/types/schema/common/Address.d.ts.map +1 -0
  121. package/dist/node/types/schema/common/AllowedBlockPayload.d.ts +11 -0
  122. package/dist/node/types/schema/common/AllowedBlockPayload.d.ts.map +1 -0
  123. package/dist/node/types/schema/common/BlockBoundWitness.d.ts +324 -0
  124. package/dist/node/types/schema/common/BlockBoundWitness.d.ts.map +1 -0
  125. package/dist/node/types/schema/common/BoundWitness.d.ts +420 -0
  126. package/dist/node/types/schema/common/BoundWitness.d.ts.map +1 -0
  127. package/dist/node/types/schema/common/Chain.d.ts +4 -0
  128. package/dist/node/types/schema/common/Chain.d.ts.map +1 -0
  129. package/dist/node/types/schema/common/HydratedBlock.d.ts +474 -0
  130. package/dist/node/types/schema/common/HydratedBlock.d.ts.map +1 -0
  131. package/dist/node/types/schema/common/HydratedTransaction.d.ts +624 -0
  132. package/dist/node/types/schema/common/HydratedTransaction.d.ts.map +1 -0
  133. package/dist/node/types/schema/common/Json.d.ts +7 -0
  134. package/dist/node/types/schema/common/Json.d.ts.map +1 -0
  135. package/dist/node/types/schema/common/Payload.d.ts +134 -0
  136. package/dist/node/types/schema/common/Payload.d.ts.map +1 -0
  137. package/dist/node/types/schema/common/Sequence.d.ts +9 -0
  138. package/dist/node/types/schema/common/Sequence.d.ts.map +1 -0
  139. package/dist/node/types/schema/common/TransactionBoundWitness.d.ts +239 -0
  140. package/dist/node/types/schema/common/TransactionBoundWitness.d.ts.map +1 -0
  141. package/dist/node/types/schema/common/TransactionFees.d.ts +93 -24
  142. package/dist/node/types/schema/common/TransactionFees.d.ts.map +1 -1
  143. package/dist/node/types/schema/common/index.d.ts +11 -13
  144. package/dist/node/types/schema/common/index.d.ts.map +1 -1
  145. package/dist/node/types/schema/common/spec/BigIntZod.spec.d.ts +2 -0
  146. package/dist/node/types/schema/common/spec/BigIntZod.spec.d.ts.map +1 -0
  147. package/dist/node/types/schema/common/spec/HydratedTransaction.spec.d.ts +2 -0
  148. package/dist/node/types/schema/common/spec/HydratedTransaction.spec.d.ts.map +1 -0
  149. package/dist/node/types/schema/common/spec/Payload.spec.d.ts +2 -0
  150. package/dist/node/types/schema/common/spec/Payload.spec.d.ts.map +1 -0
  151. package/dist/node/types/schema/common/spec/TransactionBoundWitnessZod.spec.d.ts +2 -0
  152. package/dist/node/types/schema/common/spec/TransactionBoundWitnessZod.spec.d.ts.map +1 -0
  153. package/dist/node/types/schema/common/spec/UnsignedHydratedTransactionSchema.spec copy.d.ts +2 -0
  154. package/dist/node/types/schema/common/spec/UnsignedHydratedTransactionSchema.spec copy.d.ts.map +1 -0
  155. package/dist/node/types/schema/createRequestSchema.d.ts +2 -22
  156. package/dist/node/types/schema/createRequestSchema.d.ts.map +1 -1
  157. package/dist/node/types/schema/createResponseSchema.d.ts +2 -18
  158. package/dist/node/types/schema/createResponseSchema.d.ts.map +1 -1
  159. package/dist/node/types/schema/index.d.ts +1 -0
  160. package/dist/node/types/schema/index.d.ts.map +1 -1
  161. package/package.json +30 -31
  162. package/src/engine/requestSchemas.ts +2 -2
  163. package/src/provider/client/spec/MemoryXyoClient.spec.ts +2 -2
  164. package/src/provider/connection/XyoConnection.ts +3 -3
  165. package/src/provider/connection/spec/XyoConnection.ts +2 -2
  166. package/src/provider/gateway/spec/MemoryXyoGateway.spec.ts +2 -2
  167. package/src/provider/runner/JsonRpcXyoRunner.ts +2 -2
  168. package/src/provider/runner/MemoryXyoRunner.ts +2 -2
  169. package/src/provider/runner/NodeXyoRunner.ts +2 -2
  170. package/src/provider/signer/JsonRpcXyoSigner.ts +11 -8
  171. package/src/provider/signer/MemoryXyoSigner.ts +2 -2
  172. package/src/provider/signer/spec/RpcEngineXyoSigner.spec.ts +5 -4
  173. package/src/provider/viewer/JsonRpcXyoViewer.ts +15 -16
  174. package/src/provider/viewer/spec/JsonRpcXyoViewer.spec.ts +3 -2
  175. package/src/transport/HttpRpcTransport.ts +7 -7
  176. package/src/transport/MemoryRpcTransport.ts +18 -16
  177. package/src/transport/RpcTransport.ts +3 -3
  178. package/src/transport/post-message/LegacyPostMessageRpcTransport.ts +12 -12
  179. package/src/types/schema/AllRpcSchemas.ts +2 -2
  180. package/src/types/schema/XyoGatewayRpcSchemas.ts +17 -17
  181. package/src/types/schema/XyoProviderRpcSchemas.ts +16 -16
  182. package/src/types/schema/XyoRunnerRpcSchemas.ts +8 -11
  183. package/src/types/schema/XyoSignerRpcSchemas.ts +30 -25
  184. package/src/types/schema/XyoViewerRpcSchemas.ts +55 -52
  185. package/src/types/schema/common/Address.ts +5 -0
  186. package/src/types/schema/common/AllowedBlockPayload.ts +16 -0
  187. package/src/types/schema/common/BlockBoundWitness.ts +49 -0
  188. package/src/types/schema/common/BoundWitness.ts +53 -0
  189. package/src/types/schema/common/Chain.ts +5 -0
  190. package/src/types/schema/common/HydratedBlock.ts +32 -0
  191. package/src/types/schema/common/HydratedTransaction.ts +38 -0
  192. package/src/types/schema/common/Json.ts +19 -0
  193. package/src/types/schema/common/Payload.ts +31 -0
  194. package/src/types/schema/common/Sequence.ts +18 -0
  195. package/src/types/schema/common/TransactionBoundWitness.ts +42 -0
  196. package/src/types/schema/common/TransactionFees.ts +37 -11
  197. package/src/types/schema/common/index.ts +11 -13
  198. package/src/types/schema/common/spec/{BigIntSchema.spec.ts → BigIntZod.spec.ts} +6 -7
  199. package/src/types/schema/common/spec/HydratedBlockSchema.spec.ts +9 -83
  200. package/src/types/schema/common/spec/HydratedTransaction.spec.ts +18 -0
  201. package/src/types/schema/common/spec/Payload.spec.ts +29 -0
  202. package/src/types/schema/common/spec/TransactionBoundWitnessZod.spec.ts +18 -0
  203. package/src/types/schema/common/spec/UnsignedHydratedTransactionSchema.spec copy.ts +53 -0
  204. package/src/types/schema/index.ts +1 -0
  205. package/dist/neutral/types/schema/common/AddressSchema.d.ts +0 -5
  206. package/dist/neutral/types/schema/common/AddressSchema.d.ts.map +0 -1
  207. package/dist/neutral/types/schema/common/BigIntSchema.d.ts +0 -4
  208. package/dist/neutral/types/schema/common/BigIntSchema.d.ts.map +0 -1
  209. package/dist/neutral/types/schema/common/BlockBoundWitnessSchema.d.ts +0 -235
  210. package/dist/neutral/types/schema/common/BlockBoundWitnessSchema.d.ts.map +0 -1
  211. package/dist/neutral/types/schema/common/BoundWitnessSchema.d.ts +0 -163
  212. package/dist/neutral/types/schema/common/BoundWitnessSchema.d.ts.map +0 -1
  213. package/dist/neutral/types/schema/common/HashSchema.d.ts +0 -5
  214. package/dist/neutral/types/schema/common/HashSchema.d.ts.map +0 -1
  215. package/dist/neutral/types/schema/common/HexSchema.d.ts +0 -5
  216. package/dist/neutral/types/schema/common/HexSchema.d.ts.map +0 -1
  217. package/dist/neutral/types/schema/common/HydratedBlockSchema.d.ts +0 -282
  218. package/dist/neutral/types/schema/common/HydratedBlockSchema.d.ts.map +0 -1
  219. package/dist/neutral/types/schema/common/HydratedTransactionSchema.d.ts +0 -214
  220. package/dist/neutral/types/schema/common/HydratedTransactionSchema.d.ts.map +0 -1
  221. package/dist/neutral/types/schema/common/JsonSchema.d.ts +0 -7
  222. package/dist/neutral/types/schema/common/JsonSchema.d.ts.map +0 -1
  223. package/dist/neutral/types/schema/common/PayloadSchema.d.ts +0 -28
  224. package/dist/neutral/types/schema/common/PayloadSchema.d.ts.map +0 -1
  225. package/dist/neutral/types/schema/common/SequenceSchema.d.ts +0 -9
  226. package/dist/neutral/types/schema/common/SequenceSchema.d.ts.map +0 -1
  227. package/dist/neutral/types/schema/common/StorageMetaSchema.d.ts +0 -46
  228. package/dist/neutral/types/schema/common/StorageMetaSchema.d.ts.map +0 -1
  229. package/dist/neutral/types/schema/common/TransactionBoundWitnessSchema.d.ts +0 -258
  230. package/dist/neutral/types/schema/common/TransactionBoundWitnessSchema.d.ts.map +0 -1
  231. package/dist/neutral/types/schema/common/spec/BigIntSchema.spec.d.ts +0 -2
  232. package/dist/neutral/types/schema/common/spec/BigIntSchema.spec.d.ts.map +0 -1
  233. package/dist/node/types/schema/common/AddressSchema.d.ts +0 -5
  234. package/dist/node/types/schema/common/AddressSchema.d.ts.map +0 -1
  235. package/dist/node/types/schema/common/BigIntSchema.d.ts +0 -4
  236. package/dist/node/types/schema/common/BigIntSchema.d.ts.map +0 -1
  237. package/dist/node/types/schema/common/BlockBoundWitnessSchema.d.ts +0 -235
  238. package/dist/node/types/schema/common/BlockBoundWitnessSchema.d.ts.map +0 -1
  239. package/dist/node/types/schema/common/BoundWitnessSchema.d.ts +0 -163
  240. package/dist/node/types/schema/common/BoundWitnessSchema.d.ts.map +0 -1
  241. package/dist/node/types/schema/common/HashSchema.d.ts +0 -5
  242. package/dist/node/types/schema/common/HashSchema.d.ts.map +0 -1
  243. package/dist/node/types/schema/common/HexSchema.d.ts +0 -5
  244. package/dist/node/types/schema/common/HexSchema.d.ts.map +0 -1
  245. package/dist/node/types/schema/common/HydratedBlockSchema.d.ts +0 -282
  246. package/dist/node/types/schema/common/HydratedBlockSchema.d.ts.map +0 -1
  247. package/dist/node/types/schema/common/HydratedTransactionSchema.d.ts +0 -214
  248. package/dist/node/types/schema/common/HydratedTransactionSchema.d.ts.map +0 -1
  249. package/dist/node/types/schema/common/JsonSchema.d.ts +0 -7
  250. package/dist/node/types/schema/common/JsonSchema.d.ts.map +0 -1
  251. package/dist/node/types/schema/common/PayloadSchema.d.ts +0 -28
  252. package/dist/node/types/schema/common/PayloadSchema.d.ts.map +0 -1
  253. package/dist/node/types/schema/common/SequenceSchema.d.ts +0 -9
  254. package/dist/node/types/schema/common/SequenceSchema.d.ts.map +0 -1
  255. package/dist/node/types/schema/common/StorageMetaSchema.d.ts +0 -46
  256. package/dist/node/types/schema/common/StorageMetaSchema.d.ts.map +0 -1
  257. package/dist/node/types/schema/common/TransactionBoundWitnessSchema.d.ts +0 -258
  258. package/dist/node/types/schema/common/TransactionBoundWitnessSchema.d.ts.map +0 -1
  259. package/dist/node/types/schema/common/spec/BigIntSchema.spec.d.ts +0 -2
  260. package/dist/node/types/schema/common/spec/BigIntSchema.spec.d.ts.map +0 -1
  261. package/src/types/schema/common/AddressSchema.ts +0 -9
  262. package/src/types/schema/common/BigIntSchema.ts +0 -10
  263. package/src/types/schema/common/BlockBoundWitnessSchema.ts +0 -30
  264. package/src/types/schema/common/BoundWitnessSchema.ts +0 -45
  265. package/src/types/schema/common/HashSchema.ts +0 -7
  266. package/src/types/schema/common/HexSchema.ts +0 -7
  267. package/src/types/schema/common/HydratedBlockSchema.ts +0 -26
  268. package/src/types/schema/common/HydratedTransactionSchema.ts +0 -14
  269. package/src/types/schema/common/JsonSchema.ts +0 -19
  270. package/src/types/schema/common/PayloadSchema.ts +0 -6
  271. package/src/types/schema/common/SequenceSchema.ts +0 -19
  272. package/src/types/schema/common/StorageMetaSchema.ts +0 -14
  273. package/src/types/schema/common/TransactionBoundWitnessSchema.ts +0 -33
@@ -8,7 +8,7 @@ import { isDefined } from '@xylabs/typeof'
8
8
  import { v4 } from 'uuid'
9
9
  import type { z } from 'zod'
10
10
 
11
- import type { RpcSchemaMap } from '../../types/index.ts'
11
+ import type { RpcSchemaMap, XyoGatewayRpcMethodName } from '../../types/index.ts'
12
12
  import { jsonrpc, XyoGatewayRpcSchemas } from '../../types/index.ts'
13
13
  import type { RpcTransport } from '../RpcTransport.ts'
14
14
  import { isRpcError } from './helpers.ts'
@@ -26,23 +26,23 @@ const isRpcResponse = (data: any, targetId: string) => {
26
26
  }
27
27
 
28
28
  /** @deprecated - now part of a client gateway */
29
- export class LegacyPostMessageRpcTransport<T extends RpcSchemaMap = RpcSchemaMap> implements RpcTransport<T> {
29
+ export class LegacyPostMessageRpcTransport implements RpcTransport<RpcSchemaMap<XyoGatewayRpcMethodName>> {
30
30
  protected readonly destination?: string
31
- protected readonly schemas: T
31
+ protected readonly schemas: RpcSchemaMap<XyoGatewayRpcMethodName>
32
32
  protected readonly sessionId?: string
33
33
 
34
- constructor(defaultDestination?: string, schemas: T = XyoGatewayRpcSchemas as T, sessionId?: string) {
35
- this.schemas = schemas
34
+ constructor(defaultDestination?: string, sessionId?: string) {
35
+ this.schemas = XyoGatewayRpcSchemas
36
36
  this.destination = defaultDestination
37
37
  this.sessionId = sessionId
38
38
  }
39
39
 
40
40
  async sendRequest<
41
- TMethod extends keyof T & string,
41
+ TMethod extends keyof RpcSchemaMap<XyoGatewayRpcMethodName>,
42
42
  >(
43
43
  method: TMethod,
44
- params?: z.infer<T[TMethod]['params']['to']>,
45
- ): Promise<z.infer<T[TMethod]['result']['from']>> {
44
+ params?: z.input<RpcSchemaMap<XyoGatewayRpcMethodName>[TMethod]['params']['to']>,
45
+ ): Promise<z.output<RpcSchemaMap<XyoGatewayRpcMethodName>[TMethod]['result']['from']>> {
46
46
  const id = v4()
47
47
  return await this.callRpc(this.schemas, method, id, params)
48
48
  }
@@ -54,15 +54,15 @@ export class LegacyPostMessageRpcTransport<T extends RpcSchemaMap = RpcSchemaMap
54
54
  schemas: TSchemas,
55
55
  method: TMethod,
56
56
  id: string,
57
- params?: z.infer<TSchemas[TMethod]['params']['to']>,
58
- ): Promise<z.infer<TSchemas[TMethod]['result']['from']>> {
57
+ params?: z.input<TSchemas[TMethod]['params']['to']>,
58
+ ): Promise<z.output<TSchemas[TMethod]['result']['from']>> {
59
59
  const body: JsonRpcRequest = {
60
60
  jsonrpc,
61
61
  id,
62
62
  method: method as string,
63
63
  }
64
64
 
65
- body.params = (isDefined(params) && isDefined(schemas[method])) ? schemas[method].params.to.parse(params) : params
65
+ body.params = ((isDefined(params) && isDefined(schemas[method])) ? schemas[method].params.to.parse(params) : params) as JsonRpcRequest
66
66
 
67
67
  return await new Promise((resolve, reject) => {
68
68
  const id = body.id
@@ -92,7 +92,7 @@ export class LegacyPostMessageRpcTransport<T extends RpcSchemaMap = RpcSchemaMap
92
92
  return
93
93
  }
94
94
  if (isJsonRpcSuccess(data.eventData)) {
95
- resolve(data.eventData)
95
+ resolve(data.eventData as z.infer<TSchemas[TMethod]['result']['from']>)
96
96
  return
97
97
  }
98
98
  reject(new Error('Unexpected response format'))
@@ -4,9 +4,9 @@ import { XyoRunnerRpcSchemas } from './XyoRunnerRpcSchemas.ts'
4
4
  import { XyoSignerRpcSchemas } from './XyoSignerRpcSchemas.ts'
5
5
  import { XyoViewerRpcSchemas } from './XyoViewerRpcSchemas.ts'
6
6
 
7
- export const AllRpcSchemas: RpcSchemaMap = {
7
+ export const AllRpcSchemas = {
8
8
  ...XyoProviderRpcSchemas,
9
9
  ...XyoRunnerRpcSchemas,
10
10
  ...XyoSignerRpcSchemas,
11
11
  ...XyoViewerRpcSchemas,
12
- }
12
+ } satisfies RpcSchemaMap
@@ -1,34 +1,34 @@
1
- import type { Hex } from '@xylabs/hex'
1
+ import type { Chain } from '@xyo-network/xl1-protocol'
2
2
  import { z } from 'zod'
3
3
 
4
4
  import type { XyoGatewayRpcMethodName } from '../XyoGatewayRpc.ts'
5
- import { BlockBoundWitnessSchema, HydratedTransactionSchema } from './common/index.ts'
5
+ import { BlockBoundWitnessZod, HydratedTransactionZod } from './common/index.ts'
6
6
  import type { RpcSchemaMap } from './RpcSchemaMap.ts'
7
7
 
8
- export const ChainConnectionSchema = z.object({
9
- chainId: z.union([z.string(), z.custom<Hex>()]).optional(),
8
+ export const ChainConnectionZod = z.object({
9
+ chainId: z.union([z.string(), z.custom<Chain>()]).optional(),
10
10
  name: z.string(),
11
11
  url: z.string(),
12
12
  })
13
13
 
14
- export const CaveatTypesSchema = z.enum(['chain', 'expiration', 'filteredResponse', 'rateLimit'])
14
+ export const CaveatTypesZod = z.enum(['chain', 'expiration', 'filteredResponse', 'rateLimit'])
15
15
 
16
- export const CaveatsSchema = z.object({
17
- type: CaveatTypesSchema,
16
+ export const CaveatsZod = z.object({
17
+ type: CaveatTypesZod,
18
18
  value: z.unknown(), // JsonValue is usually unknown, adjust if you have a stricter type
19
19
  })
20
20
 
21
- export const PermissionSchema = z.object({
21
+ export const PermissionZod = z.object({
22
22
  capability: z.string(),
23
- caveats: CaveatsSchema.array().optional(),
23
+ caveats: CaveatsZod.array().optional(),
24
24
  invoker: z.string(),
25
25
  })
26
26
 
27
- export const InvokerPermissionSchema = PermissionSchema.extend({ date: z.number().optional() })
27
+ export const InvokerPermissionZod = PermissionZod.extend({ date: z.number().optional() })
28
28
 
29
- export type ChainConnection = z.infer<typeof ChainConnectionSchema>
29
+ export type ChainConnection = z.infer<typeof ChainConnectionZod>
30
30
 
31
- export const XyoGatewayRpcSchemas: RpcSchemaMap<XyoGatewayRpcMethodName> = {
31
+ export const XyoGatewayRpcSchemas = {
32
32
  /*
33
33
  xyoGateway_addConnection: {
34
34
  params: {
@@ -94,15 +94,15 @@ export const XyoGatewayRpcSchemas: RpcSchemaMap<XyoGatewayRpcMethodName> = {
94
94
  xyoGateway_submitTransaction: {
95
95
  params: {
96
96
  from: z.array(
97
- HydratedTransactionSchema,
97
+ HydratedTransactionZod,
98
98
  ),
99
99
  to: z.array(
100
- HydratedTransactionSchema,
100
+ HydratedTransactionZod,
101
101
  ),
102
102
  },
103
103
  result: {
104
- from: BlockBoundWitnessSchema,
105
- to: BlockBoundWitnessSchema,
104
+ from: BlockBoundWitnessZod,
105
+ to: BlockBoundWitnessZod,
106
106
  },
107
107
  },
108
- }
108
+ } satisfies RpcSchemaMap<XyoGatewayRpcMethodName>
@@ -2,36 +2,36 @@ import { z } from 'zod'
2
2
 
3
3
  import type { XyoProviderRpcMethodName } from '../XyoProviderRpc.ts'
4
4
  import {
5
- AddressFromStringSchema, AddressToStringSchema, PayloadSchema, SignedTransactionBoundWitnessSchema, TransactionFeesFromStingSchema,
6
- TransactionFeesToStingSchema,
5
+ AddressZod, PayloadZod, SignedTransactionBoundWitnessZod, TransactionFeesBigIntToJsonZod,
6
+ TransactionFeesJsonToBigIntZod,
7
7
  } from './common/index.ts'
8
8
  import type { RpcSchemaMap } from './RpcSchemaMap.ts'
9
9
 
10
- export const XyoProviderRpcSchemas: RpcSchemaMap<XyoProviderRpcMethodName> = {
10
+ export const XyoProviderRpcSchemas = {
11
11
  xyoProvider_send: {
12
12
  params: {
13
13
  to: z.tuple([
14
- AddressFromStringSchema,
15
- z.array(PayloadSchema),
16
- z.array(PayloadSchema),
14
+ AddressZod,
15
+ z.array(PayloadZod),
16
+ z.array(PayloadZod),
17
17
  z.number().nonnegative(),
18
18
  z.number().nonnegative(),
19
- TransactionFeesToStingSchema,
20
- AddressFromStringSchema.optional(),
19
+ TransactionFeesBigIntToJsonZod,
20
+ AddressZod.optional(),
21
21
  ]),
22
22
  from: z.tuple([
23
- AddressToStringSchema,
24
- z.array(PayloadSchema),
25
- z.array(PayloadSchema),
23
+ AddressZod,
24
+ z.array(PayloadZod),
25
+ z.array(PayloadZod),
26
26
  z.number().nonnegative(),
27
27
  z.number().nonnegative(),
28
- TransactionFeesFromStingSchema,
29
- AddressToStringSchema.optional(),
28
+ TransactionFeesJsonToBigIntZod,
29
+ AddressZod.optional(),
30
30
  ]),
31
31
  },
32
32
  result: {
33
- to: SignedTransactionBoundWitnessSchema,
34
- from: SignedTransactionBoundWitnessSchema,
33
+ to: SignedTransactionBoundWitnessZod,
34
+ from: SignedTransactionBoundWitnessZod,
35
35
  },
36
36
  },
37
- }
37
+ } satisfies RpcSchemaMap<XyoProviderRpcMethodName>
@@ -1,22 +1,19 @@
1
+ import { HashToJsonZod, JsonToHashZod } from '@xylabs/hex'
1
2
  import { z } from 'zod'
2
3
 
3
4
  import type { XyoRunnerRpcMethodName } from '../XyoRunnerRpc.ts'
4
- import {
5
- HashFromStringSchema,
6
- HashToStringSchema,
7
- SignedHydratedTransactionSchema,
8
- } from './common/index.ts'
5
+ import { SignedHydratedTransactionZod } from './common/index.ts'
9
6
  import type { RpcSchemaMap } from './RpcSchemaMap.ts'
10
7
 
11
- export const XyoRunnerRpcSchemas: RpcSchemaMap<XyoRunnerRpcMethodName> = {
8
+ export const XyoRunnerRpcSchemas = {
12
9
  xyoRunner_broadcastTransaction: {
13
10
  params: {
14
- to: z.tuple([SignedHydratedTransactionSchema]),
15
- from: z.tuple([SignedHydratedTransactionSchema]),
11
+ to: z.tuple([SignedHydratedTransactionZod]),
12
+ from: z.tuple([SignedHydratedTransactionZod]),
16
13
  },
17
14
  result: {
18
- to: HashToStringSchema,
19
- from: HashFromStringSchema,
15
+ to: HashToJsonZod,
16
+ from: JsonToHashZod,
20
17
  },
21
18
  },
22
- }
19
+ } satisfies RpcSchemaMap<XyoRunnerRpcMethodName>
@@ -1,60 +1,65 @@
1
+ import type { Signed } from '@xyo-network/boundwitness-model'
2
+ import type { SignedHydratedTransaction, TransactionBoundWitness } from '@xyo-network/xl1-protocol'
1
3
  import { z } from 'zod'
2
4
 
3
5
  import type { XyoSignerRpcMethodName } from '../XyoSignerRpc.ts'
4
6
  import {
5
- AddressFromStringSchema, AddressToStringSchema,
6
- HydratedTransactionSchema,
7
- PayloadSchema, SignedHydratedTransactionSchema, SignedTransactionBoundWitnessSchema,
8
- TransactionFeesFromStingSchema,
9
- TransactionFeesToStingSchema,
7
+ AddressZod,
8
+ AllowedBlockPayloadZod,
9
+ ChainZod,
10
+ PayloadZod, SignedHydratedTransactionZod, SignedTransactionBoundWitnessZod,
11
+ TransactionFeesBigIntToJsonZod,
12
+ TransactionFeesJsonToBigIntZod,
13
+ UnsignedHydratedTransactionZod,
10
14
  } from './common/index.ts'
11
15
  import type { RpcSchemaMap } from './RpcSchemaMap.ts'
12
16
 
13
- export const XyoSignerRpcSchemas: RpcSchemaMap<XyoSignerRpcMethodName> = {
17
+ export const XyoSignerRpcSchemas = {
14
18
  xyoSigner_address: {
15
19
  params: {
16
20
  to: z.array(z.any()).length(0).optional(),
17
21
  from: z.array(z.any()).length(0).optional(),
18
22
  },
19
23
  result: {
20
- to: AddressToStringSchema,
21
- from: AddressFromStringSchema,
24
+ to: AddressZod,
25
+ from: AddressZod,
22
26
  },
23
27
  },
28
+ // NOTE: method is deprecated which is why it uses deprecated types
24
29
  xyoSigner_createSignedTransaction: {
25
30
  params: {
26
31
  to: z.tuple([
27
- AddressFromStringSchema,
28
- z.array(PayloadSchema),
29
- z.array(PayloadSchema),
32
+ ChainZod,
33
+ z.array(AllowedBlockPayloadZod),
34
+ z.array(PayloadZod),
30
35
  z.number().nonnegative(),
31
36
  z.number().nonnegative(),
32
- TransactionFeesToStingSchema,
33
- AddressFromStringSchema.optional(),
37
+ TransactionFeesBigIntToJsonZod,
38
+ AddressZod.optional(),
34
39
  ]),
35
40
  from: z.tuple([
36
- AddressToStringSchema,
37
- z.array(PayloadSchema),
38
- z.array(PayloadSchema),
41
+ ChainZod,
42
+ z.array(PayloadZod),
43
+ z.array(PayloadZod),
39
44
  z.number().nonnegative(),
40
45
  z.number().nonnegative(),
41
- TransactionFeesFromStingSchema,
42
- AddressToStringSchema.optional(),
46
+ TransactionFeesJsonToBigIntZod,
47
+ AddressZod.optional(),
43
48
  ]),
44
49
  },
45
50
  result: {
46
- to: SignedTransactionBoundWitnessSchema,
47
- from: SignedTransactionBoundWitnessSchema,
51
+ to: SignedTransactionBoundWitnessZod,
52
+ from: SignedTransactionBoundWitnessZod.transform(data => data as Signed<TransactionBoundWitness>),
48
53
  },
49
54
  },
50
55
  xyoSigner_signTransaction: {
51
56
  params: {
52
- to: z.tuple([HydratedTransactionSchema]),
53
- from: z.tuple([HydratedTransactionSchema]),
57
+ to: z.tuple([UnsignedHydratedTransactionZod]),
58
+ from: z.tuple([UnsignedHydratedTransactionZod]),
54
59
  },
55
60
  result: {
56
- to: SignedHydratedTransactionSchema,
57
- from: SignedHydratedTransactionSchema,
61
+ to: SignedHydratedTransactionZod,
62
+ from: SignedHydratedTransactionZod.transform(data => data as SignedHydratedTransaction),
58
63
  },
59
64
  },
60
- }
65
+ } as const satisfies RpcSchemaMap<XyoSignerRpcMethodName>
@@ -1,61 +1,64 @@
1
+ import {
2
+ BigIntToJsonZod, HashToJsonZod, HashZod, JsonToBigIntZod,
3
+ JsonToHashZod,
4
+ } from '@xylabs/hex'
1
5
  import { z } from 'zod'
2
6
 
3
7
  import type { XyoViewerRpcMethodName } from '../XyoViewerRpc.ts'
4
8
  import {
5
- AddressFromStringSchema, AddressToStringSchema, BigIntFromStringSchema, BigIntToStringSchema,
6
- BlockNumberSchema,
7
- HashFromStringSchema, HashToStringSchema,
8
- PayloadSchema,
9
- SignedHydratedBlockSchema,
10
- SignedHydratedTransactionSchema,
9
+ AddressZod,
10
+ BlockNumberZod,
11
+ PayloadZod,
12
+ SignedHydratedBlockZod,
13
+ SignedHydratedTransactionZod,
11
14
  } from './common/index.ts'
12
15
  import type { RpcSchemaMap } from './RpcSchemaMap.ts'
13
16
 
14
- export const XyoViewerRpcSchemas: RpcSchemaMap<XyoViewerRpcMethodName> = {
17
+ export const XyoViewerRpcSchemas = {
15
18
  xyoViewer_accountBalance: {
16
19
  params: {
17
20
  to: z.union([
18
- z.tuple([AddressToStringSchema]),
19
- z.tuple([AddressToStringSchema, z.number()]),
20
- z.tuple([AddressToStringSchema, z.number(), z.boolean()]),
21
+ z.tuple([AddressZod]),
22
+ z.tuple([AddressZod, z.number()]),
23
+ z.tuple([AddressZod, z.number(), z.boolean()]),
21
24
  ]),
22
25
  from: z.union([
23
- z.tuple([AddressToStringSchema]),
24
- z.tuple([AddressToStringSchema, z.number()]),
25
- z.tuple([AddressToStringSchema, z.number(), z.boolean()]),
26
+ z.tuple([AddressZod]),
27
+ z.tuple([AddressZod, z.number()]),
28
+ z.tuple([AddressZod, z.number(), z.boolean()]),
26
29
  ]),
27
30
  },
28
31
  result: {
29
- to: BigIntToStringSchema,
30
- from: BigIntFromStringSchema,
32
+ to: BigIntToJsonZod,
33
+ from: JsonToBigIntZod,
31
34
  },
32
35
  },
33
36
  xyoViewer_accountHistory: {
34
37
  params: {
35
38
  to: z.union([
36
- z.tuple([AddressToStringSchema]),
37
- z.tuple([AddressToStringSchema, z.number()]),
38
- z.tuple([AddressToStringSchema, z.number(), z.boolean()]),
39
+ z.tuple([AddressZod]),
40
+ z.tuple([AddressZod, z.number()]),
41
+ z.tuple([AddressZod, z.number(), z.boolean()]),
39
42
  ]),
40
43
  from: z.union([
41
- z.tuple([AddressToStringSchema]),
42
- z.tuple([AddressToStringSchema, z.number()]),
43
- z.tuple([AddressToStringSchema, z.number(), z.boolean()]),
44
+ z.tuple([AddressZod]),
45
+ z.tuple([AddressZod, z.number()]),
46
+ z.tuple([AddressZod, z.number(), z.boolean()]),
44
47
  ]),
45
48
  },
46
49
  result: {
47
- to: z.array(z.array(PayloadSchema)),
48
- from: z.array(z.array(PayloadSchema)),
50
+ to: z.array(z.tuple([HashZod, HashZod, PayloadZod])),
51
+ from: z.array(z.tuple([HashZod, HashZod, PayloadZod])),
49
52
  },
50
53
  },
51
54
  xyoViewer_blockByHash: {
52
55
  params: {
53
- to: z.tuple([HashToStringSchema]),
54
- from: z.tuple([HashFromStringSchema]),
56
+ to: z.tuple([HashToJsonZod]),
57
+ from: z.tuple([JsonToHashZod]),
55
58
  },
56
59
  result: {
57
- to: SignedHydratedBlockSchema,
58
- from: SignedHydratedBlockSchema,
60
+ to: SignedHydratedBlockZod,
61
+ from: SignedHydratedBlockZod,
59
62
  },
60
63
  },
61
64
  xyoViewer_blockByNumber: {
@@ -64,18 +67,18 @@ export const XyoViewerRpcSchemas: RpcSchemaMap<XyoViewerRpcMethodName> = {
64
67
  from: z.tuple([z.number()]),
65
68
  },
66
69
  result: {
67
- to: SignedHydratedBlockSchema,
68
- from: SignedHydratedBlockSchema,
70
+ to: SignedHydratedBlockZod,
71
+ from: SignedHydratedBlockZod,
69
72
  },
70
73
  },
71
74
  xyoViewer_blocksByHash: {
72
75
  params: {
73
- to: z.tuple([HashToStringSchema, z.number().optional()]),
74
- from: z.tuple([HashFromStringSchema, z.number().optional()]),
76
+ to: z.tuple([HashZod, z.number().optional()]),
77
+ from: z.tuple([HashZod, z.number().optional()]),
75
78
  },
76
79
  result: {
77
- to: z.array(SignedHydratedBlockSchema),
78
- from: z.array(SignedHydratedBlockSchema),
80
+ to: z.array(SignedHydratedBlockZod),
81
+ from: z.array(SignedHydratedBlockZod),
79
82
  },
80
83
  },
81
84
  xyoViewer_chainId: {
@@ -84,8 +87,8 @@ export const XyoViewerRpcSchemas: RpcSchemaMap<XyoViewerRpcMethodName> = {
84
87
  from: z.array(z.any()).length(0).optional(),
85
88
  },
86
89
  result: {
87
- to: AddressToStringSchema,
88
- from: AddressFromStringSchema,
90
+ to: AddressZod,
91
+ from: AddressZod,
89
92
  },
90
93
  },
91
94
  xyoViewer_currentBlock: {
@@ -94,8 +97,8 @@ export const XyoViewerRpcSchemas: RpcSchemaMap<XyoViewerRpcMethodName> = {
94
97
  from: z.array(z.any()).length(0).optional(),
95
98
  },
96
99
  result: {
97
- to: SignedHydratedBlockSchema,
98
- from: SignedHydratedBlockSchema,
100
+ to: SignedHydratedBlockZod,
101
+ from: SignedHydratedBlockZod,
99
102
  },
100
103
  },
101
104
  xyoViewer_currentBlockHash: {
@@ -104,8 +107,8 @@ export const XyoViewerRpcSchemas: RpcSchemaMap<XyoViewerRpcMethodName> = {
104
107
  from: z.array(z.any()).length(0).optional(),
105
108
  },
106
109
  result: {
107
- to: HashToStringSchema,
108
- from: HashFromStringSchema,
110
+ to: HashZod,
111
+ from: HashZod,
109
112
  },
110
113
  },
111
114
  xyoViewer_currentBlockNumber: {
@@ -114,18 +117,18 @@ export const XyoViewerRpcSchemas: RpcSchemaMap<XyoViewerRpcMethodName> = {
114
117
  from: z.array(z.any()).length(0).optional(),
115
118
  },
116
119
  result: {
117
- to: BlockNumberSchema,
118
- from: BlockNumberSchema,
120
+ to: BlockNumberZod,
121
+ from: BlockNumberZod,
119
122
  },
120
123
  },
121
124
  xyoViewer_transactionByBlockHashAndIndex: {
122
125
  params: {
123
- to: z.tuple([HashToStringSchema, z.number()]),
124
- from: z.tuple([HashFromStringSchema, z.number()]),
126
+ to: z.tuple([HashZod, z.number()]),
127
+ from: z.tuple([HashZod, z.number()]),
125
128
  },
126
129
  result: {
127
- to: SignedHydratedTransactionSchema.nullable(),
128
- from: SignedHydratedTransactionSchema.nullable(),
130
+ to: SignedHydratedTransactionZod.nullable(),
131
+ from: SignedHydratedTransactionZod.nullable(),
129
132
  },
130
133
  },
131
134
  xyoViewer_transactionByBlockNumberAndIndex: {
@@ -134,18 +137,18 @@ export const XyoViewerRpcSchemas: RpcSchemaMap<XyoViewerRpcMethodName> = {
134
137
  from: z.tuple([z.number(), z.number()]),
135
138
  },
136
139
  result: {
137
- to: SignedHydratedTransactionSchema.nullable(),
138
- from: SignedHydratedTransactionSchema.nullable(),
140
+ to: SignedHydratedTransactionZod.nullable(),
141
+ from: SignedHydratedTransactionZod.nullable(),
139
142
  },
140
143
  },
141
144
  xyoViewer_transactionByHash: {
142
145
  params: {
143
- to: z.tuple([HashToStringSchema]),
144
- from: z.tuple([HashFromStringSchema]),
146
+ to: z.tuple([HashZod]),
147
+ from: z.tuple([HashZod]),
145
148
  },
146
149
  result: {
147
- to: SignedHydratedTransactionSchema.nullable(),
148
- from: SignedHydratedTransactionSchema.nullable(),
150
+ to: SignedHydratedTransactionZod.nullable(),
151
+ from: SignedHydratedTransactionZod.nullable(),
149
152
  },
150
153
  },
151
- }
154
+ } satisfies RpcSchemaMap<XyoViewerRpcMethodName>
@@ -0,0 +1,5 @@
1
+ import type { Address } from '@xylabs/hex'
2
+ import { AddressRegEx, toAddress } from '@xylabs/hex'
3
+ import { z } from 'zod'
4
+
5
+ export const AddressZod = z.string().toLowerCase().regex(AddressRegEx).transform<Address>(v => toAddress(v))
@@ -0,0 +1,16 @@
1
+ import { BoundWitnessSchema } from '@xyo-network/boundwitness-model'
2
+ import { SchemaSchema } from '@xyo-network/core-payload-plugins'
3
+ import {
4
+ ChainStakeIntentSchema, HashSchema, TransferSchema,
5
+ } from '@xyo-network/xl1-protocol'
6
+ import z from 'zod'
7
+
8
+ const AllowedBlockPayloadSchemas = [
9
+ BoundWitnessSchema,
10
+ ChainStakeIntentSchema,
11
+ HashSchema,
12
+ SchemaSchema,
13
+ TransferSchema,
14
+ ] as const
15
+
16
+ export const AllowedBlockPayloadZod = z.object({ schema: z.enum(AllowedBlockPayloadSchemas) })
@@ -0,0 +1,49 @@
1
+ import { HexZod } from '@xylabs/hex'
2
+ import { z } from 'zod'
3
+
4
+ import {
5
+ SignedBoundWitnessWithStorageMetaZod, SignedBoundWitnessZod, UnsignedBoundWitnessWithStorageMetaZod,
6
+ UnsignedBoundWitnessZod,
7
+ } from './BoundWitness.ts'
8
+ import { ChainZod } from './Chain.ts'
9
+ import { StorageMetaZod } from './Payload.ts'
10
+
11
+ export const BlockNumberZod = z.number().int().nonnegative()
12
+
13
+ const BlockBoundWitnessFieldsZod = z.object({
14
+ block: BlockNumberZod,
15
+ chain: ChainZod,
16
+ previous: HexZod.nullable(),
17
+ protocol: z.number().optional(),
18
+ step_hashes: z.array(HexZod).optional(),
19
+ })
20
+
21
+ const BlockBoundWitnessMetaZod = z.object({ $epoch: z.number() })
22
+
23
+ export const BlockBoundWitnessZod = UnsignedBoundWitnessZod
24
+ // eslint-disable-next-line sonarjs/deprecation
25
+ .merge(StorageMetaZod.partial())
26
+ // eslint-disable-next-line sonarjs/deprecation
27
+ .merge(BlockBoundWitnessFieldsZod)
28
+ // eslint-disable-next-line sonarjs/deprecation
29
+ .merge(BlockBoundWitnessMetaZod)
30
+ export const BlockBoundWitnessWithStorageMetaZod = UnsignedBoundWitnessWithStorageMetaZod
31
+ // eslint-disable-next-line sonarjs/deprecation
32
+ .merge(BlockBoundWitnessFieldsZod)
33
+ // eslint-disable-next-line sonarjs/deprecation
34
+ .merge(BlockBoundWitnessMetaZod)
35
+
36
+ export const SignedBlockBoundWitnessZod = SignedBoundWitnessZod
37
+ // eslint-disable-next-line sonarjs/deprecation
38
+ .merge(StorageMetaZod.partial())
39
+ // eslint-disable-next-line sonarjs/deprecation
40
+ .merge(BlockBoundWitnessFieldsZod)
41
+ // eslint-disable-next-line sonarjs/deprecation
42
+ .merge(BlockBoundWitnessMetaZod)
43
+ export const SignedBlockBoundWitnessWithStorageMetaZod = SignedBoundWitnessWithStorageMetaZod
44
+ // eslint-disable-next-line sonarjs/deprecation
45
+ .merge(StorageMetaZod.partial())
46
+ // eslint-disable-next-line sonarjs/deprecation
47
+ .merge(BlockBoundWitnessFieldsZod)
48
+ // eslint-disable-next-line sonarjs/deprecation
49
+ .merge(BlockBoundWitnessMetaZod)
@@ -0,0 +1,53 @@
1
+ import { HashZod, HexZod } from '@xylabs/hex'
2
+ import { BoundWitnessSchema } from '@xyo-network/boundwitness-model'
3
+ import { z } from 'zod'
4
+
5
+ import { AddressZod } from './Address.ts'
6
+ import { PayloadZod, SchemaZod } from './Payload.ts'
7
+
8
+ const BoundWitnessRequiredFieldsZod = z.object({
9
+ addresses: z.array(AddressZod),
10
+ payload_hashes: z.array(HashZod),
11
+ payload_schemas: z.array(SchemaZod),
12
+ previous_hashes: z.array(HashZod.nullable()),
13
+ })
14
+
15
+ const BoundWitnessMetaZod = z.object({
16
+ $destination: AddressZod.optional(),
17
+ $sourceQuery: HashZod.optional(),
18
+ $signatures: z.array(z.union([HexZod, z.null()])),
19
+ })
20
+
21
+ export const BoundWitnessZod = PayloadZod
22
+ .extend({ schema: z.literal(BoundWitnessSchema) })
23
+ .extend(BoundWitnessRequiredFieldsZod.shape)
24
+ .extend(BoundWitnessMetaZod.shape)
25
+ .refine(data => data.$signatures.length === data.addresses.length, { message: '$signatures length must equal addresses length' })
26
+
27
+ export type BoundWitness = z.infer<typeof BoundWitnessZod>
28
+
29
+ export const AnyBoundWitnessZod = BoundWitnessZod
30
+ .catchall(z.any())
31
+
32
+ export type AnyBoundWitness = z.infer<typeof AnyBoundWitnessZod>
33
+
34
+ export const UnsignedBoundWitnessZod = BoundWitnessZod.refine(data => data.$signatures.includes(null), { message: 'all $signatures must be null' })
35
+
36
+ export type UnsignedBoundWitness = z.infer<typeof UnsignedBoundWitnessZod>
37
+
38
+ export const AnyUnsignedBoundWitnessZod = UnsignedBoundWitnessZod
39
+ .catchall(z.any())
40
+
41
+ export type AnyUnsignedBoundWitness = z.infer<typeof AnyUnsignedBoundWitnessZod>
42
+
43
+ export const UnsignedBoundWitnessWithStorageMetaZod = UnsignedBoundWitnessZod
44
+ .extend(BoundWitnessRequiredFieldsZod.shape)
45
+ .extend(BoundWitnessMetaZod.shape)
46
+
47
+ export const SignedBoundWitnessZod = BoundWitnessZod.refine(data => !data.$signatures.includes(null), { message: 'all $signatures must not be null' })
48
+
49
+ export const SignedBoundWitnessWithStorageMetaZod = UnsignedBoundWitnessWithStorageMetaZod
50
+
51
+ export const AnySignedBoundWitnessZod = UnsignedBoundWitnessZod.catchall(z.any())
52
+
53
+ export const AnySignedBoundWitnessWithStorageMetaZod = UnsignedBoundWitnessWithStorageMetaZod.catchall(z.any())
@@ -0,0 +1,5 @@
1
+ import { AddressRegEx, toAddress } from '@xylabs/hex'
2
+ import type { Chain } from '@xyo-network/xl1-protocol'
3
+ import { z } from 'zod'
4
+
5
+ export const ChainZod = z.string().toLowerCase().regex(AddressRegEx).transform<Chain>(v => toAddress(v) as Chain)