Skip to content

Commit

Permalink
Merge branch 'rmrk-team:main' into child-owner
Browse files Browse the repository at this point in the history
  • Loading branch information
Szegoo authored Apr 22, 2023
2 parents 5b0d344 + 35eced9 commit 8c63564
Show file tree
Hide file tree
Showing 16 changed files with 57 additions and 73 deletions.
5 changes: 2 additions & 3 deletions crates/catalog/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,10 @@ authors = ["Stake Technologies <[email protected]>"]
edition = "2021"

[dependencies]
ink = { version = "4.0.0", default-features = false }
ink = { version = "4.1.0", default-features = false }
scale = { package = "parity-scale-codec", version = "3", default-features = false, features = ["derive"] }
scale-info = { version = "2.3", default-features = false, features = ["derive"], optional = true }
openbrush = { tag = "3.0.0", git = "https://github.com/727-Ventures/openbrush-contracts", default-features = false, features = ["access_control", "reentrancy_guard", "psp34"] }

openbrush = { tag = "3.1.0", git = "https://github.com/727-Ventures/openbrush-contracts", default-features = false, features = ["access_control", "reentrancy_guard", "psp34"] }
rmrk_common = { path = "../common", default-features = false }

[lib]
Expand Down
10 changes: 4 additions & 6 deletions crates/catalog/src/catalog.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,18 +114,16 @@ where

