Skip to content

Commit

Permalink
refactored information about a successfully signed transaction
Browse files Browse the repository at this point in the history
  • Loading branch information
FroVolod committed Feb 5, 2025
1 parent 0700014 commit 802e0ef
Show file tree
Hide file tree
Showing 7 changed files with 62 additions and 34 deletions.
23 changes: 9 additions & 14 deletions src/transaction_signature_options/sign_later/display.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,15 @@ impl DisplayContext {
previous_context: super::SignLaterContext,
_scope: &<Display as interactive_clap::ToInteractiveClapContextScope>::InteractiveClapContextScope,
) -> color_eyre::eyre::Result<Self> {
eprintln!(
"\nTransaction hash to sign:\n{}",
hex::encode(previous_context.unsigned_transaction.get_hash_and_size().0)
);

eprintln!(
"\nUnsigned transaction (serialized as base64):\n{}\n",
crate::types::transaction::TransactionAsBase64::from(
previous_context.unsigned_transaction
)
);
eprintln!(
"This base64-encoded transaction can be signed and sent later. There is a helper command on near CLI that can do that:\n$ {} transaction sign-transaction\n",
crate::common::get_near_exec_path()
tracing::info!(
parent: &tracing::Span::none(),
"{}",
crate::common::indent_payload(&format!(
"\nTransaction hash to sign:\n{}.\n\nUnsigned transaction (serialized as base64):\n{}\n\nThis base64-encoded transaction can be signed and sent later. There is a helper command on near CLI that can do that:\n$ {} transaction sign-transaction\n",
hex::encode(previous_context.unsigned_transaction.get_hash_and_size().0),
crate::types::transaction::TransactionAsBase64::from(previous_context.unsigned_transaction),
crate::common::get_near_exec_path()
))
);
Ok(Self)
}
Expand Down
13 changes: 8 additions & 5 deletions src/transaction_signature_options/sign_later/save_to_file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,14 @@ impl SaveToFileContext {
.wrap_err_with(|| format!("Failed to create file: {:?}", &file_path))?
.write(&serde_json::to_vec_pretty(&data_unsigned_transaction)?)
.wrap_err_with(|| format!("Failed to write to file: {:?}", &file_path))?;
eprintln!("\nThe file {:?} was created successfully. It has a unsigned transaction (serialized as base64).", &file_path);

eprintln!(
"This base64-encoded transaction can be signed and sent later. There is a helper command on near CLI that can do that:\n$ {} transaction sign-transaction\n",
crate::common::get_near_exec_path()
tracing::info!(
parent: &tracing::Span::none(),
"{}",
crate::common::indent_payload(&format!(
"\nThe file {:?} was created successfully. It has a unsigned transaction (serialized as base64).\nThis base64-encoded transaction can be signed and sent later. There is a helper command on near CLI that can do that:\n$ {} transaction sign-transaction\n",
&file_path,
crate::common::get_near_exec_path()
))
);
Ok(Self)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,15 @@ impl SignAccessKeyFileContext {
unsigned_transaction,
);

eprintln!("\nYour transaction was signed successfully.");
eprintln!("Public key: {}", account_json.public_key);
eprintln!("Signature: {}", signature);
tracing::info!(
parent: &tracing::Span::none(),
"Your transaction was signed successfully.{}",
crate::common::indent_payload(&format!(
"\nPublic key: {}\nSignature: {}\n",
account_json.public_key,
signature
))
);

Ok(Self {
network_config: previous_context.network_config,
Expand Down
12 changes: 9 additions & 3 deletions src/transaction_signature_options/sign_with_keychain/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -228,9 +228,15 @@ impl SignKeychainContext {
unsigned_transaction,
);

eprintln!("\nYour transaction was signed successfully.");
eprintln!("Public key: {}", account_json.public_key);
eprintln!("Signature: {}", signature);
tracing::info!(
parent: &tracing::Span::none(),
"Your transaction was signed successfully.{}",
crate::common::indent_payload(&format!(
"\nPublic key: {}\nSignature: {}\n",
account_json.public_key,
signature
))
);

Ok(Self {
network_config: previous_context.network_config,
Expand Down
12 changes: 9 additions & 3 deletions src/transaction_signature_options/sign_with_ledger/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -199,9 +199,15 @@ impl SignLedgerContext {
unsigned_transaction,
);

eprintln!("\nYour transaction was signed successfully.");
eprintln!("Public key: {}", scope.signer_public_key);
eprintln!("Signature: {}", signature);
tracing::info!(
parent: &tracing::Span::none(),
"Your transaction was signed successfully.{}",
crate::common::indent_payload(&format!(
"\nPublic key: {}\nSignature: {}\n",
scope.signer_public_key,
signature
))
);

Ok(Self {
network_config: previous_context.network_config,
Expand Down
12 changes: 9 additions & 3 deletions src/transaction_signature_options/sign_with_private_key/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,9 +135,15 @@ impl SignPrivateKeyContext {
unsigned_transaction,
);

eprintln!("\nYour transaction was signed successfully.");
eprintln!("Public key: {}", scope.signer_public_key);
eprintln!("Signature: {}", signature);
tracing::info!(
parent: &tracing::Span::none(),
"Your transaction was signed successfully.{}",
crate::common::indent_payload(&format!(
"\nPublic key: {}\nSignature: {}\n",
scope.signer_public_key,
signature
))
);

Ok(Self {
network_config: previous_context.network_config,
Expand Down
12 changes: 9 additions & 3 deletions src/transaction_signature_options/sign_with_seed_phrase/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,9 +141,15 @@ impl SignSeedPhraseContext {
unsigned_transaction,
);

eprintln!("\nYour transaction was signed successfully.");
eprintln!("Public key: {}", signer_public_key);
eprintln!("Signature: {}", signature);
tracing::info!(
parent: &tracing::Span::none(),
"Your transaction was signed successfully.{}",
crate::common::indent_payload(&format!(
"\nPublic key: {}\nSignature: {}\n",
signer_public_key,
signature
))
);

Ok(Self {
network_config: previous_context.network_config,
Expand Down

0 comments on commit 802e0ef

Please sign in to comment.