Skip to content

Commit

Permalink
Merge branches 'tomas/rm-empty-keys-mod', 'tomas/missing-args-def', '…
Browse files Browse the repository at this point in the history
…tomas/improve-cli-commission-rate' and 'tomas/rename-tx-reveal-arg' (#1431, #1432, #1434, #1436)

* tomas/rm-empty-keys-mod:
  app/wallet: rm empty keys mod

* tomas/missing-args-def:
  cli: add missing `--wallet-alias-force` and `--alias-force`

* tomas/improve-cli-commission-rate:
  shared/tx/submit_validator_commission_change: print err even with force

* tomas/rename-tx-reveal-arg:
  cli: rename Tx arg `tx_code_path` to `tx_reveal_code_path`
  • Loading branch information
tzemanovic committed May 21, 2023
5 parents 7ffbd6d + 23a1518 + 4e6adf9 + 9d3614d + de50551 commit 26f32ca
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 19 deletions.
21 changes: 18 additions & 3 deletions apps/src/lib/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3223,7 +3223,7 @@ pub mod args {
gas_limit: self.gas_limit,
signing_key: self.signing_key.map(|x| ctx.get_cached(&x)),
signer: self.signer.map(|x| ctx.get(&x)),
tx_code_path: ctx.read_wasm(self.tx_code_path),
tx_reveal_code_path: ctx.read_wasm(self.tx_reveal_code_path),
password: self.password,
expiration: self.expiration,
chain_id: self.chain_id,
Expand Down Expand Up @@ -3259,6 +3259,9 @@ pub mod args {
initialized, the alias will be the prefix of each new \
address joined with a number.",
))
.arg(WALLET_ALIAS_FORCE.def().about(
"Override the alias without confirmation if it already exists.",
))
.arg(GAS_AMOUNT.def().about(
"The amount being paid for the inclusion of this transaction",
))
Expand Down Expand Up @@ -3309,7 +3312,7 @@ pub mod args {
let expiration = EXPIRATION_OPT.parse(matches);
let signing_key = SIGNING_KEY_OPT.parse(matches);
let signer = SIGNER.parse(matches);
let tx_code_path = PathBuf::from(TX_REVEAL_PK);
let tx_reveal_code_path = PathBuf::from(TX_REVEAL_PK);
let chain_id = CHAIN_ID_OPT.parse(matches);
let password = None;
Self {
Expand All @@ -3326,7 +3329,7 @@ pub mod args {
expiration,
signing_key,
signer,
tx_code_path,
tx_reveal_code_path,
password,
chain_id,
}
Expand Down Expand Up @@ -3376,6 +3379,9 @@ pub mod args {
.def()
.about("An alias to be associated with the new entry."),
)
.arg(ALIAS_FORCE.def().about(
"Override the alias without confirmation if it already exists.",
))
.arg(
MASP_VALUE
.def()
Expand Down Expand Up @@ -3444,6 +3450,9 @@ pub mod args {
"An alias to be associated with the payment address.",
),
)
.arg(ALIAS_FORCE.def().about(
"Override the alias without confirmation if it already exists.",
))
.arg(VIEWING_KEY.def().about("The viewing key."))
.arg(PIN.def().about(
"Require that the single transaction to this address be \
Expand Down Expand Up @@ -3524,6 +3533,9 @@ pub mod args {
"The key and address alias. If none provided, the alias will \
be the public key hash.",
))
.arg(ALIAS_FORCE.def().about(
"Override the alias without confirmation if it already exists.",
))
.arg(UNSAFE_DONT_ENCRYPT.def().about(
"UNSAFE: Do not encrypt the keypair. Do not use this for keys \
used in a live network.",
Expand Down Expand Up @@ -3701,6 +3713,9 @@ pub mod args {
.def()
.about("An alias to be associated with the address."),
)
.arg(ALIAS_FORCE.def().about(
"Override the alias without confirmation if it already exists.",
))
.arg(
RAW_ADDRESS
.def()
Expand Down
1 change: 0 additions & 1 deletion apps/src/lib/wallet/keys.rs

This file was deleted.

1 change: 0 additions & 1 deletion apps/src/lib/wallet/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
pub mod defaults;
mod keys;
pub mod pre_genesis;
mod store;

Expand Down
4 changes: 2 additions & 2 deletions shared/src/ledger/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -400,8 +400,8 @@ pub struct Tx<C: NamadaTypes = SdkTypes> {
pub signing_key: Option<C::Keypair>,
/// Sign the tx with the keypair of the public key of the given address
pub signer: Option<C::Address>,
/// Path to the TX WASM code file
pub tx_code_path: C::Data,
/// Path to the TX WASM code file to reveal PK
pub tx_reveal_code_path: C::Data,
/// Password to decrypt key
pub password: Option<String>,
}
Expand Down
17 changes: 5 additions & 12 deletions shared/src/ledger/tx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ pub async fn submit_reveal_pk_aux<
let addr: Address = public_key.into();
println!("Submitting a tx to reveal the public key for address {addr}...");
let tx_data = public_key.try_to_vec().map_err(Error::EncodeKeyFailure)?;
let tx_code = args.tx_code_path.clone();
let tx_code = args.tx_reveal_code_path.clone();
let tx = Tx::new(
tx_code,
Some(tx_data),
Expand Down Expand Up @@ -528,18 +528,11 @@ pub async fn submit_validator_commission_change<
let validator = args.validator.clone();
if rpc::is_validator(client, &validator).await {
if args.rate < Decimal::ZERO || args.rate > Decimal::ONE {
if args.tx.force {
eprintln!(
"Invalid new commission rate, received {}",
args.rate
);
Ok(())
} else {
Err(Error::InvalidCommisionRate(args.rate))
eprintln!("Invalid new commission rate, received {}", args.rate);
if !args.tx.force {
return Err(Error::InvalidCommisionRate(args.rate));
}
} else {
Ok(())
}?;
}

let pipeline_epoch_minus_one = epoch + params.pipeline_len - 1;

Expand Down

0 comments on commit 26f32ca

Please sign in to comment.