Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NFT Origins Pallet #131

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 38 additions & 5 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion node/src/chain_spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,6 @@ fn testnet_genesis(
asset_registry: Default::default(),
#[cfg(feature = "tinkernet")]
tokens: Default::default(),
core_assets: Default::default(),
// core_assets: Default::default(),
}
}
20 changes: 12 additions & 8 deletions runtime/tinkernet/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,18 @@ smallvec = "1.6.1"
getrandom = { version = "0.2.4", default-features = false, features = ["js"] }

# InvArch Pallets
pallet-inv4 = { git = "https://github.com/InvArch/InvArch-Frames", rev = "82061c35b7b73d77b3a073789ef03fd56771e9fb", default-features = false }
pallet-ocif-staking = { git = "https://github.com/InvArch/InvArch-Frames", rev = "82061c35b7b73d77b3a073789ef03fd56771e9fb", default-features = false }
pallet-checked-inflation = { git = "https://github.com/InvArch/InvArch-Frames", rev = "82061c35b7b73d77b3a073789ef03fd56771e9fb", default-features = false }
pallet-rings = { git = "https://github.com/InvArch/InvArch-Frames", rev = "82061c35b7b73d77b3a073789ef03fd56771e9fb", default-features = false }
#pallet-inv4 = { git = "https://github.com/InvArch/InvArch-Frames", rev = "82061c35b7b73d77b3a073789ef03fd56771e9fb", default-features = false }
#pallet-ocif-staking = { git = "https://github.com/InvArch/InvArch-Frames", rev = "82061c35b7b73d77b3a073789ef03fd56771e9fb", default-features = false }
#pallet-checked-inflation = { git = "https://github.com/InvArch/InvArch-Frames", rev = "82061c35b7b73d77b3a073789ef03fd56771e9fb", default-features = false }
#pallet-rings = { git = "https://github.com/InvArch/InvArch-Frames", rev = "82061c35b7b73d77b3a073789ef03fd56771e9fb", default-features = false }

#pallet-inv4 = { path = "../../../InvArch-Frames/INV4/pallet-inv4", default-features = false }
#pallet-ocif-staking = { path = "../../../InvArch-Frames/OCIF/staking", default-features = false }
#pallet-checked-inflation = { path = "../../../InvArch-Frames/pallet-checked-inflation", default-features = false }
#pallet-rings = { path = "../../../InvArch-Frames/pallet-rings", default-features = false }
pallet-inv4 = { path = "../../../InvArch-Frames/INV4/pallet-inv4", default-features = false }
pallet-ocif-staking = { path = "../../../InvArch-Frames/OCIF/staking", default-features = false }
pallet-checked-inflation = { path = "../../../InvArch-Frames/pallet-checked-inflation", default-features = false }
pallet-rings = { path = "../../../InvArch-Frames/pallet-rings", default-features = false }
pallet-nft-origins = { path = "../../../InvArch-Frames/pallet-nft-origins", default-features = false }

pallet-core-assets = { path = "../../../InvArch-Frames/pallet-core-assets", default-features = false }

pallet-maintenance-mode = { git = "https://github.com/Moonsong-Labs/moonkit", default-features = false, features = ["xcm-support"], rev = "51e3068808fb58f30ffb16bfdaa81d0890f98fd8" }

Expand Down Expand Up @@ -208,6 +211,7 @@ std = [
"pallet-rings/std",
"pallet-asset-tx-payment/std",
"modified-construct-runtime/std",
"pallet-nft-origins/std",
]

