Skip to content

Commit

Permalink
Support for bidirectional routers (#1958)
Browse files Browse the repository at this point in the history
* base implementation

* correct router_id representation

* router support

* remove axelar receiver

* add mock for axelar-router

* correct sender account

* fixes from reviews

* add account code checker

* runtime changes to compile, part 1

* required changes for gateway (#1959)

* centrifuge-runtime compiling

* development and altair compiling

* trying to compile it

* compiling with no-std

* fix restricted transfers

* remove unused mocks

* cargo fmt & taplo fmt

* fix queue tests

* added IT router tests

* add UTs for axelar-router

* remove old crates

* fix lp tests

* fix comments
  • Loading branch information
lemunozm authored Aug 14, 2024
1 parent 3def5e9 commit 0d29d17
Show file tree
Hide file tree
Showing 45 changed files with 1,327 additions and 1,970 deletions.
90 changes: 28 additions & 62 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 2 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ members = [
"libs/utils",
"pallets/anchors",
"pallets/anchors-v2",
"pallets/axelar-router",
"pallets/bridge",
"pallets/block-rewards",
"pallets/collator-allowlist",
Expand All @@ -21,8 +22,6 @@ members = [
"pallets/keystore",
"pallets/liquidity-pools",
"pallets/liquidity-pools-gateway",
"pallets/liquidity-pools-gateway/axelar-gateway-precompile",
"pallets/liquidity-pools-gateway/routers",
"pallets/liquidity-pools-gateway/queue",
"pallets/liquidity-rewards",
"pallets/loans",
Expand Down Expand Up @@ -221,10 +220,9 @@ substrate-wasm-builder = { git = "https://github.com/paritytech/polkadot-sdk", b
substrate-build-script-utils = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.7.2" }

# Centrifuge pallets
axelar-gateway-precompile = { path = "pallets/liquidity-pools-gateway/axelar-gateway-precompile", default-features = false }
liquidity-pools-gateway-routers = { path = "pallets/liquidity-pools-gateway/routers", default-features = false }
pallet-anchors = { path = "pallets/anchors", default-features = false }
pallet-anchors-v2 = { path = "pallets/anchors-v2", default-features = false }
pallet-axelar-router = { path = "pallets/axelar-router", default-features = false }
pallet-block-rewards = { path = "pallets/block-rewards", default-features = false }
pallet-bridge = { path = "pallets/bridge", default-features = false }
pallet-collator-allowlist = { path = "pallets/collator-allowlist", default-features = false }
Expand Down
37 changes: 37 additions & 0 deletions libs/mocks/src/ethereum_transactor.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#[frame_support::pallet(dev_mode)]
pub mod pallet {
use cfg_traits::ethereum::EthereumTransactor;
use frame_support::pallet_prelude::*;
use mock_builder::{execute_call, register_call};
use sp_core::{H160, U256};

#[pallet::config]
pub trait Config: frame_system::Config {}

#[pallet::pallet]
pub struct Pallet<T>(_);

#[pallet::storage]
type CallIds<T: Config> = StorageMap<_, _, String, mock_builder::CallId>;

impl<T: Config> Pallet<T> {
pub fn mock_call(
func: impl Fn(H160, H160, &[u8], U256, U256, U256) -> DispatchResultWithPostInfo + 'static,
) {
register_call!(move |(a, b, c, d, e, f)| func(a, b, c, d, e, f));
}
}

impl<T: Config> EthereumTransactor for Pallet<T> {
fn call(
a: H160,
b: H160,
c: &[u8],
d: U256,
e: U256,
f: U256,
) -> DispatchResultWithPostInfo {
execute_call!((a, b, c, d, e, f))
}
}
}
4 changes: 2 additions & 2 deletions libs/mocks/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,20 @@ pub mod change_guard;
pub mod converter;
pub mod currency_conversion;
pub mod data;
pub mod ethereum_transactor;
pub mod fees;
pub mod foreign_investment;
pub mod foreign_investment_hooks;
pub mod investment;
pub mod liquidity_pools;
pub mod liquidity_pools_gateway;
pub mod liquidity_pools_gateway_queue;
pub mod liquidity_pools_gateway_routers;
pub mod pay_fee;
pub mod permissions;
pub mod pools;
pub mod pre_conditions;
pub mod rewards;
pub mod router_message;
pub mod status_notification;
pub mod time;
pub mod token_swaps;
Expand All @@ -30,7 +31,6 @@ pub use investment::pallet as pallet_mock_investment;
pub use liquidity_pools::pallet as pallet_mock_liquidity_pools;
pub use liquidity_pools_gateway::pallet as pallet_mock_liquidity_pools_gateway;
pub use liquidity_pools_gateway_queue::pallet as pallet_mock_liquidity_pools_gateway_queue;
pub use liquidity_pools_gateway_routers::{pallet as pallet_mock_routers, RouterMock};
pub use pay_fee::pallet as pallet_mock_pay_fee;
pub use permissions::pallet as pallet_mock_permissions;
pub use pools::pallet as pallet_mock_pools;
Expand Down
Loading

0 comments on commit 0d29d17

Please sign in to comment.