Skip to content

Commit

Permalink
start
Browse files Browse the repository at this point in the history
  • Loading branch information
FroVolod committed Jan 22, 2024
1 parent f6223e0 commit 92a961c
Show file tree
Hide file tree
Showing 51 changed files with 421 additions and 347 deletions.
468 changes: 275 additions & 193 deletions Cargo.lock

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,12 @@ thiserror = "1"
bytesize = "1.1.0"
prettytable = "0.10.0"

near-ledger = { version = "0.3.0", optional = true }
near-ledger = { version = "0.4.0", optional = true }

near-crypto = "0.17.0"
near-primitives = "0.17.0"
near-jsonrpc-client = "0.6.0"
near-jsonrpc-primitives = "0.17.0"
near-crypto = "0.20.0"
near-primitives = "0.20.0"
near-jsonrpc-client = "0.8.0"
near-jsonrpc-primitives = "0.20.0"

near-gas = { version = "0.2.3", features = [
"serde",
Expand All @@ -85,7 +85,7 @@ keyring = "2.0.5"
interactive-clap = "0.2.8"
interactive-clap-derive = "0.2.8"

near-socialdb-client = "0.2.1"
near-socialdb-client = "0.2.2"

[features]
default = ["ledger", "self-update"]
Expand Down
2 changes: 1 addition & 1 deletion rust-toolchain
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.70.0
1.72.0
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,15 @@ impl From<PrintKeypairToTerminalContext> for crate::commands::ActionContext {
Ok(crate::commands::PrepopulatedTransaction {
signer_id: signer_account_id.clone(),
receiver_id: signer_account_id.clone(),
actions: vec![near_primitives::transaction::Action::AddKey(
actions: vec![near_primitives::transaction::Action::AddKey(Box::new(
near_primitives::transaction::AddKeyAction {
public_key: item.public_key.clone(),
access_key: near_primitives::account::AccessKey {
nonce: 0,
permission: item.permission.clone(),
},
},
)],
))],
})
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,15 @@ impl From<SaveKeypairToKeychainContext> for crate::commands::ActionContext {
Ok(crate::commands::PrepopulatedTransaction {
signer_id: signer_account_id.clone(),
receiver_id: signer_account_id.clone(),
actions: vec![near_primitives::transaction::Action::AddKey(
actions: vec![near_primitives::transaction::Action::AddKey(Box::new(
near_primitives::transaction::AddKeyAction {
public_key: item.0.public_key.clone(),
access_key: near_primitives::account::AccessKey {
nonce: 0,
permission: item.0.permission.clone(),
},
},
)],
))],
})
}
});
Expand All @@ -48,7 +48,7 @@ impl From<SaveKeypairToKeychainContext> for crate::commands::ActionContext {
network_config.clone(),
&serde_json::to_string(&item.0.key_pair_properties)?,
&item.0.key_pair_properties.public_key_str,
&signed_transaction.transaction.signer_id,
signed_transaction.transaction.signer_id.as_ref(),
)?;
Ok(())
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,15 @@ impl From<SaveKeypairToLegacyKeychainContext> for crate::commands::ActionContext
Ok(crate::commands::PrepopulatedTransaction {
signer_id: signer_account_id.clone(),
receiver_id: signer_account_id.clone(),
actions: vec![near_primitives::transaction::Action::AddKey(
actions: vec![near_primitives::transaction::Action::AddKey(Box::new(
near_primitives::transaction::AddKeyAction {
public_key: item.public_key.clone(),
access_key: near_primitives::account::AccessKey {
nonce: 0,
permission: item.permission.clone(),
},
},
)],
))],
})
}
});
Expand All @@ -67,7 +67,7 @@ impl From<SaveKeypairToLegacyKeychainContext> for crate::commands::ActionContext
credentials_home_dir.clone(),
&key_pair_properties_buf,
&item.key_pair_properties.public_key_str,
&signed_transaction.transaction.signer_id,
signed_transaction.transaction.signer_id.as_ref(),
)
.wrap_err_with(|| {
format!(
Expand Down
4 changes: 2 additions & 2 deletions src/commands/account/add_key/use_ledger/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,15 +56,15 @@ impl From<AddLedgerKeyActionContext> for crate::commands::ActionContext {
Ok(crate::commands::PrepopulatedTransaction {
signer_id: signer_account_id.clone(),
receiver_id: signer_account_id.clone(),
actions: vec![near_primitives::transaction::Action::AddKey(
actions: vec![near_primitives::transaction::Action::AddKey(Box::new(
near_primitives::transaction::AddKeyAction {
public_key: item.public_key.clone().into(),
access_key: near_primitives::account::AccessKey {
nonce: 0,
permission: item.permission.clone(),
},
},
)],
))],
})
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,15 @@ impl From<AddAccessWithSeedPhraseActionContext> for crate::commands::ActionConte
Ok(crate::commands::PrepopulatedTransaction {
signer_id: signer_account_id.clone(),
receiver_id: signer_account_id.clone(),
actions: vec![near_primitives::transaction::Action::AddKey(
actions: vec![near_primitives::transaction::Action::AddKey(Box::new(
near_primitives::transaction::AddKeyAction {
public_key: item.public_key.clone(),
access_key: near_primitives::account::AccessKey {
nonce: 0,
permission: item.permission.clone(),
},
},
)],
))],
})
}
});
Expand Down
4 changes: 2 additions & 2 deletions src/commands/account/add_key/use_public_key/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,15 @@ impl From<AddAccessKeyActionContext> for crate::commands::ActionContext {
Ok(crate::commands::PrepopulatedTransaction {
signer_id: signer_account_id.clone(),
receiver_id: signer_account_id.clone(),
actions: vec![near_primitives::transaction::Action::AddKey(
actions: vec![near_primitives::transaction::Action::AddKey(Box::new(
near_primitives::transaction::AddKeyAction {
public_key: item.public_key.clone().into(),
access_key: near_primitives::account::AccessKey {
nonce: 0,
permission: item.permission.clone(),
},
},
)],
))],
})
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,14 @@ impl From<SignerAccountIdContext> for crate::commands::ActionContext {
},
),
near_primitives::transaction::Action::AddKey(
near_primitives::transaction::AddKeyAction {
Box::new(near_primitives::transaction::AddKeyAction {
public_key: item.account_properties.public_key.clone(),
access_key: near_primitives::account::AccessKey {
nonce: 0,
permission:
near_primitives::account::AccessKeyPermission::FullAccess,
},
},
}),
),
],
new_account_id.clone())
Expand All @@ -92,15 +92,17 @@ impl From<SignerAccountIdContext> for crate::commands::ActionContext {
{
(
vec![near_primitives::transaction::Action::FunctionCall(
near_primitives::transaction::FunctionCallAction {
method_name: "create_account".to_string(),
args,
gas: crate::common::NearGas::from_tgas(30).as_gas(),
deposit: item
.account_properties
.initial_balance
.as_yoctonear(),
},
Box::new(
near_primitives::transaction::FunctionCallAction {
method_name: "create_account".to_string(),
args,
gas: crate::common::NearGas::from_tgas(30).as_gas(),
deposit: item
.account_properties
.initial_balance
.as_yoctonear(),
},
),
)],
linkdrop_account_id.clone(),
)
Expand Down
4 changes: 2 additions & 2 deletions src/commands/account/delete_key/public_keys_to_delete.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@ impl From<PublicKeyListContext> for crate::commands::ActionContext {
.clone()
.into_iter()
.map(|public_key| {
near_primitives::transaction::Action::DeleteKey(
near_primitives::transaction::Action::DeleteKey(Box::new(
near_primitives::transaction::DeleteKeyAction { public_key },
)
))
})
.collect(),
})
Expand Down
4 changes: 2 additions & 2 deletions src/commands/account/import_account/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ fn save_access_key(
network_config,
key_pair_properties_buf,
public_key_str,
&account_id,
account_id.as_ref(),
)
.wrap_err_with(|| {
format!(
Expand All @@ -139,7 +139,7 @@ fn save_access_key(
credentials_home_dir,
key_pair_properties_buf,
public_key_str,
&account_id,
account_id.as_ref(),
)
.wrap_err_with(|| format!("Failed to save a file with access key: {}", public_key_str))?;
eprintln!("{}", storage_message);
Expand Down
4 changes: 2 additions & 2 deletions src/commands/account/storage_management/storage_deposit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,14 +118,14 @@ impl SignerAccountIdContext {
signer_id: signer_account_id.clone(),
receiver_id: get_contract_account_id(network_config)?,
actions: vec![near_primitives::transaction::Action::FunctionCall(
near_primitives::transaction::FunctionCallAction {
Box::new(near_primitives::transaction::FunctionCallAction {
method_name: "storage_deposit".to_string(),
args: serde_json::to_vec(&serde_json::json!({
"account_id": &receiver_account_id
}))?,
gas: crate::common::NearGas::from_tgas(50).as_gas(),
deposit: deposit.as_yoctonear(),
},
}),
)],
})
}
Expand Down
4 changes: 2 additions & 2 deletions src/commands/account/storage_management/storage_withdraw.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,14 @@ impl SignerAccountIdContext {
signer_id: signer_account_id.clone(),
receiver_id: get_contract_account_id(network_config)?,
actions: vec![near_primitives::transaction::Action::FunctionCall(
near_primitives::transaction::FunctionCallAction {
Box::new(near_primitives::transaction::FunctionCallAction {
method_name: "storage_withdraw".to_string(),
args: serde_json::to_vec(&serde_json::json!({
"amount": amount.clone().as_yoctonear().to_string()
}))?,
gas: crate::common::NearGas::from_tgas(50).as_gas(),
deposit: near_token::NearToken::from_yoctonear(1).as_yoctonear(),
},
}),
)],
})
}
Expand Down
4 changes: 2 additions & 2 deletions src/commands/account/update_social_profile/sign_as.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,12 +112,12 @@ impl From<SignerContext> for crate::commands::ActionContext {

prepopulated_transaction.actions =
vec![near_primitives::transaction::Action::FunctionCall(
near_primitives::transaction::FunctionCallAction {
Box::new(near_primitives::transaction::FunctionCallAction {
method_name: "set".to_string(),
args,
gas: crate::common::NearGas::from_tgas(300).as_gas(),
deposit: deposit.as_yoctonear(),
},
}),
)];

Ok(prepopulated_transaction)
Expand Down
4 changes: 2 additions & 2 deletions src/commands/contract/call_function/as_transaction/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -234,12 +234,12 @@ impl From<SignerAccountIdContext> for crate::commands::ActionContext {
signer_id: signer_account_id.clone(),
receiver_id: receiver_account_id.clone(),
actions: vec![near_primitives::transaction::Action::FunctionCall(
near_primitives::transaction::FunctionCallAction {
Box::new(near_primitives::transaction::FunctionCallAction {
method_name: item.function_name.clone(),
args: item.function_args.clone(),
gas: item.gas.as_gas(),
deposit: item.deposit.as_yoctonear(),
},
}),
)],
})
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,14 +163,14 @@ impl DepositContext {
code: previous_context.code.clone(),
},
),
near_primitives::transaction::Action::FunctionCall(
near_primitives::transaction::Action::FunctionCall(Box::new(
near_primitives::transaction::FunctionCallAction {
method_name: previous_context.function_name.clone(),
args: previous_context.function_args.clone(),
gas: previous_context.gas.as_gas(),
deposit: deposit.as_yoctonear(),
},
),
)),
],
})
}
Expand Down
4 changes: 2 additions & 2 deletions src/commands/staking/delegate/deposit_and_stake.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@ impl DepositAndStakeContext {
signer_id: signer_id.clone(),
receiver_id: validator_account_id.clone(),
actions: vec![near_primitives::transaction::Action::FunctionCall(
near_primitives::transaction::FunctionCallAction {
Box::new(near_primitives::transaction::FunctionCallAction {
method_name: "deposit_and_stake".to_string(),
args: serde_json::to_vec(&serde_json::json!({}))?,
gas: crate::common::NearGas::from_tgas(50).as_gas(),
deposit: amount.as_yoctonear(),
},
}),
)],
})
}
Expand Down
4 changes: 2 additions & 2 deletions src/commands/staking/delegate/stake.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,14 @@ impl StakeContext {
signer_id: signer_id.clone(),
receiver_id: validator_account_id.clone(),
actions: vec![near_primitives::transaction::Action::FunctionCall(
near_primitives::transaction::FunctionCallAction {
Box::new(near_primitives::transaction::FunctionCallAction {
method_name: "stake".to_string(),
args: serde_json::to_vec(&serde_json::json!({
"amount": amount,
}))?,
gas: crate::common::NearGas::from_tgas(50).as_gas(),
deposit: 0,
},
}),
)],
})
}
Expand Down
4 changes: 2 additions & 2 deletions src/commands/staking/delegate/stake_all.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@ impl StakeAllContext {
signer_id: signer_id.clone(),
receiver_id: validator_account_id.clone(),
actions: vec![near_primitives::transaction::Action::FunctionCall(
near_primitives::transaction::FunctionCallAction {
Box::new(near_primitives::transaction::FunctionCallAction {
method_name: "stake_all".to_string(),
args: serde_json::to_vec(&serde_json::json!({}))?,
gas: crate::common::NearGas::from_tgas(50).as_gas(),
deposit: 0,
},
}),
)],
})
}
Expand Down
4 changes: 2 additions & 2 deletions src/commands/staking/delegate/unstake.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,14 @@ impl UnstakeContext {
signer_id: signer_id.clone(),
receiver_id: validator_account_id.clone(),
actions: vec![near_primitives::transaction::Action::FunctionCall(
near_primitives::transaction::FunctionCallAction {
Box::new(near_primitives::transaction::FunctionCallAction {
method_name: "unstake".to_string(),
args: serde_json::to_vec(&serde_json::json!({
"amount": amount,
}))?,
gas: crate::common::NearGas::from_tgas(50).as_gas(),
deposit: 0,
},
}),
)],
})
}
Expand Down
Loading

0 comments on commit 92a961c

Please sign in to comment.