Skip to content

Commit

Permalink
routers: Drop LP contract call from Axelar message
Browse files Browse the repository at this point in the history
  • Loading branch information
cdamian committed Sep 12, 2023
1 parent f5a2fb9 commit f83375a
Showing 1 changed file with 7 additions and 35 deletions.
42 changes: 7 additions & 35 deletions pallets/liquidity-pools-gateway/routers/src/routers/axelar_evm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ use sp_std::{collections::btree_map::BTreeMap, marker::PhantomData, vec, vec::Ve
use crate::{
AccountIdOf, EVMRouter, MessageOf, AXELAR_DESTINATION_CHAIN_PARAM,
AXELAR_DESTINATION_CONTRACT_ADDRESS_PARAM, AXELAR_FUNCTION_NAME, AXELAR_PAYLOAD_PARAM,
FUNCTION_NAME, MAX_AXELAR_EVM_CHAIN_SIZE, MESSAGE_PARAM,
MAX_AXELAR_EVM_CHAIN_SIZE,
};

/// The router used for executing the LiquidityPools contract via Axelar.
Expand Down Expand Up @@ -74,8 +74,8 @@ where
}

/// Encodes the provided message into the format required for submitting it
/// to the Axelar contract which in turn submits it to the LiquidityPools
/// contract.
/// to the Axelar contract which in turn calls the LiquidityPools
/// contract with the serialized LP message a payload.
///
/// Axelar contract call:
/// <https://github.com/axelarnetwork/axelar-cgp-solidity/blob/v4.3.2/contracts/AxelarGateway.sol#L78>
Expand All @@ -87,36 +87,6 @@ pub(crate) fn get_axelar_encoded_msg(
target_chain: Vec<u8>,
target_contract: H160,
) -> Result<Vec<u8>, &'static str> {
let target_chain_string =
String::from_utf8(target_chain).map_err(|_| "target chain conversion error")?;

#[allow(deprecated)]
let encoded_liquidity_pools_contract = Contract {
constructor: None,
functions: BTreeMap::<String, Vec<Function>>::from([(
FUNCTION_NAME.to_string(),
vec![Function {
name: FUNCTION_NAME.into(),
inputs: vec![Param {
name: MESSAGE_PARAM.into(),
kind: ParamType::Bytes,
internal_type: None,
}],
outputs: vec![],
constant: false,
state_mutability: Default::default(),
}],
)]),
events: Default::default(),
errors: Default::default(),
receive: false,
fallback: false,
}
.function(FUNCTION_NAME)
.map_err(|_| "cannot retrieve LiquidityPools contract function")?
.encode_input(&[Token::Bytes(serialized_msg)])
.map_err(|_| "cannot encode input for LiquidityPools contract function")?;

#[allow(deprecated)]
let encoded_axelar_contract = Contract {
constructor: None,
Expand Down Expand Up @@ -154,9 +124,11 @@ pub(crate) fn get_axelar_encoded_msg(
.function(AXELAR_FUNCTION_NAME)
.map_err(|_| "cannot retrieve Axelar contract function")?
.encode_input(&[
Token::String(target_chain_string),
Token::String(
String::from_utf8(target_chain).map_err(|_| "target chain conversion error")?,
),
Token::String(target_contract.to_string()),
Token::Bytes(encoded_liquidity_pools_contract),
Token::Bytes(serialized_msg),
])
.map_err(|_| "cannot encode input for Axelar contract function")?;

Expand Down

0 comments on commit f83375a

Please sign in to comment.