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

feat(sub0): nonfungibles pop-api + pallet implementation #353

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
84 commits
Select commit Hold shift + click to select a range
ac35a80
chore: forked pallet nfts
chungquantin Oct 14, 2024
59bd0ec
fix: formatting
chungquantin Oct 14, 2024
0460a44
fix: formatting
chungquantin Oct 14, 2024
d18123f
feat: add nonfungibles implementation
chungquantin Oct 14, 2024
8832470
chore: add nfts pallet
chungquantin Oct 14, 2024
facbb17
feat: add new storage items to pallet-nfts
chungquantin Oct 15, 2024
9e5e808
feat: check allowance
chungquantin Oct 16, 2024
fe1f448
test(nfts): check account balance & test total supply
chungquantin Oct 16, 2024
709398c
test(nfts): allowance works
chungquantin Oct 16, 2024
35a2839
refactor(test): check_allowance_works
chungquantin Oct 16, 2024
501a3c7
fix(nfts): cancel / approve collection transfer
chungquantin Oct 17, 2024
cebd059
test(nfts): cancel approval collection
chungquantin Oct 17, 2024
d235928
test(nfts): update approval test cases
chungquantin Oct 17, 2024
9015146
feat(nfts): get attribute read method
chungquantin Oct 17, 2024
2ad1764
feat(nonfungibles + nfts): add new methods to manage attributes
chungquantin Oct 17, 2024
48abce6
refactor(nfts): toml lock file
chungquantin Oct 18, 2024
390ca78
fix(pallet-api): propagate try-runtime feature
chungquantin Oct 18, 2024
2653a05
fix(api/nonfungibles): unit tests
chungquantin Oct 18, 2024
c41134f
test(api/nonfungibles): encoding_read_result
chungquantin Oct 18, 2024
a32e801
refactor(api/nonfungibles): pallet tests
chungquantin Oct 18, 2024
83e8122
test(nonfungibles): add tests and remove collection owner read
chungquantin Oct 21, 2024
c635172
fix(runtime): remove PartialEq, add Encode
chungquantin Oct 22, 2024
f4d1ba4
feat(nonfungibles): pop-api
chungquantin Oct 22, 2024
d3c9295
test(nonfungibles): pallet unit testing
chungquantin Oct 22, 2024
b6ebd48
fix: [nonfungibles, NonFungibles]
chungquantin Oct 22, 2024
356a253
fix: base call filter
chungquantin Oct 22, 2024
b953b42
feat(nonfungibles): pop-api integration tests utils
chungquantin Oct 22, 2024
914513d
fix: benchmark listing
chungquantin Oct 22, 2024
6816dff
fix: test
chungquantin Oct 23, 2024
0a94a25
feat: add integration test contract
chungquantin Oct 23, 2024
f2cd4a0
test(nonfungibles): integration tests skeleton
chungquantin Oct 23, 2024
09ce31d
fix(nonfungibles): integration tests
chungquantin Oct 23, 2024
a0d9a25
test(nonfungibles): add balance_of_works
chungquantin Oct 23, 2024
7ec11c0
test(nonfungibles): add more integration tests
chungquantin Oct 23, 2024
d82d3f9
test(nonfungibles): add more tests
chungquantin Oct 24, 2024
d6f418e
fix: devnet api config
chungquantin Oct 24, 2024
1943669
chore: update weight pallet-nfts file
chungquantin Oct 24, 2024
f20d191
Merge branch 'sub0' into chungquantin/sub0-pallet_nfts
chungquantin Oct 28, 2024
e477c00
chore: rebase
chungquantin Oct 28, 2024
ca14de7
feat: add nonfungibles implementation
chungquantin Oct 14, 2024
d8a15f8
chore: add nfts pallet
chungquantin Oct 14, 2024
37cd4bc
feat: add new storage items to pallet-nfts
chungquantin Oct 15, 2024
204bab4
feat: check allowance
chungquantin Oct 16, 2024
75ff645
test(nfts): check account balance & test total supply
chungquantin Oct 16, 2024
5653b66
test(nfts): allowance works
chungquantin Oct 16, 2024
15f72ed
refactor(test): check_allowance_works
chungquantin Oct 16, 2024
2c64d91
fix(nfts): cancel / approve collection transfer
chungquantin Oct 17, 2024
d29b841
test(nfts): cancel approval collection
chungquantin Oct 17, 2024
b47d42d
test(nfts): update approval test cases
chungquantin Oct 17, 2024
22dac99
feat(nfts): get attribute read method
chungquantin Oct 17, 2024
91bdcc8
feat(nonfungibles + nfts): add new methods to manage attributes
chungquantin Oct 17, 2024
091c6d3
refactor(nfts): toml lock file
chungquantin Oct 18, 2024
856c0ca
fix(pallet-api): propagate try-runtime feature
chungquantin Oct 18, 2024
b2390e2
fix(api/nonfungibles): unit tests
chungquantin Oct 18, 2024
0bc5f11
test(api/nonfungibles): encoding_read_result
chungquantin Oct 18, 2024
a2da82e
refactor(api/nonfungibles): pallet tests
chungquantin Oct 18, 2024
9d14962
test(nonfungibles): add tests and remove collection owner read
chungquantin Oct 21, 2024
d0dd77c
fix(runtime): remove PartialEq, add Encode
chungquantin Oct 22, 2024
5bd7735
feat(nonfungibles): pop-api
chungquantin Oct 22, 2024
763e27d
test(nonfungibles): pallet unit testing
chungquantin Oct 22, 2024
887804b
fix: [nonfungibles, NonFungibles]
chungquantin Oct 22, 2024
4366c0f
fix: base call filter
chungquantin Oct 22, 2024
c8b3798
feat(nonfungibles): pop-api integration tests utils
chungquantin Oct 22, 2024
4d5451e
fix: benchmark listing
chungquantin Oct 22, 2024
4441ad4
fix: test
chungquantin Oct 23, 2024
ea91eb6
feat: add integration test contract
chungquantin Oct 23, 2024
5d43294
test(nonfungibles): integration tests skeleton
chungquantin Oct 23, 2024
a6da1ff
fix(nonfungibles): integration tests
chungquantin Oct 23, 2024
34f84e2
test(nonfungibles): add balance_of_works
chungquantin Oct 23, 2024
f976c20
test(nonfungibles): add more integration tests
chungquantin Oct 23, 2024
2abb4ff
test(nonfungibles): add more tests
chungquantin Oct 24, 2024
fe4ef45
fix: devnet api config
chungquantin Oct 24, 2024
ebbba96
chore: update weight pallet-nfts file
chungquantin Oct 24, 2024
f303fe9
chore: rebase
chungquantin Oct 28, 2024
9ba71d3
Merge remote-tracking branch 'refs/remotes/origin/chungquantin/sub0-n…
chungquantin Oct 28, 2024
a9f4ceb
fix: formatting
chungquantin Oct 28, 2024
159d6bc
fix: taplo
chungquantin Oct 28, 2024
a5a1c8c
fix: remove duplicate import
chungquantin Oct 28, 2024
0ae4535
chore: nonfungibles rebase (#360)
chungquantin Oct 28, 2024
712122b
Merge branch 'chungquantin/sub0-pallet_nfts' into chungquantin/sub0-n…
chungquantin Oct 28, 2024
b879488
fix: formatting
chungquantin Oct 29, 2024
8745056
chore: resolve review comments
chungquantin Oct 31, 2024
7d7a2ac
fix: collection id
Daanvdplas Nov 1, 2024
4ef42fb
refactor: only add useful helper functions
Daanvdplas Nov 1, 2024
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
54 changes: 33 additions & 21 deletions Cargo.lock

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

4 changes: 4 additions & 0 deletions pallets/api/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ frame-benchmarking.workspace = true
frame-support.workspace = true
frame-system.workspace = true
pallet-assets.workspace = true
pallet-nfts.workspace = true
sp-core.workspace = true
sp-runtime.workspace = true
sp-std.workspace = true
Expand All @@ -43,6 +44,7 @@ runtime-benchmarks = [
"frame-support/runtime-benchmarks",
"frame-system/runtime-benchmarks",
"pallet-assets/runtime-benchmarks",
"pallet-nfts/runtime-benchmarks",
"pop-chain-extension/runtime-benchmarks",
"sp-runtime/runtime-benchmarks",
]
Expand All @@ -55,6 +57,7 @@ std = [
"pallet-assets/std",
"pallet-balances/std",
"pallet-ismp/std",
"pallet-nfts/std",
"pop-chain-extension/std",
"scale-info/std",
"sp-core/std",
Expand All @@ -65,5 +68,6 @@ std = [
try-runtime = [
"frame-support/try-runtime",
"frame-system/try-runtime",
"pallet-nfts/try-runtime",
"sp-runtime/try-runtime",
]
1 change: 1 addition & 0 deletions pallets/api/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
#![cfg_attr(not(feature = "std"), no_std)]

pub use extension::Extension;
use frame_support::pallet_prelude::Weight;

pub mod extension;

Check warning on line 6 in pallets/api/src/lib.rs

View workflow job for this annotation

GitHub Actions / clippy

missing documentation for a module

warning: missing documentation for a module --> pallets/api/src/lib.rs:6:1 | 6 | pub mod extension; | ^^^^^^^^^^^^^^^^^
pub mod fungibles;
pub mod messaging;
#[cfg(test)]
mod mock;
pub mod nonfungibles;

/// Trait for performing reads of runtime state.
pub trait Read {
Expand Down
71 changes: 68 additions & 3 deletions pallets/api/src/mock.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
use codec::{Decode, Encode};
use frame_support::{
derive_impl, parameter_types,
traits::{AsEnsureOriginWithArg, ConstU128, ConstU32, Everything},
traits::{AsEnsureOriginWithArg, ConstU128, ConstU32, ConstU64, Everything},
};
use frame_system::{EnsureRoot, EnsureSigned};
use pallet_nfts::PalletFeatures;
use scale_info::TypeInfo;
use sp_core::H256;
use sp_runtime::{
traits::{BlakeTwo256, IdentityLookup},
traits::{BlakeTwo256, IdentifyAccount, IdentityLookup, Lazy, Verify},
BuildStorage,
};

Expand All @@ -29,6 +32,8 @@ frame_support::construct_runtime!(
Assets: pallet_assets::<Instance1>,
Balances: pallet_balances,
Fungibles: crate::fungibles,
Nfts: pallet_nfts,
NonFungibles: crate::nonfungibles
}
);

Expand Down Expand Up @@ -91,7 +96,7 @@ impl pallet_assets::Config<AssetsInstance> for Test {
#[cfg(feature = "runtime-benchmarks")]
type BenchmarkHelper = ();
type CallbackHandle = ();
type CreateOrigin = AsEnsureOriginWithArg<EnsureSigned<u64>>;
type CreateOrigin = AsEnsureOriginWithArg<EnsureSigned<Self::AccountId>>;
type Currency = Balances;
type Extra = ();
type ForceOrigin = EnsureRoot<u64>;
Expand All @@ -110,6 +115,66 @@ impl crate::fungibles::Config for Test {
type WeightInfo = ();
}

parameter_types! {
pub storage Features: PalletFeatures = PalletFeatures::all_enabled();
}

#[derive(Debug, Clone, PartialEq, Eq, Encode, Decode, TypeInfo)]
pub struct Noop;

impl IdentifyAccount for Noop {
type AccountId = AccountId;

fn into_account(self) -> Self::AccountId {
0
}
}

impl Verify for Noop {
type Signer = Noop;

fn verify<L: Lazy<[u8]>>(
&self,
_msg: L,
_signer: &<Self::Signer as IdentifyAccount>::AccountId,
) -> bool {
false
}
}

impl pallet_nfts::Config for Test {
type ApprovalsLimit = ConstU32<10>;
type AttributeDepositBase = ConstU128<1>;
type CollectionDeposit = ConstU128<2>;
type CollectionId = u32;
type CreateOrigin = AsEnsureOriginWithArg<EnsureSigned<u64>>;
type Currency = Balances;
type DepositPerByte = ConstU128<1>;
type Features = Features;
type ForceOrigin = frame_system::EnsureRoot<Self::AccountId>;
#[cfg(feature = "runtime-benchmarks")]
type Helper = ();
type ItemAttributesApprovalsLimit = ConstU32<2>;
type ItemDeposit = ConstU128<1>;
type ItemId = u32;
type KeyLimit = ConstU32<50>;
type Locker = ();
type MaxAttributesPerCall = ConstU32<2>;
type MaxDeadlineDuration = ConstU64<10000>;
type MaxTips = ConstU32<10>;
type MetadataDepositBase = ConstU128<1>;
type OffchainPublic = Noop;
type OffchainSignature = Noop;
type RuntimeEvent = RuntimeEvent;
type StringLimit = ConstU32<50>;
type ValueLimit = ConstU32<50>;
type WeightInfo = ();
}

impl crate::nonfungibles::Config for Test {
type RuntimeEvent = RuntimeEvent;
}

pub(crate) fn new_test_ext() -> sp_io::TestExternalities {
let mut t = frame_system::GenesisConfig::<Test>::default()
.build_storage()
Expand Down
Loading
Loading