difftreelog
path: Add check for address length.
in: master
2 files changed
pallets/common/src/eth.rsdiffbeforeafterboth161617//! The module contains a number of functions for converting and checking ethereum identifiers.17//! The module contains a number of functions for converting and checking ethereum identifiers.181819use evm_coder::{types::*};19use evm_coder::{types::uint256, execution::Result};20pub use pallet_evm::account::CrossAccountId;20pub use pallet_evm::account::CrossAccountId;21use sp_core::H160;21use sp_core::H160;22use up_data_structs::CollectionId;22use up_data_structs::CollectionId;53}53}545455/// Convert `CrossAccountId` to `uint256`.55/// Convert `CrossAccountId` to `uint256`.56pub fn convert_cross_account_to_eth_uint256<T: Config>(from: &T::CrossAccountId) -> uint25656pub fn convert_cross_account_to_eth_uint256<T: Config>(from: &T::CrossAccountId) -> Result<uint256>57where57where58 T::AccountId: AsRef<[u8]>,58 T::AccountId: AsRef<[u8]>,59{59{62 uint256::from_big_endian(slice)62 uint256::from_big_endian(slice)63}63}6465/// Converts Substrate address to CrossAccountId66pub fn convert_substrate_address_to_cross_account_id<T: Config>(67 address: uint256,68) -> T::CrossAccountId69where70 T::AccountId: From<[u8; 32]>,71{72 let mut address_arr: [u8; 32] = Default::default();73 address.to_big_endian(&mut address_arr);74 let account_id = T::AccountId::from(address_arr);75 T::CrossAccountId::from_sub(account_id)76}7764pallets/evm-contract-helpers/src/eth.rsdiffbeforeafterboth--- a/pallets/evm-contract-helpers/src/eth.rs
+++ b/pallets/evm-contract-helpers/src/eth.rs
@@ -110,7 +110,7 @@
fn get_sponsor(&self, contract_address: address) -> Result<(address, uint256)> {
let sponsor =
Pallet::<T>::get_sponsor(contract_address).ok_or("Contract has no sponsor")?;
- let sponsor_sub = pallet_common::eth::convert_cross_account_to_eth_uint256::<T>(&sponsor);
+ let sponsor_sub = pallet_common::eth::convert_cross_account_to_eth_uint256::<T>(&sponsor)?;
Ok((*sponsor.as_eth(), sponsor_sub))
}