Skip to content

Commit a24a11f

Browse files
committed
fix comments
1 parent 18e6524 commit a24a11f

File tree

16 files changed

+519
-489
lines changed

16 files changed

+519
-489
lines changed

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/functional/test_framework/__init__.py

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,23 @@ def init_mintlayer_types():
206206
]
207207
},
208208

209+
"PoolAdditionalInfo": {
210+
"type": "struct",
211+
"type_mapping": [
212+
["staker_balance", "Amount"],
213+
]
214+
},
215+
216+
"OrderAdditionalInfo": {
217+
"type": "struct",
218+
"type_mapping": [
219+
["initially_asked", "OutputValue"],
220+
["initially_given", "OutputValue"],
221+
["ask_balance", "Amount"],
222+
["give_balance", "Amount"],
223+
]
224+
},
225+
209226
"InfoId": {
210227
"type": "enum",
211228
"type_mapping": [
@@ -216,11 +233,11 @@ def init_mintlayer_types():
216233
},
217234

218235
"TxAdditionalInfo": {
219-
"type": "enum",
236+
"type": "struct",
220237
"type_mapping": [
221-
["TokenInfo", "TokenAdditionalInfo"],
222-
["PoolInfo", "(Amount)"],
223-
["OrderInfo", ""], # TODO
238+
["token_info", "BTreeMap<H256, TokenAdditionalInfo>"],
239+
["pool_info", "BTreeMap<H256, PoolAdditionalInfo>"],
240+
["order_info", "BTreeMap<H256, OrderAdditionalInfo>"],
224241
],
225242
},
226243

@@ -248,7 +265,7 @@ def init_mintlayer_types():
248265
["input_utxos", "Vec<Option<TxOutput>>"],
249266
["destinations", "Vec<Option<Destination>>"],
250267
["htlc_secrets", "Vec<Option<[u8; 32]>>"],
251-
["additional_infos", "BTreeMap<InfoId, TxAdditionalInfo>"],
268+
["additional_infos", "TxAdditionalInfo"],
252269
]
253270
},
254271

test/functional/wallet_htlc_refund.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ async def async_test(self):
187187
'input_utxos': alice_htlc_outputs,
188188
'destinations': [refund_dest_obj, alice_htlc_change_dest],
189189
'htlc_secrets': [None, None],
190-
'additional_infos': []
190+
'additional_infos': {'token_info': [], 'pool_info': [], 'order_info': []}
191191
}
192192
alice_refund_tx_hex = scalecodec.base.RuntimeConfiguration().create_scale_object('PartiallySignedTransaction').encode(alice_refund_ptx).to_hex()[2:]
193193

@@ -216,7 +216,7 @@ async def async_test(self):
216216
'input_utxos': bob_htlc_outputs,
217217
'destinations': [refund_dest_obj, bob_htlc_change_dest],
218218
'htlc_secrets': [None, None],
219-
'additional_infos': []
219+
'additional_infos': {'token_info': [], 'pool_info': [], 'order_info': []}
220220
}
221221
bob_refund_tx_hex = scalecodec.base.RuntimeConfiguration().create_scale_object('PartiallySignedTransaction').encode(bob_refund_ptx).to_hex()[2:]
222222

wallet/src/account/mod.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,7 @@ use utils::ensure;
3838
pub use utxo_selector::UtxoSelectorError;
3939
use wallet_types::account_id::AccountPrefixedId;
4040
use wallet_types::account_info::{StandaloneAddressDetails, StandaloneAddresses};
41-
use wallet_types::partially_signed_transaction::{
42-
InfoId, PartiallySignedTransaction, TxAdditionalInfo,
43-
};
41+
use wallet_types::partially_signed_transaction::{PartiallySignedTransaction, TxAdditionalInfo};
4442
use wallet_types::with_locked::WithLocked;
4543

4644
use crate::account::utxo_selector::{select_coins, OutputGroup};
@@ -634,7 +632,7 @@ impl<K: AccountKeyChains> Account<K> {
634632
change_addresses: BTreeMap<Currency, Address<Destination>>,
635633
median_time: BlockTimestamp,
636634
fee_rate: CurrentFeeRate,
637-
additional_utxo_infos: BTreeMap<InfoId, TxAdditionalInfo>,
635+
additional_info: TxAdditionalInfo,
638636
) -> WalletResult<(PartiallySignedTransaction, BTreeMap<Currency, Amount>)> {
639637
let mut request = self.select_inputs_for_send_request(
640638
request,
@@ -648,7 +646,7 @@ impl<K: AccountKeyChains> Account<K> {
648646
)?;
649647

650648
let fees = request.get_fees();
651-
let ptx = request.into_partially_signed_tx(additional_utxo_infos)?;
649+
let ptx = request.into_partially_signed_tx(additional_info)?;
652650

653651
Ok((ptx, fees))
654652
}

wallet/src/send_request/mod.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,7 @@ use common::primitives::{Amount, BlockHeight};
2929
use crypto::vrf::VRFPublicKey;
3030
use utils::ensure;
3131
use wallet_types::currency::Currency;
32-
use wallet_types::partially_signed_transaction::{
33-
InfoId, PartiallySignedTransaction, TxAdditionalInfo,
34-
};
32+
use wallet_types::partially_signed_transaction::{PartiallySignedTransaction, TxAdditionalInfo};
3533

3634
use crate::account::PoolData;
3735
use crate::destination_getters::{get_tx_output_destination, HtlcSpendingCondition};
@@ -292,7 +290,7 @@ impl SendRequest {
292290

293291
pub fn into_partially_signed_tx(
294292
self,
295-
additional_info: BTreeMap<InfoId, TxAdditionalInfo>,
293+
additional_info: TxAdditionalInfo,
296294
) -> WalletResult<PartiallySignedTransaction> {
297295
let num_inputs = self.inputs.len();
298296
let destinations = self.destinations.into_iter().map(Some).collect();

wallet/src/signer/software_signer/tests.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
// See the License for the specific language governing permissions and
1414
// limitations under the License.
1515

16-
use std::collections::BTreeMap;
1716
use std::ops::{Add, Div, Mul, Sub};
1817

1918
use super::*;
@@ -42,6 +41,7 @@ use serialization::Encode;
4241
use test_utils::random::{make_seedable_rng, Seed};
4342
use wallet_storage::{DefaultBackend, Store, Transactional};
4443
use wallet_types::account_info::DEFAULT_ACCOUNT_INDEX;
44+
use wallet_types::partially_signed_transaction::TxAdditionalInfo;
4545
use wallet_types::seed_phrase::StoreSeedPhrase;
4646
use wallet_types::KeyPurpose::{Change, ReceiveFunds};
4747

@@ -436,7 +436,7 @@ fn sign_transaction(#[case] seed: Seed) {
436436
.with_inputs_and_destinations(acc_inputs.into_iter().zip(acc_dests.clone()))
437437
.with_outputs(outputs);
438438
let destinations = req.destinations().to_vec();
439-
let additional_info = BTreeMap::new();
439+
let additional_info = TxAdditionalInfo::new();
440440
let ptx = req.into_partially_signed_tx(additional_info).unwrap();
441441

442442
let mut signer = SoftwareSigner::new(chain_config.clone(), DEFAULT_ACCOUNT_INDEX);
@@ -687,7 +687,7 @@ fn fixed_signatures() {
687687
.with_inputs_and_destinations(acc_inputs.into_iter().zip(acc_dests.clone()))
688688
.with_outputs(outputs);
689689
let destinations = req.destinations().to_vec();
690-
let additional_info = BTreeMap::new();
690+
let additional_info = TxAdditionalInfo::new();
691691
let ptx = req.into_partially_signed_tx(additional_info).unwrap();
692692

693693
let utxos_ref = utxos

0 commit comments

Comments
 (0)