git.delta.rocks / unique-network / refs/commits / 6b2c05162432

difftreelog

ci type package generation script

Yaroslav Bolyukin2022-10-24parent: #06c5ffc.patch.diff
in: master

8 files changed

addedtests/scripts/functions.shdiffbeforeafterboth
--- /dev/null
+++ b/tests/scripts/functions.sh
@@ -0,0 +1,4 @@
+
+function do_rpc {
+	curl -s --header "Content-Type: application/json" -XPOST --data "{\"id\":1,\"jsonrpc\":\"2.0\",\"method\":\"$1\",\"params\":[$2]}" $RPC_URL
+}
addedtests/scripts/generate_types_package.shdiffbeforeafterboth

no changes

addedtests/scripts/types_template/.gitignorediffbeforeafterboth
--- /dev/null
+++ b/tests/scripts/types_template/.gitignore
@@ -0,0 +1,5 @@
+*.js
+*.map
+*.d.ts
+/node_modules
+metadata.json
addedtests/scripts/types_template/.npmignorediffbeforeafterboth
--- /dev/null
+++ b/tests/scripts/types_template/.npmignore
@@ -0,0 +1 @@
+/src
addedtests/scripts/types_template/README.mddiffbeforeafterboth
--- /dev/null
+++ b/tests/scripts/types_template/README.md
@@ -0,0 +1,31 @@
+# PKGNAME
+
+Unique network api types
+
+Do not edit by hand, those types are generated automatically, and definitions are located in chain repo
+
+## Using types
+
+Install library:
+
+```bash
+yarn add --dev PKGNAME
+```
+
+Replace polkadot.js types with our chain types adding corresponding path override to the tsconfig `compilerOptions.paths` section:
+
+```json
+// in tsconfig.json
+{
+  "compilerOptions": {
+    "paths": {
+      "@polkadot/types/lookup": ["node_modules/PKGNAME/types-lookup"]
+    }
+  }
+}
+```
+
+Since polkadot v7 api augmentations not loaded by default, in every file, where you need to access `api.tx`, `api.query`, `api.rpc`, etc; you should explicitly import corresponding augmentation before any other `polkadot.js` related import:
+```
+import 'PKGNAME/augment-api';
+```
addedtests/scripts/types_template/package.jsondiffbeforeafterboth
--- /dev/null
+++ b/tests/scripts/types_template/package.json
@@ -0,0 +1,22 @@
+{
+  "name": "TODO",
+  "private": true,
+  "version": "TODO",
+  "main": "index.js",
+  "repository": "git@github.com:UniqueNetwork/unique-types-js.git",
+  "homepage": "https://unique.network/",
+  "license": "MIT",
+  "scripts": {
+    "prepublish": "tsc -d"
+  },
+  "peerDependencies": {
+    "@polkadot/api": "TODO",
+    "@polkadot/types": "TODO"
+  },
+  "devDependencies": {
+    "@polkadot/api": "TODO",
+    "@polkadot/types": "TODO",
+    "ts-node": "TODO",
+    "typescript": "TODO"
+  }
+}
addedtests/scripts/types_template/tsconfig.jsondiffbeforeafterboth
--- /dev/null
+++ b/tests/scripts/types_template/tsconfig.json
@@ -0,0 +1,28 @@
+{
+	"exclude": [
+		"node_modules",
+		"node_modules/**/*",
+		"../node_modules/**/*",
+		"**/node_modules/**/*"
+	],
+	"compilerOptions": {
+		"target": "ES2020",
+		"moduleResolution": "node",
+		"esModuleInterop": true,
+		"resolveJsonModule": true,
+		"module": "commonjs",
+		"sourceMap": true,
+		"outDir": ".",
+		"rootDir": ".",
+		"strict": true,
+		"paths": {
+		},
+		"skipLibCheck": true,
+	},
+	"include": [
+		"**/*",
+	],
+	"lib": [
+		"es2017"
+	],
+}
modifiedtests/scripts/wait_for_first_block.shdiffbeforeafterboth
--- a/tests/scripts/wait_for_first_block.sh
+++ b/tests/scripts/wait_for_first_block.sh
@@ -1,15 +1,11 @@
 #!/usr/bin/env bash
 
-function do_rpc {
-	curl -s --header "Content-Type: application/json" -XPOST --data "{\"id\":1,\"jsonrpc\":\"2.0\",\"method\":\"$1\",\"params\":[$2]}" $RPC_URL
-}
+DIR=$(dirname "$0")
+
+. $DIR/functions.sh
 
 function is_started {
-    block_hash_rpc=$(do_rpc chain_getFinalizedHead)
-    echo Rpc response = $block_hash_rpc
-	block_hash=$(echo $block_hash_rpc | jq -r .result)
-	echo Head = $block_hash
-	block_id_hex=$(do_rpc chain_getHeader "\"$block_hash\"" | jq -r .result.number)
+	block_id_hex=$(do_rpc chain_getHeader | jq -r .result.number)
 	block_id=$((${block_id_hex}))
 	echo Id = $block_id
 	if (( $block_id > 1 )); then