@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.
- package/LICENSE +9 -0
- package/README.md +43 -2
- package/bin/README.md +38 -0
- package/bin/fun/resolve_base_url.ts +45 -0
- package/bin/fun/split_argv.ts +67 -0
- package/bin/shit-1170/README.md +333 -0
- package/bin/shit-1170/api_shit_1170_api_key_me_get.ts +46 -0
- package/bin/shit-1170/api_shit_1170_api_key_rotate_post.ts +83 -0
- package/bin/shit-1170/api_shit_1170_api_keys_post.ts +68 -0
- package/bin/shit-1170/api_shit_1170_ping_get.ts +28 -0
- package/bin/shit-1170/api_shit_1170_swap_queue_accounts_delete.ts +81 -0
- package/bin/shit-1170/api_shit_1170_swap_queue_accounts_post.ts +80 -0
- package/bin/shit-1170/api_shit_1170_swap_queue_get.ts +91 -0
- package/bin/shit-1170/api_shit_1170_swap_queue_one_get.ts +62 -0
- package/bin/shit-1170/api_shit_1170_swap_queue_post.ts +118 -0
- package/bin/shit-1170/api_shit_1170_swap_queue_sent_post.ts +87 -0
- package/bin/shit-1170/api_shit_1170_tx_queue_accounts_delete.ts +68 -0
- package/bin/shit-1170/api_shit_1170_tx_queue_accounts_post.ts +65 -0
- package/bin/shit-1170/api_shit_1170_tx_queue_facets_get.ts +68 -0
- package/bin/shit-1170/api_shit_1170_tx_queue_get.ts +99 -0
- package/bin/shit-1170/api_shit_1170_tx_queue_one_get.ts +67 -0
- package/bin/shit-1170/api_shit_1170_tx_queue_post.ts +243 -0
- package/bin/shit-1170/api_shit_1170_tx_queue_sent_post.ts +172 -0
- package/bin/shit-1170/api_shit_1170_tx_queue_stats_contracts_get.ts +60 -0
- package/bin/shit-1170/api_shit_1170_tx_queue_stats_methods_get.ts +60 -0
- package/bin/shit-1170/api_trezu_treasuries_get.ts +62 -0
- package/dist/fun/api_shit_1170_api_key_me_get.d.ts +4 -0
- package/dist/fun/api_shit_1170_api_key_me_get.d.ts.map +1 -0
- package/dist/fun/api_shit_1170_api_key_me_get.js +38 -0
- package/dist/fun/api_shit_1170_api_key_me_get.js.map +1 -0
- package/dist/fun/api_shit_1170_api_key_rotate_post.d.ts +4 -0
- package/dist/fun/api_shit_1170_api_key_rotate_post.d.ts.map +1 -0
- package/dist/fun/api_shit_1170_api_key_rotate_post.js +46 -0
- package/dist/fun/api_shit_1170_api_key_rotate_post.js.map +1 -0
- package/dist/fun/api_shit_1170_api_keys_post.d.ts +3 -0
- package/dist/fun/api_shit_1170_api_keys_post.d.ts.map +1 -0
- package/dist/fun/api_shit_1170_api_keys_post.js +52 -0
- package/dist/fun/api_shit_1170_api_keys_post.js.map +1 -0
- package/dist/fun/api_shit_1170_ping_get.d.ts +3 -0
- package/dist/fun/api_shit_1170_ping_get.d.ts.map +1 -0
- package/dist/fun/api_shit_1170_ping_get.js +32 -0
- package/dist/fun/api_shit_1170_ping_get.js.map +1 -0
- package/dist/fun/api_shit_1170_swap_queue_accounts_delete.d.ts +4 -0
- package/dist/fun/api_shit_1170_swap_queue_accounts_delete.d.ts.map +1 -0
- package/dist/fun/api_shit_1170_swap_queue_accounts_delete.js +46 -0
- package/dist/fun/api_shit_1170_swap_queue_accounts_delete.js.map +1 -0
- package/dist/fun/api_shit_1170_swap_queue_accounts_post.d.ts +4 -0
- package/dist/fun/api_shit_1170_swap_queue_accounts_post.d.ts.map +1 -0
- package/dist/fun/api_shit_1170_swap_queue_accounts_post.js +42 -0
- package/dist/fun/api_shit_1170_swap_queue_accounts_post.js.map +1 -0
- package/dist/fun/api_shit_1170_swap_queue_get.d.ts +5 -0
- package/dist/fun/api_shit_1170_swap_queue_get.d.ts.map +1 -0
- package/dist/fun/api_shit_1170_swap_queue_get.js +77 -0
- package/dist/fun/api_shit_1170_swap_queue_get.js.map +1 -0
- package/dist/fun/api_shit_1170_swap_queue_one_get.d.ts +4 -0
- package/dist/fun/api_shit_1170_swap_queue_one_get.d.ts.map +1 -0
- package/dist/fun/api_shit_1170_swap_queue_one_get.js +38 -0
- package/dist/fun/api_shit_1170_swap_queue_one_get.js.map +1 -0
- package/dist/fun/api_shit_1170_swap_queue_post.d.ts +4 -0
- package/dist/fun/api_shit_1170_swap_queue_post.d.ts.map +1 -0
- package/dist/fun/api_shit_1170_swap_queue_post.js +62 -0
- package/dist/fun/api_shit_1170_swap_queue_post.js.map +1 -0
- package/dist/fun/api_shit_1170_swap_queue_sent_post.d.ts +4 -0
- package/dist/fun/api_shit_1170_swap_queue_sent_post.d.ts.map +1 -0
- package/dist/fun/api_shit_1170_swap_queue_sent_post.js +63 -0
- package/dist/fun/api_shit_1170_swap_queue_sent_post.js.map +1 -0
- package/dist/fun/api_shit_1170_tx_queue_accounts_delete.d.ts +4 -0
- package/dist/fun/api_shit_1170_tx_queue_accounts_delete.d.ts.map +1 -0
- package/dist/fun/api_shit_1170_tx_queue_accounts_delete.js +60 -0
- package/dist/fun/api_shit_1170_tx_queue_accounts_delete.js.map +1 -0
- package/dist/fun/api_shit_1170_tx_queue_accounts_post.d.ts +4 -0
- package/dist/fun/api_shit_1170_tx_queue_accounts_post.d.ts.map +1 -0
- package/dist/fun/api_shit_1170_tx_queue_accounts_post.js +54 -0
- package/dist/fun/api_shit_1170_tx_queue_accounts_post.js.map +1 -0
- package/dist/fun/api_shit_1170_tx_queue_facets_get.d.ts +5 -0
- package/dist/fun/api_shit_1170_tx_queue_facets_get.d.ts.map +1 -0
- package/dist/fun/api_shit_1170_tx_queue_facets_get.js +45 -0
- package/dist/fun/api_shit_1170_tx_queue_facets_get.js.map +1 -0
- package/dist/fun/api_shit_1170_tx_queue_get.d.ts +5 -0
- package/dist/fun/api_shit_1170_tx_queue_get.d.ts.map +1 -0
- package/dist/fun/api_shit_1170_tx_queue_get.js +70 -0
- package/dist/fun/api_shit_1170_tx_queue_get.js.map +1 -0
- package/dist/fun/api_shit_1170_tx_queue_one_get.d.ts +4 -0
- package/dist/fun/api_shit_1170_tx_queue_one_get.d.ts.map +1 -0
- package/dist/fun/api_shit_1170_tx_queue_one_get.js +46 -0
- package/dist/fun/api_shit_1170_tx_queue_one_get.js.map +1 -0
- package/dist/fun/api_shit_1170_tx_queue_post.d.ts +4 -0
- package/dist/fun/api_shit_1170_tx_queue_post.d.ts.map +1 -0
- package/dist/fun/api_shit_1170_tx_queue_post.js +57 -0
- package/dist/fun/api_shit_1170_tx_queue_post.js.map +1 -0
- package/dist/fun/api_shit_1170_tx_queue_sent_post.d.ts +4 -0
- package/dist/fun/api_shit_1170_tx_queue_sent_post.d.ts.map +1 -0
- package/dist/fun/api_shit_1170_tx_queue_sent_post.js +59 -0
- package/dist/fun/api_shit_1170_tx_queue_sent_post.js.map +1 -0
- package/dist/fun/api_shit_1170_tx_queue_stats_contracts_get.d.ts +5 -0
- package/dist/fun/api_shit_1170_tx_queue_stats_contracts_get.d.ts.map +1 -0
- package/dist/fun/api_shit_1170_tx_queue_stats_contracts_get.js +41 -0
- package/dist/fun/api_shit_1170_tx_queue_stats_contracts_get.js.map +1 -0
- package/dist/fun/api_shit_1170_tx_queue_stats_methods_get.d.ts +5 -0
- package/dist/fun/api_shit_1170_tx_queue_stats_methods_get.d.ts.map +1 -0
- package/dist/fun/api_shit_1170_tx_queue_stats_methods_get.js +41 -0
- package/dist/fun/api_shit_1170_tx_queue_stats_methods_get.js.map +1 -0
- package/dist/fun/api_trezu_treasuries_get.d.ts +4 -0
- package/dist/fun/api_trezu_treasuries_get.d.ts.map +1 -0
- package/dist/fun/api_trezu_treasuries_get.js +34 -0
- package/dist/fun/api_trezu_treasuries_get.js.map +1 -0
- package/dist/index.d.ts +40 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +42 -0
- package/dist/index.js.map +1 -0
- package/dist/stuff/api_call.d.ts +15 -0
- package/dist/stuff/api_call.d.ts.map +1 -0
- package/dist/stuff/api_call.js +86 -0
- package/dist/stuff/api_call.js.map +1 -0
- package/dist/stuff/endpoint_paths.d.ts +14 -0
- package/dist/stuff/endpoint_paths.d.ts.map +1 -0
- package/dist/stuff/endpoint_paths.js +30 -0
- package/dist/stuff/endpoint_paths.js.map +1 -0
- package/dist/stuff/parse_error.d.ts +12 -0
- package/dist/stuff/parse_error.d.ts.map +1 -0
- package/dist/stuff/parse_error.js +84 -0
- package/dist/stuff/parse_error.js.map +1 -0
- package/dist/stuff/request_options.d.ts +6 -0
- package/dist/stuff/request_options.d.ts.map +1 -0
- package/dist/stuff/request_options.js +43 -0
- package/dist/stuff/request_options.js.map +1 -0
- package/dist/types/common.d.ts +7 -0
- package/dist/types/common.d.ts.map +1 -0
- package/dist/types/common.js +6 -0
- package/dist/types/common.js.map +1 -0
- package/dist/types/shit_1170_api_keys.d.ts +25 -0
- package/dist/types/shit_1170_api_keys.d.ts.map +1 -0
- package/dist/types/shit_1170_api_keys.js +23 -0
- package/dist/types/shit_1170_api_keys.js.map +1 -0
- package/dist/types/shit_1170_ping.d.ts +5 -0
- package/dist/types/shit_1170_ping.d.ts.map +1 -0
- package/dist/types/shit_1170_ping.js +11 -0
- package/dist/types/shit_1170_ping.js.map +1 -0
- package/dist/types/shit_1170_swap_queue.d.ts +57 -0
- package/dist/types/shit_1170_swap_queue.d.ts.map +1 -0
- package/dist/types/shit_1170_swap_queue.js +37 -0
- package/dist/types/shit_1170_swap_queue.js.map +1 -0
- package/dist/types/shit_1170_tx_queue.d.ts +74 -0
- package/dist/types/shit_1170_tx_queue.d.ts.map +1 -0
- package/dist/types/shit_1170_tx_queue.js +34 -0
- package/dist/types/shit_1170_tx_queue.js.map +1 -0
- package/dist/types/shit_1170_tx_queue_facets.d.ts +13 -0
- package/dist/types/shit_1170_tx_queue_facets.d.ts.map +1 -0
- package/dist/types/shit_1170_tx_queue_facets.js +20 -0
- package/dist/types/shit_1170_tx_queue_facets.js.map +1 -0
- package/dist/types/shit_1170_tx_queue_query.d.ts +15 -0
- package/dist/types/shit_1170_tx_queue_query.d.ts.map +1 -0
- package/dist/types/shit_1170_tx_queue_query.js +30 -0
- package/dist/types/shit_1170_tx_queue_query.js.map +1 -0
- package/dist/types/trezu_treasuries_query.d.ts +5 -0
- package/dist/types/trezu_treasuries_query.d.ts.map +1 -0
- package/dist/types/trezu_treasuries_query.js +9 -0
- package/dist/types/trezu_treasuries_query.js.map +1 -0
- package/dist/types/trezu_treasury.d.ts +10 -0
- package/dist/types/trezu_treasury.d.ts.map +1 -0
- package/dist/types/trezu_treasury.js +15 -0
- package/dist/types/trezu_treasury.js.map +1 -0
- package/dist/types/trezu_treasury_config.d.ts +8 -0
- package/dist/types/trezu_treasury_config.d.ts.map +1 -0
- package/dist/types/trezu_treasury_config.js +14 -0
- package/dist/types/trezu_treasury_config.js.map +1 -0
- package/dist/types/trezu_treasury_metadata.d.ts +5 -0
- package/dist/types/trezu_treasury_metadata.d.ts.map +1 -0
- package/dist/types/trezu_treasury_metadata.js +13 -0
- package/dist/types/trezu_treasury_metadata.js.map +1 -0
- package/package.json +45 -4
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
// ========================================
|
|
2
|
+
// API_SHIT_1170_TX_QUEUE_SENT_POST
|
|
3
|
+
// runnable bin for POST /api/shit-1170/tx-queue/{queue_id}/sent via
|
|
4
|
+
// middleman. the middleman logs the framed request + response, so this
|
|
5
|
+
// bin only adds a summary.
|
|
6
|
+
//
|
|
7
|
+
// ONE call for the whole batch — the wallet sent every transaction in
|
|
8
|
+
// one popup, so the app reports every hash in one call. the flags
|
|
9
|
+
// repeat, and the nth --tx-id, the nth --tx-hash and the nth --status
|
|
10
|
+
// are the nth entry:
|
|
11
|
+
//
|
|
12
|
+
// bun middleman/bin/shit-1170/api_shit_1170_tx_queue_sent_post.ts \
|
|
13
|
+
// --api-key shit_1170_abc123... \
|
|
14
|
+
// --queue-id 8f14e45f-ceea-467a-9b0d-2b1c2e6c1a11 \
|
|
15
|
+
// --tx-id 1a2b3c4d-0000-0000-0000-000000000001 \
|
|
16
|
+
// --tx-hash 9hN3lq... \
|
|
17
|
+
// --status succeeded \
|
|
18
|
+
// --tx-id 1a2b3c4d-0000-0000-0000-000000000002 \
|
|
19
|
+
// --tx-hash AbCdEf... \
|
|
20
|
+
// --status failed
|
|
21
|
+
//
|
|
22
|
+
// --status is OPTIONAL: without it the status is `sent`, which means
|
|
23
|
+
// "it went out and nobody knows how it went yet".
|
|
24
|
+
//
|
|
25
|
+
// --- WHY --- the argv is scanned RAW and not through split_argv: the
|
|
26
|
+
// flags that repeat have to keep their ORDER, and a Map of
|
|
27
|
+
// last-write-wins would lose every entry but the last.
|
|
28
|
+
//
|
|
29
|
+
// --- WHY --- the flags of one entry are matched by POSITION and not by
|
|
30
|
+
// name: an entry is one tx id, one hash and one status. the nth of
|
|
31
|
+
// each is the nth entry.
|
|
32
|
+
// ========================================
|
|
33
|
+
|
|
34
|
+
import {
|
|
35
|
+
api_shit_1170_tx_queue_sent_post,
|
|
36
|
+
type SHIT_1170_TX_QUEUE_HASH_REQUEST,
|
|
37
|
+
type SHIT_1170_TX_QUEUE_STATUS,
|
|
38
|
+
} from "@huggies/shit-1170-rex-engine-middleman";
|
|
39
|
+
import { resolve_base_url } from "../fun/resolve_base_url";
|
|
40
|
+
import { split_argv } from "../fun/split_argv";
|
|
41
|
+
|
|
42
|
+
// --- CONFIG --------------------------------------------------------
|
|
43
|
+
// used when no argv is supplied. the default is the local backend,
|
|
44
|
+
// which binds 0.0.0.0:54733 (see shit_1170_port_fun.rs).
|
|
45
|
+
const DEFAULT_BASE_URL = "http://127.0.0.1:54733";
|
|
46
|
+
|
|
47
|
+
// the flags of this bin that take no value.
|
|
48
|
+
const BOOLEAN_FLAGS: string[] = [];
|
|
49
|
+
|
|
50
|
+
// --- argv ----------------------------------------------------------
|
|
51
|
+
// argv[0] is bun, argv[1] is this script, so real args start at 2.
|
|
52
|
+
const argv = process.argv.slice(2);
|
|
53
|
+
const { flags } = split_argv(argv, { boolean_flags: BOOLEAN_FLAGS });
|
|
54
|
+
|
|
55
|
+
// --- WHY --- the base url is resolved from the raw argv rather than
|
|
56
|
+
// the split result: split_argv would put --base-url in the flags map,
|
|
57
|
+
// and reading the raw argv keeps one rule for the url: it is never a
|
|
58
|
+
// positional.
|
|
59
|
+
const base_url = resolve_base_url(argv, DEFAULT_BASE_URL);
|
|
60
|
+
|
|
61
|
+
// --- THE HASHES -------------------------
|
|
62
|
+
const tx_ids: string[] = [];
|
|
63
|
+
const tx_hashes: string[] = [];
|
|
64
|
+
const statuses: string[] = [];
|
|
65
|
+
|
|
66
|
+
for (let i = 0; i < argv.length; i++) {
|
|
67
|
+
const token = argv[i];
|
|
68
|
+
if (token === undefined) continue;
|
|
69
|
+
const value = argv[i + 1];
|
|
70
|
+
if (value === undefined || value.startsWith("--")) continue;
|
|
71
|
+
switch (token) {
|
|
72
|
+
case "--tx-id":
|
|
73
|
+
tx_ids.push(value);
|
|
74
|
+
i++;
|
|
75
|
+
break;
|
|
76
|
+
case "--tx-hash":
|
|
77
|
+
tx_hashes.push(value);
|
|
78
|
+
i++;
|
|
79
|
+
break;
|
|
80
|
+
case "--status":
|
|
81
|
+
statuses.push(value);
|
|
82
|
+
i++;
|
|
83
|
+
break;
|
|
84
|
+
default:
|
|
85
|
+
break;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
if (tx_ids.length === 0) {
|
|
90
|
+
console.error(
|
|
91
|
+
"usage: api_shit_1170_tx_queue_sent_post.ts [--base-url <url>] --api-key <key> " +
|
|
92
|
+
"--queue-id <id> --tx-id <id> --tx-hash <hash> [--status <status>] " +
|
|
93
|
+
"[--tx-id <id> --tx-hash <hash> ...]",
|
|
94
|
+
);
|
|
95
|
+
process.exit(1);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
if (tx_ids.length !== tx_hashes.length) {
|
|
99
|
+
console.error(
|
|
100
|
+
`api_shit_1170_tx_queue_sent_post: every entry needs a --tx-id and a --tx-hash ` +
|
|
101
|
+
`(${tx_ids.length} tx id(s), ${tx_hashes.length} hash(es))`,
|
|
102
|
+
);
|
|
103
|
+
process.exit(1);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
// --- WHY --- the status is checked HERE and not only on the server:
|
|
107
|
+
// the backend only takes `succeeded` and `failed`, and a typo would
|
|
108
|
+
// come back as a 400 with a less useful message than this one.
|
|
109
|
+
const ALLOWED_STATUSES: SHIT_1170_TX_QUEUE_STATUS[] = [
|
|
110
|
+
"sent",
|
|
111
|
+
"succeeded",
|
|
112
|
+
"failed",
|
|
113
|
+
];
|
|
114
|
+
|
|
115
|
+
const txHashes: SHIT_1170_TX_QUEUE_HASH_REQUEST[] = [];
|
|
116
|
+
for (let i = 0; i < tx_ids.length; i++) {
|
|
117
|
+
const tx_id = tx_ids[i];
|
|
118
|
+
const tx_hash = tx_hashes[i];
|
|
119
|
+
if (tx_id === undefined || tx_hash === undefined) continue;
|
|
120
|
+
|
|
121
|
+
const entry: SHIT_1170_TX_QUEUE_HASH_REQUEST = {
|
|
122
|
+
txId: tx_id,
|
|
123
|
+
txHash: tx_hash,
|
|
124
|
+
};
|
|
125
|
+
|
|
126
|
+
const status = statuses[i];
|
|
127
|
+
if (status !== undefined) {
|
|
128
|
+
if (!ALLOWED_STATUSES.includes(status as SHIT_1170_TX_QUEUE_STATUS)) {
|
|
129
|
+
console.error(
|
|
130
|
+
`api_shit_1170_tx_queue_sent_post: the --status of entry ${i} must be one of ` +
|
|
131
|
+
`${ALLOWED_STATUSES.join(", ")}: ${status}`,
|
|
132
|
+
);
|
|
133
|
+
process.exit(1);
|
|
134
|
+
}
|
|
135
|
+
entry.status = status as SHIT_1170_TX_QUEUE_STATUS;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
txHashes.push(entry);
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
const queue_id = flags.get("--queue-id");
|
|
142
|
+
if (queue_id === undefined) {
|
|
143
|
+
console.error(
|
|
144
|
+
"usage: api_shit_1170_tx_queue_sent_post.ts [--base-url <url>] --api-key <key> " +
|
|
145
|
+
"--queue-id <id> --tx-id <id> --tx-hash <hash> [--status <status>]",
|
|
146
|
+
);
|
|
147
|
+
process.exit(1);
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
const queue = await api_shit_1170_tx_queue_sent_post(
|
|
151
|
+
base_url,
|
|
152
|
+
queue_id,
|
|
153
|
+
{ txHashes },
|
|
154
|
+
{ api_key: flags.get("--api-key") },
|
|
155
|
+
);
|
|
156
|
+
|
|
157
|
+
console.log(
|
|
158
|
+
`TX QUEUE ${queue.queueId}: ${queue.transactions.length} transaction(s), ` +
|
|
159
|
+
`${queue.accounts.length} account(s)`,
|
|
160
|
+
);
|
|
161
|
+
for (const transaction of queue.transactions) {
|
|
162
|
+
console.log(
|
|
163
|
+
` #${transaction.position} ${transaction.contractId}.${transaction.method}`,
|
|
164
|
+
);
|
|
165
|
+
for (const account of transaction.accounts) {
|
|
166
|
+
console.log(
|
|
167
|
+
` ${account.accountId} ${account.status} ${account.txHash ?? "(no hash)"}`,
|
|
168
|
+
);
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
// ========================================
|
|
172
|
+
// copyright 2026 by sleet.near
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
// ========================================
|
|
2
|
+
// API_SHIT_1170_TX_QUEUE_STATS_CONTRACTS_GET
|
|
3
|
+
// runnable bin for GET /api/shit-1170/tx-queue/stats/contracts 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_stats_contracts_get.ts \
|
|
8
|
+
// --api-key shit_1170_abc123... \
|
|
9
|
+
// --limit 20
|
|
10
|
+
//
|
|
11
|
+
// --- WHY --- a number flag that is not a number is named here rather
|
|
12
|
+
// than sent to the route to be clamped into silence.
|
|
13
|
+
// ========================================
|
|
14
|
+
|
|
15
|
+
import { api_shit_1170_tx_queue_stats_contracts_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 limit_raw = flags.get("--limit");
|
|
39
|
+
let limit: number | undefined;
|
|
40
|
+
if (limit_raw !== undefined) {
|
|
41
|
+
const parsed = Number(limit_raw);
|
|
42
|
+
if (!Number.isFinite(parsed)) {
|
|
43
|
+
console.error(`--limit must be a number: ${limit_raw}`);
|
|
44
|
+
process.exit(1);
|
|
45
|
+
}
|
|
46
|
+
limit = parsed;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
const stats = await api_shit_1170_tx_queue_stats_contracts_get(
|
|
50
|
+
base_url,
|
|
51
|
+
{ limit },
|
|
52
|
+
{ api_key: flags.get("--api-key") },
|
|
53
|
+
);
|
|
54
|
+
|
|
55
|
+
console.log(`TX QUEUE CONTRACT STATS: ${stats.items.length} contract(s)`);
|
|
56
|
+
for (const stat of stats.items) {
|
|
57
|
+
console.log(` ${stat.contractId} ${stat.count}`);
|
|
58
|
+
}
|
|
59
|
+
// ========================================
|
|
60
|
+
// copyright 2026 by sleet.near
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
// ========================================
|
|
2
|
+
// API_SHIT_1170_TX_QUEUE_STATS_METHODS_GET
|
|
3
|
+
// runnable bin for GET /api/shit-1170/tx-queue/stats/methods 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_stats_methods_get.ts \
|
|
8
|
+
// --api-key shit_1170_abc123... \
|
|
9
|
+
// --limit 20
|
|
10
|
+
//
|
|
11
|
+
// --- WHY --- a number flag that is not a number is named here rather
|
|
12
|
+
// than sent to the route to be clamped into silence.
|
|
13
|
+
// ========================================
|
|
14
|
+
|
|
15
|
+
import { api_shit_1170_tx_queue_stats_methods_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 limit_raw = flags.get("--limit");
|
|
39
|
+
let limit: number | undefined;
|
|
40
|
+
if (limit_raw !== undefined) {
|
|
41
|
+
const parsed = Number(limit_raw);
|
|
42
|
+
if (!Number.isFinite(parsed)) {
|
|
43
|
+
console.error(`--limit must be a number: ${limit_raw}`);
|
|
44
|
+
process.exit(1);
|
|
45
|
+
}
|
|
46
|
+
limit = parsed;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
const stats = await api_shit_1170_tx_queue_stats_methods_get(
|
|
50
|
+
base_url,
|
|
51
|
+
{ limit },
|
|
52
|
+
{ api_key: flags.get("--api-key") },
|
|
53
|
+
);
|
|
54
|
+
|
|
55
|
+
console.log(`TX QUEUE METHOD STATS: ${stats.items.length} method(s)`);
|
|
56
|
+
for (const stat of stats.items) {
|
|
57
|
+
console.log(` ${stat.contractId}.${stat.method} ${stat.count}`);
|
|
58
|
+
}
|
|
59
|
+
// ========================================
|
|
60
|
+
// copyright 2026 by sleet.near
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
// ========================================
|
|
2
|
+
// API_TREZU_TREASURIES_GET
|
|
3
|
+
// runnable bin for GET /api/trezu/user/treasuries via middleman.
|
|
4
|
+
// the middleman logs the framed request + response, so this bin only
|
|
5
|
+
// adds a summary.
|
|
6
|
+
//
|
|
7
|
+
// argv:
|
|
8
|
+
// bun middleman/bin/shit-1170/api_trezu_treasuries_get.ts <account_id> \
|
|
9
|
+
// [--include-hidden] [--base-url <url>]
|
|
10
|
+
// ========================================
|
|
11
|
+
|
|
12
|
+
import { api_trezu_treasuries_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.
|
|
18
|
+
const DEFAULT_BASE_URL = "http://127.0.0.1:54733";
|
|
19
|
+
|
|
20
|
+
// --- FLAGS ---------------------------------------------------------
|
|
21
|
+
// the flags of this bin that take no value.
|
|
22
|
+
const BOOLEAN_FLAGS = ["--include-hidden"];
|
|
23
|
+
|
|
24
|
+
// --- argv ----------------------------------------------------------
|
|
25
|
+
// argv[0] is bun, argv[1] is this script, so real args start at 2.
|
|
26
|
+
const { positional, seen } = split_argv(process.argv.slice(2), {
|
|
27
|
+
boolean_flags: BOOLEAN_FLAGS,
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
const account_id = positional[0];
|
|
31
|
+
if (account_id === undefined) {
|
|
32
|
+
console.error(
|
|
33
|
+
"usage: bun middleman/bin/shit-1170/api_trezu_treasuries_get.ts <account_id> " +
|
|
34
|
+
"[--include-hidden] [--base-url <url>]",
|
|
35
|
+
);
|
|
36
|
+
process.exit(1);
|
|
37
|
+
}
|
|
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(process.argv.slice(2), DEFAULT_BASE_URL);
|
|
44
|
+
|
|
45
|
+
const treasuries = await api_trezu_treasuries_get(base_url, {
|
|
46
|
+
accountId: account_id,
|
|
47
|
+
includeHidden: seen.has("--include-hidden") ? true : undefined,
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
console.log("TREASURIES", `${treasuries.length} for ${account_id}`);
|
|
51
|
+
for (const treasury of treasuries) {
|
|
52
|
+
const name = treasury.config?.name ?? "(no name)";
|
|
53
|
+
console.log(
|
|
54
|
+
" ",
|
|
55
|
+
treasury.daoId,
|
|
56
|
+
`| ${name}`,
|
|
57
|
+
treasury.isMember ? "| member" : "",
|
|
58
|
+
treasury.isHidden ? "| hidden" : "",
|
|
59
|
+
);
|
|
60
|
+
}
|
|
61
|
+
// ========================================
|
|
62
|
+
// copyright 2026 by sleet.near
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { REQUEST_OPTIONS } from "../stuff/request_options";
|
|
2
|
+
import type { SHIT_1170_API_KEY_ME } from "../types/shit_1170_api_keys";
|
|
3
|
+
export declare function api_shit_1170_api_key_me_get(base_url: string, options?: REQUEST_OPTIONS): Promise<SHIT_1170_API_KEY_ME>;
|
|
4
|
+
//# sourceMappingURL=api_shit_1170_api_key_me_get.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api_shit_1170_api_key_me_get.d.ts","sourceRoot":"","sources":["../../src/fun/api_shit_1170_api_key_me_get.ts"],"names":[],"mappings":"AAmBA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAChE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AAExE,wBAAsB,4BAA4B,CAChD,QAAQ,EAAE,MAAM,EAChB,OAAO,GAAE,eAAoB,GAC5B,OAAO,CAAC,oBAAoB,CAAC,CAsB/B"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
// ========================================
|
|
2
|
+
// API_SHIT_1170_API_KEY_ME_GET
|
|
3
|
+
// GET /api/shit-1170/api-key/me — which account does this api key
|
|
4
|
+
// belong to.
|
|
5
|
+
//
|
|
6
|
+
// the first route that REQUIRES the api key. the key travels in the
|
|
7
|
+
// `x-api-key` header, and the answer is the account the key belongs
|
|
8
|
+
// to.
|
|
9
|
+
//
|
|
10
|
+
// the caller passes the key through `options.api_key`. a caller that
|
|
11
|
+
// has no key gets a 401, and the error is thrown like any other.
|
|
12
|
+
//
|
|
13
|
+
// --- WHY --- the key is a PARAMETER and not something the wrapper
|
|
14
|
+
// fetches: the middleman is a plain client with no browser state, so it
|
|
15
|
+
// cannot know the user's key. the frontend attaches it — see
|
|
16
|
+
// frontend/lib/ts/shared/api_key_token.ts.
|
|
17
|
+
// ========================================
|
|
18
|
+
import { api_call } from "../stuff/api_call";
|
|
19
|
+
export async function api_shit_1170_api_key_me_get(base_url, options = {}) {
|
|
20
|
+
const json = await api_call({
|
|
21
|
+
base_url,
|
|
22
|
+
key: "api_shit_1170_api_key_me",
|
|
23
|
+
method: "GET",
|
|
24
|
+
options,
|
|
25
|
+
label: "SHIT_1170 API KEY ME GET",
|
|
26
|
+
fallback: "api_shit_1170_api_key_me_get failed",
|
|
27
|
+
});
|
|
28
|
+
if (typeof json !== "object" ||
|
|
29
|
+
json === null ||
|
|
30
|
+
Array.isArray(json) ||
|
|
31
|
+
typeof json.accountId !== "string") {
|
|
32
|
+
throw new Error("api_shit_1170_api_key_me_get failed: invalid_response: expected a json object with an accountId");
|
|
33
|
+
}
|
|
34
|
+
return json;
|
|
35
|
+
}
|
|
36
|
+
// ========================================
|
|
37
|
+
// copyright 2026 by sleet.near
|
|
38
|
+
//# sourceMappingURL=api_shit_1170_api_key_me_get.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api_shit_1170_api_key_me_get.js","sourceRoot":"","sources":["../../src/fun/api_shit_1170_api_key_me_get.ts"],"names":[],"mappings":"AAAA,2CAA2C;AAC3C,+BAA+B;AAC/B,kEAAkE;AAClE,aAAa;AACb,EAAE;AACF,oEAAoE;AACpE,oEAAoE;AACpE,MAAM;AACN,EAAE;AACF,qEAAqE;AACrE,iEAAiE;AACjE,EAAE;AACF,mEAAmE;AACnE,wEAAwE;AACxE,6DAA6D;AAC7D,2CAA2C;AAC3C,2CAA2C;AAE3C,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAI7C,MAAM,CAAC,KAAK,UAAU,4BAA4B,CAChD,QAAgB,EAChB,OAAO,GAAoB,EAAE;IAE7B,MAAM,IAAI,GAAG,MAAM,QAAQ,CAAuB;QAChD,QAAQ;QACR,GAAG,EAAE,0BAA0B;QAC/B,MAAM,EAAE,KAAK;QACb,OAAO;QACP,KAAK,EAAE,0BAA0B;QACjC,QAAQ,EAAE,qCAAqC;KAChD,CAAC,CAAC;IAEH,IACE,OAAO,IAAI,KAAK,QAAQ;QACxB,IAAI,KAAK,IAAI;QACb,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC;QACnB,OAAO,IAAI,CAAC,SAAS,KAAK,QAAQ,EAClC,CAAC;QACD,MAAM,IAAI,KAAK,CACb,iGAAiG,CAClG,CAAC;IACJ,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC;AACD,2CAA2C;AAC3C,+BAA+B"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { REQUEST_OPTIONS } from "../stuff/request_options";
|
|
2
|
+
import type { SHIT_1170_API_KEY, SHIT_1170_API_KEYS_REQUEST } from "../types/shit_1170_api_keys";
|
|
3
|
+
export declare function api_shit_1170_api_key_rotate_post(base_url: string, body: SHIT_1170_API_KEYS_REQUEST, options?: REQUEST_OPTIONS): Promise<SHIT_1170_API_KEY>;
|
|
4
|
+
//# sourceMappingURL=api_shit_1170_api_key_rotate_post.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api_shit_1170_api_key_rotate_post.d.ts","sourceRoot":"","sources":["../../src/fun/api_shit_1170_api_key_rotate_post.ts"],"names":[],"mappings":"AAmBA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAChE,OAAO,KAAK,EACV,iBAAiB,EACjB,0BAA0B,EAC3B,MAAM,6BAA6B,CAAC;AAErC,wBAAsB,iCAAiC,CACrD,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,0BAA0B,EAChC,OAAO,GAAE,eAAoB,GAC5B,OAAO,CAAC,iBAAiB,CAAC,CAmC5B"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
// ========================================
|
|
2
|
+
// API_SHIT_1170_API_KEY_ROTATE_POST
|
|
3
|
+
// POST /api/shit-1170/api-key/rotate — give an account a NEW api key.
|
|
4
|
+
//
|
|
5
|
+
// the old key stops working at once and the new one takes its place.
|
|
6
|
+
//
|
|
7
|
+
// the request carries the account's SIGNED MESSAGE, not the old key: the
|
|
8
|
+
// old key is what a thief has, so a rotation that only needed the old
|
|
9
|
+
// key could be done by the thief. the signed message proves the owner
|
|
10
|
+
// still holds the account's NEAR key.
|
|
11
|
+
//
|
|
12
|
+
// no wallet popup is needed — the browser already holds the signed
|
|
13
|
+
// message in its local storage from the sign-in.
|
|
14
|
+
//
|
|
15
|
+
// the caller passes the api key so the backend can be sure the rotation
|
|
16
|
+
// is for the account the key belongs to.
|
|
17
|
+
// ========================================
|
|
18
|
+
import { api_call } from "../stuff/api_call";
|
|
19
|
+
export async function api_shit_1170_api_key_rotate_post(base_url, body, options = {}) {
|
|
20
|
+
if (!Array.isArray(body.accounts) || body.accounts.length === 0) {
|
|
21
|
+
throw new Error("api_shit_1170_api_key_rotate_post failed: invalid_request: a rotation needs one signed account");
|
|
22
|
+
}
|
|
23
|
+
if (body.accounts.length > 1) {
|
|
24
|
+
throw new Error("api_shit_1170_api_key_rotate_post failed: invalid_request: a rotation is for one account at a time");
|
|
25
|
+
}
|
|
26
|
+
const json = await api_call({
|
|
27
|
+
base_url,
|
|
28
|
+
key: "api_shit_1170_api_key_rotate",
|
|
29
|
+
method: "POST",
|
|
30
|
+
body,
|
|
31
|
+
options,
|
|
32
|
+
label: "SHIT_1170 API KEY ROTATE POST",
|
|
33
|
+
fallback: "api_shit_1170_api_key_rotate_post failed",
|
|
34
|
+
});
|
|
35
|
+
if (typeof json !== "object" ||
|
|
36
|
+
json === null ||
|
|
37
|
+
Array.isArray(json) ||
|
|
38
|
+
typeof json.accountId !== "string" ||
|
|
39
|
+
typeof json.apiKey !== "string") {
|
|
40
|
+
throw new Error("api_shit_1170_api_key_rotate_post failed: invalid_response: expected a json object with accountId and apiKey");
|
|
41
|
+
}
|
|
42
|
+
return json;
|
|
43
|
+
}
|
|
44
|
+
// ========================================
|
|
45
|
+
// copyright 2026 by sleet.near
|
|
46
|
+
//# sourceMappingURL=api_shit_1170_api_key_rotate_post.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api_shit_1170_api_key_rotate_post.js","sourceRoot":"","sources":["../../src/fun/api_shit_1170_api_key_rotate_post.ts"],"names":[],"mappings":"AAAA,2CAA2C;AAC3C,oCAAoC;AACpC,sEAAsE;AACtE,EAAE;AACF,qEAAqE;AACrE,EAAE;AACF,yEAAyE;AACzE,sEAAsE;AACtE,sEAAsE;AACtE,sCAAsC;AACtC,EAAE;AACF,mEAAmE;AACnE,iDAAiD;AACjD,EAAE;AACF,wEAAwE;AACxE,yCAAyC;AACzC,2CAA2C;AAE3C,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAO7C,MAAM,CAAC,KAAK,UAAU,iCAAiC,CACrD,QAAgB,EAChB,IAAgC,EAChC,OAAO,GAAoB,EAAE;IAE7B,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,IAAI,CAAC,QAAQ,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAChE,MAAM,IAAI,KAAK,CACb,gGAAgG,CACjG,CAAC;IACJ,CAAC;IACD,IAAI,IAAI,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC7B,MAAM,IAAI,KAAK,CACb,oGAAoG,CACrG,CAAC;IACJ,CAAC;IAED,MAAM,IAAI,GAAG,MAAM,QAAQ,CAAoB;QAC7C,QAAQ;QACR,GAAG,EAAE,8BAA8B;QACnC,MAAM,EAAE,MAAM;QACd,IAAI;QACJ,OAAO;QACP,KAAK,EAAE,+BAA+B;QACtC,QAAQ,EAAE,0CAA0C;KACrD,CAAC,CAAC;IAEH,IACE,OAAO,IAAI,KAAK,QAAQ;QACxB,IAAI,KAAK,IAAI;QACb,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC;QACnB,OAAO,IAAI,CAAC,SAAS,KAAK,QAAQ;QAClC,OAAO,IAAI,CAAC,MAAM,KAAK,QAAQ,EAC/B,CAAC;QACD,MAAM,IAAI,KAAK,CACb,8GAA8G,CAC/G,CAAC;IACJ,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC;AACD,2CAA2C;AAC3C,+BAA+B"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { SHIT_1170_API_KEYS_REQUEST, SHIT_1170_API_KEYS_RESPONSE } from "../types/shit_1170_api_keys";
|
|
2
|
+
export declare function api_shit_1170_api_keys_post(base_url: string, body: SHIT_1170_API_KEYS_REQUEST): Promise<SHIT_1170_API_KEYS_RESPONSE>;
|
|
3
|
+
//# sourceMappingURL=api_shit_1170_api_keys_post.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api_shit_1170_api_keys_post.d.ts","sourceRoot":"","sources":["../../src/fun/api_shit_1170_api_keys_post.ts"],"names":[],"mappings":"AAsBA,OAAO,KAAK,EACV,0BAA0B,EAC1B,2BAA2B,EAC5B,MAAM,6BAA6B,CAAC;AAErC,wBAAsB,2BAA2B,CAC/C,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,0BAA0B,GAC/B,OAAO,CAAC,2BAA2B,CAAC,CAyCtC"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
// ========================================
|
|
2
|
+
// API_SHIT_1170_API_KEYS_POST
|
|
3
|
+
// POST /api/shit-1170/api-keys — turn signed messages into api keys.
|
|
4
|
+
//
|
|
5
|
+
// the browser sends every account it holds a signature for; the backend
|
|
6
|
+
// verifies each one and answers with ONE KEY PER ACCOUNT.
|
|
7
|
+
//
|
|
8
|
+
// same-origin call, so the browser needs no cors. a non-2xx or a body
|
|
9
|
+
// that is not the expected json object throws a readable Error.
|
|
10
|
+
//
|
|
11
|
+
// --- WHY --- the request is checked HERE and not only on the server:
|
|
12
|
+
// an empty accounts list is a programming mistake, and catching it
|
|
13
|
+
// before the request means the caller gets a clear message instead of a
|
|
14
|
+
// 400 from the wire.
|
|
15
|
+
//
|
|
16
|
+
// --- WHY --- the answer's key field is `apiKey`: the credential in it
|
|
17
|
+
// is not a browser session. the user signs in once and hands the key
|
|
18
|
+
// to an agent, and the agent holds it as a bearer token for as long as
|
|
19
|
+
// it lives.
|
|
20
|
+
// ========================================
|
|
21
|
+
import { api_call } from "../stuff/api_call";
|
|
22
|
+
export async function api_shit_1170_api_keys_post(base_url, body) {
|
|
23
|
+
if (!Array.isArray(body.accounts) || body.accounts.length === 0) {
|
|
24
|
+
throw new Error("api_shit_1170_api_keys_post failed: invalid_request: at least one signed account is required");
|
|
25
|
+
}
|
|
26
|
+
const json = await api_call({
|
|
27
|
+
base_url,
|
|
28
|
+
key: "api_shit_1170_api_keys",
|
|
29
|
+
method: "POST",
|
|
30
|
+
body,
|
|
31
|
+
label: "SHIT_1170 API KEYS POST",
|
|
32
|
+
fallback: "api_shit_1170_api_keys_post failed",
|
|
33
|
+
});
|
|
34
|
+
if (typeof json !== "object" ||
|
|
35
|
+
json === null ||
|
|
36
|
+
Array.isArray(json) ||
|
|
37
|
+
!Array.isArray(json.keys)) {
|
|
38
|
+
throw new Error("api_shit_1170_api_keys_post failed: invalid_response: expected a json object with a keys array");
|
|
39
|
+
}
|
|
40
|
+
// every entry has to carry an account id and a key — the caller walks
|
|
41
|
+
// the list and pairs each key with its account.
|
|
42
|
+
for (const entry of json.keys) {
|
|
43
|
+
if (typeof entry?.accountId !== "string" ||
|
|
44
|
+
typeof entry?.apiKey !== "string") {
|
|
45
|
+
throw new Error("api_shit_1170_api_keys_post failed: invalid_response: every key entry needs an accountId and an apiKey");
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
return json;
|
|
49
|
+
}
|
|
50
|
+
// ========================================
|
|
51
|
+
// copyright 2026 by sleet.near
|
|
52
|
+
//# sourceMappingURL=api_shit_1170_api_keys_post.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api_shit_1170_api_keys_post.js","sourceRoot":"","sources":["../../src/fun/api_shit_1170_api_keys_post.ts"],"names":[],"mappings":"AAAA,2CAA2C;AAC3C,8BAA8B;AAC9B,qEAAqE;AACrE,EAAE;AACF,wEAAwE;AACxE,0DAA0D;AAC1D,EAAE;AACF,sEAAsE;AACtE,gEAAgE;AAChE,EAAE;AACF,sEAAsE;AACtE,mEAAmE;AACnE,wEAAwE;AACxE,qBAAqB;AACrB,EAAE;AACF,uEAAuE;AACvE,qEAAqE;AACrE,uEAAuE;AACvE,YAAY;AACZ,2CAA2C;AAE3C,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAM7C,MAAM,CAAC,KAAK,UAAU,2BAA2B,CAC/C,QAAgB,EAChB,IAAgC;IAEhC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,IAAI,CAAC,QAAQ,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAChE,MAAM,IAAI,KAAK,CACb,8FAA8F,CAC/F,CAAC;IACJ,CAAC;IAED,MAAM,IAAI,GAAG,MAAM,QAAQ,CAA8B;QACvD,QAAQ;QACR,GAAG,EAAE,wBAAwB;QAC7B,MAAM,EAAE,MAAM;QACd,IAAI;QACJ,KAAK,EAAE,yBAAyB;QAChC,QAAQ,EAAE,oCAAoC;KAC/C,CAAC,CAAC;IAEH,IACE,OAAO,IAAI,KAAK,QAAQ;QACxB,IAAI,KAAK,IAAI;QACb,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC;QACnB,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,EACzB,CAAC;QACD,MAAM,IAAI,KAAK,CACb,gGAAgG,CACjG,CAAC;IACJ,CAAC;IAED,sEAAsE;IACtE,gDAAgD;IAChD,KAAK,MAAM,KAAK,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC;QAC9B,IACE,OAAO,KAAK,EAAE,SAAS,KAAK,QAAQ;YACpC,OAAO,KAAK,EAAE,MAAM,KAAK,QAAQ,EACjC,CAAC;YACD,MAAM,IAAI,KAAK,CACb,wGAAwG,CACzG,CAAC;QACJ,CAAC;IACH,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC;AACD,2CAA2C;AAC3C,+BAA+B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api_shit_1170_ping_get.d.ts","sourceRoot":"","sources":["../../src/fun/api_shit_1170_ping_get.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAE9D,wBAAsB,sBAAsB,CAC1C,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC,cAAc,CAAC,CAsBzB"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
// ========================================
|
|
2
|
+
// API_SHIT_1170_PING_GET
|
|
3
|
+
// GET /api/shit-1170/ping — the liveness check of our own backend.
|
|
4
|
+
//
|
|
5
|
+
// this route is OURS: it is not a proxy for another api, so it is
|
|
6
|
+
// named after us, the way /api/shit-1170/* is named after us in the
|
|
7
|
+
// url (see DOCS/ROUTES.md).
|
|
8
|
+
//
|
|
9
|
+
// same-origin call, so the browser needs no cors. a non-2xx or a body
|
|
10
|
+
// that is not the expected json object throws a readable Error.
|
|
11
|
+
// ========================================
|
|
12
|
+
import { api_call } from "../stuff/api_call";
|
|
13
|
+
export async function api_shit_1170_ping_get(base_url) {
|
|
14
|
+
const json = await api_call({
|
|
15
|
+
base_url,
|
|
16
|
+
key: "api_shit_1170_ping",
|
|
17
|
+
method: "GET",
|
|
18
|
+
label: "SHIT_1170 PING GET",
|
|
19
|
+
fallback: "api_shit_1170_ping_get failed",
|
|
20
|
+
});
|
|
21
|
+
if (typeof json !== "object" ||
|
|
22
|
+
json === null ||
|
|
23
|
+
Array.isArray(json) ||
|
|
24
|
+
typeof json.ok !== "boolean" ||
|
|
25
|
+
typeof json.app !== "string") {
|
|
26
|
+
throw new Error("api_shit_1170_ping_get failed: invalid_response: expected a json object with ok and app");
|
|
27
|
+
}
|
|
28
|
+
return json;
|
|
29
|
+
}
|
|
30
|
+
// ========================================
|
|
31
|
+
// copyright 2026 by sleet.near
|
|
32
|
+
//# sourceMappingURL=api_shit_1170_ping_get.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api_shit_1170_ping_get.js","sourceRoot":"","sources":["../../src/fun/api_shit_1170_ping_get.ts"],"names":[],"mappings":"AAAA,2CAA2C;AAC3C,yBAAyB;AACzB,mEAAmE;AACnE,EAAE;AACF,kEAAkE;AAClE,oEAAoE;AACpE,4BAA4B;AAC5B,EAAE;AACF,sEAAsE;AACtE,gEAAgE;AAChE,2CAA2C;AAE3C,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAG7C,MAAM,CAAC,KAAK,UAAU,sBAAsB,CAC1C,QAAgB;IAEhB,MAAM,IAAI,GAAG,MAAM,QAAQ,CAAiB;QAC1C,QAAQ;QACR,GAAG,EAAE,oBAAoB;QACzB,MAAM,EAAE,KAAK;QACb,KAAK,EAAE,oBAAoB;QAC3B,QAAQ,EAAE,+BAA+B;KAC1C,CAAC,CAAC;IAEH,IACE,OAAO,IAAI,KAAK,QAAQ;QACxB,IAAI,KAAK,IAAI;QACb,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC;QACnB,OAAQ,IAAuB,CAAC,EAAE,KAAK,SAAS;QAChD,OAAQ,IAAuB,CAAC,GAAG,KAAK,QAAQ,EAChD,CAAC;QACD,MAAM,IAAI,KAAK,CACb,yFAAyF,CAC1F,CAAC;IACJ,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC;AACD,2CAA2C;AAC3C,+BAA+B"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { REQUEST_OPTIONS } from "../stuff/request_options";
|
|
2
|
+
import type { SHIT_1170_SWAP_QUEUE } from "../types/shit_1170_swap_queue";
|
|
3
|
+
export declare function api_shit_1170_swap_queue_accounts_delete(base_url: string, swap_id: string, account_id: string, options?: REQUEST_OPTIONS): Promise<SHIT_1170_SWAP_QUEUE>;
|
|
4
|
+
//# sourceMappingURL=api_shit_1170_swap_queue_accounts_delete.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api_shit_1170_swap_queue_accounts_delete.d.ts","sourceRoot":"","sources":["../../src/fun/api_shit_1170_swap_queue_accounts_delete.ts"],"names":[],"mappings":"AAiBA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAChE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,+BAA+B,CAAC;AAE1E,wBAAsB,wCAAwC,CAC5D,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,MAAM,EACf,UAAU,EAAE,MAAM,EAClB,OAAO,GAAE,eAAoB,GAC5B,OAAO,CAAC,oBAAoB,CAAC,CAqC/B"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
// ========================================
|
|
2
|
+
// API_SHIT_1170_SWAP_QUEUE_ACCOUNTS_DELETE
|
|
3
|
+
// DELETE /api/shit-1170/swap-queue/{swap_id}/accounts/{account_id} —
|
|
4
|
+
// remove YOUR OWN account from a queued swap.
|
|
5
|
+
//
|
|
6
|
+
// the rule: the api key must belong to the account being removed. you
|
|
7
|
+
// can remove yourself from a swap, and only yourself.
|
|
8
|
+
//
|
|
9
|
+
// --- WHY --- a row that already carries a HASH is HISTORY and is not
|
|
10
|
+
// deleted: the swap happened, and the swap shows who did it.
|
|
11
|
+
//
|
|
12
|
+
// --- WHY --- the path is built HERE and not read out of the endpoint
|
|
13
|
+
// map: the swap_id and the account_id both sit in the MIDDLE of the
|
|
14
|
+
// path.
|
|
15
|
+
// ========================================
|
|
16
|
+
import { api_call } from "../stuff/api_call";
|
|
17
|
+
export async function api_shit_1170_swap_queue_accounts_delete(base_url, swap_id, account_id, options = {}) {
|
|
18
|
+
const swap_id_trimmed = swap_id.trim();
|
|
19
|
+
if (swap_id_trimmed.length === 0) {
|
|
20
|
+
throw new Error("api_shit_1170_swap_queue_accounts_delete failed: invalid_request: a swap id is required");
|
|
21
|
+
}
|
|
22
|
+
const account_id_trimmed = account_id.trim();
|
|
23
|
+
if (account_id_trimmed.length === 0) {
|
|
24
|
+
throw new Error("api_shit_1170_swap_queue_accounts_delete failed: invalid_request: an account id is required");
|
|
25
|
+
}
|
|
26
|
+
const json = await api_call({
|
|
27
|
+
base_url,
|
|
28
|
+
key: "api_shit_1170_swap_queue",
|
|
29
|
+
path: `/api/shit-1170/swap-queue/${encodeURIComponent(swap_id_trimmed)}/accounts/${encodeURIComponent(account_id_trimmed)}`,
|
|
30
|
+
method: "DELETE",
|
|
31
|
+
options,
|
|
32
|
+
label: "SHIT_1170 SWAP QUEUE ACCOUNTS DELETE",
|
|
33
|
+
fallback: "api_shit_1170_swap_queue_accounts_delete failed",
|
|
34
|
+
});
|
|
35
|
+
if (typeof json !== "object" ||
|
|
36
|
+
json === null ||
|
|
37
|
+
Array.isArray(json) ||
|
|
38
|
+
typeof json.swapId !== "string" ||
|
|
39
|
+
!Array.isArray(json.accounts)) {
|
|
40
|
+
throw new Error("api_shit_1170_swap_queue_accounts_delete failed: invalid_response: expected a json object with a swapId and an accounts array");
|
|
41
|
+
}
|
|
42
|
+
return json;
|
|
43
|
+
}
|
|
44
|
+
// ========================================
|
|
45
|
+
// copyright 2026 by sleet.near
|
|
46
|
+
//# sourceMappingURL=api_shit_1170_swap_queue_accounts_delete.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api_shit_1170_swap_queue_accounts_delete.js","sourceRoot":"","sources":["../../src/fun/api_shit_1170_swap_queue_accounts_delete.ts"],"names":[],"mappings":"AAAA,2CAA2C;AAC3C,2CAA2C;AAC3C,qEAAqE;AACrE,8CAA8C;AAC9C,EAAE;AACF,sEAAsE;AACtE,sDAAsD;AACtD,EAAE;AACF,sEAAsE;AACtE,6DAA6D;AAC7D,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,QAAQ;AACR,2CAA2C;AAE3C,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAI7C,MAAM,CAAC,KAAK,UAAU,wCAAwC,CAC5D,QAAgB,EAChB,OAAe,EACf,UAAkB,EAClB,OAAO,GAAoB,EAAE;IAE7B,MAAM,eAAe,GAAG,OAAO,CAAC,IAAI,EAAE,CAAC;IACvC,IAAI,eAAe,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACjC,MAAM,IAAI,KAAK,CACb,yFAAyF,CAC1F,CAAC;IACJ,CAAC;IACD,MAAM,kBAAkB,GAAG,UAAU,CAAC,IAAI,EAAE,CAAC;IAC7C,IAAI,kBAAkB,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACpC,MAAM,IAAI,KAAK,CACb,6FAA6F,CAC9F,CAAC;IACJ,CAAC;IAED,MAAM,IAAI,GAAG,MAAM,QAAQ,CAAuB;QAChD,QAAQ;QACR,GAAG,EAAE,0BAA0B;QAC/B,IAAI,EAAE,6BAA6B,kBAAkB,CAAC,eAAe,CAAC,aAAa,kBAAkB,CAAC,kBAAkB,CAAC,EAAE;QAC3H,MAAM,EAAE,QAAQ;QAChB,OAAO;QACP,KAAK,EAAE,sCAAsC;QAC7C,QAAQ,EAAE,iDAAiD;KAC5D,CAAC,CAAC;IAEH,IACE,OAAO,IAAI,KAAK,QAAQ;QACxB,IAAI,KAAK,IAAI;QACb,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC;QACnB,OAAO,IAAI,CAAC,MAAM,KAAK,QAAQ;QAC/B,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,EAC7B,CAAC;QACD,MAAM,IAAI,KAAK,CACb,+HAA+H,CAChI,CAAC;IACJ,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC;AACD,2CAA2C;AAC3C,+BAA+B"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { REQUEST_OPTIONS } from "../stuff/request_options";
|
|
2
|
+
import type { SHIT_1170_SWAP_QUEUE, SHIT_1170_SWAP_QUEUE_ACCOUNT_REQUEST } from "../types/shit_1170_swap_queue";
|
|
3
|
+
export declare function api_shit_1170_swap_queue_accounts_post(base_url: string, swap_id: string, body: SHIT_1170_SWAP_QUEUE_ACCOUNT_REQUEST, options?: REQUEST_OPTIONS): Promise<SHIT_1170_SWAP_QUEUE>;
|
|
4
|
+
//# sourceMappingURL=api_shit_1170_swap_queue_accounts_post.d.ts.map
|