From 78ceb8bf9b830ee77db52f553c20320911abf567 Mon Sep 17 00:00:00 2001 From: Christian Langenbacher Date: Wed, 10 Apr 2024 11:53:11 +0800 Subject: [PATCH 01/12] [worker] fix imports --- packages/util/src/index.ts | 1 + packages/worker-api/src/requests.ts | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/util/src/index.ts b/packages/util/src/index.ts index 3cd6865c..1d2c313f 100644 --- a/packages/util/src/index.ts +++ b/packages/util/src/index.ts @@ -6,6 +6,7 @@ import type {ParserFixPointFn} from './parserFixPoint.js'; export * from './cidUtil.js'; export * from './toFixPoint.js'; export * from './parserFixPoint.js'; +export * from './common.js'; export const parseI4F4: ParserFixPointFn = parserFixPoint(4, 4); diff --git a/packages/worker-api/src/requests.ts b/packages/worker-api/src/requests.ts index 511affdb..38c5efa6 100644 --- a/packages/worker-api/src/requests.ts +++ b/packages/worker-api/src/requests.ts @@ -2,10 +2,10 @@ import { createJsonRpcRequest, type IWorker, type PublicGetterArgs, type TrustedGetterArgs -} from "@encointer/worker-api/interface.js"; +} from "./interface.js"; import type {BalanceTransferArgs, BalanceUnshieldArgs, ShardIdentifier, IntegriteeTrustedCallSigned} from "@encointer/types"; import type {KeyringPair} from "@polkadot/keyring/types"; -import {type PubKeyPinPair, toAccount} from "@encointer/util/common.js"; +import {type PubKeyPinPair, toAccount} from "@encointer/util"; import type {u32} from "@polkadot/types"; import bs58 from "bs58"; From 42573322acf82ccf0d991fcf7f2bff8f9c2db47d Mon Sep 17 00:00:00 2001 From: Christian Langenbacher Date: Wed, 10 Apr 2024 11:53:35 +0800 Subject: [PATCH 02/12] v0.12.0-alpha.2 --- lerna.json | 2 +- packages/node-api/package.json | 4 ++-- packages/types/package.json | 2 +- packages/util/package.json | 2 +- packages/worker-api/package.json | 8 ++++---- yarn.lock | 14 +++++++------- 6 files changed, 16 insertions(+), 16 deletions(-) diff --git a/lerna.json b/lerna.json index e5cb2f92..cf760d8c 100644 --- a/lerna.json +++ b/lerna.json @@ -7,5 +7,5 @@ "publishConfig": { "directory": "build" }, - "version": "0.12.0-alpha.1" + "version": "0.12.0-alpha.2" } diff --git a/packages/node-api/package.json b/packages/node-api/package.json index 537b4995..977d8f23 100644 --- a/packages/node-api/package.json +++ b/packages/node-api/package.json @@ -18,10 +18,10 @@ }, "sideEffects": false, "type": "module", - "version": "0.12.0-alpha.1", + "version": "0.12.0-alpha.2", "main": "index.js", "dependencies": { - "@encointer/types": "^0.12.0-alpha.1", + "@encointer/types": "^0.12.0-alpha.2", "@polkadot/api": "^10.9.1", "tslib": "^2.5.3" }, diff --git a/packages/types/package.json b/packages/types/package.json index 2410b02d..14578b75 100644 --- a/packages/types/package.json +++ b/packages/types/package.json @@ -18,7 +18,7 @@ }, "sideEffects": false, "type": "module", - "version": "0.12.0-alpha.1", + "version": "0.12.0-alpha.2", "main": "index.js", "scripts": { "generate:defs": "node --experimental-specifier-resolution=node --loader ts-node/esm ../../node_modules/.bin/polkadot-types-from-defs --package @encointer/types/interfaces --input ./src/interfaces", diff --git a/packages/util/package.json b/packages/util/package.json index b065ea16..382d4590 100644 --- a/packages/util/package.json +++ b/packages/util/package.json @@ -20,7 +20,7 @@ "sideEffects": false, "type": "module", "types": "./index.d.ts", - "version": "0.12.0-alpha.1", + "version": "0.12.0-alpha.2", "main": "index.js", "dependencies": { "@babel/runtime": "^7.18.9", diff --git a/packages/worker-api/package.json b/packages/worker-api/package.json index 41d6be8c..01e5ce97 100644 --- a/packages/worker-api/package.json +++ b/packages/worker-api/package.json @@ -19,12 +19,12 @@ "sideEffects": false, "type": "module", "types": "./index.d.ts", - "version": "0.12.0-alpha.1", + "version": "0.12.0-alpha.2", "main": "index.js", "dependencies": { - "@encointer/node-api": "^0.12.0-alpha.1", - "@encointer/types": "^0.12.0-alpha.1", - "@encointer/util": "^0.12.0-alpha.1", + "@encointer/node-api": "^0.12.0-alpha.2", + "@encointer/types": "^0.12.0-alpha.2", + "@encointer/util": "^0.12.0-alpha.2", "@polkadot/api": "^10.9.1", "@polkadot/keyring": "^12.3.2", "@polkadot/types": "^10.9.1", diff --git a/yarn.lock b/yarn.lock index fdb1f7ef..bc4137a4 100644 --- a/yarn.lock +++ b/yarn.lock @@ -755,18 +755,18 @@ __metadata: languageName: node linkType: hard -"@encointer/node-api@^0.12.0-alpha.1, @encointer/node-api@workspace:packages/node-api": +"@encointer/node-api@^0.12.0-alpha.2, @encointer/node-api@workspace:packages/node-api": version: 0.0.0-use.local resolution: "@encointer/node-api@workspace:packages/node-api" dependencies: - "@encointer/types": ^0.12.0-alpha.1 + "@encointer/types": ^0.12.0-alpha.2 "@polkadot/api": ^10.9.1 "@polkadot/util-crypto": ^12.3.2 tslib: ^2.5.3 languageName: unknown linkType: soft -"@encointer/types@^0.12.0-alpha.1, @encointer/types@workspace:packages/types": +"@encointer/types@^0.12.0-alpha.2, @encointer/types@workspace:packages/types": version: 0.0.0-use.local resolution: "@encointer/types@workspace:packages/types" dependencies: @@ -781,7 +781,7 @@ __metadata: languageName: unknown linkType: soft -"@encointer/util@^0.12.0-alpha.1, @encointer/util@workspace:packages/util": +"@encointer/util@^0.12.0-alpha.2, @encointer/util@workspace:packages/util": version: 0.0.0-use.local resolution: "@encointer/util@workspace:packages/util" dependencies: @@ -798,9 +798,9 @@ __metadata: version: 0.0.0-use.local resolution: "@encointer/worker-api@workspace:packages/worker-api" dependencies: - "@encointer/node-api": ^0.12.0-alpha.1 - "@encointer/types": ^0.12.0-alpha.1 - "@encointer/util": ^0.12.0-alpha.1 + "@encointer/node-api": ^0.12.0-alpha.2 + "@encointer/types": ^0.12.0-alpha.2 + "@encointer/util": ^0.12.0-alpha.2 "@polkadot/api": ^10.9.1 "@polkadot/keyring": ^12.3.2 "@polkadot/types": ^10.9.1 From c032d09eebfc5423b67adb3e3641999471c1465a Mon Sep 17 00:00:00 2001 From: Christian Langenbacher Date: Wed, 10 Apr 2024 12:00:03 +0800 Subject: [PATCH 03/12] fix missing peerdependencies --- package.json | 2 ++ packages/worker-api/package.json | 3 +++ yarn.lock | 6 +++++- 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 4bed965c..b23d7729 100644 --- a/package.json +++ b/package.json @@ -28,6 +28,8 @@ "version": "yarn install && git stage yarn.lock" }, "dependencies": { + "@types/node": "20.3.2", + "jest-resolve": "^29.5.0", "jest-ts-webcompat-resolver": "^1.0.0" }, "devDependencies": { diff --git a/packages/worker-api/package.json b/packages/worker-api/package.json index 01e5ce97..1b01e19b 100644 --- a/packages/worker-api/package.json +++ b/packages/worker-api/package.json @@ -36,6 +36,9 @@ "websocket": "^1.0.34", "websocket-as-promised": "^2.0.1" }, + "peerDependencies": { + "@polkadot/x-randomvalues": "^12.3.2" + }, "devDependencies": { "@types/bs58": "^4.0.1" } diff --git a/yarn.lock b/yarn.lock index bc4137a4..050bad25 100644 --- a/yarn.lock +++ b/yarn.lock @@ -812,6 +812,8 @@ __metadata: node-rsa: ^1.1.1 websocket: ^1.0.34 websocket-as-promised: ^2.0.1 + peerDependencies: + "@polkadot/x-randomvalues": ^12.3.2 languageName: unknown linkType: soft @@ -3598,7 +3600,7 @@ __metadata: languageName: node linkType: hard -"@types/node@npm:^20.3.1": +"@types/node@npm:20.3.2, @types/node@npm:^20.3.1": version: 20.3.2 resolution: "@types/node@npm:20.3.2" checksum: 5929ce2b9b12b1e2a2304a0921a953c72a81f5753ad39ac43b99ce6312fbb2b4fb5bc6b60d64a2550704e3223cd5de1299467d36085ac69888899db978f2653a @@ -13227,8 +13229,10 @@ __metadata: "@polkadot/dev": ^0.75.22 "@polkadot/types": ^10.9.1 "@types/jest": ^28.1.7 + "@types/node": 20.3.2 "@types/websocket": ^1.0.5 jest: ^29.5.0 + jest-resolve: ^29.5.0 jest-ts-webcompat-resolver: ^1.0.0 lerna: ^5.4.3 ts-jest: ^29.1.0 From cbd46c07a2cd195f2d0ed56d863746d9ce1c54ff Mon Sep 17 00:00:00 2001 From: Christian Langenbacher Date: Wed, 10 Apr 2024 12:06:58 +0800 Subject: [PATCH 04/12] add promised map as dependency --- packages/worker-api/package.json | 1 + yarn.lock | 1 + 2 files changed, 2 insertions(+) diff --git a/packages/worker-api/package.json b/packages/worker-api/package.json index 1b01e19b..f56557bf 100644 --- a/packages/worker-api/package.json +++ b/packages/worker-api/package.json @@ -33,6 +33,7 @@ "@polkadot/wasm-crypto": "^7.2.1", "bs58": "^4.0.1", "node-rsa": "^1.1.1", + "promised-map": "^1.0.0", "websocket": "^1.0.34", "websocket-as-promised": "^2.0.1" }, diff --git a/yarn.lock b/yarn.lock index 050bad25..c5548709 100644 --- a/yarn.lock +++ b/yarn.lock @@ -810,6 +810,7 @@ __metadata: "@types/bs58": ^4.0.1 bs58: ^4.0.1 node-rsa: ^1.1.1 + promised-map: ^1.0.0 websocket: ^1.0.34 websocket-as-promised: ^2.0.1 peerDependencies: From 6031e5140609ecf673973f416e92aa66b093de98 Mon Sep 17 00:00:00 2001 From: Christian Langenbacher Date: Wed, 10 Apr 2024 12:07:31 +0800 Subject: [PATCH 05/12] v0.12.0-alpha.3 --- lerna.json | 2 +- packages/node-api/package.json | 4 ++-- packages/types/package.json | 2 +- packages/util/package.json | 2 +- packages/worker-api/package.json | 8 ++++---- yarn.lock | 14 +++++++------- 6 files changed, 16 insertions(+), 16 deletions(-) diff --git a/lerna.json b/lerna.json index cf760d8c..f95a5e7c 100644 --- a/lerna.json +++ b/lerna.json @@ -7,5 +7,5 @@ "publishConfig": { "directory": "build" }, - "version": "0.12.0-alpha.2" + "version": "0.12.0-alpha.3" } diff --git a/packages/node-api/package.json b/packages/node-api/package.json index 977d8f23..e56990a1 100644 --- a/packages/node-api/package.json +++ b/packages/node-api/package.json @@ -18,10 +18,10 @@ }, "sideEffects": false, "type": "module", - "version": "0.12.0-alpha.2", + "version": "0.12.0-alpha.3", "main": "index.js", "dependencies": { - "@encointer/types": "^0.12.0-alpha.2", + "@encointer/types": "^0.12.0-alpha.3", "@polkadot/api": "^10.9.1", "tslib": "^2.5.3" }, diff --git a/packages/types/package.json b/packages/types/package.json index 14578b75..947d93c3 100644 --- a/packages/types/package.json +++ b/packages/types/package.json @@ -18,7 +18,7 @@ }, "sideEffects": false, "type": "module", - "version": "0.12.0-alpha.2", + "version": "0.12.0-alpha.3", "main": "index.js", "scripts": { "generate:defs": "node --experimental-specifier-resolution=node --loader ts-node/esm ../../node_modules/.bin/polkadot-types-from-defs --package @encointer/types/interfaces --input ./src/interfaces", diff --git a/packages/util/package.json b/packages/util/package.json index 382d4590..94771fd7 100644 --- a/packages/util/package.json +++ b/packages/util/package.json @@ -20,7 +20,7 @@ "sideEffects": false, "type": "module", "types": "./index.d.ts", - "version": "0.12.0-alpha.2", + "version": "0.12.0-alpha.3", "main": "index.js", "dependencies": { "@babel/runtime": "^7.18.9", diff --git a/packages/worker-api/package.json b/packages/worker-api/package.json index f56557bf..e029b0d5 100644 --- a/packages/worker-api/package.json +++ b/packages/worker-api/package.json @@ -19,12 +19,12 @@ "sideEffects": false, "type": "module", "types": "./index.d.ts", - "version": "0.12.0-alpha.2", + "version": "0.12.0-alpha.3", "main": "index.js", "dependencies": { - "@encointer/node-api": "^0.12.0-alpha.2", - "@encointer/types": "^0.12.0-alpha.2", - "@encointer/util": "^0.12.0-alpha.2", + "@encointer/node-api": "^0.12.0-alpha.3", + "@encointer/types": "^0.12.0-alpha.3", + "@encointer/util": "^0.12.0-alpha.3", "@polkadot/api": "^10.9.1", "@polkadot/keyring": "^12.3.2", "@polkadot/types": "^10.9.1", diff --git a/yarn.lock b/yarn.lock index c5548709..c99ca470 100644 --- a/yarn.lock +++ b/yarn.lock @@ -755,18 +755,18 @@ __metadata: languageName: node linkType: hard -"@encointer/node-api@^0.12.0-alpha.2, @encointer/node-api@workspace:packages/node-api": +"@encointer/node-api@^0.12.0-alpha.3, @encointer/node-api@workspace:packages/node-api": version: 0.0.0-use.local resolution: "@encointer/node-api@workspace:packages/node-api" dependencies: - "@encointer/types": ^0.12.0-alpha.2 + "@encointer/types": ^0.12.0-alpha.3 "@polkadot/api": ^10.9.1 "@polkadot/util-crypto": ^12.3.2 tslib: ^2.5.3 languageName: unknown linkType: soft -"@encointer/types@^0.12.0-alpha.2, @encointer/types@workspace:packages/types": +"@encointer/types@^0.12.0-alpha.3, @encointer/types@workspace:packages/types": version: 0.0.0-use.local resolution: "@encointer/types@workspace:packages/types" dependencies: @@ -781,7 +781,7 @@ __metadata: languageName: unknown linkType: soft -"@encointer/util@^0.12.0-alpha.2, @encointer/util@workspace:packages/util": +"@encointer/util@^0.12.0-alpha.3, @encointer/util@workspace:packages/util": version: 0.0.0-use.local resolution: "@encointer/util@workspace:packages/util" dependencies: @@ -798,9 +798,9 @@ __metadata: version: 0.0.0-use.local resolution: "@encointer/worker-api@workspace:packages/worker-api" dependencies: - "@encointer/node-api": ^0.12.0-alpha.2 - "@encointer/types": ^0.12.0-alpha.2 - "@encointer/util": ^0.12.0-alpha.2 + "@encointer/node-api": ^0.12.0-alpha.3 + "@encointer/types": ^0.12.0-alpha.3 + "@encointer/util": ^0.12.0-alpha.3 "@polkadot/api": ^10.9.1 "@polkadot/keyring": ^12.3.2 "@polkadot/types": ^10.9.1 From eef8ce8b72da0550b02932cfa1232a1089ff5e7d Mon Sep 17 00:00:00 2001 From: Christian Langenbacher Date: Wed, 10 Apr 2024 12:08:27 +0800 Subject: [PATCH 06/12] fmt --- packages/worker-api/package.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/worker-api/package.json b/packages/worker-api/package.json index e029b0d5..c8bc38dd 100644 --- a/packages/worker-api/package.json +++ b/packages/worker-api/package.json @@ -37,10 +37,10 @@ "websocket": "^1.0.34", "websocket-as-promised": "^2.0.1" }, - "peerDependencies": { - "@polkadot/x-randomvalues": "^12.3.2" - }, "devDependencies": { "@types/bs58": "^4.0.1" + }, + "peerDependencies": { + "@polkadot/x-randomvalues": "^12.3.2" } } From 1f83fb60bb0a187ddb411a27ac2096d653c1e868 Mon Sep 17 00:00:00 2001 From: Christian Langenbacher Date: Wed, 10 Apr 2024 12:08:57 +0800 Subject: [PATCH 07/12] v0.12.0-alpha.4 --- lerna.json | 2 +- packages/node-api/package.json | 4 ++-- packages/types/package.json | 2 +- packages/util/package.json | 2 +- packages/worker-api/package.json | 8 ++++---- yarn.lock | 14 +++++++------- 6 files changed, 16 insertions(+), 16 deletions(-) diff --git a/lerna.json b/lerna.json index f95a5e7c..1395bf64 100644 --- a/lerna.json +++ b/lerna.json @@ -7,5 +7,5 @@ "publishConfig": { "directory": "build" }, - "version": "0.12.0-alpha.3" + "version": "0.12.0-alpha.4" } diff --git a/packages/node-api/package.json b/packages/node-api/package.json index e56990a1..ee67d8e3 100644 --- a/packages/node-api/package.json +++ b/packages/node-api/package.json @@ -18,10 +18,10 @@ }, "sideEffects": false, "type": "module", - "version": "0.12.0-alpha.3", + "version": "0.12.0-alpha.4", "main": "index.js", "dependencies": { - "@encointer/types": "^0.12.0-alpha.3", + "@encointer/types": "^0.12.0-alpha.4", "@polkadot/api": "^10.9.1", "tslib": "^2.5.3" }, diff --git a/packages/types/package.json b/packages/types/package.json index 947d93c3..df7b20e9 100644 --- a/packages/types/package.json +++ b/packages/types/package.json @@ -18,7 +18,7 @@ }, "sideEffects": false, "type": "module", - "version": "0.12.0-alpha.3", + "version": "0.12.0-alpha.4", "main": "index.js", "scripts": { "generate:defs": "node --experimental-specifier-resolution=node --loader ts-node/esm ../../node_modules/.bin/polkadot-types-from-defs --package @encointer/types/interfaces --input ./src/interfaces", diff --git a/packages/util/package.json b/packages/util/package.json index 94771fd7..b7b0dc37 100644 --- a/packages/util/package.json +++ b/packages/util/package.json @@ -20,7 +20,7 @@ "sideEffects": false, "type": "module", "types": "./index.d.ts", - "version": "0.12.0-alpha.3", + "version": "0.12.0-alpha.4", "main": "index.js", "dependencies": { "@babel/runtime": "^7.18.9", diff --git a/packages/worker-api/package.json b/packages/worker-api/package.json index c8bc38dd..3e79415d 100644 --- a/packages/worker-api/package.json +++ b/packages/worker-api/package.json @@ -19,12 +19,12 @@ "sideEffects": false, "type": "module", "types": "./index.d.ts", - "version": "0.12.0-alpha.3", + "version": "0.12.0-alpha.4", "main": "index.js", "dependencies": { - "@encointer/node-api": "^0.12.0-alpha.3", - "@encointer/types": "^0.12.0-alpha.3", - "@encointer/util": "^0.12.0-alpha.3", + "@encointer/node-api": "^0.12.0-alpha.4", + "@encointer/types": "^0.12.0-alpha.4", + "@encointer/util": "^0.12.0-alpha.4", "@polkadot/api": "^10.9.1", "@polkadot/keyring": "^12.3.2", "@polkadot/types": "^10.9.1", diff --git a/yarn.lock b/yarn.lock index c99ca470..756587a0 100644 --- a/yarn.lock +++ b/yarn.lock @@ -755,18 +755,18 @@ __metadata: languageName: node linkType: hard -"@encointer/node-api@^0.12.0-alpha.3, @encointer/node-api@workspace:packages/node-api": +"@encointer/node-api@^0.12.0-alpha.4, @encointer/node-api@workspace:packages/node-api": version: 0.0.0-use.local resolution: "@encointer/node-api@workspace:packages/node-api" dependencies: - "@encointer/types": ^0.12.0-alpha.3 + "@encointer/types": ^0.12.0-alpha.4 "@polkadot/api": ^10.9.1 "@polkadot/util-crypto": ^12.3.2 tslib: ^2.5.3 languageName: unknown linkType: soft -"@encointer/types@^0.12.0-alpha.3, @encointer/types@workspace:packages/types": +"@encointer/types@^0.12.0-alpha.4, @encointer/types@workspace:packages/types": version: 0.0.0-use.local resolution: "@encointer/types@workspace:packages/types" dependencies: @@ -781,7 +781,7 @@ __metadata: languageName: unknown linkType: soft -"@encointer/util@^0.12.0-alpha.3, @encointer/util@workspace:packages/util": +"@encointer/util@^0.12.0-alpha.4, @encointer/util@workspace:packages/util": version: 0.0.0-use.local resolution: "@encointer/util@workspace:packages/util" dependencies: @@ -798,9 +798,9 @@ __metadata: version: 0.0.0-use.local resolution: "@encointer/worker-api@workspace:packages/worker-api" dependencies: - "@encointer/node-api": ^0.12.0-alpha.3 - "@encointer/types": ^0.12.0-alpha.3 - "@encointer/util": ^0.12.0-alpha.3 + "@encointer/node-api": ^0.12.0-alpha.4 + "@encointer/types": ^0.12.0-alpha.4 + "@encointer/util": ^0.12.0-alpha.4 "@polkadot/api": ^10.9.1 "@polkadot/keyring": ^12.3.2 "@polkadot/types": ^10.9.1 From 05dfa417967c40a3b58eaf72e215b6b7c7e0f333 Mon Sep 17 00:00:00 2001 From: Christian Langenbacher Date: Thu, 11 Apr 2024 09:59:58 +0800 Subject: [PATCH 08/12] [worker] merge metadata derived types into our static type registry. --- packages/worker-api/src/worker.ts | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/packages/worker-api/src/worker.ts b/packages/worker-api/src/worker.ts index ac8c08a0..a3193e4b 100644 --- a/packages/worker-api/src/worker.ts +++ b/packages/worker-api/src/worker.ts @@ -109,13 +109,18 @@ export class Worker extends WebSocketAsPromised implements IWorker { this.#registry = new TypeRegistry(); this.rsCount = 0; this.rqStack = [] as string[] - if (api) { - this.#registry = api.registry; - } else if (types) { + + if (types) { this.#registry.register(encointerOptions({types: options.types}).types as RegistryTypes); } else { this.#registry.register(encointerOptions().types as RegistryTypes); } + + if (api) { + // add the metadata derived types to the registry and overwrite + // existing definitions for types with the same name. + this.#registry.register(api.registry().types); + } } public encrypt(data: Uint8Array): Vec { From e244776b8d8106312bfb909b4af0f7a19ba88ca4 Mon Sep 17 00:00:00 2001 From: Christian Langenbacher Date: Thu, 11 Apr 2024 10:01:29 +0800 Subject: [PATCH 09/12] v0.12.0-alpha.5 --- lerna.json | 2 +- packages/node-api/package.json | 4 ++-- packages/types/package.json | 2 +- packages/util/package.json | 2 +- packages/worker-api/package.json | 8 ++++---- yarn.lock | 14 +++++++------- 6 files changed, 16 insertions(+), 16 deletions(-) diff --git a/lerna.json b/lerna.json index 1395bf64..f321f4d6 100644 --- a/lerna.json +++ b/lerna.json @@ -7,5 +7,5 @@ "publishConfig": { "directory": "build" }, - "version": "0.12.0-alpha.4" + "version": "0.12.0-alpha.5" } diff --git a/packages/node-api/package.json b/packages/node-api/package.json index ee67d8e3..f355945a 100644 --- a/packages/node-api/package.json +++ b/packages/node-api/package.json @@ -18,10 +18,10 @@ }, "sideEffects": false, "type": "module", - "version": "0.12.0-alpha.4", + "version": "0.12.0-alpha.5", "main": "index.js", "dependencies": { - "@encointer/types": "^0.12.0-alpha.4", + "@encointer/types": "^0.12.0-alpha.5", "@polkadot/api": "^10.9.1", "tslib": "^2.5.3" }, diff --git a/packages/types/package.json b/packages/types/package.json index df7b20e9..b821548b 100644 --- a/packages/types/package.json +++ b/packages/types/package.json @@ -18,7 +18,7 @@ }, "sideEffects": false, "type": "module", - "version": "0.12.0-alpha.4", + "version": "0.12.0-alpha.5", "main": "index.js", "scripts": { "generate:defs": "node --experimental-specifier-resolution=node --loader ts-node/esm ../../node_modules/.bin/polkadot-types-from-defs --package @encointer/types/interfaces --input ./src/interfaces", diff --git a/packages/util/package.json b/packages/util/package.json index b7b0dc37..a7d276db 100644 --- a/packages/util/package.json +++ b/packages/util/package.json @@ -20,7 +20,7 @@ "sideEffects": false, "type": "module", "types": "./index.d.ts", - "version": "0.12.0-alpha.4", + "version": "0.12.0-alpha.5", "main": "index.js", "dependencies": { "@babel/runtime": "^7.18.9", diff --git a/packages/worker-api/package.json b/packages/worker-api/package.json index 3e79415d..ed04a7a4 100644 --- a/packages/worker-api/package.json +++ b/packages/worker-api/package.json @@ -19,12 +19,12 @@ "sideEffects": false, "type": "module", "types": "./index.d.ts", - "version": "0.12.0-alpha.4", + "version": "0.12.0-alpha.5", "main": "index.js", "dependencies": { - "@encointer/node-api": "^0.12.0-alpha.4", - "@encointer/types": "^0.12.0-alpha.4", - "@encointer/util": "^0.12.0-alpha.4", + "@encointer/node-api": "^0.12.0-alpha.5", + "@encointer/types": "^0.12.0-alpha.5", + "@encointer/util": "^0.12.0-alpha.5", "@polkadot/api": "^10.9.1", "@polkadot/keyring": "^12.3.2", "@polkadot/types": "^10.9.1", diff --git a/yarn.lock b/yarn.lock index 756587a0..d21aa2ff 100644 --- a/yarn.lock +++ b/yarn.lock @@ -755,18 +755,18 @@ __metadata: languageName: node linkType: hard -"@encointer/node-api@^0.12.0-alpha.4, @encointer/node-api@workspace:packages/node-api": +"@encointer/node-api@^0.12.0-alpha.5, @encointer/node-api@workspace:packages/node-api": version: 0.0.0-use.local resolution: "@encointer/node-api@workspace:packages/node-api" dependencies: - "@encointer/types": ^0.12.0-alpha.4 + "@encointer/types": ^0.12.0-alpha.5 "@polkadot/api": ^10.9.1 "@polkadot/util-crypto": ^12.3.2 tslib: ^2.5.3 languageName: unknown linkType: soft -"@encointer/types@^0.12.0-alpha.4, @encointer/types@workspace:packages/types": +"@encointer/types@^0.12.0-alpha.5, @encointer/types@workspace:packages/types": version: 0.0.0-use.local resolution: "@encointer/types@workspace:packages/types" dependencies: @@ -781,7 +781,7 @@ __metadata: languageName: unknown linkType: soft -"@encointer/util@^0.12.0-alpha.4, @encointer/util@workspace:packages/util": +"@encointer/util@^0.12.0-alpha.5, @encointer/util@workspace:packages/util": version: 0.0.0-use.local resolution: "@encointer/util@workspace:packages/util" dependencies: @@ -798,9 +798,9 @@ __metadata: version: 0.0.0-use.local resolution: "@encointer/worker-api@workspace:packages/worker-api" dependencies: - "@encointer/node-api": ^0.12.0-alpha.4 - "@encointer/types": ^0.12.0-alpha.4 - "@encointer/util": ^0.12.0-alpha.4 + "@encointer/node-api": ^0.12.0-alpha.5 + "@encointer/types": ^0.12.0-alpha.5 + "@encointer/util": ^0.12.0-alpha.5 "@polkadot/api": ^10.9.1 "@polkadot/keyring": ^12.3.2 "@polkadot/types": ^10.9.1 From 0596e39951861f2117d612102d028e8595b38353 Mon Sep 17 00:00:00 2001 From: Christian Langenbacher Date: Thu, 11 Apr 2024 10:04:23 +0800 Subject: [PATCH 10/12] [worker] fix merging registry --- packages/worker-api/src/worker.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/worker-api/src/worker.ts b/packages/worker-api/src/worker.ts index a3193e4b..ba9d2335 100644 --- a/packages/worker-api/src/worker.ts +++ b/packages/worker-api/src/worker.ts @@ -119,7 +119,7 @@ export class Worker extends WebSocketAsPromised implements IWorker { if (api) { // add the metadata derived types to the registry and overwrite // existing definitions for types with the same name. - this.#registry.register(api.registry().types); + this.#registry.register(api.registry.types); } } From 278f389e5e0be69dd00886643bc16f00170a508e Mon Sep 17 00:00:00 2001 From: Christian Langenbacher Date: Thu, 11 Apr 2024 10:21:24 +0800 Subject: [PATCH 11/12] [worker] pass registry types into the constructor instead of the api --- packages/worker-api/src/interface.ts | 4 ++-- packages/worker-api/src/worker.ts | 9 +-------- 2 files changed, 3 insertions(+), 10 deletions(-) diff --git a/packages/worker-api/src/interface.ts b/packages/worker-api/src/interface.ts index b335fb24..fae60c6f 100644 --- a/packages/worker-api/src/interface.ts +++ b/packages/worker-api/src/interface.ts @@ -3,6 +3,7 @@ import WebSocketAsPromised from 'websocket-as-promised'; import {Keyring} from "@polkadot/keyring"; import type {u8} from "@polkadot/types-codec"; import type {TypeRegistry, Vec} from "@polkadot/types"; +import type {RegistryTypes} from "@polkadot/types/types"; export interface IWorker extends WebSocketAsPromised { rsCount: number; @@ -32,8 +33,7 @@ export function createJsonRpcRequest(method: string, params: any, id: number | s export interface WorkerOptions { keyring?: Keyring; - api: any; - types: any; + types?: RegistryTypes; createWebSocket?: (url: string) => WebSocket; } diff --git a/packages/worker-api/src/worker.ts b/packages/worker-api/src/worker.ts index ba9d2335..575d62f6 100644 --- a/packages/worker-api/src/worker.ts +++ b/packages/worker-api/src/worker.ts @@ -104,23 +104,16 @@ export class Worker extends WebSocketAsPromised implements IWorker { attachRequestId: (data: any): any => data, extractRequestId: () => this.rsCount = ++this.rsCount }); - const {api, types} = options; this.#keyring = (options.keyring || undefined); this.#registry = new TypeRegistry(); this.rsCount = 0; this.rqStack = [] as string[] - if (types) { + if (options.types != undefined) { this.#registry.register(encointerOptions({types: options.types}).types as RegistryTypes); } else { this.#registry.register(encointerOptions().types as RegistryTypes); } - - if (api) { - // add the metadata derived types to the registry and overwrite - // existing definitions for types with the same name. - this.#registry.register(api.registry.types); - } } public encrypt(data: Uint8Array): Vec { From eac95a9137592c71c44afa71cd2db322478fda83 Mon Sep 17 00:00:00 2001 From: Christian Langenbacher Date: Thu, 11 Apr 2024 10:22:13 +0800 Subject: [PATCH 12/12] v0.12.0-alpha.6 --- lerna.json | 2 +- packages/node-api/package.json | 4 ++-- packages/types/package.json | 2 +- packages/util/package.json | 2 +- packages/worker-api/package.json | 8 ++++---- yarn.lock | 14 +++++++------- 6 files changed, 16 insertions(+), 16 deletions(-) diff --git a/lerna.json b/lerna.json index f321f4d6..9b1db0a2 100644 --- a/lerna.json +++ b/lerna.json @@ -7,5 +7,5 @@ "publishConfig": { "directory": "build" }, - "version": "0.12.0-alpha.5" + "version": "0.12.0-alpha.6" } diff --git a/packages/node-api/package.json b/packages/node-api/package.json index f355945a..ffc07131 100644 --- a/packages/node-api/package.json +++ b/packages/node-api/package.json @@ -18,10 +18,10 @@ }, "sideEffects": false, "type": "module", - "version": "0.12.0-alpha.5", + "version": "0.12.0-alpha.6", "main": "index.js", "dependencies": { - "@encointer/types": "^0.12.0-alpha.5", + "@encointer/types": "^0.12.0-alpha.6", "@polkadot/api": "^10.9.1", "tslib": "^2.5.3" }, diff --git a/packages/types/package.json b/packages/types/package.json index b821548b..31ba0d72 100644 --- a/packages/types/package.json +++ b/packages/types/package.json @@ -18,7 +18,7 @@ }, "sideEffects": false, "type": "module", - "version": "0.12.0-alpha.5", + "version": "0.12.0-alpha.6", "main": "index.js", "scripts": { "generate:defs": "node --experimental-specifier-resolution=node --loader ts-node/esm ../../node_modules/.bin/polkadot-types-from-defs --package @encointer/types/interfaces --input ./src/interfaces", diff --git a/packages/util/package.json b/packages/util/package.json index a7d276db..fba87d52 100644 --- a/packages/util/package.json +++ b/packages/util/package.json @@ -20,7 +20,7 @@ "sideEffects": false, "type": "module", "types": "./index.d.ts", - "version": "0.12.0-alpha.5", + "version": "0.12.0-alpha.6", "main": "index.js", "dependencies": { "@babel/runtime": "^7.18.9", diff --git a/packages/worker-api/package.json b/packages/worker-api/package.json index ed04a7a4..874a1dd6 100644 --- a/packages/worker-api/package.json +++ b/packages/worker-api/package.json @@ -19,12 +19,12 @@ "sideEffects": false, "type": "module", "types": "./index.d.ts", - "version": "0.12.0-alpha.5", + "version": "0.12.0-alpha.6", "main": "index.js", "dependencies": { - "@encointer/node-api": "^0.12.0-alpha.5", - "@encointer/types": "^0.12.0-alpha.5", - "@encointer/util": "^0.12.0-alpha.5", + "@encointer/node-api": "^0.12.0-alpha.6", + "@encointer/types": "^0.12.0-alpha.6", + "@encointer/util": "^0.12.0-alpha.6", "@polkadot/api": "^10.9.1", "@polkadot/keyring": "^12.3.2", "@polkadot/types": "^10.9.1", diff --git a/yarn.lock b/yarn.lock index d21aa2ff..97e9b946 100644 --- a/yarn.lock +++ b/yarn.lock @@ -755,18 +755,18 @@ __metadata: languageName: node linkType: hard -"@encointer/node-api@^0.12.0-alpha.5, @encointer/node-api@workspace:packages/node-api": +"@encointer/node-api@^0.12.0-alpha.6, @encointer/node-api@workspace:packages/node-api": version: 0.0.0-use.local resolution: "@encointer/node-api@workspace:packages/node-api" dependencies: - "@encointer/types": ^0.12.0-alpha.5 + "@encointer/types": ^0.12.0-alpha.6 "@polkadot/api": ^10.9.1 "@polkadot/util-crypto": ^12.3.2 tslib: ^2.5.3 languageName: unknown linkType: soft -"@encointer/types@^0.12.0-alpha.5, @encointer/types@workspace:packages/types": +"@encointer/types@^0.12.0-alpha.6, @encointer/types@workspace:packages/types": version: 0.0.0-use.local resolution: "@encointer/types@workspace:packages/types" dependencies: @@ -781,7 +781,7 @@ __metadata: languageName: unknown linkType: soft -"@encointer/util@^0.12.0-alpha.5, @encointer/util@workspace:packages/util": +"@encointer/util@^0.12.0-alpha.6, @encointer/util@workspace:packages/util": version: 0.0.0-use.local resolution: "@encointer/util@workspace:packages/util" dependencies: @@ -798,9 +798,9 @@ __metadata: version: 0.0.0-use.local resolution: "@encointer/worker-api@workspace:packages/worker-api" dependencies: - "@encointer/node-api": ^0.12.0-alpha.5 - "@encointer/types": ^0.12.0-alpha.5 - "@encointer/util": ^0.12.0-alpha.5 + "@encointer/node-api": ^0.12.0-alpha.6 + "@encointer/types": ^0.12.0-alpha.6 + "@encointer/util": ^0.12.0-alpha.6 "@polkadot/api": ^10.9.1 "@polkadot/keyring": ^12.3.2 "@polkadot/types": ^10.9.1