difftreelog
fix PR
in: master
4 files changed
pallets/fungible/src/erc.rsdiffbeforeafterboth--- a/pallets/fungible/src/erc.rs
+++ b/pallets/fungible/src/erc.rs
@@ -6,7 +6,7 @@
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
-// Unique Network is disaddress: tod in the hope that it will be useful,
+// Unique Network is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
@@ -28,6 +28,7 @@
use pallet_common::{
CollectionHandle,
erc::{CommonEvmHandler, PrecompileResult, CollectionCall},
+ eth::CrossAddress,
};
use sp_std::vec::Vec;
use pallet_evm::{account::CrossAccountId, PrecompileHandle};
@@ -172,11 +173,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>()?;
@@ -191,12 +188,7 @@
}
#[weight(<SelfWeightOf<T>>::create_item())]
- fn mint_cross(
- &mut self,
- caller: Caller,
- to: pallet_common::eth::CrossAddress,
- amount: U256,
- ) -> Result<bool> {
+ fn mint_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")?;
@@ -212,7 +204,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);
@@ -253,7 +245,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);
@@ -292,12 +284,7 @@
}
#[weight(<SelfWeightOf<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")?;
@@ -313,8 +300,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);
pallets/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,
pallets/refungible/src/erc_token.rsdiffbeforeafterboth31use pallet_common::{31use pallet_common::{32 CommonWeightInfo,32 CommonWeightInfo,33 erc::{CommonEvmHandler, PrecompileResult},33 erc::{CommonEvmHandler, PrecompileResult},34 eth::collection_id_to_address,34 eth::{collection_id_to_address, CrossAddress},35};35};36use pallet_evm::{account::CrossAccountId, PrecompileHandle};36use pallet_evm::{account::CrossAccountId, PrecompileHandle};37use pallet_evm_coder_substrate::{call, dispatch_to_evm, WithRecorder};37use pallet_evm_coder_substrate::{call, dispatch_to_evm, WithRecorder};209 /// @return A uint256 specifying the amount of tokens still available for the spender.209 /// @return A uint256 specifying the amount of tokens still available for the spender.210 fn allowance_cross(210 fn allowance_cross(&self, owner: CrossAddress, spender: CrossAddress) -> Result<U256> {211 &self,212 owner: pallet_common::eth::CrossAddress,213 spender: pallet_common::eth::CrossAddress,214 ) -> Result<U256> {215 let owner = owner.into_sub_cross_account::<T>()?;211 let owner = owner.into_sub_cross_account::<T>()?;216 let spender = spender.into_sub_cross_account::<T>()?;212 let spender = spender.into_sub_cross_account::<T>()?;245 fn burn_from_cross(241 fn burn_from_cross(246 &mut self,242 &mut self,247 caller: Caller,243 caller: Caller,248 from: pallet_common::eth::CrossAddress,244 from: CrossAddress,249 amount: U256,245 amount: U256,250 ) -> Result<bool> {246 ) -> Result<bool> {251 let caller = T::CrossAccountId::from_eth(caller);247 let caller = T::CrossAccountId::from_eth(caller);271 fn approve_cross(267 fn approve_cross(272 &mut self,268 &mut self,273 caller: Caller,269 caller: Caller,274 spender: pallet_common::eth::CrossAddress,270 spender: CrossAddress,275 amount: U256,271 amount: U256,276 ) -> Result<bool> {272 ) -> Result<bool> {277 let caller = T::CrossAccountId::from_eth(caller);273 let caller = T::CrossAccountId::from_eth(caller);301 fn transfer_cross(297 fn transfer_cross(&mut self, caller: Caller, to: CrossAddress, amount: U256) -> Result<bool> {302 &mut self,303 caller: Caller,304 to: pallet_common::eth::CrossAddress,305 amount: U256,306 ) -> Result<bool> {307 let caller = T::CrossAccountId::from_eth(caller);298 let caller = T::CrossAccountId::from_eth(caller);308 let to = to.into_sub_cross_account::<T>()?;299 let to = to.into_sub_cross_account::<T>()?;324 fn transfer_from_cross(315 fn transfer_from_cross(325 &mut self,316 &mut self,326 caller: Caller,317 caller: Caller,327 from: pallet_common::eth::CrossAddress,318 from: CrossAddress,328 to: pallet_common::eth::CrossAddress,319 to: CrossAddress,329 amount: U256,320 amount: U256,330 ) -> Result<bool> {321 ) -> Result<bool> {331 let caller = T::CrossAccountId::from_eth(caller);322 let caller = T::CrossAccountId::from_eth(caller);pallets/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 {