Skip to content

Commit

Permalink
chore: add sign_delete_account short/long examples
Browse files Browse the repository at this point in the history
  • Loading branch information
dj8yf0μl committed Jan 25, 2024
1 parent 756eed6 commit 84ab665
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 0 deletions.
9 changes: 9 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,14 @@ path = "examples/sign_transaction/multiple_transfers.rs"
name = "sign_create_account"
path = "examples/sign_transaction/create_account.rs"

[[example]]
name = "sign_delete_account_short"
path = "examples/sign_transaction/delete_account_short.rs"

[[example]]
name = "sign_delete_account_long"
path = "examples/sign_transaction/delete_account_long.rs"

[[example]]
name = "blind_sign_transaction"

Expand All @@ -52,3 +60,4 @@ near-primitives-core = "0.20.0"
env_logger = "0.10.0"
near-crypto = "0.20.0"
near-primitives = "0.20.0"
near-account-id = { version = "1.0.0", features = ["internal_unstable"]}
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,18 @@ RUST_LOG=get_wallet_id,near_ledger=info cargo run --example get_wallet_id
RUST_LOG=sign_create_account,near_ledger=info cargo run --example sign_create_account
```

#### Delete account (short)

```bash
RUST_LOG=sign_delete_account_short,near_ledger=info cargo run --example sign_delete_account_short
```

#### Delete account (long)

```bash
RUST_LOG=sign_delete_account_long,near_ledger=info cargo run --example sign_delete_account_long
```

#### Transfer

```bash
Expand Down
20 changes: 20 additions & 0 deletions examples/sign_transaction/delete_account_long.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
use near_account_id::AccountId;
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);
tx.actions = vec![near_primitives::transaction::Action::DeleteAccount(
near_primitives::transaction::DeleteAccountAction {
beneficiary_id: AccountId::new_unvalidated(
"dc7e34eecec3096a4a661e10932834f801149c49dba9b93322f6d9de18047f9c1b11b3b31673033936ad07bddc01f9da27d974811e480fb197c799e23480a489".to_string()),
},
)];
tx
}

fn main() -> Result<(), NEARLedgerError> {
common::get_key_sign_and_verify_flow(tx)
}
21 changes: 21 additions & 0 deletions examples/sign_transaction/delete_account_short.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
use std::str::FromStr;

use near_account_id::AccountId;
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);
tx.actions = vec![near_primitives::transaction::Action::DeleteAccount(
near_primitives::transaction::DeleteAccountAction {
beneficiary_id: AccountId::from_str("bob.near").unwrap(),
},
)];
tx
}

fn main() -> Result<(), NEARLedgerError> {
common::get_key_sign_and_verify_flow(tx)
}

0 comments on commit 84ab665

Please sign in to comment.