@nktkas/hyperliquid 0.22.2 → 0.23.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 (256) hide show
  1. package/README.md +79 -67
  2. package/esm/mod.d.ts +1 -1
  3. package/esm/mod.d.ts.map +1 -1
  4. package/esm/src/base.d.ts +4 -1
  5. package/esm/src/base.d.ts.map +1 -1
  6. package/esm/src/base.js +2 -2
  7. package/esm/src/clients/exchange.d.ts +289 -207
  8. package/esm/src/clients/exchange.d.ts.map +1 -1
  9. package/esm/src/clients/exchange.js +605 -410
  10. package/esm/src/clients/info.d.ts +264 -48
  11. package/esm/src/clients/info.d.ts.map +1 -1
  12. package/esm/src/clients/info.js +273 -31
  13. package/esm/src/clients/multiSign.d.ts +285 -204
  14. package/esm/src/clients/multiSign.d.ts.map +1 -1
  15. package/esm/src/clients/multiSign.js +521 -493
  16. package/esm/src/clients/subscription.d.ts +38 -3
  17. package/esm/src/clients/subscription.d.ts.map +1 -1
  18. package/esm/src/clients/subscription.js +36 -3
  19. package/esm/src/signing/{_ethers.d.ts → _signTypedData/ethers.d.ts} +1 -1
  20. package/esm/src/signing/_signTypedData/ethers.d.ts.map +1 -0
  21. package/esm/src/signing/_signTypedData/mod.d.ts +35 -0
  22. package/esm/src/signing/_signTypedData/mod.d.ts.map +1 -0
  23. package/esm/src/signing/_signTypedData/mod.js +59 -0
  24. package/esm/src/signing/_signTypedData/private_key.d.ts +26 -0
  25. package/esm/src/signing/_signTypedData/private_key.d.ts.map +1 -0
  26. package/esm/src/signing/_signTypedData/private_key.js +144 -0
  27. package/esm/src/signing/{_viem.d.ts → _signTypedData/viem.d.ts} +2 -2
  28. package/esm/src/signing/_signTypedData/viem.d.ts.map +1 -0
  29. package/{script/src/signing/_window.d.ts → esm/src/signing/_signTypedData/window.d.ts} +18 -12
  30. package/esm/src/signing/_signTypedData/window.d.ts.map +1 -0
  31. package/esm/src/signing/{_window.js → _signTypedData/window.js} +3 -2
  32. package/esm/src/signing/_sorter.d.ts +56 -82
  33. package/esm/src/signing/_sorter.d.ts.map +1 -1
  34. package/esm/src/signing/_sorter.js +36 -49
  35. package/esm/src/signing/mod.d.ts +151 -130
  36. package/esm/src/signing/mod.d.ts.map +1 -1
  37. package/esm/src/signing/mod.js +182 -228
  38. package/esm/src/transports/base.d.ts +1 -1
  39. package/esm/src/transports/base.d.ts.map +1 -1
  40. package/esm/src/transports/base.js +2 -2
  41. package/esm/src/transports/http/http_transport.d.ts +9 -15
  42. package/esm/src/transports/http/http_transport.d.ts.map +1 -1
  43. package/esm/src/transports/http/http_transport.js +64 -59
  44. package/esm/src/transports/websocket/_hyperliquid_event_target.d.ts +1 -1
  45. package/esm/src/transports/websocket/_hyperliquid_event_target.d.ts.map +1 -1
  46. package/esm/src/transports/websocket/_hyperliquid_event_target.js +1 -1
  47. package/esm/src/transports/websocket/_reconnecting_websocket.d.ts.map +1 -1
  48. package/esm/src/transports/websocket/_reconnecting_websocket.js +17 -4
  49. package/esm/src/transports/websocket/_websocket_async_request.d.ts +0 -9
  50. package/esm/src/transports/websocket/_websocket_async_request.d.ts.map +1 -1
  51. package/esm/src/transports/websocket/_websocket_async_request.js +14 -20
  52. package/esm/src/transports/websocket/websocket_transport.d.ts +8 -4
  53. package/esm/src/transports/websocket/websocket_transport.d.ts.map +1 -1
  54. package/esm/src/transports/websocket/websocket_transport.js +83 -54
  55. package/esm/src/types/exchange/requests.d.ts +27 -51
  56. package/esm/src/types/exchange/requests.d.ts.map +1 -1
  57. package/esm/src/types/explorer/requests.d.ts +5 -8
  58. package/esm/src/types/explorer/requests.d.ts.map +1 -1
  59. package/esm/src/types/info/accounts.d.ts +5 -5
  60. package/esm/src/types/info/accounts.d.ts.map +1 -1
  61. package/esm/src/types/info/markets.d.ts +6 -0
  62. package/esm/src/types/info/markets.d.ts.map +1 -1
  63. package/esm/src/types/info/orders.d.ts +1 -1
  64. package/esm/src/types/info/orders.d.ts.map +1 -1
  65. package/esm/src/types/info/requests.d.ts +129 -124
  66. package/esm/src/types/info/requests.d.ts.map +1 -1
  67. package/{script/src/types/info/delegations.d.ts → esm/src/types/info/validators.d.ts} +2 -2
  68. package/esm/src/types/info/validators.d.ts.map +1 -0
  69. package/esm/src/types/info/vaults.d.ts +7 -0
  70. package/esm/src/types/info/vaults.d.ts.map +1 -1
  71. package/esm/src/types/mod.d.ts +1 -1
  72. package/esm/src/types/mod.d.ts.map +1 -1
  73. package/esm/src/types/subscriptions/requests.d.ts +72 -18
  74. package/esm/src/types/subscriptions/requests.d.ts.map +1 -1
  75. package/esm/src/types/subscriptions/responses.d.ts +2 -0
  76. package/esm/src/types/subscriptions/responses.d.ts.map +1 -1
  77. package/package.json +8 -5
  78. package/script/mod.d.ts +1 -1
  79. package/script/mod.d.ts.map +1 -1
  80. package/script/mod.js +13 -23
  81. package/script/src/base.d.ts +4 -1
  82. package/script/src/base.d.ts.map +1 -1
  83. package/script/src/base.js +10 -20
  84. package/script/src/clients/exchange.d.ts +289 -207
  85. package/script/src/clients/exchange.d.ts.map +1 -1
  86. package/script/src/clients/exchange.js +2000 -1815
  87. package/script/src/clients/info.d.ts +264 -48
  88. package/script/src/clients/info.d.ts.map +1 -1
  89. package/script/src/clients/info.js +1442 -1210
  90. package/script/src/clients/multiSign.d.ts +285 -204
  91. package/script/src/clients/multiSign.d.ts.map +1 -1
  92. package/script/src/clients/multiSign.js +2043 -2025
  93. package/script/src/clients/subscription.d.ts +38 -3
  94. package/script/src/clients/subscription.d.ts.map +1 -1
  95. package/script/src/clients/subscription.js +568 -545
  96. package/script/src/signing/{_ethers.d.ts → _signTypedData/ethers.d.ts} +1 -1
  97. package/script/src/signing/_signTypedData/ethers.d.ts.map +1 -0
  98. package/script/src/signing/_signTypedData/ethers.js +16 -0
  99. package/script/src/signing/_signTypedData/mod.d.ts +35 -0
  100. package/script/src/signing/_signTypedData/mod.d.ts.map +1 -0
  101. package/script/src/signing/_signTypedData/mod.js +67 -0
  102. package/script/src/signing/_signTypedData/private_key.d.ts +26 -0
  103. package/script/src/signing/_signTypedData/private_key.d.ts.map +1 -0
  104. package/script/src/signing/_signTypedData/private_key.js +148 -0
  105. package/script/src/signing/{_viem.d.ts → _signTypedData/viem.d.ts} +2 -2
  106. package/script/src/signing/_signTypedData/viem.d.ts.map +1 -0
  107. package/script/src/signing/_signTypedData/viem.js +9 -0
  108. package/{esm/src/signing/_window.d.ts → script/src/signing/_signTypedData/window.d.ts} +18 -12
  109. package/script/src/signing/_signTypedData/window.d.ts.map +1 -0
  110. package/script/src/signing/_signTypedData/window.js +34 -0
  111. package/script/src/signing/_sorter.d.ts +56 -82
  112. package/script/src/signing/_sorter.d.ts.map +1 -1
  113. package/script/src/signing/_sorter.js +655 -678
  114. package/script/src/signing/mod.d.ts +151 -130
  115. package/script/src/signing/mod.d.ts.map +1 -1
  116. package/script/src/signing/mod.js +286 -342
  117. package/script/src/transports/base.d.ts +1 -1
  118. package/script/src/transports/base.d.ts.map +1 -1
  119. package/script/src/transports/base.js +11 -21
  120. package/script/src/transports/http/http_transport.d.ts +9 -15
  121. package/script/src/transports/http/http_transport.d.ts.map +1 -1
  122. package/script/src/transports/http/http_transport.js +97 -102
  123. package/script/src/transports/websocket/_hyperliquid_event_target.d.ts +1 -1
  124. package/script/src/transports/websocket/_hyperliquid_event_target.d.ts.map +1 -1
  125. package/script/src/transports/websocket/_hyperliquid_event_target.js +51 -61
  126. package/script/src/transports/websocket/_reconnecting_websocket.d.ts.map +1 -1
  127. package/script/src/transports/websocket/_reconnecting_websocket.js +271 -268
  128. package/script/src/transports/websocket/_websocket_async_request.d.ts +0 -9
  129. package/script/src/transports/websocket/_websocket_async_request.d.ts.map +1 -1
  130. package/script/src/transports/websocket/_websocket_async_request.js +157 -174
  131. package/script/src/transports/websocket/websocket_transport.d.ts +8 -4
  132. package/script/src/transports/websocket/websocket_transport.d.ts.map +1 -1
  133. package/script/src/transports/websocket/websocket_transport.js +209 -189
  134. package/script/src/types/exchange/requests.d.ts +27 -51
  135. package/script/src/types/exchange/requests.d.ts.map +1 -1
  136. package/script/src/types/exchange/requests.js +2 -12
  137. package/script/src/types/exchange/responses.js +2 -12
  138. package/script/src/types/explorer/requests.d.ts +5 -8
  139. package/script/src/types/explorer/requests.d.ts.map +1 -1
  140. package/script/src/types/explorer/requests.js +2 -12
  141. package/script/src/types/explorer/responses.js +2 -12
  142. package/script/src/types/info/accounts.d.ts +5 -5
  143. package/script/src/types/info/accounts.d.ts.map +1 -1
  144. package/script/src/types/info/accounts.js +2 -12
  145. package/script/src/types/info/assets.js +2 -12
  146. package/script/src/types/info/markets.d.ts +6 -0
  147. package/script/src/types/info/markets.d.ts.map +1 -1
  148. package/script/src/types/info/markets.js +2 -12
  149. package/script/src/types/info/orders.d.ts +1 -1
  150. package/script/src/types/info/orders.d.ts.map +1 -1
  151. package/script/src/types/info/orders.js +2 -12
  152. package/script/src/types/info/requests.d.ts +129 -124
  153. package/script/src/types/info/requests.d.ts.map +1 -1
  154. package/script/src/types/info/requests.js +2 -12
  155. package/{esm/src/types/info/delegations.d.ts → script/src/types/info/validators.d.ts} +2 -2
  156. package/script/src/types/info/validators.d.ts.map +1 -0
  157. package/script/src/types/info/validators.js +2 -0
  158. package/script/src/types/info/vaults.d.ts +7 -0
  159. package/script/src/types/info/vaults.d.ts.map +1 -1
  160. package/script/src/types/info/vaults.js +2 -12
  161. package/script/src/types/mod.d.ts +1 -1
  162. package/script/src/types/mod.d.ts.map +1 -1
  163. package/script/src/types/mod.js +2 -12
  164. package/script/src/types/subscriptions/requests.d.ts +72 -18
  165. package/script/src/types/subscriptions/requests.d.ts.map +1 -1
  166. package/script/src/types/subscriptions/requests.js +2 -12
  167. package/script/src/types/subscriptions/responses.d.ts +2 -0
  168. package/script/src/types/subscriptions/responses.d.ts.map +1 -1
  169. package/script/src/types/subscriptions/responses.js +2 -12
  170. package/esm/deps/jsr.io/@derzade/typescript-event-target/1.1.1/mod.d.ts +0 -2
  171. package/esm/deps/jsr.io/@derzade/typescript-event-target/1.1.1/mod.d.ts.map +0 -1
  172. package/esm/deps/jsr.io/@derzade/typescript-event-target/1.1.1/mod.js +0 -1
  173. package/esm/deps/jsr.io/@derzade/typescript-event-target/1.1.1/src/TypedEventTarget.d.ts +0 -95
  174. package/esm/deps/jsr.io/@derzade/typescript-event-target/1.1.1/src/TypedEventTarget.d.ts.map +0 -1
  175. package/esm/deps/jsr.io/@derzade/typescript-event-target/1.1.1/src/TypedEventTarget.js +0 -10
  176. package/esm/deps/jsr.io/@std/async/1.0.13/delay.d.ts +0 -43
  177. package/esm/deps/jsr.io/@std/async/1.0.13/delay.d.ts.map +0 -1
  178. package/esm/deps/jsr.io/@std/async/1.0.13/delay.js +0 -63
  179. package/esm/deps/jsr.io/@std/bytes/1.0.6/_types.d.ts +0 -9
  180. package/esm/deps/jsr.io/@std/bytes/1.0.6/_types.d.ts.map +0 -1
  181. package/esm/deps/jsr.io/@std/bytes/1.0.6/_types.js +0 -2
  182. package/esm/deps/jsr.io/@std/bytes/1.0.6/concat.d.ts +0 -21
  183. package/esm/deps/jsr.io/@std/bytes/1.0.6/concat.d.ts.map +0 -1
  184. package/esm/deps/jsr.io/@std/bytes/1.0.6/concat.js +0 -32
  185. package/esm/deps/jsr.io/@std/encoding/1.0.10/_common16.d.ts +0 -23
  186. package/esm/deps/jsr.io/@std/encoding/1.0.10/_common16.d.ts.map +0 -1
  187. package/esm/deps/jsr.io/@std/encoding/1.0.10/_common16.js +0 -51
  188. package/esm/deps/jsr.io/@std/encoding/1.0.10/_common_detach.d.ts +0 -4
  189. package/esm/deps/jsr.io/@std/encoding/1.0.10/_common_detach.d.ts.map +0 -1
  190. package/esm/deps/jsr.io/@std/encoding/1.0.10/_common_detach.js +0 -13
  191. package/esm/deps/jsr.io/@std/encoding/1.0.10/_types.d.ts +0 -9
  192. package/esm/deps/jsr.io/@std/encoding/1.0.10/_types.d.ts.map +0 -1
  193. package/esm/deps/jsr.io/@std/encoding/1.0.10/_types.js +0 -2
  194. package/esm/deps/jsr.io/@std/encoding/1.0.10/hex.d.ts +0 -39
  195. package/esm/deps/jsr.io/@std/encoding/1.0.10/hex.d.ts.map +0 -1
  196. package/esm/deps/jsr.io/@std/encoding/1.0.10/hex.js +0 -87
  197. package/esm/deps/jsr.io/@std/msgpack/1.0.3/_types.d.ts +0 -9
  198. package/esm/deps/jsr.io/@std/msgpack/1.0.3/_types.d.ts.map +0 -1
  199. package/esm/deps/jsr.io/@std/msgpack/1.0.3/_types.js +0 -2
  200. package/esm/deps/jsr.io/@std/msgpack/1.0.3/encode.d.ts +0 -39
  201. package/esm/deps/jsr.io/@std/msgpack/1.0.3/encode.d.ts.map +0 -1
  202. package/esm/deps/jsr.io/@std/msgpack/1.0.3/encode.js +0 -237
  203. package/esm/src/signing/_ethers.d.ts.map +0 -1
  204. package/esm/src/signing/_private_key.d.ts +0 -22
  205. package/esm/src/signing/_private_key.d.ts.map +0 -1
  206. package/esm/src/signing/_private_key.js +0 -124
  207. package/esm/src/signing/_viem.d.ts.map +0 -1
  208. package/esm/src/signing/_window.d.ts.map +0 -1
  209. package/esm/src/types/info/delegations.d.ts.map +0 -1
  210. package/script/deps/jsr.io/@derzade/typescript-event-target/1.1.1/mod.d.ts +0 -2
  211. package/script/deps/jsr.io/@derzade/typescript-event-target/1.1.1/mod.d.ts.map +0 -1
  212. package/script/deps/jsr.io/@derzade/typescript-event-target/1.1.1/mod.js +0 -27
  213. package/script/deps/jsr.io/@derzade/typescript-event-target/1.1.1/src/TypedEventTarget.d.ts +0 -95
  214. package/script/deps/jsr.io/@derzade/typescript-event-target/1.1.1/src/TypedEventTarget.d.ts.map +0 -1
  215. package/script/deps/jsr.io/@derzade/typescript-event-target/1.1.1/src/TypedEventTarget.js +0 -24
  216. package/script/deps/jsr.io/@std/async/1.0.13/delay.d.ts +0 -43
  217. package/script/deps/jsr.io/@std/async/1.0.13/delay.d.ts.map +0 -1
  218. package/script/deps/jsr.io/@std/async/1.0.13/delay.js +0 -76
  219. package/script/deps/jsr.io/@std/bytes/1.0.6/_types.d.ts +0 -9
  220. package/script/deps/jsr.io/@std/bytes/1.0.6/_types.d.ts.map +0 -1
  221. package/script/deps/jsr.io/@std/bytes/1.0.6/_types.js +0 -13
  222. package/script/deps/jsr.io/@std/bytes/1.0.6/concat.d.ts +0 -21
  223. package/script/deps/jsr.io/@std/bytes/1.0.6/concat.d.ts.map +0 -1
  224. package/script/deps/jsr.io/@std/bytes/1.0.6/concat.js +0 -45
  225. package/script/deps/jsr.io/@std/encoding/1.0.10/_common16.d.ts +0 -23
  226. package/script/deps/jsr.io/@std/encoding/1.0.10/_common16.d.ts.map +0 -1
  227. package/script/deps/jsr.io/@std/encoding/1.0.10/_common16.js +0 -67
  228. package/script/deps/jsr.io/@std/encoding/1.0.10/_common_detach.d.ts +0 -4
  229. package/script/deps/jsr.io/@std/encoding/1.0.10/_common_detach.d.ts.map +0 -1
  230. package/script/deps/jsr.io/@std/encoding/1.0.10/_common_detach.js +0 -26
  231. package/script/deps/jsr.io/@std/encoding/1.0.10/_types.d.ts +0 -9
  232. package/script/deps/jsr.io/@std/encoding/1.0.10/_types.d.ts.map +0 -1
  233. package/script/deps/jsr.io/@std/encoding/1.0.10/_types.js +0 -13
  234. package/script/deps/jsr.io/@std/encoding/1.0.10/hex.d.ts +0 -39
  235. package/script/deps/jsr.io/@std/encoding/1.0.10/hex.d.ts.map +0 -1
  236. package/script/deps/jsr.io/@std/encoding/1.0.10/hex.js +0 -101
  237. package/script/deps/jsr.io/@std/msgpack/1.0.3/_types.d.ts +0 -9
  238. package/script/deps/jsr.io/@std/msgpack/1.0.3/_types.d.ts.map +0 -1
  239. package/script/deps/jsr.io/@std/msgpack/1.0.3/_types.js +0 -13
  240. package/script/deps/jsr.io/@std/msgpack/1.0.3/encode.d.ts +0 -39
  241. package/script/deps/jsr.io/@std/msgpack/1.0.3/encode.d.ts.map +0 -1
  242. package/script/deps/jsr.io/@std/msgpack/1.0.3/encode.js +0 -250
  243. package/script/src/signing/_ethers.d.ts.map +0 -1
  244. package/script/src/signing/_ethers.js +0 -26
  245. package/script/src/signing/_private_key.d.ts +0 -22
  246. package/script/src/signing/_private_key.d.ts.map +0 -1
  247. package/script/src/signing/_private_key.js +0 -138
  248. package/script/src/signing/_viem.d.ts.map +0 -1
  249. package/script/src/signing/_viem.js +0 -19
  250. package/script/src/signing/_window.d.ts.map +0 -1
  251. package/script/src/signing/_window.js +0 -43
  252. package/script/src/types/info/delegations.d.ts.map +0 -1
  253. package/script/src/types/info/delegations.js +0 -12
  254. /package/esm/src/signing/{_ethers.js → _signTypedData/ethers.js} +0 -0
  255. /package/esm/src/signing/{_viem.js → _signTypedData/viem.js} +0 -0
  256. /package/esm/src/types/info/{delegations.js → validators.js} +0 -0
