git.delta.rocks / unique-network / refs/commits / 0707cc7cb0a8

difftreelog

chore move contract address and transaction data to call context

Grigoriy Simonov2022-09-13parent: #f5580aa.patch.diff
in: master

13 files changed

modifiedCargo.lockdiffbeforeafterboth
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -6360,7 +6360,7 @@
 [[package]]
 name = "pallet-template-transaction-payment"
 version = "3.0.0"
-source = "git+https://github.com/uniquenetwork/pallet-sponsoring?rev=9ee7d6e57e03a2575cbab79431774b56f170018e#9ee7d6e57e03a2575cbab79431774b56f170018e"
+source = "git+https://github.com/uniquenetwork/pallet-sponsoring?branch=polkadot-v0.9.27#853766d6033ceb68a2bef196790b962dd0663a04"
 dependencies = [
  "frame-benchmarking",
  "frame-support",
@@ -12528,7 +12528,7 @@
 [[package]]
 name = "up-sponsorship"
 version = "0.1.0"
-source = "git+https://github.com/uniquenetwork/pallet-sponsoring?rev=9ee7d6e57e03a2575cbab79431774b56f170018e#9ee7d6e57e03a2575cbab79431774b56f170018e"
+source = "git+https://github.com/uniquenetwork/pallet-sponsoring?branch=polkadot-v0.9.27#853766d6033ceb68a2bef196790b962dd0663a04"
 dependencies = [
  "impl-trait-for-tuples",
 ]
modifiedpallets/evm-contract-helpers/Cargo.tomldiffbeforeafterboth
--- a/pallets/evm-contract-helpers/Cargo.toml
+++ b/pallets/evm-contract-helpers/Cargo.toml
@@ -21,7 +21,7 @@
 # Unique
 pallet-evm = { default-features = false, git = "https://github.com/uniquenetwork/frontier", rev = "89a37c5a489f426cc7a42d7b94019974093a052d" }
 fp-evm-mapping = { default-features = false, git = "https://github.com/uniquenetwork/frontier", rev = "89a37c5a489f426cc7a42d7b94019974093a052d" }
-up-sponsorship = { version = "0.1.0", default-features = false, git = "https://github.com/uniquenetwork/pallet-sponsoring", rev="9ee7d6e57e03a2575cbab79431774b56f170018e" }
+up-sponsorship = { version = "0.1.0", default-features = false, git = "https://github.com/uniquenetwork/pallet-sponsoring", branch = "polkadot-v0.9.27" }
 
 # Locals
 evm-coder = { default-features = false, path = '../../crates/evm-coder' }
modifiedpallets/evm-contract-helpers/src/eth.rsdiffbeforeafterboth
379379
380/// Bridge to pallet-sponsoring380/// Bridge to pallet-sponsoring
381pub struct HelpersContractSponsoring<T: Config>(PhantomData<*const T>);381pub struct HelpersContractSponsoring<T: Config>(PhantomData<*const T>);
382impl<T: Config> SponsorshipHandler<T::CrossAccountId, (H160, Vec<u8>), CallContext>382impl<T: Config> SponsorshipHandler<T::CrossAccountId, CallContext>
383 for HelpersContractSponsoring<T>383 for HelpersContractSponsoring<T>
384{384{
385 fn get_sponsor(385 fn get_sponsor(
386 who: &T::CrossAccountId,386 who: &T::CrossAccountId,
387 call: &(H160, Vec<u8>),
388 call_context: &CallContext,387 call_context: &CallContext,
389 ) -> Option<T::CrossAccountId> {388 ) -> Option<T::CrossAccountId> {
390 let (contract_address, _) = call;389 let contract_address = call_context.contract_address;
391 let mode = <Pallet<T>>::sponsoring_mode(*contract_address);390 let mode = <Pallet<T>>::sponsoring_mode(contract_address);
392 if mode == SponsoringModeT::Disabled {391 if mode == SponsoringModeT::Disabled {
393 return None;392 return None;
394 }393 }
395394
396 let sponsor = match <Pallet<T>>::get_sponsor(*contract_address) {395 let sponsor = match <Pallet<T>>::get_sponsor(contract_address) {
397 Some(sponsor) => sponsor,396 Some(sponsor) => sponsor,
398 None => return None,397 None => return None,
399 };398 };
400399
401 if mode == SponsoringModeT::Allowlisted400 if mode == SponsoringModeT::Allowlisted
402 && !<Pallet<T>>::allowed(*contract_address, *who.as_eth())401 && !<Pallet<T>>::allowed(contract_address, *who.as_eth())
403 {402 {
404 return None;403 return None;
405 }404 }
modifiedpallets/evm-transaction-payment/Cargo.tomldiffbeforeafterboth
--- a/pallets/evm-transaction-payment/Cargo.toml
+++ b/pallets/evm-transaction-payment/Cargo.toml
@@ -17,7 +17,7 @@
 pallet-evm = { default-features = false, git = "https://github.com/uniquenetwork/frontier", rev = "89a37c5a489f426cc7a42d7b94019974093a052d" }
 fp-evm = { default-features = false, git = "https://github.com/uniquenetwork/frontier", rev = "89a37c5a489f426cc7a42d7b94019974093a052d" }
 pallet-ethereum = { default-features = false, git = "https://github.com/uniquenetwork/frontier", rev = "89a37c5a489f426cc7a42d7b94019974093a052d" }
-up-sponsorship = { version = "0.1.0", default-features = false, git = "https://github.com/uniquenetwork/pallet-sponsoring", rev = "9ee7d6e57e03a2575cbab79431774b56f170018e" }
+up-sponsorship = { version = "0.1.0", default-features = false, git = "https://github.com/uniquenetwork/pallet-sponsoring", branch = "polkadot-v0.9.27" }
 fp-evm-mapping = { default-features = false, git = "https://github.com/uniquenetwork/frontier", rev = "89a37c5a489f426cc7a42d7b94019974093a052d" }
 
 [dependencies.codec]
modifiedpallets/evm-transaction-payment/src/lib.rsdiffbeforeafterboth
--- a/pallets/evm-transaction-payment/src/lib.rs
+++ b/pallets/evm-transaction-payment/src/lib.rs
@@ -35,6 +35,10 @@
 
 	/// Contains call data
 	pub struct CallContext {
+		/// Contract address
+		pub contract_address: H160,
+		/// Transaction data
+		pub input: Vec<u8>,
 		/// Max fee for transaction - gasLimit * gasPrice
 		pub max_fee: U256,
 	}
@@ -42,11 +46,7 @@
 	#[pallet::config]
 	pub trait Config: frame_system::Config + pallet_evm::account::Config {
 		/// Loosly-coupled handlers for evm call sponsoring
-		type EvmSponsorshipHandler: SponsorshipHandler<
-			Self::CrossAccountId,
-			(H160, Vec<u8>),
-			CallContext,
-		>;
+		type EvmSponsorshipHandler: SponsorshipHandler<Self::CrossAccountId, CallContext>;
 	}
 
 	#[pallet::pallet]
@@ -65,12 +65,12 @@
 		match reason {
 			WithdrawReason::Call { target, input } => {
 				let origin_sub = T::CrossAccountId::from_eth(origin);
-				let call_context = CallContext { max_fee };
-				T::EvmSponsorshipHandler::get_sponsor(
-					&origin_sub,
-					&(*target, input.clone()),
-					&call_context,
-				)
+				let call_context = CallContext {
+					contract_address: *target,
+					input: input.clone(),
+					max_fee,
+				};
+				T::EvmSponsorshipHandler::get_sponsor(&origin_sub, &call_context)
 			}
 			_ => None,
 		}
@@ -79,12 +79,12 @@
 
 /// Implements sponsoring for evm calls performed from pallet-evm (via api.tx.ethereum.transact/api.tx.evm.call)
 pub struct BridgeSponsorshipHandler<T>(PhantomData<T>);
-impl<T, C> SponsorshipHandler<T::AccountId, C, ()> for BridgeSponsorshipHandler<T>
+impl<T, C> SponsorshipHandler<T::AccountId, C> for BridgeSponsorshipHandler<T>
 where
 	T: Config + pallet_evm::Config,
 	C: IsSubType<pallet_evm::Call<T>>,
 {
-	fn get_sponsor(who: &T::AccountId, call: &C, _call_context: &()) -> Option<T::AccountId> {
+	fn get_sponsor(who: &T::AccountId, call: &C) -> Option<T::AccountId> {
 		match call.is_sub_type()? {
 			pallet_evm::Call::call {
 				source,
@@ -101,16 +101,16 @@
 				.ok()?;
 				let who = T::CrossAccountId::from_sub(who.clone());
 				let max_fee = max_fee_per_gas.saturating_mul((*gas_limit).into());
-				let call_context = CallContext { max_fee };
+				let call_context = CallContext {
+					contract_address: *target,
+					input: input.clone(),
+					max_fee,
+				};
 				// Effects from EvmSponsorshipHandler are applied by pallet_evm::runner
 				// TODO: Should we implement simulation mode (test, but do not apply effects) in `up-sponsorship`?
 				let sponsor = frame_support::storage::with_transaction(|| {
 					TransactionOutcome::Rollback(Ok::<_, DispatchError>(
-						T::EvmSponsorshipHandler::get_sponsor(
-							&who,
-							&(*target, input.clone()),
-							&call_context,
-						),
+						T::EvmSponsorshipHandler::get_sponsor(&who, &call_context),
 					))
 				})
 				// FIXME: it may fail with DispatchError in case of depth limit
modifiedpallets/scheduler/Cargo.tomldiffbeforeafterboth
--- a/pallets/scheduler/Cargo.toml
+++ b/pallets/scheduler/Cargo.toml
@@ -24,7 +24,7 @@
 sp-core = { default-features = false, git = 'https://github.com/paritytech/substrate.git', branch = 'polkadot-v0.9.27' }
 frame-benchmarking = { default-features = false, optional = true, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.27" }
 
-up-sponsorship = { version = "0.1.0", default-features = false, git = "https://github.com/uniquenetwork/pallet-sponsoring", rev="9ee7d6e57e03a2575cbab79431774b56f170018e" }
+up-sponsorship = { version = "0.1.0", default-features = false, git = "https://github.com/uniquenetwork/pallet-sponsoring", branch = "polkadot-v0.9.27" }
 log = { version = "0.4.14", default-features = false }
 
 [dev-dependencies]
modifiedpallets/unique/src/eth/mod.rsdiffbeforeafterboth
--- a/pallets/unique/src/eth/mod.rs
+++ b/pallets/unique/src/eth/mod.rs
@@ -21,25 +21,23 @@
 use evm_coder::{execution::*, generate_stubgen, solidity_interface, solidity, weight, types::*};
 use frame_support::traits::Get;
 use pallet_common::{
-	CollectionById, CollectionHandle,
+	CollectionById,
 	dispatch::CollectionDispatch,
 	erc::{
 		CollectionHelpersEvents,
 		static_property::{key, value as property_value},
 	},
-	Pallet as PalletCommon,
 };
 use pallet_evm_coder_substrate::{SubstrateRecorder, WithRecorder};
 use pallet_evm::{account::CrossAccountId, OnMethodCall, PrecompileHandle, PrecompileResult};
-use pallet_evm_coder_substrate::dispatch_to_evm;
 use up_data_structs::{
 	CollectionName, CollectionDescription, CollectionTokenPrefix, CreateCollectionData,
-	CollectionMode, PropertyKeyPermission, PropertyPermission, PropertyScope, PropertyValue,
+	CollectionMode, PropertyValue,
 };
 
 use crate::{Config, SelfWeightOf, weights::WeightInfo};
 
-use sp_std::{vec, vec::Vec};
+use sp_std::vec::Vec;
 use alloc::format;
 
 /// See [`CollectionHelpersCall`]
modifiedruntime/common/ethereum/sponsoring.rsdiffbeforeafterboth
--- a/runtime/common/ethereum/sponsoring.rs
+++ b/runtime/common/ethereum/sponsoring.rs
@@ -34,7 +34,6 @@
 };
 use pallet_refungible::Config as RefungibleConfig;
 use pallet_unique::Config as UniqueConfig;
-use sp_core::H160;
 use sp_std::prelude::*;
 use up_data_structs::{CollectionMode, CreateItemData, CreateNftData, TokenId};
 use up_sponsorship::SponsorshipHandler;
@@ -48,18 +47,16 @@
 
 pub struct UniqueEthSponsorshipHandler<T: UniqueConfig>(PhantomData<*const T>);
 impl<T: UniqueConfig + FungibleConfig + NonfungibleConfig + RefungibleConfig>
-	SponsorshipHandler<T::CrossAccountId, (H160, Vec<u8>), CallContext>
-	for UniqueEthSponsorshipHandler<T>
+	SponsorshipHandler<T::CrossAccountId, CallContext> for UniqueEthSponsorshipHandler<T>
 {
 	fn get_sponsor(
 		who: &T::CrossAccountId,
-		call: &(H160, Vec<u8>),
-		_fee_limit: &CallContext,
+		call_context: &CallContext,
 	) -> Option<T::CrossAccountId> {
-		let collection_id = map_eth_to_id(&call.0)?;
+		let collection_id = map_eth_to_id(&call_context.contract_address)?;
 		let collection = <CollectionHandle<T>>::new(collection_id)?;
 		let sponsor = collection.sponsorship.sponsor()?.clone();
-		let (method_id, mut reader) = AbiReader::new_call(&call.1).ok()?;
+		let (method_id, mut reader) = AbiReader::new_call(&call_context.input).ok()?;
 		Some(T::CrossAccountId::from_sub(match &collection.mode {
 			CollectionMode::NFT => {
 				let call = <UniqueNFTCall<T>>::parse(method_id, &mut reader).ok()??;
modifiedruntime/common/sponsoring.rsdiffbeforeafterboth
--- a/runtime/common/sponsoring.rs
+++ b/runtime/common/sponsoring.rs
@@ -224,12 +224,12 @@
 }
 
 pub struct UniqueSponsorshipHandler<T>(PhantomData<T>);
-impl<T, C> SponsorshipHandler<T::AccountId, C, ()> for UniqueSponsorshipHandler<T>
+impl<T, C> SponsorshipHandler<T::AccountId, C> for UniqueSponsorshipHandler<T>
 where
 	T: Config,
 	C: IsSubType<UniqueCall<T>>,
 {
-	fn get_sponsor(who: &T::AccountId, call: &C, _call_context: &()) -> Option<T::AccountId> {
+	fn get_sponsor(who: &T::AccountId, call: &C) -> Option<T::AccountId> {
 		match IsSubType::<UniqueCall<T>>::is_sub_type(call)? {
 			UniqueCall::set_token_properties {
 				collection_id,
modifiedruntime/opal/Cargo.tomldiffbeforeafterboth
--- a/runtime/opal/Cargo.toml
+++ b/runtime/opal/Cargo.toml
@@ -431,7 +431,7 @@
 pallet-proxy-rmrk-equip = { default-features = false, path = "../../pallets/proxy-rmrk-equip", package = "pallet-rmrk-equip" }
 pallet-unique-scheduler = { path = '../../pallets/scheduler', default-features = false }
 # pallet-contract-helpers = { path = '../pallets/contract-helpers', default-features = false, version = '0.1.0' }
-pallet-charge-transaction = { git = "https://github.com/uniquenetwork/pallet-sponsoring", rev="9ee7d6e57e03a2575cbab79431774b56f170018e", package = "pallet-template-transaction-payment", default-features = false, version = "3.0.0" }
+pallet-charge-transaction = { git = "https://github.com/uniquenetwork/pallet-sponsoring", branch = "polkadot-v0.9.27", package = "pallet-template-transaction-payment", default-features = false, version = "3.0.0" }
 pallet-evm-migration = { path = '../../pallets/evm-migration', default-features = false }
 pallet-evm-contract-helpers = { path = '../../pallets/evm-contract-helpers', default-features = false }
 pallet-evm-transaction-payment = { path = '../../pallets/evm-transaction-payment', default-features = false }
@@ -442,7 +442,7 @@
 fp-rpc = { default-features = false, git = "https://github.com/uniquenetwork/frontier", rev = "89a37c5a489f426cc7a42d7b94019974093a052d" }
 fp-self-contained = { default-features = false, git = "https://github.com/uniquenetwork/frontier", rev = "89a37c5a489f426cc7a42d7b94019974093a052d" }
 evm-coder = { default-features = false, path = '../../crates/evm-coder' }
-up-sponsorship = { default-features = false, git = "https://github.com/uniquenetwork/pallet-sponsoring", rev="9ee7d6e57e03a2575cbab79431774b56f170018e" }
+up-sponsorship = { default-features = false, git = "https://github.com/uniquenetwork/pallet-sponsoring", branch = "polkadot-v0.9.27" }
 
 ################################################################################
 # Build Dependencies
modifiedruntime/quartz/Cargo.tomldiffbeforeafterboth
--- a/runtime/quartz/Cargo.toml
+++ b/runtime/quartz/Cargo.toml
@@ -432,7 +432,7 @@
 pallet-proxy-rmrk-equip = { default-features = false, path = "../../pallets/proxy-rmrk-equip", package = "pallet-rmrk-equip" }
 pallet-unique-scheduler = { path = '../../pallets/scheduler', default-features = false }
 # pallet-contract-helpers = { path = '../pallets/contract-helpers', default-features = false, version = '0.1.0' }
-pallet-charge-transaction = { git = "https://github.com/uniquenetwork/pallet-sponsoring", rev="9ee7d6e57e03a2575cbab79431774b56f170018e", package = "pallet-template-transaction-payment", default-features = false, version = "3.0.0" }
+pallet-charge-transaction = { git = "https://github.com/uniquenetwork/pallet-sponsoring", branch = "polkadot-v0.9.27", package = "pallet-template-transaction-payment", default-features = false, version = "3.0.0" }
 pallet-evm-migration = { path = '../../pallets/evm-migration', default-features = false }
 pallet-evm-contract-helpers = { path = '../../pallets/evm-contract-helpers', default-features = false }
 pallet-evm-transaction-payment = { path = '../../pallets/evm-transaction-payment', default-features = false }
@@ -443,7 +443,7 @@
 fp-rpc = { default-features = false, git = "https://github.com/uniquenetwork/frontier", rev = "89a37c5a489f426cc7a42d7b94019974093a052d" }
 fp-self-contained = { default-features = false, git = "https://github.com/uniquenetwork/frontier", rev = "89a37c5a489f426cc7a42d7b94019974093a052d" }
 evm-coder = { default-features = false, path = '../../crates/evm-coder' }
-up-sponsorship = { default-features = false, git = "https://github.com/uniquenetwork/pallet-sponsoring", rev="9ee7d6e57e03a2575cbab79431774b56f170018e" }
+up-sponsorship = { default-features = false, git = "https://github.com/uniquenetwork/pallet-sponsoring", branch = "polkadot-v0.9.27" }
 
 ################################################################################
 # Build Dependencies
modifiedruntime/tests/Cargo.tomldiffbeforeafterboth
--- a/runtime/tests/Cargo.toml
+++ b/runtime/tests/Cargo.toml
@@ -43,4 +43,4 @@
 scale-info = "*"
 
 evm-coder = { default-features = false, path = '../../crates/evm-coder' }
-up-sponsorship = { default-features = false, git = "https://github.com/uniquenetwork/pallet-sponsoring", rev="9ee7d6e57e03a2575cbab79431774b56f170018e" }
+up-sponsorship = { default-features = false, git = "https://github.com/uniquenetwork/pallet-sponsoring", branch = "polkadot-v0.9.27" }
modifiedruntime/unique/Cargo.tomldiffbeforeafterboth
--- a/runtime/unique/Cargo.toml
+++ b/runtime/unique/Cargo.toml
@@ -425,7 +425,7 @@
 pallet-proxy-rmrk-equip = { default-features = false, path = "../../pallets/proxy-rmrk-equip", package = "pallet-rmrk-equip" }
 pallet-unique-scheduler = { path = '../../pallets/scheduler', default-features = false }
 # pallet-contract-helpers = { path = '../pallets/contract-helpers', default-features = false, version = '0.1.0' }
-pallet-charge-transaction = { git = "https://github.com/uniquenetwork/pallet-sponsoring", rev="9ee7d6e57e03a2575cbab79431774b56f170018e", package = "pallet-template-transaction-payment", default-features = false, version = "3.0.0" }
+pallet-charge-transaction = { git = "https://github.com/uniquenetwork/pallet-sponsoring", branch = "polkadot-v0.9.27", package = "pallet-template-transaction-payment", default-features = false, version = "3.0.0" }
 pallet-evm-migration = { path = '../../pallets/evm-migration', default-features = false }
 pallet-evm-contract-helpers = { path = '../../pallets/evm-contract-helpers', default-features = false }
 pallet-evm-transaction-payment = { path = '../../pallets/evm-transaction-payment', default-features = false }
@@ -437,7 +437,7 @@
 fp-self-contained = { default-features = false, git = "https://github.com/uniquenetwork/frontier", rev = "89a37c5a489f426cc7a42d7b94019974093a052d" }
 fp-evm-mapping = { default-features = false, git = "https://github.com/uniquenetwork/frontier", rev = "89a37c5a489f426cc7a42d7b94019974093a052d" }
 evm-coder = { default-features = false, path = '../../crates/evm-coder' }
-up-sponsorship = { default-features = false, git = "https://github.com/uniquenetwork/pallet-sponsoring", rev="9ee7d6e57e03a2575cbab79431774b56f170018e" }
+up-sponsorship = { default-features = false, git = "https://github.com/uniquenetwork/pallet-sponsoring", branch = "polkadot-v0.9.27" }
 
 ################################################################################
 # Build Dependencies