difftreelog
added erc20 api for refungible tokens
in: master
7 files changed
Cargo.lockdiffbeforeafterboth6322name = "pallet-refungible"6322name = "pallet-refungible"6323version = "0.1.1"6323version = "0.1.1"6324dependencies = [6324dependencies = [6325 "ethereum",6326 "evm-coder",6325 "frame-benchmarking",6327 "frame-benchmarking",6326 "frame-support",6328 "frame-support",6327 "frame-system",6329 "frame-system",6328 "pallet-common",6330 "pallet-common",6329 "pallet-evm",6331 "pallet-evm",6332 "pallet-evm-coder-substrate",6330 "pallet-structure",6333 "pallet-structure",6331 "parity-scale-codec 3.1.5",6334 "parity-scale-codec 3.1.5",6332 "scale-info",6335 "scale-info",pallets/refungible/Cargo.tomldiffbeforeafterboth11version = '3.1.2'11version = '3.1.2'121213[dependencies]13[dependencies]14evm-coder = { default-features = false, path = '../../crates/evm-coder' }15pallet-evm-coder-substrate = { default-features = false, path = '../../pallets/evm-coder-substrate' }16pallet-common = { default-features = false, path = '../common' }17pallet-structure = { default-features = false, path = '../structure' }18struct-versioning = { path = "../../crates/struct-versioning" }19up-data-structs = { default-features = false, path = '../../primitives/data-structs' }2021ethereum = { version = "0.12.0", default-features = false }22scale-info = { version = "2.0.1", default-features = false, features = ["derive",] }2324frame-benchmarking = { default-features = false, optional = true, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.24" }14frame-support = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.24" }25frame-support = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.24" }15frame-system = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.24" }26frame-system = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.24" }27pallet-evm = { default-features = false, git = "https://github.com/uniquenetwork/frontier", branch = "unique-polkadot-v0.9.24" }28sp-core = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.24" }16sp-runtime = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.24" }29sp-runtime = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.24" }17sp-std = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.24" }30sp-std = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.24" }18sp-core = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.24" }19pallet-evm = { default-features = false, git = "https://github.com/uniquenetwork/frontier", branch = "unique-polkadot-v0.9.24" }20pallet-common = { default-features = false, path = '../common' }21pallet-structure = { default-features = false, path = '../structure' }22up-data-structs = { default-features = false, path = '../../primitives/data-structs' }23frame-benchmarking = { default-features = false, optional = true, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.24" }24scale-info = { version = "2.0.1", default-features = false, features = [25 "derive",26] }27struct-versioning = { path = "../../crates/struct-versioning" }283129[features]32[features]30default = ["std"]33default = ["std"]31std = [34std = [35 "ethereum/std",36 "evm-coder/std",37 'frame-benchmarking/std',32 "frame-support/std",38 "frame-support/std",33 "frame-system/std",39 "frame-system/std",34 "sp-runtime/std",40 "pallet-common/std",35 "sp-std/std",41 "pallet-evm/std",36 "up-data-structs/std",37 "pallet-common/std",42 "pallet-evm-coder-substrate/std",38 "pallet-structure/std",43 "pallet-structure/std",39 'frame-benchmarking/std',44 "sp-runtime/std",40 "pallet-evm/std",45 "sp-std/std",46 "up-data-structs/std",41]47]42runtime-benchmarks = [48runtime-benchmarks = [43 'frame-benchmarking',49 'frame-benchmarking',44 'frame-support/runtime-benchmarks',50 'frame-support/runtime-benchmarks',45 'frame-system/runtime-benchmarks',51 'frame-system/runtime-benchmarks',52 'up-data-structs/runtime-benchmarks',46]53]4754pallets/refungible/src/erc.rsdiffbeforeafterbothno changes
pallets/refungible/src/erc20.rsdiffbeforeafterbothno changes
pallets/refungible/src/erc721.rsdiffbeforeafterbothno changes
pallets/refungible/src/lib.rsdiffbeforeafterboth878788#![cfg_attr(not(feature = "std"), no_std)]88#![cfg_attr(not(feature = "std"), no_std)]898990use crate::erc20::ERC20Events;9192use codec::{Encode, Decode, MaxEncodedLen};93use core::ops::Deref;94use evm_coder::ToLog;90use frame_support::{ensure, fail, BoundedVec, transactional, storage::with_transaction};95use frame_support::{BoundedVec, ensure, fail, storage::with_transaction, transactional};91use up_data_structs::{96use pallet_evm::{account::CrossAccountId, Pallet as PalletEvm};92 AccessMode, CollectionId, CustomDataLimit, MAX_REFUNGIBLE_PIECES, TokenId,93 CreateCollectionData, CreateRefungibleExData, mapping::TokenAddressMapping, budget::Budget,94 Property, PropertyScope, TrySetProperty, PropertyKey, PropertyValue, PropertyPermission,95 PropertyKeyPermission,96};97use pallet_evm::account::CrossAccountId;97use pallet_evm_coder_substrate::WithRecorder;98use pallet_common::{98use pallet_common::{CommonCollectionOperations, Error as CommonError, Event as CommonEvent, Pallet as PalletCommon};99 Error as CommonError, Event as CommonEvent, Pallet as PalletCommon,100 CommonCollectionOperations as _,101};102use pallet_structure::Pallet as PalletStructure;99use pallet_structure::Pallet as PalletStructure;100use scale_info::TypeInfo;101use sp_core::H160;103use sp_runtime::{ArithmeticError, DispatchError, DispatchResult, TransactionOutcome};102use sp_runtime::{ArithmeticError, DispatchError, DispatchResult, TransactionOutcome};104use sp_std::{vec::Vec, vec, collections::btree_map::BTreeMap};103use sp_std::{vec::Vec, vec, collections::btree_map::BTreeMap};105use core::ops::Deref;106use codec::{Encode, Decode, MaxEncodedLen};104use up_data_structs::{107use scale_info::TypeInfo;105 AccessMode, budget::Budget, CollectionId, CreateCollectionData, CreateRefungibleExData, CustomDataLimit, mapping::TokenAddressMapping, MAX_REFUNGIBLE_PIECES, TokenId,106 Property, PropertyKey, PropertyKeyPermission, PropertyPermission, PropertyScope, PropertyValue, TrySetProperty107};108108109pub use pallet::*;109pub use pallet::*;110#[cfg(feature = "runtime-benchmarks")]110#[cfg(feature = "runtime-benchmarks")]111pub mod benchmarking;111pub mod benchmarking;112pub mod common;112pub mod common;113pub mod erc;113pub mod erc20;114pub mod erc721;114pub mod weights;115pub mod weights;115pub(crate) type SelfWeightOf<T> = <T as Config>::WeightInfo;116pub(crate) type SelfWeightOf<T> = <T as Config>::WeightInfo;116117271 pub fn into_inner(self) -> pallet_common::CollectionHandle<T> {272 pub fn into_inner(self) -> pallet_common::CollectionHandle<T> {272 self.0273 self.0273 }274 }275 pub fn common_mut(&mut self) -> &mut pallet_common::CollectionHandle<T> {276 &mut self.0277 }274}278}279275impl<T: Config> Deref for RefungibleHandle<T> {280impl<T: Config> Deref for RefungibleHandle<T> {280 }285 }281}286}287288impl<T: Config> WithRecorder<T> for RefungibleHandle<T> {289 fn recorder(&self) -> &pallet_evm_coder_substrate::SubstrateRecorder<T> {290 self.0.recorder()291 }292 fn into_recorder(self) -> pallet_evm_coder_substrate::SubstrateRecorder<T> {293 self.0.into_recorder()294 }295}282296283impl<T: Config> Pallet<T> {297impl<T: Config> Pallet<T> {284 /// Get number of RFT tokens in collection298 /// Get number of RFT tokens in collection460 <Balance<T>>::insert((collection.id, token, owner), balance);474 <Balance<T>>::insert((collection.id, token, owner), balance);461 }475 }462 <TotalSupply<T>>::insert((collection.id, token), total_supply);476 <TotalSupply<T>>::insert((collection.id, token), total_supply);463 // TODO: ERC20 transfer event477478 <PalletEvm<T>>::deposit_log(479 ERC20Events::Transfer {480 from: *owner.as_eth(),481 to: H160::default(),482 value: amount.into(),483 }484 .to_log(T::EvmTokenAddressMapping::token_to_address(485 collection.id,486 token,487 )),488 );464 <PalletCommon<T>>::deposit_event(CommonEvent::ItemDestroyed(489 <PalletCommon<T>>::deposit_event(CommonEvent::ItemDestroyed(465 collection.id,490 collection.id,466 token,491 token,736 }761 }737 }762 }738763739 // TODO: ERC20 transfer event764 <PalletEvm<T>>::deposit_log(765 ERC20Events::Transfer {766 from: *from.as_eth(),767 to: *to.as_eth(),768 value: amount.into(),769 }770 .to_log(T::EvmTokenAddressMapping::token_to_address(771 collection.id,772 token,773 )),774 );740 <PalletCommon<T>>::deposit_event(CommonEvent::Transfer(775 <PalletCommon<T>>::deposit_event(CommonEvent::Transfer(741 collection.id,776 collection.id,742 token,777 token,889 continue;924 continue;890 }925 }891926892 // TODO: ERC20 transfer event927 <PalletEvm<T>>::deposit_log(928 ERC20Events::Transfer {929 from: H160::default(),930 to: *user.as_eth(),931 value: amount.into(),932 }933 .to_log(T::EvmTokenAddressMapping::token_to_address(934 collection.id,935 TokenId(token_id),936 )),937 );893 <PalletCommon<T>>::deposit_event(CommonEvent::ItemCreated(938 <PalletCommon<T>>::deposit_event(CommonEvent::ItemCreated(894 collection.id,939 collection.id,895 TokenId(token_id),940 TokenId(token_id),913 } else {958 } else {914 <Allowance<T>>::insert((collection.id, token, sender, spender), amount);959 <Allowance<T>>::insert((collection.id, token, sender, spender), amount);915 }960 }916 // TODO: ERC20 approval event961962 <PalletEvm<T>>::deposit_log(963 ERC20Events::Approval {964 owner: *sender.as_eth(),965 spender: *spender.as_eth(),966 value: amount.into(),967 }968 .to_log(T::EvmTokenAddressMapping::token_to_address(969 collection.id,970 token,971 )),972 );917 <PalletCommon<T>>::deposit_event(CommonEvent::Approved(973 <PalletCommon<T>>::deposit_event(CommonEvent::Approved(918 collection.id,974 collection.id,919 token,975 token,runtime/common/src/dispatch.rsdiffbeforeafterboth25pub use pallet_common::dispatch::CollectionDispatch;25pub use pallet_common::dispatch::CollectionDispatch;26use pallet_fungible::{Pallet as PalletFungible, FungibleHandle};26use pallet_fungible::{Pallet as PalletFungible, FungibleHandle};27use pallet_nonfungible::{Pallet as PalletNonfungible, NonfungibleHandle};27use pallet_nonfungible::{Pallet as PalletNonfungible, NonfungibleHandle};28use pallet_refungible::{Pallet as PalletRefungible, RefungibleHandle, erc::RefungibleTokenHandle};28use pallet_refungible::{Pallet as PalletRefungible, RefungibleHandle, erc20::RefungibleTokenHandle};29use up_data_structs::{29use up_data_structs::{30 CollectionMode, CreateCollectionData, MAX_DECIMAL_POINTS, mapping::TokenAddressMapping,30 CollectionMode, CreateCollectionData, MAX_DECIMAL_POINTS, mapping::TokenAddressMapping,31};31};