@@ -66,6 +66,8 @@ export declare class SubscriptionClient<T extends ISubscriptionTransport = ISubs
66
66
  * @param listener - The callback function to be called when the event is received.
67
67
  * @returns A promise that resolves with a {@link Subscription} object to manage the subscription lifecycle.
68
68
  *
69
+ * @throws {TransportError} When the transport layer throws an error.
70
+ *
69
71
  * @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/websocket/subscriptions
70
72
  * @example
71
73
  * ```ts
@@ -86,6 +88,8 @@ export declare class SubscriptionClient<T extends ISubscriptionTransport = ISubs
86
88
  * @param listener - The callback function to be called when the event is received.
87
89
  * @returns A promise that resolves with a {@link Subscription} object to manage the subscription lifecycle.
88
90
  *
91
+ * @throws {TransportError} When the transport layer throws an error.
92
+ *
89
93
  * @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/websocket/subscriptions
90
94
  * @example
91
95
  * ```ts
@@ -105,6 +109,8 @@ export declare class SubscriptionClient<T extends ISubscriptionTransport = ISubs
105
109
  * @param listener - The callback function to be called when the event is received.
106
110
  * @returns A promise that resolves with a {@link Subscription} object to manage the subscription lifecycle.
107
111
  *
112
+ * @throws {TransportError} When the transport layer throws an error.
113
+ *
108
114
  * @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/websocket/subscriptions
