@huggies/shit-1170-rex-engine-middleman 0.0.0-stage → 0.0.2

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 (171) hide show
  1. package/LICENSE +9 -0
  2. package/README.md +43 -2
  3. package/bin/README.md +38 -0
  4. package/bin/fun/resolve_base_url.ts +45 -0
  5. package/bin/fun/split_argv.ts +67 -0
  6. package/bin/shit-1170/README.md +333 -0
  7. package/bin/shit-1170/api_shit_1170_api_key_me_get.ts +46 -0
  8. package/bin/shit-1170/api_shit_1170_api_key_rotate_post.ts +83 -0
  9. package/bin/shit-1170/api_shit_1170_api_keys_post.ts +68 -0
  10. package/bin/shit-1170/api_shit_1170_ping_get.ts +28 -0
  11. package/bin/shit-1170/api_shit_1170_swap_queue_accounts_delete.ts +81 -0
  12. package/bin/shit-1170/api_shit_1170_swap_queue_accounts_post.ts +80 -0
  13. package/bin/shit-1170/api_shit_1170_swap_queue_get.ts +91 -0
  14. package/bin/shit-1170/api_shit_1170_swap_queue_one_get.ts +62 -0
  15. package/bin/shit-1170/api_shit_1170_swap_queue_post.ts +118 -0
  16. package/bin/shit-1170/api_shit_1170_swap_queue_sent_post.ts +87 -0
  17. package/bin/shit-1170/api_shit_1170_tx_queue_accounts_delete.ts +68 -0
  18. package/bin/shit-1170/api_shit_1170_tx_queue_accounts_post.ts +65 -0
  19. package/bin/shit-1170/api_shit_1170_tx_queue_facets_get.ts +68 -0
  20. package/bin/shit-1170/api_shit_1170_tx_queue_get.ts +99 -0
  21. package/bin/shit-1170/api_shit_1170_tx_queue_one_get.ts +67 -0
  22. package/bin/shit-1170/api_shit_1170_tx_queue_post.ts +243 -0
  23. package/bin/shit-1170/api_shit_1170_tx_queue_sent_post.ts +172 -0
  24. package/bin/shit-1170/api_shit_1170_tx_queue_stats_contracts_get.ts +60 -0
  25. package/bin/shit-1170/api_shit_1170_tx_queue_stats_methods_get.ts +60 -0
  26. package/bin/shit-1170/api_trezu_treasuries_get.ts +62 -0
  27. package/dist/fun/api_shit_1170_api_key_me_get.d.ts +4 -0
  28. package/dist/fun/api_shit_1170_api_key_me_get.d.ts.map +1 -0
  29. package/dist/fun/api_shit_1170_api_key_me_get.js +38 -0
  30. package/dist/fun/api_shit_1170_api_key_me_get.js.map +1 -0
  31. package/dist/fun/api_shit_1170_api_key_rotate_post.d.ts +4 -0
  32. package/dist/fun/api_shit_1170_api_key_rotate_post.d.ts.map +1 -0
  33. package/dist/fun/api_shit_1170_api_key_rotate_post.js +46 -0
  34. package/dist/fun/api_shit_1170_api_key_rotate_post.js.map +1 -0
  35. package/dist/fun/api_shit_1170_api_keys_post.d.ts +3 -0
  36. package/dist/fun/api_shit_1170_api_keys_post.d.ts.map +1 -0
  37. package/dist/fun/api_shit_1170_api_keys_post.js +52 -0
  38. package/dist/fun/api_shit_1170_api_keys_post.js.map +1 -0
  39. package/dist/fun/api_shit_1170_ping_get.d.ts +3 -0
  40. package/dist/fun/api_shit_1170_ping_get.d.ts.map +1 -0
  41. package/dist/fun/api_shit_1170_ping_get.js +32 -0
  42. package/dist/fun/api_shit_1170_ping_get.js.map +1 -0
  43. package/dist/fun/api_shit_1170_swap_queue_accounts_delete.d.ts +4 -0
  44. package/dist/fun/api_shit_1170_swap_queue_accounts_delete.d.ts.map +1 -0
  45. package/dist/fun/api_shit_1170_swap_queue_accounts_delete.js +46 -0
  46. package/dist/fun/api_shit_1170_swap_queue_accounts_delete.js.map +1 -0
  47. package/dist/fun/api_shit_1170_swap_queue_accounts_post.d.ts +4 -0
  48. package/dist/fun/api_shit_1170_swap_queue_accounts_post.d.ts.map +1 -0
  49. package/dist/fun/api_shit_1170_swap_queue_accounts_post.js +42 -0
  50. package/dist/fun/api_shit_1170_swap_queue_accounts_post.js.map +1 -0
  51. package/dist/fun/api_shit_1170_swap_queue_get.d.ts +5 -0
  52. package/dist/fun/api_shit_1170_swap_queue_get.d.ts.map +1 -0
  53. package/dist/fun/api_shit_1170_swap_queue_get.js +77 -0
  54. package/dist/fun/api_shit_1170_swap_queue_get.js.map +1 -0
  55. package/dist/fun/api_shit_1170_swap_queue_one_get.d.ts +4 -0
  56. package/dist/fun/api_shit_1170_swap_queue_one_get.d.ts.map +1 -0
  57. package/dist/fun/api_shit_1170_swap_queue_one_get.js +38 -0
  58. package/dist/fun/api_shit_1170_swap_queue_one_get.js.map +1 -0
  59. package/dist/fun/api_shit_1170_swap_queue_post.d.ts +4 -0
  60. package/dist/fun/api_shit_1170_swap_queue_post.d.ts.map +1 -0
  61. package/dist/fun/api_shit_1170_swap_queue_post.js +62 -0
  62. package/dist/fun/api_shit_1170_swap_queue_post.js.map +1 -0
  63. package/dist/fun/api_shit_1170_swap_queue_sent_post.d.ts +4 -0
  64. package/dist/fun/api_shit_1170_swap_queue_sent_post.d.ts.map +1 -0
  65. package/dist/fun/api_shit_1170_swap_queue_sent_post.js +63 -0
  66. package/dist/fun/api_shit_1170_swap_queue_sent_post.js.map +1 -0
  67. package/dist/fun/api_shit_1170_tx_queue_accounts_delete.d.ts +4 -0
  68. package/dist/fun/api_shit_1170_tx_queue_accounts_delete.d.ts.map +1 -0
  69. package/dist/fun/api_shit_1170_tx_queue_accounts_delete.js +60 -0
  70. package/dist/fun/api_shit_1170_tx_queue_accounts_delete.js.map +1 -0
  71. package/dist/fun/api_shit_1170_tx_queue_accounts_post.d.ts +4 -0
  72. package/dist/fun/api_shit_1170_tx_queue_accounts_post.d.ts.map +1 -0
  73. package/dist/fun/api_shit_1170_tx_queue_accounts_post.js +54 -0
  74. package/dist/fun/api_shit_1170_tx_queue_accounts_post.js.map +1 -0
  75. package/dist/fun/api_shit_1170_tx_queue_facets_get.d.ts +5 -0
  76. package/dist/fun/api_shit_1170_tx_queue_facets_get.d.ts.map +1 -0
  77. package/dist/fun/api_shit_1170_tx_queue_facets_get.js +45 -0
  78. package/dist/fun/api_shit_1170_tx_queue_facets_get.js.map +1 -0
  79. package/dist/fun/api_shit_1170_tx_queue_get.d.ts +5 -0
  80. package/dist/fun/api_shit_1170_tx_queue_get.d.ts.map +1 -0
  81. package/dist/fun/api_shit_1170_tx_queue_get.js +70 -0
  82. package/dist/fun/api_shit_1170_tx_queue_get.js.map +1 -0
  83. package/dist/fun/api_shit_1170_tx_queue_one_get.d.ts +4 -0
  84. package/dist/fun/api_shit_1170_tx_queue_one_get.d.ts.map +1 -0
  85. package/dist/fun/api_shit_1170_tx_queue_one_get.js +46 -0
  86. package/dist/fun/api_shit_1170_tx_queue_one_get.js.map +1 -0
  87. package/dist/fun/api_shit_1170_tx_queue_post.d.ts +4 -0
  88. package/dist/fun/api_shit_1170_tx_queue_post.d.ts.map +1 -0
  89. package/dist/fun/api_shit_1170_tx_queue_post.js +57 -0
  90. package/dist/fun/api_shit_1170_tx_queue_post.js.map +1 -0
  91. package/dist/fun/api_shit_1170_tx_queue_sent_post.d.ts +4 -0
  92. package/dist/fun/api_shit_1170_tx_queue_sent_post.d.ts.map +1 -0
  93. package/dist/fun/api_shit_1170_tx_queue_sent_post.js +59 -0
  94. package/dist/fun/api_shit_1170_tx_queue_sent_post.js.map +1 -0
  95. package/dist/fun/api_shit_1170_tx_queue_stats_contracts_get.d.ts +5 -0
  96. package/dist/fun/api_shit_1170_tx_queue_stats_contracts_get.d.ts.map +1 -0
  97. package/dist/fun/api_shit_1170_tx_queue_stats_contracts_get.js +41 -0
  98. package/dist/fun/api_shit_1170_tx_queue_stats_contracts_get.js.map +1 -0
  99. package/dist/fun/api_shit_1170_tx_queue_stats_methods_get.d.ts +5 -0
  100. package/dist/fun/api_shit_1170_tx_queue_stats_methods_get.d.ts.map +1 -0
  101. package/dist/fun/api_shit_1170_tx_queue_stats_methods_get.js +41 -0
  102. package/dist/fun/api_shit_1170_tx_queue_stats_methods_get.js.map +1 -0
  103. package/dist/fun/api_trezu_treasuries_get.d.ts +4 -0
  104. package/dist/fun/api_trezu_treasuries_get.d.ts.map +1 -0
  105. package/dist/fun/api_trezu_treasuries_get.js +34 -0
  106. package/dist/fun/api_trezu_treasuries_get.js.map +1 -0
  107. package/dist/index.d.ts +40 -0
  108. package/dist/index.d.ts.map +1 -0
  109. package/dist/index.js +42 -0
  110. package/dist/index.js.map +1 -0
  111. package/dist/stuff/api_call.d.ts +15 -0
  112. package/dist/stuff/api_call.d.ts.map +1 -0
  113. package/dist/stuff/api_call.js +86 -0
  114. package/dist/stuff/api_call.js.map +1 -0
  115. package/dist/stuff/endpoint_paths.d.ts +14 -0
  116. package/dist/stuff/endpoint_paths.d.ts.map +1 -0
  117. package/dist/stuff/endpoint_paths.js +30 -0
  118. package/dist/stuff/endpoint_paths.js.map +1 -0
  119. package/dist/stuff/parse_error.d.ts +12 -0
  120. package/dist/stuff/parse_error.d.ts.map +1 -0
  121. package/dist/stuff/parse_error.js +84 -0
  122. package/dist/stuff/parse_error.js.map +1 -0
  123. package/dist/stuff/request_options.d.ts +6 -0
  124. package/dist/stuff/request_options.d.ts.map +1 -0
  125. package/dist/stuff/request_options.js +43 -0
  126. package/dist/stuff/request_options.js.map +1 -0
  127. package/dist/types/common.d.ts +7 -0
  128. package/dist/types/common.d.ts.map +1 -0
  129. package/dist/types/common.js +6 -0
  130. package/dist/types/common.js.map +1 -0
  131. package/dist/types/shit_1170_api_keys.d.ts +25 -0
  132. package/dist/types/shit_1170_api_keys.d.ts.map +1 -0
  133. package/dist/types/shit_1170_api_keys.js +23 -0
  134. package/dist/types/shit_1170_api_keys.js.map +1 -0
  135. package/dist/types/shit_1170_ping.d.ts +5 -0
  136. package/dist/types/shit_1170_ping.d.ts.map +1 -0
  137. package/dist/types/shit_1170_ping.js +11 -0
  138. package/dist/types/shit_1170_ping.js.map +1 -0
  139. package/dist/types/shit_1170_swap_queue.d.ts +57 -0
  140. package/dist/types/shit_1170_swap_queue.d.ts.map +1 -0
  141. package/dist/types/shit_1170_swap_queue.js +37 -0
  142. package/dist/types/shit_1170_swap_queue.js.map +1 -0
  143. package/dist/types/shit_1170_tx_queue.d.ts +74 -0
  144. package/dist/types/shit_1170_tx_queue.d.ts.map +1 -0
  145. package/dist/types/shit_1170_tx_queue.js +34 -0
  146. package/dist/types/shit_1170_tx_queue.js.map +1 -0
  147. package/dist/types/shit_1170_tx_queue_facets.d.ts +13 -0
  148. package/dist/types/shit_1170_tx_queue_facets.d.ts.map +1 -0
  149. package/dist/types/shit_1170_tx_queue_facets.js +20 -0
  150. package/dist/types/shit_1170_tx_queue_facets.js.map +1 -0
  151. package/dist/types/shit_1170_tx_queue_query.d.ts +15 -0
  152. package/dist/types/shit_1170_tx_queue_query.d.ts.map +1 -0
  153. package/dist/types/shit_1170_tx_queue_query.js +30 -0
  154. package/dist/types/shit_1170_tx_queue_query.js.map +1 -0
  155. package/dist/types/trezu_treasuries_query.d.ts +5 -0
  156. package/dist/types/trezu_treasuries_query.d.ts.map +1 -0
  157. package/dist/types/trezu_treasuries_query.js +9 -0
  158. package/dist/types/trezu_treasuries_query.js.map +1 -0
  159. package/dist/types/trezu_treasury.d.ts +10 -0
  160. package/dist/types/trezu_treasury.d.ts.map +1 -0
  161. package/dist/types/trezu_treasury.js +15 -0
  162. package/dist/types/trezu_treasury.js.map +1 -0
  163. package/dist/types/trezu_treasury_config.d.ts +8 -0
  164. package/dist/types/trezu_treasury_config.d.ts.map +1 -0
  165. package/dist/types/trezu_treasury_config.js +14 -0
  166. package/dist/types/trezu_treasury_config.js.map +1 -0
  167. package/dist/types/trezu_treasury_metadata.d.ts +5 -0
  168. package/dist/types/trezu_treasury_metadata.d.ts.map +1 -0
  169. package/dist/types/trezu_treasury_metadata.js +13 -0
  170. package/dist/types/trezu_treasury_metadata.js.map +1 -0
  171. package/package.json +45 -4
