sc-meta tx CLI, part 1#2362
Draft
andrei-marinica wants to merge 26 commits intorc/v0.66from
Draft
Conversation
|
Contract comparison - from 518b752 to 28bb44d
|
Contributor
There was a problem hiding this comment.
Pull request overview
Adds the first slice of a new sc-meta tx CLI (plus a data helper CLI) and refactors deterministic address computation into a shared chain-core utility, with new chain-simulator-backed tests and CI coverage.
Changes:
- Introduce
sc-meta txandsc-meta datasubcommands (clap args + command dispatch + tx JSON output helpers). - Extend snippets interactor traits to expose
into_sdk_transaction()and centralize deterministic contract address computation (compute_new_address*). - Add chain-simulator integration tests + a dedicated GitHub Actions workflow for the new tx CLI flow.
Reviewed changes
Copilot reviewed 40 out of 42 changed files in this pull request and generated 16 comments.
Show a summary per file
| File | Description |
|---|---|
| sdk/core/src/wallet.rs | Generalize Wallet::from_pem_file to accept AsRef<Path>. |
| framework/snippets/src/network_response.rs | Use centralized compute_new_address for deployed SC address derivation. |
| framework/snippets/src/interactor/interactor_tx/interactor_run_trait.rs | New traits for async run/simulate + SDK tx extraction. |
| framework/snippets/src/interactor/interactor_tx/interactor_query_call.rs | Implements new trait method for queries (currently panics for tx extraction). |
| framework/snippets/src/interactor/interactor_tx/interactor_prepare_async.rs | Removed/migrated into interactor_run_trait. |
| framework/snippets/src/interactor/interactor_tx/interactor_exec_upgrade.rs | Add into_sdk_transaction() for upgrade steps. |
| framework/snippets/src/interactor/interactor_tx/interactor_exec_transf.rs | Add into_sdk_transaction() for EGLD transfers. |
| framework/snippets/src/interactor/interactor_tx/interactor_exec_deploy.rs | Add into_sdk_transaction() for deploy steps; update imports. |
| framework/snippets/src/interactor/interactor_tx/interactor_exec_call.rs | Add into_sdk_transaction() for call steps; update imports. |
| framework/snippets/src/interactor/interactor_tx.rs | Wire new module + re-export updated traits. |
| framework/snippets/src/interactor/interactor_dns.rs | Switch to centralized compute_new_address for DNS address derivation. |
| framework/meta/tests/cs_tx_cli_test/cs_tx_test_owner.pem | Add test PEM wallet fixture for chain-simulator CLI tests. |
| framework/meta/tests/cs_tx_cli_test.rs | Add end-to-end chain-simulator tests for sc-meta tx deploy/call/query and tx new transfer. |
| framework/meta/src/cmd/tx/tx_send.rs | New tx send command (broadcast tx from file, optionally wait for result). |
| framework/meta/src/cmd/tx/tx_query.rs | New tx query command (gateway VM query, mxpy-like output). |
| framework/meta/src/cmd/tx/tx_new.rs | New tx new command (create/sign optional send of a generic tx). |
| framework/meta/src/cmd/tx/tx_deploy.rs | New tx deploy command (build tx via interactor + deterministic contract address). |
| framework/meta/src/cmd/tx/tx_common.rs | Shared helpers for wallet loading, arg encoding, signing + dispatch/output. |
| framework/meta/src/cmd/tx/tx_cli_args.rs | Clap definitions for tx subcommands and shared argument groups. |
| framework/meta/src/cmd/tx/tx_call.rs | New tx call command (build SC call tx via interactor). |
| framework/meta/src/cmd/tx/output.rs | Define mxpy-compatible JSON output struct for signed/broadcast tx flows. |
| framework/meta/src/cmd/tx.rs | New tx CLI dispatcher (some subcommands still TODO). |
| framework/meta/src/cmd/data.rs | New data CLI for store/load/parse of a mxpy-like data storage JSON. |
| framework/meta/src/cmd.rs | Export new tx and data command modules. |
| framework/meta/src/cli/cli_standalone_main.rs | Dispatch tx and data in standalone CLI main. |
| framework/meta/src/cli/cli_args_standalone.rs | Add top-level tx and data CLI variants + args structs for data. |
| framework/meta/Cargo.toml | Add chain-simulator-tests feature gate for new tests. |
| framework/meta/.gitignore | Ignore chain-simulator test output artifacts. |
| contracts/examples/order-book/.gitignore | Broaden ignore pattern to *.data-storage.json. |
| contracts/examples/adder/snippets/adder.snippets.sh | Add/replace adder example script using sc-meta tx + sc-meta data. |
| contracts/examples/adder/mxpy/testnet.snippets.sh | Remove old mxpy script variant. |
| contracts/examples/adder/mxpy/devnet.snippets.sh | Remove old mxpy script variant. |
| chain/vm/src/host/context/tx_cache.rs | Move mock address generation to chain_core::std::new_address. |
| chain/core/src/types/address.rs | Remove VM-type constants + mock SC address generation from Address. |
| chain/core/src/std/new_address.rs | New centralized utilities for deterministic SC address computation + mock address generation. |
| chain/core/src/std.rs | Export new_address module. |
| .gitignore | Broaden ignore pattern to *.data-storage.json. |
| .github/workflows/template-test-released.yml | Rename workflow display name to “sc-meta CI”. |
| .github/workflows/template-test-current.yml | Rename workflow display name to “sc-meta CI”. |
| .github/workflows/sc-meta-tx-cli-test.yml | New workflow running chain-simulator-based tx CLI tests. |
| .github/prompts/plan-scMetaContract.prompt.md | Add planning prompt doc for sc-meta tx CLI implementation. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+57
to
+60
|
|
||
| /// Wallet index used when deriving from a PEM with multiple entries (default: 0). | ||
| #[arg(long, default_value = "0")] | ||
| pub sender_wallet_index: u32, |
Comment on lines
+33
to
+43
| // Build call transaction. | ||
| let arg_buffer = build_arg_buffer(&args.arguments)?; | ||
| let tx_builder = interactor | ||
| .tx() | ||
| .from(&sender_bech32) | ||
| .to(&contract) | ||
| .gas(args.tx.gas_limit) | ||
| .egld(args.tx.value) | ||
| .raw_call(args.function.as_str()) | ||
| .arguments_raw(arg_buffer); | ||
|
|
Comment on lines
+29
to
+34
| let result_json = if args.wait_result { | ||
| let on_network = fetch_tx_on_network(&args.proxy, &tx_hash).await?; | ||
| serde_json::to_string_pretty(&on_network).context("failed to serialize result")? | ||
| } else { | ||
| serde_json::json!({ "txHash": tx_hash }).to_string() | ||
| }; |
Comment on lines
+17
to
+25
| pub async fn tx_cli(args: &TxCliArgs) { | ||
| match &args.command { | ||
| TxCliAction::Deploy(deploy_args) => tx_deploy(deploy_args).await, | ||
| TxCliAction::Call(call_args) => tx_call(call_args).await, | ||
| TxCliAction::Upgrade(_upgrade_args) => todo!("tx upgrade not yet implemented"), | ||
| TxCliAction::Query(query_args) => tx_query(query_args).await, | ||
| TxCliAction::New(new_args) => tx_new(new_args).await, | ||
| TxCliAction::Send(send_args) => tx_send(send_args).await, | ||
| TxCliAction::Sign(_sign_args) => todo!("tx sign not yet implemented"), |
Comment on lines
+15
to
+20
| /// Global storage lives in ~/multiversx-sdk, same as mxpy. | ||
| fn global_storage_path() -> PathBuf { | ||
| let home = std::env::var_os("HOME") | ||
| .map(PathBuf::from) | ||
| .unwrap_or_else(|| PathBuf::from(".")); | ||
| home.join("multiversx-sdk").join(STORAGE_FILE) |
Comment on lines
47
to
+53
| fn run(self) -> impl std::future::Future<Output = Self::Result> { | ||
| run_async_query(self) | ||
| } | ||
|
|
||
| fn into_sdk_transaction(self) -> Transaction { | ||
| unimplemented!("SC queries don't produce blockchain transactions") | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.