diff --git a/src/commands/transaction/mod.rs b/src/commands/transaction/mod.rs index be2582ed2..0407e6767 100644 --- a/src/commands/transaction/mod.rs +++ b/src/commands/transaction/mod.rs @@ -5,7 +5,7 @@ pub mod construct_transaction; mod print_transaction; mod reconstruct_transaction; mod send_meta_transaction; -mod send_signed_transaction; +pub mod send_signed_transaction; pub mod sign_transaction; mod view_status; diff --git a/src/commands/transaction/send_signed_transaction/mod.rs b/src/commands/transaction/send_signed_transaction/mod.rs index 79ed15259..6bf62acc1 100644 --- a/src/commands/transaction/send_signed_transaction/mod.rs +++ b/src/commands/transaction/send_signed_transaction/mod.rs @@ -80,10 +80,10 @@ pub struct FileWithBase64SignedTransaction { #[derive(Debug, Clone)] pub struct FileWithBase64SignedTransactionContext(SignedTransactionContext); -#[derive(Debug, serde::Deserialize)] -struct FileSignedTransaction { - #[serde(alias = "signedTransactionAsBase64")] - signed_transaction: near_primitives::transaction::SignedTransaction, +#[derive(Debug, serde::Deserialize, serde::Serialize)] +pub struct FileSignedTransaction { + #[serde(rename = "signed_transaction_as_base64")] + pub signed_transaction: near_primitives::transaction::SignedTransaction, } impl FileWithBase64SignedTransactionContext { diff --git a/src/transaction_signature_options/save_to_file/mod.rs b/src/transaction_signature_options/save_to_file/mod.rs index 90f8aafc3..f637e3ef3 100644 --- a/src/transaction_signature_options/save_to_file/mod.rs +++ b/src/transaction_signature_options/save_to_file/mod.rs @@ -3,6 +3,8 @@ use std::io::Write; use color_eyre::eyre::Context; use inquire::CustomType; +use super::super::commands::transaction::send_signed_transaction::FileSignedTransaction; + #[derive(Debug, Clone, interactive_clap_derive::InteractiveClap)] #[interactive_clap(input_context = super::SubmitContext)] #[interactive_clap(output_context = SaveToFileContext)] @@ -32,14 +34,8 @@ impl SaveToFileContext { super::SignedTransactionOrSignedDelegateAction::SignedTransaction( signed_transaction, ) => { - let signed_transaction_as_base64 = - crate::types::signed_transaction::SignedTransactionAsBase64::from( - signed_transaction, - ) - .to_string(); - - let data_signed_transaction = serde_json::json!( - {"signedTransactionAsBase64": signed_transaction_as_base64}); + let data_signed_transaction = + serde_json::to_value(FileSignedTransaction { signed_transaction })?; std::fs::File::create(&file_path) .wrap_err_with(|| format!("Failed to create file: {:?}", &file_path))?