oneie 5.7.6 → 5.8.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 (245) hide show
  1. package/README.md +19 -1
  2. package/dist/package.json +7 -8
  3. package/dist/src/age-yefbe8pe.js +1 -0
  4. package/dist/src/evm-tx-ee2q0e3w.js +1 -0
  5. package/dist/src/hl-run-tgrkrk69.js +1 -0
  6. package/dist/src/index-0rj9wdk9.js +4 -0
  7. package/dist/src/index-91y484c2.js +2052 -0
  8. package/dist/src/index-940y3rnv.js +12 -0
  9. package/dist/src/index.js +1047 -121
  10. package/dist/src/message-key-db1xjdkw.js +1 -0
  11. package/dist/src/message-lock-5vr8079x.js +5 -0
  12. package/dist/src/sweep-order-c2p6rk8c.js +1 -0
  13. package/dist/src/sweep-runner-t68xe7vx.js +1 -0
  14. package/package.json +7 -8
  15. package/dist/src/agent.d.ts +0 -75
  16. package/dist/src/agent.js +0 -1334
  17. package/dist/src/agentverse.d.ts +0 -26
  18. package/dist/src/agentverse.js +0 -171
  19. package/dist/src/args.d.ts +0 -9
  20. package/dist/src/args.js +0 -61
  21. package/dist/src/auth.d.ts +0 -6
  22. package/dist/src/auth.js +0 -121
  23. package/dist/src/balances.d.ts +0 -89
  24. package/dist/src/balances.js +0 -202
  25. package/dist/src/banner.d.ts +0 -1
  26. package/dist/src/banner.js +0 -17
  27. package/dist/src/broadcast.d.ts +0 -8
  28. package/dist/src/broadcast.js +0 -175
  29. package/dist/src/catalog.d.ts +0 -12
  30. package/dist/src/catalog.js +0 -76
  31. package/dist/src/chat.d.ts +0 -2
  32. package/dist/src/chat.js +0 -92
  33. package/dist/src/client.d.ts +0 -5
  34. package/dist/src/client.js +0 -157
  35. package/dist/src/compiler.d.ts +0 -36
  36. package/dist/src/compiler.js +0 -366
  37. package/dist/src/config.d.ts +0 -24
  38. package/dist/src/config.js +0 -70
  39. package/dist/src/connect.d.ts +0 -2
  40. package/dist/src/connect.js +0 -64
  41. package/dist/src/coordinate.d.ts +0 -3
  42. package/dist/src/coordinate.js +0 -58
  43. package/dist/src/create.d.ts +0 -2
  44. package/dist/src/create.js +0 -113
  45. package/dist/src/deploy.d.ts +0 -2
  46. package/dist/src/deploy.js +0 -19
  47. package/dist/src/dev.d.ts +0 -2
  48. package/dist/src/dev.js +0 -75
  49. package/dist/src/device-flow.d.ts +0 -57
  50. package/dist/src/device-flow.js +0 -173
  51. package/dist/src/doctor.d.ts +0 -26
  52. package/dist/src/doctor.js +0 -146
  53. package/dist/src/draw.d.ts +0 -18
  54. package/dist/src/draw.js +0 -156
  55. package/dist/src/endpoint.d.ts +0 -2
  56. package/dist/src/endpoint.js +0 -250
  57. package/dist/src/env.d.ts +0 -3
  58. package/dist/src/env.js +0 -37
  59. package/dist/src/eval.d.ts +0 -2
  60. package/dist/src/eval.js +0 -43
  61. package/dist/src/fn.d.ts +0 -2
  62. package/dist/src/fn.js +0 -70
  63. package/dist/src/group.d.ts +0 -2
  64. package/dist/src/group.js +0 -117
  65. package/dist/src/hl-run.d.ts +0 -119
  66. package/dist/src/hl-run.js +0 -480
  67. package/dist/src/hl.d.ts +0 -17
  68. package/dist/src/hl.js +0 -148
  69. package/dist/src/index.d.ts +0 -2
  70. package/dist/src/init.d.ts +0 -76
  71. package/dist/src/init.js +0 -278
  72. package/dist/src/join.d.ts +0 -11
  73. package/dist/src/join.js +0 -293
  74. package/dist/src/key-publish.d.ts +0 -40
  75. package/dist/src/key-publish.js +0 -232
  76. package/dist/src/key-seal.d.ts +0 -21
  77. package/dist/src/key-seal.js +0 -142
  78. package/dist/src/key-sweep.d.ts +0 -93
  79. package/dist/src/key-sweep.js +0 -263
  80. package/dist/src/key.d.ts +0 -26
  81. package/dist/src/key.js +0 -338
  82. package/dist/src/lib/age-plugin.d.ts +0 -51
  83. package/dist/src/lib/age-plugin.js +0 -130
  84. package/dist/src/lib/agent-env.d.ts +0 -12
  85. package/dist/src/lib/agent-env.js +0 -48
  86. package/dist/src/lib/api-path.d.ts +0 -2
  87. package/dist/src/lib/api-path.js +0 -40
  88. package/dist/src/lib/asker.d.ts +0 -34
  89. package/dist/src/lib/asker.js +0 -126
  90. package/dist/src/lib/client.d.ts +0 -20
  91. package/dist/src/lib/client.js +0 -71
  92. package/dist/src/lib/env-sealed.d.ts +0 -53
  93. package/dist/src/lib/env-sealed.js +0 -184
  94. package/dist/src/lib/flow-tag.d.ts +0 -86
  95. package/dist/src/lib/flow-tag.js +0 -230
  96. package/dist/src/lib/hl-core/actions.d.ts +0 -99
  97. package/dist/src/lib/hl-core/actions.js +0 -69
  98. package/dist/src/lib/hl-core/eip712.d.ts +0 -33
  99. package/dist/src/lib/hl-core/eip712.js +0 -107
  100. package/dist/src/lib/hl-core/errors.d.ts +0 -10
  101. package/dist/src/lib/hl-core/errors.js +0 -15
  102. package/dist/src/lib/hl-core/exchange.d.ts +0 -24
  103. package/dist/src/lib/hl-core/exchange.js +0 -47
  104. package/dist/src/lib/hl-core/index.d.ts +0 -13
  105. package/dist/src/lib/hl-core/index.js +0 -14
  106. package/dist/src/lib/hl-core/meta.d.ts +0 -57
  107. package/dist/src/lib/hl-core/meta.js +0 -110
  108. package/dist/src/lib/hl-core/msgpack.d.ts +0 -18
  109. package/dist/src/lib/hl-core/msgpack.js +0 -136
  110. package/dist/src/lib/hl-core/net.d.ts +0 -2
  111. package/dist/src/lib/hl-core/net.js +0 -7
  112. package/dist/src/lib/hl-core/signing.d.ts +0 -103
  113. package/dist/src/lib/hl-core/signing.js +0 -295
  114. package/dist/src/lib/hl-core/wire.d.ts +0 -34
  115. package/dist/src/lib/hl-core/wire.js +0 -81
  116. package/dist/src/lib/invoked-as.d.ts +0 -2
  117. package/dist/src/lib/invoked-as.js +0 -24
  118. package/dist/src/lib/journey-words.d.ts +0 -84
  119. package/dist/src/lib/journey-words.js +0 -360
  120. package/dist/src/lib/journey.d.ts +0 -148
  121. package/dist/src/lib/journey.js +0 -245
  122. package/dist/src/lib/key-receipt.d.ts +0 -48
  123. package/dist/src/lib/key-receipt.js +0 -116
  124. package/dist/src/lib/key-source.d.ts +0 -9
  125. package/dist/src/lib/key-source.js +0 -33
  126. package/dist/src/lib/keyfile.d.ts +0 -136
  127. package/dist/src/lib/keyfile.js +0 -397
  128. package/dist/src/lib/launch-claude.d.ts +0 -5
  129. package/dist/src/lib/launch-claude.js +0 -45
  130. package/dist/src/lib/lock-lookup.d.ts +0 -40
  131. package/dist/src/lib/lock-lookup.js +0 -92
  132. package/dist/src/lib/message-seal.d.ts +0 -63
  133. package/dist/src/lib/message-seal.js +0 -150
  134. package/dist/src/lib/network.d.ts +0 -15
  135. package/dist/src/lib/network.js +0 -41
  136. package/dist/src/lib/paths.d.ts +0 -41
  137. package/dist/src/lib/paths.js +0 -91
  138. package/dist/src/lib/plan-draw.d.ts +0 -56
  139. package/dist/src/lib/plan-draw.js +0 -219
  140. package/dist/src/lib/plan-live.d.ts +0 -20
  141. package/dist/src/lib/plan-live.js +0 -192
  142. package/dist/src/lib/qr.d.ts +0 -21
  143. package/dist/src/lib/qr.js +0 -402
  144. package/dist/src/lib/roster.d.ts +0 -20
  145. package/dist/src/lib/roster.js +0 -79
  146. package/dist/src/lib/sale-card.d.ts +0 -117
  147. package/dist/src/lib/sale-card.js +0 -261
  148. package/dist/src/lib/shop-init.d.ts +0 -62
  149. package/dist/src/lib/shop-init.js +0 -63
  150. package/dist/src/lib/sui-grpc-send.d.ts +0 -50
  151. package/dist/src/lib/sui-grpc-send.js +0 -89
  152. package/dist/src/lib/swap-core.d.ts +0 -163
  153. package/dist/src/lib/swap-core.js +0 -405
  154. package/dist/src/lib/tasks-digest.d.ts +0 -66
  155. package/dist/src/lib/tasks-digest.js +0 -200
  156. package/dist/src/lib/tasks-graph.d.ts +0 -79
  157. package/dist/src/lib/tasks-graph.js +0 -463
  158. package/dist/src/lib/tasks-lens.d.ts +0 -31
  159. package/dist/src/lib/tasks-lens.js +0 -47
  160. package/dist/src/lib/tasks-next.d.ts +0 -25
  161. package/dist/src/lib/tasks-next.js +0 -103
  162. package/dist/src/lib/tasks-prove.d.ts +0 -15
  163. package/dist/src/lib/tasks-prove.js +0 -68
  164. package/dist/src/lib/tasks-route.d.ts +0 -29
  165. package/dist/src/lib/tasks-route.js +0 -151
  166. package/dist/src/lib/tasks-score.d.ts +0 -36
  167. package/dist/src/lib/tasks-score.js +0 -152
  168. package/dist/src/lib/tasks-workspace.d.ts +0 -18
  169. package/dist/src/lib/tasks-workspace.js +0 -73
  170. package/dist/src/lib/vault-read.d.ts +0 -24
  171. package/dist/src/lib/vault-read.js +0 -77
  172. package/dist/src/lib/vaultfile.d.ts +0 -88
  173. package/dist/src/lib/vaultfile.js +0 -222
  174. package/dist/src/lib/wallet-money.d.ts +0 -222
  175. package/dist/src/lib/wallet-money.js +0 -578
  176. package/dist/src/lib/wallet-request.d.ts +0 -50
  177. package/dist/src/lib/wallet-request.js +0 -86
  178. package/dist/src/links.d.ts +0 -5
  179. package/dist/src/links.js +0 -45
  180. package/dist/src/media.d.ts +0 -29
  181. package/dist/src/media.js +0 -487
  182. package/dist/src/message-receipt.d.ts +0 -25
  183. package/dist/src/message-receipt.js +0 -71
  184. package/dist/src/message.d.ts +0 -13
  185. package/dist/src/message.js +0 -92
  186. package/dist/src/onboard.d.ts +0 -16
  187. package/dist/src/onboard.js +0 -149
  188. package/dist/src/plugin.d.ts +0 -2
  189. package/dist/src/plugin.js +0 -193
  190. package/dist/src/push.d.ts +0 -2
  191. package/dist/src/push.js +0 -115
  192. package/dist/src/render.d.ts +0 -21
  193. package/dist/src/render.js +0 -32
  194. package/dist/src/secrets-device.d.ts +0 -32
  195. package/dist/src/secrets-device.js +0 -127
  196. package/dist/src/secrets-give.d.ts +0 -125
  197. package/dist/src/secrets-give.js +0 -236
  198. package/dist/src/secrets-list.d.ts +0 -27
  199. package/dist/src/secrets-list.js +0 -84
  200. package/dist/src/secrets-run.d.ts +0 -31
  201. package/dist/src/secrets-run.js +0 -182
  202. package/dist/src/secrets.d.ts +0 -33
  203. package/dist/src/secrets.js +0 -200
  204. package/dist/src/setup.d.ts +0 -6
  205. package/dist/src/setup.js +0 -127
  206. package/dist/src/ship.d.ts +0 -2
  207. package/dist/src/ship.js +0 -18
  208. package/dist/src/shop.d.ts +0 -10
  209. package/dist/src/shop.js +0 -110
  210. package/dist/src/skill-parser.d.ts +0 -14
  211. package/dist/src/skill-parser.js +0 -113
  212. package/dist/src/skill.d.ts +0 -2
  213. package/dist/src/skill.js +0 -493
  214. package/dist/src/slug.d.ts +0 -2
  215. package/dist/src/slug.js +0 -6
  216. package/dist/src/social.d.ts +0 -2
  217. package/dist/src/social.js +0 -106
  218. package/dist/src/staff.d.ts +0 -2
  219. package/dist/src/staff.js +0 -104
  220. package/dist/src/start.d.ts +0 -15
  221. package/dist/src/start.js +0 -203
  222. package/dist/src/status.d.ts +0 -2
  223. package/dist/src/status.js +0 -52
  224. package/dist/src/substrate.d.ts +0 -2
  225. package/dist/src/substrate.js +0 -258
  226. package/dist/src/swap.d.ts +0 -93
  227. package/dist/src/swap.js +0 -622
  228. package/dist/src/tasks.d.ts +0 -2
  229. package/dist/src/tasks.js +0 -743
  230. package/dist/src/templates.d.ts +0 -1
  231. package/dist/src/templates.js +0 -213
  232. package/dist/src/trade.d.ts +0 -2
  233. package/dist/src/trade.js +0 -91
  234. package/dist/src/trail.d.ts +0 -2
  235. package/dist/src/trail.js +0 -41
  236. package/dist/src/validate.d.ts +0 -13
  237. package/dist/src/validate.js +0 -35
  238. package/dist/src/wallet-money.d.ts +0 -152
  239. package/dist/src/wallet-money.js +0 -564
  240. package/dist/src/wallet.d.ts +0 -167
  241. package/dist/src/wallet.js +0 -855
  242. package/dist/src/workflow.d.ts +0 -2
  243. package/dist/src/workflow.js +0 -166
  244. package/dist/src/write.d.ts +0 -43
  245. package/dist/src/write.js +0 -180
@@ -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;
@@ -1,136 +0,0 @@
1
- // VENDORED from one.ie/web/src/lib/hyperliquid/msgpack.ts by packages/cli/scripts/hl-core-vendor.mjs — do not edit; tests/hl-core-parity.test.ts compares bytes.
2
- /**
3
- * hyperliquid/msgpack — the exact msgpack bytes Hyperliquid hashes for an L1 action
4
- * (text/hyperliquid-plan.md § The hash). A port of what python `msgpack.packb(action)` emits
5
- * for the shapes an action can hold, and nothing else:
6
- *
7
- * null → nil · boolean → c2/c3 · integer → smallest fixint/uint/int · string → fixstr/str8/16/32
8
- * array → fixarray/array16/32 · plain object → fixmap/map16/32, keys in INSERTION order
9
- *
10
- * A JS float is REFUSED (`msgpack_float`): Hyperliquid's wire carries prices and sizes as decimal
11
- * strings, so a float here means a builder bug — and python would emit float64, a different hash.
12
- * `undefined` is refused too: python never sees it, so silently dropping a key would hash a
13
- * different action than the one the caller thinks it built.
14
- */
15
- export class MsgpackError extends Error {
16
- code;
17
- constructor(code, detail) {
18
- super(`${code}: ${detail}`);
19
- this.code = code;
20
- }
21
- }
22
- const U64_MAX = (1n << 64n) - 1n;
23
- const I64_MIN = -(1n << 63n);
24
- export function packb(value) {
25
- const out = [];
26
- write(out, value, '$');
27
- return Uint8Array.from(out);
28
- }
29
- function be(out, n, bytes) {
30
- for (let i = bytes - 1; i >= 0; i--)
31
- out.push(Number((n >> BigInt(8 * i)) & 0xffn));
32
- }
33
- function writeInt(out, n, at) {
34
- if (n > U64_MAX || n < I64_MIN)
35
- throw new MsgpackError('msgpack_int_range', at);
36
- if (n >= 0n) {
37
- if (n <= 0x7fn)
38
- out.push(Number(n));
39
- else if (n <= 0xffn) {
40
- out.push(0xcc);
41
- be(out, n, 1);
42
- }
43
- else if (n <= 0xffffn) {
44
- out.push(0xcd);
45
- be(out, n, 2);
46
- }
47
- else if (n <= 0xffffffffn) {
48
- out.push(0xce);
49
- be(out, n, 4);
50
- }
51
- else {
52
- out.push(0xcf);
53
- be(out, n, 8);
54
- }
55
- return;
56
- }
57
- const u = (bits) => (n + (1n << BigInt(bits))); // two's complement
58
- if (n >= -32n)
59
- out.push(Number(u(8)));
60
- else if (n >= -128n) {
61
- out.push(0xd0);
62
- be(out, u(8), 1);
63
- }
64
- else if (n >= -32768n) {
65
- out.push(0xd1);
66
- be(out, u(16), 2);
67
- }
68
- else if (n >= -2147483648n) {
69
- out.push(0xd2);
70
- be(out, u(32), 4);
71
- }
72
- else {
73
- out.push(0xd3);
74
- be(out, u(64), 8);
75
- }
76
- }
77
- function writeLen(out, len, fix, fixMax, codes) {
78
- if (len <= fixMax)
79
- out.push(fix | len);
80
- else if (codes[0] !== null && len <= 0xff) {
81
- out.push(codes[0]);
82
- be(out, BigInt(len), 1);
83
- }
84
- else if (len <= 0xffff) {
85
- out.push(codes[1]);
86
- be(out, BigInt(len), 2);
87
- }
88
- else {
89
- out.push(codes[2]);
90
- be(out, BigInt(len), 4);
91
- }
92
- }
93
- function write(out, v, at) {
94
- if (v === null) {
95
- out.push(0xc0);
96
- return;
97
- }
98
- if (v === undefined)
99
- throw new MsgpackError('msgpack_undefined', at);
100
- if (typeof v === 'boolean') {
101
- out.push(v ? 0xc3 : 0xc2);
102
- return;
103
- }
104
- if (typeof v === 'bigint') {
105
- writeInt(out, v, at);
106
- return;
107
- }
108
- if (typeof v === 'number') {
109
- if (!Number.isSafeInteger(v))
110
- throw new MsgpackError('msgpack_float', `${at}=${v}`);
111
- writeInt(out, BigInt(v), at);
112
- return;
113
- }
114
- if (typeof v === 'string') {
115
- const b = new TextEncoder().encode(v);
116
- writeLen(out, b.length, 0xa0, 31, [0xd9, 0xda, 0xdb]);
117
- for (const x of b)
118
- out.push(x);
119
- return;
120
- }
121
- if (Array.isArray(v)) {
122
- writeLen(out, v.length, 0x90, 15, [null, 0xdc, 0xdd]);
123
- v.forEach((x, i) => write(out, x, `${at}[${i}]`));
124
- return;
125
- }
126
- if (typeof v === 'object' && Object.getPrototypeOf(v) === Object.prototype) {
127
- const keys = Object.keys(v);
128
- writeLen(out, keys.length, 0x80, 15, [null, 0xde, 0xdf]);
129
- for (const k of keys) {
130
- write(out, k, at);
131
- write(out, v[k], `${at}.${k}`);
132
- }
133
- return;
134
- }
135
- throw new MsgpackError('msgpack_type', `${at}: ${typeof v}`);
136
- }
@@ -1,2 +0,0 @@
1
- export type HlNet = 'mainnet' | 'testnet';
2
- export declare const HL_INFO: Record<HlNet, string>;
@@ -1,7 +0,0 @@
1
- // The two names the vendored core imports from one.ie/web/src/lib/swap/hyperliquid.ts.
2
- // Hand-written (that web file carries more than the core needs); tests/hl-core-parity.test.ts
3
- // pins HL_INFO to the web original value for value.
4
- export const HL_INFO = {
5
- mainnet: 'https://api.hyperliquid.xyz/info',
6
- testnet: 'https://api.hyperliquid-testnet.xyz/info',
7
- };