@@ -0,0 +1,68 @@
1
+ // ========================================
2
+ // API_SHIT_1170_API_KEYS_POST
3
+ // runnable bin for POST /api/shit-1170/api-keys via middleman. the
4
+ // middleman logs the framed request + response, so this bin only adds
5
+ // a one-line summary.
6
+ //
7
+ // the accounts come from a json file, so a real signed message can be
8
+ // posted without a wallet in the loop:
9
+ //
10
+ // bun middleman/bin/shit-1170/api_shit_1170_api_keys_post.ts \
11
+ // --accounts <path-to-json>
12
+ //
13
+ // the file holds the accounts array, either as the array itself or as
14
+ // the whole request body:
15
+ // { "accounts": [ { "accountId": "...", "publicKey": "...", ... } ] }
16
+ //
17
+ // --- WHY --- the bin is named after the API KEY and not after the
18
+ // session: the credential in it is not a browser session. the user
19
+ // signs in once and hands the key to an agent, and the agent holds it
20
+ // as a bearer token for as long as it lives.
21
+ // ========================================
22
+
23
+ import { readFileSync } from "node:fs";
24
+ import { api_shit_1170_api_keys_post } from "@huggies/shit-1170-rex-engine-middleman";
25
+ import type {
26
+ SHIT_1170_API_KEYS_REQUEST,
27
+ SHIT_1170_SIGNED_ACCOUNT,
28
+ } from "@huggies/shit-1170-rex-engine-middleman";
29
+ import { resolve_base_url } from "../fun/resolve_base_url";
30
+
31
+ // --- CONFIG --------------------------------------------------------
32
+ // used when no argv is supplied. the default is the local backend,
33
+ // which binds 0.0.0.0:54733 (see shit_1170_port_fun.rs).
34
+ const DEFAULT_BASE_URL = "http://127.0.0.1:54733";
35
+
36
+ // --- argv ----------------------------------------------------------
37
+ // argv[0] is bun, argv[1] is this script, so real args start at 2.
38
+ const argv = process.argv.slice(2);
39
+ const base_url = resolve_base_url(argv, DEFAULT_BASE_URL);
40
+
41
+ const accounts_flag = argv.indexOf("--accounts");
42
+ const accounts_path =
43
+ accounts_flag === -1 ? undefined : argv[accounts_flag + 1];
44
+ if (accounts_path === undefined || accounts_path.length === 0) {
45
+ console.error(
46
+ "usage: api_shit_1170_api_keys_post.ts [--base-url <url>] --accounts <file.json>",
47
+ );
48
+ process.exit(1);
49
+ }
50
+
51
+ const raw = readFileSync(accounts_path, "utf8");
52
+ const parsed = JSON.parse(raw) as
53
+ SHIT_1170_API_KEYS_REQUEST | SHIT_1170_SIGNED_ACCOUNT[];
54
+ // the file may hold the accounts array on its own or the whole body.
55
+ const accounts = Array.isArray(parsed) ? parsed : parsed.accounts;
56
+
57
+ const keys = await api_shit_1170_api_keys_post(base_url, { accounts });
58
+
59
+ console.log(`API KEYS: ${keys.keys.length} account(s)`);
60
+ for (const entry of keys.keys) {
61
+ console.log(
62
+ ` ${entry.accountId} ${
63
+ entry.created ? "created" : "existing"
64
+ } key: ${entry.apiKey.slice(0, 8)}…`,
65
+ );
66
+ }
67
+ // ========================================
68
+ // copyright 2026 by sleet.near
@@ -0,0 +1,28 @@
1
+ // ========================================
2
+ // API_SHIT_1170_PING_GET
3
+ // runnable bin for GET /api/shit-1170/ping via middleman. the
4
+ // middleman logs the framed request + response, so this bin only adds
5
+ // a one-line summary.
6
+ //
7
+ // argv:
8
+ // bun middleman/bin/shit-1170/api_shit_1170_ping_get.ts [--base-url <url>]
9
+ // ========================================
10
+
11
+ import { api_shit_1170_ping_get } from "@huggies/shit-1170-rex-engine-middleman";
12
+ import { resolve_base_url } from "../fun/resolve_base_url";
13
+
14
+ // --- CONFIG --------------------------------------------------------
15
+ // used when no argv is supplied. the default is the local backend,
16
+ // which binds 0.0.0.0:54733 (see shit_1170_port_fun.rs).
17
+ const DEFAULT_BASE_URL = "http://127.0.0.1:54733";
18
+
19
+ // --- argv ----------------------------------------------------------
20
+ // argv[0] is bun, argv[1] is this script, so real args start at 2.
21
+ const argv = process.argv.slice(2);
22
+ const base_url = resolve_base_url(argv, DEFAULT_BASE_URL);
23
+
24
+ const ping = await api_shit_1170_ping_get(base_url);
25
+
26
+ console.log("PING", ping.ok ? "ok" : "not ok", `app: ${ping.app}`);
27
+ // ========================================
28
+ // copyright 2026 by sleet.near
@@ -0,0 +1,81 @@
1
+ // ========================================
2
+ // API_SHIT_1170_SWAP_QUEUE_ACCOUNTS_DELETE
3
+ // runnable bin for DELETE
4
+ // /api/shit-1170/swap-queue/{swap_id}/accounts/{account_id} via
5
+ // middleman. the middleman logs the framed request + response, so this
6
+ // bin only adds a summary.
7
+ //
8
+ // the account removed is ALWAYS the one the api key belongs to — the
9
+ // backend refuses anybody else. so the bin takes the account id and
10
+ // checks it against the key's own answer, and says so when they differ.
11
+ //
12
+ // bun middleman/bin/shit-1170/api_shit_1170_swap_queue_accounts_delete.ts \
13
+ // --api-key shit_1170_abc123... \
14
+ // --swap-id 8f14e45f-ceea-467a-9b0d-2b1c2e6c1a11 \
15
+ // --account-id alice.near
16
+ // ========================================
17
+
18
+ import {
19
+ api_shit_1170_swap_queue_accounts_delete,
20
+ api_shit_1170_api_key_me_get,
21
+ } from "@huggies/shit-1170-rex-engine-middleman";
22
+ import { resolve_base_url } from "../fun/resolve_base_url";
23
+ import { split_argv } from "../fun/split_argv";
24
+
25
+ // --- CONFIG --------------------------------------------------------
26
+ // used when no argv is supplied. the default is the local backend,
27
+ // which binds 0.0.0.0:54733 (see shit_1170_port_fun.rs).
28
+ const DEFAULT_BASE_URL = "http://127.0.0.1:54733";
29
+
30
+ // the flags of this bin that take no value.
31
+ const BOOLEAN_FLAGS: string[] = [];
32
+
33
+ // --- argv ----------------------------------------------------------
34
+ // argv[0] is bun, argv[1] is this script, so real args start at 2.
35
+ const argv = process.argv.slice(2);
36
+
37
+ const { flags } = split_argv(argv, { boolean_flags: BOOLEAN_FLAGS });
38
+
39
+ // --- WHY --- the base url is resolved from the raw argv rather than
40
+ // the split result: split_argv would put --base-url in the flags map,
41
+ // and reading the raw argv keeps one rule for the url: it is never a
42
+ // positional.
43
+ const base_url = resolve_base_url(argv, DEFAULT_BASE_URL);
44
+
45
+ const swap_id = flags.get("--swap-id");
46
+ const account_id = flags.get("--account-id");
47
+ if (swap_id === undefined || account_id === undefined) {
48
+ console.error(
49
+ "usage: api_shit_1170_swap_queue_accounts_delete.ts [--base-url <url>] " +
50
+ "--api-key <key> --swap-id <id> --account-id <account_id>",
51
+ );
52
+ process.exit(1);
53
+ }
54
+
55
+ const api_key = flags.get("--api-key");
56
+
57
+ // --- WHY --- the account is CHECKED against the key here: the backend
58
+ // refuses to remove anybody but the key's own account, and a 403 says
59
+ // less than saying which account the key really belongs to.
60
+ const me = await api_shit_1170_api_key_me_get(base_url, { api_key });
61
+ if (me.accountId !== account_id) {
62
+ console.error(
63
+ `api_shit_1170_swap_queue_accounts_delete: the api key belongs to ${me.accountId}, ` +
64
+ `not to ${account_id} — you may only remove yourself`,
65
+ );
66
+ process.exit(1);
67
+ }
68
+
69
+ const swap = await api_shit_1170_swap_queue_accounts_delete(
70
+ base_url,
71
+ swap_id,
72
+ account_id,
73
+ { api_key },
74
+ );
75
+
76
+ console.log(`SWAP QUEUE ${swap.swapId}: ${swap.accounts.length} account(s)`);
77
+ for (const account of swap.accounts) {
78
+ console.log(` ${account.accountId} ${account.status}`);
79
+ }
80
+ // ========================================
81
+ // copyright 2026 by sleet.near
@@ -0,0 +1,80 @@
1
+ // ========================================
2
+ // API_SHIT_1170_SWAP_QUEUE_ACCOUNTS_POST
3
+ // runnable bin for POST /api/shit-1170/swap-queue/{swap_id}/accounts via
4
+ // middleman. the middleman logs the framed request + response, so this
5
+ // bin only adds a summary.
6
+ //
7
+ // the account added is ALWAYS the one the api key belongs to — the
8
+ // backend refuses anybody else. so the bin takes the account id and
9
+ // checks it against the key's own answer, and says so when they differ.
10
+ //
11
+ // bun middleman/bin/shit-1170/api_shit_1170_swap_queue_accounts_post.ts \
12
+ // --api-key shit_1170_abc123... \
13
+ // --swap-id 8f14e45f-ceea-467a-9b0d-2b1c2e6c1a11 \
14
+ // --account-id alice.near
15
+ // ========================================
16
+
17
+ import {
18
+ api_shit_1170_swap_queue_accounts_post,
19
+ api_shit_1170_api_key_me_get,
20
+ } from "@huggies/shit-1170-rex-engine-middleman";
21
+ import { resolve_base_url } from "../fun/resolve_base_url";
22
+ import { split_argv } from "../fun/split_argv";
23
+
24
+ // --- CONFIG --------------------------------------------------------
25
+ // used when no argv is supplied. the default is the local backend,
26
+ // which binds 0.0.0.0:54733 (see shit_1170_port_fun.rs).
27
+ const DEFAULT_BASE_URL = "http://127.0.0.1:54733";
28
+
29
+ // the flags of this bin that take no value.
30
+ const BOOLEAN_FLAGS: string[] = [];
31
+
32
+ // --- argv ----------------------------------------------------------
33
+ // argv[0] is bun, argv[1] is this script, so real args start at 2.
34
+ const argv = process.argv.slice(2);
35
+
36
+ const { flags } = split_argv(argv, { boolean_flags: BOOLEAN_FLAGS });
37
+
38
+ // --- WHY --- the base url is resolved from the raw argv rather than
39
+ // the split result: split_argv would put --base-url in the flags map,
40
+ // and reading the raw argv keeps one rule for the url: it is never a
41
+ // positional.
42
+ const base_url = resolve_base_url(argv, DEFAULT_BASE_URL);
43
+
44
+ const swap_id = flags.get("--swap-id");
45
+ const account_id = flags.get("--account-id");
46
+ if (swap_id === undefined || account_id === undefined) {
47
+ console.error(
48
+ "usage: api_shit_1170_swap_queue_accounts_post.ts [--base-url <url>] " +
49
+ "--api-key <key> --swap-id <id> --account-id <account_id>",
50
+ );
51
+ process.exit(1);
52
+ }
53
+
54
+ const api_key = flags.get("--api-key");
55
+
56
+ // --- WHY --- the account is CHECKED against the key here: the backend
57
+ // refuses to add anybody but the key's own account, and a 403 says less
58
+ // than saying which account the key really belongs to.
59
+ const me = await api_shit_1170_api_key_me_get(base_url, { api_key });
60
+ if (me.accountId !== account_id) {
61
+ console.error(
62
+ `api_shit_1170_swap_queue_accounts_post: the api key belongs to ${me.accountId}, ` +
63
+ `not to ${account_id} — you may only add yourself`,
64
+ );
65
+ process.exit(1);
66
+ }
67
+
68
+ const swap = await api_shit_1170_swap_queue_accounts_post(
69
+ base_url,
70
+ swap_id,
71
+ { accountId: account_id },
72
+ { api_key },
73
+ );
74
+
75
+ console.log(`SWAP QUEUE ${swap.swapId}: ${swap.accounts.length} account(s)`);
76
+ for (const account of swap.accounts) {
77
+ console.log(` ${account.accountId} ${account.status}`);
78
+ }
79
+ // ========================================
80
+ // copyright 2026 by sleet.near
@@ -0,0 +1,91 @@
1
+ // ========================================
2
+ // API_SHIT_1170_SWAP_QUEUE_GET
3
+ // runnable bin for GET /api/shit-1170/swap-queue via middleman. the
4
+ // middleman logs the framed request + response, so this bin only adds
5
+ // a summary.
6
+ //
7
+ // bun middleman/bin/shit-1170/api_shit_1170_swap_queue_get.ts \
8
+ // --api-key shit_1170_abc123... \
9
+ // --limit 50
10
+ //
11
+ // the filters:
12
+ // --account-id only the swaps these accounts are on, comma separated
13
+ // --hide-sent with the account, drop the ones it has already sent
14
+ // --token-in only the swaps that sell this token
15
+ // --token-out only the swaps that buy this token
16
+ // --limit how many to return
17
+ // --cursor where the page starts, default the first page
18
+ //
19
+ // --- WHY --- `--hide-sent` NEEDS `--account-id`: "has this account sent
20
+ // it" is a question about ONE account, and the backend answers a 400
21
+ // for the filter without one.
22
+ //
23
+ // --- WHY --- --cursor and not --offset: the page is walked by a cursor
24
+ // the backend hands out, and the cursor is opaque. there is no offset
25
+ // to ask for, and the bin prints the next cursor so the next page can
26
+ // be fetched with it.
27
+ // ========================================
28
+
29
+ import { api_shit_1170_swap_queue_get } from "@huggies/shit-1170-rex-engine-middleman";
30
+ import { resolve_base_url } from "../fun/resolve_base_url";
31
+ import { split_argv } from "../fun/split_argv";
32
+
33
+ // --- CONFIG --------------------------------------------------------
34
+ // used when no argv is supplied. the default is the local backend,
35
+ // which binds 0.0.0.0:54733 (see shit_1170_port_fun.rs).
36
+ const DEFAULT_BASE_URL = "http://127.0.0.1:54733";
37
+
38
+ // the flags of this bin that take no value.
39
+ const BOOLEAN_FLAGS: string[] = ["--hide-sent"];
40
+
41
+ // --- argv ----------------------------------------------------------
42
+ // argv[0] is bun, argv[1] is this script, so real args start at 2.
43
+ const argv = process.argv.slice(2);
44
+
45
+ const { flags, seen } = split_argv(argv, { boolean_flags: BOOLEAN_FLAGS });
46
+
47
+ // --- WHY --- the base url is resolved from the raw argv rather than
48
+ // the split result: split_argv would put --base-url in the flags map,
49
+ // and reading the raw argv keeps one rule for the url: it is never a
50
+ // positional.
51
+ const base_url = resolve_base_url(argv, DEFAULT_BASE_URL);
52
+
53
+ const limit_raw = flags.get("--limit");
54
+ let limit: number | undefined;
55
+ if (limit_raw !== undefined) {
56
+ const parsed = Number(limit_raw);
57
+ if (!Number.isFinite(parsed)) {
58
+ console.error(
59
+ `api_shit_1170_swap_queue_get: --limit must be a number: ${limit_raw}`,
60
+ );
61
+ process.exit(1);
62
+ }
63
+ limit = parsed;
64
+ }
65
+
66
+ const cursor = flags.get("--cursor");
67
+
68
+ const list = await api_shit_1170_swap_queue_get(
69
+ base_url,
70
+ {
71
+ account_id: flags.get("--account-id"),
72
+ hide_sent: seen.has("--hide-sent"),
73
+ token_in: flags.get("--token-in"),
74
+ token_out: flags.get("--token-out"),
75
+ limit,
76
+ cursor,
77
+ },
78
+ { api_key: flags.get("--api-key") },
79
+ );
80
+
81
+ console.log(`SWAP QUEUE: ${list.items.length} of ${list.total}`);
82
+ for (const swap of list.items) {
83
+ console.log(
84
+ ` ${swap.swapId} ${swap.tokenIn} -> ${swap.tokenOut} ` +
85
+ `in ${swap.amountIn} out ${swap.amountOut ?? "(no quote)"} ` +
86
+ `${swap.accounts.length} account(s)`,
87
+ );
88
+ }
89
+ console.log(`NEXT CURSOR: ${list.nextCursor ?? "(last page)"}`);
90
+ // ========================================
91
+ // copyright 2026 by sleet.near
@@ -0,0 +1,62 @@
1
+ // ========================================
2
+ // API_SHIT_1170_SWAP_QUEUE_ONE_GET
3
+ // runnable bin for GET /api/shit-1170/swap-queue/{swap_id} via
4
+ // middleman. the middleman logs the framed request + response, so this
5
+ // bin only adds a summary.
6
+ //
7
+ // bun middleman/bin/shit-1170/api_shit_1170_swap_queue_one_get.ts \
8
+ // --api-key shit_1170_abc123... \
9
+ // --swap-id 8f14e45f-ceea-467a-9b0d-2b1c2e6c1a11
10
+ // ========================================
11
+
12
+ import { api_shit_1170_swap_queue_one_get } from "@huggies/shit-1170-rex-engine-middleman";
13
+ import { resolve_base_url } from "../fun/resolve_base_url";
14
+ import { split_argv } from "../fun/split_argv";
15
+
16
+ // --- CONFIG --------------------------------------------------------
17
+ // used when no argv is supplied. the default is the local backend,
18
+ // which binds 0.0.0.0:54733 (see shit_1170_port_fun.rs).
19
+ const DEFAULT_BASE_URL = "http://127.0.0.1:54733";
20
+
21
+ // the flags of this bin that take no value.
22
+ const BOOLEAN_FLAGS: string[] = [];
23
+
24
+ // --- argv ----------------------------------------------------------
25
+ // argv[0] is bun, argv[1] is this script, so real args start at 2.
26
+ const argv = process.argv.slice(2);
27
+
28
+ const { flags } = split_argv(argv, { boolean_flags: BOOLEAN_FLAGS });
29
+
30
+ // --- WHY --- the base url is resolved from the raw argv rather than
31
+ // the split result: split_argv would put --base-url in the flags map,
32
+ // and reading the raw argv keeps one rule for the url: it is never a
33
+ // positional.
34
+ const base_url = resolve_base_url(argv, DEFAULT_BASE_URL);
35
+
36
+ const swap_id = flags.get("--swap-id");
37
+ if (swap_id === undefined) {
38
+ console.error(
39
+ "usage: api_shit_1170_swap_queue_one_get.ts [--base-url <url>] --api-key <key> --swap-id <id>",
40
+ );
41
+ process.exit(1);
42
+ }
43
+
44
+ const swap = await api_shit_1170_swap_queue_one_get(base_url, swap_id, {
45
+ api_key: flags.get("--api-key"),
46
+ });
47
+
48
+ console.log(`SWAP QUEUE ${swap.swapId}: ${swap.tokenIn} -> ${swap.tokenOut}`);
49
+ console.log(` what: ${swap.what ?? "(none)"}`);
50
+ console.log(` when: ${swap.when ?? "(none)"}`);
51
+ console.log(` why: ${swap.why ?? "(none)"}`);
52
+ console.log(` amount in: ${swap.amountIn}`);
53
+ console.log(` amount out: ${swap.amountOut ?? "(no quote)"}`);
54
+ console.log(` dex: ${swap.dexId ?? "(none)"}`);
55
+ for (const account of swap.accounts) {
56
+ console.log(
57
+ ` ${account.accountId} ${account.status} ${account.txHash ?? "(no hash)"} ` +
58
+ `out ${account.amountOut ?? "(unknown)"}`,
59
+ );
60
+ }
61
+ // ========================================
62
+ // copyright 2026 by sleet.near
@@ -0,0 +1,118 @@
1
+ // ========================================
2
+ // API_SHIT_1170_SWAP_QUEUE_POST
3
+ // runnable bin for POST /api/shit-1170/swap-queue via middleman. the
4
+ // middleman logs the framed request + response, so this bin only adds
5
+ // a summary.
6
+ //
7
+ // a queued swap is NOT a queued batch of transactions: the agent does
8
+ // not know the route. it names the token in, the amount in and the token
9
+ // out, and the route is worked out when the swap is executed.
10
+ //
11
+ // bun middleman/bin/shit-1170/api_shit_1170_swap_queue_post.ts \
12
+ // --api-key shit_1170_abc123... \
13
+ // --token-in usdt.tether-token.near \
14
+ // --amount-in 100000000 \
15
+ // --token-out near \
16
+ // --what "swap 100 USDC for NEAR" \
17
+ // --why "you asked for it" \
18
+ // --account alice.near
19
+ //
20
+ // --- WHY --- the amount in is the RAW unit amount and not a human
21
+ // amount: the chain and the router trade the token's smallest unit, and
22
+ // a human amount only means something next to the token it belongs to.
23
+ // ========================================
24
+
25
+ import { api_shit_1170_swap_queue_post } from "@huggies/shit-1170-rex-engine-middleman";
26
+ import { resolve_base_url } from "../fun/resolve_base_url";
27
+ import { split_argv } from "../fun/split_argv";
28
+
29
+ // --- CONFIG --------------------------------------------------------
30
+ // used when no argv is supplied. the default is the local backend,
31
+ // which binds 0.0.0.0:54733 (see shit_1170_port_fun.rs).
32
+ const DEFAULT_BASE_URL = "http://127.0.0.1:54733";
33
+
34
+ // the flags of this bin that take no value.
35
+ const BOOLEAN_FLAGS: string[] = [];
36
+
37
+ // --- argv ----------------------------------------------------------
38
+ // argv[0] is bun, argv[1] is this script, so real args start at 2.
39
+ const argv = process.argv.slice(2);
40
+
41
+ const { flags } = split_argv(argv, { boolean_flags: BOOLEAN_FLAGS });
42
+
43
+ // --- WHY --- the base url is resolved from the raw argv rather than
44
+ // the split result: split_argv would put --base-url in the flags map,
45
+ // and reading the raw argv keeps one rule for the url: it is never a
46
+ // positional.
47
+ const base_url = resolve_base_url(argv, DEFAULT_BASE_URL);
48
+
49
+ const token_in = flags.get("--token-in");
50
+ const amount_in = flags.get("--amount-in");
51
+ const token_out = flags.get("--token-out");
52
+ if (
53
+ token_in === undefined ||
54
+ amount_in === undefined ||
55
+ token_out === undefined
56
+ ) {
57
+ console.error(
58
+ "usage: api_shit_1170_swap_queue_post.ts [--base-url <url>] --api-key <key> " +
59
+ "--token-in <id> --amount-in <raw> --token-out <id> " +
60
+ "[--amount-out <raw>] [--dex-id <dex>] [--what <text>] [--when <text>] " +
61
+ "[--why <text>] [--when-at <ms>] [--account <account_id> ...]",
62
+ );
63
+ process.exit(1);
64
+ }
65
+
66
+ // the WHO — the accounts this swap is for. each one must be an account
67
+ // the api key belongs to.
68
+ const accounts: string[] = [];
69
+ for (let i = 0; i < argv.length; i++) {
70
+ const token = argv[i];
71
+ if (token === undefined) continue;
72
+ const value = argv[i + 1];
73
+ if (value === undefined || value.startsWith("--")) continue;
74
+ if (token === "--account") {
75
+ accounts.push(value);
76
+ i++;
77
+ }
78
+ }
79
+
80
+ const when_at_raw = flags.get("--when-at");
81
+ let when_at: number | undefined;
82
+ if (when_at_raw !== undefined) {
83
+ const parsed = Number(when_at_raw);
84
+ if (!Number.isFinite(parsed)) {
85
+ console.error(
86
+ `api_shit_1170_swap_queue_post: --when-at must be a number of milliseconds: ${when_at_raw}`,
87
+ );
88
+ process.exit(1);
89
+ }
90
+ when_at = parsed;
91
+ }
92
+
93
+ const swap = await api_shit_1170_swap_queue_post(
94
+ base_url,
95
+ {
96
+ what: flags.get("--what"),
97
+ when: flags.get("--when"),
98
+ why: flags.get("--why"),
99
+ whenAt: when_at,
100
+ tokenIn: token_in,
101
+ amountIn: amount_in,
102
+ tokenOut: token_out,
103
+ amountOut: flags.get("--amount-out"),
104
+ dexId: flags.get("--dex-id"),
105
+ accounts: accounts.length > 0 ? accounts : undefined,
106
+ },
107
+ { api_key: flags.get("--api-key") },
108
+ );
109
+
110
+ console.log(
111
+ `SWAP QUEUE: ${swap.swapId} ${swap.tokenIn} -> ${swap.tokenOut} ` +
112
+ `amount in ${swap.amountIn}, amount out ${swap.amountOut ?? "(no quote)"}`,
113
+ );
114
+ console.log(
115
+ ` accounts: ${swap.accounts.map((one) => one.accountId).join(", ") || "(none)"}`,
116
+ );
117
+ // ========================================
118
+ // copyright 2026 by sleet.near
@@ -0,0 +1,87 @@
1
+ // ========================================
2
+ // API_SHIT_1170_SWAP_QUEUE_SENT_POST
3
+ // runnable bin for POST /api/shit-1170/swap-queue/{swap_id}/sent via
4
+ // middleman. the middleman logs the framed request + response, so this
5
+ // bin only adds a summary.
6
+ //
7
+ // THIS is the route the swap page calls after it executes a queued swap,
8
+ // so the swap's status moves from `pending` to `sent` to `succeeded` or
9
+ // `failed`.
10
+ //
11
+ // bun middleman/bin/shit-1170/api_shit_1170_swap_queue_sent_post.ts \
12
+ // --api-key shit_1170_abc123... \
13
+ // --swap-id 8f14e45f-ceea-467a-9b0d-2b1c2e6c1a11 \
14
+ // --tx-hash 9t6w... \
15
+ // --status succeeded \
16
+ // --amount-out 4999000000000000000000000
17
+ //
18
+ // --- WHY --- the status is OPTIONAL: without it the status is `sent`,
19
+ // which means "it went out and nobody knows how it went yet".
20
+ // ========================================
21
+
22
+ import { api_shit_1170_swap_queue_sent_post } from "@huggies/shit-1170-rex-engine-middleman";
23
+ import { resolve_base_url } from "../fun/resolve_base_url";
24
+ import { split_argv } from "../fun/split_argv";
25
+
26
+ // --- CONFIG --------------------------------------------------------
27
+ // used when no argv is supplied. the default is the local backend,
28
+ // which binds 0.0.0.0:54733 (see shit_1170_port_fun.rs).
29
+ const DEFAULT_BASE_URL = "http://127.0.0.1:54733";
30
+
31
+ // the flags of this bin that take no value.
32
+ const BOOLEAN_FLAGS: string[] = [];
33
+
34
+ // --- argv ----------------------------------------------------------
35
+ // argv[0] is bun, argv[1] is this script, so real args start at 2.
36
+ const argv = process.argv.slice(2);
37
+
38
+ const { flags } = split_argv(argv, { boolean_flags: BOOLEAN_FLAGS });
39
+
40
+ // --- WHY --- the base url is resolved from the raw argv rather than
41
+ // the split result: split_argv would put --base-url in the flags map,
42
+ // and reading the raw argv keeps one rule for the url: it is never a
43
+ // positional.
44
+ const base_url = resolve_base_url(argv, DEFAULT_BASE_URL);
45
+
46
+ const swap_id = flags.get("--swap-id");
47
+ const tx_hash = flags.get("--tx-hash");
48
+ if (swap_id === undefined || tx_hash === undefined) {
49
+ console.error(
50
+ "usage: api_shit_1170_swap_queue_sent_post.ts [--base-url <url>] " +
51
+ "--api-key <key> --swap-id <id> --tx-hash <hash> " +
52
+ "[--status succeeded|failed] [--amount-out <raw>]",
53
+ );
54
+ process.exit(1);
55
+ }
56
+
57
+ // --- WHY --- the status is CHECKED here: the backend refuses anything
58
+ // but `succeeded` and `failed`, and a 400 says less than naming the
59
+ // word that is wrong.
60
+ const status = flags.get("--status");
61
+ if (status !== undefined && status !== "succeeded" && status !== "failed") {
62
+ console.error(
63
+ `api_shit_1170_swap_queue_sent_post: --status must be succeeded or failed, not ${status}`,
64
+ );
65
+ process.exit(1);
66
+ }
67
+
68
+ const swap = await api_shit_1170_swap_queue_sent_post(
69
+ base_url,
70
+ swap_id,
71
+ {
72
+ txHash: tx_hash,
73
+ status,
74
+ amountOut: flags.get("--amount-out"),
75
+ },
76
+ { api_key: flags.get("--api-key") },
77
+ );
78
+
79
+ console.log(`SWAP QUEUE ${swap.swapId}: ${swap.accounts.length} account(s)`);
80
+ for (const account of swap.accounts) {
81
+ console.log(
82
+ ` ${account.accountId} ${account.status} ${account.txHash ?? "(no hash)"} ` +
83
+ `out ${account.amountOut ?? "(unknown)"}`,
84
+ );
85
+ }
86
+ // ========================================
87
+ // copyright 2026 by sleet.near