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

difftreelog

Merge pull request #6 from usetech-llc/feature/NFTPAR-93

usetech-llc2020-10-07parents: #ab1a681 #8eb82cd.patch.diff
in: master
Feature/nftpar-93

15 files changed

addedpurge-running-node.shdiffbeforeafterboth
--- /dev/null
+++ b/purge-running-node.sh
@@ -0,0 +1,3 @@
+docker-compose exec node nft purge-chain --dev --base-path=/chain-data -y
+docker-compose down
+docker-compose up -d
addedtests/flipper-src/.gitignorediffbeforeafterboth
--- /dev/null
+++ b/tests/flipper-src/.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
addedtests/flipper-src/.ink/abi_gen/Cargo.tomldiffbeforeafterboth
--- /dev/null
+++ b/tests/flipper-src/.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 = "flipper", 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"
addedtests/flipper-src/.ink/abi_gen/main.rsdiffbeforeafterboth
--- /dev/null
+++ b/tests/flipper-src/.ink/abi_gen/main.rs
@@ -0,0 +1,7 @@
+fn main() -> Result<(), std::io::Error> {
+    let abi = <contract::Flipper 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(())
+}
addedtests/flipper-src/Cargo.tomldiffbeforeafterboth
--- /dev/null
+++ b/tests/flipper-src/Cargo.toml
@@ -0,0 +1,67 @@
+[package]
+name = "flipper"
+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"] }
+
+[dependencies.type-metadata]
+git = "https://github.com/type-metadata/type-metadata.git"
+rev = "02eae9f35c40c943b56af5b60616219f2b72b47d"
+default-features = false
+features = ["derive"]
+optional = true
+
+[lib]
+name = "flipper"
+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"
+]
addedtests/flipper-src/build.shdiffbeforeafterboth
--- /dev/null
+++ b/tests/flipper-src/build.sh
@@ -0,0 +1,2 @@
+cargo +nightly contract build
+cargo +nightly contract generate-metadata
addedtests/flipper-src/lib.rsdiffbeforeafterboth
--- /dev/null
+++ b/tests/flipper-src/lib.rs
@@ -0,0 +1,76 @@
+#![cfg_attr(not(feature = "std"), no_std)]
+
+use ink_lang as ink;
+
+#[ink::contract(version = "0.1.0")]
+mod flipper {
+    use ink_core::storage;
+
+    /// Defines the storage of your contract.
+    /// Add new fields to the below struct in order
+    /// to add new static storage fields to your contract.
+    #[ink(storage)]
+    struct Flipper {
+        /// Stores a single `bool` value on the storage.
+        value: storage::Value<bool>,
+    }
+
+    impl Flipper {
+        /// Constructor that initializes the `bool` value to the given `init_value`.
+        #[ink(constructor)]
+        fn new(&mut self, init_value: bool) {
+            self.value.set(init_value);
+        }
+
+        /// Constructor that initializes the `bool` value to `false`.
+        ///
+        /// Constructors can delegate to other constructors.
+        #[ink(constructor)]
+        fn default(&mut self) {
+            self.new(false)
+        }
+
+        /// A message that can be called on instantiated contracts.
+        /// This one flips the value of the stored `bool` from `true`
+        /// to `false` and vice versa.
+        #[ink(message)]
+        fn flip(&mut self) {
+            *self.value = !self.get();
+        }
+
+        /// Simply returns the current value of our `bool`.
+        #[ink(message)]
+        fn get(&self) -> bool {
+            *self.value
+        }
+    }
+
+    /// Unit tests in Rust are normally defined within such a `#[cfg(test)]`
+    /// module and test functions are marked with a `#[test]` attribute.
+    /// The below code is technically just normal Rust code.
+    #[cfg(test)]
+    mod tests {
+        /// Imports all the definitions from the outer scope so we can use them here.
+        use super::*;
+
+        /// We test if the default constructor does its job.
+        #[test]
+        fn default_works() {
+            // Note that even though we defined our `#[ink(constructor)]`
+            // above as `&mut self` functions that return nothing we can call
+            // them in test code as if they were normal Rust constructors
+            // that take no `self` argument but return `Self`.
+            let flipper = Flipper::default();
+            assert_eq!(flipper.get(), false);
+        }
+
+        /// We test a simple use case of our contract.
+        #[test]
+        fn it_works() {
+            let mut flipper = Flipper::new(false);
+            assert_eq!(flipper.get(), false);
+            flipper.flip();
+            assert_eq!(flipper.get(), true);
+        }
+    }
+}
modifiedtests/package-lock.jsondiffbeforeafterboth
--- a/tests/package-lock.json
+++ b/tests/package-lock.json
@@ -3933,8 +3933,197 @@
         "bn.js": "^5.1.3",
         "eventemitter3": "^4.0.7",
         "rxjs": "^6.6.3"
+      },
+      "dependencies": {
+        "@polkadot/metadata": {
+          "version": "1.34.1",
+          "resolved": "https://registry.npmjs.org/@polkadot/metadata/-/metadata-1.34.1.tgz",
+          "integrity": "sha512-uoaOhNHjECDaLBYvGRaLvF0mhZBFmsV3oikYDP4sZx3a5oD0xYsyXtr5bFPQDImwPFASP8/ltrMVqcYTX42xFg==",
+          "requires": {
+            "@babel/runtime": "^7.11.2",
+            "@polkadot/types": "1.34.1",
+            "@polkadot/types-known": "1.34.1",
+            "@polkadot/util": "^3.4.1",
+            "@polkadot/util-crypto": "^3.4.1",
+            "bn.js": "^5.1.3"
+          }
+        },
+        "@polkadot/types": {
+          "version": "1.34.1",
+          "resolved": "https://registry.npmjs.org/@polkadot/types/-/types-1.34.1.tgz",
+          "integrity": "sha512-jPwix2y+ZXKYB4ghODXlqYmcI3Tnsl3iO3xIkiGsZhhs9PdrKibcNeAv4LUiRpPuGRnAM+mrlPrBbCuzguKSGg==",
+          "requires": {
+            "@babel/runtime": "^7.11.2",
+            "@polkadot/metadata": "1.34.1",
+            "@polkadot/util": "^3.4.1",
+            "@polkadot/util-crypto": "^3.4.1",
+            "@types/bn.js": "^4.11.6",
+            "bn.js": "^5.1.3",
+            "memoizee": "^0.4.14",
+            "rxjs": "^6.6.3"
+          }
+        },
+        "@polkadot/types-known": {
+          "version": "1.34.1",
+          "resolved": "https://registry.npmjs.org/@polkadot/types-known/-/types-known-1.34.1.tgz",
+          "integrity": "sha512-H9V8u9cqbKjxU/dxEyLl7kJwoBImXpRskQ5+X0fq3BH7g1nQ6jrIg/buRPpbc3GxKivdFYUZWshPY9hbqE8y8A==",
+          "requires": {
+            "@babel/runtime": "^7.11.2",
+            "@polkadot/types": "1.34.1",
+            "@polkadot/util": "^3.4.1",
+            "bn.js": "^5.1.3"
+          }
+        },
+        "@polkadot/util": {
+          "version": "3.4.1",
+          "resolved": "https://registry.npmjs.org/@polkadot/util/-/util-3.4.1.tgz",
+          "integrity": "sha512-CJo0wAzXR8vjAzs9mHDooZr5a3XRW8LlYWik8d/+bv1VDwCC/metSiBrYBOapFhYUjlS5IYIw5bhWS5dnpkXvQ==",
+          "requires": {
+            "@babel/runtime": "^7.11.2",
+            "@types/bn.js": "^4.11.6",
+            "bn.js": "^5.1.3",
+            "camelcase": "^5.3.1",
+            "chalk": "^4.1.0",
+            "ip-regex": "^4.1.0"
+          }
+        }
       }
     },
+    "@polkadot/api-contract": {
+      "version": "1.34.1",
+      "resolved": "https://registry.npmjs.org/@polkadot/api-contract/-/api-contract-1.34.1.tgz",
+      "integrity": "sha512-oXh7An6E9wdbczXQhw+TfIkoKLQr4t0j3OwxubrhS5Qn6f99xGoAkk0BIKjsHPGIbMHEJoywmmLrDUAeTxExgg==",
+      "requires": {
+        "@babel/runtime": "^7.11.2",
+        "@polkadot/api": "1.34.1",
+        "@polkadot/rpc-core": "1.34.1",
+        "@polkadot/types": "1.34.1",
+        "@polkadot/util": "^3.4.1",
+        "bn.js": "^5.1.3",
+        "rxjs": "^6.6.3"
+      },
+      "dependencies": {
+        "@polkadot/api": {
+          "version": "1.34.1",
+          "resolved": "https://registry.npmjs.org/@polkadot/api/-/api-1.34.1.tgz",
+          "integrity": "sha512-3gCibNRchH+XbEdULS1bwiV1RgarZW1PDw1Y1mAQBVqPrUpkYqntp1D52SQOpAbRzldkwk296Sj+mx9/IeDRXA==",
+          "requires": {
+            "@babel/runtime": "^7.11.2",
+            "@polkadot/api-derive": "1.34.1",
+            "@polkadot/keyring": "^3.4.1",
+            "@polkadot/metadata": "1.34.1",
+            "@polkadot/rpc-core": "1.34.1",
+            "@polkadot/rpc-provider": "1.34.1",
+            "@polkadot/types": "1.34.1",
+            "@polkadot/types-known": "1.34.1",
+            "@polkadot/util": "^3.4.1",
+            "@polkadot/util-crypto": "^3.4.1",
+            "bn.js": "^5.1.3",
+            "eventemitter3": "^4.0.7",
+            "rxjs": "^6.6.3"
+          }
+        },
+        "@polkadot/api-derive": {
+          "version": "1.34.1",
+          "resolved": "https://registry.npmjs.org/@polkadot/api-derive/-/api-derive-1.34.1.tgz",
+          "integrity": "sha512-LMlCkNJRp29MwKa36crYuY6cZpnkHCFrPCv9dmJEuDbMqrK+EAhXM9/6sTDYJ4uKNhyetJKe9rXslkXdI6pidA==",
+          "requires": {
+            "@babel/runtime": "^7.11.2",
+            "@polkadot/api": "1.34.1",
+            "@polkadot/rpc-core": "1.34.1",
+            "@polkadot/rpc-provider": "1.34.1",
+            "@polkadot/types": "1.34.1",
+            "@polkadot/util": "^3.4.1",
+            "@polkadot/util-crypto": "^3.4.1",
+            "bn.js": "^5.1.3",
+            "memoizee": "^0.4.14",
+            "rxjs": "^6.6.3"
+          }
+        },
+        "@polkadot/metadata": {
+          "version": "1.34.1",
+          "resolved": "https://registry.npmjs.org/@polkadot/metadata/-/metadata-1.34.1.tgz",
+          "integrity": "sha512-uoaOhNHjECDaLBYvGRaLvF0mhZBFmsV3oikYDP4sZx3a5oD0xYsyXtr5bFPQDImwPFASP8/ltrMVqcYTX42xFg==",
+          "requires": {
+            "@babel/runtime": "^7.11.2",
+            "@polkadot/types": "1.34.1",
+            "@polkadot/types-known": "1.34.1",
+            "@polkadot/util": "^3.4.1",
+            "@polkadot/util-crypto": "^3.4.1",
+            "bn.js": "^5.1.3"
+          }
+        },
+        "@polkadot/rpc-core": {
+          "version": "1.34.1",
+          "resolved": "https://registry.npmjs.org/@polkadot/rpc-core/-/rpc-core-1.34.1.tgz",
+          "integrity": "sha512-BVQDyBEkbRe5b/u8p9UPpTCj0sDZ32sTmPEP43Klc4s9+oHtiNvOFYvkjK5oyW9dlcOwXi8HpLsQxGAeMtM7Tw==",
+          "requires": {
+            "@babel/runtime": "^7.11.2",
+            "@polkadot/metadata": "1.34.1",
+            "@polkadot/rpc-provider": "1.34.1",
+            "@polkadot/types": "1.34.1",
+            "@polkadot/util": "^3.4.1",
+            "memoizee": "^0.4.14",
+            "rxjs": "^6.6.3"
+          }
+        },
+        "@polkadot/rpc-provider": {
+          "version": "1.34.1",
+          "resolved": "https://registry.npmjs.org/@polkadot/rpc-provider/-/rpc-provider-1.34.1.tgz",
+          "integrity": "sha512-bebeis9mB4LS9Spk1WSHoadZHsyHmK4gyyC6uKSLZxHZmnopWna6zWnOBIrYHRz7qDHSZC5eNTseuU8NJXtscA==",
+          "requires": {
+            "@babel/runtime": "^7.11.2",
+            "@polkadot/metadata": "1.34.1",
+            "@polkadot/types": "1.34.1",
+            "@polkadot/util": "^3.4.1",
+            "@polkadot/util-crypto": "^3.4.1",
+            "@polkadot/x-fetch": "^0.3.2",
+            "@polkadot/x-ws": "^0.3.2",
+            "bn.js": "^5.1.3",
+            "eventemitter3": "^4.0.7"
+          }
+        },
+        "@polkadot/types": {
+          "version": "1.34.1",
+          "resolved": "https://registry.npmjs.org/@polkadot/types/-/types-1.34.1.tgz",
+          "integrity": "sha512-jPwix2y+ZXKYB4ghODXlqYmcI3Tnsl3iO3xIkiGsZhhs9PdrKibcNeAv4LUiRpPuGRnAM+mrlPrBbCuzguKSGg==",
+          "requires": {
+            "@babel/runtime": "^7.11.2",
+            "@polkadot/metadata": "1.34.1",
+            "@polkadot/util": "^3.4.1",
+            "@polkadot/util-crypto": "^3.4.1",
+            "@types/bn.js": "^4.11.6",
+            "bn.js": "^5.1.3",
+            "memoizee": "^0.4.14",
+            "rxjs": "^6.6.3"
+          }
+        },
+        "@polkadot/types-known": {
+          "version": "1.34.1",
+          "resolved": "https://registry.npmjs.org/@polkadot/types-known/-/types-known-1.34.1.tgz",
+          "integrity": "sha512-H9V8u9cqbKjxU/dxEyLl7kJwoBImXpRskQ5+X0fq3BH7g1nQ6jrIg/buRPpbc3GxKivdFYUZWshPY9hbqE8y8A==",
+          "requires": {
+            "@babel/runtime": "^7.11.2",
+            "@polkadot/types": "1.34.1",
+            "@polkadot/util": "^3.4.1",
+            "bn.js": "^5.1.3"
+          }
+        },
+        "@polkadot/util": {
+          "version": "3.4.1",
+          "resolved": "https://registry.npmjs.org/@polkadot/util/-/util-3.4.1.tgz",
+          "integrity": "sha512-CJo0wAzXR8vjAzs9mHDooZr5a3XRW8LlYWik8d/+bv1VDwCC/metSiBrYBOapFhYUjlS5IYIw5bhWS5dnpkXvQ==",
+          "requires": {
+            "@babel/runtime": "^7.11.2",
+            "@types/bn.js": "^4.11.6",
+            "bn.js": "^5.1.3",
+            "camelcase": "^5.3.1",
+            "chalk": "^4.1.0",
+            "ip-regex": "^4.1.0"
+          }
+        }
+      }
+    },
     "@polkadot/api-derive": {
       "version": "1.34.1",
       "resolved": "https://registry.npmjs.org/@polkadot/api-derive/-/api-derive-1.34.1.tgz",
@@ -3950,6 +4139,60 @@
         "bn.js": "^5.1.3",
         "memoizee": "^0.4.14",
         "rxjs": "^6.6.3"
+      },
+      "dependencies": {
+        "@polkadot/metadata": {
+          "version": "1.34.1",
+          "resolved": "https://registry.npmjs.org/@polkadot/metadata/-/metadata-1.34.1.tgz",
+          "integrity": "sha512-uoaOhNHjECDaLBYvGRaLvF0mhZBFmsV3oikYDP4sZx3a5oD0xYsyXtr5bFPQDImwPFASP8/ltrMVqcYTX42xFg==",
+          "requires": {
+            "@babel/runtime": "^7.11.2",
+            "@polkadot/types": "1.34.1",
+            "@polkadot/types-known": "1.34.1",
+            "@polkadot/util": "^3.4.1",
+            "@polkadot/util-crypto": "^3.4.1",
+            "bn.js": "^5.1.3"
+          }
+        },
+        "@polkadot/types": {
+          "version": "1.34.1",
+          "resolved": "https://registry.npmjs.org/@polkadot/types/-/types-1.34.1.tgz",
+          "integrity": "sha512-jPwix2y+ZXKYB4ghODXlqYmcI3Tnsl3iO3xIkiGsZhhs9PdrKibcNeAv4LUiRpPuGRnAM+mrlPrBbCuzguKSGg==",
+          "requires": {
+            "@babel/runtime": "^7.11.2",
+            "@polkadot/metadata": "1.34.1",
+            "@polkadot/util": "^3.4.1",
+            "@polkadot/util-crypto": "^3.4.1",
+            "@types/bn.js": "^4.11.6",
+            "bn.js": "^5.1.3",
+            "memoizee": "^0.4.14",
+            "rxjs": "^6.6.3"
+          }
+        },
+        "@polkadot/types-known": {
+          "version": "1.34.1",
+          "resolved": "https://registry.npmjs.org/@polkadot/types-known/-/types-known-1.34.1.tgz",
+          "integrity": "sha512-H9V8u9cqbKjxU/dxEyLl7kJwoBImXpRskQ5+X0fq3BH7g1nQ6jrIg/buRPpbc3GxKivdFYUZWshPY9hbqE8y8A==",
+          "requires": {
+            "@babel/runtime": "^7.11.2",
+            "@polkadot/types": "1.34.1",
+            "@polkadot/util": "^3.4.1",
+            "bn.js": "^5.1.3"
+          }
+        },
+        "@polkadot/util": {
+          "version": "3.4.1",
+          "resolved": "https://registry.npmjs.org/@polkadot/util/-/util-3.4.1.tgz",
+          "integrity": "sha512-CJo0wAzXR8vjAzs9mHDooZr5a3XRW8LlYWik8d/+bv1VDwCC/metSiBrYBOapFhYUjlS5IYIw5bhWS5dnpkXvQ==",
+          "requires": {
+            "@babel/runtime": "^7.11.2",
+            "@types/bn.js": "^4.11.6",
+            "bn.js": "^5.1.3",
+            "camelcase": "^5.3.1",
+            "chalk": "^4.1.0",
+            "ip-regex": "^4.1.0"
+          }
+        }
       }
     },
     "@polkadot/dev": {
@@ -4034,13 +4277,28 @@
       }
     },
     "@polkadot/keyring": {
-      "version": "3.5.1",
-      "resolved": "https://registry.npmjs.org/@polkadot/keyring/-/keyring-3.5.1.tgz",
-      "integrity": "sha512-Wg8PBACl+RobbmcShl659/5a+foU1j7PGdvdr2pZowkZul8jvwyAN+piIyPSfrsaJkbUoDUR9Pe+oVoeF4ZoXg==",
+      "version": "3.4.1",
+      "resolved": "https://registry.npmjs.org/@polkadot/keyring/-/keyring-3.4.1.tgz",
+      "integrity": "sha512-x8FxzDzyFX5ai+tnPaxAFUBV/2Mw/om8sRoMh+fT6Jzh3nC7pXfecH5ticJPKe73v/y42hn9xM0tiAI5P8Ohcw==",
       "requires": {
         "@babel/runtime": "^7.11.2",
-        "@polkadot/util": "3.5.1",
-        "@polkadot/util-crypto": "3.5.1"
+        "@polkadot/util": "3.4.1",
+        "@polkadot/util-crypto": "3.4.1"
+      },
+      "dependencies": {
+        "@polkadot/util": {
+          "version": "3.4.1",
+          "resolved": "https://registry.npmjs.org/@polkadot/util/-/util-3.4.1.tgz",
+          "integrity": "sha512-CJo0wAzXR8vjAzs9mHDooZr5a3XRW8LlYWik8d/+bv1VDwCC/metSiBrYBOapFhYUjlS5IYIw5bhWS5dnpkXvQ==",
+          "requires": {
+            "@babel/runtime": "^7.11.2",
+            "@types/bn.js": "^4.11.6",
+            "bn.js": "^5.1.3",
+            "camelcase": "^5.3.1",
+            "chalk": "^4.1.0",
+            "ip-regex": "^4.1.0"
+          }
+        }
       }
     },
     "@polkadot/metadata": {
@@ -4054,6 +4312,21 @@
         "@polkadot/util": "^3.4.1",
         "@polkadot/util-crypto": "^3.4.1",
         "bn.js": "^5.1.3"
+      },
+      "dependencies": {
+        "@polkadot/util": {
+          "version": "3.4.1",
+          "resolved": "https://registry.npmjs.org/@polkadot/util/-/util-3.4.1.tgz",
+          "integrity": "sha512-CJo0wAzXR8vjAzs9mHDooZr5a3XRW8LlYWik8d/+bv1VDwCC/metSiBrYBOapFhYUjlS5IYIw5bhWS5dnpkXvQ==",
+          "requires": {
+            "@babel/runtime": "^7.11.2",
+            "@types/bn.js": "^4.11.6",
+            "bn.js": "^5.1.3",
+            "camelcase": "^5.3.1",
+            "chalk": "^4.1.0",
+            "ip-regex": "^4.1.0"
+          }
+        }
       }
     },
     "@polkadot/rpc-core": {
@@ -4068,6 +4341,60 @@
         "@polkadot/util": "^3.4.1",
         "memoizee": "^0.4.14",
         "rxjs": "^6.6.3"
+      },
+      "dependencies": {
+        "@polkadot/metadata": {
+          "version": "1.34.1",
+          "resolved": "https://registry.npmjs.org/@polkadot/metadata/-/metadata-1.34.1.tgz",
+          "integrity": "sha512-uoaOhNHjECDaLBYvGRaLvF0mhZBFmsV3oikYDP4sZx3a5oD0xYsyXtr5bFPQDImwPFASP8/ltrMVqcYTX42xFg==",
+          "requires": {
+            "@babel/runtime": "^7.11.2",
+            "@polkadot/types": "1.34.1",
+            "@polkadot/types-known": "1.34.1",
+            "@polkadot/util": "^3.4.1",
+            "@polkadot/util-crypto": "^3.4.1",
+            "bn.js": "^5.1.3"
+          }
+        },
+        "@polkadot/types": {
+          "version": "1.34.1",
+          "resolved": "https://registry.npmjs.org/@polkadot/types/-/types-1.34.1.tgz",
+          "integrity": "sha512-jPwix2y+ZXKYB4ghODXlqYmcI3Tnsl3iO3xIkiGsZhhs9PdrKibcNeAv4LUiRpPuGRnAM+mrlPrBbCuzguKSGg==",
+          "requires": {
+            "@babel/runtime": "^7.11.2",
+            "@polkadot/metadata": "1.34.1",
+            "@polkadot/util": "^3.4.1",
+            "@polkadot/util-crypto": "^3.4.1",
+            "@types/bn.js": "^4.11.6",
+            "bn.js": "^5.1.3",
+            "memoizee": "^0.4.14",
+            "rxjs": "^6.6.3"
+          }
+        },
+        "@polkadot/types-known": {
+          "version": "1.34.1",
+          "resolved": "https://registry.npmjs.org/@polkadot/types-known/-/types-known-1.34.1.tgz",
+          "integrity": "sha512-H9V8u9cqbKjxU/dxEyLl7kJwoBImXpRskQ5+X0fq3BH7g1nQ6jrIg/buRPpbc3GxKivdFYUZWshPY9hbqE8y8A==",
+          "requires": {
+            "@babel/runtime": "^7.11.2",
+            "@polkadot/types": "1.34.1",
+            "@polkadot/util": "^3.4.1",
+            "bn.js": "^5.1.3"
+          }
+        },
+        "@polkadot/util": {
+          "version": "3.4.1",
+          "resolved": "https://registry.npmjs.org/@polkadot/util/-/util-3.4.1.tgz",
+          "integrity": "sha512-CJo0wAzXR8vjAzs9mHDooZr5a3XRW8LlYWik8d/+bv1VDwCC/metSiBrYBOapFhYUjlS5IYIw5bhWS5dnpkXvQ==",
+          "requires": {
+            "@babel/runtime": "^7.11.2",
+            "@types/bn.js": "^4.11.6",
+            "bn.js": "^5.1.3",
+            "camelcase": "^5.3.1",
+            "chalk": "^4.1.0",
+            "ip-regex": "^4.1.0"
+          }
+        }
       }
     },
     "@polkadot/rpc-provider": {
@@ -4084,6 +4411,60 @@
         "@polkadot/x-ws": "^0.3.2",
         "bn.js": "^5.1.3",
         "eventemitter3": "^4.0.7"
+      },
+      "dependencies": {
+        "@polkadot/metadata": {
+          "version": "1.34.1",
+          "resolved": "https://registry.npmjs.org/@polkadot/metadata/-/metadata-1.34.1.tgz",
+          "integrity": "sha512-uoaOhNHjECDaLBYvGRaLvF0mhZBFmsV3oikYDP4sZx3a5oD0xYsyXtr5bFPQDImwPFASP8/ltrMVqcYTX42xFg==",
+          "requires": {
+            "@babel/runtime": "^7.11.2",
+            "@polkadot/types": "1.34.1",
+            "@polkadot/types-known": "1.34.1",
+            "@polkadot/util": "^3.4.1",
+            "@polkadot/util-crypto": "^3.4.1",
+            "bn.js": "^5.1.3"
+          }
+        },
+        "@polkadot/types": {
+          "version": "1.34.1",
+          "resolved": "https://registry.npmjs.org/@polkadot/types/-/types-1.34.1.tgz",
+          "integrity": "sha512-jPwix2y+ZXKYB4ghODXlqYmcI3Tnsl3iO3xIkiGsZhhs9PdrKibcNeAv4LUiRpPuGRnAM+mrlPrBbCuzguKSGg==",
+          "requires": {
+            "@babel/runtime": "^7.11.2",
+            "@polkadot/metadata": "1.34.1",
+            "@polkadot/util": "^3.4.1",
+            "@polkadot/util-crypto": "^3.4.1",
+            "@types/bn.js": "^4.11.6",
+            "bn.js": "^5.1.3",
+            "memoizee": "^0.4.14",
+            "rxjs": "^6.6.3"
+          }
+        },
+        "@polkadot/types-known": {
+          "version": "1.34.1",
+          "resolved": "https://registry.npmjs.org/@polkadot/types-known/-/types-known-1.34.1.tgz",
+          "integrity": "sha512-H9V8u9cqbKjxU/dxEyLl7kJwoBImXpRskQ5+X0fq3BH7g1nQ6jrIg/buRPpbc3GxKivdFYUZWshPY9hbqE8y8A==",
+          "requires": {
+            "@babel/runtime": "^7.11.2",
+            "@polkadot/types": "1.34.1",
+            "@polkadot/util": "^3.4.1",
+            "bn.js": "^5.1.3"
+          }
+        },
+        "@polkadot/util": {
+          "version": "3.4.1",
+          "resolved": "https://registry.npmjs.org/@polkadot/util/-/util-3.4.1.tgz",
+          "integrity": "sha512-CJo0wAzXR8vjAzs9mHDooZr5a3XRW8LlYWik8d/+bv1VDwCC/metSiBrYBOapFhYUjlS5IYIw5bhWS5dnpkXvQ==",
+          "requires": {
+            "@babel/runtime": "^7.11.2",
+            "@types/bn.js": "^4.11.6",
+            "bn.js": "^5.1.3",
+            "camelcase": "^5.3.1",
+            "chalk": "^4.1.0",
+            "ip-regex": "^4.1.0"
+          }
+        }
       }
     },
     "@polkadot/ts": {
@@ -4108,6 +4489,21 @@
         "bn.js": "^5.1.3",
         "memoizee": "^0.4.14",
         "rxjs": "^6.6.3"
+      },
+      "dependencies": {
+        "@polkadot/util": {
+          "version": "3.4.1",
+          "resolved": "https://registry.npmjs.org/@polkadot/util/-/util-3.4.1.tgz",
+          "integrity": "sha512-CJo0wAzXR8vjAzs9mHDooZr5a3XRW8LlYWik8d/+bv1VDwCC/metSiBrYBOapFhYUjlS5IYIw5bhWS5dnpkXvQ==",
+          "requires": {
+            "@babel/runtime": "^7.11.2",
+            "@types/bn.js": "^4.11.6",
+            "bn.js": "^5.1.3",
+            "camelcase": "^5.3.1",
+            "chalk": "^4.1.0",
+            "ip-regex": "^4.1.0"
+          }
+        }
       }
     },
     "@polkadot/types-known": {
@@ -4119,16 +4515,29 @@
         "@polkadot/types": "1.34.1",
         "@polkadot/util": "^3.4.1",
         "bn.js": "^5.1.3"
+      },
+      "dependencies": {
+        "@polkadot/util": {
+          "version": "3.4.1",
+          "resolved": "https://registry.npmjs.org/@polkadot/util/-/util-3.4.1.tgz",
+          "integrity": "sha512-CJo0wAzXR8vjAzs9mHDooZr5a3XRW8LlYWik8d/+bv1VDwCC/metSiBrYBOapFhYUjlS5IYIw5bhWS5dnpkXvQ==",
+          "requires": {
+            "@babel/runtime": "^7.11.2",
+            "@types/bn.js": "^4.11.6",
+            "bn.js": "^5.1.3",
+            "camelcase": "^5.3.1",
+            "chalk": "^4.1.0",
+            "ip-regex": "^4.1.0"
+          }
+        }
       }
     },
     "@polkadot/util": {
-      "version": "3.5.1",
-      "resolved": "https://registry.npmjs.org/@polkadot/util/-/util-3.5.1.tgz",
-      "integrity": "sha512-9CBVeQlhmghlVeOttZDxwOtDVWLKpHSP0iAE2vG2bnI6T1dSjD0cFHCG9q7GeD6UAN8z+m17/M9WDV2WXzT6kA==",
+      "version": "3.4.1",
+      "resolved": "https://registry.npmjs.org/@polkadot/util/-/util-3.4.1.tgz",
+      "integrity": "sha512-CJo0wAzXR8vjAzs9mHDooZr5a3XRW8LlYWik8d/+bv1VDwCC/metSiBrYBOapFhYUjlS5IYIw5bhWS5dnpkXvQ==",
       "requires": {
         "@babel/runtime": "^7.11.2",
-        "@polkadot/x-textdecoder": "^0.3.2",
-        "@polkadot/x-textencoder": "^0.3.2",
         "@types/bn.js": "^4.11.6",
         "bn.js": "^5.1.3",
         "camelcase": "^5.3.1",
@@ -4137,12 +4546,12 @@
       }
     },
     "@polkadot/util-crypto": {
-      "version": "3.5.1",
-      "resolved": "https://registry.npmjs.org/@polkadot/util-crypto/-/util-crypto-3.5.1.tgz",
-      "integrity": "sha512-7SWxOYG+dUCAkGW2xCJc9gutLJ02T9LwiumTW8cXFysRai4qLA3XRl+XQHAEdRzKA+97IQmtGMl4/Tjq9TGwYw==",
+      "version": "3.4.1",
+      "resolved": "https://registry.npmjs.org/@polkadot/util-crypto/-/util-crypto-3.4.1.tgz",
+      "integrity": "sha512-RdTAiJ6dFE8nQJ7/wQkvYa6aNZG3Lusf/r7UmPJ56dZldvDTP3OdekzcfYdogU8hSJrE/xX84ii4DrHLnXXfAQ==",
       "requires": {
         "@babel/runtime": "^7.11.2",
-        "@polkadot/util": "3.5.1",
+        "@polkadot/util": "3.4.1",
         "@polkadot/wasm-crypto": "^1.4.1",
         "base-x": "^3.0.8",
         "bip39": "^3.0.2",
@@ -4154,6 +4563,21 @@
         "scryptsy": "^2.1.0",
         "tweetnacl": "^1.0.3",
         "xxhashjs": "^0.2.2"
+      },
+      "dependencies": {
+        "@polkadot/util": {
+          "version": "3.4.1",
+          "resolved": "https://registry.npmjs.org/@polkadot/util/-/util-3.4.1.tgz",
+          "integrity": "sha512-CJo0wAzXR8vjAzs9mHDooZr5a3XRW8LlYWik8d/+bv1VDwCC/metSiBrYBOapFhYUjlS5IYIw5bhWS5dnpkXvQ==",
+          "requires": {
+            "@babel/runtime": "^7.11.2",
+            "@types/bn.js": "^4.11.6",
+            "bn.js": "^5.1.3",
+            "camelcase": "^5.3.1",
+            "chalk": "^4.1.0",
+            "ip-regex": "^4.1.0"
+          }
+        }
       }
     },
     "@polkadot/wasm-crypto": {
@@ -4169,22 +4593,13 @@
         "@babel/runtime": "^7.11.2",
         "@types/node-fetch": "^2.5.7",
         "node-fetch": "^2.6.1"
-      }
-    },
-    "@polkadot/x-textdecoder": {
-      "version": "0.3.2",
-      "resolved": "https://registry.npmjs.org/@polkadot/x-textdecoder/-/x-textdecoder-0.3.2.tgz",
-      "integrity": "sha512-W3KK6mMzOH5kts8pSkyYyfsQuAsKUHmIm8jQkhQnSR6FRyhwJtHLZnxP3feEwkNkRbGggG6CtDPrxYCuEO0MvA==",
-      "requires": {
-        "@babel/runtime": "^7.11.2"
-      }
-    },
-    "@polkadot/x-textencoder": {
-      "version": "0.3.2",
-      "resolved": "https://registry.npmjs.org/@polkadot/x-textencoder/-/x-textencoder-0.3.2.tgz",
-      "integrity": "sha512-nm7N9gWgKsZv8In1Fgfm+jYOPjprna/03Cd8hOqkCMRlSq0L4LS+d8BPrFhPOiT57VFTTW/7csLivFdeKv0GMA==",
-      "requires": {
-        "@babel/runtime": "^7.11.2"
+      },
+      "dependencies": {
+        "node-fetch": {
+          "version": "2.6.1",
+          "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.1.tgz",
+          "integrity": "sha512-V4aYg89jEoVRxRb2fJdAg8FHvI7cEyYdVAh94HH0UIK8oJxUfkjlDQN9RbMx+bEjP7+ggMiFRprSti032Oipxw=="
+        }
       }
     },
     "@polkadot/x-ws": {
@@ -13113,9 +13528,9 @@
       "dev": true
     },
     "ip-regex": {
-      "version": "4.2.0",
-      "resolved": "https://registry.npmjs.org/ip-regex/-/ip-regex-4.2.0.tgz",
-      "integrity": "sha512-n5cDDeTWWRwK1EBoWwRti+8nP4NbytBBY0pldmnIkq6Z55KNFmWofh4rl9dPZpj+U/nVq7gweR3ylrvMt4YZ5A=="
+      "version": "4.1.0",
+      "resolved": "https://registry.npmjs.org/ip-regex/-/ip-regex-4.1.0.tgz",
+      "integrity": "sha512-pKnZpbgCTfH/1NLIlOduP/V+WRXzC2MOz3Qo8xmxk8C5GudJLgK5QyLVXOSWy3ParAH7Eemurl3xjv/WXYFvMA=="
     },
     "ipaddr.js": {
       "version": "1.9.1",
@@ -16424,11 +16839,6 @@
       "requires": {
         "lower-case": "^1.1.1"
       }
-    },
-    "node-fetch": {
-      "version": "2.6.1",
-      "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.1.tgz",
-      "integrity": "sha512-V4aYg89jEoVRxRb2fJdAg8FHvI7cEyYdVAh94HH0UIK8oJxUfkjlDQN9RbMx+bEjP7+ggMiFRprSti032Oipxw=="
     },
     "node-fetch-npm": {
       "version": "2.0.4",
modifiedtests/package.jsondiffbeforeafterboth
--- a/tests/package.json
+++ b/tests/package.json
@@ -24,6 +24,7 @@
   "homepage": "",
   "dependencies": {
     "@polkadot/api": "^1.34.1",
+    "@polkadot/api-contract": "^1.34.1",
     "@polkadot/types": "^1.34.1",
     "@polkadot/util": "^3.4.1",
     "@types/bn.js": "^4.11.6",
addedtests/src/accounts.tsdiffbeforeafterboth
--- /dev/null
+++ b/tests/src/accounts.ts
@@ -0,0 +1,2 @@
+export const bobsPublicKey = '5FHneW46xGXgs5mUiveU4sbTyGBzmstUspZC92UhjJM694ty';
+export const alicesPublicKey = '5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY';
addedtests/src/deploy-flipper.test.tsdiffbeforeafterboth
--- /dev/null
+++ b/tests/src/deploy-flipper.test.ts
@@ -0,0 +1,102 @@
+import { expect } from "chai";
+import usingApi from "./substrate/substrate-api";
+import promisifySubstrate from "./substrate/promisify-substrate";
+import fs from "fs";
+import privateKey from "./substrate/privateKey";
+import { compactAddLength, u8aToU8a } from '@polkadot/util';
+import { Hash, AccountId } from "@polkadot/types/interfaces";
+import { Abi, PromiseContract } from "@polkadot/api-contract";
+import { ISubmittableResult } from "@polkadot/types/types";
+import BN from "bn.js";
+import { alicesPublicKey } from "./accounts";
+
+describe('Flipper', () => {
+  it(`Can deploy smart contract Flipper, instantiate it and call it's get and flip messages.`, async () => {
+    await usingApi(async api => {
+      const wasm = fs.readFileSync('./src/flipper/flipper.wasm');
+      const contract = compactAddLength(u8aToU8a(wasm));
+
+      const metadata = JSON.parse(fs.readFileSync('./src/flipper/metadata.json').toString('utf-8'));
+      const abi = new Abi(api.registry as any, metadata);
+
+      const alicesPrivateKey = privateKey('//Alice');
+
+      const contractHash = await promisifySubstrate(api, () => {
+        return new Promise<Hash>(async (resolve, reject) => {
+          const unsubscribe = api.tx.contracts.putCode(contract).signAndSend(alicesPrivateKey, async result => {
+            if(!result.isInBlock){
+              return;
+            }
+
+            const record = result.findRecord('contracts', 'CodeStored');
+
+            if(record) {
+              (await unsubscribe)();
+              resolve(record.event.data[0] as unknown as Hash);
+            } else {
+              reject('Failed to find contract hash in putCode transaction result.');
+            }
+          });
+        })
+      })();
+
+
+      const instanceAccountId = await promisifySubstrate(api, () => {
+        return new Promise<AccountId>((resolve, reject) => {
+          const args = abi.constructors[0](true);
+          const unsubscribe = api.tx.contracts.instantiate(1000000000000000n, 1000000000000n, contractHash, args)
+            .signAndSend(alicesPrivateKey, async (result:ISubmittableResult) => {
+              if(!result.isInBlock) {
+                return;
+              }
+              const record = result.findRecord('contracts', 'Instantiated');
+              if(record) {
+                (await unsubscribe)();
+                expect(alicesPublicKey).to.be.equal(record.event.data[0].toString());
+                resolve(record.event.data[1] as AccountId);
+              } else {
+                reject('Failed to find instantiated event,');
+              }
+            });
+        });
+      })();
+
+      const contractInstance = new PromiseContract(api, abi, instanceAccountId);
+      const getFlipValue = async () => {
+        return await promisifySubstrate(api, async () => {
+          const result = await contractInstance.call('rpc', 'get', 0, new BN('1000000000000'))
+            .send(alicesPublicKey);
+          if(!result.isSuccess) {
+            throw 'Failed to get flipper value';
+          }
+          return result.output && result.output.valueOf && result.output.valueOf();
+        })();
+      }
+
+      const initialGetResponse = await getFlipValue();
+      expect(initialGetResponse).to.be.true;
+
+      await promisifySubstrate(api, async () => {
+        return new Promise<void>(async (resolve, reject) => {
+          api.tx.contracts.call(contractInstance.address.toString(), 0, 1000000000000n, contractInstance.getMessage('flip').fn())
+            .signAndSend(alicesPrivateKey, async result => {
+              if(!result.isInBlock) {
+                return;
+              }
+
+              if(result.findRecord('system', 'ExtrinsicSuccess')) {
+                resolve();
+              }
+              else {
+                reject('Failed to flip value.');
+              }
+            })
+        });
+      })();
+
+      const afterFlipGetResponse = await getFlipValue();
+
+      expect(afterFlipGetResponse).to.be.false;
+    });
+  });
+});
addedtests/src/flipper/flipper.wasmdiffbeforeafterboth

binary blob — no preview

addedtests/src/flipper/metadata.jsondiffbeforeafterboth
--- /dev/null
+++ b/tests/src/flipper/metadata.json
@@ -0,0 +1,204 @@
+{
+  "registry": {
+    "strings": [
+      "Storage",
+      "flipper",
+      "__ink_private",
+      "__ink_storage",
+      "value",
+      "Value",
+      "ink_core",
+      "storage",
+      "cell",
+      "SyncCell",
+      "sync_cell",
+      "Key",
+      "ink_primitives",
+      "new",
+      "init_value",
+      "bool",
+      "default",
+      "flip",
+      "get"
+    ],
+    "types": [
+      {
+        "id": {
+          "custom.name": 1,
+          "custom.namespace": [
+            2,
+            2,
+            3,
+            4
+          ],
+          "custom.params": []
+        },
+        "def": {
+          "struct.fields": [
+            {
+              "name": 5,
+              "type": 2
+            }
+          ]
+        }
+      },
+      {
+        "id": {
+          "custom.name": 6,
+          "custom.namespace": [
+            7,
+            8,
+            5
+          ],
+          "custom.params": [
+            3
+          ]
+        },
+        "def": {
+          "struct.fields": [
+            {
+              "name": 9,
+              "type": 4
+            }
+          ]
+        }
+      },
+      {
+        "id": "bool",
+        "def": "builtin"
+      },
+      {
+        "id": {
+          "custom.name": 10,
+          "custom.namespace": [
+            7,
+            8,
+            9,
+            11
+          ],
+          "custom.params": [
+            3
+          ]
+        },
+        "def": {
+          "struct.fields": [
+            {
+              "name": 9,
+              "type": 5
+            }
+          ]
+        }
+      },
+      {
+        "id": {
+          "custom.name": 12,
+          "custom.namespace": [
+            13
+          ],
+          "custom.params": []
+        },
+        "def": {
+          "tuple_struct.types": [
+            6
+          ]
+        }
+      },
+      {
+        "id": {
+          "array.len": 32,
+          "array.type": 7
+        },
+        "def": "builtin"
+      },
+      {
+        "id": "u8",
+        "def": "builtin"
+      }
+    ]
+  },
+  "storage": {
+    "struct.type": 1,
+    "struct.fields": [
+      {
+        "name": 5,
+        "layout": {
+          "struct.type": 2,
+          "struct.fields": [
+            {
+              "name": 9,
+              "layout": {
+                "range.offset": "0x0000000000000000000000000000000000000000000000000000000000000000",
+                "range.len": 1,
+                "range.elem_type": 3
+              }
+            }
+          ]
+        }
+      }
+    ]
+  },
+  "contract": {
+    "name": 2,
+    "constructors": [
+      {
+        "name": 14,
+        "selector": "[\"0x5E\",\"0xBD\",\"0x88\",\"0xD6\"]",
+        "args": [
+          {
+            "name": 15,
+            "type": {
+              "ty": 3,
+              "display_name": [
+                16
+              ]
+            }
+          }
+        ],
+        "docs": [
+          "Constructor that initializes the `bool` value to the given `init_value`."
+        ]
+      },
+      {
+        "name": 17,
+        "selector": "[\"0x02\",\"0x22\",\"0xFF\",\"0x18\"]",
+        "args": [],
+        "docs": [
+          "Constructor that initializes the `bool` value to `false`.",
+          "",
+          "Constructors can delegate to other constructors."
+        ]
+      }
+    ],
+    "messages": [
+      {
+        "name": 18,
+        "selector": "[\"0x8C\",\"0x97\",\"0xDB\",\"0x39\"]",
+        "mutates": true,
+        "args": [],
+        "return_type": null,
+        "docs": [
+          "A message that can be called on instantiated contracts.",
+          "This one flips the value of the stored `bool` from `true`",
+          "to `false` and vice versa."
+        ]
+      },
+      {
+        "name": 19,
+        "selector": "[\"0x25\",\"0x44\",\"0x4A\",\"0xFE\"]",
+        "mutates": false,
+        "args": [],
+        "return_type": {
+          "ty": 3,
+          "display_name": [
+            16
+          ]
+        },
+        "docs": [
+          "Simply returns the current value of our `bool`."
+        ]
+      }
+    ],
+    "events": [],
+    "docs": []
+  }
+}
\ No newline at end of file
addedtests/src/substrate/privateKey.tsdiffbeforeafterboth
--- /dev/null
+++ b/tests/src/substrate/privateKey.ts
@@ -0,0 +1,7 @@
+import { Keyring } from "@polkadot/api";
+
+export default function privateKey(account: string) {
+  const keyring = new Keyring({ type: 'sr25519' });
+  
+  return keyring.addFromUri(account);
+}
\ No newline at end of file
modifiedtests/src/transfer.test.tsdiffbeforeafterboth
5import usingApi from "./substrate/substrate-api";5import usingApi from "./substrate/substrate-api";
6import promisifySubstrate from "./substrate/promisify-substrate";6import promisifySubstrate from "./substrate/promisify-substrate";
7import waitNewBlocks from "./substrate/wait-new-blocks";7import waitNewBlocks from "./substrate/wait-new-blocks";
8import { alicesPublicKey, bobsPublicKey } from "./accounts";
9import privateKey from "./substrate/privateKey";
810
9async function getBalance(api: ApiPromise, accounts: string[]): Promise<bigint[]> {11async function getBalance(api: ApiPromise, accounts: string[]): Promise<bigint[]> {
10 const balance = promisifySubstrate(api, (accounts: string[]) => api.query.system.account.multi(accounts));12 const balance = promisifySubstrate(api, (accounts: string[]) => api.query.system.account.multi(accounts));
1416
15describe('Transfer', () => {17describe('Transfer', () => {
16 it('Balance transfers', async () => {18 it('Balance transfers', async () => {
17 const bobsPublicKey = '5FHneW46xGXgs5mUiveU4sbTyGBzmstUspZC92UhjJM694ty';
18 const alicesPublicKey = '5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY';
19 await usingApi(async api => {19 await usingApi(async api => {
20 const [alicesBalanceBefore, bobsBalanceBefore] = await getBalance(api, [alicesPublicKey, bobsPublicKey]);20 const [alicesBalanceBefore, bobsBalanceBefore] = await getBalance(api, [alicesPublicKey, bobsPublicKey]);
2121
22 const keyring = new Keyring({ type: 'sr25519' });
23
24 const alicePrivateKey = keyring.addFromUri('//Alice');22 const alicePrivateKey = privateKey('//Alice');
25 23
26 const transfer = api.tx.balances.transfer(bobsPublicKey, 1n);24 const transfer = api.tx.balances.transfer(bobsPublicKey, 1n);
27 25
28 const hash = await transfer.signAndSend(alicePrivateKey);26 await promisifySubstrate(api, () => transfer.signAndSend(alicePrivateKey))();
2927
30 await waitNewBlocks(api);28 await waitNewBlocks(api);
31 29