Skip to content

Commit

Permalink
feat: New command to reconstruct NEAR CLI command from a historical t…
Browse files Browse the repository at this point in the history
…ransaction (near#266)
  • Loading branch information
FroVolod authored Dec 2, 2023
1 parent 53e424f commit 0f484b5
Show file tree
Hide file tree
Showing 10 changed files with 308 additions and 28 deletions.
2 changes: 1 addition & 1 deletion src/commands/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ mod config;
pub mod contract;
mod staking;
mod tokens;
mod transaction;
pub mod transaction;

#[cfg(feature = "self-update")]
pub mod extensions;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use strum::{EnumDiscriminants, EnumIter, EnumMessage};

mod access_key_type;
mod use_manually_provided_seed_phrase;
mod use_public_key;
pub mod access_key_type;
pub mod use_manually_provided_seed_phrase;
pub mod use_public_key;

#[derive(Debug, Clone, interactive_clap::InteractiveClap)]
#[interactive_clap(context = super::super::super::ConstructTransactionContext)]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use color_eyre::eyre::Context;

mod initialize_mode;
pub mod initialize_mode;

#[derive(Debug, Clone, interactive_clap::InteractiveClap)]
#[interactive_clap(context = super::super::super::ConstructTransactionContext)]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
use strum::{EnumDiscriminants, EnumIter, EnumMessage};

mod add_key;
mod call_function;
mod create_account;
mod delete_account;
mod delete_key;
mod deploy_contract;
mod stake;
mod transfer;
pub mod add_key;
pub mod call_function;
pub mod create_account;
pub mod delete_account;
pub mod delete_key;
pub mod deploy_contract;
pub mod stake;
pub mod transfer;

#[derive(Debug, Clone, interactive_clap::InteractiveClap)]
#[interactive_clap(context = super::super::ConstructTransactionContext)]
pub struct AddAction {
#[interactive_clap(subcommand)]
action: ActionSubcommand,
pub action: ActionSubcommand,
}

#[derive(Debug, Clone, EnumDiscriminants, interactive_clap::InteractiveClap)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
#[interactive_clap(output_context = TransferActionContext)]
pub struct TransferAction {
/// How many NEAR Tokens do you want to transfer? (example: 10NEAR or 0.5near or 10000yoctonear)
amount_in_near: near_token::NearToken,
pub amount_in_near: near_token::NearToken,
#[interactive_clap(subcommand)]
next_action: super::super::super::add_action_2::NextAction,
pub next_action: super::super::super::add_action_2::NextAction,
}

#[derive(Debug, Clone)]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#![allow(clippy::enum_variant_names, clippy::large_enum_variant)]
use strum::{EnumDiscriminants, EnumIter, EnumMessage};

mod add_action;
pub mod add_action;

#[derive(Debug, Clone, EnumDiscriminants, interactive_clap::InteractiveClap)]
#[interactive_clap(context = super::ConstructTransactionContext)]
Expand Down
16 changes: 8 additions & 8 deletions src/commands/transaction/construct_transaction/mod.rs
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
mod add_action_1;
mod add_action_2;
mod add_action_3;
mod add_action_last;
mod skip_action;
pub mod add_action_1;
pub mod add_action_2;
pub mod add_action_3;
pub mod add_action_last;
pub mod skip_action;

#[derive(Debug, Clone, interactive_clap::InteractiveClap)]
#[interactive_clap(input_context = crate::GlobalContext)]
#[interactive_clap(output_context = ConstructTransactionContext)]
pub struct ConstructTransaction {
#[interactive_clap(skip_default_input_arg)]
/// What is the sender account ID?
sender_account_id: crate::types::account_id::AccountId,
pub sender_account_id: crate::types::account_id::AccountId,
#[interactive_clap(skip_default_input_arg)]
/// What is the receiver account ID?
receiver_account_id: crate::types::account_id::AccountId,
pub receiver_account_id: crate::types::account_id::AccountId,
#[interactive_clap(subcommand)]
next_actions: self::add_action_1::NextAction,
pub next_actions: self::add_action_1::NextAction,
}

#[derive(Debug, Clone)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
pub struct SkipAction {
#[interactive_clap(named_arg)]
/// Select network
network_config: crate::network_for_transaction::NetworkForTransactionArgs,
pub network_config: crate::network_for_transaction::NetworkForTransactionArgs,
}

#[derive(Debug, Clone)]
Expand Down
10 changes: 8 additions & 2 deletions src/commands/transaction/mod.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
#![allow(clippy::enum_variant_names, clippy::large_enum_variant)]
use strum::{EnumDiscriminants, EnumIter, EnumMessage};

mod construct_transaction;
pub mod construct_transaction;
mod reconstruct_transaction;
mod send_meta_transaction;
mod send_signed_transaction;
mod sign_transaction;
pub mod sign_transaction;
mod view_status;

#[derive(Debug, Clone, interactive_clap::InteractiveClap)]
Expand All @@ -25,6 +26,11 @@ pub enum TransactionActions {
))]
/// Execute function (contract method)
ViewStatus(self::view_status::TransactionInfo),
#[strum_discriminants(strum(
message = "reconstruct-transaction - Use any existing transaction from the chain to construct NEAR CLI command (helpful tool for re-submitting similar transactions)"
))]
/// Use any existing transaction from the chain to construct NEAR CLI command (helpful tool for re-submitting similar transactions)
ReconstructTransaction(self::reconstruct_transaction::TransactionInfo),
#[strum_discriminants(strum(
message = "construct-transaction - Construct a new transaction"
))]
Expand Down
Loading

0 comments on commit 0f484b5

Please sign in to comment.