Skip to content

Commit 9b601f8

Browse files
author
Josh Hardy
committed
feat: polish --describe output and label calldata transactions
- Mark each field as (required) or (optional, default: X) - Add a units convention note to the usage section - Add a build-once guidance section (run binary directly, avoid the npm install noise from the nix develop shellHook) - Label calldata stdout lines with # comment headers describing each tx - Update the cast-send pipe example to skip # comment lines and blank lines - Document the # comment convention in the output format section The # comment lines are safe for any submitter that skips lines not matching <address>:<hex> — cast-loop example shows the idiom. The stox submit parser will be updated in a follow-up PR to do the same.
1 parent 4acbab1 commit 9b601f8

2 files changed

Lines changed: 52 additions & 15 deletions

File tree

crates/cli/src/commands/strategy_builder/describe.rs

Lines changed: 49 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -28,16 +28,30 @@ raindex strategy-builder \
2828
Each deployment below has an **Example command** with the required flags
2929
pre-filled for that specific deployment.
3030
31+
Field values passed via `--set-field` are in human-readable decimal form — the
32+
tool handles token-decimal scaling internally. You do not need to multiply by
33+
`10^decimals`.
34+
3135
### Output format
3236
33-
The command writes one transaction per line to stdout, each in the form:
37+
The command writes one transaction per line to stdout. Each transaction is
38+
preceded by a `#` comment line describing what the transaction does. The lines
39+
look like:
3440
3541
```
36-
<to-address>:<hex-calldata>
42+
# approve WETH
43+
0x...:0x095ea7b3...
44+
# deploy order
45+
0xe522cB4a...:0xac9650d8...
46+
# emit strategy metadata
47+
0x59401C93...:0x37480e2a...
3748
```
3849
39-
Multiple lines are possible — they must be signed and broadcast in order.
40-
Output contains (in order):
50+
Submitters should skip lines starting with `#` and split the remaining lines on
51+
the first `:` to get `(to-address, hex-calldata)` pairs.
52+
53+
Multiple non-comment lines are possible — they must be signed and broadcast in
54+
order. Output contains (in order):
4155
4256
1. One ERC20 `approve` transaction per token being deposited. If you pass
4357
no `--set-deposit` flags, there are no approvals.
@@ -56,21 +70,41 @@ Option B — sign and broadcast each line with `cast send` (foundry):
5670
5771
```
5872
raindex strategy-builder ... | while IFS=: read -r to data; do
73+
[[ "$to" == \#* || -z "$to" ]] && continue
5974
cast send "$to" "$data" \
6075
--private-key "$PRIVATE_KEY" \
6176
--rpc-url "$RPC_URL"
6277
done
6378
```
6479
65-
Option C — pipe into any other submitter that reads `address:calldata` lines.
80+
Option C — pipe into any other submitter that reads `address:calldata` lines
81+
(skipping `#` comment lines).
6682
6783
### Picking token addresses
6884
69-
Token addresses are chain-specific. Look them up on a block explorer
70-
(basescan.org, etherscan.io, etc.) or a token list for the target network.
71-
Each deployment below lists the tokens that must be selected via
72-
`--select-token KEY=<address>`; the KEY side is a slot name defined by the
73-
strategy, the `<address>` side is the ERC20 contract address you pick.
85+
Token addresses are chain-specific. Each deployment below lists the tokens
86+
that must be selected via `--select-token KEY=<address>`. To see which token
87+
addresses the registry has for a given deployment, use `--tokens`:
88+
89+
```
90+
raindex strategy-builder --tokens \
91+
--registry <url> --strategy <key> --deployment <key>
92+
```
93+
94+
Any ERC20 address is valid for `--select-token`; the registry list is just a
95+
curated convenience subset.
96+
97+
### Building the CLI from source
98+
99+
If you're running this from a local clone, build once and call the binary
100+
directly — the `nix develop` shellHook runs `npm install` on every invocation
101+
which is noisy and slow.
102+
103+
```
104+
cd rain.orderbook
105+
nix develop --impure --command cargo build -p rain_orderbook_cli
106+
./target/debug/rain_orderbook_cli strategy-builder --describe --registry <url>
107+
```
74108
75109
"#;
76110

@@ -292,11 +326,11 @@ fn describe_fields(
292326
writeln!(out, "**Fields:**")?;
293327
writeln!(out)?;
294328
for field in &deployment.fields {
295-
write!(out, "- `{}` ({})", field.binding, field.name)?;
296-
if let Some(default) = &field.default {
297-
write!(out, " _[default: `{default}`]_")?;
298-
}
299-
writeln!(out)?;
329+
let marker = match &field.default {
330+
Some(default) => format!(" _(optional, default: `{default}`)_"),
331+
None => " _(required)_".to_string(),
332+
};
333+
writeln!(out, "- `{}` ({}){marker}", field.binding, field.name)?;
300334
if let Some(desc) = &field.description {
301335
writeln!(out, " - {desc}")?;
302336
}

crates/cli/src/commands/strategy_builder/mod.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,16 +184,19 @@ impl Execute for StrategyBuilder {
184184
})?;
185185

186186
for approval in &args.approvals {
187+
println!("# approve {}", approval.symbol);
187188
println!("{}:0x{}", approval.token, hex::encode(&approval.calldata));
188189
}
189190

191+
println!("# deploy {strategy} order");
190192
println!(
191193
"{}:0x{}",
192194
args.orderbook_address,
193195
hex::encode(&args.deployment_calldata)
194196
);
195197

196198
if let Some(meta_call) = &args.emit_meta_call {
199+
println!("# emit strategy metadata");
197200
println!("{}:0x{}", meta_call.to, hex::encode(&meta_call.calldata));
198201
}
199202

0 commit comments

Comments
 (0)