From 278f389e5e0be69dd00886643bc16f00170a508e Mon Sep 17 00:00:00 2001 From: Christian Langenbacher Date: Thu, 11 Apr 2024 10:21:24 +0800 Subject: [PATCH] [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 {