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
165 pub type Allowance<T: Config> = StorageNMap<165 pub type Allowance<T: Config> = StorageNMap<
166 Key = (166 Key = (
167 Key<Twox64Concat, CollectionId>,167 Key<Twox64Concat, CollectionId>,
168 Key<Blake2_128, T::CrossAccountId>,168 Key<Blake2_128, T::CrossAccountId>, // Owner
169 Key<Blake2_128Concat, T::CrossAccountId>,169 Key<Blake2_128Concat, T::CrossAccountId>, // Spender
170 ),170 ),
171 Value = u128,171 Value = u128,
172 QueryKind = ValueQuery,172 QueryKind = ValueQuery,
modifiedpallets/refungible/src/erc_token.rsdiffbeforeafterboth
31use 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);
modifiedpallets/refungible/src/lib.rsdiffbeforeafterboth
240 QueryKind = ValueQuery,240 QueryKind = ValueQuery,
241 >;241 >;
242242
243 /// 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>, // Owner
249 Key<Blake2_128Concat, T::CrossAccountId>, // Operator249 Key<Blake2_128Concat, T::CrossAccountId>, // Spender
250 ),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 }
14321432
1433 pub fn repair_item(collection: &RefungibleHandle<T>, token: TokenId) -> DispatchResult {1433 pub fn repair_item(collection: &RefungibleHandle<T>, token: TokenId) -> DispatchResult {