Skip to content

Commit 7e991db

Browse files
authored
feat: Sign transactions with MPC from a different account or even through a DAO proposal (#520)
This pr enables user to control other account using derived key and signing transaction through MPC contract like this: ``` cargo run tokens <controllable-account-id> send-near <recipient-account-id> '0.1 NEAR' network-config testnet sign-with-mpc <admin-account-id> ed25519 derivation-path <derivation-path> prepaid-gas '15.0 Tgas' attached-deposit '1 yoctoNEAR' sign-mpc-with-keychain send ``` Additionally, PR adds new field to the config `mpc_contract_account_id` and bumps it to version 4. Here are examples of transactions on nearblocks: - using ed25519 derived key: - "sign" call to MPC: [link](https://testnet.nearblocks.io/txns/22qLC8AjEqhCzNTmRsogDhFyeLBZ999bj7XPMdn8aUqP?tab=execution#3a4X5GGesrPP4EfcvHcQR5tJkTgtqB3pS92JcPcERWsF) - transfer to admin: [link](https://testnet.nearblocks.io/txns/HbF7gKqo4xke3zuGwCeU6STCSug4wEMGsBbyiQgWdKvp) - using secp256k1 derived key: - "sign" call to MPC: [link](https://testnet.nearblocks.io/txns/B4TMvTQP5SUqWhSFWwohd5yNhNjTyCBm8DWs6vFGkbfn?tab=execution#382GwQimfinLJLeH7YVzTSDQTTwF4cMtvLafLn1mnpVZ) - transfer to admin: [link](https://testnet.nearblocks.io/txns/D6bf7oAsMMZTNwAp75ADgsGy9ebxgUErRWTztkFXWGDS)
1 parent 9ab0e64 commit 7e991db

File tree

48 files changed

+1343
-56
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+1343
-56
lines changed

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ jobs:
6363
# we specify bash to get pipefail; it guards against the `curl` command
6464
# failing. otherwise `sh` won't catch that `curl` returned non-0
6565
shell: bash
66-
run: "curl --proto '=https' --tlsv1.2 -LsSf https://github.com/axodotdev/cargo-dist/releases/download/v0.29.0/cargo-dist-installer.sh | sh"
66+
run: "curl --proto '=https' --tlsv1.2 -LsSf https://github.com/axodotdev/cargo-dist/releases/download/v0.30.2/cargo-dist-installer.sh | sh"
6767
- name: Cache dist
6868
uses: actions/upload-artifact@v4
6969
with:

Cargo.toml

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ bip39 = { version = "2.0.0", features = ["rand"] }
4444
bs58 = "0.5"
4545
borsh = "1.5.7"
4646
ed25519-dalek = { version = "2", default-features = false }
47-
hex = "0.4.2"
47+
hex = { version = "0.4.2", features = ["serde"] }
4848
linked-hash-map = { version = "0.5", features = ["serde_impl"] }
4949
serde = { version = "1.0", features = ["derive"] }
5050
serde_json = "1.0.57"
@@ -114,10 +114,10 @@ interactive-clap-derive = "0.3"
114114
rust_decimal = "1.35.0"
115115

116116
# verify_contract dependencies
117-
near-verify-rs = {version = "0.3.0", optional = true}
118-
camino = {version = "1.1.1", optional = true}
119-
git2 = {version = "0.19", optional = true}
120-
tempfile = {version = "3.10.1", optional = true}
117+
near-verify-rs = { version = "0.3.0", optional = true }
118+
camino = { version = "1.1.1", optional = true }
119+
git2 = { version = "0.19", optional = true }
120+
tempfile = { version = "3.10.1", optional = true }
121121

122122
[dev-dependencies]
123123
near-sandbox = "0.2"
@@ -135,7 +135,7 @@ verify_contract = [
135135
"dep:near-verify-rs",
136136
"dep:camino",
137137
"dep:git2",
138-
"dep:tempfile"
138+
"dep:tempfile",
139139
]
140140

141141
# The profile that 'cargo dist' will build with
@@ -146,8 +146,7 @@ lto = "thin"
146146
# Config for 'dist'
147147
[workspace.metadata.dist]
148148
# The preferred dist version to use in CI (Cargo.toml SemVer syntax)
149-
cargo-dist-version = "0.29.0"
150-
# Skip checking whether the specified configuration files are up to date
149+
cargo-dist-version = "0.30.2"
151150
allow-dirty = ["ci"]
152151
# CI backends to support
153152
ci = "github"

src/commands/account/add_key/autogenerate_new_keypair/print_keypair_to_terminal/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ impl From<PrintKeypairToTerminalContext> for crate::commands::ActionContext {
5959
interacting_with_account_ids: vec![item.signer_account_id],
6060
get_prepopulated_transaction_after_getting_network_callback,
6161
on_before_signing_callback: std::sync::Arc::new(
62-
|_prepolulated_unsinged_transaction, _network_config| Ok(()),
62+
|_prepopulated_unsigned_transaction, _network_config| Ok(()),
6363
),
6464
on_before_sending_transaction_callback: std::sync::Arc::new(
6565
move |_transaction, _network_config| {

src/commands/account/add_key/autogenerate_new_keypair/save_keypair_to_keychain/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ impl From<SaveKeypairToKeychainContext> for crate::commands::ActionContext {
6969
interacting_with_account_ids: vec![item.0.signer_account_id],
7070
get_prepopulated_transaction_after_getting_network_callback,
7171
on_before_signing_callback: std::sync::Arc::new(
72-
|_prepolulated_unsinged_transaction, _network_config| Ok(()),
72+
|_prepopulated_unsigned_transaction, _network_config| Ok(()),
7373
),
7474
on_before_sending_transaction_callback,
7575
on_after_sending_transaction_callback: std::sync::Arc::new(

src/commands/account/add_key/autogenerate_new_keypair/save_keypair_to_legacy_keychain/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ impl From<SaveKeypairToLegacyKeychainContext> for crate::commands::ActionContext
9191
interacting_with_account_ids: vec![item.signer_account_id],
9292
get_prepopulated_transaction_after_getting_network_callback,
9393
on_before_signing_callback: std::sync::Arc::new(
94-
|_prepolulated_unsinged_transaction, _network_config| Ok(()),
94+
|_prepopulated_unsigned_transaction, _network_config| Ok(()),
9595
),
9696
on_before_sending_transaction_callback,
9797
on_after_sending_transaction_callback: std::sync::Arc::new(

src/commands/account/add_key/use_ledger/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ impl From<AddLedgerKeyActionContext> for crate::commands::ActionContext {
8282
interacting_with_account_ids: vec![item.signer_account_id],
8383
get_prepopulated_transaction_after_getting_network_callback,
8484
on_before_signing_callback: std::sync::Arc::new(
85-
|_prepolulated_unsinged_transaction, _network_config| Ok(()),
85+
|_prepopulated_unsigned_transaction, _network_config| Ok(()),
8686
),
8787
on_before_sending_transaction_callback: std::sync::Arc::new(
8888
|_signed_transaction, _network_config| Ok(String::new()),

src/commands/account/add_key/use_manually_provided_seed_phrase/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ impl From<AddAccessWithSeedPhraseActionContext> for crate::commands::ActionConte
6666
interacting_with_account_ids: vec![item.signer_account_id],
6767
get_prepopulated_transaction_after_getting_network_callback,
6868
on_before_signing_callback: std::sync::Arc::new(
69-
|_prepolulated_unsinged_transaction, _network_config| Ok(()),
69+
|_prepopulated_unsigned_transaction, _network_config| Ok(()),
7070
),
7171
on_before_sending_transaction_callback: std::sync::Arc::new(
7272
|_signed_transaction, _network_config| Ok(String::new()),

src/commands/account/add_key/use_public_key/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ impl From<AddAccessKeyActionContext> for crate::commands::ActionContext {
5959
interacting_with_account_ids: vec![item.signer_account_id],
6060
get_prepopulated_transaction_after_getting_network_callback,
6161
on_before_signing_callback: std::sync::Arc::new(
62-
|_prepolulated_unsinged_transaction, _network_config| Ok(()),
62+
|_prepopulated_unsigned_transaction, _network_config| Ok(()),
6363
),
6464
on_before_sending_transaction_callback: std::sync::Arc::new(
6565
|_signed_transaction, _network_config| Ok(String::new()),

src/commands/account/create_account/fund_myself_create_account/sign_as/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ impl From<SignerAccountIdContext> for crate::commands::ActionContext {
151151
],
152152
get_prepopulated_transaction_after_getting_network_callback,
153153
on_before_signing_callback: std::sync::Arc::new(
154-
|_prepolulated_unsinged_transaction, _network_config| Ok(()),
154+
|_prepopulated_unsigned_transaction, _network_config| Ok(()),
155155
),
156156
on_before_sending_transaction_callback: item.on_before_sending_transaction_callback,
157157
on_after_sending_transaction_callback,

src/commands/account/delete_account/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ impl From<BeneficiaryAccountContext> for crate::commands::ActionContext {
9898
interacting_with_account_ids: vec![item.account_id],
9999
get_prepopulated_transaction_after_getting_network_callback,
100100
on_before_signing_callback: std::sync::Arc::new(
101-
|_prepolulated_unsinged_transaction, _network_config| Ok(()),
101+
|_prepopulated_unsigned_transaction, _network_config| Ok(()),
102102
),
103103
on_before_sending_transaction_callback: std::sync::Arc::new(
104104
|_signed_transaction, _network_config| Ok(String::new()),

0 commit comments

Comments
 (0)