I have the following case:
let contract = Invoice {
origin: from.clone(),
to: to.clone(),
amount,
status: false,
id: 17,
msg: msg.clone(),
};
let mut invoice_vec: Vec<Invoice<T::AccountId, T::AccountId, BalanceOf<T>>> = Vec::new();
invoice_vec.push(contract);
// Save in storage the sender and the invoices
<InvoiceSender<T>>::insert(from.clone(), &invoice_vec);
InvoiceSender::<T>::mutate(&from, |invoice| {
invoice_vec.iter_mut().filter(|i| i.id == 17).for_each(|i| {
i.status = true;
})
});
As you can see, I have created an Invoice object, I have put it inside an array and then I have stored it.
The issue happens when I try to mutate one of the contracts.
During debugging I can see that the following line i.status = true;
is being executed, but the status is remains false, so the state was not mutated.