difftreelog
chore replace u128 with CallContext
in: master
19 files changed
Cargo.lockdiffbeforeafterboth--- a/Cargo.lock
+++ b/Cargo.lock
@@ -5794,6 +5794,7 @@
"pallet-common",
"pallet-evm 6.0.0-dev (git+https://github.com/uniquenetwork/frontier?rev=89a37c5a489f426cc7a42d7b94019974093a052d)",
"pallet-evm-coder-substrate",
+ "pallet-evm-transaction-payment",
"parity-scale-codec 3.1.5",
"scale-info",
"sp-core",
@@ -6409,7 +6410,7 @@
[[package]]
name = "pallet-template-transaction-payment"
version = "3.0.0"
-source = "git+https://github.com/uniquenetwork/pallet-sponsoring?rev=a8ec4bf8d5ded662d96da6d8fb211b0bbf6617b3#a8ec4bf8d5ded662d96da6d8fb211b0bbf6617b3"
+source = "git+https://github.com/uniquenetwork/pallet-sponsoring?rev=9ee7d6e57e03a2575cbab79431774b56f170018e#9ee7d6e57e03a2575cbab79431774b56f170018e"
dependencies = [
"frame-benchmarking",
"frame-support",
@@ -12577,7 +12578,7 @@
[[package]]
name = "up-sponsorship"
version = "0.1.0"
-source = "git+https://github.com/uniquenetwork/pallet-sponsoring?rev=a8ec4bf8d5ded662d96da6d8fb211b0bbf6617b3#a8ec4bf8d5ded662d96da6d8fb211b0bbf6617b3"
+source = "git+https://github.com/uniquenetwork/pallet-sponsoring?rev=9ee7d6e57e03a2575cbab79431774b56f170018e#9ee7d6e57e03a2575cbab79431774b56f170018e"
dependencies = [
"impl-trait-for-tuples",
]
pallets/evm-contract-helpers/Cargo.tomldiffbeforeafterboth--- a/pallets/evm-contract-helpers/Cargo.toml
+++ b/pallets/evm-contract-helpers/Cargo.toml
@@ -21,12 +21,13 @@
# 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="a8ec4bf8d5ded662d96da6d8fb211b0bbf6617b3" }
+up-sponsorship = { version = "0.1.0", default-features = false, git = "https://github.com/uniquenetwork/pallet-sponsoring", rev="9ee7d6e57e03a2575cbab79431774b56f170018e" }
# Locals
evm-coder = { default-features = false, path = '../../crates/evm-coder' }
pallet-common = { default-features = false, path = '../../pallets/common' }
pallet-evm-coder-substrate = { default-features = false, path = '../../pallets/evm-coder-substrate' }
+pallet-evm-transaction-payment = { default-features = false, path = '../../pallets/evm-transaction-payment' }
up-data-structs = { default-features = false, path = '../../primitives/data-structs', features = [
'serde1',
] }
pallets/evm-contract-helpers/src/eth.rsdiffbeforeafterboth--- a/pallets/evm-contract-helpers/src/eth.rs
+++ b/pallets/evm-contract-helpers/src/eth.rs
@@ -20,12 +20,13 @@
use evm_coder::{
abi::AbiWriter, execution::Result, generate_stubgen, solidity_interface, types::*, ToLog,
};
-use pallet_evm_coder_substrate::{SubstrateRecorder, WithRecorder, dispatch_to_evm};
use pallet_evm::{
ExitRevert, OnCreate, OnMethodCall, PrecompileResult, PrecompileFailure, PrecompileHandle,
account::CrossAccountId,
};
-use sp_core::{H160, U256};
+use pallet_evm_coder_substrate::{SubstrateRecorder, WithRecorder, dispatch_to_evm};
+use pallet_evm_transaction_payment::CallContext;
+use sp_core::H160;
use up_data_structs::SponsorshipState;
use crate::{
AllowlistEnabled, Config, Owner, Pallet, SponsorBasket, SponsoringFeeLimit,
@@ -254,17 +255,15 @@
&mut self,
caller: caller,
contract_address: address,
- fee_limit: uint128,
+ fee_limit: uint256,
) -> Result<void> {
<Pallet<T>>::ensure_owner(contract_address, caller).map_err(dispatch_to_evm::<T>)?;
<Pallet<T>>::set_sponsoring_fee_limit(contract_address, fee_limit.into());
Ok(())
}
- fn get_sponsoring_fee_limit(&self, contract_address: address) -> Result<uint128> {
- Ok(<SponsoringFeeLimit<T>>::get(contract_address)
- .try_into()
- .map_err(|_| "fee limit > u128::MAX")?)
+ fn get_sponsoring_fee_limit(&self, contract_address: address) -> Result<uint256> {
+ Ok(<SponsoringFeeLimit<T>>::get(contract_address))
}
/// Is specified user present in contract allow list
@@ -380,13 +379,13 @@
/// Bridge to pallet-sponsoring
pub struct HelpersContractSponsoring<T: Config>(PhantomData<*const T>);
-impl<T: Config> SponsorshipHandler<T::CrossAccountId, (H160, Vec<u8>), u128>
+impl<T: Config> SponsorshipHandler<T::CrossAccountId, (H160, Vec<u8>), CallContext>
for HelpersContractSponsoring<T>
{
fn get_sponsor(
who: &T::CrossAccountId,
call: &(H160, Vec<u8>),
- fee_limit: &u128,
+ call_context: &CallContext,
) -> Option<T::CrossAccountId> {
let (contract_address, _) = call;
let mode = <Pallet<T>>::sponsoring_mode(*contract_address);
@@ -417,7 +416,7 @@
let sponsored_fee_limit = <SponsoringFeeLimit<T>>::get(contract_address);
- if *fee_limit > sponsored_fee_limit {
+ if call_context.max_fee > sponsored_fee_limit {
return None;
}
pallets/evm-contract-helpers/src/lib.rsdiffbeforeafterboth--- a/pallets/evm-contract-helpers/src/lib.rs
+++ b/pallets/evm-contract-helpers/src/lib.rs
@@ -30,7 +30,7 @@
use crate::eth::ContractHelpersEvents;
use frame_support::pallet_prelude::*;
use pallet_evm_coder_substrate::DispatchResult;
- use sp_core::H160;
+ use sp_core::{H160, U256};
use pallet_evm::{account::CrossAccountId, Pallet as PalletEvm};
use up_data_structs::SponsorshipState;
use evm_coder::ToLog;
@@ -50,7 +50,7 @@
type DefaultSponsoringRateLimit: Get<Self::BlockNumber>;
/// In case of enabled sponsoring, but no sponsoring fee limit set,
/// this value will be used implicitly
- type DefaultSponsoringFeeLimit: Get<u128>;
+ type DefaultSponsoringFeeLimit: Get<U256>;
}
#[pallet::error]
@@ -124,7 +124,7 @@
pub(super) type SponsoringFeeLimit<T: Config> = StorageMap<
Hasher = Twox128,
Key = H160,
- Value = u128,
+ Value = U256,
QueryKind = ValueQuery,
OnEmpty = T::DefaultSponsoringFeeLimit,
>;
@@ -366,7 +366,7 @@
}
/// Set maximum for gas limit of transaction
- pub fn set_sponsoring_fee_limit(contract: H160, fee_limit: u128) {
+ pub fn set_sponsoring_fee_limit(contract: H160, fee_limit: U256) {
<SponsoringFeeLimit<T>>::insert(contract, fee_limit);
}
pallets/evm-contract-helpers/src/stubs/ContractHelpers.rawdiffbeforeafterbothbinary blob — no preview
pallets/evm-contract-helpers/src/stubs/ContractHelpers.soldiffbeforeafterboth1// SPDX-License-Identifier: OTHER2// This code is automatically generated34pragma solidity >=0.8.0 <0.9.0;56/// @dev common stubs holder7contract Dummy {8 uint8 dummy;9 string stub_error = "this contract is implemented in native";10}1112contract ERC165 is Dummy {13 function supportsInterface(bytes4 interfaceID)14 external15 view16 returns (bool)17 {18 require(false, stub_error);19 interfaceID;20 return true;21 }22}2324/// @dev inlined interface25contract ContractHelpersEvents {26 event ContractSponsorSet(address indexed contractAddress, address sponsor);27 event ContractSponsorshipConfirmed(28 address indexed contractAddress,29 address sponsor30 );31 event ContractSponsorRemoved(address indexed contractAddress);32}3334/// @title Magic contract, which allows users to reconfigure other contracts35/// @dev the ERC-165 identifier for this interface is 0xd77fab7036contract ContractHelpers is Dummy, ERC165, ContractHelpersEvents {37 /// Get user, which deployed specified contract38 /// @dev May return zero address in case if contract is deployed39 /// using uniquenetwork evm-migration pallet, or using other terms not40 /// intended by pallet-evm41 /// @dev Returns zero address if contract does not exists42 /// @param contractAddress Contract to get owner of43 /// @return address Owner of contract44 /// @dev EVM selector for this function is: 0x5152b14c,45 /// or in textual repr: contractOwner(address)46 function contractOwner(address contractAddress)47 public48 view49 returns (address)50 {51 require(false, stub_error);52 contractAddress;53 dummy;54 return 0x0000000000000000000000000000000000000000;55 }5657 /// Set sponsor.58 /// @param contractAddress Contract for which a sponsor is being established.59 /// @param sponsor User address who set as pending sponsor.60 /// @dev EVM selector for this function is: 0xf01fba93,61 /// or in textual repr: setSponsor(address,address)62 function setSponsor(address contractAddress, address sponsor) public {63 require(false, stub_error);64 contractAddress;65 sponsor;66 dummy = 0;67 }6869 /// Set contract as self sponsored.70 ///71 /// @param contractAddress Contract for which a self sponsoring is being enabled.72 /// @dev EVM selector for this function is: 0x89f7d9ae,73 /// or in textual repr: selfSponsoredEnable(address)74 function selfSponsoredEnable(address contractAddress) public {75 require(false, stub_error);76 contractAddress;77 dummy = 0;78 }7980 /// Remove sponsor.81 ///82 /// @param contractAddress Contract for which a sponsorship is being removed.83 /// @dev EVM selector for this function is: 0xef784250,84 /// or in textual repr: removeSponsor(address)85 function removeSponsor(address contractAddress) public {86 require(false, stub_error);87 contractAddress;88 dummy = 0;89 }9091 /// Confirm sponsorship.92 ///93 /// @dev Caller must be same that set via [`setSponsor`].94 ///95 /// @param contractAddress Сontract for which need to confirm sponsorship.96 /// @dev EVM selector for this function is: 0xabc00001,97 /// or in textual repr: confirmSponsorship(address)98 function confirmSponsorship(address contractAddress) public {99 require(false, stub_error);100 contractAddress;101 dummy = 0;102 }103104 /// Get current sponsor.105 ///106 /// @param contractAddress The contract for which a sponsor is requested.107 /// @return Tuble with sponsor address and his substrate mirror. If there is no confirmed sponsor error "Contract has no sponsor" throw.108 /// @dev EVM selector for this function is: 0x743fc745,109 /// or in textual repr: getSponsor(address)110 function getSponsor(address contractAddress)111 public112 view113 returns (Tuple0 memory)114 {115 require(false, stub_error);116 contractAddress;117 dummy;118 return Tuple0(0x0000000000000000000000000000000000000000, 0);119 }120121 /// Check tat contract has confirmed sponsor.122 ///123 /// @param contractAddress The contract for which the presence of a confirmed sponsor is checked.124 /// @return **true** if contract has confirmed sponsor.125 /// @dev EVM selector for this function is: 0x97418603,126 /// or in textual repr: hasSponsor(address)127 function hasSponsor(address contractAddress) public view returns (bool) {128 require(false, stub_error);129 contractAddress;130 dummy;131 return false;132 }133134 /// Check tat contract has pending sponsor.135 ///136 /// @param contractAddress The contract for which the presence of a pending sponsor is checked.137 /// @return **true** if contract has pending sponsor.138 /// @dev EVM selector for this function is: 0x39b9b242,139 /// or in textual repr: hasPendingSponsor(address)140 function hasPendingSponsor(address contractAddress)141 public142 view143 returns (bool)144 {145 require(false, stub_error);146 contractAddress;147 dummy;148 return false;149 }150151 /// @dev EVM selector for this function is: 0x6027dc61,152 /// or in textual repr: sponsoringEnabled(address)153 function sponsoringEnabled(address contractAddress)154 public155 view156 returns (bool)157 {158 require(false, stub_error);159 contractAddress;160 dummy;161 return false;162 }163164 /// @dev EVM selector for this function is: 0xfde8a560,165 /// or in textual repr: setSponsoringMode(address,uint8)166 function setSponsoringMode(address contractAddress, uint8 mode) public {167 require(false, stub_error);168 contractAddress;169 mode;170 dummy = 0;171 }172173 /// Get current contract sponsoring rate limit174 /// @param contractAddress Contract to get sponsoring mode of175 /// @return uint32 Amount of blocks between two sponsored transactions176 /// @dev EVM selector for this function is: 0x610cfabd,177 /// or in textual repr: getSponsoringRateLimit(address)178 function getSponsoringRateLimit(address contractAddress)179 public180 view181 returns (uint32)182 {183 require(false, stub_error);184 contractAddress;185 dummy;186 return 0;187 }188189 /// Set contract sponsoring rate limit190 /// @dev Sponsoring rate limit - is a minimum amount of blocks that should191 /// pass between two sponsored transactions192 /// @param contractAddress Contract to change sponsoring rate limit of193 /// @param rateLimit Target rate limit194 /// @dev Only contract owner can change this setting195 /// @dev EVM selector for this function is: 0x77b6c908,196 /// or in textual repr: setSponsoringRateLimit(address,uint32)197 function setSponsoringRateLimit(address contractAddress, uint32 rateLimit)198 public199 {200 require(false, stub_error);201 contractAddress;202 rateLimit;203 dummy = 0;204 }205206 /// @dev EVM selector for this function is: 0x1c362eb4,207 /// or in textual repr: setSponsoringFeeLimit(address,uint128)208 function setSponsoringFeeLimit(address contractAddress, uint128 feeLimit)209 public210 {211 require(false, stub_error);212 contractAddress;213 feeLimit;214 dummy = 0;215 }216217 /// @dev EVM selector for this function is: 0xc3fdc9ee,218 /// or in textual repr: getSponsoringFeeLimit(address)219 function getSponsoringFeeLimit(address contractAddress)220 public221 view222 returns (uint128)223 {224 require(false, stub_error);225 contractAddress;226 dummy;227 return 0;228 }229230 /// Is specified user present in contract allow list231 /// @dev Contract owner always implicitly included232 /// @param contractAddress Contract to check allowlist of233 /// @param user User to check234 /// @return bool Is specified users exists in contract allowlist235 /// @dev EVM selector for this function is: 0x5c658165,236 /// or in textual repr: allowed(address,address)237 function allowed(address contractAddress, address user)238 public239 view240 returns (bool)241 {242 require(false, stub_error);243 contractAddress;244 user;245 dummy;246 return false;247 }248249 /// Toggle user presence in contract allowlist250 /// @param contractAddress Contract to change allowlist of251 /// @param user Which user presence should be toggled252 /// @param isAllowed `true` if user should be allowed to be sponsored253 /// or call this contract, `false` otherwise254 /// @dev Only contract owner can change this setting255 /// @dev EVM selector for this function is: 0x4706cc1c,256 /// or in textual repr: toggleAllowed(address,address,bool)257 function toggleAllowed(258 address contractAddress,259 address user,260 bool isAllowed261 ) public {262 require(false, stub_error);263 contractAddress;264 user;265 isAllowed;266 dummy = 0;267 }268269 /// Is this contract has allowlist access enabled270 /// @dev Allowlist always can have users, and it is used for two purposes:271 /// in case of allowlist sponsoring mode, users will be sponsored if they exist in allowlist272 /// in case of allowlist access enabled, only users from allowlist may call this contract273 /// @param contractAddress Contract to get allowlist access of274 /// @return bool Is specified contract has allowlist access enabled275 /// @dev EVM selector for this function is: 0xc772ef6c,276 /// or in textual repr: allowlistEnabled(address)277 function allowlistEnabled(address contractAddress)278 public279 view280 returns (bool)281 {282 require(false, stub_error);283 contractAddress;284 dummy;285 return false;286 }287288 /// Toggle contract allowlist access289 /// @param contractAddress Contract to change allowlist access of290 /// @param enabled Should allowlist access to be enabled?291 /// @dev EVM selector for this function is: 0x36de20f5,292 /// or in textual repr: toggleAllowlist(address,bool)293 function toggleAllowlist(address contractAddress, bool enabled) public {294 require(false, stub_error);295 contractAddress;296 enabled;297 dummy = 0;298 }299}300301/// @dev anonymous struct302struct Tuple0 {303 address field_0;304 uint256 field_1;305}1// SPDX-License-Identifier: OTHER2// This code is automatically generated34pragma solidity >=0.8.0 <0.9.0;56/// @dev common stubs holder7contract Dummy {8 uint8 dummy;9 string stub_error = "this contract is implemented in native";10}1112contract ERC165 is Dummy {13 function supportsInterface(bytes4 interfaceID)14 external15 view16 returns (bool)17 {18 require(false, stub_error);19 interfaceID;20 return true;21 }22}2324/// @dev inlined interface25contract ContractHelpersEvents {26 event ContractSponsorSet(address indexed contractAddress, address sponsor);27 event ContractSponsorshipConfirmed(28 address indexed contractAddress,29 address sponsor30 );31 event ContractSponsorRemoved(address indexed contractAddress);32}3334/// @title Magic contract, which allows users to reconfigure other contracts35/// @dev the ERC-165 identifier for this interface is 0x172cb4fb36contract ContractHelpers is Dummy, ERC165, ContractHelpersEvents {37 /// Get user, which deployed specified contract38 /// @dev May return zero address in case if contract is deployed39 /// using uniquenetwork evm-migration pallet, or using other terms not40 /// intended by pallet-evm41 /// @dev Returns zero address if contract does not exists42 /// @param contractAddress Contract to get owner of43 /// @return address Owner of contract44 /// @dev EVM selector for this function is: 0x5152b14c,45 /// or in textual repr: contractOwner(address)46 function contractOwner(address contractAddress)47 public48 view49 returns (address)50 {51 require(false, stub_error);52 contractAddress;53 dummy;54 return 0x0000000000000000000000000000000000000000;55 }5657 /// Set sponsor.58 /// @param contractAddress Contract for which a sponsor is being established.59 /// @param sponsor User address who set as pending sponsor.60 /// @dev EVM selector for this function is: 0xf01fba93,61 /// or in textual repr: setSponsor(address,address)62 function setSponsor(address contractAddress, address sponsor) public {63 require(false, stub_error);64 contractAddress;65 sponsor;66 dummy = 0;67 }6869 /// Set contract as self sponsored.70 ///71 /// @param contractAddress Contract for which a self sponsoring is being enabled.72 /// @dev EVM selector for this function is: 0x89f7d9ae,73 /// or in textual repr: selfSponsoredEnable(address)74 function selfSponsoredEnable(address contractAddress) public {75 require(false, stub_error);76 contractAddress;77 dummy = 0;78 }7980 /// Remove sponsor.81 ///82 /// @param contractAddress Contract for which a sponsorship is being removed.83 /// @dev EVM selector for this function is: 0xef784250,84 /// or in textual repr: removeSponsor(address)85 function removeSponsor(address contractAddress) public {86 require(false, stub_error);87 contractAddress;88 dummy = 0;89 }9091 /// Confirm sponsorship.92 ///93 /// @dev Caller must be same that set via [`setSponsor`].94 ///95 /// @param contractAddress Сontract for which need to confirm sponsorship.96 /// @dev EVM selector for this function is: 0xabc00001,97 /// or in textual repr: confirmSponsorship(address)98 function confirmSponsorship(address contractAddress) public {99 require(false, stub_error);100 contractAddress;101 dummy = 0;102 }103104 /// Get current sponsor.105 ///106 /// @param contractAddress The contract for which a sponsor is requested.107 /// @return Tuble with sponsor address and his substrate mirror. If there is no confirmed sponsor error "Contract has no sponsor" throw.108 /// @dev EVM selector for this function is: 0x743fc745,109 /// or in textual repr: getSponsor(address)110 function getSponsor(address contractAddress)111 public112 view113 returns (Tuple0 memory)114 {115 require(false, stub_error);116 contractAddress;117 dummy;118 return Tuple0(0x0000000000000000000000000000000000000000, 0);119 }120121 /// Check tat contract has confirmed sponsor.122 ///123 /// @param contractAddress The contract for which the presence of a confirmed sponsor is checked.124 /// @return **true** if contract has confirmed sponsor.125 /// @dev EVM selector for this function is: 0x97418603,126 /// or in textual repr: hasSponsor(address)127 function hasSponsor(address contractAddress) public view returns (bool) {128 require(false, stub_error);129 contractAddress;130 dummy;131 return false;132 }133134 /// Check tat contract has pending sponsor.135 ///136 /// @param contractAddress The contract for which the presence of a pending sponsor is checked.137 /// @return **true** if contract has pending sponsor.138 /// @dev EVM selector for this function is: 0x39b9b242,139 /// or in textual repr: hasPendingSponsor(address)140 function hasPendingSponsor(address contractAddress)141 public142 view143 returns (bool)144 {145 require(false, stub_error);146 contractAddress;147 dummy;148 return false;149 }150151 /// @dev EVM selector for this function is: 0x6027dc61,152 /// or in textual repr: sponsoringEnabled(address)153 function sponsoringEnabled(address contractAddress)154 public155 view156 returns (bool)157 {158 require(false, stub_error);159 contractAddress;160 dummy;161 return false;162 }163164 /// @dev EVM selector for this function is: 0xfde8a560,165 /// or in textual repr: setSponsoringMode(address,uint8)166 function setSponsoringMode(address contractAddress, uint8 mode) public {167 require(false, stub_error);168 contractAddress;169 mode;170 dummy = 0;171 }172173 /// Get current contract sponsoring rate limit174 /// @param contractAddress Contract to get sponsoring mode of175 /// @return uint32 Amount of blocks between two sponsored transactions176 /// @dev EVM selector for this function is: 0x610cfabd,177 /// or in textual repr: getSponsoringRateLimit(address)178 function getSponsoringRateLimit(address contractAddress)179 public180 view181 returns (uint32)182 {183 require(false, stub_error);184 contractAddress;185 dummy;186 return 0;187 }188189 /// Set contract sponsoring rate limit190 /// @dev Sponsoring rate limit - is a minimum amount of blocks that should191 /// pass between two sponsored transactions192 /// @param contractAddress Contract to change sponsoring rate limit of193 /// @param rateLimit Target rate limit194 /// @dev Only contract owner can change this setting195 /// @dev EVM selector for this function is: 0x77b6c908,196 /// or in textual repr: setSponsoringRateLimit(address,uint32)197 function setSponsoringRateLimit(address contractAddress, uint32 rateLimit)198 public199 {200 require(false, stub_error);201 contractAddress;202 rateLimit;203 dummy = 0;204 }205206 /// @dev EVM selector for this function is: 0x03aed665,207 /// or in textual repr: setSponsoringFeeLimit(address,uint256)208 function setSponsoringFeeLimit(address contractAddress, uint256 feeLimit)209 public210 {211 require(false, stub_error);212 contractAddress;213 feeLimit;214 dummy = 0;215 }216217 /// @dev EVM selector for this function is: 0xc3fdc9ee,218 /// or in textual repr: getSponsoringFeeLimit(address)219 function getSponsoringFeeLimit(address contractAddress)220 public221 view222 returns (uint256)223 {224 require(false, stub_error);225 contractAddress;226 dummy;227 return 0;228 }229230 /// Is specified user present in contract allow list231 /// @dev Contract owner always implicitly included232 /// @param contractAddress Contract to check allowlist of233 /// @param user User to check234 /// @return bool Is specified users exists in contract allowlist235 /// @dev EVM selector for this function is: 0x5c658165,236 /// or in textual repr: allowed(address,address)237 function allowed(address contractAddress, address user)238 public239 view240 returns (bool)241 {242 require(false, stub_error);243 contractAddress;244 user;245 dummy;246 return false;247 }248249 /// Toggle user presence in contract allowlist250 /// @param contractAddress Contract to change allowlist of251 /// @param user Which user presence should be toggled252 /// @param isAllowed `true` if user should be allowed to be sponsored253 /// or call this contract, `false` otherwise254 /// @dev Only contract owner can change this setting255 /// @dev EVM selector for this function is: 0x4706cc1c,256 /// or in textual repr: toggleAllowed(address,address,bool)257 function toggleAllowed(258 address contractAddress,259 address user,260 bool isAllowed261 ) public {262 require(false, stub_error);263 contractAddress;264 user;265 isAllowed;266 dummy = 0;267 }268269 /// Is this contract has allowlist access enabled270 /// @dev Allowlist always can have users, and it is used for two purposes:271 /// in case of allowlist sponsoring mode, users will be sponsored if they exist in allowlist272 /// in case of allowlist access enabled, only users from allowlist may call this contract273 /// @param contractAddress Contract to get allowlist access of274 /// @return bool Is specified contract has allowlist access enabled275 /// @dev EVM selector for this function is: 0xc772ef6c,276 /// or in textual repr: allowlistEnabled(address)277 function allowlistEnabled(address contractAddress)278 public279 view280 returns (bool)281 {282 require(false, stub_error);283 contractAddress;284 dummy;285 return false;286 }287288 /// Toggle contract allowlist access289 /// @param contractAddress Contract to change allowlist access of290 /// @param enabled Should allowlist access to be enabled?291 /// @dev EVM selector for this function is: 0x36de20f5,292 /// or in textual repr: toggleAllowlist(address,bool)293 function toggleAllowlist(address contractAddress, bool enabled) public {294 require(false, stub_error);295 contractAddress;296 enabled;297 dummy = 0;298 }299}300301/// @dev anonymous struct302struct Tuple0 {303 address field_0;304 uint256 field_1;305}pallets/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 = "a8ec4bf8d5ded662d96da6d8fb211b0bbf6617b3" }
+up-sponsorship = { version = "0.1.0", default-features = false, git = "https://github.com/uniquenetwork/pallet-sponsoring", rev = "9ee7d6e57e03a2575cbab79431774b56f170018e" }
fp-evm-mapping = { default-features = false, git = "https://github.com/uniquenetwork/frontier", rev = "89a37c5a489f426cc7a42d7b94019974093a052d" }
[dependencies.codec]
pallets/evm-transaction-payment/src/lib.rsdiffbeforeafterboth--- a/pallets/evm-transaction-payment/src/lib.rs
+++ b/pallets/evm-transaction-payment/src/lib.rs
@@ -22,7 +22,7 @@
use fp_evm::WithdrawReason;
use frame_support::traits::IsSubType;
pub use pallet::*;
-use pallet_evm::{account::CrossAccountId, EnsureAddressOrigin, FeeCalculator};
+use pallet_evm::{account::CrossAccountId, EnsureAddressOrigin};
use sp_core::{H160, U256};
use sp_runtime::{TransactionOutcome, DispatchError};
use up_sponsorship::SponsorshipHandler;
@@ -33,10 +33,20 @@
use sp_std::vec::Vec;
+ /// Contains call data
+ pub struct CallContext {
+ /// Max fee for transaction - gasLimit * gasPrice
+ pub max_fee: U256,
+ }
+
#[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>), u128>;
+ type EvmSponsorshipHandler: SponsorshipHandler<
+ Self::CrossAccountId,
+ (H160, Vec<u8>),
+ CallContext,
+ >;
}
#[pallet::pallet]
@@ -55,10 +65,11 @@
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()),
- &max_fee.as_u128(),
+ &call_context,
)
}
_ => None,
@@ -68,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, u128> 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, _fee_limit: &u128) -> Option<T::AccountId> {
+ fn get_sponsor(who: &T::AccountId, call: &C, _call_context: &()) -> Option<T::AccountId> {
match call.is_sub_type()? {
pallet_evm::Call::call {
source,
@@ -90,6 +101,7 @@
.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 };
// 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(|| {
@@ -97,7 +109,7 @@
T::EvmSponsorshipHandler::get_sponsor(
&who,
&(*target, input.clone()),
- &max_fee.try_into().unwrap(),
+ &call_context,
),
))
})
pallets/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="a8ec4bf8d5ded662d96da6d8fb211b0bbf6617b3" }
+up-sponsorship = { version = "0.1.0", default-features = false, git = "https://github.com/uniquenetwork/pallet-sponsoring", rev="9ee7d6e57e03a2575cbab79431774b56f170018e" }
log = { version = "0.4.14", default-features = false }
[dev-dependencies]
runtime/common/config/sponsoring.rsdiffbeforeafterboth--- a/runtime/common/config/sponsoring.rs
+++ b/runtime/common/config/sponsoring.rs
@@ -14,16 +14,17 @@
// You should have received a copy of the GNU General Public License
// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.
-use frame_support::parameter_types;
use crate::{
runtime_common::{sponsoring::UniqueSponsorshipHandler},
Runtime,
};
-use up_common::{types::BlockNumber, constants::*};
+use frame_support::parameter_types;
+use sp_core::U256;
+use up_common::{constants::*, types::BlockNumber};
parameter_types! {
pub const DefaultSponsoringRateLimit: BlockNumber = 1 * DAYS;
- pub const DefaultSponsoringFeeLimit: u128 = u128::MAX;
+ pub const DefaultSponsoringFeeLimit: U256 = U256::MAX;
}
type SponsorshipHandler = (
runtime/common/ethereum/sponsoring.rsdiffbeforeafterboth--- a/runtime/common/ethereum/sponsoring.rs
+++ b/runtime/common/ethereum/sponsoring.rs
@@ -16,27 +16,31 @@
//! Implements EVM sponsoring logic via TransactionValidityHack
+use core::{convert::TryInto, marker::PhantomData};
use evm_coder::{Call, abi::AbiReader};
use pallet_common::{CollectionHandle, eth::map_eth_to_id};
+use pallet_evm::account::CrossAccountId;
+use pallet_evm_transaction_payment::CallContext;
+use pallet_nonfungible::{
+ Config as NonfungibleConfig,
+ erc::{
+ UniqueNFTCall, ERC721UniqueExtensionsCall, ERC721MintableCall, ERC721Call,
+ TokenPropertiesCall,
+ },
+};
+use pallet_fungible::{
+ Config as FungibleConfig,
+ erc::{UniqueFungibleCall, ERC20Call},
+};
+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;
-use core::marker::PhantomData;
-use core::convert::TryInto;
-use pallet_evm::account::CrossAccountId;
-use up_data_structs::{TokenId, CreateItemData, CreateNftData, CollectionMode};
-use pallet_unique::Config as UniqueConfig;
use crate::{Runtime, runtime_common::sponsoring::*};
-use pallet_nonfungible::erc::{
- UniqueNFTCall, ERC721UniqueExtensionsCall, ERC721MintableCall, ERC721Call, TokenPropertiesCall,
-};
-use pallet_fungible::erc::{UniqueFungibleCall, ERC20Call};
-use pallet_fungible::Config as FungibleConfig;
-use pallet_nonfungible::Config as NonfungibleConfig;
-use pallet_refungible::Config as RefungibleConfig;
-
pub type EvmSponsorshipHandler = (
UniqueEthSponsorshipHandler<Runtime>,
pallet_evm_contract_helpers::HelpersContractSponsoring<Runtime>,
@@ -44,12 +48,13 @@
pub struct UniqueEthSponsorshipHandler<T: UniqueConfig>(PhantomData<*const T>);
impl<T: UniqueConfig + FungibleConfig + NonfungibleConfig + RefungibleConfig>
- SponsorshipHandler<T::CrossAccountId, (H160, Vec<u8>), u128> for UniqueEthSponsorshipHandler<T>
+ SponsorshipHandler<T::CrossAccountId, (H160, Vec<u8>), CallContext>
+ for UniqueEthSponsorshipHandler<T>
{
fn get_sponsor(
who: &T::CrossAccountId,
call: &(H160, Vec<u8>),
- _fee_limit: &u128,
+ _fee_limit: &CallContext,
) -> Option<T::CrossAccountId> {
let collection_id = map_eth_to_id(&call.0)?;
let collection = <CollectionHandle<T>>::new(collection_id)?;
runtime/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, u128> 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, _fee_limit: &u128) -> Option<T::AccountId> {
+ fn get_sponsor(who: &T::AccountId, call: &C, _call_context: &()) -> Option<T::AccountId> {
match IsSubType::<UniqueCall<T>>::is_sub_type(call)? {
UniqueCall::set_token_properties {
collection_id,
runtime/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="a8ec4bf8d5ded662d96da6d8fb211b0bbf6617b3", package = "pallet-template-transaction-payment", default-features = false, version = "3.0.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-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="a8ec4bf8d5ded662d96da6d8fb211b0bbf6617b3" }
+up-sponsorship = { default-features = false, git = "https://github.com/uniquenetwork/pallet-sponsoring", rev="9ee7d6e57e03a2575cbab79431774b56f170018e" }
################################################################################
# Build Dependencies
runtime/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="a8ec4bf8d5ded662d96da6d8fb211b0bbf6617b3", package = "pallet-template-transaction-payment", default-features = false, version = "3.0.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-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="a8ec4bf8d5ded662d96da6d8fb211b0bbf6617b3" }
+up-sponsorship = { default-features = false, git = "https://github.com/uniquenetwork/pallet-sponsoring", rev="9ee7d6e57e03a2575cbab79431774b56f170018e" }
################################################################################
# Build Dependencies
runtime/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="a8ec4bf8d5ded662d96da6d8fb211b0bbf6617b3" }
+up-sponsorship = { default-features = false, git = "https://github.com/uniquenetwork/pallet-sponsoring", rev="9ee7d6e57e03a2575cbab79431774b56f170018e" }
runtime/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="a8ec4bf8d5ded662d96da6d8fb211b0bbf6617b3", package = "pallet-template-transaction-payment", default-features = false, version = "3.0.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-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="a8ec4bf8d5ded662d96da6d8fb211b0bbf6617b3" }
+up-sponsorship = { default-features = false, git = "https://github.com/uniquenetwork/pallet-sponsoring", rev="9ee7d6e57e03a2575cbab79431774b56f170018e" }
################################################################################
# Build Dependencies
tests/src/eth/api/ContractHelpers.soldiffbeforeafterboth--- a/tests/src/eth/api/ContractHelpers.sol
+++ b/tests/src/eth/api/ContractHelpers.sol
@@ -23,7 +23,7 @@
}
/// @title Magic contract, which allows users to reconfigure other contracts
-/// @dev the ERC-165 identifier for this interface is 0xd77fab70
+/// @dev the ERC-165 identifier for this interface is 0x172cb4fb
interface ContractHelpers is Dummy, ERC165, ContractHelpersEvents {
/// Get user, which deployed specified contract
/// @dev May return zero address in case if contract is deployed
@@ -131,9 +131,9 @@
function setSponsoringRateLimit(address contractAddress, uint32 rateLimit)
external;
- /// @dev EVM selector for this function is: 0x1c362eb4,
- /// or in textual repr: setSponsoringFeeLimit(address,uint128)
- function setSponsoringFeeLimit(address contractAddress, uint128 feeLimit)
+ /// @dev EVM selector for this function is: 0x03aed665,
+ /// or in textual repr: setSponsoringFeeLimit(address,uint256)
+ function setSponsoringFeeLimit(address contractAddress, uint256 feeLimit)
external;
/// @dev EVM selector for this function is: 0xc3fdc9ee,
@@ -141,7 +141,7 @@
function getSponsoringFeeLimit(address contractAddress)
external
view
- returns (uint128);
+ returns (uint256);
/// Is specified user present in contract allow list
/// @dev Contract owner always implicitly included
tests/src/eth/contractSponsoring.test.tsdiffbeforeafterboth--- a/tests/src/eth/contractSponsoring.test.ts
+++ b/tests/src/eth/contractSponsoring.test.ts
@@ -558,7 +558,7 @@
const owner = await createEthAccountWithBalance(api, web3, privateKeyWrapper);
const flipper = await deployFlipper(web3, owner);
const helpers = contractHelpers(web3, owner);
- expect(await helpers.methods.getSponsoringFeeLimit(flipper.options.address).call()).to.be.equals('340282366920938463463374607431768211455');
+ expect(await helpers.methods.getSponsoringFeeLimit(flipper.options.address).call()).to.be.equals('115792089237316195423570985008687907853269984665640564039457584007913129639935');
});
itWeb3('Set fee limit', async ({api, web3, privateKeyWrapper}) => {
tests/src/eth/util/contractHelpersAbi.jsondiffbeforeafterboth--- a/tests/src/eth/util/contractHelpersAbi.json
+++ b/tests/src/eth/util/contractHelpersAbi.json
@@ -135,7 +135,7 @@
}
],
"name": "getSponsoringFeeLimit",
- "outputs": [{ "internalType": "uint128", "name": "", "type": "uint128" }],
+ "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],
"stateMutability": "view",
"type": "function"
},
@@ -225,7 +225,7 @@
"name": "contractAddress",
"type": "address"
},
- { "internalType": "uint128", "name": "feeLimit", "type": "uint128" }
+ { "internalType": "uint256", "name": "feeLimit", "type": "uint256" }
],
"name": "setSponsoringFeeLimit",
"outputs": [],