oneie 5.8.0 → 5.9.0

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 (270) hide show
  1. package/README.md +114 -6
  2. package/dist/package.json +37 -11
  3. package/dist/src/age-1k8hs4ec.js +1 -0
  4. package/dist/src/client-n6fpnd9f.js +1 -0
  5. package/dist/src/evm-tx-cqhm9rtt.js +1 -0
  6. package/dist/src/hl-run-0pv1e0p2.js +1 -0
  7. package/dist/src/index-f5vhzspa.js +12 -0
  8. package/dist/src/index-h3nrt8bx.js +4 -0
  9. package/dist/src/index-st6k9vhc.js +2062 -0
  10. package/dist/src/index.js +1122 -134
  11. package/dist/src/message-key-yczrxszr.js +1 -0
  12. package/dist/src/message-lock-thr851d5.js +5 -0
  13. package/dist/src/sweep-order-jrq2hkye.js +1 -0
  14. package/dist/src/sweep-runner-jftw9em7.js +1 -0
  15. package/package.json +37 -11
  16. package/dist/src/agent.d.ts +0 -75
  17. package/dist/src/agent.js +0 -1334
  18. package/dist/src/agentverse.d.ts +0 -26
  19. package/dist/src/agentverse.js +0 -171
  20. package/dist/src/args.d.ts +0 -9
  21. package/dist/src/args.js +0 -61
  22. package/dist/src/auth.d.ts +0 -6
  23. package/dist/src/auth.js +0 -121
  24. package/dist/src/balances.d.ts +0 -89
  25. package/dist/src/balances.js +0 -202
  26. package/dist/src/banner.d.ts +0 -1
  27. package/dist/src/banner.js +0 -17
  28. package/dist/src/broadcast.d.ts +0 -8
  29. package/dist/src/broadcast.js +0 -175
  30. package/dist/src/catalog.d.ts +0 -12
  31. package/dist/src/catalog.js +0 -76
  32. package/dist/src/ceiling.d.ts +0 -36
  33. package/dist/src/ceiling.js +0 -189
  34. package/dist/src/chat.d.ts +0 -2
  35. package/dist/src/chat.js +0 -92
  36. package/dist/src/check.d.ts +0 -11
  37. package/dist/src/check.js +0 -53
  38. package/dist/src/client.d.ts +0 -5
  39. package/dist/src/client.js +0 -157
  40. package/dist/src/compiler.d.ts +0 -36
  41. package/dist/src/compiler.js +0 -366
  42. package/dist/src/config.d.ts +0 -24
  43. package/dist/src/config.js +0 -70
  44. package/dist/src/connect.d.ts +0 -2
  45. package/dist/src/connect.js +0 -64
  46. package/dist/src/coordinate.d.ts +0 -3
  47. package/dist/src/coordinate.js +0 -58
  48. package/dist/src/create.d.ts +0 -2
  49. package/dist/src/create.js +0 -113
  50. package/dist/src/credits.d.ts +0 -29
  51. package/dist/src/credits.js +0 -88
  52. package/dist/src/deploy.d.ts +0 -2
  53. package/dist/src/deploy.js +0 -19
  54. package/dist/src/dev.d.ts +0 -2
  55. package/dist/src/dev.js +0 -75
  56. package/dist/src/device-flow.d.ts +0 -57
  57. package/dist/src/device-flow.js +0 -173
  58. package/dist/src/doctor.d.ts +0 -26
  59. package/dist/src/doctor.js +0 -146
  60. package/dist/src/draw.d.ts +0 -18
  61. package/dist/src/draw.js +0 -156
  62. package/dist/src/endpoint.d.ts +0 -2
  63. package/dist/src/endpoint.js +0 -250
  64. package/dist/src/env.d.ts +0 -3
  65. package/dist/src/env.js +0 -37
  66. package/dist/src/eval.d.ts +0 -2
  67. package/dist/src/eval.js +0 -43
  68. package/dist/src/fn.d.ts +0 -2
  69. package/dist/src/fn.js +0 -70
  70. package/dist/src/group.d.ts +0 -2
  71. package/dist/src/group.js +0 -117
  72. package/dist/src/hl-run.d.ts +0 -119
  73. package/dist/src/hl-run.js +0 -480
  74. package/dist/src/hl.d.ts +0 -17
  75. package/dist/src/hl.js +0 -148
  76. package/dist/src/index.d.ts +0 -2
  77. package/dist/src/init.d.ts +0 -76
  78. package/dist/src/init.js +0 -278
  79. package/dist/src/join.d.ts +0 -11
  80. package/dist/src/join.js +0 -297
  81. package/dist/src/key-publish.d.ts +0 -40
  82. package/dist/src/key-publish.js +0 -232
  83. package/dist/src/key-seal.d.ts +0 -21
  84. package/dist/src/key-seal.js +0 -142
  85. package/dist/src/key-sweep.d.ts +0 -93
  86. package/dist/src/key-sweep.js +0 -270
  87. package/dist/src/key.d.ts +0 -26
  88. package/dist/src/key.js +0 -338
  89. package/dist/src/lib/age-plugin.d.ts +0 -51
  90. package/dist/src/lib/age-plugin.js +0 -130
  91. package/dist/src/lib/agent-env.d.ts +0 -12
  92. package/dist/src/lib/agent-env.js +0 -48
  93. package/dist/src/lib/api-path.d.ts +0 -2
  94. package/dist/src/lib/api-path.js +0 -40
  95. package/dist/src/lib/asker.d.ts +0 -34
  96. package/dist/src/lib/asker.js +0 -126
  97. package/dist/src/lib/check-words.d.ts +0 -57
  98. package/dist/src/lib/check-words.js +0 -144
  99. package/dist/src/lib/client.d.ts +0 -20
  100. package/dist/src/lib/client.js +0 -71
  101. package/dist/src/lib/env-sealed.d.ts +0 -53
  102. package/dist/src/lib/env-sealed.js +0 -184
  103. package/dist/src/lib/flow-tag.d.ts +0 -86
  104. package/dist/src/lib/flow-tag.js +0 -230
  105. package/dist/src/lib/hl-core/actions.d.ts +0 -99
  106. package/dist/src/lib/hl-core/actions.js +0 -69
  107. package/dist/src/lib/hl-core/eip712.d.ts +0 -33
  108. package/dist/src/lib/hl-core/eip712.js +0 -107
  109. package/dist/src/lib/hl-core/errors.d.ts +0 -10
  110. package/dist/src/lib/hl-core/errors.js +0 -15
  111. package/dist/src/lib/hl-core/exchange.d.ts +0 -24
  112. package/dist/src/lib/hl-core/exchange.js +0 -47
  113. package/dist/src/lib/hl-core/index.d.ts +0 -13
  114. package/dist/src/lib/hl-core/index.js +0 -14
  115. package/dist/src/lib/hl-core/meta.d.ts +0 -57
  116. package/dist/src/lib/hl-core/meta.js +0 -110
  117. package/dist/src/lib/hl-core/msgpack.d.ts +0 -18
  118. package/dist/src/lib/hl-core/msgpack.js +0 -136
  119. package/dist/src/lib/hl-core/net.d.ts +0 -2
  120. package/dist/src/lib/hl-core/net.js +0 -7
  121. package/dist/src/lib/hl-core/signing.d.ts +0 -103
  122. package/dist/src/lib/hl-core/signing.js +0 -295
  123. package/dist/src/lib/hl-core/wire.d.ts +0 -34
  124. package/dist/src/lib/hl-core/wire.js +0 -81
  125. package/dist/src/lib/invoked-as.d.ts +0 -2
  126. package/dist/src/lib/invoked-as.js +0 -24
  127. package/dist/src/lib/journey-words.d.ts +0 -84
  128. package/dist/src/lib/journey-words.js +0 -363
  129. package/dist/src/lib/journey.d.ts +0 -150
  130. package/dist/src/lib/journey.js +0 -264
  131. package/dist/src/lib/key-receipt.d.ts +0 -48
  132. package/dist/src/lib/key-receipt.js +0 -116
  133. package/dist/src/lib/key-source.d.ts +0 -9
  134. package/dist/src/lib/key-source.js +0 -33
  135. package/dist/src/lib/keyfile.d.ts +0 -136
  136. package/dist/src/lib/keyfile.js +0 -397
  137. package/dist/src/lib/launch-claude.d.ts +0 -5
  138. package/dist/src/lib/launch-claude.js +0 -45
  139. package/dist/src/lib/lock-lookup.d.ts +0 -40
  140. package/dist/src/lib/lock-lookup.js +0 -92
  141. package/dist/src/lib/message-seal.d.ts +0 -63
  142. package/dist/src/lib/message-seal.js +0 -150
  143. package/dist/src/lib/net-choice.d.ts +0 -28
  144. package/dist/src/lib/net-choice.js +0 -72
  145. package/dist/src/lib/network.d.ts +0 -22
  146. package/dist/src/lib/network.js +0 -50
  147. package/dist/src/lib/next-words.d.ts +0 -105
  148. package/dist/src/lib/next-words.js +0 -298
  149. package/dist/src/lib/paths.d.ts +0 -41
  150. package/dist/src/lib/paths.js +0 -91
  151. package/dist/src/lib/plan-draw.d.ts +0 -56
  152. package/dist/src/lib/plan-draw.js +0 -219
  153. package/dist/src/lib/plan-live.d.ts +0 -20
  154. package/dist/src/lib/plan-live.js +0 -192
  155. package/dist/src/lib/qr.d.ts +0 -21
  156. package/dist/src/lib/qr.js +0 -402
  157. package/dist/src/lib/roster.d.ts +0 -20
  158. package/dist/src/lib/roster.js +0 -79
  159. package/dist/src/lib/sale-card.d.ts +0 -117
  160. package/dist/src/lib/sale-card.js +0 -261
  161. package/dist/src/lib/shop-init.d.ts +0 -62
  162. package/dist/src/lib/shop-init.js +0 -63
  163. package/dist/src/lib/sui-grpc-send.d.ts +0 -90
  164. package/dist/src/lib/sui-grpc-send.js +0 -128
  165. package/dist/src/lib/swap-core.d.ts +0 -163
  166. package/dist/src/lib/swap-core.js +0 -405
  167. package/dist/src/lib/tasks-digest.d.ts +0 -66
  168. package/dist/src/lib/tasks-digest.js +0 -200
  169. package/dist/src/lib/tasks-graph.d.ts +0 -79
  170. package/dist/src/lib/tasks-graph.js +0 -463
  171. package/dist/src/lib/tasks-lens.d.ts +0 -31
  172. package/dist/src/lib/tasks-lens.js +0 -47
  173. package/dist/src/lib/tasks-next.d.ts +0 -25
  174. package/dist/src/lib/tasks-next.js +0 -103
  175. package/dist/src/lib/tasks-prove.d.ts +0 -15
  176. package/dist/src/lib/tasks-prove.js +0 -68
  177. package/dist/src/lib/tasks-route.d.ts +0 -29
  178. package/dist/src/lib/tasks-route.js +0 -151
  179. package/dist/src/lib/tasks-score.d.ts +0 -36
  180. package/dist/src/lib/tasks-score.js +0 -152
  181. package/dist/src/lib/tasks-workspace.d.ts +0 -18
  182. package/dist/src/lib/tasks-workspace.js +0 -73
  183. package/dist/src/lib/timed-fetch.d.ts +0 -33
  184. package/dist/src/lib/timed-fetch.js +0 -59
  185. package/dist/src/lib/vault-read.d.ts +0 -24
  186. package/dist/src/lib/vault-read.js +0 -77
  187. package/dist/src/lib/vaultfile.d.ts +0 -103
  188. package/dist/src/lib/vaultfile.js +0 -249
  189. package/dist/src/lib/wallet-money.d.ts +0 -222
  190. package/dist/src/lib/wallet-money.js +0 -578
  191. package/dist/src/lib/wallet-request.d.ts +0 -50
  192. package/dist/src/lib/wallet-request.js +0 -86
  193. package/dist/src/links.d.ts +0 -5
  194. package/dist/src/links.js +0 -45
  195. package/dist/src/media.d.ts +0 -29
  196. package/dist/src/media.js +0 -487
  197. package/dist/src/message-receipt.d.ts +0 -25
  198. package/dist/src/message-receipt.js +0 -71
  199. package/dist/src/message.d.ts +0 -13
  200. package/dist/src/message.js +0 -92
  201. package/dist/src/move.d.ts +0 -36
  202. package/dist/src/move.js +0 -152
  203. package/dist/src/network-cmd.d.ts +0 -17
  204. package/dist/src/network-cmd.js +0 -74
  205. package/dist/src/next.d.ts +0 -12
  206. package/dist/src/next.js +0 -67
  207. package/dist/src/onboard.d.ts +0 -16
  208. package/dist/src/onboard.js +0 -149
  209. package/dist/src/plugin.d.ts +0 -2
  210. package/dist/src/plugin.js +0 -193
  211. package/dist/src/push.d.ts +0 -2
  212. package/dist/src/push.js +0 -115
  213. package/dist/src/render.d.ts +0 -21
  214. package/dist/src/render.js +0 -32
  215. package/dist/src/secrets-device.d.ts +0 -32
  216. package/dist/src/secrets-device.js +0 -127
  217. package/dist/src/secrets-give.d.ts +0 -125
  218. package/dist/src/secrets-give.js +0 -236
  219. package/dist/src/secrets-list.d.ts +0 -27
  220. package/dist/src/secrets-list.js +0 -84
  221. package/dist/src/secrets-run.d.ts +0 -31
  222. package/dist/src/secrets-run.js +0 -182
  223. package/dist/src/secrets.d.ts +0 -33
  224. package/dist/src/secrets.js +0 -200
  225. package/dist/src/setup.d.ts +0 -6
  226. package/dist/src/setup.js +0 -127
  227. package/dist/src/ship.d.ts +0 -2
  228. package/dist/src/ship.js +0 -18
  229. package/dist/src/shop-buy.d.ts +0 -16
  230. package/dist/src/shop-buy.js +0 -101
  231. package/dist/src/shop.d.ts +0 -10
  232. package/dist/src/shop.js +0 -112
  233. package/dist/src/skill-parser.d.ts +0 -14
  234. package/dist/src/skill-parser.js +0 -113
  235. package/dist/src/skill.d.ts +0 -2
  236. package/dist/src/skill.js +0 -493
  237. package/dist/src/slug.d.ts +0 -2
  238. package/dist/src/slug.js +0 -6
  239. package/dist/src/social.d.ts +0 -2
  240. package/dist/src/social.js +0 -106
  241. package/dist/src/staff.d.ts +0 -2
  242. package/dist/src/staff.js +0 -104
  243. package/dist/src/start.d.ts +0 -27
  244. package/dist/src/start.js +0 -225
  245. package/dist/src/status.d.ts +0 -2
  246. package/dist/src/status.js +0 -52
  247. package/dist/src/substrate.d.ts +0 -2
  248. package/dist/src/substrate.js +0 -258
  249. package/dist/src/swap.d.ts +0 -93
  250. package/dist/src/swap.js +0 -622
  251. package/dist/src/tasks.d.ts +0 -2
  252. package/dist/src/tasks.js +0 -743
  253. package/dist/src/templates.d.ts +0 -1
  254. package/dist/src/templates.js +0 -213
  255. package/dist/src/thread.d.ts +0 -2
  256. package/dist/src/thread.js +0 -52
  257. package/dist/src/trade.d.ts +0 -2
  258. package/dist/src/trade.js +0 -91
  259. package/dist/src/trail.d.ts +0 -2
  260. package/dist/src/trail.js +0 -41
  261. package/dist/src/validate.d.ts +0 -13
  262. package/dist/src/validate.js +0 -35
  263. package/dist/src/wallet-money.d.ts +0 -158
  264. package/dist/src/wallet-money.js +0 -664
  265. package/dist/src/wallet.d.ts +0 -169
  266. package/dist/src/wallet.js +0 -973
  267. package/dist/src/workflow.d.ts +0 -2
  268. package/dist/src/workflow.js +0 -169
  269. package/dist/src/write.d.ts +0 -43
  270. package/dist/src/write.js +0 -180
