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

difftreelog

Fix contract tests

Greg Zaitsev2020-10-19parent: #b57ed09.patch.diff
in: master

3 files changed

modifiedtests/package-lock.jsondiffbeforeafterboth
--- a/tests/package-lock.json
+++ b/tests/package-lock.json
@@ -3916,104 +3916,143 @@
       }
     },
     "@polkadot/api": {
-      "version": "2.2.1",
-      "resolved": "https://registry.npmjs.org/@polkadot/api/-/api-2.2.1.tgz",
-      "integrity": "sha512-h6G1nYeXGnnUB//JXZcSKDNZNuasB4DDE0Hf+G5rf/9/aDxbkN+T1Wc6+saFxrxSmDGx2/qEUNVx6PluFKLvJA==",
+      "version": "2.3.1",
+      "resolved": "https://registry.npmjs.org/@polkadot/api/-/api-2.3.1.tgz",
+      "integrity": "sha512-B9ZOb1PiPaAlke4wQHoivVQ5ZCQWn5bgLjhVIGdcEZ4WjIcxApmzTV4ruSfqVoRKpRiVOyV3Dx/VUQDD/WgBFw==",
       "requires": {
-        "@babel/runtime": "^7.11.2",
-        "@polkadot/api-derive": "2.2.1",
-        "@polkadot/keyring": "^3.5.1",
-        "@polkadot/metadata": "2.2.1",
-        "@polkadot/rpc-core": "2.2.1",
-        "@polkadot/rpc-provider": "2.2.1",
-        "@polkadot/types": "2.2.1",
-        "@polkadot/types-known": "2.2.1",
-        "@polkadot/util": "^3.5.1",
-        "@polkadot/util-crypto": "^3.5.1",
+        "@babel/runtime": "^7.12.1",
+        "@polkadot/api-derive": "2.3.1",
+        "@polkadot/keyring": "^3.6.1",
+        "@polkadot/metadata": "2.3.1",
+        "@polkadot/rpc-core": "2.3.1",
+        "@polkadot/rpc-provider": "2.3.1",
+        "@polkadot/types": "2.3.1",
+        "@polkadot/types-known": "2.3.1",
+        "@polkadot/util": "^3.6.1",
+        "@polkadot/util-crypto": "^3.6.1",
         "bn.js": "^5.1.3",
         "eventemitter3": "^4.0.7",
         "rxjs": "^6.6.3"
       },
       "dependencies": {
+        "@babel/runtime": {
+          "version": "7.12.1",
+          "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.12.1.tgz",
+          "integrity": "sha512-J5AIf3vPj3UwXaAzb5j1xM4WAQDX3EMgemF8rjCP3SoW09LfRKAXQKt6CoVYl230P6iWdRcBbnLDDdnqWxZSCA==",
+          "requires": {
+            "regenerator-runtime": "^0.13.4"
+          }
+        },
         "@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.6.1",
+          "resolved": "https://registry.npmjs.org/@polkadot/util/-/util-3.6.1.tgz",
+          "integrity": "sha512-ToGVghmTtC8s8cg8mCGG3I88UasrCg9VNm5JoUvBH4nTZCxc/dQEkU24nULXwHUpmd7d39p3RLpVbkLCVYIMZw==",
           "requires": {
-            "@babel/runtime": "^7.11.2",
-            "@polkadot/x-textdecoder": "^0.3.2",
-            "@polkadot/x-textencoder": "^0.3.2",
+            "@babel/runtime": "^7.12.1",
+            "@polkadot/x-textdecoder": "^0.3.3",
+            "@polkadot/x-textencoder": "^0.3.3",
             "@types/bn.js": "^4.11.6",
             "bn.js": "^5.1.3",
             "camelcase": "^5.3.1",
             "chalk": "^4.1.0",
-            "ip-regex": "^4.1.0"
+            "ip-regex": "^4.2.0"
           }
+        },
+        "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=="
         }
       }
     },
     "@polkadot/api-contract": {
-      "version": "2.2.1",
-      "resolved": "https://registry.npmjs.org/@polkadot/api-contract/-/api-contract-2.2.1.tgz",
-      "integrity": "sha512-7Kb9pAx9n7qske7p3yI+YYZX8Z5/MCNET1SCEE6t3fkwtYxs+BMw2Wucq5yt/EbVgJDLM3NmZyh9xmJiLwLxHQ==",
+      "version": "2.3.1",
+      "resolved": "https://registry.npmjs.org/@polkadot/api-contract/-/api-contract-2.3.1.tgz",
+      "integrity": "sha512-hqRU2mGkHK84dtqZSX71tFCuBmBiV/6H7pJwj5E7UPcd124LM2ETXYJ9T0ElxbAHmZQD7yv+2ZM/ncvGC/A68Q==",
       "requires": {
-        "@babel/runtime": "^7.11.2",
-        "@polkadot/api": "2.2.1",
-        "@polkadot/rpc-core": "2.2.1",
-        "@polkadot/types": "2.2.1",
-        "@polkadot/util": "^3.5.1",
+        "@babel/runtime": "^7.12.1",
+        "@polkadot/api": "2.3.1",
+        "@polkadot/rpc-core": "2.3.1",
+        "@polkadot/types": "2.3.1",
+        "@polkadot/util": "^3.6.1",
         "bn.js": "^5.1.3",
         "rxjs": "^6.6.3"
       },
       "dependencies": {
+        "@babel/runtime": {
+          "version": "7.12.1",
+          "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.12.1.tgz",
+          "integrity": "sha512-J5AIf3vPj3UwXaAzb5j1xM4WAQDX3EMgemF8rjCP3SoW09LfRKAXQKt6CoVYl230P6iWdRcBbnLDDdnqWxZSCA==",
+          "requires": {
+            "regenerator-runtime": "^0.13.4"
+          }
+        },
         "@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.6.1",
+          "resolved": "https://registry.npmjs.org/@polkadot/util/-/util-3.6.1.tgz",
+          "integrity": "sha512-ToGVghmTtC8s8cg8mCGG3I88UasrCg9VNm5JoUvBH4nTZCxc/dQEkU24nULXwHUpmd7d39p3RLpVbkLCVYIMZw==",
           "requires": {
-            "@babel/runtime": "^7.11.2",
-            "@polkadot/x-textdecoder": "^0.3.2",
-            "@polkadot/x-textencoder": "^0.3.2",
+            "@babel/runtime": "^7.12.1",
+            "@polkadot/x-textdecoder": "^0.3.3",
+            "@polkadot/x-textencoder": "^0.3.3",
             "@types/bn.js": "^4.11.6",
             "bn.js": "^5.1.3",
             "camelcase": "^5.3.1",
             "chalk": "^4.1.0",
-            "ip-regex": "^4.1.0"
+            "ip-regex": "^4.2.0"
           }
+        },
+        "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=="
         }
       }
     },
     "@polkadot/api-derive": {
-      "version": "2.2.1",
-      "resolved": "https://registry.npmjs.org/@polkadot/api-derive/-/api-derive-2.2.1.tgz",
-      "integrity": "sha512-4J9nA9bDBlE+yn06VjgeCnElnRn8IhTpkGhtT4J/agBe+4I0tYSz+DR5o2Rb5mQDMXu3aayYpfVDaJk1mRJsPQ==",
+      "version": "2.3.1",
+      "resolved": "https://registry.npmjs.org/@polkadot/api-derive/-/api-derive-2.3.1.tgz",
+      "integrity": "sha512-FcDEx+/1Io7zOHPjbQAEzXB0KenA9emgY+96aHS4yPV/OVmAifU0IAxudZdMVp7uVC2dWq9iFvjxx84yCXgVRA==",
       "requires": {
-        "@babel/runtime": "^7.11.2",
-        "@polkadot/api": "2.2.1",
-        "@polkadot/rpc-core": "2.2.1",
-        "@polkadot/rpc-provider": "2.2.1",
-        "@polkadot/types": "2.2.1",
-        "@polkadot/util": "^3.5.1",
-        "@polkadot/util-crypto": "^3.5.1",
+        "@babel/runtime": "^7.12.1",
+        "@polkadot/api": "2.3.1",
+        "@polkadot/rpc-core": "2.3.1",
+        "@polkadot/rpc-provider": "2.3.1",
+        "@polkadot/types": "2.3.1",
+        "@polkadot/util": "^3.6.1",
+        "@polkadot/util-crypto": "^3.6.1",
         "bn.js": "^5.1.3",
         "memoizee": "^0.4.14",
         "rxjs": "^6.6.3"
       },
       "dependencies": {
+        "@babel/runtime": {
+          "version": "7.12.1",
+          "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.12.1.tgz",
+          "integrity": "sha512-J5AIf3vPj3UwXaAzb5j1xM4WAQDX3EMgemF8rjCP3SoW09LfRKAXQKt6CoVYl230P6iWdRcBbnLDDdnqWxZSCA==",
+          "requires": {
+            "regenerator-runtime": "^0.13.4"
+          }
+        },
         "@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.6.1",
+          "resolved": "https://registry.npmjs.org/@polkadot/util/-/util-3.6.1.tgz",
+          "integrity": "sha512-ToGVghmTtC8s8cg8mCGG3I88UasrCg9VNm5JoUvBH4nTZCxc/dQEkU24nULXwHUpmd7d39p3RLpVbkLCVYIMZw==",
           "requires": {
-            "@babel/runtime": "^7.11.2",
-            "@polkadot/x-textdecoder": "^0.3.2",
-            "@polkadot/x-textencoder": "^0.3.2",
+            "@babel/runtime": "^7.12.1",
+            "@polkadot/x-textdecoder": "^0.3.3",
+            "@polkadot/x-textencoder": "^0.3.3",
             "@types/bn.js": "^4.11.6",
             "bn.js": "^5.1.3",
             "camelcase": "^5.3.1",
             "chalk": "^4.1.0",
-            "ip-regex": "^4.1.0"
+            "ip-regex": "^4.2.0"
           }
+        },
+        "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=="
         }
       }
     },
@@ -4099,123 +4138,193 @@
       }
     },
     "@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.6.1",
+      "resolved": "https://registry.npmjs.org/@polkadot/keyring/-/keyring-3.6.1.tgz",
+      "integrity": "sha512-JbW4M5Ct3HaX3vgoa/UWAQVF/0sc1PbbA2D6v0KKaJkXl+EYVP9uyOYAoRCppB6ENZThz7CUJVQp8trs8WTrFQ==",
       "requires": {
-        "@babel/runtime": "^7.11.2",
-        "@polkadot/util": "3.5.1",
-        "@polkadot/util-crypto": "3.5.1"
+        "@babel/runtime": "^7.12.1",
+        "@polkadot/util": "3.6.1",
+        "@polkadot/util-crypto": "3.6.1"
       },
       "dependencies": {
+        "@babel/runtime": {
+          "version": "7.12.1",
+          "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.12.1.tgz",
+          "integrity": "sha512-J5AIf3vPj3UwXaAzb5j1xM4WAQDX3EMgemF8rjCP3SoW09LfRKAXQKt6CoVYl230P6iWdRcBbnLDDdnqWxZSCA==",
+          "requires": {
+            "regenerator-runtime": "^0.13.4"
+          }
+        },
         "@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.6.1",
+          "resolved": "https://registry.npmjs.org/@polkadot/util/-/util-3.6.1.tgz",
+          "integrity": "sha512-ToGVghmTtC8s8cg8mCGG3I88UasrCg9VNm5JoUvBH4nTZCxc/dQEkU24nULXwHUpmd7d39p3RLpVbkLCVYIMZw==",
           "requires": {
-            "@babel/runtime": "^7.11.2",
-            "@polkadot/x-textdecoder": "^0.3.2",
-            "@polkadot/x-textencoder": "^0.3.2",
+            "@babel/runtime": "^7.12.1",
+            "@polkadot/x-textdecoder": "^0.3.3",
+            "@polkadot/x-textencoder": "^0.3.3",
             "@types/bn.js": "^4.11.6",
             "bn.js": "^5.1.3",
             "camelcase": "^5.3.1",
             "chalk": "^4.1.0",
-            "ip-regex": "^4.1.0"
+            "ip-regex": "^4.2.0"
           }
+        },
+        "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=="
         }
       }
     },
     "@polkadot/metadata": {
-      "version": "2.2.1",
-      "resolved": "https://registry.npmjs.org/@polkadot/metadata/-/metadata-2.2.1.tgz",
-      "integrity": "sha512-Xp5S2ukNS2rvSeK4cT/xhWzIMmOQZ8BssZU9pqK8u1ttv36CKCD9CRUGxAvG42+SiHV6WMG1S2NAt3UgLthQyw==",
+      "version": "2.3.1",
+      "resolved": "https://registry.npmjs.org/@polkadot/metadata/-/metadata-2.3.1.tgz",
+      "integrity": "sha512-F/QwDDR/d9mcqToDqndRTUYvMt/GYzjQ+kNGjQYBOIDRqF9zDbPHAXruqcHd0Y5MMpPMRBZGNaqPOb3BMrIdOQ==",
       "requires": {
-        "@babel/runtime": "^7.11.2",
-        "@polkadot/types": "2.2.1",
-        "@polkadot/types-known": "2.2.1",
-        "@polkadot/util": "^3.5.1",
-        "@polkadot/util-crypto": "^3.5.1",
+        "@babel/runtime": "^7.12.1",
+        "@polkadot/types": "2.3.1",
+        "@polkadot/types-known": "2.3.1",
+        "@polkadot/util": "^3.6.1",
+        "@polkadot/util-crypto": "^3.6.1",
         "bn.js": "^5.1.3"
       },
       "dependencies": {
+        "@babel/runtime": {
+          "version": "7.12.1",
+          "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.12.1.tgz",
+          "integrity": "sha512-J5AIf3vPj3UwXaAzb5j1xM4WAQDX3EMgemF8rjCP3SoW09LfRKAXQKt6CoVYl230P6iWdRcBbnLDDdnqWxZSCA==",
+          "requires": {
+            "regenerator-runtime": "^0.13.4"
+          }
+        },
         "@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.6.1",
+          "resolved": "https://registry.npmjs.org/@polkadot/util/-/util-3.6.1.tgz",
+          "integrity": "sha512-ToGVghmTtC8s8cg8mCGG3I88UasrCg9VNm5JoUvBH4nTZCxc/dQEkU24nULXwHUpmd7d39p3RLpVbkLCVYIMZw==",
           "requires": {
-            "@babel/runtime": "^7.11.2",
-            "@polkadot/x-textdecoder": "^0.3.2",
-            "@polkadot/x-textencoder": "^0.3.2",
+            "@babel/runtime": "^7.12.1",
+            "@polkadot/x-textdecoder": "^0.3.3",
+            "@polkadot/x-textencoder": "^0.3.3",
             "@types/bn.js": "^4.11.6",
             "bn.js": "^5.1.3",
             "camelcase": "^5.3.1",
             "chalk": "^4.1.0",
-            "ip-regex": "^4.1.0"
+            "ip-regex": "^4.2.0"
           }
+        },
+        "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=="
         }
       }
     },
