@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_TX_QUEUE_ACCOUNTS_DELETE
3
+ // runnable bin for DELETE /api/shit-1170/tx-queue/{queue_id}/accounts/
4
+ // {account_id} via middleman. the middleman logs the framed request +
5
+ // response, so this bin only adds a summary.
6
+ //
7
+ // bun middleman/bin/shit-1170/api_shit_1170_tx_queue_accounts_delete.ts \
8
+ // --api-key shit_1170_abc123... \
9
+ // --queue-id 8f14e45f-ceea-467a-9b0d-2b1c2e6c1a11 \
10
+ // --account-id alice.near
11
+ //
12
+ // --- WHY --- the account id is a flag and not a positional: the
13
+ // account has to be the one the api key belongs to, and naming it
14
+ // next to the key says so.
15
+ //
16
+ // --- WHY --- the request carries NO BODY: the account to remove is in
17
+ // the path, and the api key in the header says who is asking.
18
+ // ========================================
19
+
20
+ import { api_shit_1170_tx_queue_accounts_delete } 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
+ const { flags } = split_argv(argv, { boolean_flags: BOOLEAN_FLAGS });
36
+
37
+ // --- WHY --- the base url is resolved from the raw argv rather than
38
+ // the split result: split_argv would put --base-url in the flags map,
39
+ // and reading the raw argv keeps one rule for the url: it is never a
40
+ // positional.
41
+ const base_url = resolve_base_url(argv, DEFAULT_BASE_URL);
42
+
43
+ const queue_id = flags.get("--queue-id");
44
+ const account_id = flags.get("--account-id");
45
+ if (queue_id === undefined || account_id === undefined) {
46
+ console.error(
47
+ "usage: api_shit_1170_tx_queue_accounts_delete.ts [--base-url <url>] " +
48
+ "--api-key <key> --queue-id <id> --account-id <account_id>",
49
+ );
50
+ process.exit(1);
51
+ }
52
+
53
+ const queue = await api_shit_1170_tx_queue_accounts_delete(
54
+ base_url,
55
+ queue_id,
56
+ account_id,
57
+ { api_key: flags.get("--api-key") },
58
+ );
59
+
60
+ console.log(
61
+ `TX QUEUE ${queue.queueId}: ${queue.transactions.length} transaction(s), ` +
62
+ `${queue.accounts.length} account(s)`,
63
+ );
64
+ for (const account of queue.accounts) {
65
+ console.log(` ${account.accountId} ${account.status}`);
66
+ }
67
+ // ========================================
68
+ // copyright 2026 by sleet.near
@@ -0,0 +1,65 @@
1
+ // ========================================
2
+ // API_SHIT_1170_TX_QUEUE_ACCOUNTS_POST
3
+ // runnable bin for POST /api/shit-1170/tx-queue/{queue_id}/accounts 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_tx_queue_accounts_post.ts \
8
+ // --api-key shit_1170_abc123... \
9
+ // --queue-id 8f14e45f-ceea-467a-9b0d-2b1c2e6c1a11 \
10
+ // --account-id alice.near
11
+ //
12
+ // --- WHY --- the account id is a flag and not a positional: the
13
+ // account has to be the one the api key belongs to, and naming it
14
+ // next to the key says so.
15
+ // ========================================
16
+
17
+ import { api_shit_1170_tx_queue_accounts_post } from "@huggies/shit-1170-rex-engine-middleman";
18
+ import { resolve_base_url } from "../fun/resolve_base_url";
19
+ import { split_argv } from "../fun/split_argv";
20
+
21
+ // --- CONFIG --------------------------------------------------------
22
+ // used when no argv is supplied. the default is the local backend,
23
+ // which binds 0.0.0.0:54733 (see shit_1170_port_fun.rs).
24
+ const DEFAULT_BASE_URL = "http://127.0.0.1:54733";
25
+
26
+ // the flags of this bin that take no value.
27
+ const BOOLEAN_FLAGS: string[] = [];
28
+
29
+ // --- argv ----------------------------------------------------------
30
+ // argv[0] is bun, argv[1] is this script, so real args start at 2.
31
+ const argv = process.argv.slice(2);
32
+ const { flags } = split_argv(argv, { boolean_flags: BOOLEAN_FLAGS });
33
+
34
+ // --- WHY --- the base url is resolved from the raw argv rather than
35
+ // the split result: split_argv would put --base-url in the flags map,
36
+ // and reading the raw argv keeps one rule for the url: it is never a
37
+ // positional.
38
+ const base_url = resolve_base_url(argv, DEFAULT_BASE_URL);
39
+
40
+ const queue_id = flags.get("--queue-id");
41
+ const account_id = flags.get("--account-id");
42
+ if (queue_id === undefined || account_id === undefined) {
43
+ console.error(
44
+ "usage: api_shit_1170_tx_queue_accounts_post.ts [--base-url <url>] " +
45
+ "--api-key <key> --queue-id <id> --account-id <account_id>",
46
+ );
47
+ process.exit(1);
48
+ }
49
+
50
+ const queue = await api_shit_1170_tx_queue_accounts_post(
51
+ base_url,
52
+ queue_id,
53
+ { accountId: account_id },
54
+ { api_key: flags.get("--api-key") },
55
+ );
56
+
57
+ console.log(
58
+ `TX QUEUE ${queue.queueId}: ${queue.transactions.length} transaction(s), ` +
59
+ `${queue.accounts.length} account(s)`,
60
+ );
61
+ for (const account of queue.accounts) {
62
+ console.log(` ${account.accountId} ${account.status}`);
63
+ }
64
+ // ========================================
65
+ // copyright 2026 by sleet.near
@@ -0,0 +1,68 @@
1
+ // ========================================
2
+ // API_SHIT_1170_TX_QUEUE_FACETS_GET
3
+ // runnable bin for GET /api/shit-1170/tx-queue/facets via middleman.
4
+ // the middleman logs the framed request + response, so this bin only
5
+ // adds a summary.
6
+ //
7
+ // bun middleman/bin/shit-1170/api_shit_1170_tx_queue_facets_get.ts \
8
+ // --limit 40
9
+ //
10
+ // the filters:
11
+ // --limit how many contracts and how many accounts, default 40
12
+ //
13
+ // --- WHY --- the bin sends NO api key: the route is open, because the
14
+ // facets are a summary of the open queue list. the key is passed when
15
+ // there is one, and it is not demanded.
16
+ //
17
+ // --- WHY --- a number flag that is not a number is named here rather
18
+ // than sent to the route to be clamped into silence.
19
+ // ========================================
20
+
21
+ import { api_shit_1170_tx_queue_facets_get } 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
+ 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 limit_raw = flags.get("--limit");
45
+ let limit: number | undefined;
46
+ if (limit_raw !== undefined) {
47
+ const parsed = Number(limit_raw);
48
+ if (!Number.isFinite(parsed)) {
49
+ console.error(`--limit must be a number: ${limit_raw}`);
50
+ process.exit(1);
51
+ }
52
+ limit = parsed;
53
+ }
54
+
55
+ const facets = await api_shit_1170_tx_queue_facets_get(base_url, { limit });
56
+
57
+ console.log(
58
+ `TX QUEUE FACETS: ${facets.contracts.length} contract(s), ` +
59
+ `${facets.accounts.length} account(s)`,
60
+ );
61
+ for (const contract of facets.contracts) {
62
+ console.log(` contract ${contract.contractId} ${contract.count}`);
63
+ }
64
+ for (const account of facets.accounts) {
65
+ console.log(` account ${account.accountId} ${account.count}`);
66
+ }
67
+ // ========================================
68
+ // copyright 2026 by sleet.near
@@ -0,0 +1,99 @@
1
+ // ========================================
2
+ // API_SHIT_1170_TX_QUEUE_GET
3
+ // runnable bin for GET /api/shit-1170/tx-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_tx_queue_get.ts \
8
+ // --api-key shit_1170_abc123... \
9
+ // --account-id alice.near \
10
+ // --hide-sent
11
+ //
12
+ // the filters:
13
+ // --account-id only the queues these accounts are on, comma separated
14
+ // --hide-sent with the account, drop the ones it has already sent
15
+ // --contract-id only the queues holding a tx for these contracts, comma separated
16
+ // --method only the queues holding a tx for this method
17
+ // --limit how many, default 50
18
+ // --cursor where the page starts, default the first page
19
+ //
20
+ // --- WHY --- --hide-sent stands alone and takes no value: it is a
21
+ // switch, and "hide sent = maybe" is not a thing.
22
+ //
23
+ // --- WHY --- the flag names are kebab-case and the query names are
24
+ // snake_case: the flag is what a person types, the query is what the
25
+ // route reads. `serde_urlencoded` matches the query key literally, so
26
+ // the snake_case spelling is the one that goes on the wire.
27
+ //
28
+ // --- WHY --- --cursor and not --offset: the page is walked by a cursor
29
+ // the backend hands out, and the cursor is opaque. there is no offset
30
+ // to ask for, and the bin prints the next cursor so the next page can
31
+ // be fetched with it.
32
+ // ========================================
33
+
34
+ import { api_shit_1170_tx_queue_get } from "@huggies/shit-1170-rex-engine-middleman";
35
+ import { resolve_base_url } from "../fun/resolve_base_url";
36
+ import { split_argv } from "../fun/split_argv";
37
+
38
+ // --- CONFIG --------------------------------------------------------
39
+ // used when no argv is supplied. the default is the local backend,
40
+ // which binds 0.0.0.0:54733 (see shit_1170_port_fun.rs).
41
+ const DEFAULT_BASE_URL = "http://127.0.0.1:54733";
42
+
43
+ // the flags of this bin that take no value.
44
+ const BOOLEAN_FLAGS = ["--hide-sent"];
45
+
46
+ // --- argv ----------------------------------------------------------
47
+ // argv[0] is bun, argv[1] is this script, so real args start at 2.
48
+ const argv = process.argv.slice(2);
49
+ const { flags, seen } = split_argv(argv, { boolean_flags: BOOLEAN_FLAGS });
50
+
51
+ // --- WHY --- the base url is resolved from the raw argv rather than
52
+ // the split result: split_argv would put --base-url in the flags map,
53
+ // and reading the raw argv keeps one rule for the url: it is never a
54
+ // positional.
55
+ const base_url = resolve_base_url(argv, DEFAULT_BASE_URL);
56
+
57
+ // --- THE NUMBERS -------------------------
58
+ // a number flag that is not a number is a typo, and it is named here
59
+ // rather than sent to the route to be clamped into silence.
60
+ function number_flag_fun(name: string): number | undefined {
61
+ const raw = flags.get(name);
62
+ if (raw === undefined) return undefined;
63
+ const parsed = Number(raw);
64
+ if (!Number.isFinite(parsed)) {
65
+ console.error(`${name} must be a number: ${raw}`);
66
+ process.exit(1);
67
+ }
68
+ return parsed;
69
+ }
70
+
71
+ const limit = number_flag_fun("--limit");
72
+ const cursor = flags.get("--cursor");
73
+
74
+ const list = await api_shit_1170_tx_queue_get(
75
+ base_url,
76
+ {
77
+ account_id: flags.get("--account-id"),
78
+ hide_sent: seen.has("--hide-sent") ? true : undefined,
79
+ contract_id: flags.get("--contract-id"),
80
+ method: flags.get("--method"),
81
+ limit,
82
+ cursor,
83
+ },
84
+ { api_key: flags.get("--api-key") },
85
+ );
86
+
87
+ console.log(`TX QUEUE LIST: ${list.items.length} of ${list.total} queue(s)`);
88
+ for (const queue of list.items) {
89
+ console.log(
90
+ ` ${queue.queueId} ${queue.transactions.length} tx ` +
91
+ `${queue.accounts.length} account(s) ${queue.what ?? "(no what)"}`,
92
+ );
93
+ for (const account of queue.accounts) {
94
+ console.log(` ${account.accountId} ${account.status}`);
95
+ }
96
+ }
97
+ console.log(`NEXT CURSOR: ${list.nextCursor ?? "(last page)"}`);
98
+ // ========================================
99
+ // copyright 2026 by sleet.near
@@ -0,0 +1,67 @@
1
+ // ========================================
2
+ // API_SHIT_1170_TX_QUEUE_ONE_GET
3
+ // runnable bin for GET /api/shit-1170/tx-queue/{queue_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_tx_queue_one_get.ts \
8
+ // --api-key shit_1170_abc123... \
9
+ // --queue-id 8f14e45f-ceea-467a-9b0d-2b1c2e6c1a11
10
+ // ========================================
11
+
12
+ import { api_shit_1170_tx_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
+ const { flags } = split_argv(argv, { boolean_flags: BOOLEAN_FLAGS });
28
+
29
+ // --- WHY --- the base url is resolved from the raw argv rather than
30
+ // the split result: split_argv would put --base-url in the flags map,
31
+ // and reading the raw argv keeps one rule for the url: it is never a
32
+ // positional.
33
+ const base_url = resolve_base_url(argv, DEFAULT_BASE_URL);
34
+
35
+ const queue_id = flags.get("--queue-id");
36
+ if (queue_id === undefined) {
37
+ console.error(
38
+ "usage: api_shit_1170_tx_queue_one_get.ts [--base-url <url>] --api-key <key> --queue-id <id>",
39
+ );
40
+ process.exit(1);
41
+ }
42
+
43
+ const queue = await api_shit_1170_tx_queue_one_get(base_url, queue_id, {
44
+ api_key: flags.get("--api-key"),
45
+ });
46
+
47
+ console.log(
48
+ `TX QUEUE ${queue.queueId}: ${queue.transactions.length} transaction(s), ` +
49
+ `${queue.accounts.length} account(s)`,
50
+ );
51
+ console.log(` what: ${queue.what ?? "(none)"}`);
52
+ console.log(` when: ${queue.when ?? "(none)"}`);
53
+ console.log(` why: ${queue.why ?? "(none)"}`);
54
+ for (const transaction of queue.transactions) {
55
+ console.log(
56
+ ` #${transaction.position} ${transaction.contractId}.${transaction.method}` +
57
+ ` tx: ${transaction.txId}`,
58
+ );
59
+ console.log(` args: ${JSON.stringify(transaction.args)}`);
60
+ for (const account of transaction.accounts) {
61
+ console.log(
62
+ ` ${account.accountId} ${account.status} ${account.txHash ?? "(no hash)"}`,
63
+ );
64
+ }
65
+ }
66
+ // ========================================
67
+ // copyright 2026 by sleet.near
@@ -0,0 +1,243 @@
1
+ // ========================================
2
+ // API_SHIT_1170_TX_QUEUE_POST
3
+ // runnable bin for POST /api/shit-1170/tx-queue via middleman. the
4
+ // middleman logs the framed request + response, so this bin only adds
5
+ // a summary.
6
+ //
7
+ // a queue_id is a BATCH of transactions. one flag per transaction, in
8
+ // the order the flags are given, and that order is the order the
9
+ // wallet signs them in:
10
+ //
11
+ // bun middleman/bin/shit-1170/api_shit_1170_tx_queue_post.ts \
12
+ // --api-key shit_1170_abc123... \
13
+ // --contract-id ref.finance.near \
14
+ // --method ft_swap \
15
+ // --args '{"receiver_id":"alice.near"}' \
16
+ // --contract-id ref.finance.near \
17
+ // --method ft_resolve_transfer \
18
+ // --args '{"receiver_id":"alice.near"}' \
19
+ // --what "swap 100 USDC for NEAR" \
20
+ // --why "you asked for it" \
21
+ // --account alice.near
22
+ //
23
+ // --- WHY --- the bin takes --contract-id over and over and not a json
24
+ // file: a file is tidier for a batch of five and harder for the common
25
+ // case of one. the flag repeats, and the order is the order.
26
+ //
27
+ // --- WHY --- the argv is scanned RAW and not through split_argv: the
28
+ // flags that repeat have to keep their ORDER, and a Map of
29
+ // last-write-wins would lose every transaction but the last. so the
30
+ // transaction flags are collected here, in the order they appear, and
31
+ // the single-valued flags are read with split_argv.
32
+ //
33
+ // --- WHY --- the flags of one transaction are matched by POSITION and
34
+ // not by name: a transaction is one contract, one method, one args, one
35
+ // gas and one deposit. the nth --contract-id, the nth --method and the
36
+ // nth --args are the nth transaction. that is what lets a caller leave
37
+ // --gas or --deposit off one call and on the next.
38
+ // ========================================
39
+
40
+ import {
41
+ api_shit_1170_tx_queue_post,
42
+ type SHIT_1170_TX_QUEUE_TRANSACTION_REQUEST,
43
+ } from "@huggies/shit-1170-rex-engine-middleman";
44
+ import { resolve_base_url } from "../fun/resolve_base_url";
45
+ import { split_argv } from "../fun/split_argv";
46
+
47
+ // --- CONFIG --------------------------------------------------------
48
+ // used when no argv is supplied. the default is the local backend,
49
+ // which binds 0.0.0.0:54733 (see shit_1170_port_fun.rs).
50
+ const DEFAULT_BASE_URL = "http://127.0.0.1:54733";
51
+
52
+ // the flags that name the pieces of ONE transaction, in the order they
53
+ // are collected.
54
+ const TRANSACTION_FLAGS = [
55
+ "--contract-id",
56
+ "--method",
57
+ "--args",
58
+ "--gas",
59
+ "--deposit",
60
+ ] as const;
61
+
62
+ // the flags that take no value.
63
+ const BOOLEAN_FLAGS: string[] = [];
64
+
65
+ // --- argv ----------------------------------------------------------
66
+ // argv[0] is bun, argv[1] is this script, so real args start at 2.
67
+ const argv = process.argv.slice(2);
68
+
69
+ const { flags } = split_argv(argv, { boolean_flags: BOOLEAN_FLAGS });
70
+
71
+ // --- WHY --- the base url is resolved from the raw argv rather than
72
+ // the split result: split_argv would put --base-url in the flags map,
73
+ // and reading the raw argv keeps one rule for the url: it is never a
74
+ // positional.
75
+ const base_url = resolve_base_url(argv, DEFAULT_BASE_URL);
76
+
77
+ // --- THE BATCH ---------------------------
78
+ // the transactions, in the order the flags were given.
79
+ //
80
+ // --- WHY --- the scan is over the RAW argv: the order of the repeated
81
+ // flags IS the order of the transactions, and split_argv's map is
82
+ // last-write-wins. so each occurrence is collected as it is found.
83
+ const contract_ids: string[] = [];
84
+ const methods: string[] = [];
85
+ const args_list: string[] = [];
86
+ const gases: string[] = [];
87
+ const deposits: string[] = [];
88
+
89
+ for (let i = 0; i < argv.length; i++) {
90
+ const token = argv[i];
91
+ if (token === undefined) continue;
92
+ // --- WHY --- a repeated flag is read from the raw argv instead of
93
+ // from the map, because the map only holds the LAST value.
94
+ const value = argv[i + 1];
95
+ if (value === undefined || value.startsWith("--")) continue;
96
+ switch (token) {
97
+ case "--contract-id":
98
+ contract_ids.push(value);
99
+ i++;
100
+ break;
101
+ case "--method":
102
+ methods.push(value);
103
+ i++;
104
+ break;
105
+ case "--args":
106
+ args_list.push(value);
107
+ i++;
108
+ break;
109
+ case "--gas":
110
+ gases.push(value);
111
+ i++;
112
+ break;
113
+ case "--deposit":
114
+ deposits.push(value);
115
+ i++;
116
+ break;
117
+ default:
118
+ break;
119
+ }
120
+ }
121
+
122
+ if (contract_ids.length === 0) {
123
+ console.error(
124
+ "usage: api_shit_1170_tx_queue_post.ts [--base-url <url>] --api-key <key> " +
125
+ "--contract-id <id> --method <name> [--args <json>] [--gas <gas>] [--deposit <deposit>] " +
126
+ "[--contract-id <id> --method <name> ...] [--what <text>] [--when <text>] " +
127
+ "[--why <text>] [--when-at <ms>] [--account <account_id> ...]",
128
+ );
129
+ process.exit(1);
130
+ }
131
+
132
+ if (contract_ids.length !== methods.length) {
133
+ console.error(
134
+ `api_shit_1170_tx_queue_post: every transaction needs a --contract-id and a --method ` +
135
+ `(${contract_ids.length} contract id(s), ${methods.length} method(s))`,
136
+ );
137
+ process.exit(1);
138
+ }
139
+
140
+ // the WHO — the accounts this batch is for. each one must be an
141
+ // account the api key belongs to.
142
+ const accounts: string[] = [];
143
+ for (let i = 0; i < argv.length; i++) {
144
+ const token = argv[i];
145
+ if (token === undefined) continue;
146
+ const value = argv[i + 1];
147
+ if (value === undefined || value.startsWith("--")) continue;
148
+ if (token === "--account") {
149
+ accounts.push(value);
150
+ i++;
151
+ }
152
+ }
153
+
154
+ const transactions: SHIT_1170_TX_QUEUE_TRANSACTION_REQUEST[] = [];
155
+ for (let i = 0; i < contract_ids.length; i++) {
156
+ const contract_id = contract_ids[i];
157
+ const method = methods[i];
158
+ if (contract_id === undefined || method === undefined) continue;
159
+
160
+ // --- WHY --- the args are parsed HERE and not on the backend: the
161
+ // args must be a json OBJECT, and an object is a thing you can check
162
+ // before the round trip. a string that is not json would come back as
163
+ // a 400 with a less useful message than this one.
164
+ const args_raw = args_list[i];
165
+ let args: Record<string, unknown> | undefined;
166
+ if (args_raw !== undefined) {
167
+ let parsed: unknown;
168
+ try {
169
+ parsed = JSON.parse(args_raw);
170
+ } catch {
171
+ console.error(
172
+ `api_shit_1170_tx_queue_post: the --args of transaction ${i} are not json: ${args_raw}`,
173
+ );
174
+ process.exit(1);
175
+ }
176
+ if (
177
+ typeof parsed !== "object" ||
178
+ parsed === null ||
179
+ Array.isArray(parsed)
180
+ ) {
181
+ console.error(
182
+ `api_shit_1170_tx_queue_post: the --args of transaction ${i} must be a json object`,
183
+ );
184
+ process.exit(1);
185
+ }
186
+ args = parsed as Record<string, unknown>;
187
+ }
188
+
189
+ const transaction: SHIT_1170_TX_QUEUE_TRANSACTION_REQUEST = {
190
+ contractId: contract_id,
191
+ method,
192
+ };
193
+ if (args !== undefined) transaction.args = args;
194
+ const gas = gases[i];
195
+ if (gas !== undefined) transaction.gas = gas;
196
+ const deposit = deposits[i];
197
+ if (deposit !== undefined) transaction.deposit = deposit;
198
+ transactions.push(transaction);
199
+ }
200
+
201
+ const when_at_raw = flags.get("--when-at");
202
+ let when_at: number | undefined;
203
+ if (when_at_raw !== undefined) {
204
+ const parsed = Number(when_at_raw);
205
+ if (!Number.isFinite(parsed)) {
206
+ console.error(
207
+ `api_shit_1170_tx_queue_post: --when-at must be a number of milliseconds: ${when_at_raw}`,
208
+ );
209
+ process.exit(1);
210
+ }
211
+ when_at = parsed;
212
+ }
213
+
214
+ const api_key = flags.get("--api-key");
215
+
216
+ const queue = await api_shit_1170_tx_queue_post(
217
+ base_url,
218
+ {
219
+ what: flags.get("--what"),
220
+ when: flags.get("--when"),
221
+ why: flags.get("--why"),
222
+ whenAt: when_at,
223
+ transactions,
224
+ accounts: accounts.length > 0 ? accounts : undefined,
225
+ },
226
+ { api_key },
227
+ );
228
+
229
+ console.log(
230
+ `TX QUEUE: ${queue.queueId} ${queue.transactions.length} transaction(s), ` +
231
+ `${queue.accounts.length} account(s)`,
232
+ );
233
+ for (const transaction of queue.transactions) {
234
+ console.log(
235
+ ` #${transaction.position} ${transaction.contractId}.${transaction.method}` +
236
+ ` tx: ${transaction.txId}`,
237
+ );
238
+ }
239
+ console.log(
240
+ ` accounts: ${queue.accounts.map((one) => one.accountId).join(", ")}`,
241
+ );
242
+ // ========================================
243
+ // copyright 2026 by sleet.near