Skip to content

Commit

Permalink
fix: CLI must return a non-zero exit code when function call (as-tran…
Browse files Browse the repository at this point in the history
…saction) fails (#238)
  • Loading branch information
FroVolod authored Sep 4, 2023
1 parent ab6cf46 commit 12d22f6
Show file tree
Hide file tree
Showing 2 changed files with 81 additions and 82 deletions.
14 changes: 6 additions & 8 deletions src/commands/contract/call_function/as_read_only/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ use crate::common::JsonRpcClientExt;
#[interactive_clap(output_context = CallFunctionViewContext)]
pub struct CallFunctionView {
#[interactive_clap(skip_default_input_arg)]
/// What is the account ID?
account_id: crate::types::account_id::AccountId,
/// What is the contract account ID?
contract_account_id: crate::types::account_id::AccountId,
/// What is the name of the function?
function_name: String,
#[interactive_clap(value_enum)]
Expand All @@ -32,7 +32,7 @@ impl CallFunctionViewContext {
let on_after_getting_block_reference_callback: crate::network_view_at_block::OnAfterGettingBlockReferenceCallback = std::sync::Arc::new({
let function_args = scope.function_args.clone();
let function_args_type = scope.function_args_type.clone();
let account_id: near_primitives::types::AccountId = scope.account_id.clone().into();
let account_id: near_primitives::types::AccountId = scope.contract_account_id.clone().into();
let function_name = scope.function_name.clone();

move |network_config, block_reference| {
Expand Down Expand Up @@ -67,7 +67,7 @@ impl CallFunctionViewContext {

Ok(Self(crate::network_view_at_block::ArgsForViewContext {
config: previous_context.config,
interacting_with_account_ids: vec![scope.account_id.clone().into()],
interacting_with_account_ids: vec![scope.contract_account_id.clone().into()],
on_after_getting_block_reference_callback,
}))
}
Expand All @@ -85,15 +85,13 @@ impl CallFunctionView {
) -> color_eyre::eyre::Result<Option<super::call_function_args_type::FunctionArgsType>> {
super::call_function_args_type::input_function_args_type()
}
}

impl CallFunctionView {
pub fn input_account_id(
pub fn input_contract_account_id(
context: &crate::GlobalContext,
) -> color_eyre::eyre::Result<Option<crate::types::account_id::AccountId>> {
crate::common::input_non_signer_account_id_from_used_account_list(
&context.config.credentials_home_dir,
"What is the account ID?",
"What is the contract account ID?",
)
}
}
Loading

0 comments on commit 12d22f6

Please sign in to comment.