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.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);
pallets/refungible/src/lib.rsdiffbeforeafterboth240 QueryKind = ValueQuery,240 QueryKind = ValueQuery,241 >;241 >;242242243 /// Operator set by a wallet owner that could perform certain transactions on all tokens in the wallet.243 /// Spender set by a wallet owner that could perform certain transactions on all tokens in the wallet.244 #[pallet::storage]244 #[pallet::storage]245 pub type CollectionAllowance<T: Config> = StorageNMap<245 pub type CollectionAllowance<T: Config> = StorageNMap<246 Key = (246 Key = (247 Key<Twox64Concat, CollectionId>,247 Key<Twox64Concat, CollectionId>,248 Key<Blake2_128Concat, T::CrossAccountId>, // Owner248 Key<Blake2_128Concat, T::CrossAccountId>, // Owner249 Key<Blake2_128Concat, T::CrossAccountId>, // Operator249 Key<Blake2_128Concat, T::CrossAccountId>, // Spender250 ),250 ),251 Value = bool,251 Value = bool,252 QueryKind = ValueQuery,252 QueryKind = ValueQuery,1403 pub fn set_allowance_for_all(1403 pub fn set_allowance_for_all(1404 collection: &RefungibleHandle<T>,1404 collection: &RefungibleHandle<T>,1405 owner: &T::CrossAccountId,1405 owner: &T::CrossAccountId,1406 operator: &T::CrossAccountId,1406 spender: &T::CrossAccountId,1407 approve: bool,1407 approve: bool,1408 ) -> DispatchResult {1408 ) -> DispatchResult {1409 <PalletCommon<T>>::set_allowance_for_all(1409 <PalletCommon<T>>::set_allowance_for_all(1410 collection,1410 collection,1411 owner,1411 owner,1412 operator,1412 spender,1413 approve,1413 approve,1414 || <CollectionAllowance<T>>::insert((collection.id, owner, operator), approve),1414 || <CollectionAllowance<T>>::insert((collection.id, owner, spender), approve),1415 ERC721Events::ApprovalForAll {1415 ERC721Events::ApprovalForAll {1416 owner: *owner.as_eth(),1416 owner: *owner.as_eth(),1417 operator: *operator.as_eth(),1417 operator: *spender.as_eth(),1418 approved: approve,1418 approved: approve,1419 }1419 }1420 .to_log(collection_id_to_address(collection.id)),1420 .to_log(collection_id_to_address(collection.id)),1425 pub fn allowance_for_all(1425 pub fn allowance_for_all(1426 collection: &RefungibleHandle<T>,1426 collection: &RefungibleHandle<T>,1427 owner: &T::CrossAccountId,1427 owner: &T::CrossAccountId,1428 operator: &T::CrossAccountId,1428 spender: &T::CrossAccountId,1429 ) -> bool {1429 ) -> bool {1430 <CollectionAllowance<T>>::get((collection.id, owner, operator))1430 <CollectionAllowance<T>>::get((collection.id, owner, spender))1431 }1431 }143214321433 pub fn repair_item(collection: &RefungibleHandle<T>, token: TokenId) -> DispatchResult {1433 pub fn repair_item(collection: &RefungibleHandle<T>, token: TokenId) -> DispatchResult {