runtime-benchmarks = [
Expand Down
166 changes: 84 additions & 82 deletions runtime/tinkernet/src/inv4.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ use crate::{
use codec::{Decode, Encode};
use frame_support::{
parameter_types,
traits::{fungibles::Credit, Contains, Currency, OnUnbalanced},
traits::{fungibles::Credit, Currency, OnUnbalanced},
};
use pallet_asset_tx_payment::ChargeAssetTxPayment;
use pallet_inv4::fee_handling::{FeeAsset, FeeAssetNegativeImbalance, MultisigFeeHandler};
use scale_info::TypeInfo;
use sp_core::{ConstU32, H256};
use sp_runtime::traits::{One, SignedExtension, Zero};
use sp_core::H256;
use sp_runtime::traits::{SignedExtension, Zero};

parameter_types! {
pub const MaxMetadata: u32 = 10000;
Expand All @@ -42,7 +42,6 @@ impl pallet_inv4::Config for Runtime {
type CoreSeedBalance = CoreSeedBalance;
type AssetsProvider = CoreAssets;
type RuntimeOrigin = RuntimeOrigin;
// type AssetFreezer = AssetFreezer;
type CoreCreationFee = CoreCreationFee;
type FeeCharger = FeeCharger;
type GenesisHash = GenesisHash;
Expand Down Expand Up @@ -121,86 +120,89 @@ impl MultisigFeeHandler<Runtime> for FeeCharger {
}
}

orml_traits2::parameter_type_with_key! {
pub CoreExistentialDeposits: |_currency_id: <Runtime as pallet_inv4::Config>::CoreId| -> Balance {
Balance::one()
};
}

pub struct CoreDustRemovalWhitelist;
impl Contains<AccountId> for CoreDustRemovalWhitelist {
fn contains(_: &AccountId) -> bool {
true
}
}

pub struct DisallowIfFrozen;
impl
orml_traits2::currency::OnTransfer<AccountId, <Runtime as pallet_inv4::Config>::CoreId, Balance>
for DisallowIfFrozen
{
fn on_transfer(
currency_id: <Runtime as pallet_inv4::Config>::CoreId,
_from: &AccountId,
_to: &AccountId,
_amount: Balance,
) -> sp_runtime::DispatchResult {
if let Some(true) = crate::INV4::is_asset_frozen(currency_id) {
Err(sp_runtime::DispatchError::Token(
sp_runtime::TokenError::Frozen,
))
} else {
Ok(())
}
}
}

pub struct HandleNewMembers;
impl orml_traits2::Happened<(AccountId, <Runtime as pallet_inv4::Config>::CoreId)>
for HandleNewMembers
{
fn happened((member, core_id): &(AccountId, <Runtime as pallet_inv4::Config>::CoreId)) {
crate::INV4::add_member(core_id, member)
}
}

pub struct HandleRemovedMembers;
impl orml_traits2::Happened<(AccountId, <Runtime as pallet_inv4::Config>::CoreId)>
for HandleRemovedMembers
{
fn happened((member, core_id): &(AccountId, <Runtime as pallet_inv4::Config>::CoreId)) {
crate::INV4::remove_member(core_id, member)
}
}

pub struct INV4TokenHooks;
impl
orml_traits2::currency::MutationHooks<
AccountId,
<Runtime as pallet_inv4::Config>::CoreId,
Balance,
> for INV4TokenHooks
{
type PreTransfer = DisallowIfFrozen;
type OnDust = ();
type OnSlash = ();
type PreDeposit = ();
type PostDeposit = ();
type PostTransfer = ();
type OnNewTokenAccount = HandleNewMembers;
type OnKilledTokenAccount = HandleRemovedMembers;
}

impl orml_tokens2::Config for Runtime {
// pub struct DisallowIfFrozen;
// impl
// orml_tokens_fork::OnTransfer<
// pallet_inv4::multisig::MultisigMemberOf<Runtime>,
// <Runtime as pallet_inv4::Config>::CoreId,
// Balance,
// > for DisallowIfFrozen
// {
// fn on_transfer(
// currency_id: <Runtime as pallet_inv4::Config>::CoreId,
// _from: &pallet_inv4::multisig::MultisigMemberOf<Runtime>,
// _to: &pallet_inv4::multisig::MultisigMemberOf<Runtime>,
// _amount: Balance,
// ) -> sp_runtime::DispatchResult {
// if let Some(true) = crate::INV4::is_asset_frozen(currency_id) {
// Err(sp_runtime::DispatchError::Token(
// sp_runtime::TokenError::Frozen,
// ))
// } else {
// Ok(())
// }
// }
// }

// pub struct HandleNewMembers;
// impl
// orml_tokens_fork::Happened<(
// pallet_inv4::multisig::MultisigMemberOf<Runtime>,
// <Runtime as pallet_inv4::Config>::CoreId,
// )> for HandleNewMembers
// {
// fn happened(
// (member, core_id): &(
// pallet_inv4::multisig::MultisigMemberOf<Runtime>,
// <Runtime as pallet_inv4::Config>::CoreId,
// ),
// ) {
// crate::INV4::add_member(core_id, member)
// }
// }

// pub struct HandleRemovedMembers;
// impl
// orml_tokens_fork::Happened<(
// pallet_inv4::multisig::MultisigMemberOf<Runtime>,
// <Runtime as pallet_inv4::Config>::CoreId,
// )> for HandleRemovedMembers
// {
// fn happened(
// (member, core_id): &(
// pallet_inv4::multisig::MultisigMemberOf<Runtime>,
// <Runtime as pallet_inv4::Config>::CoreId,
// ),
// ) {
// crate::INV4::remove_member(core_id, member)
// }
// }

// pub struct INV4TokenHooks;
// impl
// orml_tokens_fork::MutationHooks<
// pallet_inv4::multisig::MultisigMemberOf<Runtime>,
// <Runtime as pallet_inv4::Config>::CoreId,
// Balance,
// > for INV4TokenHooks
// {
// type PreTransfer = DisallowIfFrozen;
// type OnDust = ();
// type OnSlash = ();
// type PreDeposit = ();
// type PostDeposit = ();
// type PostTransfer = ();
// type OnNewTokenAccount = HandleNewMembers;
// type OnKilledTokenAccount = HandleRemovedMembers;
// }

impl pallet_core_assets::Config for Runtime {
type RuntimeEvent = RuntimeEvent;
type Balance = Balance;
type Amount = i128;
type CurrencyId = <Runtime as pallet_inv4::Config>::CoreId;
type WeightInfo = ();
type ExistentialDeposits = CoreExistentialDeposits;
type MaxLocks = ConstU32<0u32>;
type MaxReserves = ConstU32<0u32>;
type DustRemovalWhitelist = CoreDustRemovalWhitelist;
type ReserveIdentifier = [u8; 8];
type CurrencyHooks = INV4TokenHooks;

type AccountId = pallet_inv4::multisig::MultisigMemberOf<Runtime>;
type Lookup =
sp_runtime::traits::IdentityLookup<pallet_inv4::multisig::MultisigMemberOf<Runtime>>;
}
4 changes: 3 additions & 1 deletion runtime/tinkernet/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ use fee_handling::TnkrToKsm;
mod inflation;
mod inv4;
mod nft;
mod nft_origins;
mod rings;
mod staking;
mod weights;
Expand Down Expand Up @@ -834,8 +835,9 @@ construct_runtime_modified!(
OcifStaking: pallet_ocif_staking::{Pallet, Call, Storage, Event<T>} = 51,

INV4: pallet_inv4::{Pallet, Call, Storage, Event<T>, Origin<T>} = 71,
CoreAssets: orml_tokens2::{Pallet, Storage, Call, Event<T>, Config<T>} = 72,
CoreAssets: pallet_core_assets::{Pallet, Storage, Call, Event<T>} = 72,
Rings: pallet_rings::{Pallet, Call, Storage, Event<T>} = 73,
NftOrigins: pallet_nft_origins::{Pallet, Origin, Event<T>, Call, Storage} = 74,

Uniques: pallet_uniques::{Pallet, Storage, Event<T>} = 80,

Expand Down
Loading
Loading