+    "@polkadot/networks": {
+      "version": "3.6.1",
+      "resolved": "https://registry.npmjs.org/@polkadot/networks/-/networks-3.6.1.tgz",
+      "integrity": "sha512-PEEw/vTZaKf32vuAUeFXYNJei+b/s3hr7msMKfvoYeKDU/otgt9Mgkqrh6VCaE6+lHHgX8vLbH70pCqQrGG/uA==",
+      "requires": {
+        "@babel/runtime": "^7.12.1"
+      },
+      "dependencies": {
+        "@babel/runtime": {
+          "version": "7.12.1",
+          "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.12.1.tgz",
+          "integrity": "sha512-J5AIf3vPj3UwXaAzb5j1xM4WAQDX3EMgemF8rjCP3SoW09LfRKAXQKt6CoVYl230P6iWdRcBbnLDDdnqWxZSCA==",
+          "requires": {
+            "regenerator-runtime": "^0.13.4"
+          }
+        }
+      }
+    },
     "@polkadot/rpc-core": {
-      "version": "2.2.1",
-      "resolved": "https://registry.npmjs.org/@polkadot/rpc-core/-/rpc-core-2.2.1.tgz",
-      "integrity": "sha512-t3XoR6QPE6TaYsuKXCfOvTW9C6Lvjgcn++0DT33EANANtgtT9b6e+08mEOjf8VtYkwExgzK2aSGwCCoRccYcsg==",
+      "version": "2.3.1",
+      "resolved": "https://registry.npmjs.org/@polkadot/rpc-core/-/rpc-core-2.3.1.tgz",
+      "integrity": "sha512-SWYU6azxNwWkhz6bm/wpRPQZ/5KJ2hnEXPS4EN77q7EFH4c4k9mNtVyjUQFkKJsG7T85vxaCCWwhx60aYCZVeA==",
       "requires": {
-        "@babel/runtime": "^7.11.2",
-        "@polkadot/metadata": "2.2.1",
-        "@polkadot/rpc-provider": "2.2.1",
-        "@polkadot/types": "2.2.1",
-        "@polkadot/util": "^3.5.1",
+        "@babel/runtime": "^7.12.1",
+        "@polkadot/metadata": "2.3.1",
+        "@polkadot/rpc-provider": "2.3.1",
+        "@polkadot/types": "2.3.1",
+        "@polkadot/util": "^3.6.1",
         "memoizee": "^0.4.14",
         "rxjs": "^6.6.3"
       },
       "dependencies": {
+        "@babel/runtime": {
+          "version": "7.12.1",
+          "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.12.1.tgz",
+          "integrity": "sha512-J5AIf3vPj3UwXaAzb5j1xM4WAQDX3EMgemF8rjCP3SoW09LfRKAXQKt6CoVYl230P6iWdRcBbnLDDdnqWxZSCA==",
+          "requires": {
+            "regenerator-runtime": "^0.13.4"
+          }
+        },
         "@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.6.1",
+          "resolved": "https://registry.npmjs.org/@polkadot/util/-/util-3.6.1.tgz",
+          "integrity": "sha512-ToGVghmTtC8s8cg8mCGG3I88UasrCg9VNm5JoUvBH4nTZCxc/dQEkU24nULXwHUpmd7d39p3RLpVbkLCVYIMZw==",
           "requires": {
-            "@babel/runtime": "^7.11.2",
-            "@polkadot/x-textdecoder": "^0.3.2",
-            "@polkadot/x-textencoder": "^0.3.2",
+            "@babel/runtime": "^7.12.1",
+            "@polkadot/x-textdecoder": "^0.3.3",
+            "@polkadot/x-textencoder": "^0.3.3",
             "@types/bn.js": "^4.11.6",
             "bn.js": "^5.1.3",
             "camelcase": "^5.3.1",
             "chalk": "^4.1.0",
-            "ip-regex": "^4.1.0"
+            "ip-regex": "^4.2.0"
           }
+        },
+        "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=="
         }
       }
     },
     "@polkadot/rpc-provider": {
-      "version": "2.2.1",
-      "resolved": "https://registry.npmjs.org/@polkadot/rpc-provider/-/rpc-provider-2.2.1.tgz",
-      "integrity": "sha512-s6iIRazo2O8xcyXaNrnWW48qJEx0FqMHD506Z8RzuYzh3jQxlAd53zw0InWZpFTfrvk46VN3tvQJaq9LYvcliA==",
+      "version": "2.3.1",
+      "resolved": "https://registry.npmjs.org/@polkadot/rpc-provider/-/rpc-provider-2.3.1.tgz",
+      "integrity": "sha512-lRN68RosWvtBA844PWqhYEV2ifT3T9SUyAP2WvRYyWVPiMmXjw57qG1zHKQWgZk5aFzeaHKSYgsKTmkWz9IM4g==",
       "requires": {
-        "@babel/runtime": "^7.11.2",
-        "@polkadot/metadata": "2.2.1",
-        "@polkadot/types": "2.2.1",
-        "@polkadot/util": "^3.5.1",
-        "@polkadot/util-crypto": "^3.5.1",
-        "@polkadot/x-fetch": "^0.3.2",
-        "@polkadot/x-ws": "^0.3.2",
+        "@babel/runtime": "^7.12.1",
+        "@polkadot/metadata": "2.3.1",
+        "@polkadot/types": "2.3.1",
+        "@polkadot/util": "^3.6.1",
+        "@polkadot/util-crypto": "^3.6.1",
+        "@polkadot/x-fetch": "^0.3.3",
+        "@polkadot/x-ws": "^0.3.3",
         "bn.js": "^5.1.3",
         "eventemitter3": "^4.0.7"
       },
       "dependencies": {
+        "@babel/runtime": {
+          "version": "7.12.1",
+          "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.12.1.tgz",
+          "integrity": "sha512-J5AIf3vPj3UwXaAzb5j1xM4WAQDX3EMgemF8rjCP3SoW09LfRKAXQKt6CoVYl230P6iWdRcBbnLDDdnqWxZSCA==",
+          "requires": {
+            "regenerator-runtime": "^0.13.4"
+          }
+        },
         "@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.6.1",
+          "resolved": "https://registry.npmjs.org/@polkadot/util/-/util-3.6.1.tgz",
+          "integrity": "sha512-ToGVghmTtC8s8cg8mCGG3I88UasrCg9VNm5JoUvBH4nTZCxc/dQEkU24nULXwHUpmd7d39p3RLpVbkLCVYIMZw==",
           "requires": {
-            "@babel/runtime": "^7.11.2",
-            "@polkadot/x-textdecoder": "^0.3.2",
-            "@polkadot/x-textencoder": "^0.3.2",
+            "@babel/runtime": "^7.12.1",
+            "@polkadot/x-textdecoder": "^0.3.3",
+            "@polkadot/x-textencoder": "^0.3.3",
             "@types/bn.js": "^4.11.6",
             "bn.js": "^5.1.3",
             "camelcase": "^5.3.1",
             "chalk": "^4.1.0",
-            "ip-regex": "^4.1.0"
+            "ip-regex": "^4.2.0"
           }
+        },
+        "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=="
         }
       }
     },
