Skip to content

Commit

Permalink
Some fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
thibault-martinez committed Jan 12, 2024
1 parent 31f0d70 commit 696ff5d
Show file tree
Hide file tree
Showing 12 changed files with 232 additions and 131 deletions.
10 changes: 2 additions & 8 deletions sdk/src/client/api/block_builder/input_selection/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ impl InputSelection {
available_inputs: impl Into<Vec<InputSigningData>>,
outputs: impl Into<Vec<Output>>,
addresses: impl IntoIterator<Item = Address>,
slot_index: impl Into<SlotIndex>,
protocol_parameters: ProtocolParameters,
) -> Self {
let available_inputs = available_inputs.into();
Expand Down Expand Up @@ -189,9 +190,8 @@ impl InputSelection {
burn: None,
remainder_address: None,
protocol_parameters,
// TODO may want to make this mandatory at some point
// Should be set from a commitment context input
slot_index: SlotIndex::from(0),
slot_index: slot_index.into(),
requirements: Vec::new(),
automatically_transitioned: HashSet::new(),
mana_allotments: 0,
Expand Down Expand Up @@ -222,12 +222,6 @@ impl InputSelection {
self
}

/// Sets the slot index of an [`InputSelection`].
pub fn with_slot_index(mut self, slot_index: impl Into<SlotIndex>) -> Self {
self.slot_index = slot_index.into();
self
}

/// Sets the mana allotments sum of an [`InputSelection`].
pub fn with_mana_allotments<'a>(mut self, mana_allotments: impl Iterator<Item = &'a ManaAllotment>) -> Self {
self.mana_allotments = mana_allotments.map(ManaAllotment::mana).sum();
Expand Down
12 changes: 6 additions & 6 deletions sdk/src/wallet/operations/transaction/input_selection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,11 @@ where
available_outputs_signing_data,
outputs,
Some(wallet_data.address.clone().into_inner()),
slot_index,
protocol_parameters.clone(),
)
.with_required_inputs(custom_inputs)
.with_forbidden_inputs(forbidden_inputs)
.with_slot_index(slot_index);
.with_forbidden_inputs(forbidden_inputs);

if let Some(address) = remainder_address {
input_selection = input_selection.with_remainder_address(address);
Expand Down Expand Up @@ -134,11 +134,11 @@ where
available_outputs_signing_data,
outputs,
Some(wallet_data.address.clone().into_inner()),
slot_index,
protocol_parameters.clone(),
)
.with_required_inputs(mandatory_inputs)
.with_forbidden_inputs(forbidden_inputs)
.with_slot_index(slot_index);
.with_forbidden_inputs(forbidden_inputs);

if let Some(address) = remainder_address {
input_selection = input_selection.with_remainder_address(address);
Expand Down Expand Up @@ -171,10 +171,10 @@ where
available_outputs_signing_data,
outputs,
Some(wallet_data.address.clone().into_inner()),
slot_index,
protocol_parameters.clone(),
)
.with_forbidden_inputs(forbidden_inputs)
.with_slot_index(slot_index);
.with_forbidden_inputs(forbidden_inputs);

if let Some(address) = remainder_address {
input_selection = input_selection.with_remainder_address(address);
Expand Down
Loading

0 comments on commit 696ff5d

Please sign in to comment.