difftreelog
chore replace u128 with CallContext
in: master
19 files changed
Cargo.lockdiffbeforeafterboth5794 "pallet-common",5794 "pallet-common",5795 "pallet-evm 6.0.0-dev (git+https://github.com/uniquenetwork/frontier?rev=89a37c5a489f426cc7a42d7b94019974093a052d)",5795 "pallet-evm 6.0.0-dev (git+https://github.com/uniquenetwork/frontier?rev=89a37c5a489f426cc7a42d7b94019974093a052d)",5796 "pallet-evm-coder-substrate",5796 "pallet-evm-coder-substrate",5797 "pallet-evm-transaction-payment",5797 "parity-scale-codec 3.1.5",5798 "parity-scale-codec 3.1.5",5798 "scale-info",5799 "scale-info",5799 "sp-core",5800 "sp-core",6409[[package]]6410[[package]]6410name = "pallet-template-transaction-payment"6411name = "pallet-template-transaction-payment"6411version = "3.0.0"6412version = "3.0.0"6412source = "git+https://github.com/uniquenetwork/pallet-sponsoring?rev=a8ec4bf8d5ded662d96da6d8fb211b0bbf6617b3#a8ec4bf8d5ded662d96da6d8fb211b0bbf6617b3"6413source = "git+https://github.com/uniquenetwork/pallet-sponsoring?rev=9ee7d6e57e03a2575cbab79431774b56f170018e#9ee7d6e57e03a2575cbab79431774b56f170018e"6413dependencies = [6414dependencies = [6414 "frame-benchmarking",6415 "frame-benchmarking",6415 "frame-support",6416 "frame-support",12577[[package]]12578[[package]]12578name = "up-sponsorship"12579name = "up-sponsorship"12579version = "0.1.0"12580version = "0.1.0"12580source = "git+https://github.com/uniquenetwork/pallet-sponsoring?rev=a8ec4bf8d5ded662d96da6d8fb211b0bbf6617b3#a8ec4bf8d5ded662d96da6d8fb211b0bbf6617b3"12581source = "git+https://github.com/uniquenetwork/pallet-sponsoring?rev=9ee7d6e57e03a2575cbab79431774b56f170018e#9ee7d6e57e03a2575cbab79431774b56f170018e"12581dependencies = [12582dependencies = [12582 "impl-trait-for-tuples",12583 "impl-trait-for-tuples",12583]12584]pallets/evm-contract-helpers/Cargo.tomldiffbeforeafterboth21# Unique21# Unique22pallet-evm = { default-features = false, git = "https://github.com/uniquenetwork/frontier", rev = "89a37c5a489f426cc7a42d7b94019974093a052d" }22pallet-evm = { default-features = false, git = "https://github.com/uniquenetwork/frontier", rev = "89a37c5a489f426cc7a42d7b94019974093a052d" }23fp-evm-mapping = { default-features = false, git = "https://github.com/uniquenetwork/frontier", rev = "89a37c5a489f426cc7a42d7b94019974093a052d" }23fp-evm-mapping = { default-features = false, git = "https://github.com/uniquenetwork/frontier", rev = "89a37c5a489f426cc7a42d7b94019974093a052d" }24up-sponsorship = { version = "0.1.0", default-features = false, git = "https://github.com/uniquenetwork/pallet-sponsoring", rev="a8ec4bf8d5ded662d96da6d8fb211b0bbf6617b3" }24up-sponsorship = { version = "0.1.0", default-features = false, git = "https://github.com/uniquenetwork/pallet-sponsoring", rev="9ee7d6e57e03a2575cbab79431774b56f170018e" }252526# Locals26# Locals27evm-coder = { default-features = false, path = '../../crates/evm-coder' }27evm-coder = { default-features = false, path = '../../crates/evm-coder' }28pallet-common = { default-features = false, path = '../../pallets/common' }28pallet-common = { default-features = false, path = '../../pallets/common' }29pallet-evm-coder-substrate = { default-features = false, path = '../../pallets/evm-coder-substrate' }29pallet-evm-coder-substrate = { default-features = false, path = '../../pallets/evm-coder-substrate' }30pallet-evm-transaction-payment = { default-features = false, path = '../../pallets/evm-transaction-payment' }30up-data-structs = { default-features = false, path = '../../primitives/data-structs', features = [31up-data-structs = { default-features = false, path = '../../primitives/data-structs', features = [31 'serde1',32 'serde1',32] }33] }pallets/evm-contract-helpers/src/eth.rsdiffbeforeafterboth20use evm_coder::{20use evm_coder::{21 abi::AbiWriter, execution::Result, generate_stubgen, solidity_interface, types::*, ToLog,21 abi::AbiWriter, execution::Result, generate_stubgen, solidity_interface, types::*, ToLog,22};22};23use pallet_evm::{24 ExitRevert, OnCreate, OnMethodCall, PrecompileResult, PrecompileFailure, PrecompileHandle,25 account::CrossAccountId,26};23use pallet_evm_coder_substrate::{SubstrateRecorder, WithRecorder, dispatch_to_evm};27use pallet_evm_coder_substrate::{SubstrateRecorder, WithRecorder, dispatch_to_evm};24use pallet_evm::{28use pallet_evm_transaction_payment::CallContext;25 ExitRevert, OnCreate, OnMethodCall, PrecompileResult, PrecompileFailure, PrecompileHandle,26 account::CrossAccountId,27};28use sp_core::{H160, U256};29use sp_core::H160;29use up_data_structs::SponsorshipState;30use up_data_structs::SponsorshipState;30use crate::{31use crate::{31 AllowlistEnabled, Config, Owner, Pallet, SponsorBasket, SponsoringFeeLimit,32 AllowlistEnabled, Config, Owner, Pallet, SponsorBasket, SponsoringFeeLimit,254 &mut self,255 &mut self,255 caller: caller,256 caller: caller,256 contract_address: address,257 contract_address: address,257 fee_limit: uint128,258 fee_limit: uint256,258 ) -> Result<void> {259 ) -> Result<void> {259 <Pallet<T>>::ensure_owner(contract_address, caller).map_err(dispatch_to_evm::<T>)?;260 <Pallet<T>>::ensure_owner(contract_address, caller).map_err(dispatch_to_evm::<T>)?;260 <Pallet<T>>::set_sponsoring_fee_limit(contract_address, fee_limit.into());261 <Pallet<T>>::set_sponsoring_fee_limit(contract_address, fee_limit.into());261 Ok(())262 Ok(())262 }263 }263264264 fn get_sponsoring_fee_limit(&self, contract_address: address) -> Result<uint128> {265 fn get_sponsoring_fee_limit(&self, contract_address: address) -> Result<uint256> {265 Ok(<SponsoringFeeLimit<T>>::get(contract_address)266 Ok(<SponsoringFeeLimit<T>>::get(contract_address))266 .try_into()267 .map_err(|_| "fee limit > u128::MAX")?)268 }267 }269268270 /// Is specified user present in contract allow list269 /// Is specified user present in contract allow list380379381/// Bridge to pallet-sponsoring380/// Bridge to pallet-sponsoring382pub struct HelpersContractSponsoring<T: Config>(PhantomData<*const T>);381pub struct HelpersContractSponsoring<T: Config>(PhantomData<*const T>);383impl<T: Config> SponsorshipHandler<T::CrossAccountId, (H160, Vec<u8>), u128>382impl<T: Config> SponsorshipHandler<T::CrossAccountId, (H160, Vec<u8>), CallContext>384 for HelpersContractSponsoring<T>383 for HelpersContractSponsoring<T>385{384{386 fn get_sponsor(385 fn get_sponsor(387 who: &T::CrossAccountId,386 who: &T::CrossAccountId,388 call: &(H160, Vec<u8>),387 call: &(H160, Vec<u8>),389 fee_limit: &u128,388 call_context: &CallContext,390 ) -> Option<T::CrossAccountId> {389 ) -> Option<T::CrossAccountId> {391 let (contract_address, _) = call;390 let (contract_address, _) = call;392 let mode = <Pallet<T>>::sponsoring_mode(*contract_address);391 let mode = <Pallet<T>>::sponsoring_mode(*contract_address);417416418 let sponsored_fee_limit = <SponsoringFeeLimit<T>>::get(contract_address);417 let sponsored_fee_limit = <SponsoringFeeLimit<T>>::get(contract_address);419418420 if *fee_limit > sponsored_fee_limit {419 if call_context.max_fee > sponsored_fee_limit {421 return None;420 return None;422 }421 }423422pallets/evm-contract-helpers/src/lib.rsdiffbeforeafterboth30 use crate::eth::ContractHelpersEvents;30 use crate::eth::ContractHelpersEvents;31 use frame_support::pallet_prelude::*;31 use frame_support::pallet_prelude::*;32 use pallet_evm_coder_substrate::DispatchResult;32 use pallet_evm_coder_substrate::DispatchResult;33 use sp_core::H160;33 use sp_core::{H160, U256};34 use pallet_evm::{account::CrossAccountId, Pallet as PalletEvm};34 use pallet_evm::{account::CrossAccountId, Pallet as PalletEvm};35 use up_data_structs::SponsorshipState;35 use up_data_structs::SponsorshipState;36 use evm_coder::ToLog;36 use evm_coder::ToLog;50 type DefaultSponsoringRateLimit: Get<Self::BlockNumber>;50 type DefaultSponsoringRateLimit: Get<Self::BlockNumber>;51 /// In case of enabled sponsoring, but no sponsoring fee limit set,51 /// In case of enabled sponsoring, but no sponsoring fee limit set,52 /// this value will be used implicitly52 /// this value will be used implicitly53 type DefaultSponsoringFeeLimit: Get<u128>;53 type DefaultSponsoringFeeLimit: Get<U256>;54 }54 }555556 #[pallet::error]56 #[pallet::error]124 pub(super) type SponsoringFeeLimit<T: Config> = StorageMap<124 pub(super) type SponsoringFeeLimit<T: Config> = StorageMap<125 Hasher = Twox128,125 Hasher = Twox128,126 Key = H160,126 Key = H160,127 Value = u128,127 Value = U256,128 QueryKind = ValueQuery,128 QueryKind = ValueQuery,129 OnEmpty = T::DefaultSponsoringFeeLimit,129 OnEmpty = T::DefaultSponsoringFeeLimit,130 >;130 >;366 }366 }367367368 /// Set maximum for gas limit of transaction368 /// Set maximum for gas limit of transaction369 pub fn set_sponsoring_fee_limit(contract: H160, fee_limit: u128) {369 pub fn set_sponsoring_fee_limit(contract: H160, fee_limit: U256) {370 <SponsoringFeeLimit<T>>::insert(contract, fee_limit);370 <SponsoringFeeLimit<T>>::insert(contract, fee_limit);371 }371 }372372pallets/evm-contract-helpers/src/stubs/ContractHelpers.rawdiffbeforeafterbothbinary blob — no preview
pallets/evm-contract-helpers/src/stubs/ContractHelpers.soldiffbeforeafterboth32}32}333334/// @title Magic contract, which allows users to reconfigure other contracts34/// @title Magic contract, which allows users to reconfigure other contracts35/// @dev the ERC-165 identifier for this interface is 0xd77fab7035/// @dev the ERC-165 identifier for this interface is 0x172cb4fb36contract ContractHelpers is Dummy, ERC165, ContractHelpersEvents {36contract ContractHelpers is Dummy, ERC165, ContractHelpersEvents {37 /// Get user, which deployed specified contract37 /// Get user, which deployed specified contract38 /// @dev May return zero address in case if contract is deployed38 /// @dev May return zero address in case if contract is deployed203 dummy = 0;203 dummy = 0;204 }204 }205205206 /// @dev EVM selector for this function is: 0x1c362eb4,206 /// @dev EVM selector for this function is: 0x03aed665,207 /// or in textual repr: setSponsoringFeeLimit(address,uint128)207 /// or in textual repr: setSponsoringFeeLimit(address,uint256)208 function setSponsoringFeeLimit(address contractAddress, uint128 feeLimit)208 function setSponsoringFeeLimit(address contractAddress, uint256 feeLimit)209 public209 public210 {210 {211 require(false, stub_error);211 require(false, stub_error);219 function getSponsoringFeeLimit(address contractAddress)219 function getSponsoringFeeLimit(address contractAddress)220 public220 public221 view221 view222 returns (uint128)222 returns (uint256)223 {223 {224 require(false, stub_error);224 require(false, stub_error);225 contractAddress;225 contractAddress;pallets/evm-transaction-payment/Cargo.tomldiffbeforeafterboth17pallet-evm = { default-features = false, git = "https://github.com/uniquenetwork/frontier", rev = "89a37c5a489f426cc7a42d7b94019974093a052d" }17pallet-evm = { default-features = false, git = "https://github.com/uniquenetwork/frontier", rev = "89a37c5a489f426cc7a42d7b94019974093a052d" }18fp-evm = { default-features = false, git = "https://github.com/uniquenetwork/frontier", rev = "89a37c5a489f426cc7a42d7b94019974093a052d" }18fp-evm = { default-features = false, git = "https://github.com/uniquenetwork/frontier", rev = "89a37c5a489f426cc7a42d7b94019974093a052d" }19pallet-ethereum = { default-features = false, git = "https://github.com/uniquenetwork/frontier", rev = "89a37c5a489f426cc7a42d7b94019974093a052d" }19pallet-ethereum = { default-features = false, git = "https://github.com/uniquenetwork/frontier", rev = "89a37c5a489f426cc7a42d7b94019974093a052d" }20up-sponsorship = { version = "0.1.0", default-features = false, git = "https://github.com/uniquenetwork/pallet-sponsoring", rev = "a8ec4bf8d5ded662d96da6d8fb211b0bbf6617b3" }20up-sponsorship = { version = "0.1.0", default-features = false, git = "https://github.com/uniquenetwork/pallet-sponsoring", rev = "9ee7d6e57e03a2575cbab79431774b56f170018e" }21fp-evm-mapping = { default-features = false, git = "https://github.com/uniquenetwork/frontier", rev = "89a37c5a489f426cc7a42d7b94019974093a052d" }21fp-evm-mapping = { default-features = false, git = "https://github.com/uniquenetwork/frontier", rev = "89a37c5a489f426cc7a42d7b94019974093a052d" }222223[dependencies.codec]23[dependencies.codec]pallets/evm-transaction-payment/src/lib.rsdiffbeforeafterboth22use fp_evm::WithdrawReason;22use fp_evm::WithdrawReason;23use frame_support::traits::IsSubType;23use frame_support::traits::IsSubType;24pub use pallet::*;24pub use pallet::*;25use pallet_evm::{account::CrossAccountId, EnsureAddressOrigin, FeeCalculator};25use pallet_evm::{account::CrossAccountId, EnsureAddressOrigin};26use sp_core::{H160, U256};26use sp_core::{H160, U256};27use sp_runtime::{TransactionOutcome, DispatchError};27use sp_runtime::{TransactionOutcome, DispatchError};28use up_sponsorship::SponsorshipHandler;28use up_sponsorship::SponsorshipHandler;333334 use sp_std::vec::Vec;34 use sp_std::vec::Vec;3536 /// Contains call data37 pub struct CallContext {38 /// Max fee for transaction - gasLimit * gasPrice39 pub max_fee: U256,40 }354136 #[pallet::config]42 #[pallet::config]37 pub trait Config: frame_system::Config + pallet_evm::account::Config {43 pub trait Config: frame_system::Config + pallet_evm::account::Config {38 /// Loosly-coupled handlers for evm call sponsoring44 /// Loosly-coupled handlers for evm call sponsoring39 type EvmSponsorshipHandler: SponsorshipHandler<Self::CrossAccountId, (H160, Vec<u8>), u128>;45 type EvmSponsorshipHandler: SponsorshipHandler<46 Self::CrossAccountId,47 (H160, Vec<u8>),48 CallContext,49 >;40 }50 }415155 match reason {65 match reason {56 WithdrawReason::Call { target, input } => {66 WithdrawReason::Call { target, input } => {57 let origin_sub = T::CrossAccountId::from_eth(origin);67 let origin_sub = T::CrossAccountId::from_eth(origin);68 let call_context = CallContext { max_fee };58 T::EvmSponsorshipHandler::get_sponsor(69 T::EvmSponsorshipHandler::get_sponsor(59 &origin_sub,70 &origin_sub,60 &(*target, input.clone()),71 &(*target, input.clone()),61 &max_fee.as_u128(),72 &call_context,62 )73 )63 }74 }64 _ => None,75 _ => None,687969/// Implements sponsoring for evm calls performed from pallet-evm (via api.tx.ethereum.transact/api.tx.evm.call)80/// Implements sponsoring for evm calls performed from pallet-evm (via api.tx.ethereum.transact/api.tx.evm.call)70pub struct BridgeSponsorshipHandler<T>(PhantomData<T>);81pub struct BridgeSponsorshipHandler<T>(PhantomData<T>);71impl<T, C> SponsorshipHandler<T::AccountId, C, u128> for BridgeSponsorshipHandler<T>82impl<T, C> SponsorshipHandler<T::AccountId, C, ()> for BridgeSponsorshipHandler<T>72where83where73 T: Config + pallet_evm::Config,84 T: Config + pallet_evm::Config,74 C: IsSubType<pallet_evm::Call<T>>,85 C: IsSubType<pallet_evm::Call<T>>,75{86{76 fn get_sponsor(who: &T::AccountId, call: &C, _fee_limit: &u128) -> Option<T::AccountId> {87 fn get_sponsor(who: &T::AccountId, call: &C, _call_context: &()) -> Option<T::AccountId> {77 match call.is_sub_type()? {88 match call.is_sub_type()? {78 pallet_evm::Call::call {89 pallet_evm::Call::call {79 source,90 source,90 .ok()?;101 .ok()?;91 let who = T::CrossAccountId::from_sub(who.clone());102 let who = T::CrossAccountId::from_sub(who.clone());92 let max_fee = max_fee_per_gas.saturating_mul((*gas_limit).into());103 let max_fee = max_fee_per_gas.saturating_mul((*gas_limit).into());104 let call_context = CallContext { max_fee };93 // Effects from EvmSponsorshipHandler are applied by pallet_evm::runner105 // Effects from EvmSponsorshipHandler are applied by pallet_evm::runner94 // TODO: Should we implement simulation mode (test, but do not apply effects) in `up-sponsorship`?106 // TODO: Should we implement simulation mode (test, but do not apply effects) in `up-sponsorship`?95 let sponsor = frame_support::storage::with_transaction(|| {107 let sponsor = frame_support::storage::with_transaction(|| {96 TransactionOutcome::Rollback(Ok::<_, DispatchError>(108 TransactionOutcome::Rollback(Ok::<_, DispatchError>(97 T::EvmSponsorshipHandler::get_sponsor(109 T::EvmSponsorshipHandler::get_sponsor(98 &who,110 &who,99 &(*target, input.clone()),111 &(*target, input.clone()),100 &max_fee.try_into().unwrap(),112 &call_context,101 ),113 ),102 ))114 ))103 })115 })pallets/scheduler/Cargo.tomldiffbeforeafterboth24sp-core = { default-features = false, git = 'https://github.com/paritytech/substrate.git', branch = 'polkadot-v0.9.27' }24sp-core = { default-features = false, git = 'https://github.com/paritytech/substrate.git', branch = 'polkadot-v0.9.27' }25frame-benchmarking = { default-features = false, optional = true, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.27" }25frame-benchmarking = { default-features = false, optional = true, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.27" }262627up-sponsorship = { version = "0.1.0", default-features = false, git = "https://github.com/uniquenetwork/pallet-sponsoring", rev="a8ec4bf8d5ded662d96da6d8fb211b0bbf6617b3" }27up-sponsorship = { version = "0.1.0", default-features = false, git = "https://github.com/uniquenetwork/pallet-sponsoring", rev="9ee7d6e57e03a2575cbab79431774b56f170018e" }28log = { version = "0.4.14", default-features = false }28log = { version = "0.4.14", default-features = false }292930[dev-dependencies]30[dev-dependencies]runtime/common/config/sponsoring.rsdiffbeforeafterboth14// You should have received a copy of the GNU General Public License14// You should have received a copy of the GNU General Public License15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.161617use frame_support::parameter_types;18use crate::{17use crate::{19 runtime_common::{sponsoring::UniqueSponsorshipHandler},18 runtime_common::{sponsoring::UniqueSponsorshipHandler},20 Runtime,19 Runtime,21};20};21use frame_support::parameter_types;22use sp_core::U256;22use up_common::{types::BlockNumber, constants::*};23use up_common::{constants::*, types::BlockNumber};232424parameter_types! {25parameter_types! {25 pub const DefaultSponsoringRateLimit: BlockNumber = 1 * DAYS;26 pub const DefaultSponsoringRateLimit: BlockNumber = 1 * DAYS;26 pub const DefaultSponsoringFeeLimit: u128 = u128::MAX;27 pub const DefaultSponsoringFeeLimit: U256 = U256::MAX;27}28}282929type SponsorshipHandler = (30type SponsorshipHandler = (runtime/common/ethereum/sponsoring.rsdiffbeforeafterboth161617//! Implements EVM sponsoring logic via TransactionValidityHack17//! Implements EVM sponsoring logic via TransactionValidityHack181819use core::{convert::TryInto, marker::PhantomData};19use evm_coder::{Call, abi::AbiReader};20use evm_coder::{Call, abi::AbiReader};20use pallet_common::{CollectionHandle, eth::map_eth_to_id};21use pallet_common::{CollectionHandle, eth::map_eth_to_id};21use sp_core::H160;22use pallet_evm::account::CrossAccountId;23use pallet_evm_transaction_payment::CallContext;22use sp_std::prelude::*;24use pallet_nonfungible::{25 Config as NonfungibleConfig,26 erc::{27 UniqueNFTCall, ERC721UniqueExtensionsCall, ERC721MintableCall, ERC721Call,28 TokenPropertiesCall,29 },30};23use up_sponsorship::SponsorshipHandler;31use pallet_fungible::{32 Config as FungibleConfig,33 erc::{UniqueFungibleCall, ERC20Call},34};24use core::marker::PhantomData;35use pallet_refungible::Config as RefungibleConfig;25use core::convert::TryInto;36use pallet_unique::Config as UniqueConfig;37use sp_core::H160;26use pallet_evm::account::CrossAccountId;38use sp_std::prelude::*;27use up_data_structs::{TokenId, CreateItemData, CreateNftData, CollectionMode};39use up_data_structs::{CollectionMode, CreateItemData, CreateNftData, TokenId};28use pallet_unique::Config as UniqueConfig;40use up_sponsorship::SponsorshipHandler;294130use crate::{Runtime, runtime_common::sponsoring::*};42use crate::{Runtime, runtime_common::sponsoring::*};3132use pallet_nonfungible::erc::{33 UniqueNFTCall, ERC721UniqueExtensionsCall, ERC721MintableCall, ERC721Call, TokenPropertiesCall,34};35use pallet_fungible::erc::{UniqueFungibleCall, ERC20Call};36use pallet_fungible::Config as FungibleConfig;37use pallet_nonfungible::Config as NonfungibleConfig;38use pallet_refungible::Config as RefungibleConfig;394340pub type EvmSponsorshipHandler = (44pub type EvmSponsorshipHandler = (41 UniqueEthSponsorshipHandler<Runtime>,45 UniqueEthSponsorshipHandler<Runtime>,444845pub struct UniqueEthSponsorshipHandler<T: UniqueConfig>(PhantomData<*const T>);49pub struct UniqueEthSponsorshipHandler<T: UniqueConfig>(PhantomData<*const T>);46impl<T: UniqueConfig + FungibleConfig + NonfungibleConfig + RefungibleConfig>50impl<T: UniqueConfig + FungibleConfig + NonfungibleConfig + RefungibleConfig>47 SponsorshipHandler<T::CrossAccountId, (H160, Vec<u8>), u128> for UniqueEthSponsorshipHandler<T>51 SponsorshipHandler<T::CrossAccountId, (H160, Vec<u8>), CallContext>52 for UniqueEthSponsorshipHandler<T>48{53{49 fn get_sponsor(54 fn get_sponsor(50 who: &T::CrossAccountId,55 who: &T::CrossAccountId,51 call: &(H160, Vec<u8>),56 call: &(H160, Vec<u8>),52 _fee_limit: &u128,57 _fee_limit: &CallContext,53 ) -> Option<T::CrossAccountId> {58 ) -> Option<T::CrossAccountId> {54 let collection_id = map_eth_to_id(&call.0)?;59 let collection_id = map_eth_to_id(&call.0)?;55 let collection = <CollectionHandle<T>>::new(collection_id)?;60 let collection = <CollectionHandle<T>>::new(collection_id)?;runtime/common/sponsoring.rsdiffbeforeafterboth224}224}225225226pub struct UniqueSponsorshipHandler<T>(PhantomData<T>);226pub struct UniqueSponsorshipHandler<T>(PhantomData<T>);227impl<T, C> SponsorshipHandler<T::AccountId, C, u128> for UniqueSponsorshipHandler<T>227impl<T, C> SponsorshipHandler<T::AccountId, C, ()> for UniqueSponsorshipHandler<T>228where228where229 T: Config,229 T: Config,230 C: IsSubType<UniqueCall<T>>,230 C: IsSubType<UniqueCall<T>>,231{231{232 fn get_sponsor(who: &T::AccountId, call: &C, _fee_limit: &u128) -> Option<T::AccountId> {232 fn get_sponsor(who: &T::AccountId, call: &C, _call_context: &()) -> Option<T::AccountId> {233 match IsSubType::<UniqueCall<T>>::is_sub_type(call)? {233 match IsSubType::<UniqueCall<T>>::is_sub_type(call)? {234 UniqueCall::set_token_properties {234 UniqueCall::set_token_properties {235 collection_id,235 collection_id,runtime/opal/Cargo.tomldiffbeforeafterboth431pallet-proxy-rmrk-equip = { default-features = false, path = "../../pallets/proxy-rmrk-equip", package = "pallet-rmrk-equip" }431pallet-proxy-rmrk-equip = { default-features = false, path = "../../pallets/proxy-rmrk-equip", package = "pallet-rmrk-equip" }432pallet-unique-scheduler = { path = '../../pallets/scheduler', default-features = false }432pallet-unique-scheduler = { path = '../../pallets/scheduler', default-features = false }433# pallet-contract-helpers = { path = '../pallets/contract-helpers', default-features = false, version = '0.1.0' }433# pallet-contract-helpers = { path = '../pallets/contract-helpers', default-features = false, version = '0.1.0' }434pallet-charge-transaction = { git = "https://github.com/uniquenetwork/pallet-sponsoring", rev="a8ec4bf8d5ded662d96da6d8fb211b0bbf6617b3", package = "pallet-template-transaction-payment", default-features = false, version = "3.0.0" }434pallet-charge-transaction = { git = "https://github.com/uniquenetwork/pallet-sponsoring", rev="9ee7d6e57e03a2575cbab79431774b56f170018e", package = "pallet-template-transaction-payment", default-features = false, version = "3.0.0" }435pallet-evm-migration = { path = '../../pallets/evm-migration', default-features = false }435pallet-evm-migration = { path = '../../pallets/evm-migration', default-features = false }436pallet-evm-contract-helpers = { path = '../../pallets/evm-contract-helpers', default-features = false }436pallet-evm-contract-helpers = { path = '../../pallets/evm-contract-helpers', default-features = false }437pallet-evm-transaction-payment = { path = '../../pallets/evm-transaction-payment', default-features = false }437pallet-evm-transaction-payment = { path = '../../pallets/evm-transaction-payment', default-features = false }442fp-rpc = { default-features = false, git = "https://github.com/uniquenetwork/frontier", rev = "89a37c5a489f426cc7a42d7b94019974093a052d" }442fp-rpc = { default-features = false, git = "https://github.com/uniquenetwork/frontier", rev = "89a37c5a489f426cc7a42d7b94019974093a052d" }443fp-self-contained = { default-features = false, git = "https://github.com/uniquenetwork/frontier", rev = "89a37c5a489f426cc7a42d7b94019974093a052d" }443fp-self-contained = { default-features = false, git = "https://github.com/uniquenetwork/frontier", rev = "89a37c5a489f426cc7a42d7b94019974093a052d" }444evm-coder = { default-features = false, path = '../../crates/evm-coder' }444evm-coder = { default-features = false, path = '../../crates/evm-coder' }445up-sponsorship = { default-features = false, git = "https://github.com/uniquenetwork/pallet-sponsoring", rev="a8ec4bf8d5ded662d96da6d8fb211b0bbf6617b3" }445up-sponsorship = { default-features = false, git = "https://github.com/uniquenetwork/pallet-sponsoring", rev="9ee7d6e57e03a2575cbab79431774b56f170018e" }446446447################################################################################447################################################################################448# Build Dependencies448# Build Dependenciesruntime/quartz/Cargo.tomldiffbeforeafterboth432pallet-proxy-rmrk-equip = { default-features = false, path = "../../pallets/proxy-rmrk-equip", package = "pallet-rmrk-equip" }432pallet-proxy-rmrk-equip = { default-features = false, path = "../../pallets/proxy-rmrk-equip", package = "pallet-rmrk-equip" }433pallet-unique-scheduler = { path = '../../pallets/scheduler', default-features = false }433pallet-unique-scheduler = { path = '../../pallets/scheduler', default-features = false }434# pallet-contract-helpers = { path = '../pallets/contract-helpers', default-features = false, version = '0.1.0' }434# pallet-contract-helpers = { path = '../pallets/contract-helpers', default-features = false, version = '0.1.0' }435pallet-charge-transaction = { git = "https://github.com/uniquenetwork/pallet-sponsoring", rev="a8ec4bf8d5ded662d96da6d8fb211b0bbf6617b3", package = "pallet-template-transaction-payment", default-features = false, version = "3.0.0" }435pallet-charge-transaction = { git = "https://github.com/uniquenetwork/pallet-sponsoring", rev="9ee7d6e57e03a2575cbab79431774b56f170018e", package = "pallet-template-transaction-payment", default-features = false, version = "3.0.0" }436pallet-evm-migration = { path = '../../pallets/evm-migration', default-features = false }436pallet-evm-migration = { path = '../../pallets/evm-migration', default-features = false }437pallet-evm-contract-helpers = { path = '../../pallets/evm-contract-helpers', default-features = false }437pallet-evm-contract-helpers = { path = '../../pallets/evm-contract-helpers', default-features = false }438pallet-evm-transaction-payment = { path = '../../pallets/evm-transaction-payment', default-features = false }438pallet-evm-transaction-payment = { path = '../../pallets/evm-transaction-payment', default-features = false }443fp-rpc = { default-features = false, git = "https://github.com/uniquenetwork/frontier", rev = "89a37c5a489f426cc7a42d7b94019974093a052d" }443fp-rpc = { default-features = false, git = "https://github.com/uniquenetwork/frontier", rev = "89a37c5a489f426cc7a42d7b94019974093a052d" }444fp-self-contained = { default-features = false, git = "https://github.com/uniquenetwork/frontier", rev = "89a37c5a489f426cc7a42d7b94019974093a052d" }444fp-self-contained = { default-features = false, git = "https://github.com/uniquenetwork/frontier", rev = "89a37c5a489f426cc7a42d7b94019974093a052d" }445evm-coder = { default-features = false, path = '../../crates/evm-coder' }445evm-coder = { default-features = false, path = '../../crates/evm-coder' }446up-sponsorship = { default-features = false, git = "https://github.com/uniquenetwork/pallet-sponsoring", rev="a8ec4bf8d5ded662d96da6d8fb211b0bbf6617b3" }446up-sponsorship = { default-features = false, git = "https://github.com/uniquenetwork/pallet-sponsoring", rev="9ee7d6e57e03a2575cbab79431774b56f170018e" }447447448################################################################################448################################################################################449# Build Dependencies449# Build Dependenciesruntime/tests/Cargo.tomldiffbeforeafterboth43scale-info = "*"43scale-info = "*"444445evm-coder = { default-features = false, path = '../../crates/evm-coder' }45evm-coder = { default-features = false, path = '../../crates/evm-coder' }46up-sponsorship = { default-features = false, git = "https://github.com/uniquenetwork/pallet-sponsoring", rev="a8ec4bf8d5ded662d96da6d8fb211b0bbf6617b3" }46up-sponsorship = { default-features = false, git = "https://github.com/uniquenetwork/pallet-sponsoring", rev="9ee7d6e57e03a2575cbab79431774b56f170018e" }4747runtime/unique/Cargo.tomldiffbeforeafterboth425pallet-proxy-rmrk-equip = { default-features = false, path = "../../pallets/proxy-rmrk-equip", package = "pallet-rmrk-equip" }425pallet-proxy-rmrk-equip = { default-features = false, path = "../../pallets/proxy-rmrk-equip", package = "pallet-rmrk-equip" }426pallet-unique-scheduler = { path = '../../pallets/scheduler', default-features = false }426pallet-unique-scheduler = { path = '../../pallets/scheduler', default-features = false }427# pallet-contract-helpers = { path = '../pallets/contract-helpers', default-features = false, version = '0.1.0' }427# pallet-contract-helpers = { path = '../pallets/contract-helpers', default-features = false, version = '0.1.0' }428pallet-charge-transaction = { git = "https://github.com/uniquenetwork/pallet-sponsoring", rev="a8ec4bf8d5ded662d96da6d8fb211b0bbf6617b3", package = "pallet-template-transaction-payment", default-features = false, version = "3.0.0" }428pallet-charge-transaction = { git = "https://github.com/uniquenetwork/pallet-sponsoring", rev="9ee7d6e57e03a2575cbab79431774b56f170018e", package = "pallet-template-transaction-payment", default-features = false, version = "3.0.0" }429pallet-evm-migration = { path = '../../pallets/evm-migration', default-features = false }429pallet-evm-migration = { path = '../../pallets/evm-migration', default-features = false }430pallet-evm-contract-helpers = { path = '../../pallets/evm-contract-helpers', default-features = false }430pallet-evm-contract-helpers = { path = '../../pallets/evm-contract-helpers', default-features = false }431pallet-evm-transaction-payment = { path = '../../pallets/evm-transaction-payment', default-features = false }431pallet-evm-transaction-payment = { path = '../../pallets/evm-transaction-payment', default-features = false }437fp-self-contained = { default-features = false, git = "https://github.com/uniquenetwork/frontier", rev = "89a37c5a489f426cc7a42d7b94019974093a052d" }437fp-self-contained = { default-features = false, git = "https://github.com/uniquenetwork/frontier", rev = "89a37c5a489f426cc7a42d7b94019974093a052d" }438fp-evm-mapping = { default-features = false, git = "https://github.com/uniquenetwork/frontier", rev = "89a37c5a489f426cc7a42d7b94019974093a052d" }438fp-evm-mapping = { default-features = false, git = "https://github.com/uniquenetwork/frontier", rev = "89a37c5a489f426cc7a42d7b94019974093a052d" }439evm-coder = { default-features = false, path = '../../crates/evm-coder' }439evm-coder = { default-features = false, path = '../../crates/evm-coder' }440up-sponsorship = { default-features = false, git = "https://github.com/uniquenetwork/pallet-sponsoring", rev="a8ec4bf8d5ded662d96da6d8fb211b0bbf6617b3" }440up-sponsorship = { default-features = false, git = "https://github.com/uniquenetwork/pallet-sponsoring", rev="9ee7d6e57e03a2575cbab79431774b56f170018e" }441441442################################################################################442################################################################################443# Build Dependencies443# Build Dependenciestests/src/eth/api/ContractHelpers.soldiffbeforeafterboth23}23}242425/// @title Magic contract, which allows users to reconfigure other contracts25/// @title Magic contract, which allows users to reconfigure other contracts26/// @dev the ERC-165 identifier for this interface is 0xd77fab7026/// @dev the ERC-165 identifier for this interface is 0x172cb4fb27interface ContractHelpers is Dummy, ERC165, ContractHelpersEvents {27interface ContractHelpers is Dummy, ERC165, ContractHelpersEvents {28 /// Get user, which deployed specified contract28 /// Get user, which deployed specified contract29 /// @dev May return zero address in case if contract is deployed29 /// @dev May return zero address in case if contract is deployed131 function setSponsoringRateLimit(address contractAddress, uint32 rateLimit)131 function setSponsoringRateLimit(address contractAddress, uint32 rateLimit)132 external;132 external;133133134 /// @dev EVM selector for this function is: 0x1c362eb4,134 /// @dev EVM selector for this function is: 0x03aed665,135 /// or in textual repr: setSponsoringFeeLimit(address,uint128)135 /// or in textual repr: setSponsoringFeeLimit(address,uint256)136 function setSponsoringFeeLimit(address contractAddress, uint128 feeLimit)136 function setSponsoringFeeLimit(address contractAddress, uint256 feeLimit)137 external;137 external;138138139 /// @dev EVM selector for this function is: 0xc3fdc9ee,139 /// @dev EVM selector for this function is: 0xc3fdc9ee,140 /// or in textual repr: getSponsoringFeeLimit(address)140 /// or in textual repr: getSponsoringFeeLimit(address)141 function getSponsoringFeeLimit(address contractAddress)141 function getSponsoringFeeLimit(address contractAddress)142 external142 external143 view143 view144 returns (uint128);144 returns (uint256);145145146 /// Is specified user present in contract allow list146 /// Is specified user present in contract allow list147 /// @dev Contract owner always implicitly included147 /// @dev Contract owner always implicitly includedtests/src/eth/contractSponsoring.test.tsdiffbeforeafterboth558 const owner = await createEthAccountWithBalance(api, web3, privateKeyWrapper);558 const owner = await createEthAccountWithBalance(api, web3, privateKeyWrapper);559 const flipper = await deployFlipper(web3, owner);559 const flipper = await deployFlipper(web3, owner);560 const helpers = contractHelpers(web3, owner);560 const helpers = contractHelpers(web3, owner);561 expect(await helpers.methods.getSponsoringFeeLimit(flipper.options.address).call()).to.be.equals('340282366920938463463374607431768211455');561 expect(await helpers.methods.getSponsoringFeeLimit(flipper.options.address).call()).to.be.equals('115792089237316195423570985008687907853269984665640564039457584007913129639935');562 });562 });563563564 itWeb3('Set fee limit', async ({api, web3, privateKeyWrapper}) => {564 itWeb3('Set fee limit', async ({api, web3, privateKeyWrapper}) => {tests/src/eth/util/contractHelpersAbi.jsondiffbeforeafterboth135 }135 }136 ],136 ],137 "name": "getSponsoringFeeLimit",137 "name": "getSponsoringFeeLimit",138 "outputs": [{ "internalType": "uint128", "name": "", "type": "uint128" }],138 "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],139 "stateMutability": "view",139 "stateMutability": "view",140 "type": "function"140 "type": "function"141 },141 },225 "name": "contractAddress",225 "name": "contractAddress",226 "type": "address"226 "type": "address"227 },227 },228 { "internalType": "uint128", "name": "feeLimit", "type": "uint128" }228 { "internalType": "uint256", "name": "feeLimit", "type": "uint256" }229 ],229 ],230 "name": "setSponsoringFeeLimit",230 "name": "setSponsoringFeeLimit",231 "outputs": [],231 "outputs": [],