Skip to content

Commit

Permalink
fix: Fixed field name for JSON file with transaction information (sig…
Browse files Browse the repository at this point in the history
…ned-transaction-info.json) (#427)

As recommended by @akorchyn
([pull/412#pullrequestreview-2502347297](#412 (review))),
the field name for the transaction information JSON file
(signed-transaction-info.json) has been fixed.

---------

Co-authored-by: FroVolod <[email protected]>
  • Loading branch information
FroVolod and FroVolod authored Dec 16, 2024
1 parent 75db5d7 commit 67e8d0f
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 14 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 = "Signed transaction (serialized as base64)")]
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
14 changes: 5 additions & 9 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!(
{"Signed transaction (serialized as base64)": 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 All @@ -63,7 +59,7 @@ impl SaveToFileContext {
.to_string();

let data_signed_delegate_action = serde_json::json!(
{"Signed delegate action (serialized as base64)": signed_delegate_action_as_base64});
{"signed_delegate_action_as_base64": signed_delegate_action_as_base64});

std::fs::File::create(&file_path)
.wrap_err_with(|| format!("Failed to create file: {:?}", &file_path))?
Expand Down

0 comments on commit 67e8d0f

Please sign in to comment.