109
115
  * @example
110
116
  * ```ts
@@ -126,6 +132,8 @@ export declare class SubscriptionClient<T extends ISubscriptionTransport = ISubs
126
132
  * @param listener - The callback function to be called when the event is received.
127
133
  * @returns A promise that resolves with a {@link Subscription} object to manage the subscription lifecycle.
128
134
  *
135
+ * @throws {TransportError} When the transport layer throws an error.
136
+ *
129
137
  * @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/websocket/subscriptions
130
138
  * @example
131
139
  * ```ts
@@ -146,6 +154,8 @@ export declare class SubscriptionClient<T extends ISubscriptionTransport = ISubs
146
154
  * @param listener - The callback function to be called when the event is received.
147
155
  * @returns A promise that resolves with a {@link Subscription} object to manage the subscription lifecycle.
148
156
  *
157
+ * @throws {TransportError} When the transport layer throws an error.
158
+ *
149
159
  * @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/websocket/subscriptions
150
160
  * @example
151
161
  * ```ts
@@ -166,7 +176,9 @@ export declare class SubscriptionClient<T extends ISubscriptionTransport = ISubs
166
176
  * @returns A promise that resolves with a {@link Subscription} object to manage the subscription lifecycle.
167
177
  * @note Make sure the endpoint in the {@link transport} supports this method.
168
178
  *
169
- * @see null - no documentation
179
+ * @throws {TransportError} When the transport layer throws an error.
180
+ *
181
+ * @see null
170
182
  * @example
171
183
  * ```ts