@@ -1,99 +0,0 @@
1
- /**
2
- * hyperliquid/actions — builders for the four actions ONE prepares (text/hyperliquid-plan.md H2):
3
- *
4
- * L1 (msgpack-hashed, phantom-agent signed) order · cancel
5
- * user-signed (own EIP-712 domain) usdClassTransfer · withdraw3
6
- *
7
- * KEY ORDER IS PART OF THE HASH for L1 actions: msgpack keeps insertion order, so each literal
8
- * below is written in exactly the python SDK's order (`order_request_to_order_wire`,
9
- * `order_wires_to_order_action`, `bulk_cancel`). Do not "tidy" them.
10
- *
11
- * Every builder validates against the asset's tick rules and throws `HlRefusal` before an action
12
- * exists. Nothing here reads the network or the clock: nonce and mid come in as arguments.
13
- */
14
- import { type AssetInfo } from './meta.js';
15
- export type Tif = 'Gtc' | 'Ioc' | 'Alo';
16
- export interface OrderWire {
17
- a: number;
18
- b: boolean;
19
- p: string;
20
- s: string;
21
- r: boolean;
22
- t: {
23
- limit: {
24
- tif: Tif;
25
- };
26
- };
27
- c?: string;
28
- }
29
- export interface OrderAction {
30
- type: 'order';
31
- orders: OrderWire[];
32
- grouping: 'na';
33
- }
34
- export interface CancelAction {
35
- type: 'cancel';
36
- cancels: Array<{
37
- a: number;
38
- o: number;
39
- }>;
40
- }
41
- export interface UsdClassTransferAction {
42
- type: 'usdClassTransfer';
43
- amount: string;
44
- toPerp: boolean;
45
- nonce: number;
46
- }
47
- export interface Withdraw3Action {
48
- type: 'withdraw3';
49
- destination: string;
50
- amount: string;
51
- time: number;
52
- }
53
- export type L1Action = OrderAction | CancelAction;
54
- export type UserAction = UsdClassTransferAction | Withdraw3Action;
55
- export type HlAction = L1Action | UserAction;
56
- export interface LimitOrderInput {
57
- asset: AssetInfo;
58
- isBuy: boolean;
59
- /** Decimal string, in the asset's units. */
60
- sz: string;
61
- /** Decimal string. */
62
- px: string;
63
- tif?: Tif;
64
- reduceOnly?: boolean;
65
- /** 16-byte client order id, 0x + 32 hex. */
66
- cloid?: string;
67
- }
68
- export declare function orderWire(o: LimitOrderInput): OrderWire;
69
- export declare function buildOrder(o: LimitOrderInput): OrderAction;
70
- export interface MarketOrderInput {
71
- asset: AssetInfo;
72
- isBuy: boolean;
73
- sz: string;
74
- /** The mid the caller read (allMids). The core never fetches it. */
75
- mid: string;
76
- /** Default 0.05, the python SDK's DEFAULT_SLIPPAGE. */
77
- slippage?: number;
78
- reduceOnly?: boolean;
79
- cloid?: string;
80
- }
81
- /** A market order is an aggressive IOC limit (python `market_open` / `market_close`). */
82
- export declare function buildMarketOrder(o: MarketOrderInput): OrderAction;
83
- /** A cancel needs only the asset INDEX; pass the AssetInfo from the table when you have it. */
84
- export declare function buildCancel(o: {
85
- asset: Pick<AssetInfo, 'asset'>;
86
- oid: number;
87
- }): CancelAction;
88
- /** Move USDC between the spot and perps balances of the SAME account (toPerp: spot → perps). */
89
- export declare function buildUsdClassTransfer(o: {
90
- amount: string;
91
- toPerp: boolean;
92
- nonce: number;
93
- }): UsdClassTransferAction;
94
- /** Withdraw USDC from the PERPS balance to an address on Arbitrum. */
95
- export declare function buildWithdraw3(o: {
96
- destination: string;
97
- amount: string;
98
- time: number;
99
- }): Withdraw3Action;
@@ -1,69 +0,0 @@
1
- // VENDORED from one.ie/web/src/lib/hyperliquid/actions.ts by packages/cli/scripts/hl-core-vendor.mjs — do not edit; tests/hl-core-parity.test.ts compares bytes.
2
- /**
3
- * hyperliquid/actions — builders for the four actions ONE prepares (text/hyperliquid-plan.md H2):
4
- *
5
- * L1 (msgpack-hashed, phantom-agent signed) order · cancel
6
- * user-signed (own EIP-712 domain) usdClassTransfer · withdraw3
7
- *
8
- * KEY ORDER IS PART OF THE HASH for L1 actions: msgpack keeps insertion order, so each literal
9
- * below is written in exactly the python SDK's order (`order_request_to_order_wire`,
10
- * `order_wires_to_order_action`, `bulk_cancel`). Do not "tidy" them.
11
- *
12
- * Every builder validates against the asset's tick rules and throws `HlRefusal` before an action
13
- * exists. Nothing here reads the network or the clock: nonce and mid come in as arguments.
14
- */
15
- import { HlRefusal } from './errors.js';
16
- import { BUILDER_DEX_OFFSET } from './meta.js';
17
- import { checkPrice, checkSize, checkUsd, marketPrice } from './wire.js';
18
- const TIFS = ['Gtc', 'Ioc', 'Alo'];
19
- const CLOID = /^0x[0-9a-fA-F]{32}$/;
20
- const ADDRESS = /^0x[0-9a-fA-F]{40}$/;
21
- export function orderWire(o) {
22
- const tif = o.tif ?? 'Gtc';
23
- if (!TIFS.includes(tif))
24
- throw new HlRefusal('bad_tif', String(tif));
25
- if (o.asset.delisted)
26
- throw new HlRefusal('asset_delisted', o.asset.coin);
27
- const s = checkSize(o.sz, o.asset.szDecimals);
28
- const p = checkPrice(o.px, o.asset.szDecimals, o.asset.kind);
29
- if (o.cloid !== undefined && !CLOID.test(o.cloid))
30
- throw new HlRefusal('bad_cloid', o.cloid);
31
- const w = { a: o.asset.asset, b: o.isBuy, p, s, r: o.reduceOnly ?? false, t: { limit: { tif } } };
32
- if (o.cloid !== undefined)
33
- w.c = o.cloid.toLowerCase();
34
- return w;
35
- }
36
- export function buildOrder(o) {
37
- return { type: 'order', orders: [orderWire(o)], grouping: 'na' };
38
- }
39
- /** A market order is an aggressive IOC limit (python `market_open` / `market_close`). */
40
- export function buildMarketOrder(o) {
41
- const px = marketPrice(o.mid, o.isBuy, o.slippage ?? 0.05, o.asset.szDecimals, o.asset.kind);
42
- return buildOrder({ asset: o.asset, isBuy: o.isBuy, sz: o.sz, px, tif: 'Ioc', reduceOnly: o.reduceOnly, cloid: o.cloid });
43
- }
44
- /** A cancel needs only the asset INDEX; pass the AssetInfo from the table when you have it. */
45
- export function buildCancel(o) {
46
- const a = o.asset.asset;
47
- if (!Number.isSafeInteger(a) || a < 0)
48
- throw new HlRefusal('unknown_asset', String(a));
49
- if (a >= BUILDER_DEX_OFFSET)
50
- throw new HlRefusal('builder_dex_unsupported', String(a));
51
- if (!Number.isSafeInteger(o.oid) || o.oid < 0)
52
- throw new HlRefusal('bad_oid', String(o.oid));
53
- return { type: 'cancel', cancels: [{ a, o: o.oid }] };
54
- }
55
- function checkNonce(n) {
56
- if (!Number.isSafeInteger(n) || n <= 0)
57
- throw new HlRefusal('nonce_required', String(n));
58
- return n;
59
- }
60
- /** Move USDC between the spot and perps balances of the SAME account (toPerp: spot → perps). */
61
- export function buildUsdClassTransfer(o) {
62
- return { type: 'usdClassTransfer', amount: checkUsd(o.amount), toPerp: o.toPerp, nonce: checkNonce(o.nonce) };
63
- }
64
- /** Withdraw USDC from the PERPS balance to an address on Arbitrum. */
65
- export function buildWithdraw3(o) {
66
- if (!ADDRESS.test(o.destination))
67
- throw new HlRefusal('bad_address', o.destination);
68
- return { type: 'withdraw3', destination: o.destination.toLowerCase(), amount: checkUsd(o.amount), time: checkNonce(o.time) };
69
- }
@@ -1,33 +0,0 @@
1
- /**
2
- * hyperliquid/eip712 — the EIP-712 digest, in pure keccak, for the flat struct types Hyperliquid
3
- * signs (text/hyperliquid-plan.md § The signer seam). Only the field types Hyperliquid uses are
4
- * encoded: string · bytes32 · address · bool · uint64 · uint256. Any other type is refused,
5
- * never guessed — a wrong encoding is a signature over a different message.
6
- *
7
- * Only the DECLARED fields are encoded. A user-signed action also carries `type` and
8
- * `signatureChainId`; those are on the wire, not in the struct, exactly as eth_account ignores them.
9
- */
10
- export interface TypedField {
11
- name: string;
12
- type: 'string' | 'bytes32' | 'address' | 'bool' | 'uint64' | 'uint256';
13
- }
14
- export interface Eip712Domain {
15
- name: string;
16
- version: string;
17
- chainId: number;
18
- verifyingContract: `0x${string}`;
19
- }
20
- /** The full eth_signTypedData_v4 shape: `types` INCLUDES EIP712Domain, `primaryType` is named. */
21
- export interface TypedData {
22
- domain: Eip712Domain;
23
- types: Record<string, TypedField[]>;
24
- primaryType: string;
25
- message: Record<string, unknown>;
26
- }
27
- export declare const EIP712_DOMAIN_FIELDS: TypedField[];
28
- export declare const toHex: (b: Uint8Array) => string;
29
- export declare const hex0x: (b: Uint8Array) => `0x${string}`;
30
- export declare function hexToBytes(h: string): Uint8Array;
31
- export declare const encodeType: (name: string, fields: TypedField[]) => string;
32
- export declare function hashStruct(name: string, fields: TypedField[], message: Record<string, unknown>): Uint8Array;
33
- export declare function typedDataDigest(td: TypedData): Uint8Array;
@@ -1,107 +0,0 @@
1
- // VENDORED from one.ie/web/src/lib/hyperliquid/eip712.ts by packages/cli/scripts/hl-core-vendor.mjs — do not edit; tests/hl-core-parity.test.ts compares bytes.
2
- /**
3
- * hyperliquid/eip712 — the EIP-712 digest, in pure keccak, for the flat struct types Hyperliquid
4
- * signs (text/hyperliquid-plan.md § The signer seam). Only the field types Hyperliquid uses are
5
- * encoded: string · bytes32 · address · bool · uint64 · uint256. Any other type is refused,
6
- * never guessed — a wrong encoding is a signature over a different message.
7
- *
8
- * Only the DECLARED fields are encoded. A user-signed action also carries `type` and
9
- * `signatureChainId`; those are on the wire, not in the struct, exactly as eth_account ignores them.
10
- */
11
- import { keccak_256 } from '@noble/hashes/sha3.js';
12
- import { HlRefusal } from './errors.js';
13
- export const EIP712_DOMAIN_FIELDS = [
14
- { name: 'name', type: 'string' },
15
- { name: 'version', type: 'string' },
16
- { name: 'chainId', type: 'uint256' },
17
- { name: 'verifyingContract', type: 'address' },
18
- ];
19
- export const toHex = (b) => Array.from(b, (x) => x.toString(16).padStart(2, '0')).join('');
20
- export const hex0x = (b) => `0x${toHex(b)}`;
21
- export function hexToBytes(h) {
22
- const s = h.startsWith('0x') ? h.slice(2) : h;
23
- if (s.length % 2 !== 0 || !/^[0-9a-fA-F]*$/.test(s))
24
- throw new HlRefusal('bad_hex', h);
25
- const out = new Uint8Array(s.length / 2);
26
- for (let i = 0; i < out.length; i++)
27
- out[i] = parseInt(s.slice(2 * i, 2 * i + 2), 16);
28
- return out;
29
- }
30
- function word(n) {
31
- if (n < 0n || n >= 1n << 256n)
32
- throw new HlRefusal('eip712_range', String(n));
33
- const out = new Uint8Array(32);
34
- for (let i = 31; i >= 0; i--) {
35
- out[i] = Number(n & 0xffn);
36
- n >>= 8n;
37
- }
38
- return out;
39
- }
40
- function toUint(v, bits, at) {
41
- let n;
42
- if (typeof v === 'bigint')
43
- n = v;
44
- else if (typeof v === 'number' && Number.isSafeInteger(v))
45
- n = BigInt(v);
46
- else if (typeof v === 'string' && /^(0x[0-9a-fA-F]+|\d+)$/.test(v))
47
- n = BigInt(v);
48
- else
49
- throw new HlRefusal('eip712_value', `${at} not a uint`);
50
- if (n < 0n || n >= 1n << BigInt(bits))
51
- throw new HlRefusal('eip712_range', at);
52
- return n;
53
- }
54
- function encodeValue(f, v) {
55
- switch (f.type) {
56
- case 'string':
57
- if (typeof v !== 'string')
58
- throw new HlRefusal('eip712_value', `${f.name} not a string`);
59
- return keccak_256(new TextEncoder().encode(v));
60
- case 'bytes32': {
61
- const b = v instanceof Uint8Array ? v : typeof v === 'string' ? hexToBytes(v) : null;
62
- if (!b || b.length !== 32)
63
- throw new HlRefusal('eip712_value', `${f.name} not bytes32`);
64
- return b;
65
- }
66
- case 'address': {
67
- if (typeof v !== 'string' || !/^0x[0-9a-fA-F]{40}$/.test(v))
68
- throw new HlRefusal('eip712_value', `${f.name} not an address`);
69
- return word(BigInt(v));
70
- }
71
- case 'bool':
72
- if (typeof v !== 'boolean')
73
- throw new HlRefusal('eip712_value', `${f.name} not a bool`);
74
- return word(v ? 1n : 0n);
75
- case 'uint64':
76
- return word(toUint(v, 64, f.name));
77
- case 'uint256':
78
- return word(toUint(v, 256, f.name));
79
- default:
80
- throw new HlRefusal('eip712_type', String(f.type));
81
- }
82
- }
83
- export const encodeType = (name, fields) => `${name}(${fields.map((f) => `${f.type} ${f.name}`).join(',')})`;
84
- export function hashStruct(name, fields, message) {
85
- const parts = [keccak_256(new TextEncoder().encode(encodeType(name, fields)))];
86
- for (const f of fields) {
87
- if (!(f.name in message))
88
- throw new HlRefusal('eip712_missing', f.name);
89
- parts.push(encodeValue(f, message[f.name]));
90
- }
91
- const buf = new Uint8Array(parts.length * 32);
92
- parts.forEach((p, i) => buf.set(p, i * 32));
93
- return keccak_256(buf);
94
- }
95
- export function typedDataDigest(td) {
96
- const fields = td.types[td.primaryType];
97
- if (!fields)
98
- throw new HlRefusal('eip712_type', td.primaryType);
99
- const domainSep = hashStruct('EIP712Domain', EIP712_DOMAIN_FIELDS, td.domain);
100
- const body = hashStruct(td.primaryType, fields, td.message);
101
- const buf = new Uint8Array(66);
102
- buf[0] = 0x19;
103
- buf[1] = 0x01;
104
- buf.set(domainSep, 2);
105
- buf.set(body, 34);
106
- return keccak_256(buf);
107
- }
@@ -1,10 +0,0 @@
1
- /**
2
- * hyperliquid/errors — every refusal in the core is a named code, thrown BEFORE any typed data
3
- * exists or any signer is asked. Callers (CLI, page, receiver) catch `HlRefusal` and show the code.
4
- */
5
- export type HlRefusalCode = 'bad_hex' | 'bad_address' | 'bad_decimal' | 'size_zero' | 'size_too_precise' | 'price_zero' | 'price_sig_figs' | 'price_too_precise' | 'amount_zero' | 'amount_too_precise' | 'bad_slippage' | 'bad_cloid' | 'bad_oid' | 'bad_tif' | 'unknown_asset' | 'asset_delisted' | 'asset_mismatch' | 'builder_dex_unsupported' | 'meta_required' | 'nonce_required' | 'nonce_mismatch' | 'vault_unsupported' | 'expires_unsupported' | 'unsupported_action' | 'signer_mismatch' | 'bad_signature' | 'eip712_type' | 'eip712_value' | 'eip712_range' | 'eip712_missing';
6
- export declare class HlRefusal extends Error {
7
- code: HlRefusalCode;
8
- detail?: string | undefined;
9
- constructor(code: HlRefusalCode, detail?: string | undefined);
10
- }
@@ -1,15 +0,0 @@
1
- // VENDORED from one.ie/web/src/lib/hyperliquid/errors.ts by packages/cli/scripts/hl-core-vendor.mjs — do not edit; tests/hl-core-parity.test.ts compares bytes.
2
- /**
3
- * hyperliquid/errors — every refusal in the core is a named code, thrown BEFORE any typed data
4
- * exists or any signer is asked. Callers (CLI, page, receiver) catch `HlRefusal` and show the code.
5
- */
6
- export class HlRefusal extends Error {
7
- code;
8
- detail;
9
- constructor(code, detail) {
10
- super(detail ? `${code}: ${detail}` : code);
11
- this.code = code;
12
- this.detail = detail;
13
- this.name = 'HlRefusal';
14
- }
15
- }
@@ -1,24 +0,0 @@
1
- /**
2
- * hyperliquid/exchange — the ONE function that POSTs to /exchange (text/hyperliquid-plan.md H7).
3
- * It takes an already-signed request; it cannot sign and it never builds an action. The server
4
- * never calls it (R19 / H8): it runs in the browser or the CLI, beside the key that signed.
5
- *
6
- * Hyperliquid answers 200 for refusals too: `{status:'err', response:'<reason>'}`, and an order's
7
- * per-order `statuses[i].error`. Both come back `ok:false` with the exchange's own words.
8
- */
9
- import type { HlNet } from './net.js';
10
- import { type ExchangeRequest } from './signing.js';
11
- export type ExchangeResult = {
12
- ok: true;
13
- response: unknown;
14
- } | {
15
- ok: false;
16
- error: 'exchange_refused' | 'exchange_unavailable';
17
- detail: string;
18
- response?: unknown;
19
- };
20
- export declare function readExchangeAnswer(body: unknown): ExchangeResult;
21
- export declare function postExchange(request: ExchangeRequest, net: HlNet, o?: {
22
- fetchImpl?: typeof fetch;
23
- timeoutMs?: number;
24
- }): Promise<ExchangeResult>;
@@ -1,47 +0,0 @@
1
- // VENDORED from one.ie/web/src/lib/hyperliquid/exchange.ts by packages/cli/scripts/hl-core-vendor.mjs — do not edit; tests/hl-core-parity.test.ts compares bytes.
2
- /**
3
- * hyperliquid/exchange — the ONE function that POSTs to /exchange (text/hyperliquid-plan.md H7).
4
- * It takes an already-signed request; it cannot sign and it never builds an action. The server
5
- * never calls it (R19 / H8): it runs in the browser or the CLI, beside the key that signed.
6
- *
7
- * Hyperliquid answers 200 for refusals too: `{status:'err', response:'<reason>'}`, and an order's
8
- * per-order `statuses[i].error`. Both come back `ok:false` with the exchange's own words.
9
- */
10
- import { HL_EXCHANGE } from './signing.js';
11
- const isObj = (v) => typeof v === 'object' && v !== null && !Array.isArray(v);
12
- export function readExchangeAnswer(body) {
13
- if (!isObj(body))
14
- return { ok: false, error: 'exchange_unavailable', detail: 'not json' };
15
- if (body['status'] !== 'ok') {
16
- return { ok: false, error: 'exchange_refused', detail: typeof body['response'] === 'string' ? body['response'] : 'err', response: body['response'] };
17
- }
18
- const resp = body['response'];
19
- const statuses = isObj(resp) && isObj(resp['data']) && Array.isArray(resp['data']['statuses']) ? resp['data']['statuses'] : [];
20
- const firstErr = statuses.find((s) => isObj(s) && typeof s['error'] === 'string');
21
- if (firstErr)
22
- return { ok: false, error: 'exchange_refused', detail: String(firstErr['error']), response: resp };
23
- return { ok: true, response: resp };
24
- }
25
- export async function postExchange(request, net, o = {}) {
26
- const f = o.fetchImpl ?? fetch;
27
- try {
28
- const res = await f(HL_EXCHANGE[net], {
29
- method: 'POST',
30
- headers: { 'content-type': 'application/json' },
31
- body: JSON.stringify(request),
32
- signal: AbortSignal.timeout(o.timeoutMs ?? 10_000),
33
- });
34
- const text = await res.text();
35
- let body;
36
- try {
37
- body = JSON.parse(text);
38
- }
39
- catch {
40
- return { ok: false, error: 'exchange_unavailable', detail: `status_${res.status}: ${text.slice(0, 200)}` };
41
- }
42
- return readExchangeAnswer(body);
43
- }
44
- catch (e) {
45
- return { ok: false, error: 'exchange_unavailable', detail: e.message };
46
- }
47
- }
@@ -1,13 +0,0 @@
1
- /**
2
- * hyperliquid — the core the CLI and the browser both sign with (text/hyperliquid-plan.md).
3
- * Pure except `meta.ts` reads and `exchange.ts` posts, both through a `fetchImpl` seam.
4
- * No key material anywhere: a key is a `Signer` the caller brings.
5
- */
6
- export * from './errors.js';
7
- export * from './wire.js';
8
- export * from './meta.js';
9
- export * from './actions.js';
10
- export * from './signing.js';
11
- export * from './exchange.js';
12
- export { packb } from './msgpack.js';
13
- export { typedDataDigest, type TypedData, type TypedField, type Eip712Domain } from './eip712.js';
@@ -1,14 +0,0 @@
1
- // VENDORED from one.ie/web/src/lib/hyperliquid/index.ts by packages/cli/scripts/hl-core-vendor.mjs — do not edit; tests/hl-core-parity.test.ts compares bytes.
2
- /**
3
- * hyperliquid — the core the CLI and the browser both sign with (text/hyperliquid-plan.md).
4
- * Pure except `meta.ts` reads and `exchange.ts` posts, both through a `fetchImpl` seam.
5
- * No key material anywhere: a key is a `Signer` the caller brings.
6
- */
7
- export * from './errors.js';
8
- export * from './wire.js';
9
- export * from './meta.js';
10
- export * from './actions.js';
11
- export * from './signing.js';
12
- export * from './exchange.js';
13
- export { packb } from './msgpack.js';
14
- export { typedDataDigest } from './eip712.js';
@@ -1,57 +0,0 @@
1
- /**
2
- * hyperliquid/meta — asset index, szDecimals and tick kind from `meta` (perps) and `spotMeta`
3
- * (spot), and the keyless info reads behind them (text/hyperliquid-plan.md H5).
4
- *
5
- * Indexing, as the python SDK's Info.__init__ does it:
6
- * perp asset = position in meta.universe (0 = BTC on mainnet)
7
- * spot asset = 10000 + spotMeta.universe[i].index (the `index` FIELD, not the array position)
8
- * spot szDecimals = the BASE token's szDecimals
9
- * spot names = the pair's own name ("PURR/USDC", "@107") plus "BASE/QUOTE" as an alias
10
- * Builder-deployed perp dexs (110000+) are not read here and are refused by index.
11
- *
12
- * Reads go through a `fetchImpl` seam and a failed read is `{ok:false}` — never an empty table.
13
- */
14
- import { type HlNet } from './net.js';
15
- import type { AssetKind } from './wire.js';
16
- export interface AssetInfo {
17
- /** The coin name orders and mids use: "BTC", "PURR/USDC", "@107". */
18
- coin: string;
19
- /** Human label: "BTC", "HYPE/USDC". */
20
- label: string;
21
- asset: number;
22
- szDecimals: number;
23
- kind: AssetKind;
24
- delisted: boolean;
25
- }
26
- export interface AssetTable {
27
- byName: Map<string, AssetInfo>;
28
- byIndex: Map<number, AssetInfo>;
29
- }
30
- export declare const SPOT_OFFSET = 10000;
31
- export declare const BUILDER_DEX_OFFSET = 110000;
32
- export declare function buildAssetTable(meta: unknown, spotMeta: unknown): AssetTable;
33
- /** "BTC" is the perp; spot bitcoin is "UBTC/USDC" (or its "@142" pair name). */
34
- export declare function resolveCoin(table: AssetTable, coin: string): AssetInfo;
35
- export declare function assetByIndex(table: AssetTable, asset: number): AssetInfo;
36
- export type InfoRead<T> = {
37
- ok: true;
38
- data: T;
39
- } | {
40
- ok: false;
41
- error: 'hyperliquid_unavailable';
42
- detail: string;
43
- };
44
- export declare function readInfo<T = unknown>(body: Record<string, unknown>, net: HlNet, o?: {
45
- fetchImpl?: typeof fetch;
46
- timeoutMs?: number;
47
- }): Promise<InfoRead<T>>;
48
- /** meta + spotMeta in one go. Either read failing fails the table — half a table is not a table. */
49
- export declare function readAssetTable(net: HlNet, o?: {
50
- fetchImpl?: typeof fetch;
51
- timeoutMs?: number;
52
- }): Promise<InfoRead<AssetTable>>;
53
- /** Mid prices by coin name. A coin absent from the answer is absent here — never 0. */
54
- export declare function readMids(net: HlNet, o?: {
55
- fetchImpl?: typeof fetch;
56
- timeoutMs?: number;
57
- }): Promise<InfoRead<Record<string, string>>>;
@@ -1,110 +0,0 @@
1
- // VENDORED from one.ie/web/src/lib/hyperliquid/meta.ts by packages/cli/scripts/hl-core-vendor.mjs — do not edit; tests/hl-core-parity.test.ts compares bytes.
2
- /**
3
- * hyperliquid/meta — asset index, szDecimals and tick kind from `meta` (perps) and `spotMeta`
4
- * (spot), and the keyless info reads behind them (text/hyperliquid-plan.md H5).
5
- *
6
- * Indexing, as the python SDK's Info.__init__ does it:
7
- * perp asset = position in meta.universe (0 = BTC on mainnet)
8
- * spot asset = 10000 + spotMeta.universe[i].index (the `index` FIELD, not the array position)
9
- * spot szDecimals = the BASE token's szDecimals
10
- * spot names = the pair's own name ("PURR/USDC", "@107") plus "BASE/QUOTE" as an alias
11
- * Builder-deployed perp dexs (110000+) are not read here and are refused by index.
12
- *
13
- * Reads go through a `fetchImpl` seam and a failed read is `{ok:false}` — never an empty table.
14
- */
15
- import { HL_INFO } from './net.js';
16
- import { HlRefusal } from './errors.js';
17
- const isObj = (v) => typeof v === 'object' && v !== null && !Array.isArray(v);
18
- export const SPOT_OFFSET = 10_000;
19
- export const BUILDER_DEX_OFFSET = 110_000;
20
- export function buildAssetTable(meta, spotMeta) {
21
- const byName = new Map();
22
- const byIndex = new Map();
23
- const add = (a, ...names) => {
24
- byIndex.set(a.asset, a);
25
- for (const n of names)
26
- if (!byName.has(n))
27
- byName.set(n, a);
28
- };
29
- // Perps first: a perp name wins over any spot alias spelled the same.
30
- const m = isObj(meta) ? meta : {};
31
- const universe = Array.isArray(m['universe']) ? m['universe'] : [];
32
- universe.forEach((p, i) => {
33
- if (!isObj(p) || typeof p['name'] !== 'string' || typeof p['szDecimals'] !== 'number')
34
- return;
35
- add({ coin: p['name'], label: p['name'], asset: i, szDecimals: p['szDecimals'], kind: 'perp', delisted: p['isDelisted'] === true }, p['name']);
36
- });
37
- const sm = isObj(spotMeta) ? spotMeta : {};
38
- const tokens = new Map();
39
- for (const t of Array.isArray(sm['tokens']) ? sm['tokens'] : []) {
40
- if (isObj(t) && typeof t['index'] === 'number')
41
- tokens.set(t['index'], t);
42
- }
43
- for (const u of Array.isArray(sm['universe']) ? sm['universe'] : []) {
44
- if (!isObj(u) || typeof u['index'] !== 'number' || typeof u['name'] !== 'string' || !Array.isArray(u['tokens']))
45
- continue;
46
- const [b, q] = u['tokens'];
47
- const base = tokens.get(b);
48
- const quote = tokens.get(q);
49
- if (!base || typeof base['szDecimals'] !== 'number')
50
- continue;
51
- const label = `${String(base['name'])}/${String(quote?.['name'] ?? '?')}`;
52
- add({ coin: u['name'], label, asset: SPOT_OFFSET + u['index'], szDecimals: base['szDecimals'], kind: 'spot', delisted: false }, u['name'], label);
53
- }
54
- return { byName, byIndex };
55
- }
56
- /** "BTC" is the perp; spot bitcoin is "UBTC/USDC" (or its "@142" pair name). */
57
- export function resolveCoin(table, coin) {
58
- const hit = table.byName.get(coin);
59
- if (!hit)
60
- throw new HlRefusal('unknown_asset', coin);
61
- if (hit.delisted)
62
- throw new HlRefusal('asset_delisted', coin);
63
- return hit;
64
- }
65
- export function assetByIndex(table, asset) {
66
- if (asset >= BUILDER_DEX_OFFSET)
67
- throw new HlRefusal('builder_dex_unsupported', String(asset));
68
- const hit = table.byIndex.get(asset);
69
- if (!hit)
70
- throw new HlRefusal('unknown_asset', String(asset));
71
- return hit;
72
- }
73
- export async function readInfo(body, net, o = {}) {
74
- const f = o.fetchImpl ?? fetch;
75
- try {
76
- const res = await f(HL_INFO[net], {
77
- method: 'POST',
78
- headers: { 'content-type': 'application/json' },
79
- body: JSON.stringify(body),
80
- signal: AbortSignal.timeout(o.timeoutMs ?? 5000),
81
- });
82
- if (!res.ok)
83
- return { ok: false, error: 'hyperliquid_unavailable', detail: `status_${res.status}` };
84
- return { ok: true, data: (await res.json()) };
85
- }
86
- catch (e) {
87
- return { ok: false, error: 'hyperliquid_unavailable', detail: e.message };
88
- }
89
- }
90
- /** meta + spotMeta in one go. Either read failing fails the table — half a table is not a table. */
91
- export async function readAssetTable(net, o = {}) {
92
- const [meta, spot] = await Promise.all([readInfo({ type: 'meta' }, net, o), readInfo({ type: 'spotMeta' }, net, o)]);
93
- if (!meta.ok)
94
- return meta;
95
- if (!spot.ok)
96
- return spot;
97
- return { ok: true, data: buildAssetTable(meta.data, spot.data) };
98
- }
99
- /** Mid prices by coin name. A coin absent from the answer is absent here — never 0. */
100
- export async function readMids(net, o = {}) {
101
- const r = await readInfo({ type: 'allMids' }, net, o);
102
- if (!r.ok)
103
- return r;
104
- const out = {};
105
- if (isObj(r.data))
106
- for (const [k, v] of Object.entries(r.data))
107
- if (typeof v === 'string' && /^\d+(\.\d+)?$/.test(v))
108
- out[k] = v;
109
- return { ok: true, data: out };
110
- }
@@ -1,18 +0,0 @@
1
- /**
2
- * hyperliquid/msgpack — the exact msgpack bytes Hyperliquid hashes for an L1 action
3
- * (text/hyperliquid-plan.md § The hash). A port of what python `msgpack.packb(action)` emits
4
- * for the shapes an action can hold, and nothing else:
5
- *
6
- * null → nil · boolean → c2/c3 · integer → smallest fixint/uint/int · string → fixstr/str8/16/32
7
- * array → fixarray/array16/32 · plain object → fixmap/map16/32, keys in INSERTION order
8
- *
9
- * A JS float is REFUSED (`msgpack_float`): Hyperliquid's wire carries prices and sizes as decimal
10
- * strings, so a float here means a builder bug — and python would emit float64, a different hash.
11
- * `undefined` is refused too: python never sees it, so silently dropping a key would hash a
12
- * different action than the one the caller thinks it built.
13
- */
14
- export declare class MsgpackError extends Error {
15
- code: 'msgpack_float' | 'msgpack_undefined' | 'msgpack_type' | 'msgpack_int_range';
16
- constructor(code: 'msgpack_float' | 'msgpack_undefined' | 'msgpack_type' | 'msgpack_int_range', detail: string);
17
- }
18
- export declare function packb(value: unknown): Uint8Array;