@@ -4229,62 +4338,88 @@
       }
     },
     "@polkadot/types": {
-      "version": "2.2.1",
-      "resolved": "https://registry.npmjs.org/@polkadot/types/-/types-2.2.1.tgz",
-      "integrity": "sha512-4kW+pdCgXoUQ4bXIdHMs5/JV7tsxseqlV2O0p6j60CeXZQOaRQJkIeC2I9J+HwpmnkT1SAgakX3wZniFp9nDeA==",
+      "version": "2.3.1",
+      "resolved": "https://registry.npmjs.org/@polkadot/types/-/types-2.3.1.tgz",
+      "integrity": "sha512-G3cyYYV+vYmpkMjPirwOA/zLreb1uBrKpEMWTvtTuCz/sNwcbCT5hI/KZCzNo1PueOQAowroKPe4yQ793dqVPw==",
       "requires": {
-        "@babel/runtime": "^7.11.2",
-        "@polkadot/metadata": "2.2.1",
-        "@polkadot/util": "^3.5.1",
-        "@polkadot/util-crypto": "^3.5.1",
+        "@babel/runtime": "^7.12.1",
+        "@polkadot/metadata": "2.3.1",
+        "@polkadot/util": "^3.6.1",
+        "@polkadot/util-crypto": "^3.6.1",
         "@types/bn.js": "^4.11.6",
         "bn.js": "^5.1.3",
         "memoizee": "^0.4.14",
         "rxjs": "^6.6.3"
       },
       "dependencies": {
+        "@babel/runtime": {
+          "version": "7.12.1",
+          "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.12.1.tgz",
+          "integrity": "sha512-J5AIf3vPj3UwXaAzb5j1xM4WAQDX3EMgemF8rjCP3SoW09LfRKAXQKt6CoVYl230P6iWdRcBbnLDDdnqWxZSCA==",
+          "requires": {
+            "regenerator-runtime": "^0.13.4"
+          }
+        },
         "@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.6.1",
+          "resolved": "https://registry.npmjs.org/@polkadot/util/-/util-3.6.1.tgz",
+          "integrity": "sha512-ToGVghmTtC8s8cg8mCGG3I88UasrCg9VNm5JoUvBH4nTZCxc/dQEkU24nULXwHUpmd7d39p3RLpVbkLCVYIMZw==",
           "requires": {
-            "@babel/runtime": "^7.11.2",
-            "@polkadot/x-textdecoder": "^0.3.2",
-            "@polkadot/x-textencoder": "^0.3.2",
+            "@babel/runtime": "^7.12.1",
+            "@polkadot/x-textdecoder": "^0.3.3",
+            "@polkadot/x-textencoder": "^0.3.3",
             "@types/bn.js": "^4.11.6",
             "bn.js": "^5.1.3",
             "camelcase": "^5.3.1",
             "chalk": "^4.1.0",
-            "ip-regex": "^4.1.0"
+            "ip-regex": "^4.2.0"
           }
+        },
+        "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=="
         }
       }
     },
     "@polkadot/types-known": {
-      "version": "2.2.1",
-      "resolved": "https://registry.npmjs.org/@polkadot/types-known/-/types-known-2.2.1.tgz",
-      "integrity": "sha512-RmxDg1C5bz1GWe1Bk21Lf75PdtwdWWO4mPVkXsZi1zGfFLxoCYcsO4duEab/kAJk2hKyhxANn88SF1tIBpJ2ww==",
+      "version": "2.3.1",
+      "resolved": "https://registry.npmjs.org/@polkadot/types-known/-/types-known-2.3.1.tgz",
+      "integrity": "sha512-34yuvDraW9Sjy5ookQZf55sBKLOsTqos+WQdTu6DUxtRuwvMP9DEAGcs2m6AFvWxwZps+3zFGUvzn6SMHsSJ5Q==",
       "requires": {
-        "@babel/runtime": "^7.11.2",
-        "@polkadot/types": "2.2.1",
-        "@polkadot/util": "^3.5.1",
+        "@babel/runtime": "^7.12.1",
+        "@polkadot/types": "2.3.1",
+        "@polkadot/util": "^3.6.1",
         "bn.js": "^5.1.3"
       },
       "dependencies": {
+        "@babel/runtime": {
+          "version": "7.12.1",
+          "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.12.1.tgz",
+          "integrity": "sha512-J5AIf3vPj3UwXaAzb5j1xM4WAQDX3EMgemF8rjCP3SoW09LfRKAXQKt6CoVYl230P6iWdRcBbnLDDdnqWxZSCA==",
+          "requires": {
+            "regenerator-runtime": "^0.13.4"
+          }
+        },
         "@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.6.1",
+          "resolved": "https://registry.npmjs.org/@polkadot/util/-/util-3.6.1.tgz",
+          "integrity": "sha512-ToGVghmTtC8s8cg8mCGG3I88UasrCg9VNm5JoUvBH4nTZCxc/dQEkU24nULXwHUpmd7d39p3RLpVbkLCVYIMZw==",
           "requires": {
-            "@babel/runtime": "^7.11.2",
-            "@polkadot/x-textdecoder": "^0.3.2",
-            "@polkadot/x-textencoder": "^0.3.2",
+            "@babel/runtime": "^7.12.1",
+            "@polkadot/x-textdecoder": "^0.3.3",
+            "@polkadot/x-textencoder": "^0.3.3",
             "@types/bn.js": "^4.11.6",
             "bn.js": "^5.1.3",
             "camelcase": "^5.3.1",
             "chalk": "^4.1.0",
-            "ip-regex": "^4.1.0"
+            "ip-regex": "^4.2.0"
           }
+        },
+        "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=="
         }
       }
     },
