Skip to content

Commit

Permalink
refactored
Browse files Browse the repository at this point in the history
  • Loading branch information
FroVolod committed Dec 14, 2024
1 parent e2965fd commit c3e50e1
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 13 deletions.
2 changes: 1 addition & 1 deletion src/commands/transaction/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
8 changes: 4 additions & 4 deletions src/commands/transaction/send_signed_transaction/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
12 changes: 4 additions & 8 deletions src/transaction_signature_options/save_to_file/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down Expand Up @@ -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))?
Expand Down

0 comments on commit c3e50e1

Please sign in to comment.