-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: add
add_key_fullaccess
example
- Loading branch information
dj8yf0μl
committed
Jan 26, 2024
1 parent
9696dbb
commit e78fb01
Showing
3 changed files
with
38 additions
and
0 deletions.
There are no files selected for viewing
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 @@ | ||
use near_crypto::SecretKey; | ||
use near_ledger::NEARLedgerError; | ||
|
||
#[path = "../common/lib.rs"] | ||
mod common; | ||
|
||
fn tx(ledger_pub_key: ed25519_dalek::PublicKey) -> near_primitives::transaction::Transaction { | ||
let mut tx = common::tx_template(ledger_pub_key.clone()); | ||
let sk = SecretKey::from_seed( | ||
near_crypto::KeyType::SECP256K1, | ||
&format!("{:?}", ledger_pub_key), | ||
); | ||
let public_key = sk.public_key(); | ||
tx.actions = vec![near_primitives::transaction::Action::AddKey(Box::new( | ||
near_primitives::transaction::AddKeyAction { | ||
public_key, | ||
access_key: near_primitives_core::account::AccessKey { | ||
nonce: 127127127127, | ||
permission: near_primitives_core::account::AccessKeyPermission::FullAccess, | ||
}, | ||
}, | ||
))]; | ||
tx | ||
} | ||
|
||
fn main() -> Result<(), NEARLedgerError> { | ||
common::get_key_sign_and_verify_flow(tx) | ||
} |