diff --git a/framework/cached-packages/src/libra_framework_sdk_builder.rs b/framework/cached-packages/src/libra_framework_sdk_builder.rs index b506801c1..965f4e4f4 100644 --- a/framework/cached-packages/src/libra_framework_sdk_builder.rs +++ b/framework/cached-packages/src/libra_framework_sdk_builder.rs @@ -460,6 +460,11 @@ pub enum EntryFunctionCall { code: Vec>, }, + /// Users can change their account to slow, by calling the entry function + /// Warning: this is permanent for the account. There's no way to + /// reverse a "slow wallet". + SlowWalletSetSlow {}, + SlowWalletSmokeTestVmUnlock { user_addr: AccountAddress, unlocked: u64, @@ -806,6 +811,7 @@ impl EntryFunctionCall { metadata_serialized, code, ), + SlowWalletSetSlow {} => slow_wallet_set_slow(), SlowWalletSmokeTestVmUnlock { user_addr, unlocked, @@ -2105,6 +2111,24 @@ pub fn resource_account_create_resource_account_and_publish_package( )) } +/// Users can change their account to slow, by calling the entry function +/// Warning: this is permanent for the account. There's no way to +/// reverse a "slow wallet". +pub fn slow_wallet_set_slow() -> TransactionPayload { + TransactionPayload::EntryFunction(EntryFunction::new( + ModuleId::new( + AccountAddress::new([ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 1, + ]), + ident_str!("slow_wallet").to_owned(), + ), + ident_str!("set_slow").to_owned(), + vec![], + vec![], + )) +} + pub fn slow_wallet_smoke_test_vm_unlock( user_addr: AccountAddress, unlocked: u64, @@ -3064,6 +3088,14 @@ mod decoder { } } + pub fn slow_wallet_set_slow(payload: &TransactionPayload) -> Option { + if let TransactionPayload::EntryFunction(_script) = payload { + Some(EntryFunctionCall::SlowWalletSetSlow {}) + } else { + None + } + } + pub fn slow_wallet_smoke_test_vm_unlock( payload: &TransactionPayload, ) -> Option { @@ -3446,6 +3478,10 @@ static SCRIPT_FUNCTION_DECODER_MAP: once_cell::sync::Lazy, // Dev NOTE: account address has the same bytes as AuthKey -} impl UserTxs { pub async fn run(&self, sender: &mut Sender) -> anyhow::Result<()> { match &self { - UserTxs::RotateKey(tx) => match tx.run(sender).await { + UserTxs::RotateKey(rotate) => match rotate.run(sender).await { Ok(_) => println!("SUCCESS: privated key rotated"), Err(e) => { println!("ERROR: could not rotate private key, message: {}", e); } }, + SetSlow => { + + } } Ok(()) } } +#[derive(clap::Args)] +pub struct SetSlowTx { + // TODO: any arguments needed? Confirmation? +} + +impl SetSlowTx { + pub async fn run(&self, sender: &mut Sender) -> anyhow::Result<()> { + let payload = libra_stdlib::slow_wallet_set_slow(); + sender.sign_submit_wait(payload).await?; + Ok(()) + } +} + + +#[derive(clap::Args)] +pub struct RotateKeyTx { + #[clap(short, long)] + /// The new authkey to be used + new_private_key: Option, // Dev NOTE: account address has the same bytes as AuthKey +} + + impl RotateKeyTx { pub async fn run(&self, sender: &mut Sender) -> anyhow::Result<()> { let user_account: AccountAddress = sender.local_account.address(); @@ -94,7 +114,7 @@ pub fn rotate_key( let rotation_proof_signed_by_new_private_key = new_private_key.sign_arbitrary_message(&rotation_msg); - let payload = account_rotate_authentication_key( + let payload = libra_stdlib::account_rotate_authentication_key( 0, // Existing public key current_private_key.public_key().to_bytes().to_vec(),