Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ impl From<PrintKeypairToTerminalContext> for crate::commands::ActionContext {
on_after_sending_transaction_callback: std::sync::Arc::new(
move |_outcome_view, _network_config| Ok(()),
),
sign_as_delegate_action: false,
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ impl From<SaveKeypairToKeychainContext> for crate::commands::ActionContext {
on_after_sending_transaction_callback: std::sync::Arc::new(
|_outcome_view, _network_config| Ok(()),
),
sign_as_delegate_action: false,
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ impl From<SaveKeypairToLegacyKeychainContext> for crate::commands::ActionContext
on_after_sending_transaction_callback: std::sync::Arc::new(
|_outcome_view, _network_config| Ok(()),
),
sign_as_delegate_action: false,
}
}
}
1 change: 1 addition & 0 deletions src/commands/account/add_key/use_ledger/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ impl From<AddLedgerKeyActionContext> for crate::commands::ActionContext {
on_after_sending_transaction_callback: std::sync::Arc::new(
|_outcome_view, _network_config| Ok(()),
),
sign_as_delegate_action: false,
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ impl From<AddAccessWithSeedPhraseActionContext> for crate::commands::ActionConte
on_after_sending_transaction_callback: std::sync::Arc::new(
|_outcome_view, _network_config| Ok(()),
),
sign_as_delegate_action: false,
}
}
}
1 change: 1 addition & 0 deletions src/commands/account/add_key/use_mpc/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,7 @@ impl From<MpcDeriveKeyToAddContext> for crate::commands::ActionContext {
on_after_sending_transaction_callback: std::sync::Arc::new(
|_outcome_view, _network_config| Ok(()),
),
sign_as_delegate_action: false,
}
}
}
1 change: 1 addition & 0 deletions src/commands/account/add_key/use_public_key/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ impl From<AddAccessKeyActionContext> for crate::commands::ActionContext {
on_after_sending_transaction_callback: std::sync::Arc::new(
|_outcome_view, _network_config| Ok(()),
),
sign_as_delegate_action: false,
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ impl From<SignerAccountIdContext> for crate::commands::ActionContext {
),
on_before_sending_transaction_callback: item.on_before_sending_transaction_callback,
on_after_sending_transaction_callback,
sign_as_delegate_action: false,
}
}
}
Expand Down
1 change: 1 addition & 0 deletions src/commands/account/delete_account/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ impl From<BeneficiaryAccountContext> for crate::commands::ActionContext {
on_after_sending_transaction_callback: std::sync::Arc::new(
|_outcome_view, _network_config| Ok(()),
),
sign_as_delegate_action: false,
}
}
}
Expand Down
1 change: 1 addition & 0 deletions src/commands/account/delete_key/public_keys_to_delete.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ impl From<PublicKeyListContext> for crate::commands::ActionContext {
on_after_sending_transaction_callback: std::sync::Arc::new(
|_outcome_view, _network_config| Ok(()),
),
sign_as_delegate_action: false,
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ impl SignerAccountIdContext {
|_signed_transaction, _network_config| Ok(String::new()),
),
on_after_sending_transaction_callback,
sign_as_delegate_action: false,
}))
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ impl SignerAccountIdContext {
|_signed_transaction, _network_config| Ok(String::new()),
),
on_after_sending_transaction_callback,
sign_as_delegate_action: false,
}))
}
}
Expand Down
1 change: 1 addition & 0 deletions src/commands/account/update_social_profile/sign_as.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ impl From<SignerContext> for crate::commands::ActionContext {
|_signed_transaction, _network_config| Ok(String::new()),
),
on_after_sending_transaction_callback,
sign_as_delegate_action: false,
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,7 @@ impl From<SignerAccountIdContext> for crate::commands::ActionContext {
on_after_sending_transaction_callback: std::sync::Arc::new(
|_outcome_view, _network_config| Ok(()),
),
sign_as_delegate_action: false,
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ impl DepositContext {
on_after_sending_transaction_callback: std::sync::Arc::new(
|_outcome_view, _network_config| Ok(()),
),
sign_as_delegate_action: false,
}))
}
}
Expand Down
1 change: 1 addition & 0 deletions src/commands/contract/deploy/initialize_mode/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ impl From<NoInitializeContext> for crate::commands::ActionContext {
on_after_sending_transaction_callback: std::sync::Arc::new(
|_outcome_view, _network_config| Ok(()),
),
sign_as_delegate_action: false,
}
}
}
1 change: 1 addition & 0 deletions src/commands/contract/deploy_global/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ impl From<DeployGlobalResultContext> for crate::commands::ActionContext {
on_after_sending_transaction_callback: std::sync::Arc::new(
|_outcome_view, _network_config| Ok(()),
),
sign_as_delegate_action: false,
}
}
}
2 changes: 2 additions & 0 deletions src/commands/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ pub struct ActionContext {
crate::transaction_signature_options::OnBeforeSendingTransactionCallback,
pub on_after_sending_transaction_callback:
crate::transaction_signature_options::OnAfterSendingTransactionCallback,
pub sign_as_delegate_action: bool,
}

