Skip to content

Commit

Permalink
Merge branch 'tiago/fix-ethbridge-vp' (#1855)
Browse files Browse the repository at this point in the history
* origin/tiago/fix-ethbridge-vp:
  Changelog for #1855
  Allow an arbitrary nr of accounts to transfer to the Eth bridge addr
  Refactor the Ethereum bridge native VP
  Introduce `has_eth_addr_segment()` storage key predicate
  • Loading branch information
Fraccaman committed Sep 6, 2023
2 parents 6761d6b + f63d364 commit 230114c
Show file tree
Hide file tree
Showing 3 changed files with 91 additions and 178 deletions.
2 changes: 2 additions & 0 deletions .changelog/unreleased/bug-fixes/1855-fix-ethbridge-vp.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- Fix the Ethereum Bridge VP
([\#1855](https://github.com/anoma/namada/pull/1855))
11 changes: 10 additions & 1 deletion core/src/ledger/eth_bridge/storage/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use super::ADDRESS;
use crate::ledger::parameters::storage::*;
use crate::ledger::parameters::ADDRESS as PARAM_ADDRESS;
use crate::types::address::Address;
use crate::types::storage::{Key, KeySeg};
use crate::types::storage::{DbKeySeg, Key, KeySeg};
use crate::types::token::balance_key;

/// Key prefix for the storage subspace
Expand All @@ -26,6 +26,15 @@ pub fn escrow_key(nam_addr: &Address) -> Key {
balance_key(nam_addr, &ADDRESS)
}

/// Check if the given `key` contains an Ethereum
/// bridge address segment.
#[inline]
pub fn has_eth_addr_segment(key: &Key) -> bool {
key.segments
.iter()
.any(|s| matches!(s, DbKeySeg::AddressSeg(ADDRESS)))
}

/// Returns whether a key belongs to this account or not
pub fn is_eth_bridge_key(nam_addr: &Address, key: &Key) -> bool {
key == &escrow_key(nam_addr)
Expand Down
Loading

0 comments on commit 230114c

Please sign in to comment.