cli: when interacting with a network output tx hash
Maybe even with a link to the transaction page in a supported block explorer
It would be helpful if in general the CLI outputted the tx hash for any tx it has built for any purpose.
This feature missing is very inconvenient when wanting to introspect further into a transaction the CLI has submitted.
I've opened a separate issue for being able to get the tx hash for any tx:
- https://github.com/stellar/soroban-cli/issues/1316
It doesn't compete with this feature exactly, but I'd also find it useful and it's semi-related.
Can log without waiting for the tx to complete
I thought about logging the transaction hash as a debug logging, which would then be available when using --verbose. Wdyt?
$ stellar --verbose contract deploy --wasm target/wasm32-unknown-unknown/release/hello_world.wasm --source alice --network testnet --alias hello
2024-07-16T16:51:08.633869Z DEBUG soroban_cli::commands::contract::deploy::wasm: transaction hash: b92b5cd32a13eb40400b4a71361d256074cdb381df554342284ceda38202039e
CB4YDNXFAZ42EM2DJG2PXTIVXXAKTKUYOCFJ2IGVTG5FFYLNS3HV7PMO
I don't love that the verbose logging includes that much noise, but it seems like a good choice and backwards compatible.
Debug is verbose. Trace is very verbose
I think the transaction hash could be debug or info.
Our commands could be more communicative about what they're doing, and not in terms of logs, but in terms of stderr output so that the user understands what is happening. We've started to do this on some commands, but not most, where we have informational output about each step.
Something like:
$ stellar contract deploy --wasm out/hello_world.wasm --source alice --network testnet --alias hello
ℹ️ Simulating install transaction...
🌎 Submitting install transaction... b92b5cd32a13eb40400b4a71361d256074cdb381df554342284ceda38202039e
ℹ️ Simulating deploy transaction...
🌎 Submitting deploy transaction... b92b5cd32a13eb40400b4a71361d256074cdb381df554342284ceda38202039e
✅ Deployed
CB4YDNXFAZ42EM2DJG2PXTIVXXAKTKUYOCFJ2IGVTG5FFYLNS3HV7PMO
In the output above all lines are stderr except the last that is stdout.
@leighmcculloch I like that. Should we send everything to stderr and just the contract id to stdout, so it's backward compatible?
Yeah definitely. Stdout should just be for the Contract Id so that it can be captured in scripts.
+1 Ideally every command that could be used in a scriptable way has a single entity on stdout for scripting.
It could be beneficial to do a quick sketch in a google doc for what each of the major commands are, and what type of stderr output we'd like for them. Taking a holistic view of how this should play out. Then we can make sure we have a good unified and consistent story for what this UX would look like.
I think we can start with stellar contract deploy, laying out the foundation with functions like info(message), link(url), and so on. The functions would know which emoji to use and any other annotations we'd like to add.