git.delta.rocks / unique-network / refs/commits / e50c7257388c

difftreelog

path: Return sponsor as a tuple.

Trubnikov Sergey2022-08-04parent: #14eb87c.patch.diff
in: master

3 files changed

modifiedcrates/evm-coder/src/abi.rsdiffbeforeafterboth
--- a/crates/evm-coder/src/abi.rs
+++ b/crates/evm-coder/src/abi.rs
@@ -425,7 +425,7 @@
 macro_rules! impl_tuples_abi_writer {
 	($($ident:ident)+) => {
 		#[allow(non_snake_case)]
-		impl<$($ident),+> AbiWrite for &($($ident,)+) 
+		impl<$($ident),+> AbiWrite for &($($ident,)+)
 		where
 			$($ident: AbiWrite,)+
 		{
modifiedpallets/common/src/eth.rsdiffbeforeafterboth
--- a/pallets/common/src/eth.rs
+++ b/pallets/common/src/eth.rs
@@ -52,6 +52,16 @@
 	address[0..16] == ETH_COLLECTION_PREFIX
 }
 
+/// Convert `CrossAccountId` to `uint256`.
+pub fn convert_cross_account_to_eth_uint256<T: Config>(from: &T::CrossAccountId) -> uint256
+where
+	T::AccountId: AsRef<[u8]>,
+{
+	use pallet_evm::account::CrossAccountId;
+	let slice = from.as_sub().as_ref();
+	uint256::from_big_endian(slice)
+}
+
 /// Converts Substrate address to CrossAccountId
 pub fn convert_substrate_address_to_cross_account_id<T: Config>(
 	address: uint256,
modifiedpallets/evm-contract-helpers/src/eth.rsdiffbeforeafterboth
17use core::marker::PhantomData;17use core::marker::PhantomData;
18use evm_coder::{18use evm_coder::{abi::AbiWriter, execution::Result, generate_stubgen, solidity_interface, types::*};
19 abi::AbiWriter,
20 execution::{Result, Error},
21 generate_stubgen, solidity_interface,
22 types::*,
23};
24use pallet_evm_coder_substrate::{SubstrateRecorder, WithRecorder, dispatch_to_evm};19use pallet_evm_coder_substrate::{SubstrateRecorder, WithRecorder, dispatch_to_evm};
25use pallet_evm::{20use pallet_evm::{
4742
48#[solidity_interface(name = "ContractHelpers")]43#[solidity_interface(name = "ContractHelpers")]
49impl<T: Config> ContractHelpers<T> {44impl<T: Config> ContractHelpers<T>
45where
46 T::AccountId: AsRef<[u8]>,
47{
50 fn contract_owner(&self, contract_address: address) -> Result<address> {48 fn contract_owner(&self, contract_address: address) -> Result<address> {
51 Ok(<Owner<T>>::get(contract_address))49 Ok(<Owner<T>>::get(contract_address))
72 Ok(())70 Ok(())
73 }71 }
7472
75 fn get_sponsor(&self, contract_address: address) -> Result<address> {73 fn get_sponsor(&self, contract_address: address) -> Result<(address, uint256)> {
76 let sponsor =74 let sponsor =
77 Pallet::<T>::get_sponsor(contract_address).ok_or("Contract has no sponsor")?;75 Pallet::<T>::get_sponsor(contract_address).ok_or("Contract has no sponsor")?;
76 let sponsor_sub =
77 pallet_common::eth::convert_cross_account_to_eth_uint256::<T>(&sponsor);
78 Ok(*sponsor.as_eth())78 Ok((*sponsor.as_eth(), sponsor_sub))
79 }79 }
8080
81 fn sponsoring_enabled(&self, contract_address: address) -> Result<bool> {81 fn sponsoring_enabled(&self, contract_address: address) -> Result<bool> {
82 Ok(<Pallet<T>>::sponsoring_mode(contract_address) != SponsoringModeT::Disabled)82 Ok(<Pallet<T>>::sponsoring_mode(contract_address) != SponsoringModeT::Disabled)
83 }83 }
8484
85 /// Deprecated85 /// Deprecated
86 fn toggle_sponsoring(86 fn toggle_sponsoring(
87 &mut self,87 &mut self,
88 caller: caller,88 caller: caller,
162162
163pub struct HelpersOnMethodCall<T: Config>(PhantomData<*const T>);163pub struct HelpersOnMethodCall<T: Config>(PhantomData<*const T>);
164impl<T: Config> OnMethodCall<T> for HelpersOnMethodCall<T> {164impl<T: Config> OnMethodCall<T> for HelpersOnMethodCall<T>
165where
166 T::AccountId: AsRef<[u8]>,
167{
165 fn is_reserved(contract: &sp_core::H160) -> bool {168 fn is_reserved(contract: &sp_core::H160) -> bool {
166 contract == &T::ContractAddress::get()169 contract == &T::ContractAddress::get()