Skip to content

Commit

Permalink
properly handle memos
Browse files Browse the repository at this point in the history
  • Loading branch information
TalDerei committed Apr 2, 2024
1 parent 452d960 commit 8662b02
Showing 1 changed file with 1 addition and 20 deletions.
21 changes: 1 addition & 20 deletions crates/view/src/planner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,19 +92,12 @@ impl<R: RngCore + CryptoRng> Planner<R> {

fn calculate_balance(&self) -> Balance {
let mut balance = Balance::zero();
println!("self.actions inside calculate_balance: {:?}", self.actions);
for action in &self.actions {
balance += action.balance();
}
println!("balance inside calculate balance: {:?}", balance);
println!(
"self.actions inside calculate_balance: {:?}",
self.change_outputs.values()
);
for action in self.change_outputs.values() {
balance += action.balance();
}
println!("balance inside calculate balance: {:?}", balance);
balance
}

Expand Down Expand Up @@ -576,8 +569,6 @@ impl<R: RngCore + CryptoRng> Planner<R> {
let fmd_params = view.fmd_parameters().await?;

// Caller has already processed all the user-supplied intents into complete action plans.
println!("self.plan.actions.clone(): {:?}", self.plan.actions.clone());

self.actions = self.plan.actions.clone();

let change_address = view.address_by_index(source).await?;
Expand Down Expand Up @@ -730,11 +721,9 @@ impl<R: RngCore + CryptoRng> Planner<R> {
fee: self.fee_estimate(&self.gas_prices, &self.fee_tier),
},
detection_data: None,
memo: None,
memo: self.plan.memo.clone(),
};

println!("action plans: {:?}", self.plan.actions);

// If there are outputs, we check that a memo has been added. If not, we add a blank memo.
if self.plan.num_outputs() > 0 && self.plan.memo.is_none() {
self.memo(MemoPlaintext::blank_memo(change_address.clone()))
Expand All @@ -747,14 +736,6 @@ impl<R: RngCore + CryptoRng> Planner<R> {
self.plan
.populate_detection_data(&mut OsRng, fmd_params.precision_bits.into());

println!("!!!!!!!!!!!!!!!!!!!!!!!!");
println!(
"calculate_balance: {:?}",
self.calculate_balance().is_zero()
);
println!("balance inner: {:?}", self.balance);
println!("!!!!!!!!!!!!!!!!!!!!!!!!");

// All actions have now been added, so check to make sure that you don't build and submit an
// empty transaction.
if self.actions.is_empty() {
Expand Down

0 comments on commit 8662b02

Please sign in to comment.