diff --git a/crates/sage-wallet/src/wallet/offer/lock_assets.rs b/crates/sage-wallet/src/wallet/offer/lock_assets.rs index 9a30ca6..892b7ed 100644 --- a/crates/sage-wallet/src/wallet/offer/lock_assets.rs +++ b/crates/sage-wallet/src/wallet/offer/lock_assets.rs @@ -135,9 +135,10 @@ impl Wallet { outputs.push(royalty_coin); } - // TODO: This is a hack to make the puzzle non-conflicting, maybe there's a better amount or method - let non_conflicting_amount = - outputs.iter().map(|output| output.amount).sum::() + 1; + let remaining_amount = remaining_royalties + .iter() + .map(|royalty| royalty.amount) + .sum::(); if !remaining_royalties.is_empty() { notarized_payments.push(NotarizedPayment { @@ -145,7 +146,7 @@ impl Wallet { nonce: Bytes32::default(), payments: vec![Payment::new( SETTLEMENT_PAYMENTS_PUZZLE_HASH.into(), - non_conflicting_amount, + remaining_amount, )], }); } @@ -161,7 +162,7 @@ impl Wallet { parent_royalty_coin = Coin::new( parent_royalty_coin.coin_id(), SETTLEMENT_PAYMENTS_PUZZLE_HASH.into(), - non_conflicting_amount, + remaining_amount, ); } } @@ -257,9 +258,10 @@ impl Wallet { outputs.push(royalty_cat.coin); } - // TODO: This is a hack to make the puzzle non-conflicting, maybe there's a better amount or method - let non_conflicting_amount = - outputs.iter().map(|output| output.amount).sum::() + 1; + let remaining_amount = remaining_royalties + .iter() + .map(|royalty| royalty.amount) + .sum::(); if !remaining_royalties.is_empty() { notarized_payments.push(NotarizedPayment { @@ -267,7 +269,7 @@ impl Wallet { nonce: Bytes32::default(), payments: vec![Payment::new( SETTLEMENT_PAYMENTS_PUZZLE_HASH.into(), - non_conflicting_amount, + remaining_amount, )], }); } @@ -277,10 +279,8 @@ impl Wallet { cat_spends.push(CatSpend::new(parent_royalty_cat, inner_spend)); - parent_royalty_cat = parent_royalty_cat.wrapped_child( - SETTLEMENT_PAYMENTS_PUZZLE_HASH.into(), - non_conflicting_amount, - ); + parent_royalty_cat = parent_royalty_cat + .wrapped_child(SETTLEMENT_PAYMENTS_PUZZLE_HASH.into(), remaining_amount); } Cat::spend_all(ctx, &cat_spends)?; diff --git a/crates/sage-wallet/src/wallet/offer/make_offer.rs b/crates/sage-wallet/src/wallet/offer/make_offer.rs index baa68f2..7fc2806 100644 --- a/crates/sage-wallet/src/wallet/offer/make_offer.rs +++ b/crates/sage-wallet/src/wallet/offer/make_offer.rs @@ -155,24 +155,10 @@ impl Wallet { .count(), )?; - let taker_royalties = calculate_royalties( - &taker_amounts, - &maker_coins - .nfts - .values() - .map(|nft| NftRoyaltyInfo { - launcher_id: nft.info.launcher_id, - royalty_puzzle_hash: nft.info.royalty_puzzle_hash, - royalty_ten_thousandths: nft.info.royalty_ten_thousandths, - }) - .collect::>(), - )?; - let (assertions, builder) = builder.finish(); let mut extra_conditions = Conditions::new() .extend(assertions) - .extend(maker_royalties.assertions()) - .extend(taker_royalties.assertions()); + .extend(maker_royalties.assertions()); if let Some(expires_at) = expires_at { extra_conditions = extra_conditions.assert_before_seconds_absolute(expires_at); diff --git a/crates/sage-wallet/src/wallet/offer/take_offer.rs b/crates/sage-wallet/src/wallet/offer/take_offer.rs index 483d317..140c154 100644 --- a/crates/sage-wallet/src/wallet/offer/take_offer.rs +++ b/crates/sage-wallet/src/wallet/offer/take_offer.rs @@ -32,19 +32,6 @@ impl Wallet { let requested_payments = parse_offer_payments(&mut ctx, &mut builder)?; let taker_amounts = requested_payments.amounts(); - let maker_royalties = calculate_royalties( - &maker_amounts, - &requested_payments - .nfts - .values() - .map(|(nft, _)| NftRoyaltyInfo { - launcher_id: nft.launcher_id, - royalty_puzzle_hash: nft.royalty_puzzle_hash, - royalty_ten_thousandths: nft.royalty_ten_thousandths, - }) - .collect::>(), - )?; - let taker_royalties = calculate_royalties( &taker_amounts, &locked_coins @@ -86,8 +73,7 @@ impl Wallet { let extra_conditions = Conditions::new() .extend(assertions) - .extend(taker_royalties.assertions()) - .extend(maker_royalties.assertions()); + .extend(taker_royalties.assertions()); // Spend the assets. let payment_coins = self