Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Fixed field name for JSON file with transaction information (signed-transaction-info.json) #427

Merged
merged 3 commits into from
Dec 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading