feat: add AccountBalanceChange proto message (#137)

This commit is contained in:
Louise Poole
2025-01-23 11:00:12 +02:00
committed by GitHub
parent 53f764972d
commit 28dd2fc858
3 changed files with 102 additions and 79 deletions

View File

@@ -467,6 +467,7 @@ pub struct InterimContractChange {
code: Vec<u8>,
slots: HashMap<Vec<u8>, SlotValue>,
change: ChangeType,
token_balances: HashMap<Vec<u8>, Vec<u8>>,
}
impl InterimContractChange {
@@ -477,6 +478,7 @@ impl InterimContractChange {
code: vec![],
slots: Default::default(),
change: if creation { ChangeType::Creation } else { ChangeType::Update },
token_balances: Default::default(),
}
}
@@ -530,6 +532,11 @@ impl From<InterimContractChange> for Option<ContractChange> {
.map(|(slot, value)| ContractSlot { slot, value: value.new_value })
.collect(),
change: value.change.into(),
token_balances: value
.token_balances
.into_iter()
.map(|(k, v)| AccountBalanceChange { token: k, balance: v })
.collect(),
};
if contract_change.is_empty() {
None