Skip to content

Commit

Permalink
Return is a BasicOutputBuilder
Browse files Browse the repository at this point in the history
  • Loading branch information
thibault-martinez committed Nov 14, 2023
1 parent a6da4ce commit 7e5a5de
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
4 changes: 2 additions & 2 deletions sdk/src/types/block/output/basic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -166,10 +166,10 @@ impl BasicOutputBuilder {
// Check whether we already have enough funds to cover it
if amount < minimum_amount {
// Get the projected minimum amount of the return output
let return_min_amount = Self::new_with_amount(0)
let return_min_amount = Self::new_with_minimum_amount(params)
.add_unlock_condition(AddressUnlockCondition::new(return_address.clone()))
.finish()?
.minimum_amount(params);
.amount();
// Add a temporary storage deposit unlock condition so the new storage requirement can be calculated
self = self.add_unlock_condition(StorageDepositReturnUnlockCondition::new(
return_address.clone(),
Expand Down
14 changes: 9 additions & 5 deletions sdk/src/types/block/output/nft.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ use crate::types::block::{
verify_allowed_unlock_conditions, AddressUnlockCondition, StorageDepositReturnUnlockCondition,
UnlockCondition, UnlockConditionFlags, UnlockConditions,
},
verify_output_amount_packable, ChainId, MinimumOutputAmount, NativeToken, NativeTokens, Output,
OutputBuilderAmount, OutputId, StateTransitionError, StateTransitionVerifier, StorageScore,
verify_output_amount_packable, BasicOutputBuilder, ChainId, MinimumOutputAmount, NativeToken, NativeTokens,
Output, OutputBuilderAmount, OutputId, StateTransitionError, StateTransitionVerifier, StorageScore,
StorageScoreParameters,
},
payload::signed_transaction::TransactionCapabilityFlag,
Expand All @@ -46,7 +46,11 @@ impl From<&OutputId> for NftId {
impl NftId {
///
pub fn or_from_output_id(self, output_id: &OutputId) -> Self {
if self.is_null() { Self::from(output_id) } else { self }
if self.is_null() {
Self::from(output_id)
} else {
self
}
}
}

Expand Down Expand Up @@ -236,10 +240,10 @@ impl NftOutputBuilder {
// Check whether we already have enough funds to cover it
if amount < minimum_amount {
// Get the projected minimum amount of the return output
let return_min_amount = Self::new_with_amount(0, self.nft_id)
let return_min_amount = BasicOutputBuilder::new_with_minimum_amount(params)
.add_unlock_condition(AddressUnlockCondition::new(return_address.clone()))
.finish()?
.minimum_amount(params);
.amount();
// Add a temporary storage deposit unlock condition so the new storage requirement can be calculated
self = self.add_unlock_condition(StorageDepositReturnUnlockCondition::new(
return_address.clone(),
Expand Down

0 comments on commit 7e5a5de

Please sign in to comment.