Skip to content

Commit

Permalink
fix some planner bug (#1611)
Browse files Browse the repository at this point in the history
* fix some planner bug

* lint

* disable max sends

* linting

---------

Co-authored-by: Tal Derei <talderei99@gmail.com>
  • Loading branch information
Valentine1898 and TalDerei authored Aug 1, 2024
1 parent b58cc64 commit a0c9988
Showing 1 changed file with 31 additions and 34 deletions.
65 changes: 31 additions & 34 deletions packages/wasm/crate/src/planner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ pub async fn plan_transaction_inner<Db: Database>(
source_address_index.randomizer = [0u8; 12];

// Compute the change address for this transaction.
let (mut change_address, _) = fvk
let (change_address, _) = fvk
.incoming()
.payment_address(source_address_index.account.into());

Expand Down Expand Up @@ -481,39 +481,36 @@ pub async fn plan_transaction_inner<Db: Database>(
));
}

for tpr::Spend { value, address } in request.spends {
let value = value.ok_or_else(|| anyhow!("missing value in spend"))?;
let address = address.ok_or_else(|| anyhow!("missing address in spend"))?;
let asset_id = value
.asset_id
.ok_or_else(|| anyhow!("missing asset_id in spend"))?;

// Find all the notes of this asset in the source account.
let records = storage
.get_notes(NotesRequest {
include_spent: false,
asset_id: Some(asset_id.clone()),
address_index: Some(source_address_index.into()),
amount_to_spend: None,
})
.await?;
notes_by_asset_id.insert(
asset_id.try_into()?,
prioritize_and_filter_spendable_notes(records.clone()),
);

for record in records {
// filter zero-valued notes from SNR set
if record.clone().note.amount() != 0u64.into() {
let spend: SpendPlan =
SpendPlan::new(&mut OsRng, record.clone().note, record.clone().position);
actions_list.push(spend);
}
}

// Change address is overwritten to the recipient.
change_address = address.try_into()?;
}
// for tpr::Spend { value, address } in request.spends {
// let value = value.ok_or_else(|| anyhow!("missing value in spend"))?;
// let address = address.ok_or_else(|| anyhow!("missing address in spend"))?;
// let asset_id = value
// .asset_id
// .ok_or_else(|| anyhow!("missing asset_id in spend"))?;

// // Find all the notes of this asset in the source account.
// let records = storage
// .get_notes(NotesRequest {
// include_spent: false,
// asset_id: Some(asset_id.clone()),
// address_index: Some(source_address_index.into()),
// amount_to_spend: None,
// })
// .await?;
// notes_by_asset_id.insert(
// asset_id.try_into()?,
// prioritize_and_filter_spendable_notes(records.clone()),
// );

// for record in records {
// // filter zero-valued notes from SNR set
// if record.clone().note.amount() != 0u64.into() {
// let spend: SpendPlan =
// SpendPlan::new(&mut OsRng, record.clone().note, record.clone().position);
// actions_list.push(spend);
// }
// }
// }

for tpr::DelegatorVote {
proposal,
Expand Down

0 comments on commit a0c9988

Please sign in to comment.