@@ -4302,12 +4437,13 @@
       }
     },
     "@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.6.1",
+      "resolved": "https://registry.npmjs.org/@polkadot/util-crypto/-/util-crypto-3.6.1.tgz",
+      "integrity": "sha512-mRCijOXrxTa2JD5vpNvr1MHSj3NaSGaImg1yzAf3l7nw7zNGjLy1K3qQNcFgr8+0NHyPKk5lCIehtwGTRZYsiA==",
       "requires": {
-        "@babel/runtime": "^7.11.2",
-        "@polkadot/util": "3.5.1",
+        "@babel/runtime": "^7.12.1",
+        "@polkadot/networks": "3.6.1",
+        "@polkadot/util": "3.6.1",
         "@polkadot/wasm-crypto": "^1.4.1",
         "base-x": "^3.0.8",
         "bip39": "^3.0.2",
@@ -4321,20 +4457,33 @@
         "xxhashjs": "^0.2.2"
       },
       "dependencies": {
+        "@babel/runtime": {
+          "version": "7.12.1",
+          "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.12.1.tgz",
+          "integrity": "sha512-J5AIf3vPj3UwXaAzb5j1xM4WAQDX3EMgemF8rjCP3SoW09LfRKAXQKt6CoVYl230P6iWdRcBbnLDDdnqWxZSCA==",
+          "requires": {
+            "regenerator-runtime": "^0.13.4"
+          }
+        },
         "@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.6.1",
+          "resolved": "https://registry.npmjs.org/@polkadot/util/-/util-3.6.1.tgz",
+          "integrity": "sha512-ToGVghmTtC8s8cg8mCGG3I88UasrCg9VNm5JoUvBH4nTZCxc/dQEkU24nULXwHUpmd7d39p3RLpVbkLCVYIMZw==",
           "requires": {
-            "@babel/runtime": "^7.11.2",
-            "@polkadot/x-textdecoder": "^0.3.2",
-            "@polkadot/x-textencoder": "^0.3.2",
+            "@babel/runtime": "^7.12.1",
+            "@polkadot/x-textdecoder": "^0.3.3",
+            "@polkadot/x-textencoder": "^0.3.3",
             "@types/bn.js": "^4.11.6",
             "bn.js": "^5.1.3",
             "camelcase": "^5.3.1",
             "chalk": "^4.1.0",
-            "ip-regex": "^4.1.0"
+            "ip-regex": "^4.2.0"
           }
+        },
+        "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=="
         }
       }
     },
