Skip to main content

casper_client/cli/
transaction_builder_params.rs

1use casper_types::{
2    bytesrepr::Bytes,
3    system::auction::{DelegatorKind, Reservation},
4    AddressableEntityHash, EntityVersionKey, PackageHash, PublicKey, TransactionRuntimeParams,
5    TransferTarget, URef, U512,
6};
7
8/// An enum representing the parameters needed to construct a transaction builder
9/// for the commands concerning the creation of a transaction
10
11#[derive(Debug)]
12pub enum TransactionBuilderParams<'a> {
13    /// Parameters for the add bid variant of the transaction builder
14    AddBid {
15        /// The public key for the add bid transaction
16        public_key: PublicKey,
17        /// The delegation rate for the add bid transaction
18        delegation_rate: u8,
19        /// The amount to be bid in the add bid transaction
20        amount: U512,
21        /// The minimum amount to be delegated
22        minimum_delegation_amount: Option<u64>,
23        /// The maximum amount to be delegated
24        maximum_delegation_amount: Option<u64>,
25        /// Number of delegator slots which can be reserved for specific delegators
26        reserved_slots: Option<u32>,
27    },
28    /// Parameters for the delegate variant of the transaction builder
29    Delegate {
30        /// The delegator for the delegate transaction
31        delegator: PublicKey,
32        /// The validator on which to delegate via the transaction
33        validator: PublicKey,
34        /// The amount to be delegtaed in the transaction
35        amount: U512,
36    },
37    /// Parameters for the undelegate variant of the transaction builder
38    Undelegate {
39        /// The delegator for the undelegate transaction
40        delegator: PublicKey,
41        /// The delegator for the delegate transaction
42        validator: PublicKey,
43        /// The delegator for the delegate transaction
44        amount: U512,
45    },
46    /// Parameters for the redelegate variant of the transaction builder
47    Redelegate {
48        /// The delegator for the redelegate transaction
49        delegator: PublicKey,
50        /// The validator for the redelegate transaction
51        validator: PublicKey,
52        /// The amount to be redelegated for the redelegate transaction
53        amount: U512,
54        /// The new validator for the redelegate transaction
55        new_validator: PublicKey,
56    },
57    /// Parameters for the change bid public key variant of the transaction builder
58    ChangeBidPublicKey {
59        /// The validator for the change bid public key transaction
60        public_key: PublicKey,
61        /// New validator for the change bid public key transaction
62        new_public_key: PublicKey,
63    },
64    /// Parameters for the add reservations variant of the transaction builder
65    AddReservations {
66        /// List of reservations for the add reservations transaction
67        reservations: Vec<Reservation>,
68    },
69    /// Parameters for the cancel reservations variant of the transaction builder
70    CancelReservations {
71        /// The validator for the cancel reservations transaction
72        validator: PublicKey,
73        /// List of delegatora for the cancel reservations transaction
74        delegators: Vec<DelegatorKind>,
75    },
76    /// Parameters for the invocable entity variant of the transaction builder
77    InvocableEntity {
78        /// The entity hash for the invocable entity transaction
79        entity_hash: AddressableEntityHash,
80        /// The entry point for the invocable entity transaction
81        entry_point: &'a str,
82        /// Transaction Runtime params.
83        runtime: TransactionRuntimeParams,
84    },
85    /// Parameters for the invocable entity alias variant of the transaction builder
86    InvocableEntityAlias {
87        /// The entity alias for the invocable entity alias transaction
88        entity_alias: &'a str,
89        /// The entry_point for the invocable entity alias transaction
90        entry_point: &'a str,
91        /// Transaction Runtime params.
92        runtime: TransactionRuntimeParams,
93    },
94    /// Parameters for the package variant of the transaction builder
95    Package {
96        /// The package hash for the package transaction
97        package_hash: PackageHash,
98        /// The optional entity version for the package transaction
99        maybe_entity_version: Option<u32>,
100        /// The entry_point for the package transaction
101        entry_point: &'a str,
102        /// Transaction Runtime.
103        runtime: TransactionRuntimeParams,
104    },
105    /// Parameters for the package variant of the transaction builder
106    PackageWithVersionKey {
107        /// The package hash for the package transaction
108        package_hash: PackageHash,
109        /// The optional entity version for the package transaction
110        maybe_entity_version_key: Option<EntityVersionKey>,
111        /// The entry_point for the package transaction
112        entry_point: &'a str,
113        /// Transaction Runtime.
114        runtime: TransactionRuntimeParams,
115    },
116    /// Parameters for the package alias variant of the transaction builder
117    PackageAlias {
118        /// The package alias for the package alias transaction
119        package_alias: &'a str,
120        /// The optional entity version for the package alias transaction
121        maybe_entity_version: Option<u32>,
122        /// The entry point for the package alias transaction
123        entry_point: &'a str,
124        /// Transaction Runtime params.
125        runtime: TransactionRuntimeParams,
126    },
127    /// Parameters for the package alias variant of the transaction builder
128    PackageAliasWithVersionKey {
129        /// The package alias for the package alias transaction
130        package_alias: &'a str,
131        /// The optional entity version for the package alias transaction
132        maybe_entity_version_key: Option<EntityVersionKey>,
133        /// The entry point for the package alias transaction
134        entry_point: &'a str,
135        /// Transaction Runtime params.
136        runtime: TransactionRuntimeParams,
137    },
138    /// Parameters for the session variant of the transaction builder
139    Session {
140        /// Flag determining if the Wasm is an install/upgrade.
141        is_install_upgrade: bool,
142        /// The Bytes to be run by the execution engine for the session transaction
143        transaction_bytes: Bytes,
144        /// Transaction Runtime.
145        runtime: TransactionRuntimeParams,
146    },
147    /// Parameters for the transfer variant of the transaction builder
148    Transfer {
149        /// Source of the transfer transaction
150        maybe_source: Option<URef>,
151        /// Target of the transfer transaction
152        target: TransferTarget,
153        /// The amount of motes for the undelegate transaction
154        amount: U512,
155        /// The optional id for the transfer transaction
156        maybe_id: Option<u64>,
157    },
158    /// Parameters for the withdraw bid variant of the transaction builder
159    WithdrawBid {
160        /// The public key for the withdraw bid transaction
161        public_key: PublicKey,
162        /// The amount to be withdrawn in the withdraw bid transaction
163        amount: U512,
164        /// Override the min bid amount check
165        min_bid_override: bool,
166    },
167    /// Parameters for the activate bid variant of the transaction builder
168    ActivateBid {
169        /// The public key for the activate bid transaction
170        validator: PublicKey,
171    },
172}