@huggies/shit-1170-rex-engine-middleman 0.0.0-stage → 0.0.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 (162) hide show
  1. package/LICENSE +9 -0
  2. package/README.md +42 -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 +88 -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_get.ts +93 -0
  20. package/bin/shit-1170/api_shit_1170_tx_queue_one_get.ts +67 -0
  21. package/bin/shit-1170/api_shit_1170_tx_queue_post.ts +243 -0
  22. package/bin/shit-1170/api_shit_1170_tx_queue_sent_post.ts +172 -0
  23. package/bin/shit-1170/api_shit_1170_tx_queue_stats_contracts_get.ts +60 -0
  24. package/bin/shit-1170/api_shit_1170_tx_queue_stats_methods_get.ts +60 -0
  25. package/bin/shit-1170/api_trezu_treasuries_get.ts +62 -0
  26. package/dist/fun/api_shit_1170_api_key_me_get.d.ts +4 -0
  27. package/dist/fun/api_shit_1170_api_key_me_get.d.ts.map +1 -0
  28. package/dist/fun/api_shit_1170_api_key_me_get.js +38 -0
  29. package/dist/fun/api_shit_1170_api_key_me_get.js.map +1 -0
  30. package/dist/fun/api_shit_1170_api_key_rotate_post.d.ts +4 -0
  31. package/dist/fun/api_shit_1170_api_key_rotate_post.d.ts.map +1 -0
  32. package/dist/fun/api_shit_1170_api_key_rotate_post.js +46 -0
  33. package/dist/fun/api_shit_1170_api_key_rotate_post.js.map +1 -0
  34. package/dist/fun/api_shit_1170_api_keys_post.d.ts +3 -0
  35. package/dist/fun/api_shit_1170_api_keys_post.d.ts.map +1 -0
  36. package/dist/fun/api_shit_1170_api_keys_post.js +52 -0
  37. package/dist/fun/api_shit_1170_api_keys_post.js.map +1 -0
  38. package/dist/fun/api_shit_1170_ping_get.d.ts +3 -0
  39. package/dist/fun/api_shit_1170_ping_get.d.ts.map +1 -0
  40. package/dist/fun/api_shit_1170_ping_get.js +32 -0
  41. package/dist/fun/api_shit_1170_ping_get.js.map +1 -0
  42. package/dist/fun/api_shit_1170_swap_queue_accounts_delete.d.ts +4 -0
  43. package/dist/fun/api_shit_1170_swap_queue_accounts_delete.d.ts.map +1 -0
  44. package/dist/fun/api_shit_1170_swap_queue_accounts_delete.js +46 -0
  45. package/dist/fun/api_shit_1170_swap_queue_accounts_delete.js.map +1 -0
  46. package/dist/fun/api_shit_1170_swap_queue_accounts_post.d.ts +4 -0
  47. package/dist/fun/api_shit_1170_swap_queue_accounts_post.d.ts.map +1 -0
  48. package/dist/fun/api_shit_1170_swap_queue_accounts_post.js +42 -0
  49. package/dist/fun/api_shit_1170_swap_queue_accounts_post.js.map +1 -0
  50. package/dist/fun/api_shit_1170_swap_queue_get.d.ts +5 -0
  51. package/dist/fun/api_shit_1170_swap_queue_get.d.ts.map +1 -0
  52. package/dist/fun/api_shit_1170_swap_queue_get.js +60 -0
  53. package/dist/fun/api_shit_1170_swap_queue_get.js.map +1 -0
  54. package/dist/fun/api_shit_1170_swap_queue_one_get.d.ts +4 -0
  55. package/dist/fun/api_shit_1170_swap_queue_one_get.d.ts.map +1 -0
  56. package/dist/fun/api_shit_1170_swap_queue_one_get.js +38 -0
  57. package/dist/fun/api_shit_1170_swap_queue_one_get.js.map +1 -0
  58. package/dist/fun/api_shit_1170_swap_queue_post.d.ts +4 -0
  59. package/dist/fun/api_shit_1170_swap_queue_post.d.ts.map +1 -0
  60. package/dist/fun/api_shit_1170_swap_queue_post.js +62 -0
  61. package/dist/fun/api_shit_1170_swap_queue_post.js.map +1 -0
  62. package/dist/fun/api_shit_1170_swap_queue_sent_post.d.ts +4 -0
  63. package/dist/fun/api_shit_1170_swap_queue_sent_post.d.ts.map +1 -0
  64. package/dist/fun/api_shit_1170_swap_queue_sent_post.js +63 -0
  65. package/dist/fun/api_shit_1170_swap_queue_sent_post.js.map +1 -0
  66. package/dist/fun/api_shit_1170_tx_queue_accounts_delete.d.ts +4 -0
  67. package/dist/fun/api_shit_1170_tx_queue_accounts_delete.d.ts.map +1 -0
  68. package/dist/fun/api_shit_1170_tx_queue_accounts_delete.js +60 -0
  69. package/dist/fun/api_shit_1170_tx_queue_accounts_delete.js.map +1 -0
  70. package/dist/fun/api_shit_1170_tx_queue_accounts_post.d.ts +4 -0
  71. package/dist/fun/api_shit_1170_tx_queue_accounts_post.d.ts.map +1 -0
  72. package/dist/fun/api_shit_1170_tx_queue_accounts_post.js +54 -0
  73. package/dist/fun/api_shit_1170_tx_queue_accounts_post.js.map +1 -0
  74. package/dist/fun/api_shit_1170_tx_queue_get.d.ts +5 -0
  75. package/dist/fun/api_shit_1170_tx_queue_get.d.ts.map +1 -0
  76. package/dist/fun/api_shit_1170_tx_queue_get.js +60 -0
  77. package/dist/fun/api_shit_1170_tx_queue_get.js.map +1 -0
  78. package/dist/fun/api_shit_1170_tx_queue_one_get.d.ts +4 -0
  79. package/dist/fun/api_shit_1170_tx_queue_one_get.d.ts.map +1 -0
  80. package/dist/fun/api_shit_1170_tx_queue_one_get.js +46 -0
  81. package/dist/fun/api_shit_1170_tx_queue_one_get.js.map +1 -0
  82. package/dist/fun/api_shit_1170_tx_queue_post.d.ts +4 -0
  83. package/dist/fun/api_shit_1170_tx_queue_post.d.ts.map +1 -0
  84. package/dist/fun/api_shit_1170_tx_queue_post.js +57 -0
  85. package/dist/fun/api_shit_1170_tx_queue_post.js.map +1 -0
  86. package/dist/fun/api_shit_1170_tx_queue_sent_post.d.ts +4 -0
  87. package/dist/fun/api_shit_1170_tx_queue_sent_post.d.ts.map +1 -0
  88. package/dist/fun/api_shit_1170_tx_queue_sent_post.js +59 -0
  89. package/dist/fun/api_shit_1170_tx_queue_sent_post.js.map +1 -0
  90. package/dist/fun/api_shit_1170_tx_queue_stats_contracts_get.d.ts +5 -0
  91. package/dist/fun/api_shit_1170_tx_queue_stats_contracts_get.d.ts.map +1 -0
  92. package/dist/fun/api_shit_1170_tx_queue_stats_contracts_get.js +41 -0
  93. package/dist/fun/api_shit_1170_tx_queue_stats_contracts_get.js.map +1 -0
  94. package/dist/fun/api_shit_1170_tx_queue_stats_methods_get.d.ts +5 -0
  95. package/dist/fun/api_shit_1170_tx_queue_stats_methods_get.d.ts.map +1 -0
  96. package/dist/fun/api_shit_1170_tx_queue_stats_methods_get.js +41 -0
  97. package/dist/fun/api_shit_1170_tx_queue_stats_methods_get.js.map +1 -0
  98. package/dist/fun/api_trezu_treasuries_get.d.ts +4 -0
  99. package/dist/fun/api_trezu_treasuries_get.d.ts.map +1 -0
  100. package/dist/fun/api_trezu_treasuries_get.js +34 -0
  101. package/dist/fun/api_trezu_treasuries_get.js.map +1 -0
  102. package/dist/index.d.ts +38 -0
  103. package/dist/index.d.ts.map +1 -0
  104. package/dist/index.js +41 -0
  105. package/dist/index.js.map +1 -0
  106. package/dist/stuff/api_call.d.ts +15 -0
  107. package/dist/stuff/api_call.d.ts.map +1 -0
  108. package/dist/stuff/api_call.js +86 -0
  109. package/dist/stuff/api_call.js.map +1 -0
  110. package/dist/stuff/endpoint_paths.d.ts +13 -0
  111. package/dist/stuff/endpoint_paths.d.ts.map +1 -0
  112. package/dist/stuff/endpoint_paths.js +29 -0
  113. package/dist/stuff/endpoint_paths.js.map +1 -0
  114. package/dist/stuff/parse_error.d.ts +12 -0
  115. package/dist/stuff/parse_error.d.ts.map +1 -0
  116. package/dist/stuff/parse_error.js +84 -0
  117. package/dist/stuff/parse_error.js.map +1 -0
  118. package/dist/stuff/request_options.d.ts +6 -0
  119. package/dist/stuff/request_options.d.ts.map +1 -0
  120. package/dist/stuff/request_options.js +43 -0
  121. package/dist/stuff/request_options.js.map +1 -0
  122. package/dist/types/common.d.ts +7 -0
  123. package/dist/types/common.d.ts.map +1 -0
  124. package/dist/types/common.js +6 -0
  125. package/dist/types/common.js.map +1 -0
  126. package/dist/types/shit_1170_api_keys.d.ts +25 -0
  127. package/dist/types/shit_1170_api_keys.d.ts.map +1 -0
  128. package/dist/types/shit_1170_api_keys.js +23 -0
  129. package/dist/types/shit_1170_api_keys.js.map +1 -0
  130. package/dist/types/shit_1170_ping.d.ts +5 -0
  131. package/dist/types/shit_1170_ping.d.ts.map +1 -0
  132. package/dist/types/shit_1170_ping.js +11 -0
  133. package/dist/types/shit_1170_ping.js.map +1 -0
  134. package/dist/types/shit_1170_swap_queue.d.ts +55 -0
  135. package/dist/types/shit_1170_swap_queue.d.ts.map +1 -0
  136. package/dist/types/shit_1170_swap_queue.js +37 -0
  137. package/dist/types/shit_1170_swap_queue.js.map +1 -0
  138. package/dist/types/shit_1170_tx_queue.d.ts +73 -0
  139. package/dist/types/shit_1170_tx_queue.d.ts.map +1 -0
  140. package/dist/types/shit_1170_tx_queue.js +34 -0
  141. package/dist/types/shit_1170_tx_queue.js.map +1 -0
  142. package/dist/types/shit_1170_tx_queue_query.d.ts +12 -0
  143. package/dist/types/shit_1170_tx_queue_query.d.ts.map +1 -0
  144. package/dist/types/shit_1170_tx_queue_query.js +23 -0
  145. package/dist/types/shit_1170_tx_queue_query.js.map +1 -0
  146. package/dist/types/trezu_treasuries_query.d.ts +5 -0
  147. package/dist/types/trezu_treasuries_query.d.ts.map +1 -0
  148. package/dist/types/trezu_treasuries_query.js +9 -0
  149. package/dist/types/trezu_treasuries_query.js.map +1 -0
  150. package/dist/types/trezu_treasury.d.ts +10 -0
  151. package/dist/types/trezu_treasury.d.ts.map +1 -0
  152. package/dist/types/trezu_treasury.js +15 -0
  153. package/dist/types/trezu_treasury.js.map +1 -0
  154. package/dist/types/trezu_treasury_config.d.ts +8 -0
  155. package/dist/types/trezu_treasury_config.d.ts.map +1 -0
  156. package/dist/types/trezu_treasury_config.js +14 -0
  157. package/dist/types/trezu_treasury_config.js.map +1 -0
  158. package/dist/types/trezu_treasury_metadata.d.ts +5 -0
  159. package/dist/types/trezu_treasury_metadata.d.ts.map +1 -0
  160. package/dist/types/trezu_treasury_metadata.js +13 -0
  161. package/dist/types/trezu_treasury_metadata.js.map +1 -0
  162. package/package.json +42 -4
