Skip to content

Commit

Permalink
feat!: sign_message_nep413, sign_message_nep366_delegate_action f…
Browse files Browse the repository at this point in the history
…eatures, examples (#6)

* chore: increase `CHUNK_SIZE`

* chore: move `sign_transaction` example to `sign_transfer`

* chore: add `sign_multiple_transfers` example (3x)

* chore: add `get_public_key_display` and `get_public_key_silent` examples

* chore: add `get_wallet_id` example

* chore: silent `get_public_key` by default in sign examples

* chore: add `sign_create_account` example

* chore: add `sign_delete_account` `short/long` examples

* chore: add `delete_key_ed25519` example

* chore: add `sign_delete_key_secp256k1` example

* chore: compile fix and fmt

* chore: add `sign_stake` example

* chore: add `add_key_fullaccess` example

* chore: add `sign_add_key_functioncall` example

* chore: add `sign_deploy_contract` example

* chore: add `sign_functioncall_str` example

* chore: add `sign_functioncall_bin` example

* chore: add `sign_delegate` example

* feat: impl `sign_message_nep413`

* chore: correct `sign_delegate` example

* feat: impl `sign_message_nep366_delegate_action`

* chore: reorg examples

* chore: add `sign_functioncall_str_parse_err` example

* chore: add `sign_transaction/batch_all_actions.rs` example

* chore: expand `sign_nep_366_delegate_action` to include all types of actions

* chore: improve `log::info` of apdu-s

* chore!: remove `blind_sign_transaction` public fn
  • Loading branch information
dj8yfo authored Feb 29, 2024
1 parent 2be7f7f commit 75b6363
Show file tree
Hide file tree
Showing 25 changed files with 1,010 additions and 164 deletions.
77 changes: 73 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "near-ledger"
version = "0.4.0"
version = "0.5.0"
edition = "2018"
authors = ["Bohdan Khorolets <b@khorolets.com>"]
description = "Transport library to integrate with NEAR Ledger app"
Expand All @@ -12,13 +12,80 @@ keywords = ["ledger", "nearprotocol"]
name = "get_version"

[[example]]
name = "get_public_key"
name = "get_public_key_display"
path = "examples/get_public_key/display.rs"

[[example]]
name = "sign_transaction"
name = "get_public_key_silent"
path = "examples/get_public_key/silent.rs"

[[example]]
name = "blind_sign_transaction"
name = "get_wallet_id"
path = "examples/get_wallet_id.rs"

[[example]]
name = "sign_transfer"
path = "examples/sign_transaction/transfer.rs"

[[example]]
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 = "sign_delete_key_ed25519"
path = "examples/sign_transaction/delete_key_ed25519.rs"

[[example]]
name = "sign_delete_key_secp256k1"
path = "examples/sign_transaction/delete_key_secp256k1.rs"

[[example]]
name = "sign_stake"
path = "examples/sign_transaction/stake.rs"

[[example]]
name = "sign_add_key_fullaccess"
path = "examples/sign_transaction/add_key_fullaccess.rs"

[[example]]
name = "sign_add_key_functioncall"
path = "examples/sign_transaction/add_key_functioncall.rs"

[[example]]
name = "sign_deploy_contract"
path = "examples/sign_transaction/deploy_contract.rs"

[[example]]
name = "sign_functioncall_str"
path = "examples/sign_transaction/functioncall_str.rs"

[[example]]
name = "sign_functioncall_bin"
path = "examples/sign_transaction/functioncall_bin.rs"

[[example]]
name = "sign_functioncall_str_parse_err"
path = "examples/sign_transaction/functioncall_str_parse_err.rs"

[[example]]
name = "sign_batch_all_actions"
path = "examples/sign_transaction/batch_all_actions.rs"

[[example]]
name = "sign_nep_413_message"
path = "examples/sign_nep_413_message.rs"

[[example]]
name = "sign_nep_366_delegate_action"
path = "examples/sign_nep_366_delegate_action.rs"

[dependencies]
ed25519-dalek = { version = "1" }
Expand All @@ -29,8 +96,10 @@ slip10 = "0.4.3"
log = "0.4.20"
hex = "0.4.3"
near-primitives-core = "0.20.0"
near-primitives = "0.20.0"

[dev-dependencies]
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"]}
49 changes: 44 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,23 +75,62 @@ let signature = near_crypto::Signature::from_parts(near_crypto::KeyType::ED25519
### Get version

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

### Get PublicKey from Ledger

#### Display

```bash
RUST_LOG=info cargo run --example get_public_key_display
```
#### Silent

```bash
RUST_LOG=get_public_key,near_ledger=info cargo run --example get_public_key
RUST_LOG=info cargo run --example get_public_key_silent
```

### Get WalletID from Ledger

```bash
RUST_LOG=info cargo run --example get_wallet_id
```
### Sign a transaction

#### Transfer

```bash
RUST_LOG=info cargo run --example sign_transfer
```

#### Other

```bash
export RUST_LOG=info
cargo run --example sign_create_account
cargo run --example sign_delete_account_short
cargo run --example sign_delete_account_long
cargo run --example sign_delete_key_ed25519
cargo run --example sign_delete_key_secp256k1
cargo run --example sign_stake
cargo run --example sign_add_key_fullaccess
cargo run --example sign_add_key_functioncall
cargo run --example sign_deploy_contract
cargo run --example sign_functioncall_str
cargo run --example sign_functioncall_bin
cargo run --example sign_functioncall_str_parse_err
cargo run --example sign_batch_all_actions
```

### Sign a NEP-413 message

```bash
RUST_LOG=sign_transaction,near_ledger=info cargo run --example sign_transaction
RUST_LOG=info cargo run --example sign_nep_413_message
```

### Blind sign a transaction
### Sign a NEP-366 delegate action

```bash
RUST_LOG=blind_sign_transaction,near_ledger=info cargo run --example blind_sign_transaction
RUST_LOG=info cargo run --example sign_nep_366_delegate_action
```
53 changes: 0 additions & 53 deletions examples/blind_sign_transaction.rs

This file was deleted.

Loading

0 comments on commit 75b6363

Please sign in to comment.