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