Skip to content

Commit

Permalink
Multitoken vp ensures internal addresses verify the transaction
Browse files Browse the repository at this point in the history
  • Loading branch information
grarco committed Sep 10, 2024
1 parent 8bebfc9 commit 08425fe
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions crates/trans_token/src/vp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,16 @@ where
let mut dec_mints: HashMap<Address, Amount> = HashMap::new();
for key in keys_changed {
if let Some([token, owner]) = is_any_token_balance_key(key) {
if owner.is_internal() && !verifiers.contains(owner) {
// Internal addresses need to always verify the transaction
// (credit and debit)
return Err(Error::new_alloc(format!(
"The vp of debited internal address {} has not been \
triggered",
owner
)));
}

let pre: Amount = self.ctx.read_pre(key)?.unwrap_or_default();
let post: Amount = self.ctx.read_post(key)?.unwrap_or_default();
match post.checked_sub(pre) {
Expand Down

0 comments on commit 08425fe

Please sign in to comment.