Skip to content

Commit 2e4bfcd

Browse files
authored
Merge pull request #219 from teonite/fix_cancel_reservations_args
Fix cancel reservations args
2 parents 686ad6d + e349da0 commit 2e4bfcd

File tree

5 files changed

+19
-16
lines changed

5 files changed

+19
-16
lines changed

lib/cli/arg_handling.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use core::marker::PhantomData;
22

3-
use casper_types::system::auction::{Reservation, ARG_VALIDATOR};
3+
use casper_types::system::auction::{DelegatorKind, Reservation, ARG_VALIDATOR};
44
use casper_types::TransferTarget;
55
use casper_types::{bytesrepr::ToBytes, CLTyped, CLValueError, PublicKey, RuntimeArgs, URef, U512};
66

@@ -48,7 +48,7 @@ const ADD_RESERVATIONS_ARG_RESERVATIONS: RequiredArg<Vec<Reservation>> =
4848
RequiredArg::new("reservations");
4949

5050
const CANCEL_RESERVATIONS_ARG_VALIDATOR: RequiredArg<PublicKey> = RequiredArg::new("validator");
51-
const CANCEL_RESERVATIONS_ARG_DELEGATORS: RequiredArg<Vec<PublicKey>> =
51+
const CANCEL_RESERVATIONS_ARG_DELEGATORS: RequiredArg<Vec<DelegatorKind>> =
5252
RequiredArg::new("delegators");
5353

5454
struct RequiredArg<T> {
@@ -149,7 +149,7 @@ pub fn new_add_reservations_args(
149149
/// Creates a `RuntimeArgs` suitable for use in a cancel reservations transaction.
150150
pub fn new_cancel_reservations_args(
151151
validator: PublicKey,
152-
delegators: Vec<PublicKey>,
152+
delegators: Vec<DelegatorKind>,
153153
) -> Result<RuntimeArgs, CLValueError> {
154154
let mut args = RuntimeArgs::new();
155155
CANCEL_RESERVATIONS_ARG_VALIDATOR.insert(&mut args, validator)?;

lib/cli/tests.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -447,9 +447,10 @@ mod transaction {
447447
use super::*;
448448
use crate::{cli::TransactionV1BuilderError, Error::TransactionBuild};
449449
use casper_types::{
450-
bytesrepr::Bytes, system::auction::Reservation, PackageAddr, TransactionArgs,
451-
TransactionEntryPoint, TransactionInvocationTarget, TransactionRuntimeParams,
452-
TransactionTarget, TransferTarget,
450+
bytesrepr::Bytes,
451+
system::auction::{DelegatorKind, Reservation},
452+
PackageAddr, TransactionArgs, TransactionEntryPoint, TransactionInvocationTarget,
453+
TransactionRuntimeParams, TransactionTarget, TransferTarget,
453454
};
454455
use once_cell::sync::Lazy;
455456
use rand::{thread_rng, Rng};
@@ -1092,7 +1093,7 @@ mod transaction {
10921093
let delegators = (0..rng.gen_range(1..10))
10931094
.map(|_| {
10941095
let secret_key = SecretKey::generate_ed25519().unwrap();
1095-
PublicKey::from(&secret_key)
1096+
DelegatorKind::PublicKey(PublicKey::from(&secret_key))
10961097
})
10971098
.collect();
10981099

@@ -1448,7 +1449,7 @@ mod transaction {
14481449

14491450
let maybe_source = Some(source_uref);
14501451

1451-
let source_uref_cl = &CLValue::from_t(&source_uref).unwrap();
1452+
let source_uref_cl = &CLValue::from_t(source_uref).unwrap();
14521453
let target_uref_cl = &CLValue::from_t(target_uref).unwrap();
14531454

14541455
let transaction_string_params = TransactionStrParams {

lib/cli/transaction_builder_params.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
use casper_types::{
2-
bytesrepr::Bytes, system::auction::Reservation, AddressableEntityHash, PackageHash, PublicKey,
3-
TransactionRuntimeParams, TransferTarget, URef, U512,
2+
bytesrepr::Bytes,
3+
system::auction::{DelegatorKind, Reservation},
4+
AddressableEntityHash, PackageHash, PublicKey, TransactionRuntimeParams, TransferTarget, URef,
5+
U512,
46
};
57

68
/// An enum representing the parameters needed to construct a transaction builder
@@ -69,7 +71,7 @@ pub enum TransactionBuilderParams<'a> {
6971
/// The validator for the cancel reservations transaction
7072
validator: PublicKey,
7173
/// List of delegatora for the cancel reservations transaction
72-
delegators: Vec<PublicKey>,
74+
delegators: Vec<DelegatorKind>,
7375
},
7476
/// Parameters for the invocable entity variant of the transaction builder
7577
InvocableEntity {

lib/cli/transaction_v1_builder.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use alloc::collections::BTreeSet;
99
use alloc::vec::Vec;
1010
use casper_types::{
1111
bytesrepr::{Bytes, ToBytes},
12-
system::auction::Reservation,
12+
system::auction::{DelegatorKind, Reservation},
1313
AddressableEntityHash, CLValueError, Digest, EntityVersion, InitiatorAddr, PackageHash,
1414
PricingMode, PublicKey, RuntimeArgs, SecretKey, TimeDiff, Timestamp, TransactionArgs,
1515
TransactionEntryPoint, TransactionInvocationTarget, TransactionRuntimeParams,
@@ -303,7 +303,7 @@ impl<'a> TransactionV1Builder<'a> {
303303
/// transaction.
304304
pub fn new_cancel_reservations(
305305
validator: PublicKey,
306-
delegators: Vec<PublicKey>,
306+
delegators: Vec<DelegatorKind>,
307307
) -> Result<Self, CLValueError> {
308308
let args = arg_handling::new_cancel_reservations_args(validator, delegators)?;
309309
let mut builder = TransactionV1Builder::new();

src/transaction/creation_common.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1467,10 +1467,10 @@ mod reservations {
14671467
mod delegators {
14681468
use super::*;
14691469
use casper_client::cli::CliError;
1470-
use casper_types::PublicKey;
1470+
use casper_types::system::auction::DelegatorKind;
14711471

14721472
pub const ARG_NAME: &str = "delegators";
1473-
const ARG_VALUE_NAME: &str = "JSON serialized Vec<PublicKey>";
1473+
const ARG_VALUE_NAME: &str = "JSON serialized Vec<DelegatorKind>";
14741474
const ARG_HELP: &str = "list of delegator public keys for the cancel-reservations transaction";
14751475

14761476
pub fn arg() -> Arg {
@@ -1489,7 +1489,7 @@ mod delegators {
14891489
.unwrap_or_default()
14901490
}
14911491

1492-
pub(super) fn parse_delegators(value: &str) -> Result<Vec<PublicKey>, CliError> {
1492+
pub(super) fn parse_delegators(value: &str) -> Result<Vec<DelegatorKind>, CliError> {
14931493
if !value.is_empty() {
14941494
serde_json::from_str(value).map_err(|_| {
14951495
CliError::InvalidCLValue(

0 commit comments

Comments
 (0)