@@ -4344,39 +4493,79 @@
       "integrity": "sha512-GPBCh8YvQmA5bobI4rqRkUhrEHkEWU1+lcJVPbZYsa7jiHFaZpzCLrGQfiqW/vtbU1aBS2wmJ0x1nlt33B9QqQ=="
     },
     "@polkadot/x-fetch": {
-      "version": "0.3.2",
-      "resolved": "https://registry.npmjs.org/@polkadot/x-fetch/-/x-fetch-0.3.2.tgz",
-      "integrity": "sha512-lk9M8ql/kBBqiZ8KOWj7LFK7P9OxDgVn2fZPNELJzQbfFZwFF8umBPDIWlQIK7wTnlRsQlzOuf6MGEyMK5p42w==",
+      "version": "0.3.3",
+      "resolved": "https://registry.npmjs.org/@polkadot/x-fetch/-/x-fetch-0.3.3.tgz",
+      "integrity": "sha512-Osa+ifkqlndIW5U5jLnuugLYTd6q/cHkjdfisyYgNev/etsEtXkqesbGvF/UKw5FgZBxhK8sj6jjfProfh2NZw==",
       "requires": {
-        "@babel/runtime": "^7.11.2",
+        "@babel/runtime": "^7.12.1",
         "@types/node-fetch": "^2.5.7",
         "node-fetch": "^2.6.1"
+      },
+      "dependencies": {
+        "@babel/runtime": {
+          "version": "7.12.1",
+          "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.12.1.tgz",
+          "integrity": "sha512-J5AIf3vPj3UwXaAzb5j1xM4WAQDX3EMgemF8rjCP3SoW09LfRKAXQKt6CoVYl230P6iWdRcBbnLDDdnqWxZSCA==",
+          "requires": {
+            "regenerator-runtime": "^0.13.4"
+          }
+        }
       }
     },
     "@polkadot/x-textdecoder": {
-      "version": "0.3.2",
-      "resolved": "https://registry.npmjs.org/@polkadot/x-textdecoder/-/x-textdecoder-0.3.2.tgz",
-      "integrity": "sha512-W3KK6mMzOH5kts8pSkyYyfsQuAsKUHmIm8jQkhQnSR6FRyhwJtHLZnxP3feEwkNkRbGggG6CtDPrxYCuEO0MvA==",
+      "version": "0.3.3",
+      "resolved": "https://registry.npmjs.org/@polkadot/x-textdecoder/-/x-textdecoder-0.3.3.tgz",
+      "integrity": "sha512-ehbPUUNn34kJh/RV8eQwyLnAFcMQSbtGPKqGRB7GSa/bL7P6hh1QGxB4DwvtlFU//bDTlofsv44ydpjDNmfWLg==",
       "requires": {
-        "@babel/runtime": "^7.11.2"
+        "@babel/runtime": "^7.12.1"
+      },
+      "dependencies": {
+        "@babel/runtime": {
+          "version": "7.12.1",
+          "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.12.1.tgz",
+          "integrity": "sha512-J5AIf3vPj3UwXaAzb5j1xM4WAQDX3EMgemF8rjCP3SoW09LfRKAXQKt6CoVYl230P6iWdRcBbnLDDdnqWxZSCA==",
+          "requires": {
+            "regenerator-runtime": "^0.13.4"
+          }
+        }
       }
     },
     "@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==",
