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

difftreelog

fix PR

Trubnikov Sergey2023-02-02parent: #a06d0b8.patch.diff
in: master

4 files changed

modifiedpallets/fungible/src/erc.rsdiffbeforeafterboth
6// the Free Software Foundation, either version 3 of the License, or6// the Free Software Foundation, either version 3 of the License, or
7// (at your option) any later version.7// (at your option) any later version.
88
9// Unique Network is disaddress: tod in the hope that it will be useful,9// Unique Network is distributed in the hope that it will be useful,
10// but WITHOUT ANY WARRANTY; without even the implied warranty of10// but WITHOUT ANY WARRANTY; without even the implied warranty of
11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12// GNU General Public License for more details.12// GNU General Public License for more details.
28use pallet_common::{28use pallet_common::{
29 CollectionHandle,29 CollectionHandle,
30 erc::{CommonEvmHandler, PrecompileResult, CollectionCall},30 erc::{CommonEvmHandler, PrecompileResult, CollectionCall},
31 eth::CrossAddress,
31};32};
32use sp_std::vec::Vec;33use sp_std::vec::Vec;
33use pallet_evm::{account::CrossAccountId, PrecompileHandle};34use pallet_evm::{account::CrossAccountId, PrecompileHandle};
174 /// @return A uint256 specifying the amount of tokens still available for the spender.175 /// @return A uint256 specifying the amount of tokens still available for the spender.
175 fn allowance_cross(176 fn allowance_cross(&self, owner: CrossAddress, spender: CrossAddress) -> Result<U256> {
176 &self,
177 owner: pallet_common::eth::CrossAddress,
178 spender: pallet_common::eth::CrossAddress,
179 ) -> Result<U256> {
180 let owner = owner.into_sub_cross_account::<T>()?;177 let owner = owner.into_sub_cross_account::<T>()?;
181 let spender = spender.into_sub_cross_account::<T>()?;178 let spender = spender.into_sub_cross_account::<T>()?;
194 fn mint_cross(191 fn mint_cross(&mut self, caller: Caller, to: CrossAddress, amount: U256) -> Result<bool> {
195 &mut self,
196 caller: Caller,
197 to: pallet_common::eth::CrossAddress,
198 amount: U256,
199 ) -> Result<bool> {
200 let caller = T::CrossAccountId::from_eth(caller);192 let caller = T::CrossAccountId::from_eth(caller);
201 let to = to.into_sub_cross_account::<T>()?;193 let to = to.into_sub_cross_account::<T>()?;
212 fn approve_cross(204 fn approve_cross(
213 &mut self,205 &mut self,
214 caller: Caller,206 caller: Caller,
215 spender: pallet_common::eth::CrossAddress,207 spender: CrossAddress,
216 amount: U256,208 amount: U256,
217 ) -> Result<bool> {209 ) -> Result<bool> {
218 let caller = T::CrossAccountId::from_eth(caller);210 let caller = T::CrossAccountId::from_eth(caller);
253 fn burn_from_cross(245 fn burn_from_cross(
254 &mut self,246 &mut self,
255 caller: Caller,247 caller: Caller,
256 from: pallet_common::eth::CrossAddress,248 from: CrossAddress,
257 amount: U256,249 amount: U256,
258 ) -> Result<bool> {250 ) -> Result<bool> {
259 let caller = T::CrossAccountId::from_eth(caller);251 let caller = T::CrossAccountId::from_eth(caller);
295 fn transfer_cross(287 fn transfer_cross(&mut self, caller: Caller, to: CrossAddress, amount: U256) -> Result<bool> {
296 &mut self,
297 caller: Caller,
298 to: pallet_common::eth::CrossAddress,
299 amount: U256,
300 ) -> Result<bool> {
301 let caller = T::CrossAccountId::from_eth(caller);288 let caller = T::CrossAccountId::from_eth(caller);
302 let to = to.into_sub_cross_account::<T>()?;289 let to = to.into_sub_cross_account::<T>()?;
313 fn transfer_from_cross(300 fn transfer_from_cross(
314 &mut self,301 &mut self,
315 caller: Caller,302 caller: Caller,
316 from: pallet_common::eth::CrossAddress,303 from: CrossAddress,
317 to: pallet_common::eth::CrossAddress,304 to: CrossAddress,
318 amount: U256,305 amount: U256,
319 ) -> Result<bool> {306 ) -> Result<bool> {
320 let caller = T::CrossAccountId::from_eth(caller);307 let caller = T::CrossAccountId::from_eth(caller);
modifiedpallets/fungible/src/lib.rsdiffbeforeafterboth
--- a/pallets/fungible/src/lib.rs
+++ b/pallets/fungible/src/lib.rs
@@ -165,8 +165,8 @@
 	pub type Allowance<T: Config> = StorageNMap<
 		Key = (
 			Key<Twox64Concat, CollectionId>,
-			Key<Blake2_128, T::CrossAccountId>,
-			Key<Blake2_128Concat, T::CrossAccountId>,
+			Key<Blake2_128, T::CrossAccountId>,       // Owner
+			Key<Blake2_128Concat, T::CrossAccountId>, // Spender
 		),
 		Value = u128,
 		QueryKind = ValueQuery,
modifiedpallets/refungible/src/erc_token.rsdiffbeforeafterboth
--- a/pallets/refungible/src/erc_token.rs
+++ b/pallets/refungible/src/erc_token.rs
@@ -31,7 +31,7 @@
 use pallet_common::{
 	CommonWeightInfo,
 	erc::{CommonEvmHandler, PrecompileResult},
-	eth::collection_id_to_address,
+	eth::{collection_id_to_address, CrossAddress},
 };
 use pallet_evm::{account::CrossAccountId, PrecompileHandle};
 use pallet_evm_coder_substrate::{call, dispatch_to_evm, WithRecorder};
@@ -207,11 +207,7 @@
 	/// @param owner crossAddress The address which owns the funds.
 	/// @param spender crossAddress The address which will spend the funds.
 	/// @return A uint256 specifying the amount of tokens still available for the spender.
-	fn allowance_cross(
-		&self,
-		owner: pallet_common::eth::CrossAddress,
-		spender: pallet_common::eth::CrossAddress,
-	) -> Result<U256> {
+	fn allowance_cross(&self, owner: CrossAddress, spender: CrossAddress) -> Result<U256> {
 		let owner = owner.into_sub_cross_account::<T>()?;
 		let spender = spender.into_sub_cross_account::<T>()?;
 
@@ -245,7 +241,7 @@
 	fn burn_from_cross(
 		&mut self,
 		caller: Caller,
-		from: pallet_common::eth::CrossAddress,
+		from: CrossAddress,
 		amount: U256,
 	) -> Result<bool> {
 		let caller = T::CrossAccountId::from_eth(caller);
@@ -271,7 +267,7 @@
 	fn approve_cross(
 		&mut self,
 		caller: Caller,
-		spender: pallet_common::eth::CrossAddress,
+		spender: CrossAddress,
 		amount: U256,
 	) -> Result<bool> {
 		let caller = T::CrossAccountId::from_eth(caller);
@@ -298,12 +294,7 @@
 	/// @param to The crossaccount to transfer to.
 	/// @param amount The amount to be transferred.
 	#[weight(<CommonWeights<T>>::transfer())]
-	fn transfer_cross(
-		&mut self,
-		caller: Caller,
-		to: pallet_common::eth::CrossAddress,
-		amount: U256,
-	) -> Result<bool> {
+	fn transfer_cross(&mut self, caller: Caller, to: CrossAddress, amount: U256) -> Result<bool> {
 		let caller = T::CrossAccountId::from_eth(caller);
 		let to = to.into_sub_cross_account::<T>()?;
 		let amount = amount.try_into().map_err(|_| "amount overflow")?;
@@ -324,8 +315,8 @@
 	fn transfer_from_cross(
 		&mut self,
 		caller: Caller,
-		from: pallet_common::eth::CrossAddress,
-		to: pallet_common::eth::CrossAddress,
+		from: CrossAddress,
+		to: CrossAddress,
 		amount: U256,
 	) -> Result<bool> {
 		let caller = T::CrossAccountId::from_eth(caller);
modifiedpallets/refungible/src/lib.rsdiffbeforeafterboth
--- a/pallets/refungible/src/lib.rs
+++ b/pallets/refungible/src/lib.rs
@@ -240,13 +240,13 @@
 		QueryKind = ValueQuery,
 	>;
 
-	/// Operator set by a wallet owner that could perform certain transactions on all tokens in the wallet.
+	/// Spender set by a wallet owner that could perform certain transactions on all tokens in the wallet.
 	#[pallet::storage]
 	pub type CollectionAllowance<T: Config> = StorageNMap<
 		Key = (
 			Key<Twox64Concat, CollectionId>,
 			Key<Blake2_128Concat, T::CrossAccountId>, // Owner
-			Key<Blake2_128Concat, T::CrossAccountId>, // Operator
+			Key<Blake2_128Concat, T::CrossAccountId>, // Spender
 		),
 		Value = bool,
 		QueryKind = ValueQuery,
@@ -1403,18 +1403,18 @@
 	pub fn set_allowance_for_all(
 		collection: &RefungibleHandle<T>,
 		owner: &T::CrossAccountId,
-		operator: &T::CrossAccountId,
+		spender: &T::CrossAccountId,
 		approve: bool,
 	) -> DispatchResult {
 		<PalletCommon<T>>::set_allowance_for_all(
 			collection,
 			owner,
-			operator,
+			spender,
 			approve,
-			|| <CollectionAllowance<T>>::insert((collection.id, owner, operator), approve),
+			|| <CollectionAllowance<T>>::insert((collection.id, owner, spender), approve),
 			ERC721Events::ApprovalForAll {
 				owner: *owner.as_eth(),
-				operator: *operator.as_eth(),
+				operator: *spender.as_eth(),
 				approved: approve,
 			}
 			.to_log(collection_id_to_address(collection.id)),
@@ -1425,9 +1425,9 @@
 	pub fn allowance_for_all(
 		collection: &RefungibleHandle<T>,
 		owner: &T::CrossAccountId,
-		operator: &T::CrossAccountId,
+		spender: &T::CrossAccountId,
 	) -> bool {
-		<CollectionAllowance<T>>::get((collection.id, owner, operator))
+		<CollectionAllowance<T>>::get((collection.id, owner, spender))
 	}
 
 	pub fn repair_item(collection: &RefungibleHandle<T>, token: TokenId) -> DispatchResult {