#[derive(Clone)]
Expand All @@ -123,4 +124,5 @@ pub struct TransactionContext {
crate::transaction_signature_options::OnBeforeSendingTransactionCallback,
pub on_after_sending_transaction_callback:
crate::transaction_signature_options::OnAfterSendingTransactionCallback,
pub sign_as_delegate_action: bool,
}
1 change: 1 addition & 0 deletions src/commands/staking/delegate/deposit_and_stake.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ impl DepositAndStakeContext {
|_signed_transaction, _network_config| Ok(String::new()),
),
on_after_sending_transaction_callback,
sign_as_delegate_action: false,
}))
}
}
Expand Down
1 change: 1 addition & 0 deletions src/commands/staking/delegate/stake.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ impl StakeContext {
|_signed_transaction, _network_config| Ok(String::new()),
),
on_after_sending_transaction_callback,
sign_as_delegate_action: false,
}))
}
}
Expand Down
1 change: 1 addition & 0 deletions src/commands/staking/delegate/stake_all.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ impl StakeAllContext {
|_signed_transaction, _network_config| Ok(String::new()),
),
on_after_sending_transaction_callback,
sign_as_delegate_action: false,
}))
}
}
Expand Down
1 change: 1 addition & 0 deletions src/commands/staking/delegate/unstake.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ impl UnstakeContext {
|_signed_transaction, _network_config| Ok(String::new()),
),
on_after_sending_transaction_callback,
sign_as_delegate_action: false,
}))
}
}
Expand Down
1 change: 1 addition & 0 deletions src/commands/staking/delegate/unstake_all.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ impl UnstakeAllContext {
|_signed_transaction, _network_config| Ok(String::new()),
),
on_after_sending_transaction_callback,
sign_as_delegate_action: false,
}))
}
}
Expand Down
1 change: 1 addition & 0 deletions src/commands/staking/delegate/withdraw.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ impl WithdrawContext {
|_signed_transaction, _network_config| Ok(String::new()),
),
on_after_sending_transaction_callback,
sign_as_delegate_action: false,
}))
}
}
Expand Down
1 change: 1 addition & 0 deletions src/commands/staking/delegate/withdraw_all.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ impl WithdrawAllContext {
|_signed_transaction, _network_config| Ok(String::new()),
),
on_after_sending_transaction_callback,
sign_as_delegate_action: false,
}))
}
}
Expand Down
1 change: 1 addition & 0 deletions src/commands/tokens/send_ft/amount_ft.rs
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,7 @@ impl FtTransferParamsContext {
|_signed_transaction, _network_config| Ok(String::new()),
),
on_after_sending_transaction_callback,
sign_as_delegate_action: false,
}))
}
}
Expand Down
1 change: 1 addition & 0 deletions src/commands/tokens/send_near/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ impl From<SendNearCommandContext> for crate::commands::ActionContext {
on_after_sending_transaction_callback: std::sync::Arc::new(
|_outcome_view, _network_config| Ok(()),
),
sign_as_delegate_action: false,
}
}
}
Expand Down
1 change: 1 addition & 0 deletions src/commands/tokens/send_nft/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ impl From<SendNftCommandContext> for crate::commands::ActionContext {
|_signed_transaction, _network_config| Ok(String::new()),
),
on_after_sending_transaction_callback,
sign_as_delegate_action: false,
}
}
}
Expand Down
63 changes: 63 additions & 0 deletions src/commands/transaction/construct_meta_transaction/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
#[derive(Debug, Clone, interactive_clap::InteractiveClap)]
#[interactive_clap(input_context = crate::GlobalContext)]
#[interactive_clap(output_context = ConstructMetaTransactionContext)]
pub struct ConstructMetaTransaction {
#[interactive_clap(skip_default_input_arg)]
/// What is the sender account ID?
pub sender_account_id: crate::types::account_id::AccountId,
#[interactive_clap(skip_default_input_arg)]
/// What is the receiver account ID?
pub receiver_account_id: crate::types::account_id::AccountId,
#[interactive_clap(subcommand)]
pub next_actions: crate::commands::transaction::construct_transaction::add_action_1::NextAction,
}

#[derive(Debug, Clone)]
pub struct ConstructMetaTransactionContext(
crate::commands::transaction::construct_transaction::ConstructTransactionContext,
);