172
184
  * import * as hl from "@nktkas/hyperliquid";
@@ -186,7 +198,9 @@ export declare class SubscriptionClient<T extends ISubscriptionTransport = ISubs
186
198
  * @returns A promise that resolves with a {@link Subscription} object to manage the subscription lifecycle.
187
199
  * @note Make sure the endpoint in the {@link transport} supports this method.
188
200
  *
189
- * @see null - no documentation
201
+ * @throws {TransportError} When the transport layer throws an error.
202
+ *
203
+ * @see null
190
204
  * @example
191
205
  * ```ts
192
206
  * import * as hl from "@nktkas/hyperliquid";
@@ -206,6 +220,8 @@ export declare class SubscriptionClient<T extends ISubscriptionTransport = ISubs
206
220
  * @param listener - The callback function to be called when the event is received.
207
221
  * @returns A promise that resolves with a {@link Subscription} object to manage the subscription lifecycle.
208
222
  *
223
+ * @throws {TransportError} When the transport layer throws an error.
224
+ *
209
225
  * @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/websocket/subscriptions
210
226
  * @example
211
227
  * ```ts
@@ -226,6 +242,8 @@ export declare class SubscriptionClient<T extends ISubscriptionTransport = ISubs
226
242
  * @param listener - The callback function to be called when the event is received.
227
243
  * @returns A promise that resolves with a {@link Subscription} object to manage the subscription lifecycle.
228
244
  *
245
+ * @throws {TransportError} When the transport layer throws an error.
246
+ *
229
247
  * @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/websocket/subscriptions
230
248
  * @example
231
249
  * ```ts
@@ -246,6 +264,8 @@ export declare class SubscriptionClient<T extends ISubscriptionTransport = ISubs
246
264
  * @param listener - The callback function to be called when the event is received.
247
265
  * @returns A promise that resolves with a {@link Subscription} object to manage the subscription lifecycle.
248
266
  *
267
+ * @throws {TransportError} When the transport layer throws an error.
268
+ *
249
269
  * @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/websocket/subscriptions
250
270
  * @example
251
271
  * ```ts
@@ -266,6 +286,8 @@ export declare class SubscriptionClient<T extends ISubscriptionTransport = ISubs
266
286
  * @param listener - The callback function to be called when the event is received.
267
287
  * @returns A promise that resolves with a {@link Subscription} object to manage the subscription lifecycle.
268
288
  *
289
+ * @throws {TransportError} When the transport layer throws an error.
290
+ *
269
291
  * @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/websocket/subscriptions
270
292
  * @example
271
293
  * ```ts
@@ -285,9 +307,10 @@ export declare class SubscriptionClient<T extends ISubscriptionTransport = ISubs
285
307
  * @param args - The parameters for the subscription.
286
308
  * @param listener - The callback function to be called when the event is received.
287
309
  * @returns A promise that resolves with a {@link Subscription} object to manage the subscription lifecycle.
288
- *
289
310
  * @note Different subscriptions cannot be distinguished from each other.
290
311
  *
312
+ * @throws {TransportError} When the transport layer throws an error.
313
+ *
291
314
  * @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/websocket/subscriptions
292
315
  * @example
293
316
  * ```ts
@@ -308,6 +331,8 @@ export declare class SubscriptionClient<T extends ISubscriptionTransport = ISubs
308
331
  * @param listener - The callback function to be called when the event is received.
309
332
  * @returns A promise that resolves with a {@link Subscription} object to manage the subscription lifecycle.
310
333
  *
334
+ * @throws {TransportError} When the transport layer throws an error.
335
+ *
311
336
  * @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/websocket/subscriptions
312
337
  * @example
313
338
  * ```ts
@@ -328,6 +353,8 @@ export declare class SubscriptionClient<T extends ISubscriptionTransport = ISubs
328
353
  * @param listener - The callback function to be called when the event is received.
329
354
  * @returns A promise that resolves with a {@link Subscription} object to manage the subscription lifecycle.
330
355
  *
356
+ * @throws {TransportError} When the transport layer throws an error.
357
+ *
331
358
  * @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/websocket/subscriptions
332
359
  * @example
333
360
  * ```ts
@@ -348,6 +375,8 @@ export declare class SubscriptionClient<T extends ISubscriptionTransport = ISubs
348
375
  * @param listener - The callback function to be called when the event is received.
349
376
  * @returns A promise that resolves with a {@link Subscription} object to manage the subscription lifecycle.
350
377
  *
378
+ * @throws {TransportError} When the transport layer throws an error.
379
+ *
351
380
  * @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/websocket/subscriptions
352
381
  * @example
353
382
  * ```ts
@@ -368,6 +397,8 @@ export declare class SubscriptionClient<T extends ISubscriptionTransport = ISubs
368
397
  * @param listener - The callback function to be called when the event is received.
369
398
  * @returns A promise that resolves with a {@link Subscription} object to manage the subscription lifecycle.
370
399
  *
400
+ * @throws {TransportError} When the transport layer throws an error.
401
+ *
371
402
  * @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/websocket/subscriptions
372
403
  * @example
373
404
  * ```ts
@@ -388,6 +419,8 @@ export declare class SubscriptionClient<T extends ISubscriptionTransport = ISubs
388
419
  * @param listener - The callback function to be called when the event is received.
389
420
  * @returns A promise that resolves with a {@link Subscription} object to manage the subscription lifecycle.
390
421
  *
422
+ * @throws {TransportError} When the transport layer throws an error.
423
+ *
391
424
  * @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/websocket/subscriptions
392
425
  * @example
393
426
  * ```ts
@@ -408,6 +441,8 @@ export declare class SubscriptionClient<T extends ISubscriptionTransport = ISubs
408
441
  * @param listener - The callback function to be called when the event is received.
409
442
  * @returns A promise that resolves with a {@link Subscription} object to manage the subscription lifecycle.
410
443
  *
444
+ * @throws {TransportError} When the transport layer throws an error.
445
+ *
411
446
  * @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/websocket/subscriptions
412
447
  * @example
413
448
  * ```ts