package/LICENSE ADDED
@@ -0,0 +1,9 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 sleet.near
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6
+
7
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8
+
9
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,43 @@
1
- # Temporary Holding Version
1
+ # @huggies/shit-1170-rex-engine-middleman
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ clean ts library for interacting with the shit-1170-rex-engine backend routes.
4
+
5
+ ```sh
6
+ bun i
7
+ bun run build
8
+ # publish
9
+ bun publish --dry-run
10
+ bunx npm login
11
+ bun publish --access public
12
+ # other
13
+ bun run typecheck
14
+ bunx prettier . --write
15
+ ```
16
+
17
+ ---
18
+
19
+ shit-1170-rex-engine
20
+ <br/>
21
+ https://shit-1170.com
22
+
23
+ the base url is a parameter on every call: the frontend passes the
24
+ origin of the page it is served from, a bin passes whatever backend it
25
+ was told to talk to (`--base-url`).
26
+
27
+ the routes covered here are the ones this backend owns:
28
+
29
+ - `/api/shit-1170/*` - our own routes, nothing is proxied
30
+ - `/api/trezu/*` - our proxy for the trezu api
31
+
32
+ the third-party apis the app talks to are NOT here. the intear api, the
33
+ intear dex backend and the rhea indexer each ship their own published
34
+ middleman package, so there is one client per api and one place to keep
35
+ it:
36
+
37
+ - `@sleet-js/middleman-intear-api` - `https://api.intea.rs`
38
+ - `@sleet-js/middleman-intear-dex-api` - `https://dex-backend.intear.tech`
39
+ - `@sleet-js/middleman-rhea-api` - `https://api.rhea.finance`
40
+
41
+ =====================
42
+ <br/>
43
+ copyright 2026 by sleet.near
package/bin/README.md ADDED
@@ -0,0 +1,38 @@
1
+ # @huggies/shit-1170-rex-engine-middleman/bin
2
+
3
+ cli bins for our own backend, called through this package's `src/`.
4
+ every bin imports the middleman wrapper (never `fetch`), so the framed
5
+ request/response block and the error handling are identical to what
6
+ the frontend sees.
7
+
8
+ the bins are grouped by the api they talk to, mirroring the
9
+ middleman:
10
+
11
+ - [`bin/shit-1170/`](./shit-1170/README.md) — our own backend, through
12
+ `src/`.
13
+ - `bin/fun/` — bin primitives shared by the bins above.
14
+
15
+ each group has its own README with the example run commands.
16
+
17
+ the third-party apis are not binned here. the intear api, the intear
18
+ dex backend and the rhea indexer each ship their own bins inside their
19
+ published middleman package, so there is one bin per endpoint and one
20
+ place to keep it:
21
+
22
+ - `@sleet-js/middleman-intear-api` — `node_modules/@sleet-js/middleman-intear-api/bin`
23
+ - `@sleet-js/middleman-intear-dex-api` — `node_modules/@sleet-js/middleman-intear-dex-api/bin`
24
+ - `@sleet-js/middleman-rhea-api` — `node_modules/@sleet-js/middleman-rhea-api/bin`
25
+
26
+ bins accept positional args and `--flag value` pairs; when argv is
27
+ omitted, the defaults documented per bin are used. all commands are run
28
+ from the project root.
29
+
30
+ ## NOTES
31
+
32
+ - **a flag that takes no value is listed by its bin.** `split_argv`
33
+ takes the boolean flags as an argument, so `--desc` in one bin never
34
+ swallows a positional in another bin.
35
+
36
+ ========================================
37
+ <br/>
38
+ copyright 2026 by sleet.near
@@ -0,0 +1,45 @@
1
+ // ========================================
2
+ // RESOLVE_BASE_URL
3
+ // bin primitive that picks the backend base URL for a bin run. scan argv
4
+ // for an explicit `--base-url <url>` flag; when present the flag value
5
+ // wins, otherwise the bin's own DEFAULT_BASE_URL is returned.
6
+ //
7
+ // argv layout expected:
8
+ // ["--base-url", "http://my-host:54733", ...other args...]
9
+ // only the FIRST `--base-url` flag wins here. NOTE: this differs from
10
+ // split_argv, where a repeated flag is last-write-wins.
11
+ //
12
+ // exit-1 on a present-but-empty `--base-url` (a typo is more likely
13
+ // than a deliberate empty override). does NOT validate the URL beyond
14
+ // "non-empty" — the fetch in api_call() surfaces a malformed URL as a
15
+ // network error.
16
+ //
17
+ // --- WHY --- the flag wins over the default and there is no env-var
18
+ // fallback. every invocation must be explicit about which backend it
19
+ // talks to, because the docker-mounted production vault and the local
20
+ // dev backend are different boxes.
21
+ // ========================================
22
+
23
+ export function resolve_base_url(
24
+ argv: string[],
25
+ default_base_url: string,
26
+ ): string {
27
+ // ========================================
28
+ for (let i = 0; i < argv.length; i++) {
29
+ const tok = argv[i];
30
+ if (tok === "--base-url") {
31
+ const value = argv[i + 1];
32
+ if (value === undefined || value === "") {
33
+ console.error(
34
+ "resolve_base_url: --base-url was passed without a value",
35
+ );
36
+ process.exit(1);
37
+ }
38
+ return value;
39
+ }
40
+ }
41
+ return default_base_url;
42
+ // ========================================
43
+ }
44
+ // ========================================
45
+ // copyright 2026 by sleet.near
@@ -0,0 +1,67 @@
1
+ // ========================================
2
+ // SPLIT_ARGV
3
+ // bin primitive that separates positional args from flags in one pass,
4
+ // so every bin parses argv the same way. a flag listed in the bin's own
5
+ // boolean_flags takes no value; every other --flag takes the next token
6
+ // as its value.
7
+ //
8
+ // booleans are recorded in the `seen` set rather than the flags map, so
9
+ // a bin reads `seen.has("--desc")` instead of guessing whether the map
10
+ // holds "true" or an empty string.
11
+ //
12
+ // --- WHY --- the boolean flags are per-bin, not one global set. the
13
+ // shit-1170 bins use --include-hidden, and a shared set would make one
14
+ // bin's flag swallow the next positional in another bin's argv.
15
+ // ========================================
16
+
17
+ export interface SPLIT_ARGV_OPTIONS {
18
+ // the flags that stand alone with no value.
19
+ boolean_flags?: Iterable<string>;
20
+ }
21
+
22
+ export interface SPLIT_ARGV_RESULT {
23
+ positional: string[];
24
+ flags: Map<string, string>;
25
+ // true when the flag appeared in argv at all, boolean or not.
26
+ seen: Set<string>;
27
+ }
28
+
29
+ export function split_argv(
30
+ argv: string[],
31
+ options: SPLIT_ARGV_OPTIONS = {},
32
+ ): SPLIT_ARGV_RESULT {
33
+ const boolean_flags = new Set(options.boolean_flags ?? []);
34
+ const positional: string[] = [];
35
+ const flags = new Map<string, string>();
36
+ const seen = new Set<string>();
37
+
38
+ for (let i = 0; i < argv.length; i++) {
39
+ const token = argv[i];
40
+ // --- WHY --- the guard: with `noUncheckedIndexedAccess` an index
41
+ // into an array reads as `string | undefined`, and the loop bound
42
+ // is not enough for the compiler to prove it. an empty argv skips
43
+ // the loop entirely, so this branch is unreachable in practice.
44
+ if (token === undefined) continue;
45
+ if (!token.startsWith("--")) {
46
+ positional.push(token);
47
+ continue;
48
+ }
49
+ seen.add(token);
50
+ if (boolean_flags.has(token)) continue;
51
+
52
+ const value = argv[i + 1];
53
+ // --- WHY --- a trailing flag with no value is a typo far more
54
+ // often than a deliberate empty string, and a value-taking flag
55
+ // must never swallow the next positional.
56
+ if (value === undefined || value.startsWith("--")) {
57
+ console.error(`split_argv: ${token} was passed without a value`);
58
+ process.exit(1);
59
+ }
60
+ flags.set(token, value);
61
+ i++;
62
+ }
63
+
64
+ return { positional, flags, seen };
65
+ }
66
+ // ========================================
67
+ // copyright 2026 by sleet.near
@@ -0,0 +1,333 @@
1
+ # bin/shit-1170
2
+
3
+ cli bins for our own backend, called through `middleman`.
4
+ one bin per route of ours, so a new route gets a new bin.
5
+
6
+ all commands are run from the project root.
7
+
8
+ every bin takes `--base-url <url>` to point at a backend other than the
9
+ default one (`http://127.0.0.1:54733`).
10
+
11
+ ## the api key
12
+
13
+ the api key is the bearer token the user hands to an agent. it travels
14
+ in the `x-api-key` header, and the legacy `x-session-token` header is
15
+ sent alongside it during the beta.
16
+
17
+ every bin that needs one takes `--api-key <key>`.
18
+
19
+ ## api_shit_1170_ping_get
20
+
21
+ GET /api/shit-1170/ping — liveness check. answers
22
+ `{ "ok": true, "app": "shit-1170" }`.
23
+
24
+ ```sh
25
+ # defaults to http://127.0.0.1:54733
26
+ bun middleman/bin/shit-1170/api_shit_1170_ping_get.ts
27
+
28
+ # point at a different backend (staging / docker host / etc.)
29
+ bun middleman/bin/shit-1170/api_shit_1170_ping_get.ts --base-url http://my-host:54733
30
+ ```
31
+
32
+ ## api_shit_1170_api_keys_post
33
+
34
+ POST /api/shit-1170/api-keys — sign in and get an api key. the signed
35
+ messages come from a json file, so a real signature can be posted
36
+ without a wallet in the loop. the file holds the accounts array, either
37
+ as the array itself or as the whole request body.
38
+
39
+ ```sh
40
+ bun middleman/bin/shit-1170/api_shit_1170_api_keys_post.ts --accounts ./accounts.json
41
+ ```
42
+
43
+ ## api_shit_1170_api_key_me_get
44
+
45
+ GET /api/shit-1170/api-key/me — which account the api key belongs to.
46
+
47
+ ```sh
48
+ bun middleman/bin/shit-1170/api_shit_1170_api_key_me_get.ts --api-key shit_1170_abc123...
49
+ ```
50
+
51
+ ## api_shit_1170_api_key_rotate_post
52
+
53
+ POST /api/shit-1170/api-key/rotate — give an account a NEW api key. the
54
+ old key stops working at once. the signed message comes from a json
55
+ file, the same way the sign-in bin takes it.
56
+
57
+ ```sh
58
+ bun middleman/bin/shit-1170/api_shit_1170_api_key_rotate_post.ts --accounts ./accounts.json
59
+ ```
60
+
61
+ ## the tx queue
62
+
63
+ a `queue_id` is a BATCH of transactions, not one transaction. the agent
64
+ queues a swap that needs three calls, they go in together, and the user
65
+ signs them as one batch in one wallet popup.
66
+
67
+ ## api_shit_1170_tx_queue_post
68
+
69
+ POST /api/shit-1170/tx-queue — queue a batch of transactions.
70
+
71
+ one flag per transaction, and the flag order IS the transaction order:
72
+ the nth `--contract-id`, the nth `--method` and the nth `--args` are
73
+ the nth transaction. `--gas` and `--deposit` are optional per call.
74
+
75
+ `--account` names the WHO — the accounts the batch is for. each one
76
+ must be an account the api key belongs to.
77
+
78
+ ```sh
79
+ # queue ONE transaction
80
+ bun middleman/bin/shit-1170/api_shit_1170_tx_queue_post.ts \
81
+ --api-key shit_1170_abc123... \
82
+ --contract-id ref.finance.near \
83
+ --method ft_swap \
84
+ --args '{"receiver_id":"alice.near"}' \
85
+ --what "swap 100 USDC for NEAR" \
86
+ --why "you asked for it" \
87
+ --account alice.near
88
+
89
+ # queue a BATCH of two, in order, in one wallet popup
90
+ bun middleman/bin/shit-1170/api_shit_1170_tx_queue_post.ts \
91
+ --api-key shit_1170_abc123... \
92
+ --contract-id ref.finance.near \
93
+ --method ft_swap \
94
+ --args '{"receiver_id":"alice.near"}' \
95
+ --gas 30000000000000 \
96
+ --deposit 1 \
97
+ --contract-id ref.finance.near \
98
+ --method ft_resolve_transfer \
99
+ --args '{"receiver_id":"alice.near"}' \
100
+ --when "when the price is right" \
101
+ --when-at 1772666400000
102
+ ```
103
+
104
+ ## api_shit_1170_tx_queue_get
105
+
106
+ GET /api/shit-1170/tx-queue — the queue list, filterable.
107
+
108
+ - `--account-id` — only the queues this account is on
109
+ - `--hide-sent` — with the account, drop the ones it has already sent
110
+ - `--contract-id` — only the queues holding a tx for this contract
111
+ - `--method` — only the queues holding a tx for this method
112
+ - `--limit` — how many, default 50
113
+ - `--offset` — where to start, default 0
114
+
115
+ `--hide-sent` stands alone, it takes no value. it needs `--account-id`
116
+ — it is a filter on ONE account's view.
117
+
118
+ ```sh
119
+ bun middleman/bin/shit-1170/api_shit_1170_tx_queue_get.ts --api-key shit_1170_abc123...
120
+ bun middleman/bin/shit-1170/api_shit_1170_tx_queue_get.ts \
121
+ --api-key shit_1170_abc123... \
122
+ --account-id alice.near \
123
+ --hide-sent \
124
+ --limit 20
125
+ ```
126
+
127
+ ## api_shit_1170_tx_queue_one_get
128
+
129
+ GET /api/shit-1170/tx-queue/{queue_id} — one queued batch, with its
130
+ transactions and its accounts.
131
+
132
+ ```sh
133
+ bun middleman/bin/shit-1170/api_shit_1170_tx_queue_one_get.ts \
134
+ --api-key shit_1170_abc123... \
135
+ --queue-id 8f14e45f-ceea-467a-9b0d-2b1c2e6c1a11
136
+ ```
137
+
138
+ ## api_shit_1170_tx_queue_accounts_post
139
+
140
+ POST /api/shit-1170/tx-queue/{queue_id}/accounts — add YOUR OWN account
141
+ to a queued batch. the api key must belong to that account.
142
+
143
+ ```sh
144
+ bun middleman/bin/shit-1170/api_shit_1170_tx_queue_accounts_post.ts \
145
+ --api-key shit_1170_abc123... \
146
+ --queue-id 8f14e45f-ceea-467a-9b0d-2b1c2e6c1a11 \
147
+ --account-id alice.near
148
+ ```
149
+
150
+ ## api_shit_1170_tx_queue_accounts_delete
151
+
152
+ DELETE /api/shit-1170/tx-queue/{queue_id}/accounts/{account_id} —
153
+ remove YOUR OWN account from a queued batch. a row that already carries
154
+ a hash is history and is not deleted.
155
+
156
+ ```sh
157
+ bun middleman/bin/shit-1170/api_shit_1170_tx_queue_accounts_delete.ts \
158
+ --api-key shit_1170_abc123... \
159
+ --queue-id 8f14e45f-ceea-467a-9b0d-2b1c2e6c1a11 \
160
+ --account-id alice.near
161
+ ```
162
+
163
+ ## api_shit_1170_tx_queue_sent_post
164
+
165
+ POST /api/shit-1170/tx-queue/{queue_id}/sent — record that the
166
+ transactions were sent.
167
+
168
+ ONE call for the whole batch — the wallet sent every transaction in one
169
+ popup, so the app reports every hash in one call. the flags repeat, and
170
+ the nth `--tx-id`, the nth `--tx-hash` and the nth `--status` are the
171
+ nth entry.
172
+
173
+ `--status` is optional: without it the status is `sent`, which means
174
+ "it went out and nobody knows how it went yet".
175
+
176
+ ```sh
177
+ bun middleman/bin/shit-1170/api_shit_1170_tx_queue_sent_post.ts \
178
+ --api-key shit_1170_abc123... \
179
+ --queue-id 8f14e45f-ceea-467a-9b0d-2b1c2e6c1a11 \
180
+ --tx-id 1a2b3c4d-0000-0000-0000-000000000001 \
181
+ --tx-hash 9hN3lq... \
182
+ --status succeeded \
183
+ --tx-id 1a2b3c4d-0000-0000-0000-000000000002 \
184
+ --tx-hash AbCdEf... \
185
+ --status failed
186
+ ```
187
+
188
+ ## api_shit_1170_tx_queue_stats_contracts_get
189
+
190
+ GET /api/shit-1170/tx-queue/stats/contracts — how many queued
191
+ transactions hit each contract, biggest first.
192
+
193
+ ```sh
194
+ bun middleman/bin/shit-1170/api_shit_1170_tx_queue_stats_contracts_get.ts \
195
+ --api-key shit_1170_abc123... \
196
+ --limit 20
197
+ ```
198
+
199
+ ## api_shit_1170_tx_queue_stats_methods_get
200
+
201
+ GET /api/shit-1170/tx-queue/stats/methods — how many queued
202
+ transactions call each method, biggest first. the contract rides along,
203
+ because `ft_swap` on two contracts is two different transactions.
204
+
205
+ ```sh
206
+ bun middleman/bin/shit-1170/api_shit_1170_tx_queue_stats_methods_get.ts \
207
+ --api-key shit_1170_abc123... \
208
+ --limit 20
209
+ ```
210
+
211
+ ## api_trezu_treasuries_get
212
+
213
+ GET /api/trezu/user/treasuries — the treasuries (sputnik daos) an
214
+ account belongs to. the account id is required and is trimmed.
215
+ `--include-hidden` stands alone, it takes no value.
216
+
217
+ ```sh
218
+ bun middleman/bin/shit-1170/api_trezu_treasuries_get.ts sleet.near
219
+ bun middleman/bin/shit-1170/api_trezu_treasuries_get.ts sleet.near --include-hidden
220
+ bun middleman/bin/shit-1170/api_trezu_treasuries_get.ts sleet.near --base-url http://my-host:54733
221
+ ```
222
+
223
+ ## the swap queue
224
+
225
+ a `swap_id` is a SWAP, not a batch of transactions. the agent does not
226
+ know the route — it names the token in, the amount in and the token out,
227
+ and the route is worked out when the swap is executed.
228
+
229
+ `--amount-in` is the RAW unit amount — the token's smallest unit — and
230
+ not a human amount. a human amount only means something next to the
231
+ token it belongs to.
232
+
233
+ ## api_shit_1170_swap_queue_post
234
+
235
+ POST /api/shit-1170/swap-queue — queue a swap.
236
+
237
+ `--account` names the WHO — the accounts the swap is for. each one must
238
+ be an account the api key belongs to.
239
+
240
+ ```sh
241
+ bun middleman/bin/shit-1170/api_shit_1170_swap_queue_post.ts \
242
+ --api-key shit_1170_abc123... \
243
+ --token-in usdt.tether-token.near \
244
+ --amount-in 100000000 \
245
+ --token-out near \
246
+ --what "swap 100 USDC for NEAR" \
247
+ --why "you asked for it" \
248
+ --account alice.near
249
+ ```
250
+
251
+ ## api_shit_1170_swap_queue_get
252
+
253
+ GET /api/shit-1170/swap-queue — the swap list, filterable.
254
+
255
+ - `--account-id` — only the swaps this account is on
256
+ - `--hide-sent` — with the account, drop the ones it has already sent
257
+ - `--token-in` — only the swaps that sell this token
258
+ - `--token-out` — only the swaps that buy this token
259
+ - `--limit` — how many, default 50
260
+ - `--offset` — where to start, default 0
261
+
262
+ `--hide-sent` stands alone, it takes no value. it needs `--account-id`
263
+ — it is a filter on ONE account's view.
264
+
265
+ ```sh
266
+ bun middleman/bin/shit-1170/api_shit_1170_swap_queue_get.ts --api-key shit_1170_abc123...
267
+ bun middleman/bin/shit-1170/api_shit_1170_swap_queue_get.ts \
268
+ --api-key shit_1170_abc123... \
269
+ --account-id alice.near \
270
+ --hide-sent \
271
+ --limit 20
272
+ ```
273
+
274
+ ## api_shit_1170_swap_queue_one_get
275
+
276
+ GET /api/shit-1170/swap-queue/{swap_id} — one queued swap, with its
277
+ accounts.
278
+
279
+ ```sh
280
+ bun middleman/bin/shit-1170/api_shit_1170_swap_queue_one_get.ts \
281
+ --api-key shit_1170_abc123... \
282
+ --swap-id 8f14e45f-ceea-467a-9b0d-2b1c2e6c1a11
283
+ ```
284
+
285
+ ## api_shit_1170_swap_queue_accounts_post
286
+
287
+ POST /api/shit-1170/swap-queue/{swap_id}/accounts — add YOUR OWN
288
+ account to a queued swap. the api key must belong to that account.
289
+
290
+ ```sh
291
+ bun middleman/bin/shit-1170/api_shit_1170_swap_queue_accounts_post.ts \
292
+ --api-key shit_1170_abc123... \
293
+ --swap-id 8f14e45f-ceea-467a-9b0d-2b1c2e6c1a11 \
294
+ --account-id alice.near
295
+ ```
296
+
297
+ ## api_shit_1170_swap_queue_accounts_delete
298
+
299
+ DELETE /api/shit-1170/swap-queue/{swap_id}/accounts/{account_id} —
300
+ remove YOUR OWN account from a queued swap. a row that already carries a
301
+ hash is history and is not deleted.
302
+
303
+ ```sh
304
+ bun middleman/bin/shit-1170/api_shit_1170_swap_queue_accounts_delete.ts \
305
+ --api-key shit_1170_abc123... \
306
+ --swap-id 8f14e45f-ceea-467a-9b0d-2b1c2e6c1a11 \
307
+ --account-id alice.near
308
+ ```
309
+
310
+ ## api_shit_1170_swap_queue_sent_post
311
+
312
+ POST /api/shit-1170/swap-queue/{swap_id}/sent — record that the swap
313
+ was sent. THIS is the route the swap page calls after it executes a
314
+ queued swap.
315
+
316
+ a queued swap is ONE swap, so there is ONE hash and not a list.
317
+
318
+ `--status` is optional: without it the status is `sent`, which means
319
+ "it went out and nobody knows how it went yet". `--amount-out` is the
320
+ amount that came out, in the output token's smallest unit.
321
+
322
+ ```sh
323
+ bun middleman/bin/shit-1170/api_shit_1170_swap_queue_sent_post.ts \
324
+ --api-key shit_1170_abc123... \
325
+ --swap-id 8f14e45f-ceea-467a-9b0d-2b1c2e6c1a11 \
326
+ --tx-hash 9hN3lq... \
327
+ --status succeeded \
328
+ --amount-out 4999000000000000000000000
329
+ ```
330
+
331
+ ========================================
332
+ <br/>
333
+ copyright 2026 by sleet.near
@@ -0,0 +1,46 @@
1
+ // ========================================
2
+ // API_SHIT_1170_API_KEY_ME_GET
3
+ // runnable bin for GET /api/shit-1170/api-key/me via middleman. the
4
+ // middleman logs the framed request + response, so this bin only adds
5
+ // a one-line summary.
6
+ //
7
+ // bun middleman/bin/shit-1170/api_shit_1170_api_key_me_get.ts \
8
+ // --api-key shit_1170_abc123...
9
+ //
10
+ // --- WHY --- this is the bin that tells an agent whether the key it
11
+ // holds is still good: a 401 means the key is not one of ours, and a
12
+ // 200 names the account it belongs to.
13
+ // ========================================
14
+
15
+ import { api_shit_1170_api_key_me_get } from "@huggies/shit-1170-rex-engine-middleman";
16
+ import { resolve_base_url } from "../fun/resolve_base_url";
17
+ import { split_argv } from "../fun/split_argv";
18
+
19
+ // --- CONFIG --------------------------------------------------------
20
+ // used when no argv is supplied. the default is the local backend,
21
+ // which binds 0.0.0.0:54733 (see shit_1170_port_fun.rs).
22
+ const DEFAULT_BASE_URL = "http://127.0.0.1:54733";
23
+
24
+ // the flags of this bin that take no value.
25
+ const BOOLEAN_FLAGS: string[] = [];
26
+
27
+ // --- argv ----------------------------------------------------------
28
+ // argv[0] is bun, argv[1] is this script, so real args start at 2.
29
+ const argv = process.argv.slice(2);
30
+ const { flags } = split_argv(argv, { boolean_flags: BOOLEAN_FLAGS });
31
+
32
+ // --- WHY --- the base url is resolved from the raw argv rather than
33
+ // the split result: split_argv would put --base-url in the flags map,
34
+ // and reading the raw argv keeps one rule for the url: it is never a
35
+ // positional.
36
+ const base_url = resolve_base_url(argv, DEFAULT_BASE_URL);
37
+
38
+ const me = await api_shit_1170_api_key_me_get(base_url, {
39
+ api_key: flags.get("--api-key"),
40
+ });
41
+
42
+ console.log(`API KEY ME: ${me.accountId}`);
43
+ console.log(` created: ${new Date(me.createdAt).toISOString()}`);
44
+ console.log(` updated: ${new Date(me.updatedAt).toISOString()}`);
45
+ // ========================================
46
+ // copyright 2026 by sleet.near
@@ -0,0 +1,83 @@
1
+ // ========================================
2
+ // API_SHIT_1170_API_KEY_ROTATE_POST
3
+ // runnable bin for POST /api/shit-1170/api-key/rotate via middleman.
4
+ // the middleman logs the framed request + response, so this bin only
5
+ // adds 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_key_rotate_post.ts \
11
+ // --accounts <path-to-json>
12
+ //
13
+ // the file holds ONE signed account, either as the array itself or as
14
+ // the whole request body:
15
+ // { "accounts": [ { "accountId": "...", "publicKey": "...", ... } ] }
16
+ //
17
+ // --- WHY --- the rotation is proved by the SIGNED MESSAGE and not by
18
+ // the old key: the old key is what a thief has. a rotation that only
19
+ // needed the old key could be done by the thief, who would lock the
20
+ // owner out while keeping access. the signed message proves the owner
21
+ // still holds the account's NEAR key.
22
+ //
23
+ // --- WHY --- --api-key is optional here: the route proves the ownership
24
+ // with the signed message, so the key is not needed. it is still sent
25
+ // when it is given, because the header is the route's usual way of
26
+ // saying who is calling.
27
+ // ========================================
28
+
29
+ import { readFileSync } from "node:fs";
30
+ import { api_shit_1170_api_key_rotate_post } from "@huggies/shit-1170-rex-engine-middleman";
31
+ import type {
32
+ SHIT_1170_API_KEYS_REQUEST,
33
+ SHIT_1170_SIGNED_ACCOUNT,
34
+ } 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: string[] = [];
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 } = 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
+ const accounts_flag = argv.indexOf("--accounts");
58
+ const accounts_path =
59
+ accounts_flag === -1 ? undefined : argv[accounts_flag + 1];
60
+ if (accounts_path === undefined || accounts_path.length === 0) {
61
+ console.error(
62
+ "usage: api_shit_1170_api_key_rotate_post.ts [--base-url <url>] --accounts <file.json>",
63
+ );
64
+ process.exit(1);
65
+ }
66
+
67
+ const raw = readFileSync(accounts_path, "utf8");
68
+ const parsed = JSON.parse(raw) as
69
+ SHIT_1170_API_KEYS_REQUEST | SHIT_1170_SIGNED_ACCOUNT[];
70
+ // the file may hold the accounts array on its own or the whole body.
71
+ const accounts = Array.isArray(parsed) ? parsed : parsed.accounts;
72
+
73
+ const key = await api_shit_1170_api_key_rotate_post(
74
+ base_url,
75
+ { accounts },
76
+ { api_key: flags.get("--api-key") },
77
+ );
78
+
79
+ console.log(`API KEY ROTATED: ${key.accountId}`);
80
+ console.log(` key: ${key.apiKey}`);
81
+ console.log(" the old key stops working at once — update whatever holds it.");
82
+ // ========================================
83
+ // copyright 2026 by sleet.near