Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sdk minor fixes #1409

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 18 additions & 3 deletions apps/src/lib/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3165,7 +3165,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 @@ -3201,6 +3201,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 @@ -3251,7 +3254,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 @@ -3268,7 +3271,7 @@ pub mod args {
expiration,
signing_key,
signer,
tx_code_path,
tx_reveal_code_path,
password,
chain_id,
}
Expand Down Expand Up @@ -3318,6 +3321,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 @@ -3386,6 +3392,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 @@ -3418,6 +3427,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 @@ -3586,6 +3598,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
25 changes: 9 additions & 16 deletions shared/src/ledger/tx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ pub enum Error {
TxBroadcast(RpcError),
/// Invalid comission rate set
#[error("Invalid new commission rate, received {0}")]
InvalidCommisionRate(Decimal),
InvalidCommissionRate(Decimal),
/// Invalid validator address
#[error("The address {0} doesn't belong to any known validator account.")]
InvalidValidatorAddress(Address),
Expand All @@ -73,7 +73,7 @@ pub enum Error {
TooLargeOfChange(Decimal),
/// Error retrieving from storage
#[error("Error retrieving from storage")]
Retrival,
Retrieval,
/// No unbonded bonds ready to withdraw in the current epoch
#[error(
"There are no unbonded bonds ready to withdraw in the current epoch \
Expand Down 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::InvalidCommissionRate(args.rate));
}
} else {
Ok(())
}?;
}

let pipeline_epoch_minus_one = epoch + params.pipeline_len - 1;

Expand All @@ -563,14 +556,14 @@ pub async fn submit_validator_commission_change<
effect."
);
if !args.tx.force {
return Err(Error::InvalidCommisionRate(args.rate));
return Err(Error::InvalidCommissionRate(args.rate));
}
}
}
None => {
eprintln!("Error retrieving from storage");
if !args.tx.force {
return Err(Error::Retrival);
return Err(Error::Retrieval);
}
}
}
Expand Down