forked from near/near-cli-rs
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Added support for blind signing with Ledger [requires updated L…
…edger app that is not yet published] (near#259)
- Loading branch information
Showing
11 changed files
with
213 additions
and
10 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#![allow(clippy::enum_variant_names, clippy::large_enum_variant)] | ||
use strum::{EnumDiscriminants, EnumIter, EnumMessage}; | ||
|
||
mod signed; | ||
mod unsigned; | ||
|
||
#[derive(Debug, Clone, interactive_clap::InteractiveClap)] | ||
#[interactive_clap(context = crate::GlobalContext)] | ||
pub struct PrintTransactionCommands { | ||
#[interactive_clap(subcommand)] | ||
show_transaction_actions: PrintTransactionActions, | ||
} | ||
|
||
#[derive(Debug, EnumDiscriminants, Clone, interactive_clap::InteractiveClap)] | ||
#[interactive_clap(context = crate::GlobalContext)] | ||
#[strum_discriminants(derive(EnumMessage, EnumIter))] | ||
pub enum PrintTransactionActions { | ||
#[strum_discriminants(strum( | ||
message = "unsigned - Print all fields of previously prepared unsigned transaction without modification" | ||
))] | ||
/// Print previously prepared unsigned transaction without modification | ||
Unsigned(self::unsigned::PrintTransaction), | ||
#[strum_discriminants(strum( | ||
message = "signed - Print all fields of previously prepared signed transaction without modification" | ||
))] | ||
/// Send a signed transaction | ||
Signed(self::signed::PrintTransaction), | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#[derive(Debug, Clone, interactive_clap::InteractiveClap)] | ||
#[interactive_clap(input_context = crate::GlobalContext)] | ||
#[interactive_clap(output_context = PrintContext)] | ||
pub struct PrintTransaction { | ||
/// Enter the signed transaction encoded in base64: | ||
signed_transaction: crate::types::signed_transaction::SignedTransactionAsBase64, | ||
} | ||
|
||
#[derive(Debug, Clone)] | ||
pub struct PrintContext; | ||
|
||
impl PrintContext { | ||
pub fn from_previous_context( | ||
_previous_context: crate::GlobalContext, | ||
scope: &<PrintTransaction as interactive_clap::ToInteractiveClapContextScope>::InteractiveClapContextScope, | ||
) -> color_eyre::eyre::Result<Self> { | ||
let signed_transaction: near_primitives::transaction::SignedTransaction = | ||
scope.signed_transaction.clone().into(); | ||
|
||
eprintln!("\nSigned transaction (full):\n"); | ||
crate::common::print_full_signed_transaction(signed_transaction); | ||
eprintln!(); | ||
|
||
Ok(Self) | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
src/commands/transaction/print_transaction/unsigned/mod.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#[derive(Debug, Clone, interactive_clap::InteractiveClap)] | ||
#[interactive_clap(input_context = crate::GlobalContext)] | ||
#[interactive_clap(output_context = PrintContext)] | ||
pub struct PrintTransaction { | ||
/// Enter the unsigned transaction encoded in base64: | ||
unsigned_transaction: crate::types::transaction::TransactionAsBase64, | ||
} | ||
|
||
#[derive(Debug, Clone)] | ||
pub struct PrintContext; | ||
|
||
impl PrintContext { | ||
pub fn from_previous_context( | ||
_previous_context: crate::GlobalContext, | ||
scope: &<PrintTransaction as interactive_clap::ToInteractiveClapContextScope>::InteractiveClapContextScope, | ||
) -> color_eyre::eyre::Result<Self> { | ||
let unsigned_transaction: near_primitives::transaction::Transaction = | ||
scope.unsigned_transaction.clone().into(); | ||
|
||
eprintln!("\nUnsigned transaction (full):\n"); | ||
crate::common::print_full_unsigned_transaction(unsigned_transaction); | ||
eprintln!(); | ||
|
||
Ok(Self) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters