git.delta.rocks / unique-network / refs/commits / 0a7b60da8a0b

difftreelog

feat implement all CE calls in test contract

Yaroslav Bolyukin2021-06-04parent: #0b72135.patch.diff
in: master

4 files changed

modifiedsmart_contracs/transfer/Cargo.tomldiffbeforeafterboth
--- a/smart_contracs/transfer/Cargo.toml
+++ b/smart_contracs/transfer/Cargo.toml
@@ -4,15 +4,17 @@
 authors = ["[Greg Zaitsev] <[your_email]>"]
 edition = "2018"
 
+[workspace]
+
 [dependencies]
-ink_primitives = { git = "https://github.com/usetech-llc/ink", branch = "unique", default-features = false }
-ink_metadata = { git = "https://github.com/usetech-llc/ink", branch = "unique", default-features = false, features = ["derive"], optional = true }
-ink_env = { git = "https://github.com/usetech-llc/ink", branch = "unique", default-features = false }
-ink_storage = { git = "https://github.com/usetech-llc/ink", branch = "unique", default-features = false }
-ink_lang = { git = "https://github.com/usetech-llc/ink", branch = "unique", default-features = false }
+ink_primitives = { default-features = false }
+ink_metadata = { default-features = false, features = ["derive"], optional = true }
+ink_env = { default-features = false }
+ink_storage = { default-features = false }
+ink_lang = { default-features = false }
 
-scale = { package = "parity-scale-codec", version = "1.3", default-features = false, features = ["derive"] }
-scale-info = { version = "0.4.1", default-features = false, features = ["derive"], optional = true }
+scale = { package = "parity-scale-codec", version = "2.1.1", default-features = false, features = ["derive"] }
+scale-info = { version = "0.6.0", default-features = false, features = ["derive"] }
 
 [lib]
 name = "nft_transfer"
@@ -28,6 +30,7 @@
     "ink_metadata/std",
     "ink_env/std",
     "ink_storage/std",
+    "ink_lang/std",
     "ink_primitives/std",
     "scale/std",
     "scale-info/std",
modifiedsmart_contracs/transfer/lib.rsdiffbeforeafterboth
before · smart_contracs/transfer/lib.rs
1#![cfg_attr(not(feature = "std"), no_std)]23use ink_lang as ink;4use ink_env::{Environment, DefaultEnvironment};56pub enum NftEnvironment {}78impl Environment for NftEnvironment {9    const MAX_EVENT_TOPICS: usize =10        <DefaultEnvironment as Environment>::MAX_EVENT_TOPICS;1112    type AccountId = <DefaultEnvironment as Environment>::AccountId;13    type Balance = <DefaultEnvironment as Environment>::Balance;14    type Hash = <DefaultEnvironment as Environment>::Hash;15    type BlockNumber = <DefaultEnvironment as Environment>::BlockNumber;16    type Timestamp = <DefaultEnvironment as Environment>::Timestamp;1718    type ChainExtension = NftChainExtension;19}2021/// The shared error code for the NFT chain extension.22#[derive(23    Debug, Copy, Clone, PartialEq, Eq, scale::Encode, scale::Decode,24)]25pub enum NftErrorCode {26    SomeError,27}2829impl ink_env::chain_extension::FromStatusCode for NftErrorCode {30    fn from_status_code(status_code: u32) -> Result<(), Self> {31        match status_code {32            0 => Ok(()),33            1 => Err(Self::SomeError),34            _ => panic!("encountered unknown status code"),35        }36    }37}3839#[ink::chain_extension]40pub trait NftChainExtension {41    type ErrorCode = NftErrorCode;4243    /// Transfer one NFT token from sender44    ///45    #[ink(extension = 0, returns_result = false)]46    fn transfer(recipient: <DefaultEnvironment as Environment>::AccountId, collection_id: u32, token_id: u32, amount: u128);47}4849#[ink::contract(env = crate::NftEnvironment)]50mod nft_transfer {5152    #[ink(storage)]53    pub struct NftTransfer {54    }5556    impl NftTransfer {57        /// Default Constructor58        ///59        /// Constructors can delegate to other constructors.60        #[ink(constructor)]61        pub fn default() -> Self {62            Self {}63        }6465        /// Transfer one NFT token66        #[ink(message)]67        pub fn transfer(&mut self, recipient: AccountId, collection_id: u32, token_id: u32, amount: u128) {68            let _ = self.env()69                .extension()70                .transfer(recipient, collection_id, token_id, amount);71        }7273    }7475}
modifiedtests/src/transfer_contract/metadata.jsondiffbeforeafterboth
--- a/tests/src/transfer_contract/metadata.json
+++ b/tests/src/transfer_contract/metadata.json
@@ -1,9 +1,9 @@
 {
   "metadataVersion": "0.1.0",
   "source": {
-    "hash": "0xfbbc0729acefed9d99f93f6cbb751d12e317958fd0fe183f5781329b37f1bf6e",
-    "language": "ink! 3.0.0-rc2",
-    "compiler": "rustc 1.51.0-nightly"
+    "hash": "0xc6c3f47adeafe86d1674ed72c7179605787842f2f05a2d7da0dbabf3c4fa1aa8",
+    "language": "ink! 3.0.0-rc3",
+    "compiler": "rustc 1.52.0-nightly"
   },
   "contract": {
     "name": "nft_transfer",
@@ -24,7 +24,7 @@
         "name": [
           "default"
         ],
-        "selector": "0x6a3712e2"
+        "selector": "0xed4b9d1b"
       }
     ],
     "docs": [],
@@ -78,7 +78,268 @@
         ],
         "payable": false,
         "returnType": null,
-        "selector": "0xfae3a09d"
+        "selector": "0x84a15da1"
+      },
+      {
+        "args": [
+          {
+            "name": "recipient",
+            "type": {
+              "displayName": [
+                "AccountId"
+              ],
+              "type": 1
+            }
+          },
+          {
+            "name": "collection_id",
+            "type": {
+              "displayName": [
+                "u32"
+              ],
+              "type": 4
+            }
+          },
+          {
+            "name": "data",
+            "type": {
+              "displayName": [
+                "CreateItemData"
+              ],
+              "type": 6
+            }
+          }
+        ],
+        "docs": [],
+        "mutates": true,
+        "name": [
+          "create_item"
+        ],
+        "payable": false,
+        "returnType": null,
+        "selector": "0xd7c3f083"
+      },
+      {
+        "args": [
+          {
+            "name": "owner",
+            "type": {
+              "displayName": [
+                "AccountId"
+              ],
+              "type": 1
+            }
+          },
+          {
+            "name": "collection_id",
+            "type": {
+              "displayName": [
+                "u32"
+              ],
+              "type": 4
+            }
+          },
+          {
+            "name": "data",
+            "type": {
+              "displayName": [
+                "Vec"
+              ],
+              "type": 8
+            }
+          }
+        ],
+        "docs": [],
+        "mutates": true,
+        "name": [
+          "create_multiple_items"
+        ],
+        "payable": false,
+        "returnType": null,
+        "selector": "0x15f9a1eb"
+      },
+      {
+        "args": [
+          {
+            "name": "spender",
+            "type": {
+              "displayName": [
+                "AccountId"
+              ],
+              "type": 1
+            }
+          },
+          {
+            "name": "collection_id",
+            "type": {
+              "displayName": [
+                "u32"
+              ],
+              "type": 4
+            }
+          },
+          {
+            "name": "item_id",
+            "type": {
+              "displayName": [
+                "u32"
+              ],
+              "type": 4
+            }
+          },
+          {
+            "name": "amount",
+            "type": {
+              "displayName": [
+                "u128"
+              ],
+              "type": 5
+            }
+          }
+        ],
+        "docs": [],
+        "mutates": true,
+        "name": [
+          "approve"
+        ],
+        "payable": false,
+        "returnType": null,
+        "selector": "0x681266a0"
+      },
+      {
+        "args": [
+          {
+            "name": "owner",
+            "type": {
+              "displayName": [
+                "AccountId"
+              ],
+              "type": 1
+            }
+          },
+          {
+            "name": "recipient",
+            "type": {
+              "displayName": [
+                "AccountId"
+              ],
+              "type": 1
+            }
+          },
+          {
+            "name": "collection_id",
+            "type": {
+              "displayName": [
+                "u32"
+              ],
+              "type": 4
+            }
+          },
+          {
+            "name": "item_id",
+            "type": {
+              "displayName": [
+                "u32"
+              ],
+              "type": 4
+            }
+          },
+          {
+            "name": "amount",
+            "type": {
+              "displayName": [
+                "u128"
+              ],
+              "type": 5
+            }
+          }
+        ],
+        "docs": [],
+        "mutates": true,
+        "name": [
+          "transfer_from"
+        ],
+        "payable": false,
+        "returnType": null,
+        "selector": "0x0b396f18"
+      },
+      {
+        "args": [
+          {
+            "name": "collection_id",
+            "type": {
+              "displayName": [
+                "u32"
+              ],
+              "type": 4
+            }
+          },
+          {
+            "name": "item_id",
+            "type": {
+              "displayName": [
+                "u32"
+              ],
+              "type": 4
+            }
+          },
+          {
+            "name": "data",
+            "type": {
+              "displayName": [
+                "Vec"
+              ],
+              "type": 7
+            }
+          }
+        ],
+        "docs": [],
+        "mutates": true,
+        "name": [
+          "set_variable_meta_data"
+        ],
+        "payable": false,
+        "returnType": null,
+        "selector": "0xb0b26da2"
+      },
+      {
+        "args": [
+          {
+            "name": "collection_id",
+            "type": {
+              "displayName": [
+                "u32"
+              ],
+              "type": 4
+            }
+          },
+          {
+            "name": "address",
+            "type": {
+              "displayName": [
+                "AccountId"
+              ],
+              "type": 1
+            }
+          },
+          {
+            "name": "whitelisted",
+            "type": {
+              "displayName": [
+                "bool"
+              ],
+              "type": 9
+            }
+          }
+        ],
+        "docs": [],
+        "mutates": true,
+        "name": [
+          "toggle_white_list"
+        ],
+        "payable": false,
+        "returnType": null,
+        "selector": "0x98574dac"
       }
     ]
   },