@@ -1 +1 @@
1
- {"version":3,"file":"subscription.d.ts","sourceRoot":"","sources":["../../../src/src/clients/subscription.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAClF,OAAO,KAAK,EACR,uBAAuB,EACvB,wBAAwB,EACxB,gBAAgB,EAChB,YAAY,EACZ,eAAe,EAGf,eAAe,EACf,qBAAqB,EACrB,qBAAqB,EACrB,eAAe,EACf,mBAAmB,EACnB,kBAAkB,EAClB,qBAAqB,EACrB,oCAAoC,EACpC,wBAAwB,EACxB,2BAA2B,EAC3B,iBAAiB,EACpB,MAAM,oCAAoC,CAAC;AAC5C,OAAO,KAAK,EACR,gBAAgB,EAChB,iBAAiB,EACjB,oBAAoB,EACpB,SAAS,EACT,KAAK,EACL,cAAc,EACd,cAAc,EACd,OAAO,EACP,WAAW,EACX,WAAW,EACX,cAAc,EACd,6BAA6B,EAC7B,iBAAiB,EACjB,oBAAoB,EACpB,UAAU,EACb,MAAM,qCAAqC,CAAC;AAC7C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AACtD,OAAO,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,WAAW,EAAE,MA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AC;CAG/C"}
1
+ {"version":3,"file":"subscription.d.ts","sourceRoot":"","sources":["../../../src/src/clients/subscription.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAClF,OAAO,KAAK,EACR,uBAAuB,EACvB,wBAAwB,EACxB,gBAAgB,EAChB,YAAY,EACZ,eAAe,EAGf,eAAe,EACf,qBAAqB,EACrB,qBAAqB,EACrB,eAAe,EACf,mBAAmB,EACnB,kBAAkB,EAClB,qBAAqB,EACrB,oCAAoC,EACpC,wBAAwB,EACxB,2BAA2B,EAC3B,iBAAiB,EACpB,MAAM,oCAAoC,CAAC;AAC5C,OAAO,KAAK,EACR,gBAAgB,EAChB,iBAAiB,EACjB,oBAAoB,EACpB,SAAS,EACT,KAAK,EACL,cAAc,EACd,cAAc,EACd,OAAO,EACP,WAAW,EACX,WAAW,EACX,cAAc,EACd,6BAA6B,EAC7B,iBAAiB,EACjB,oBAAoB,EACpB,UAAU,EACb,MAAM,qCAAqC,CAAC;AAC7C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AACtD,OAAO,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AACxE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gCAAgC,CAAC;AAEhE,qEAAqE;AACrE,MAAM,WAAW,4BAA4B,CAAC,CAAC,SAAS,sBAAsB,GAAG,sBAAsB;IACnG,4DAA4D;IAC5D,SAAS,EAAE,CAAC,CAAC;CAChB;AAED,+EAA+E;AAC/E,MAAM,MAAM,6BAA6B,GAAG,IAAI,CAAC,uBAAuB,EAAE,MAAM,CAAC,CAAC;AAElF,gFAAgF;AAChF,MAAM,MAAM,8BAA8B,GAAG,IAAI,CAAC,wBAAwB,EAAE,MAAM,CAAC,CAAC;AAEpF,wEAAwE;AACxE,MAAM,MAAM,mBAAmB,GAAG,IAAI,CAAC,gBA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EAAE,2BAA2B,EAAE,QAAQ,EAAE,CAAC,IAAI,EAAE,cAAc,KAAK,IAAI,GAAG,OAAO,CAAC,YAAY,CAAC;IAYhH;;;;;;;;;;;;;;;;;;;;OAoBG;IACH,2BAA2B,CACvB,IAAI,EAAE,0CAA0C,EAChD,QAAQ,EAAE,CAAC,IAAI,EAAE,6BAA6B,KAAK,IAAI,GACxD,OAAO,CAAC,YAAY,CAAC;IAYxB;;;;;;;;;;;;;;;;;;;;OAoBG;IACH,eAAe,CAAC,IAAI,EAAE,oBAAoB,EAAE,QAAQ,EAAE,CAAC,IAAI,EAAE,iBAAiB,KAAK,IAAI,GAAG,OAAO,CAAC,YAAY,CAAC;IAY/G;;;;;;;;;;;;;;;;;;;;OAoBG;IACH,kBAAkB,CACd,IAAI,EAAE,uBAAuB,EAC7B,QAAQ,EAAE,CAAC,IAAI,EAAE,oBAAoB,KAAK,IAAI,GAC/C,OAAO,CAAC,YAAY,CAAC;IAYxB;;;;;;;;;;;;;;;;;;;;OAoBG;IACH,QAAQ,CAAC,IAAI,EAAE,uBAAuB,EAAE,QAAQ,EAAE,CAAC,IAAI,EAAE,UAAU,KAAK,IAAI,GAAG,OAAO,CAAC,YAAY,CAAC;IAY9F,CAAC,MAAM,CAAC,YAAY,CAAC,IAAI,OAAO,CAAC,IAAI,CAAC;CAG/C"}
@@ -25,6 +25,8 @@ export class SubscriptionClient {
25
25
  * @param listener - The callback function to be called when the event is received.
26
26
  * @returns A promise that resolves with a {@link Subscription} object to manage the subscription lifecycle.
27
27
  *
28
+ * @throws {TransportError} When the transport layer throws an error.
29
+ *
28
30
  * @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/websocket/subscriptions
29
31
  * @example
30
32
  * ```ts
@@ -56,6 +58,8 @@ export class SubscriptionClient {
56
58
  * @param listener - The callback function to be called when the event is received.
57
59
  * @returns A promise that resolves with a {@link Subscription} object to manage the subscription lifecycle.
58
60
  *
61
+ * @throws {TransportError} When the transport layer throws an error.
62
+ *
59
63
  * @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/websocket/subscriptions
60
64
  * @example
61
65
  * ```ts
@@ -98,6 +102,8 @@ export class SubscriptionClient {
98
102
  * @param listener - The callback function to be called when the event is received.
99
103
  * @returns A promise that resolves with a {@link Subscription} object to manage the subscription lifecycle.
100
104
  *
105
+ * @throws {TransportError} When the transport layer throws an error.
106
+ *
101
107
  * @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/websocket/subscriptions
102
108
  * @example
103
109
  * ```ts
@@ -128,6 +134,8 @@ export class SubscriptionClient {
128
134
  * @param listener - The callback function to be called when the event is received.
129
135
  * @returns A promise that resolves with a {@link Subscription} object to manage the subscription lifecycle.
130
136
  *
137
+ * @throws {TransportError} When the transport layer throws an error.
138
+ *
131
139
  * @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/websocket/subscriptions
132
140
  * @example
133
141
  * ```ts
@@ -159,7 +167,9 @@ export class SubscriptionClient {
159
167
  * @returns A promise that resolves with a {@link Subscription} object to manage the subscription lifecycle.
160
168
  * @note Make sure the endpoint in the {@link transport} supports this method.
161
169
  *
162
- * @see null - no documentation
170
+ * @throws {TransportError} When the transport layer throws an error.
171
+ *
172
+ * @see null
163
173
  * @example
164
174
  * ```ts
165
175
  * import * as hl from "@nktkas/hyperliquid";
@@ -186,7 +196,9 @@ export class SubscriptionClient {
186
196
  * @returns A promise that resolves with a {@link Subscription} object to manage the subscription lifecycle.
187
197
  * @note Make sure the endpoint in the {@link transport} supports this method.
188
198
  *
189
- * @see null - no documentation
199
+ * @throws {TransportError} When the transport layer throws an error.
200
+ *
201
+ * @see null
190
202
  * @example
191
203
  * ```ts
192
204
  * import * as hl from "@nktkas/hyperliquid";
@@ -213,6 +225,8 @@ export class SubscriptionClient {
213
225
  * @param listener - The callback function to be called when the event is received.
214
226
  * @returns A promise that resolves with a {@link Subscription} object to manage the subscription lifecycle.
215
227
  *
228
+ * @throws {TransportError} When the transport layer throws an error.
229
+ *
216
230
  * @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/websocket/subscriptions
217
231
  * @example
218
232
  * ```ts
@@ -245,6 +259,8 @@ export class SubscriptionClient {
245
259
  * @param listener - The callback function to be called when the event is received.
246
260
  * @returns A promise that resolves with a {@link Subscription} object to manage the subscription lifecycle.
247
261
  *
262
+ * @throws {TransportError} When the transport layer throws an error.
263
+ *
248
264
  * @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/websocket/subscriptions
249
265
  * @example
250
266
  * ```ts
@@ -273,6 +289,8 @@ export class SubscriptionClient {
273
289
  * @param listener - The callback function to be called when the event is received.
274
290
  * @returns A promise that resolves with a {@link Subscription} object to manage the subscription lifecycle.
275
291
  *
292
+ * @throws {TransportError} When the transport layer throws an error.
293
+ *
276
294
  * @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/websocket/subscriptions
277
295
  * @example
278
296
  * ```ts
@@ -301,6 +319,8 @@ export class SubscriptionClient {
301
319
  * @param listener - The callback function to be called when the event is received.
302
320
  * @returns A promise that resolves with a {@link Subscription} object to manage the subscription lifecycle.
303
321
  *
322
+ * @throws {TransportError} When the transport layer throws an error.
323
+ *
304
324
  * @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/websocket/subscriptions
305
325
  * @example
306
326
  * ```ts
@@ -330,9 +350,10 @@ export class SubscriptionClient {
330
350
  * @param args - The parameters for the subscription.
331
351
  * @param listener - The callback function to be called when the event is received.
332
352
  * @returns A promise that resolves with a {@link Subscription} object to manage the subscription lifecycle.
333
- *
334
353
  * @note Different subscriptions cannot be distinguished from each other.
335
354
  *
355
+ * @throws {TransportError} When the transport layer throws an error.
356
+ *
336
357
  * @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/websocket/subscriptions
337
358
  * @example
338
359
  * ```ts
@@ -361,6 +382,8 @@ export class SubscriptionClient {
361
382
  * @param listener - The callback function to be called when the event is received.
362
383
  * @returns A promise that resolves with a {@link Subscription} object to manage the subscription lifecycle.
363
384
  *
385
+ * @throws {TransportError} When the transport layer throws an error.
386
+ *
364
387
  * @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/websocket/subscriptions
365
388
  * @example
366
389
  * ```ts
@@ -392,6 +415,8 @@ export class SubscriptionClient {
392
415
  * @param listener - The callback function to be called when the event is received.
393
416
  * @returns A promise that resolves with a {@link Subscription} object to manage the subscription lifecycle.
394
417
  *
418
+ * @throws {TransportError} When the transport layer throws an error.
419
+ *
395
420
  * @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/websocket/subscriptions
396
421
  * @example
397
422
  * ```ts
@@ -422,6 +447,8 @@ export class SubscriptionClient {
422
447
  * @param listener - The callback function to be called when the event is received.
423
448
  * @returns A promise that resolves with a {@link Subscription} object to manage the subscription lifecycle.
424
449
  *
450
+ * @throws {TransportError} When the transport layer throws an error.
451
+ *
425
452
  * @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/websocket/subscriptions
426
453
  * @example
427
454
  * ```ts
@@ -452,6 +479,8 @@ export class SubscriptionClient {
452
479
  * @param listener - The callback function to be called when the event is received.
453
480
  * @returns A promise that resolves with a {@link Subscription} object to manage the subscription lifecycle.
454
481
  *
482
+ * @throws {TransportError} When the transport layer throws an error.
483
+ *
455
484
  * @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/websocket/subscriptions
456
485
  * @example
457
486
  * ```ts
@@ -482,6 +511,8 @@ export class SubscriptionClient {
482
511
  * @param listener - The callback function to be called when the event is received.
483
512
  * @returns A promise that resolves with a {@link Subscription} object to manage the subscription lifecycle.
484
513
  *
514
+ * @throws {TransportError} When the transport layer throws an error.
515
+ *
485
516
  * @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/websocket/subscriptions
486
517
  * @example
487
518
  * ```ts
@@ -512,6 +543,8 @@ export class SubscriptionClient {
512
543
  * @param listener - The callback function to be called when the event is received.
513
544
  * @returns A promise that resolves with a {@link Subscription} object to manage the subscription lifecycle.
514
545
  *
546
+ * @throws {TransportError} When the transport layer throws an error.
547
+ *
515
548
  * @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/websocket/subscriptions
516
549
  * @example
517
550
  * ```ts
@@ -30,4 +30,4 @@ export interface AbstractEthersV5Signer {
30
30
  export declare function isAbstractEthersSigner(client: unknown): client is AbstractEthersSigner;
31
31
  /** Checks if the given value is an abstract ethers v5 signer. */
32
32
  export declare function isAbstractEthersV5Signer(client: unknown): client is AbstractEthersV5Signer;
33
- //# sourceMappingURL=_ethers.d.ts.map
33
+ //# sourceMappingURL=ethers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ethers.d.ts","sourceRoot":"","sources":["../../../../src/src/signing/_signTypedData/ethers.ts"],"names":[],"mappings":"AAAA,sGAAsG;AACtG,MAAM,WAAW,oBAAoB;IACjC,aAAa,CACT,MAAM,EAAE;QACJ,IAAI,EAAE,MAAM,CAAC;QACb,OAAO,EAAE,MAAM,CAAC;QAChB,OAAO,EAAE,MAAM,CAAC;QAChB,iBAAiB,EAAE,MAAM,CAAC;KAC7B,EACD,KAAK,EAAE;QACH,CAAC,GAAG,EAAE,MAAM,GAAG;YACX,IAAI,EAAE,MAAM,CAAC;YACb,IAAI,EAAE,MAAM,CAAC;SAChB,EAAE,CAAC;KACP,EACD,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC/B,OAAO,CAAC,MAAM,CAAC,CAAC;CACtB;AAED,+FAA+F;AAC/F,MAAM,WAAW,sBAAsB;IACnC,cAAc,CACV,MAAM,EAAE;QACJ,IAAI,EAAE,MAAM,CAAC;QACb,OAAO,EAAE,MAAM,CAAC;QAChB,OAAO,EAAE,MAAM,CAAC;QAChB,iBAAiB,EAAE,MAAM,CAAC;KAC7B,EACD,KAAK,EAAE;QACH,CAAC,GAAG,EAAE,MAAM,GAAG;YACX,IAAI,EAAE,MAAM,CAAC;YACb,IAAI,EAAE,MAAM,CAAC;SAChB,EAAE,CAAC;KACP,EACD,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC/B,OAAO,CAAC,MAAM,CAAC,CAAC;CACtB;AAED,8DAA8D;AAC9D,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,OAAO,GAAG,MAAM,IAAI,oBAAoB,CAItF;AAED,iEAAiE;AACjE,wBAAgB,wBAAwB,CAAC,MAAM,EAAE,OAAO,GAAG,MAAM,IAAI,sBAAsB,CAI1F"}
@@ -0,0 +1,35 @@
1
+ import type { Hex } from "../../base.js";
2
+ import { type AbstractEthersSigner, type AbstractEthersV5Signer, isAbstractEthersSigner, isAbstractEthersV5Signer } from "./ethers.js";
3
+ import { isValidPrivateKey } from "./private_key.js";
4
+ import { type AbstractViemWalletClient, isAbstractViemWalletClient } from "./viem.js";
5
+ import { type AbstractWindowEthereum, isAbstractWindowEthereum } from "./window.js";
6
+ export { type AbstractEthersSigner, type AbstractEthersV5Signer, type AbstractViemWalletClient, type AbstractWindowEthereum, isAbstractEthersSigner, isAbstractEthersV5Signer, isAbstractViemWalletClient, isAbstractWindowEthereum, isValidPrivateKey, };
7
+ /** Abstract interface for a wallet that can sign typed data. */
8
+ export type AbstractWallet = Hex | AbstractViemWalletClient | AbstractEthersSigner | AbstractEthersV5Signer | AbstractWindowEthereum;
9
+ /** ECDSA signature components for Ethereum transactions and typed data. */
10
+ export interface Signature {
11
+ /** First 32-byte component of ECDSA signature */
12
+ r: Hex;
13
+ /** Second 32-byte component of ECDSA signature */
14
+ s: Hex;
15
+ /** Recovery identifier (27 or 28, or 0 or 1 for EIP-155) */
16
+ v: number;
17
+ }
18
+ export declare function signTypedData(args: {
19
+ wallet: AbstractWallet;
20
+ domain: {
21
+ name: string;
22
+ version: string;
23
+ chainId: number;
24
+ verifyingContract: Hex;
25
+ };
26
+ types: {
27
+ [key: string]: {
28
+ name: string;
29
+ type: string;
30
+ }[];
31
+ };
32
+ primaryType: string;
33
+ message: Record<string, unknown>;
34
+ }): Promise<Signature>;
35
+ //# sourceMappingURL=mod.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../../../../src/src/signing/_signTypedData/mod.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EACH,KAAK,oBAAoB,EACzB,KAAK,sBAAsB,EAC3B,sBAAsB,EACtB,wBAAwB,EAC3B,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,iBAAiB,EAAgD,MAAM,kBAAkB,CAAC;AACnG,OAAO,EAAE,KAAK,wBAAwB,EAAE,0BAA0B,EAAE,MAAM,WAAW,CAAC;AACtF,OAAO,EAAE,KAAK,sBAAsB,EAAE,wBAAwB,EAAmC,MAAM,aAAa,CAAC;AAErH,OAAO,EACH,KAAK,oBAAoB,EACzB,KAAK,sBAAsB,EAC3B,KAAK,wBAAwB,EAC7B,KAAK,sBAAsB,EAC3B,sBAAsB,EACtB,wBAAwB,EACxB,0BAA0B,EAC1B,wBAAwB,EACxB,iBAAiB,GACpB,CAAC;AAEF,gEAAgE;AAChE,MAAM,MAAM,cAAc,GACpB,GAAG,GACH,wBAAwB,GACxB,oBAAoB,GACpB,sBAAsB,GACtB,sBAAsB,CAAC;AAE7B,2EAA2E;AAC3E,MAAM,WAAW,SAAS;IACtB,iDAAiD;IACjD,CAAC,EAAE,GAAG,CAAC;IACP,kDAAkD;IAClD,CAAC,EAAE,GAAG,CAAC;IACP,4DAA4D;IAC5D,CAAC,EAAE,MAAM,CAAC;CACb;AAED,wBAAsB,aAAa,CAAC,IAAI,EAAE;IACtC,MAAM,EAAE,cAAc,CAAC;IACvB,MAAM,EAAE;QACJ,IAAI,EAAE,MAAM,CAAC;QACb,OAAO,EAAE,MAAM,CAAC;QAChB,OAAO,EAAE,MAAM,CAAC;QAChB,iBAAiB,EAAE,GAAG,CAAC;KAC1B,CAAC;IACF,KAAK,EAAE;QACH,CAAC,GAAG,EAAE,MAAM,GAAG;YACX,IAAI,EAAE,MAAM,CAAC;YACb,IAAI,EAAE,MAAM,CAAC;SAChB,EAAE,CAAC;KACP,CAAC;IACF,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACpC,GAAG,OAAO,CAAC,SAAS,CAAC,CA4CrB"}
@@ -0,0 +1,59 @@
1
+ import { isAbstractEthersSigner, isAbstractEthersV5Signer, } from "./ethers.js";
2
+ import { isValidPrivateKey, signTypedData as signTypedDataWithPrivateKey } from "./private_key.js";
3
+ import { isAbstractViemWalletClient } from "./viem.js";
4
+ import { isAbstractWindowEthereum, signTypedDataWithWindowEthereum } from "./window.js";
5
+ export { isAbstractEthersSigner, isAbstractEthersV5Signer, isAbstractViemWalletClient, isAbstractWindowEthereum, isValidPrivateKey, };
6
+ export async function signTypedData(args) {
7
+ const { wallet, domain, types, primaryType, message } = args;
8
+ let signature;
9
+ if (isValidPrivateKey(wallet)) {
10
+ signature = await signTypedDataWithPrivateKey({
11
+ privateKey: wallet,
12
+ domain,
13
+ types,
14
+ primaryType,
15
+ message,
16
+ });
17
+ }
18
+ else if (isAbstractViemWalletClient(wallet)) {
19
+ signature = await wallet.signTypedData({
20
+ domain,
21
+ types: {
22
+ EIP712Domain: [
23
+ { name: "name", type: "string" },
24
+ { name: "version", type: "string" },
25
+ { name: "chainId", type: "uint256" },
26
+ { name: "verifyingContract", type: "address" },
27
+ ],
28
+ ...types,
29
+ },
30
+ primaryType,
31
+ message,
32
+ });
33
+ }
34
+ else if (isAbstractEthersSigner(wallet)) {
35
+ signature = await wallet.signTypedData(domain, types, message);
36
+ }
37
+ else if (isAbstractEthersV5Signer(wallet)) {
38
+ signature = await wallet._signTypedData(domain, types, message);
39
+ }
40
+ else if (isAbstractWindowEthereum(wallet)) {
41
+ signature = await signTypedDataWithWindowEthereum({
42
+ ethereum: wallet,
43
+ domain,
44
+ types,
45
+ primaryType,
46
+ message,
47
+ });
48
+ }
49
+ else {
50
+ throw new Error("Unsupported wallet for signing typed data");
51
+ }
52
+ return splitSignature(signature);
53
+ }
54
+ function splitSignature(signature) {
55
+ const r = `0x${signature.slice(2, 66)}`;
56
+ const s = `0x${signature.slice(66, 130)}`;
57
+ const v = parseInt(signature.slice(130, 132), 16);
58
+ return { r, s, v };
59
+ }
@@ -0,0 +1,26 @@
1
+ type Hex = `0x${string}`;
2
+ interface Types {
3
+ [type: string]: {
4
+ name: string;
5
+ type: string;
6
+ }[];
7
+ }
8
+ interface Domain extends Record<string, unknown> {
9
+ name?: string;
10
+ version?: string;
11
+ chainId?: number | string | bigint | Hex;
12
+ verifyingContract?: Hex;
13
+ salt?: Hex;
14
+ }
15
+ /** Signs typed data with a private key. */
16
+ export declare function signTypedData(args: {
17
+ privateKey: string;
18
+ domain?: Domain;
19
+ types: Types;
20
+ primaryType: string;
21
+ message: Record<string, unknown>;
22
+ }): Promise<Hex>;
23
+ /** Validates if a string is a valid secp256k1 private key. */
24
+ export declare function isValidPrivateKey(privateKey: unknown): privateKey is string;
25
+ export {};
26
+ //# sourceMappingURL=private_key.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"private_key.d.ts","sourceRoot":"","sources":["../../../../src/src/signing/_signTypedData/private_key.ts"],"names":[],"mappings":"AAGA,KAAK,GAAG,GAAG,KAAK,MAAM,EAAE,CAAC;AAEzB,UAAU,KAAK;IACX,CAAC,IAAI,EAAE,MAAM,GAAG;QACZ,IAAI,EAAE,MAAM,CAAC;QACb,IAAI,EAAE,MAAM,CAAC;KAChB,EAAE,CAAC;CACP;AAED,UAAU,MAAO,SAAQ,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAC5C,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,GAAG,CAAC;IACzC,iBAAiB,CAAC,EAAE,GAAG,CAAC;IACxB,IAAI,CAAC,EAAE,GAAG,CAAC;CACd;AAED,2CAA2C;AAC3C,wBAAsB,aAAa,CAAC,IAAI,EAAE;IACtC,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,KAAK,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACpC,GAAG,OAAO,CAAC,GAAG,CAAC,CAkBf;AAuJD,8DAA8D;AAC9D,wBAAgB,iBAAiB,CAAC,UAAU,EAAE,OAAO,GAAG,UAAU,IAAI,MAAM,CAG3E"}
@@ -0,0 +1,144 @@
1
+ import { keccak_256 } from "@noble/hashes/sha3";
2
+ import { etc, signAsync, utils } from "@noble/secp256k1";
3
+ /** Signs typed data with a private key. */
4
+ export async function signTypedData(args) {
5
+ const { privateKey, domain = {}, types, primaryType, message, } = args;
6
+ const hash = hashTypedData({ domain, types, primaryType, message });
7
+ const signature = await signAsync(hash, cleanHex(privateKey));
8
+ const r = signature.r.toString(16).padStart(64, "0");
9
+ const s = signature.s.toString(16).padStart(64, "0");
10
+ const v = (signature.recovery + 27).toString(16).padStart(2, "0");
11
+ return `0x${r}${s}${v}`;
12
+ }
13
+ function hashTypedData(args) {
14
+ const { domain, types: types_, primaryType, message } = args;
15
+ const domainFields = [];
16
+ if (domain.name !== undefined) {
17
+ domainFields.push({ name: "name", type: "string" });
18
+ }
19
+ if (domain.version !== undefined) {
20
+ domainFields.push({ name: "version", type: "string" });
21
+ }
22
+ if (domain.chainId !== undefined) {
23
+ domainFields.push({ name: "chainId", type: "uint256" });
24
+ }
25
+ if (domain.verifyingContract !== undefined) {
26
+ domainFields.push({ name: "verifyingContract", type: "address" });
27
+ }
28
+ if (domain.salt !== undefined) {
29
+ domainFields.push({ name: "salt", type: "bytes32" });
30
+ }
31
+ const types = {
32
+ EIP712Domain: domainFields,
33
+ ...types_,
34
+ };
35
+ const bytes = [new Uint8Array([0x19, 0x01])];
36
+ bytes.push(hashStruct("EIP712Domain", domain, types));
37
+ if (primaryType !== "EIP712Domain")
38
+ bytes.push(hashStruct(primaryType, message, types));
39
+ return keccak_256(etc.concatBytes(...bytes));
40
+ }
41
+ function hashStruct(primaryType, data, types) {
42
+ const typeHash = keccak_256(new TextEncoder().encode(encodeType(primaryType, types)));
43
+ const encodedValues = types[primaryType].map((field) => encodeValue(field.type, data[field.name], types));
44
+ return keccak_256(etc.concatBytes(typeHash, ...encodedValues));
45
+ }
46
+ function encodeType(primaryType, types) {
47
+ const deps = findTypeDependencies(primaryType, types);
48
+ const sortedDeps = [primaryType, ...deps.filter((d) => d !== primaryType).sort()];
49
+ return sortedDeps
50
+ .map((type) => `${type}(${types[type].map((field) => `${field.type} ${field.name}`).join(",")})`)
51
+ .join("");
52
+ }
53
+ function findTypeDependencies(primaryType, types, found = new Set()) {
54
+ if (found.has(primaryType) || !types[primaryType])
55
+ return [];
56
+ found.add(primaryType);
57
+ for (const field of types[primaryType]) {
58
+ const baseType = field.type.replace(/\[\d*\]$/, "");
59
+ if (types[baseType]) {
60
+ findTypeDependencies(baseType, types, found);
61
+ }
62
+ }
63
+ return Array.from(found);
64
+ }
65
+ function encodeValue(type, value, types) {
66
+ const arrayMatch = type.match(/^(.*)\[(\d*)\]$/);
67
+ if (arrayMatch) {
68
+ // Extract type info: base type and optional length
69
+ const [, baseType, len] = arrayMatch;
70
+ if (!Array.isArray(value)) {
71
+ throw new Error(`Expected array for ${type}, got ${typeof value}`);
72
+ }
73
+ if (len && value.length !== +len) {
74
+ throw new Error(`Invalid length for ${type}: expected ${len}, got ${value.length}`);
75
+ }
76
+ // Encode each element in the array and hash them together
77
+ const encodedElements = value.map((v) => encodeValue(baseType, v, types));
78
+ return keccak_256(etc.concatBytes(...encodedElements));
79
+ }
80
+ if (types[type]) {
81
+ if (value === undefined)
82
+ return new Uint8Array(32);
83
+ return hashStruct(type, value, types);
84
+ }
85
+ if (type === "string") {
86
+ return keccak_256(new TextEncoder().encode(value));
87
+ }
88
+ if (type === "address") {
89
+ const bytes = etc.hexToBytes(cleanHex(value));
90
+ if (bytes.length !== 20)
91
+ throw new Error("address must be 20 bytes");
92
+ const padded = new Uint8Array(32);
93
+ padded.set(bytes, 12);
94
+ return padded;
95
+ }
96
+ if (type.startsWith("uint") || type.startsWith("int")) {
97
+ // Extract type info: uint/int and bit size
98
+ const isUint = type.startsWith("uint");
99
+ const bits = parseInt(type.slice(isUint ? 4 : 3) || "256");
100
+ if (bits > 256 || bits % 8 !== 0) {
101
+ throw new Error(`Unsupported bit size for ${type}: ${bits}`);
102
+ }
103
+ // Apply Two's complement for specified bit size
104
+ const bigIntValue = BigInt(value);
105
+ const resizedValue = isUint ? BigInt.asUintN(bits, bigIntValue) : BigInt.asIntN(bits, bigIntValue);
106
+ // Convert to 32-byte big-endian
107
+ const hex = BigInt.asUintN(256, resizedValue).toString(16).padStart(64, "0");
108
+ return etc.hexToBytes(hex);
109
+ }
110
+ if (type === "bool") {
111
+ const result = new Uint8Array(32);
112
+ result[31] = value ? 1 : 0;
113
+ return result;
114
+ }
115
+ if (type === "bytes") {
116
+ const bytes = typeof value === "string" ? etc.hexToBytes(cleanHex(value)) : value;
117
+ return keccak_256(bytes);
118
+ }
119
+ const bytesMatch = type.match(/^bytes(\d+)$/);
120
+ if (bytesMatch) {
121
+ // Extract type info: bytes size
122
+ const size = parseInt(bytesMatch[1]);
123
+ if (size === 0 || size > 32)
124
+ throw new Error(`Unsupported bytes size: ${size}`);
125
+ // Convert hex to bytes
126
+ const bytes = etc.hexToBytes(cleanHex(value));
127
+ if (bytes.length !== size)
128
+ throw new Error(`Invalid length for ${type}: expected ${size}, got ${bytes.length}`);
129
+ // Pad to 32 bytes
130
+ const padded = new Uint8Array(32);
131
+ padded.set(bytes, 0);
132
+ return padded;
133
+ }
134
+ throw new Error(`Unsupported type: ${type}`);
135
+ }
136
+ function cleanHex(hex) {
137
+ return hex.startsWith("0x") ? hex.slice(2) : hex;
138
+ }
139
+ /** Validates if a string is a valid secp256k1 private key. */
140
+ export function isValidPrivateKey(privateKey) {
141
+ if (typeof privateKey !== "string")
142
+ return false;
143
+ return utils.isValidPrivateKey(cleanHex(privateKey));
144
+ }
@@ -1,4 +1,4 @@
1
- import type { Hex } from "../base.js";
1
+ import type { Hex } from "../../base.js";
2
2
  /** Abstract interface for a [viem wallet](https://viem.sh/docs/clients/wallet). */
3
3
  export interface AbstractViemWalletClient {
4
4
  signTypedData(params: {
@@ -20,4 +20,4 @@ export interface AbstractViemWalletClient {
20
20
  }
21
21
  /** Checks if the given value is an abstract viem wallet. */
22
22
  export declare function isAbstractViemWalletClient(client: unknown): client is AbstractViemWalletClient;
23
- //# sourceMappingURL=_viem.d.ts.map
23
+ //# sourceMappingURL=viem.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"viem.d.ts","sourceRoot":"","sources":["../../../../src/src/signing/_signTypedData/viem.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AAEzC,mFAAmF;AACnF,MAAM,WAAW,wBAAwB;IACrC,aAAa,CACT,MAAM,EAAE;QACJ,MAAM,EAAE;YACJ,IAAI,EAAE,MAAM,CAAC;YACb,OAAO,EAAE,MAAM,CAAC;YAChB,OAAO,EAAE,MAAM,CAAC;YAChB,iBAAiB,EAAE,GAAG,CAAC;SAC1B,CAAC;QACF,KAAK,EAAE;YACH,CAAC,GAAG,EAAE,MAAM,GAAG;gBACX,IAAI,EAAE,MAAM,CAAC;gBACb,IAAI,EAAE,MAAM,CAAC;aAChB,EAAE,CAAC;SACP,CAAC;QACF,WAAW,EAAE,MAAM,CAAC;QACpB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;KACpC,EACD,OAAO,CAAC,EAAE,OAAO,GAClB,OAAO,CAAC,GAAG,CAAC,CAAC;CACnB;AAED,4DAA4D;AAC5D,wBAAgB,0BAA0B,CAAC,MAAM,EAAE,OAAO,GAAG,MAAM,IAAI,wBAAwB,CAI9F"}