git.delta.rocks / unique-network / refs/commits / e67fafd19a27

difftreelog

Smart contract added

str-mv2020-07-06parent: #f4d3ad6.patch.diff
in: master

6 files changed

modifiedpallets/nft/src/lib.rsdiffbeforeafterboth
--- a/pallets/nft/src/lib.rs
+++ b/pallets/nft/src/lib.rs
@@ -130,7 +130,9 @@
             ensure!(prefix.len() <= 16, "Token prefix can not be longer than 15 char");
 
             // Generate next collection ID
-            let next_id = NextCollectionID::get();
+            let next_id = NextCollectionID::get()
+                .checked_add(1)
+                .expect("collection id error");
 
             NextCollectionID::put(next_id);
 
@@ -270,7 +272,9 @@
             };
 
 
-            let current_index = <ItemListIndex>::get(collection_id);
+            let current_index = <ItemListIndex>::get(collection_id)
+                .checked_add(1)
+                .expect("Item list index id error");
 
             Self::add_token_index(collection_id, current_index, new_item.owner.clone())?;
 
addedsmart_contract/nft/.gitignorediffbeforeafterboth
--- /dev/null
+++ b/smart_contract/nft/.gitignore
@@ -0,0 +1,9 @@
+# Ignore build artifacts from the local tests sub-crate.
+/target/
+
+# Ignore backup files creates by cargo fmt.
+**/*.rs.bk
+
+# Remove Cargo.lock when creating an executable, leave it for libraries
+# More information here http://doc.crates.io/guide.html#cargotoml-vs-cargolock
+Cargo.lock
addedsmart_contract/nft/.ink/abi_gen/Cargo.tomldiffbeforeafterboth
--- /dev/null
+++ b/smart_contract/nft/.ink/abi_gen/Cargo.toml
@@ -0,0 +1,16 @@
+[package]
+name = "abi-gen"
+version = "0.1.0"
+authors = ["Parity Technologies <admin@parity.io>"]
+edition = "2018"
+publish = false
+
+[[bin]]
+name = "abi-gen"
+path = "main.rs"
+
+[dependencies]
+contract = { path = "../..", package = "nft", default-features = false, features = ["ink-generate-abi"] }
+ink_lang = { version = "2", git = "https://github.com/paritytech/ink", tag = "latest-v2", package = "ink_lang", default-features = false, features = ["ink-generate-abi"] }
+serde = "1.0"
+serde_json = "1.0"
addedsmart_contract/nft/.ink/abi_gen/main.rsdiffbeforeafterboth
--- /dev/null
+++ b/smart_contract/nft/.ink/abi_gen/main.rs
@@ -0,0 +1,7 @@
+fn main() -> Result<(), std::io::Error> {
+    let abi = <contract::Nft as ink_lang::GenerateAbi>::generate_abi();
+    let contents = serde_json::to_string_pretty(&abi)?;
+    std::fs::create_dir("target").ok();
+    std::fs::write("target/metadata.json", contents)?;
+    Ok(())
+}
addedsmart_contract/nft/Cargo.tomldiffbeforeafterboth
--- /dev/null
+++ b/smart_contract/nft/Cargo.toml
@@ -0,0 +1,73 @@
+[package]
+name = "nft"
+version = "0.1.0"
+authors = ["[your_name] <[your_email]>"]
+edition = "2018"
+
+[dependencies]
+
+ink_abi = { version = "2", git = "https://github.com/paritytech/ink", tag = "latest-v2", package = "ink_abi", default-features = false, features = ["derive"], optional = true }
+ink_primitives = { version = "2", git = "https://github.com/paritytech/ink", tag = "latest-v2", package = "ink_primitives", default-features = false }
+ink_core = { version = "2", git = "https://github.com/paritytech/ink", tag = "latest-v2", package = "ink_core", default-features = false }
+ink_lang = { version = "2", git = "https://github.com/paritytech/ink", tag = "latest-v2", package = "ink_lang", default-features = false }
+scale = { package = "parity-scale-codec", version = "1.2", default-features = false, features = ["derive"] }
+
+sp-core = { git = "https://github.com/paritytech/substrate/", package = "sp-core", default-features = false }
+sp-runtime = { git = "https://github.com/paritytech/substrate/", package = "sp-runtime", default-features = false }
+sp-io = { git = "https://github.com/paritytech/substrate/", package = "sp-io", default-features = false, features = ["disable_panic_handler", "disable_oom", "disable_allocator"] }
+pallet-indices = { git = "https://github.com/paritytech/substrate/", package = "pallet-indices", default-features = false }
+
+
+[dependencies.type-metadata]
+git = "https://github.com/type-metadata/type-metadata.git"
+rev = "02eae9f35c40c943b56af5b60616219f2b72b47d"
+default-features = false
+features = ["derive"]
+optional = true
+
+[lib]
+name = "nft"
+path = "lib.rs"
+crate-type = [
+	# Used for normal contract Wasm blobs.
+	"cdylib",
+	# Required for ABI generation, and using this contract as a dependency.
+	# If using `cargo contract build`, it will be automatically disabled to produce a smaller Wasm binary
+	"rlib",
+]
+
+[features]
+default = ["test-env"]
+std = [
+    "ink_abi/std",
+    "ink_core/std",
+    "ink_primitives/std",
+    "scale/std",
+    "type-metadata/std",
+]
+test-env = [
+    "std",
+    "ink_lang/test-env",
+]
+ink-generate-abi = [
+    "std",
+    "ink_abi",
+    "type-metadata",
+    "ink_core/ink-generate-abi",
+    "ink_lang/ink-generate-abi",
+]
+ink-as-dependency = []
+
+[profile.release]
+panic = "abort"
+lto = true
+opt-level = "z"
+overflow-checks = true
+
+[workspace]
+members = [
+	".ink/abi_gen"
+]
+exclude = [
+	".ink"
+]
addedsmart_contract/nft/lib.rsdiffbeforeafterboth

no changes