+      "version": "0.3.3",
+      "resolved": "https://registry.npmjs.org/@polkadot/x-textencoder/-/x-textencoder-0.3.3.tgz",
+      "integrity": "sha512-klbz82L5LxDJTFoCO64G/EFfY1mKXHDlteJMDGFTOim/1oK1ypLOG8/7BmncmQAw2BevA0r1YkvWN+F3muJSag==",
       "requires": {
-        "@babel/runtime": "^7.11.2"
+        "@babel/runtime": "^7.12.1"
+      },
+      "dependencies": {
+        "@babel/runtime": {
+          "version": "7.12.1",
+          "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.12.1.tgz",
+          "integrity": "sha512-J5AIf3vPj3UwXaAzb5j1xM4WAQDX3EMgemF8rjCP3SoW09LfRKAXQKt6CoVYl230P6iWdRcBbnLDDdnqWxZSCA==",
+          "requires": {
+            "regenerator-runtime": "^0.13.4"
+          }
+        }
       }
     },
     "@polkadot/x-ws": {
-      "version": "0.3.2",
-      "resolved": "https://registry.npmjs.org/@polkadot/x-ws/-/x-ws-0.3.2.tgz",
-      "integrity": "sha512-1aiG11Py8sgzJsz19melMzvBOn5zeMmfjCPoMryX4//063E0mcfnkujg4O6pTMygxJdFGAV1INB9wvMU9Dg9Wg==",
+      "version": "0.3.3",
+      "resolved": "https://registry.npmjs.org/@polkadot/x-ws/-/x-ws-0.3.3.tgz",
+      "integrity": "sha512-t06ID5QLYi5B8bzlT2fcYsQ09yfLf5Uq9idunKRZj13EwSELaqvZFfn2UmiDFiIB1H5u7c2y+VDWbIdqE8ZxKw==",
       "requires": {
-        "@babel/runtime": "^7.11.2",
+        "@babel/runtime": "^7.12.1",
         "@types/websocket": "^1.0.1",
         "websocket": "^1.0.32"
+      },
+      "dependencies": {
+        "@babel/runtime": {
+          "version": "7.12.1",
+          "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.12.1.tgz",
+          "integrity": "sha512-J5AIf3vPj3UwXaAzb5j1xM4WAQDX3EMgemF8rjCP3SoW09LfRKAXQKt6CoVYl230P6iWdRcBbnLDDdnqWxZSCA==",
+          "requires": {
+            "regenerator-runtime": "^0.13.4"
+          }
+        }
       }
     },
     "@sindresorhus/is": {
modifiedtests/package.jsondiffbeforeafterboth
--- a/tests/package.json
+++ b/tests/package.json
@@ -23,9 +23,9 @@
   "license": "Apache 2.0",
   "homepage": "",
   "dependencies": {
-    "@polkadot/api": "^2.0.1",
-    "@polkadot/api-contract": "^2.0.1",
-    "@polkadot/types": "^2.0.1",
+    "@polkadot/api": "^2.3.1",
+    "@polkadot/api-contract": "^2.3.1",
+    "@polkadot/types": "^2.3.1",
     "@polkadot/util": "^3.4.1",
     "@types/bn.js": "^4.11.6",
     "chai-as-promised": "^7.1.1"
modifiedtests/src/contracts.test.tsdiffbeforeafterboth
before · tests/src/contracts.test.ts
1import { expect } from "chai";2import usingApi from "./substrate/substrate-api";3import promisifySubstrate from "./substrate/promisify-substrate";4import fs from "fs";5import privateKey from "./substrate/privateKey";6import { compactAddLength, u8aToU8a } from '@polkadot/util';7import { Hash, AccountId } from "@polkadot/types/interfaces";8import { Abi, PromiseContract } from "@polkadot/api-contract";9import { ISubmittableResult, IKeyringPair } from "@polkadot/types/types";10import BN from "bn.js";11import { alicesPublicKey, bobsPublicKey } from "./accounts";12import { ApiPromise } from "@polkadot/api";13import { GenericAccountId, u128 } from "@polkadot/types";14import getBalance from "./substrate/get-balance";151617function deployContract(api: ApiPromise, contract: Uint8Array, privateKey: IKeyringPair): Promise<Hash> {18  return promisifySubstrate(api, () => {19    return new Promise<Hash>(async (resolve, reject) => {20      const unsubscribe = api.tx.contracts.putCode(contract).signAndSend(privateKey, async result => {21        if(!result.isInBlock){22          return;23        }2425        const record = result.findRecord('contracts', 'CodeStored');2627        if(record) {28          (await unsubscribe)();29          resolve(record.event.data[0] as unknown as Hash);30        } else {31          reject('Failed to find contract hash in putCode transaction result.');32        }33      });34    })35  })();36}3738function instantiateContract(api: ApiPromise, contractHash: Hash, args: Uint8Array, privateKey: IKeyringPair): Promise<AccountId> {39  return promisifySubstrate(api, () => {40    return new Promise<AccountId>((resolve, reject) => {41      const unsubscribe = api.tx.contracts.instantiate(1000000000000000n, 1000000000000n, contractHash, args)42        .signAndSend(privateKey, async (result:ISubmittableResult) => {43          if(!result.isInBlock) {44            return;45          }46          const record = result.findRecord('contracts', 'Instantiated');47          if(record) {48            (await unsubscribe)();49            expect(alicesPublicKey).to.be.equal(record.event.data[0].toString());50            resolve(record.event.data[1] as AccountId);51          } else {52            reject('Failed to find instantiated event.');53          }54        });55    });56  })();57}5859function txContractCall(api: ApiPromise, privateKey: IKeyringPair, address: string, call: Uint8Array): Promise<void> {60  return promisifySubstrate(api, async () => {61    return new Promise<void>(async (resolve, reject) => {62      api.tx.contracts.call(address, 0, 1000000000000n, call)63        .signAndSend(privateKey, async result => {64          if(!result.isInBlock) {65            return;66          }6768          if(result.findRecord('system', 'ExtrinsicSuccess')) {69            resolve();70          }71          else {72            reject('Failed to execute tx call.');73          }74        })75    });76  })();77}7879describe('Contracts', () => {80  it(`Can deploy smart contract Flipper, instantiate it and call it's get and flip messages.`, async () => {81    await usingApi(async api => {82      const wasm = fs.readFileSync('./src/flipper/flipper.wasm');83      const contract = compactAddLength(u8aToU8a(wasm));8485      const metadata = JSON.parse(fs.readFileSync('./src/flipper/metadata.json').toString('utf-8'));86      const abi = new Abi(api.registry as any, metadata);8788      const alicesPrivateKey = privateKey('//Alice');8990      const contractHash = await deployContract(api, contract, alicesPrivateKey);9192      const args = abi.constructors[0](true);93      const instanceAccountId = await instantiateContract(api, contractHash, args, alicesPrivateKey);9495      const contractInstance = new PromiseContract(api, abi, instanceAccountId);96      const getFlipValue = async () => {97        return await promisifySubstrate(api, async () => {98          const result = await contractInstance.call('rpc', 'get', 0, new BN('1000000000000'))99            .send(alicesPublicKey);100          if(!result.isSuccess) {101            throw 'Failed to get flipper value';102          }103          return result.output && result.output.valueOf && result.output.valueOf();104        })();105      }106107      const initialGetResponse = await getFlipValue();108      expect(initialGetResponse).to.be.true;109110      await promisifySubstrate(api, async () => {111        return new Promise<void>(async (resolve, reject) => {112          api.tx.contracts.call(contractInstance.address.toString(), 0, 1000000000000n, contractInstance.getMessage('flip').fn())113            .signAndSend(alicesPrivateKey, async result => {114              if(!result.isInBlock) {115                return;116              }117118              if(result.findRecord('system', 'ExtrinsicSuccess')) {119                resolve();120              }121              else {122                reject('Failed to flip value.');123              }124            })125        });126      })();127128      const afterFlipGetResponse = await getFlipValue();129130      expect(afterFlipGetResponse).to.be.false;131    });132  });133134  it.skip('Can transfer balance using smart contract.', async () => {135    await usingApi(async api => {136      const [alicesBalanceBefore, bobsBalanceBefore] = await getBalance(api, [alicesPublicKey, bobsPublicKey]);137      const wasm = fs.readFileSync('./src/balance-transfer-contract/calls.wasm');138      const contract = compactAddLength(u8aToU8a(wasm));139140      const metadata = JSON.parse(fs.readFileSync('./src/balance-transfer-contract/metadata.json').toString('utf-8'));141      const abi = new Abi(api.registry as any, metadata);142143      const alicesPrivateKey = privateKey('//Alice');144145      const contractHash = await deployContract(api, contract, alicesPrivateKey);146147      const args = abi.constructors[0]();148      const instanceAccountId = await instantiateContract(api, contractHash, args, alicesPrivateKey);149      const contractInstance = new PromiseContract(api, abi, instanceAccountId);150      const bob = new GenericAccountId(api.registry, bobsPublicKey);151      const call = contractInstance.getMessage('balance_transfer').fn(bob, new u128(api.registry, 1000000));152      await txContractCall(api, alicesPrivateKey, contractInstance.address.toString(), call);153154      const [alicesBalanceAfter, bobsBalanceAfter] = await getBalance(api, [alicesPublicKey, bobsPublicKey]);155156      expect(alicesBalanceAfter < alicesBalanceBefore).to.be.true;157      expect(bobsBalanceAfter > bobsBalanceBefore).to.be.true;158    });159  })160});
after · tests/src/contracts.test.ts
1import { expect } from "chai";2import usingApi from "./substrate/substrate-api";3import fs from "fs";4import { Abi, BlueprintPromise, CodePromise } from "@polkadot/api-contract";5import { IKeyringPair } from "@polkadot/types/types";6import { Keyring } from "@polkadot/api";7import { ApiTypes, SubmittableExtrinsic } from "@polkadot/api/types";89const value = 0;10const gasLimit = 3000n * 1000000n;1112function deployBlueprint(alice: IKeyringPair, code: CodePromise): Promise<BlueprintPromise> {13  return new Promise<BlueprintPromise>(async (resolve, reject) => {14    const unsub = await code15      .createBlueprint()16      .signAndSend(alice, (result) => {17        if (result.status.isInBlock || result.status.isFinalized) {18          // here we have an additional field in the result, containing the blueprint19          resolve(result.blueprint);20          unsub();21        }22      })23  });24}2526function deployContract(alice: IKeyringPair, blueprint: BlueprintPromise) : Promise<any> {27  return new Promise<any>(async (resolve, reject) => {28    const endowment = 1000000000000000n;29    const initValue = true;3031    const unsub = await blueprint.tx32    .new(endowment, gasLimit, initValue)33    .signAndSend(alice, (result) => {34      if (result.status.isInBlock || result.status.isFinalized) {35        unsub();36        resolve(result);37      }38    });    39  });40}4142function runTransaction(privateKey: IKeyringPair, extrinsic: SubmittableExtrinsic<ApiTypes>) {43  return new Promise<void>(async (resolve, reject) => {44    extrinsic.signAndSend(privateKey, async result => {45        if(!result.isInBlock) {46          return;47        }4849        if(result.findRecord('system', 'ExtrinsicSuccess')) {50          resolve();51        }52        else {53          reject('Failed to flip value.');54        }55      })56  });57}5859describe('Contracts', () => {60  it(`Can deploy smart contract Flipper, instantiate it and call it's get and flip messages.`, async () => {61    await usingApi(async api => {62      const keyring = new Keyring({ type: 'sr25519' });63      const alice = keyring.addFromUri("//Alice");64      65      const wasm = fs.readFileSync('./src/flipper/flipper.wasm');66      67      const metadata = JSON.parse(fs.readFileSync('./src/flipper/metadata.json').toString('utf-8'));68      const abi = new Abi(metadata);6970      const code = new CodePromise(api, abi, wasm);7172      const blueprint = await deployBlueprint(alice, code);73      const contract = (await deployContract(alice, blueprint))['contract'];7475      const getFlipValue = async () => {76        const result = await contract.query.get(alice.address, value, gasLimit);7778        if(!result.result.isSuccess) {79          throw `Failed to get flipper value`;80        }81        return (result.result.asSuccess.data[0] == 0x00) ? false : true;82      }8384      const initialGetResponse = await getFlipValue();85      expect(initialGetResponse).to.be.true;8687      const flip = contract.exec('flip', value, gasLimit);88      await runTransaction(alice, flip);8990      const afterFlipGetResponse = await getFlipValue();9192      expect(afterFlipGetResponse).to.be.false;93    });94  });9596  it.skip('Can transfer balance using smart contract.', async () => {97    await usingApi(async api => {98      // const [alicesBalanceBefore, bobsBalanceBefore] = await getBalance(api, [alicesPublicKey, bobsPublicKey]);99      // const wasm = fs.readFileSync('./src/balance-transfer-contract/calls.wasm');100      // const contract = compactAddLength(u8aToU8a(wasm));101102      // const metadata = JSON.parse(fs.readFileSync('./src/balance-transfer-contract/metadata.json').toString('utf-8'));103      // const abi = new Abi(api.registry as any, metadata);104105      // const alicesPrivateKey = privateKey('//Alice');106107      // const contractHash = await deployContract(api, contract, alicesPrivateKey);108109      // // const args = abi.constructors[0]();110      // const instanceAccountId = await instantiateContract(api, contractHash, /*args,*/ alicesPrivateKey);111      // const contractInstance = new ContractPromise(api, abi, instanceAccountId);112      // const bob = new GenericAccountId(api.registry, bobsPublicKey);113114      // const transfer = contractInstance.exec('balance_transfer', 0, 1000000000000n, [bob, new u128(api.registry, 1000000)]);115      // await runTransaction(alicesPrivateKey, transfer);116117      // const [alicesBalanceAfter, bobsBalanceAfter] = await getBalance(api, [alicesPublicKey, bobsPublicKey]);118119      // expect(alicesBalanceAfter < alicesBalanceBefore).to.be.true;120      // expect(bobsBalanceAfter > bobsBalanceBefore).to.be.true;121    });122  })123});