git.delta.rocks / unique-network / refs/commits / 415e3d612ac1

difftreelog

feat eth address mapping

Yaroslav Bolyukin2021-04-30parent: #9936e25.patch.diff
in: master

5 files changed

addedpallets/nft/src/eth/account.rsdiffbeforeafterboth

no changes

addedpallets/nft/src/eth/mod.rsdiffbeforeafterboth

no changes

modifiedpallets/nft/src/lib.rsdiffbeforeafterboth
77
8#![cfg_attr(not(feature = "std"), no_std)]8#![cfg_attr(not(feature = "std"), no_std)]
9
10#[cfg(feature = "std")]
11pub use std::*;
129
13#[cfg(feature = "std")]10#[cfg(feature = "std")]
14pub use serde::*;11pub use serde::*;
33};30};
3431
35use frame_system::{self as system, ensure_signed, ensure_root};32use frame_system::{self as system, ensure_signed, ensure_root};
33use sp_core::{H160, H256};
36use sp_runtime::sp_std::prelude::Vec;34use sp_runtime::sp_std::prelude::Vec;
37use sp_runtime::{35use sp_runtime::{
38 traits::{36 traits::{
45};43};
46use sp_runtime::traits::StaticLookup;44use sp_runtime::traits::StaticLookup;
47use pallet_contracts::chain_extension::UncheckedFrom;45use pallet_contracts::chain_extension::UncheckedFrom;
46use pallet_evm::AddressMapping;
48use pallet_transaction_payment::OnChargeTransaction;47use pallet_transaction_payment::OnChargeTransaction;
4948
50#[cfg(test)]49#[cfg(test)]
54mod tests;53mod tests;
5554
56mod default_weights;55mod default_weights;
56mod eth;
57
58pub use eth::account::*;
5759
58pub const MAX_DECIMAL_POINTS: DecimalPoints = 30;60pub const MAX_DECIMAL_POINTS: DecimalPoints = 30;
59pub const MAX_REFUNGIBLE_PIECES: u128 = 1_000_000_000_000_000_000_000;61pub const MAX_REFUNGIBLE_PIECES: u128 = 1_000_000_000_000_000_000_000;
164#[derive(Encode, Decode, Clone, PartialEq)]166#[derive(Encode, Decode, Clone, PartialEq)]
165#[cfg_attr(feature = "std", derive(Serialize, Deserialize))]167#[cfg_attr(feature = "std", derive(Serialize, Deserialize))]
166pub struct Collection<T: Config> {168pub struct Collection<T: Config> {
167 pub owner: T::AccountId,169 pub owner: T::CrossAccountId,
168 pub mode: CollectionMode,170 pub mode: CollectionMode,
169 pub access: AccessMode,171 pub access: AccessMode,
170 pub decimal_points: DecimalPoints,172 pub decimal_points: DecimalPoints,
174 pub mint_mode: bool,176 pub mint_mode: bool,
175 pub offchain_schema: Vec<u8>,177 pub offchain_schema: Vec<u8>,
176 pub schema_version: SchemaVersion,178 pub schema_version: SchemaVersion,
177 pub sponsorship: SponsorshipState<T::AccountId>,179 pub sponsorship: SponsorshipState<T::CrossAccountId>,
178 pub limits: CollectionLimits<T::BlockNumber>, // Collection private restrictions 180 pub limits: CollectionLimits<T::BlockNumber>, // Collection private restrictions
179 pub variable_on_chain_schema: Vec<u8>, //181 pub variable_on_chain_schema: Vec<u8>, //
180 pub const_on_chain_schema: Vec<u8>, //182 pub const_on_chain_schema: Vec<u8>, //
461 /// Weight information for extrinsics in this pallet.463 /// Weight information for extrinsics in this pallet.
462 type WeightInfo: WeightInfo;464 type WeightInfo: WeightInfo;
463465
466 type EvmAddressMapping: pallet_evm::AddressMapping<Self::AccountId>;
467 type EvmBackwardsAddressMapping: EvmBackwardsAddressMapping<Self::AccountId>;
468 type EvmWithdrawOrigin: pallet_evm::EnsureAddressOrigin<Self::Origin, Success = Self::AccountId>;
469
470 type CrossAccountId: CrossAccountId<Self::AccountId>;
464 type Currency: Currency<Self::AccountId>;471 type Currency: Currency<Self::AccountId>;
465 type CollectionCreationPrice: Get<<<Self as Config>::Currency as Currency<Self::AccountId>>::Balance>;472 type CollectionCreationPrice: Get<<<Self as Config>::Currency as Currency<Self::AccountId>>::Balance>;
466 type TreasuryAccountId: Get<Self::AccountId>;473 type TreasuryAccountId: Get<Self::AccountId>;
525 pub CollectionById get(fn collection_id) config(): map hasher(blake2_128_concat) CollectionId => Option<Collection<T>> = None;532 pub CollectionById get(fn collection_id) config(): map hasher(blake2_128_concat) CollectionId => Option<Collection<T>> = None;
526 /// List of collection admins533 /// List of collection admins
527 /// Collection id (controlled?2)534 /// Collection id (controlled?2)
528 pub AdminList get(fn admin_list_collection): map hasher(blake2_128_concat) CollectionId => Vec<T::AccountId>;535 pub AdminList get(fn admin_list_collection): map hasher(blake2_128_concat) CollectionId => Vec<T::CrossAccountId>;
529 /// Whitelisted collection users536 /// Whitelisted collection users
530 /// Collection id (controlled?2), user id (controlled?3)537 /// Collection id (controlled?2), user id (controlled?3)
531 pub WhiteList get(fn white_list): double_map hasher(blake2_128_concat) CollectionId, hasher(blake2_128_concat) T::AccountId => bool;538 pub WhiteList get(fn white_list): double_map hasher(blake2_128_concat) CollectionId, hasher(blake2_128_concat) T::AccountId => bool;
542549
543 //#region Item collections550 //#region Item collections
544 /// Collection id (controlled?2), token id (controlled?1)551 /// Collection id (controlled?2), token id (controlled?1)
545 pub NftItemList get(fn nft_item_id) config(): double_map hasher(blake2_128_concat) CollectionId, hasher(blake2_128_concat) TokenId => Option<NftItemType<T::AccountId>>;552 pub NftItemList get(fn nft_item_id) config(): double_map hasher(blake2_128_concat) CollectionId, hasher(blake2_128_concat) TokenId => Option<NftItemType<T::CrossAccountId>>;
546 /// Collection id (controlled?2), owner (controlled?2)553 /// Collection id (controlled?2), owner (controlled?2)
547 pub FungibleItemList get(fn fungible_item_id) config(): double_map hasher(blake2_128_concat) CollectionId, hasher(blake2_128_concat) T::AccountId => FungibleItemType;554 pub FungibleItemList get(fn fungible_item_id) config(): double_map hasher(blake2_128_concat) CollectionId, hasher(blake2_128_concat) T::AccountId => FungibleItemType;
548 /// Collection id (controlled?2), token id (controlled?1)555 /// Collection id (controlled?2), token id (controlled?1)
549 pub ReFungibleItemList get(fn refungible_item_id) config(): double_map hasher(blake2_128_concat) CollectionId, hasher(blake2_128_concat) TokenId => Option<ReFungibleItemType<T::AccountId>>;556 pub ReFungibleItemList get(fn refungible_item_id) config(): double_map hasher(blake2_128_concat) CollectionId, hasher(blake2_128_concat) TokenId => Option<ReFungibleItemType<T::CrossAccountId>>;
550 //#endregion557 //#endregion
551558
552 //#region Index list559 //#region Index list
610decl_event!(617decl_event!(
611 pub enum Event<T>618 pub enum Event<T>
612 where619 where
613 AccountId = <T as system::Config>::AccountId,620 CrossAccountId = <T as Config>::CrossAccountId,
614 {621 {
615 /// New collection was created622 /// New collection was created
616 /// 623 ///
621 /// * mode: [CollectionMode] converted into u8.628 /// * mode: [CollectionMode] converted into u8.
622 /// 629 ///
623 /// * account_id: Collection owner.630 /// * account_id: Collection owner.
624 CollectionCreated(CollectionId, u8, AccountId),631 CollectionCreated(CollectionId, u8, CrossAccountId),
625632
626 /// New item was created.633 /// New item was created.
627 /// 634 ///
632 /// * item_id: Id of an item. Unique within the collection.639 /// * item_id: Id of an item. Unique within the collection.
633 ///640 ///
634 /// * recipient: Owner of newly created item 641 /// * recipient: Owner of newly created item
635 ItemCreated(CollectionId, TokenId, AccountId),642 ItemCreated(CollectionId, TokenId, CrossAccountId),
636643
637 /// Collection item was burned.644 /// Collection item was burned.
638 /// 645 ///
654 /// * recipient: New owner of item661 /// * recipient: New owner of item
655 ///662 ///
656 /// * amount: Always 1 for NFT663 /// * amount: Always 1 for NFT
657 Transfer(CollectionId, TokenId, AccountId, AccountId, u128),664 Transfer(CollectionId, TokenId, CrossAccountId, CrossAccountId, u128),
658665
659 /// * collection_id666 /// * collection_id
660 ///667 ///
665 /// * spender672 /// * spender
666 ///673 ///
667 /// * amount674 /// * amount
668 Approved(CollectionId, TokenId, AccountId, AccountId, u128),675 Approved(CollectionId, TokenId, CrossAccountId, CrossAccountId, u128),
669 }676 }
670);677);
671678
modifiedruntime/src/lib.rsdiffbeforeafterboth
579 type Event = Event;579 type Event = Event;
580 type WeightInfo = nft_weights::WeightInfo;580 type WeightInfo = nft_weights::WeightInfo;
581
582 type EvmWithdrawOrigin = EnsureAddressTruncated;
583 type EvmBackwardsAddressMapping = pallet_nft::MapBackwardsAddressTruncated;
584 type EvmAddressMapping = HashedAddressMapping<Self::Hashing>;
585 type CrossAccountId = pallet_nft::BasicCrossAccountId<Self>;
586
581 type Currency = Balances;587 type Currency = Balances;
582 type CollectionCreationPrice = CollectionCreationPrice;588 type CollectionCreationPrice = CollectionCreationPrice;
modifiedruntime_types.jsondiffbeforeafterboth
1{1{
2 "CrossAccountId": {
3 "_enum": {
4 "substrate": "AccountId",
5 "ethereum": "H160"
6 }
7 },
2 "AccessMode": {8 "AccessMode": {
3 "_enum": [9 "_enum": [
4 "Normal",10 "Normal",
15 }21 }
16 },22 },
17 "Ownership": {23 "Ownership": {
18 "Owner": "AccountId",24 "Owner": "CrossAccountId",
19 "Fraction": "u128"25 "Fraction": "u128"
20 },26 },
21 "FungibleItemType": {27 "FungibleItemType": {
22 "Value": "u128"28 "Value": "u128"
23 },29 },
24 "NftItemType": {30 "NftItemType": {
25 "Owner": "AccountId",31 "Owner": "CrossAccountId",
26 "ConstData": "Vec<u8>",32 "ConstData": "Vec<u8>",
27 "VariableData": "Vec<u8>"33 "VariableData": "Vec<u8>"
28 },34 },
29 "ReFungibleItemType": {35 "ReFungibleItemType": {
30 "Owner": "Vec<Ownership<AccountId>>",36 "Owner": "Vec<Ownership<CrossAccountId>>",
31 "ConstData": "Vec<u8>",37 "ConstData": "Vec<u8>",
32 "VariableData": "Vec<u8>"38 "VariableData": "Vec<u8>"
33 },39 },
34 "SponsorshipState": {40 "SponsorshipState": {
35 "_enum": {41 "_enum": {
36 "Disabled": null,42 "disabled": null,
37 "Unconfirmed": "AccountId",43 "unconfirmed": "CrossAccountId",
38 "Confirmed": "AccountId"44 "confirmed": "CrossAccountId"
39 }45 }
40 },46 },
41 "Collection": {47 "Collection": {
42 "Owner": "AccountId",48 "Owner": "CrossAccountId",
43 "Mode": "CollectionMode",49 "Mode": "CollectionMode",
44 "Access": "AccessMode",50 "Access": "AccessMode",
45 "DecimalPoints": "DecimalPoints",51 "DecimalPoints": "DecimalPoints",