Skip to content

Commit

Permalink
Add uniques pallet to shibuya and local runtime (#4)
Browse files Browse the repository at this point in the history
* Add pallet_uniques to local-runtime

* Add pallet_uniques to shibuya-runtime
  • Loading branch information
Szegoo authored Dec 27, 2023
1 parent 036c146 commit df3e221
Show file tree
Hide file tree
Showing 10 changed files with 1,000 additions and 4 deletions.
17 changes: 17 additions & 0 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ frame-benchmarking-cli = { git = "https://github.com/paritytech/substrate", bran
pallet-assets = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.43", default-features = false }
pallet-balances = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.43", default-features = false }
pallet-proxy = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.43", default-features = false }
pallet-uniques = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.43", default-features = false }
pallet-utility = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.43", default-features = false }
frame-support = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.43", default-features = false }
frame-system = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.43", default-features = false }
Expand Down
3 changes: 3 additions & 0 deletions runtime/local/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ pallet-grandpa = { workspace = true }
pallet-insecure-randomness-collective-flip = { workspace = true }
pallet-preimage = { workspace = true }
pallet-proxy = { workspace = true }
pallet-uniques = { workspace = true }
pallet-scheduler = { workspace = true }
pallet-sudo = { workspace = true }
pallet-timestamp = { workspace = true }
Expand Down Expand Up @@ -155,6 +156,7 @@ std = [
"pallet-utility/std",
"pallet-vesting/std",
"pallet-proxy/std",
"pallet-uniques/std",
"sp-api/std",
"sp-block-builder/std",
"sp-consensus-aura/std",
Expand Down Expand Up @@ -235,6 +237,7 @@ try-runtime = [
"pallet-democracy/try-runtime",
"pallet-collective/try-runtime",
"pallet-proxy/try-runtime",
"pallet-uniques/try-runtime",
"pallet-treasury/try-runtime",
"pallet-preimage/try-runtime",
"pallet-dynamic-evm-base-fee/try-runtime",
Expand Down
38 changes: 36 additions & 2 deletions runtime/local/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,9 @@ pub const MINUTES: BlockNumber = 60_000 / (MILLISECS_PER_BLOCK as BlockNumber);
pub const HOURS: BlockNumber = MINUTES * 60;
pub const DAYS: BlockNumber = HOURS * 24;

pub type CollectionId = u128;
pub type ItemId = u128;

impl AddressToAssetId<AssetId> for Runtime {
fn address_to_asset_id(address: H160) -> Option<AssetId> {
let mut data = [0u8; 16];
Expand Down Expand Up @@ -1019,9 +1022,9 @@ impl InstanceFilter<RuntimeCall> for ProxyType {
ProxyType::Balances => {
matches!(c, RuntimeCall::Balances(..))
}
// All Runtime calls from Pallet Assets allowed for proxy account
// All Runtime calls from Pallet Assets and Uniques allowed for proxy account
ProxyType::Assets => {
matches!(c, RuntimeCall::Assets(..))
matches!(c, RuntimeCall::Assets(..) | RuntimeCall::Uniques(..))
}
ProxyType::Governance => {
matches!(
Expand Down Expand Up @@ -1083,6 +1086,35 @@ impl pallet_proxy::Config for Runtime {
type AnnouncementDepositFactor = ConstU128<{ MILLIAST * 660 }>;
}

parameter_types! {
pub const UniquesCollectionDeposit: Balance = 10 * AST;
pub const UniquesItemDeposit: Balance = 1 * AST;
pub const UniquesMetadataDepositBase: Balance = deposit(1, 129);
pub const UniquesAttributeDepositBase: Balance = deposit(1, 0);
pub const UniquesDepositPerByte: Balance = deposit(0, 1);
}

impl pallet_uniques::Config for Runtime {
type RuntimeEvent = RuntimeEvent;
type CollectionId = CollectionId;
type ItemId = ItemId;
type Currency = Balances;
type ForceOrigin = EnsureRoot<AccountId>;
type CollectionDeposit = UniquesCollectionDeposit;
type ItemDeposit = UniquesItemDeposit;
type MetadataDepositBase = UniquesMetadataDepositBase;
type AttributeDepositBase = UniquesAttributeDepositBase;
type DepositPerByte = UniquesDepositPerByte;
type StringLimit = ConstU32<128>;
type KeyLimit = ConstU32<32>;
type ValueLimit = ConstU32<64>;
type WeightInfo = weights::pallet_uniques::WeightInfo<Runtime>;
#[cfg(feature = "runtime-benchmarks")]
type Helper = ();
type CreateOrigin = AsEnsureOriginWithArg<EnsureSigned<AccountId>>;
type Locker = ();
}

// TODO: remove this once https://github.com/paritytech/substrate/issues/12161 is resolved
#[rustfmt::skip]
construct_runtime!(
Expand Down Expand Up @@ -1122,6 +1154,7 @@ construct_runtime!(
Preimage: pallet_preimage,
EthereumChecked: pallet_ethereum_checked,
UnifiedAccounts: pallet_unified_accounts,
Uniques: pallet_uniques,
}
);

Expand Down Expand Up @@ -1243,6 +1276,7 @@ mod benches {
[pallet_dapp_staking_migration, DappStakingMigration]
[pallet_inflation, Inflation]
[pallet_dynamic_evm_base_fee, DynamicEvmBaseFee]
[pallet_uniques, Uniques]
);
}

Expand Down
1 change: 1 addition & 0 deletions runtime/local/src/weights/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,4 @@

pub mod pallet_assets;
pub mod pallet_balances;
pub mod pallet_uniques;
Loading

0 comments on commit df3e221

Please sign in to comment.