@@ -93,7 +354,8 @@
         "composite": {
           "fields": [
             {
-              "type": 2
+              "type": 2,
+              "typeName": "[u8; 32]"
             }
           ]
         }
@@ -126,6 +388,82 @@
       "def": {
         "primitive": "u128"
       }
+    },
+    {
+      "def": {
+        "variant": {
+          "variants": [
+            {
+              "fields": [
+                {
+                  "name": "const_data",
+                  "type": 7,
+                  "typeName": "Vec<u8>"
+                },
+                {
+                  "name": "variable_data",
+                  "type": 7,
+                  "typeName": "Vec<u8>"
+                }
+              ],
+              "name": "Nft"
+            },
+            {
+              "fields": [
+                {
+                  "name": "value",
+                  "type": 5,
+                  "typeName": "u128"
+                }
+              ],
+              "name": "Fungible"
+            },
+            {
+              "fields": [
+                {
+                  "name": "const_data",
+                  "type": 7,
+                  "typeName": "Vec<u8>"
+                },
+                {
+                  "name": "variable_data",
+                  "type": 7,
+                  "typeName": "Vec<u8>"
+                },
+                {
+                  "name": "pieces",
+                  "type": 5,
+                  "typeName": "u128"
+                }
+              ],
+              "name": "ReFungible"
+            }
+          ]
+        }
+      },
+      "path": [
+        "nft_transfer",
+        "CreateItemData"
+      ]
+    },
+    {
+      "def": {
+        "sequence": {
+          "type": 3
+        }
+      }
+    },
+    {
+      "def": {
+        "sequence": {
+          "type": 6
+        }
+      }
+    },
+    {
+      "def": {
+        "primitive": "bool"
+      }
     }
   ]
 }
\ No newline at end of file
modifiedtests/src/transfer_contract/nft_transfer.wasmdiffbeforeafterboth

binary blob — no preview