Skip to content

Commit

Permalink
routers: Use correct formatting for H160 addresses
Browse files Browse the repository at this point in the history
  • Loading branch information
cdamian committed Sep 12, 2023
1 parent 4fa5082 commit 77eefda
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions pallets/liquidity-pools-gateway/routers/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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" }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down Expand Up @@ -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:
/// <https://github.com/axelarnetwork/axelar-cgp-solidity/blob/v4.3.2/contracts/AxelarGateway.sol#L78>
Expand Down Expand Up @@ -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")?;
Expand Down

0 comments on commit 77eefda

Please sign in to comment.