/// Sets the metadata URI for Catalog
#[modifiers(only_role(CONTRIBUTOR))]
default fn setup_catalog(&mut self, catalog_metadata: String) -> Result<()> {
default fn set_catalog_metadata(&mut self, catalog_metadata: String) -> Result<()> {
self.data::<CatalogData>().catalog_metadata = catalog_metadata;

Ok(())
}

/// Get the Catalog metadataURI.
default fn get_catalog_metadata(&self) -> PreludeString {
match PreludeString::from_utf8(self.data::<CatalogData>().catalog_metadata.clone()) {
Ok(m) => m,
_ => PreludeString::from(""),
}
default fn get_catalog_metadata(&self) -> Result<PreludeString> {
PreludeString::from_utf8(self.data::<CatalogData>().catalog_metadata.clone())
.map_err(|_| RmrkError::UriNotFound.into())
}

/// Get the number of parts.
Expand Down
11 changes: 4 additions & 7 deletions crates/catalog/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,10 @@
#![feature(min_specialization)]
#![allow(clippy::inline_fn_without_body)]

pub use rmrk_common::{
errors,
roles,
types,
utils,
};

pub mod catalog;
pub mod internal;
pub mod traits;

pub use catalog::*;
pub use internal::*;
pub use traits::*;
4 changes: 2 additions & 2 deletions crates/catalog/src/traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,11 @@ pub trait Catalog {

//// Set the Catalog metadataURI.
#[ink(message)]
fn setup_catalog(&mut self, catalog_metadata: String) -> Result<()>;
fn set_catalog_metadata(&mut self, catalog_metadata: String) -> Result<()>;

//// Get the Catalog metadataURI.
#[ink(message)]
fn get_catalog_metadata(&self) -> PreludeString;
fn get_catalog_metadata(&self) -> Result<PreludeString>;

/// Get the list of all parts.
#[ink(message)]
Expand Down
4 changes: 2 additions & 2 deletions crates/common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ authors = ["Stake Technologies <[email protected]>"]
edition = "2021"

[dependencies]
ink = { version = "4.0.0", default-features = false }
ink = { version = "4.1.0", default-features = false }
scale = { package = "parity-scale-codec", version = "3", default-features = false, features = ["derive"] }
scale-info = { version = "2.3", default-features = false, features = ["derive"], optional = true }
openbrush = { tag = "3.0.0", git = "https://github.com/727-Ventures/openbrush-contracts", default-features = false, features = ["access_control", "reentrancy_guard", "psp34"] }
openbrush = { tag = "3.1.0", git = "https://github.com/727-Ventures/openbrush-contracts", default-features = false, features = ["access_control", "reentrancy_guard", "psp34"] }


[lib]
Expand Down
4 changes: 2 additions & 2 deletions crates/equippable/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ authors = ["Stake Technologies <[email protected]>"]
edition = "2021"

[dependencies]
ink = { version = "4.0.0", default-features = false }
ink = { version = "4.1.0", default-features = false }
scale = { package = "parity-scale-codec", version = "3", default-features = false, features = ["derive"] }
scale-info = { version = "2.3", default-features = false, features = ["derive"], optional = true }
openbrush = { tag = "3.0.0", git = "https://github.com/727-Ventures/openbrush-contracts", default-features = false, features = ["access_control", "reentrancy_guard", "psp34"] }
openbrush = { tag = "3.1.0", git = "https://github.com/727-Ventures/openbrush-contracts", default-features = false, features = ["access_control", "reentrancy_guard", "psp34"] }
rmrk_common = { path = "../common", default-features = false }
rmrk_multiasset = { path = "../multiasset", default-features = false }

Expand Down
4 changes: 2 additions & 2 deletions crates/minting/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ authors = ["Stake Technologies <[email protected]>"]
edition = "2021"

[dependencies]
ink = { version = "4.0.0", default-features = false }
ink = { version = "4.1.0", default-features = false }
scale = { package = "parity-scale-codec", version = "3", default-features = false, features = ["derive"] }
scale-info = { version = "2.3", default-features = false, features = ["derive"], optional = true }
openbrush = { tag = "3.0.0", git = "https://github.com/727-Ventures/openbrush-contracts", default-features = false, features = ["access_control", "reentrancy_guard", "psp34"] }
openbrush = { tag = "3.1.0", git = "https://github.com/727-Ventures/openbrush-contracts", default-features = false, features = ["access_control", "reentrancy_guard", "psp34"] }
rmrk_common = { path = "../common", default-features = false }


Expand Down
4 changes: 2 additions & 2 deletions crates/multiasset/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ authors = ["Stake Technologies <[email protected]>"]
edition = "2021"

[dependencies]
ink = { version = "4.0.0", default-features = false }
ink = { version = "4.1.0", default-features = false }
scale = { package = "parity-scale-codec", version = "3", default-features = false, features = ["derive"] }
scale-info = { version = "2.3", default-features = false, features = ["derive"], optional = true }
openbrush = { tag = "3.0.0", git = "https://github.com/727-Ventures/openbrush-contracts", default-features = false, features = ["access_control", "reentrancy_guard", "psp34"] }
openbrush = { tag = "3.1.0", git = "https://github.com/727-Ventures/openbrush-contracts", default-features = false, features = ["access_control", "reentrancy_guard", "psp34"] }

rmrk_common = { path = "../common", default-features = false }

Expand Down
4 changes: 2 additions & 2 deletions crates/nesting/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ authors = ["Stake Technologies <[email protected]>"]
edition = "2021"

[dependencies]
ink = { version = "4.0.0", default-features = false }
ink = { version = "4.1.0", default-features = false }
scale = { package = "parity-scale-codec", version = "3", default-features = false, features = ["derive"] }
scale-info = { version = "2.3", default-features = false, features = ["derive"], optional = true }
openbrush = { tag = "3.0.0", git = "https://github.com/727-Ventures/openbrush-contracts", default-features = false, features = ["access_control", "reentrancy_guard", "psp34"] }
openbrush = { tag = "3.1.0", git = "https://github.com/727-Ventures/openbrush-contracts", default-features = false, features = ["access_control", "reentrancy_guard", "psp34"] }

rmrk_common = { path = "../common", default-features = false }

Expand Down
8 changes: 3 additions & 5 deletions crates/rmrk/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,17 @@ authors = ["Stake Technologies <[email protected]>"]
edition = "2021"

[dependencies]
ink = { version = "4.0.0", default-features = false }
ink = { version = "4.1.0", default-features = false }
scale = { package = "parity-scale-codec", version = "3", default-features = false, features = ["derive"] }
scale-info = { version = "2.3", default-features = false, features = ["derive"], optional = true }
openbrush = { tag = "3.0.0", git = "https://github.com/727-Ventures/openbrush-contracts", default-features = false, features = ["access_control", "reentrancy_guard", "psp34"] }
openbrush = { tag = "3.1.0", git = "https://github.com/727-Ventures/openbrush-contracts", default-features = false, features = ["access_control", "reentrancy_guard", "psp34"] }

rmrk_minting = { path = "../minting", default-features = false }
rmrk_multiasset = { path = "../multiasset", default-features = false }
rmrk_nesting = { path = "../nesting", default-features = false }
rmrk_common = { path = "../common", default-features = false }
rmrk_equippable = { path = "../equippable", default-features = false }

# external contracts
rmrk_catalog = { path = "../catalog", default-features = false, features = ["ink-as-dependency"]}
rmrk_catalog = { path = "../catalog", default-features = false }

[lib]
path = "src/lib.rs"
Expand Down
2 changes: 2 additions & 0 deletions crates/rmrk/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,13 @@ pub mod storage {
pub use rmrk_minting::*;
pub use rmrk_multiasset::*;
pub use rmrk_nesting::*;
pub use rmrk_catalog::*;
}

pub mod traits {
pub use rmrk_equippable::traits::*;
pub use rmrk_minting::traits::*;
pub use rmrk_multiasset::traits::*;
pub use rmrk_nesting::traits::*;
pub use rmrk_catalog::traits::*;
}
10 changes: 4 additions & 6 deletions examples/catalog/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,11 @@ authors = ["Stake Technologies <[email protected]>"]
edition = "2021"

[dependencies]
ink = { version = "4.0.0", default-features = false }
ink = { version = "4.1.0", default-features = false }
scale = { package = "parity-scale-codec", version = "3", default-features = false, features = ["derive"] }
scale-info = { version = "2.3", default-features = false, features = ["derive"], optional = true }
openbrush = { tag = "3.0.0", git = "https://github.com/727-Ventures/openbrush-contracts", default-features = false, features = ["access_control", "reentrancy_guard", "psp34"] }

# RMRK
rmrk_catalog = { path = "../../crates/catalog", default-features = false }
openbrush = { tag = "3.1.0", git = "https://github.com/727-Ventures/openbrush-contracts", default-features = false, features = ["access_control", "reentrancy_guard", "psp34"] }
rmrk = { path = "../../crates/rmrk", default-features = false }

[lib]
path = "lib.rs"
Expand All @@ -27,6 +25,6 @@ std = [
"scale/std",
"scale-info/std",
"openbrush/std",
"rmrk_catalog/std",
"rmrk/std",
]
ink-as-dependency = []
38 changes: 20 additions & 18 deletions examples/catalog/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ pub mod catalog_example {
},
};

use rmrk_catalog::{
catalog::*,
use rmrk::{
errors::Result,
roles::*,
traits::*,
storage::*,
};

// CatalogContract contract storage
Expand All @@ -32,14 +32,14 @@ pub mod catalog_example {
impl CatalogContract {
/// Instantiate new CatalogContract contract
#[ink(constructor)]
pub fn new(catalog_metadata: String) -> Self {
pub fn new(catalog_metadata: String) -> Result<Self> {
let mut instance = CatalogContract::default();
let admin = Self::env().caller();
instance._init_with_admin(admin);
instance._setup_role(CONTRIBUTOR, admin);
_ = Catalog::setup_catalog(&mut instance, catalog_metadata);
Catalog::set_catalog_metadata(&mut instance, catalog_metadata)?;

instance
Ok(instance)
}
}

Expand All @@ -49,14 +49,13 @@ pub mod catalog_example {

use ink::env::test;

use openbrush::contracts::psp34::extensions::enumerable::*;
use rmrk_catalog::{
use rmrk::{
errors::*,
roles::ADMIN,
traits::Catalog,
types::*,
};

// use openbrush::contracts::psp34::extensions::enumerable::*;

const METADATA: &str = "ipfs://myIpfsUri/";
const EQUIPPABLE_ADDRESS1: [u8; 32] = [1; 32];
const EQUIPPABLE_ADDRESS2: [u8; 32] = [2; 32];
Expand All @@ -70,15 +69,15 @@ pub mod catalog_example {
}

fn init() -> CatalogContract {
CatalogContract::new(String::from(METADATA).into())
CatalogContract::new(String::from(METADATA).into()).expect("Contract instantiated")
}

#[ink::test]
fn add_parts_to_catalog_works() {
const ASSET_URI: &str = "asset_uri/";
const ASSET_ID: AssetId = 1;
const TOKEN_ID1: Id = Id::U64(1);
const TOKEN_ID2: Id = Id::U64(2);
// const ASSET_URI: &str = "asset_uri/";
// const ASSET_ID: AssetId = 1;
// const TOKEN_ID1: Id = Id::U64(1);
// const TOKEN_ID2: Id = Id::U64(2);
const PART_ID0: PartId = 0;
const PART_ID1: PartId = 1;

Expand Down Expand Up @@ -202,11 +201,14 @@ pub mod catalog_example {
fn setting_metadata_works() {
let mut catalog = init();

assert_eq!(catalog.get_catalog_metadata(), METADATA);
assert_eq!(catalog.get_catalog_metadata(), Ok(METADATA.to_string()));
assert!(catalog
.setup_catalog(String::from("ipfs://catalog_metadata2"))
.set_catalog_metadata(String::from("ipfs://catalog_metadata2"))
.is_ok());
assert_eq!(catalog.get_catalog_metadata(), "ipfs://catalog_metadata2");
assert_eq!(
catalog.get_catalog_metadata(),
Ok("ipfs://catalog_metadata2".to_string())
);
}

fn default_accounts() -> test::DefaultAccounts<ink::env::DefaultEnvironment> {
Expand Down
8 changes: 2 additions & 6 deletions examples/equippable-lazy/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,11 @@ authors = ["Stake Technologies <[email protected]>"]
edition = "2021"

[dependencies]
ink = { version = "4.0.0", default-features = false }
ink = { version = "4.1.0", default-features = false }
scale = { package = "parity-scale-codec", version = "3", default-features = false, features = ["derive"] }
scale-info = { version = "2.3", default-features = false, features = ["derive"], optional = true }
openbrush = { tag = "3.0.0", git = "https://github.com/727-Ventures/openbrush-contracts", default-features = false, features = ["access_control", "reentrancy_guard", "psp34"] }

# RMRK
openbrush = { tag = "3.1.0", git = "https://github.com/727-Ventures/openbrush-contracts", default-features = false, features = ["access_control", "reentrancy_guard", "psp34"] }
rmrk = { path = "../../crates/rmrk", default-features = false }
rmrk_catalog = { path = "../../crates/catalog", default-features = false }


[lib]
path = "lib.rs"
Expand Down
8 changes: 2 additions & 6 deletions examples/equippable/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,11 @@ authors = ["Stake Technologies <[email protected]>"]
edition = "2021"

[dependencies]
ink = { version = "4.0.0", default-features = false }
ink = { version = "4.1.0", default-features = false }
scale = { package = "parity-scale-codec", version = "3", default-features = false, features = ["derive"] }
scale-info = { version = "2.3", default-features = false, features = ["derive"], optional = true }
openbrush = { tag = "3.0.0", git = "https://github.com/727-Ventures/openbrush-contracts", default-features = false, features = ["access_control", "reentrancy_guard", "psp34"] }

# RMRK
openbrush = { tag = "3.1.0", git = "https://github.com/727-Ventures/openbrush-contracts", default-features = false, features = ["access_control", "reentrancy_guard", "psp34"] }
rmrk = { path = "../../crates/rmrk", default-features = false }
rmrk_catalog = { path = "../../crates/catalog", default-features = false }



[lib]
Expand Down
6 changes: 2 additions & 4 deletions examples/mintable/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,10 @@ authors = ["Stake Technologies <[email protected]>"]
edition = "2021"

[dependencies]
ink = { version = "4.0.0", default-features = false }
ink = { version = "4.1.0", default-features = false }
scale = { package = "parity-scale-codec", version = "3", default-features = false, features = ["derive"] }
scale-info = { version = "2.3", default-features = false, features = ["derive"], optional = true }
openbrush = { tag = "3.0.0", git = "https://github.com/727-Ventures/openbrush-contracts", default-features = false, features = ["access_control", "reentrancy_guard", "psp34"] }

#RMRK
openbrush = { tag = "3.1.0", git = "https://github.com/727-Ventures/openbrush-contracts", default-features = false, features = ["access_control", "reentrancy_guard", "psp34"] }
rmrk = { path = "../../crates/rmrk", default-features = false }

[lib]
Expand Down

0 comments on commit 8c63564

Please sign in to comment.