From 77eefdad4505f7d5e4d0c398a44613c69c71971e Mon Sep 17 00:00:00 2001 From: cdamian <17934949+cdamian@users.noreply.github.com> Date: Tue, 12 Sep 2023 15:09:52 +0300 Subject: [PATCH] routers: Use correct formatting for H160 addresses --- Cargo.lock | 1 + pallets/liquidity-pools-gateway/routers/Cargo.toml | 1 + .../routers/src/routers/axelar_evm.rs | 10 +++++++--- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index abc5d4d715..11a0d225e8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5805,6 +5805,7 @@ dependencies = [ "ethabi 16.0.0", "frame-support", "frame-system", + "hex", "lazy_static", "orml-traits", "pallet-balances", diff --git a/pallets/liquidity-pools-gateway/routers/Cargo.toml b/pallets/liquidity-pools-gateway/routers/Cargo.toml index d0ba8b5395..fae92ee6ea 100644 --- a/pallets/liquidity-pools-gateway/routers/Cargo.toml +++ b/pallets/liquidity-pools-gateway/routers/Cargo.toml @@ -11,6 +11,7 @@ version = "0.0.1" targets = ["x86_64-unknown-linux-gnu"] [dependencies] +hex = { version = "0.4.3", default-features = false } codec = { package = "parity-scale-codec", version = "3.0.0", features = ["derive"], default-features = false } frame-support = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.38" } frame-system = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.38" } diff --git a/pallets/liquidity-pools-gateway/routers/src/routers/axelar_evm.rs b/pallets/liquidity-pools-gateway/routers/src/routers/axelar_evm.rs index 20bb127f0c..6e7e7bfc9b 100644 --- a/pallets/liquidity-pools-gateway/routers/src/routers/axelar_evm.rs +++ b/pallets/liquidity-pools-gateway/routers/src/routers/axelar_evm.rs @@ -15,7 +15,7 @@ use ethabi::{Contract, Function, Param, ParamType, Token}; use frame_support::dispatch::{DispatchError, DispatchResult}; use frame_system::pallet_prelude::OriginFor; use scale_info::{ - prelude::string::{String, ToString}, + prelude::{format, string::String}, TypeInfo, }; use sp_core::{bounded::BoundedVec, ConstU32, H160}; @@ -75,7 +75,7 @@ where /// Encodes the provided message into the format required for submitting it /// to the Axelar contract which in turn calls the LiquidityPools -/// contract with the serialized LP message a payload. +/// contract with the serialized LP message as `payload`. /// /// Axelar contract call: /// @@ -127,7 +127,11 @@ pub(crate) fn get_axelar_encoded_msg( Token::String( String::from_utf8(target_chain).map_err(|_| "target chain conversion error")?, ), - Token::String(target_contract.to_string()), + // Ensure that the target contract is correctly converted to hex. + // + // The `to_string` method on the H160 is returning a string containing an ellipsis, such + // as: 0x1234…7890 + Token::String(format!("0x{}", hex::encode(target_contract.0))), Token::Bytes(serialized_msg), ]) .map_err(|_| "cannot encode input for Axelar contract function")?;