impl ConstructMetaTransactionContext {
pub fn from_previous_context(
previous_context: crate::GlobalContext,
scope: &<ConstructMetaTransaction as interactive_clap::ToInteractiveClapContextScope>::InteractiveClapContextScope,
) -> color_eyre::eyre::Result<Self> {
Ok(Self(
crate::commands::transaction::construct_transaction::ConstructTransactionContext {
global_context: previous_context,
signer_account_id: scope.sender_account_id.clone().into(),
receiver_account_id: scope.receiver_account_id.clone().into(),
actions: vec![],
sign_as_delegate_action: true,
},
))
}
}

impl From<ConstructMetaTransactionContext>
for crate::commands::transaction::construct_transaction::ConstructTransactionContext
{
fn from(item: ConstructMetaTransactionContext) -> Self {
item.0
}
}

impl ConstructMetaTransaction {
pub fn input_sender_account_id(
context: &crate::GlobalContext,
) -> color_eyre::eyre::Result<Option<crate::types::account_id::AccountId>> {
crate::common::input_signer_account_id_from_used_account_list(
&context.config.credentials_home_dir,
"What is the sender account ID?",
)
}

pub fn input_receiver_account_id(
context: &crate::GlobalContext,
) -> color_eyre::eyre::Result<Option<crate::types::account_id::AccountId>> {
crate::common::input_non_signer_account_id_from_used_account_list(
&context.config.credentials_home_dir,
"What is the receiver account ID?",
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ pub struct AccessKeyPermissionContext {
pub receiver_account_id: near_primitives::types::AccountId,
pub actions: Vec<near_primitives::transaction::Action>,
pub access_key_permission: near_primitives::account::AccessKeyPermission,
pub sign_as_delegate_action: bool,
}

#[derive(Debug, Clone, interactive_clap::InteractiveClap)]
Expand All @@ -33,6 +34,7 @@ impl FullAccessTypeContext {
receiver_account_id: previous_context.receiver_account_id,
actions: previous_context.actions,
access_key_permission: near_primitives::account::AccessKeyPermission::FullAccess,
sign_as_delegate_action: previous_context.sign_as_delegate_action,
}))
}
}
Expand Down Expand Up @@ -81,6 +83,7 @@ impl FunctionCallTypeContext {
receiver_account_id: previous_context.receiver_account_id,
actions: previous_context.actions,
access_key_permission,
sign_as_delegate_action: previous_context.sign_as_delegate_action,
}))
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ impl AddAccessWithSeedPhraseActionContext {
signer_account_id: previous_context.signer_account_id,
receiver_account_id: previous_context.receiver_account_id,
actions,
sign_as_delegate_action: previous_context.sign_as_delegate_action,
},
))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ impl AddAccessKeyActionContext {
signer_account_id: previous_context.signer_account_id,
receiver_account_id: previous_context.receiver_account_id,
actions,
sign_as_delegate_action: previous_context.sign_as_delegate_action,
},
))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ pub struct FunctionCallActionContext {
actions: Vec<near_primitives::transaction::Action>,
function_name: String,
function_args: Vec<u8>,
sign_as_delegate_action: bool,
}

impl FunctionCallActionContext {
Expand All @@ -46,6 +47,7 @@ impl FunctionCallActionContext {
actions: previous_context.actions,
function_name: scope.function_name.clone(),
function_args,
sign_as_delegate_action: previous_context.sign_as_delegate_action,
})
}
}
Expand Down Expand Up @@ -91,6 +93,7 @@ pub struct PrepaidGasContext {
function_name: String,
function_args: Vec<u8>,
gas: crate::common::NearGas,
sign_as_delegate_action: bool,
}

impl PrepaidGasContext {
Expand All @@ -106,6 +109,7 @@ impl PrepaidGasContext {
function_name: previous_context.function_name,
function_args: previous_context.function_args,
gas: scope.gas,
sign_as_delegate_action: previous_context.sign_as_delegate_action,
})
}
}
Expand Down Expand Up @@ -167,6 +171,7 @@ impl DepositContext {
signer_account_id: previous_context.signer_account_id,
receiver_account_id: previous_context.receiver_account_id,
actions,
sign_as_delegate_action: previous_context.sign_as_delegate_action,
}))
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ impl CreateAccountActionContext {
signer_account_id: previous_context.signer_account_id,
receiver_account_id: previous_context.receiver_account_id,
actions,
sign_as_delegate_action: previous_context.sign_as_delegate_action,
}))
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ impl DeleteAccountActionContext {
signer_account_id: previous_context.signer_account_id,
receiver_account_id: previous_context.receiver_account_id,
actions,
sign_as_delegate_action: previous_context.sign_as_delegate_action,
}))
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ impl DeleteKeyActionContext {
signer_account_id: previous_context.signer_account_id,
receiver_account_id: previous_context.receiver_account_id,
actions,
sign_as_delegate_action: previous_context.sign_as_delegate_action,
}))
}
}
Expand Down
Loading
Loading