1
1
use crate :: jcli_lib:: rest:: RestArgs ;
2
2
use crate :: jcli_lib:: transaction:: { common, Error } ;
3
- use chain_crypto:: { Ed25519 , Ed25519Extended , PublicKey , SecretKey } ;
4
-
5
3
use crate :: transaction:: mk_witness:: WitnessType ;
6
4
use crate :: transaction:: staging:: Staging ;
7
5
use crate :: utils:: key_parser:: read_ed25519_secret_key_from_file;
8
6
use crate :: utils:: AccountId ;
9
7
use crate :: { rest, transaction} ;
10
8
use chain_addr:: Kind ;
11
9
use chain_core:: property:: FromStr ;
10
+ use chain_crypto:: { Ed25519 , Ed25519Extended , PublicKey , SecretKey } ;
12
11
use chain_impl_mockchain:: account:: SpendingCounter ;
13
12
use chain_impl_mockchain:: key:: EitherEd25519SecretKey ;
14
13
use chain_impl_mockchain:: transaction:: Output ;
15
14
use jormungandr_lib:: interfaces;
15
+
16
+ use crate :: transaction:: common:: CommonFees ;
17
+ use jormungandr_lib:: interfaces:: SettingsDto ;
16
18
use rand:: rngs:: OsRng ;
17
19
use rand:: SeedableRng ;
18
20
use rand_chacha:: ChaChaRng ;
@@ -42,9 +44,6 @@ pub struct MakeTransaction {
42
44
#[ structopt( flatten) ]
43
45
pub common : common:: CommonTransaction ,
44
46
45
- #[ structopt( flatten) ]
46
- pub fee : common:: CommonFees ,
47
-
48
47
#[ structopt( flatten) ]
49
48
rest_args : RestArgs ,
50
49
}
@@ -58,7 +57,6 @@ impl MakeTransaction {
58
57
receiver_address,
59
58
secret_key,
60
59
self . value ,
61
- self . fee ,
62
60
& self . block0_hash ,
63
61
self . rest_args . clone ( ) ,
64
62
self . change ,
@@ -90,13 +88,41 @@ fn create_receiver_secret_key_and_address(
90
88
Ok ( ( sk, address) )
91
89
}
92
90
91
+ fn common_fee_from_settings ( settings : & SettingsDto ) -> CommonFees {
92
+ let fees = settings. fees ;
93
+ CommonFees {
94
+ constant : fees. constant ,
95
+ coefficient : fees. coefficient ,
96
+ certificate : fees. certificate ,
97
+ certificate_pool_registration : fees
98
+ . per_certificate_fees
99
+ . certificate_pool_registration
100
+ . map ( Into :: into) ,
101
+ certificate_stake_delegation : fees
102
+ . per_certificate_fees
103
+ . certificate_owner_stake_delegation
104
+ . map ( Into :: into) ,
105
+ certificate_owner_stake_delegation : fees
106
+ . per_certificate_fees
107
+ . certificate_owner_stake_delegation
108
+ . map ( Into :: into) ,
109
+ certificate_vote_plan : fees
110
+ . per_vote_certificate_fees
111
+ . certificate_vote_plan
112
+ . map ( Into :: into) ,
113
+ certificate_vote_cast : fees
114
+ . per_vote_certificate_fees
115
+ . certificate_vote_cast
116
+ . map ( Into :: into) ,
117
+ }
118
+ }
119
+
93
120
#[ allow( clippy:: too_many_arguments) ]
94
121
pub fn make_transaction (
95
122
sender_account : interfaces:: Address ,
96
123
receiver_address : interfaces:: Address ,
97
124
secret_key : EitherEd25519SecretKey ,
98
125
value : interfaces:: Value ,
99
- fee : common:: CommonFees ,
100
126
block0_hash : & str ,
101
127
rest_args : RestArgs ,
102
128
change : Option < interfaces:: Address > ,
@@ -112,6 +138,9 @@ pub fn make_transaction(
112
138
value : value. into ( ) ,
113
139
} ) ?;
114
140
141
+ let settings = rest:: v0:: settings:: request_settings ( rest_args. clone ( ) ) ?;
142
+ let fee = common_fee_from_settings ( & settings) ;
143
+
115
144
// finalize
116
145
transaction:: finalize:: finalize ( fee, change, & mut transaction) ?;
117
146
0 commit comments