@novasamatech/host-container 0.5.4-4 → 0.5.4-6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -257,11 +257,13 @@ export function createContainer(provider) {
257
257
  .unwrapOr(enumValue(version, resultErr(error)));
258
258
  });
259
259
  },
260
- handleJsonRpcMessageSubscribe(genesisHash, provider) {
260
+ handleChainConnection(factory) {
261
261
  init();
262
262
  return transport.handleSubscription('jsonrpc_message_subscribe', (params, send) => {
263
263
  assertEnumVariant(params, 'v1', UNSUPPORTED_MESSAGE_FORMAT_ERROR);
264
- if (params.value !== genesisHash) {
264
+ const genesisHash = params.value;
265
+ const provider = factory(params.value);
266
+ if (provider === null) {
265
267
  return () => {
266
268
  // empty subscription, we don't want to react to foreign chain subscription request
267
269
  };
@@ -270,10 +272,9 @@ export function createContainer(provider) {
270
272
  const unsubRequests = transport.handleRequest('jsonrpc_message_send', async (message) => {
271
273
  assertEnumVariant(message, 'v1', UNSUPPORTED_MESSAGE_FORMAT_ERROR);
272
274
  const [requestedGenesisHash, payload] = message.value;
273
- if (requestedGenesisHash !== genesisHash) {
274
- return enumValue('v1', resultOk(undefined));
275
+ if (requestedGenesisHash === genesisHash) {
276
+ connection.send(payload);
275
277
  }
276
- connection.send(payload);
277
278
  return enumValue('v1', resultOk(undefined));
278
279
  });
279
280
  return () => {
@@ -285,7 +286,7 @@ export function createContainer(provider) {
285
286
  isReady() {
286
287
  return transport.isReady();
287
288
  },
288
- subscribeConnectionStatus(callback) {
289
+ subscribeProductConnectionStatus(callback) {
289
290
  // this specific order exists because container should report all connection statuses including "disconnected",
290
291
  // which immediately got changed to "connecting" after init() call.
291
292
  const unsubscribe = transport.onConnectionStatusChange(callback);
package/dist/types.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { Codec, CodecType, ConnectionStatus, HostApiProtocol, VersionedProtocolRequest, VersionedProtocolSubscription } from '@novasamatech/host-api';
1
+ import type { Codec, CodecType, ConnectionStatus, HexString, HostApiProtocol, VersionedProtocolRequest, VersionedProtocolSubscription } from '@novasamatech/host-api';
2
2
  import type { JsonRpcProvider } from '@polkadot-api/json-rpc-provider';
3
3
  import type { ResultAsync, errAsync } from 'neverthrow';
4
4
  import { okAsync } from 'neverthrow';
@@ -70,9 +70,9 @@ export type Container = {
70
70
  handleStatementStoreSubscribe: InferHandler<'v1', HostApiProtocol['statement_store_subscribe']>;
71
71
  handleStatementStoreCreateProof: InferHandler<'v1', HostApiProtocol['statement_store_create_proof']>;
72
72
  handleStatementStoreSubmit: InferHandler<'v1', HostApiProtocol['statement_store_submit']>;
73
- handleJsonRpcMessageSubscribe: (params: WithVersion<'v1', Value<HostApiProtocol['jsonrpc_message_subscribe']['start']>>, provider: JsonRpcProvider) => VoidFunction;
73
+ handleChainConnection: (factory: (genesisHash: HexString) => JsonRpcProvider | null) => VoidFunction;
74
74
  isReady(): Promise<boolean>;
75
75
  dispose(): void;
76
- subscribeConnectionStatus(callback: (connectionStatus: ConnectionStatus) => void): VoidFunction;
76
+ subscribeProductConnectionStatus(callback: (connectionStatus: ConnectionStatus) => void): VoidFunction;
77
77
  };
78
78
  export {};
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@novasamatech/host-container",
3
3
  "type": "module",
4
- "version": "0.5.4-4",
4
+ "version": "0.5.4-6",
5
5
  "description": "Host container for hosting and managing products within the Polkadot ecosystem.",
6
6
  "license": "Apache-2.0",
7
7
  "repository": {
@@ -28,7 +28,7 @@
28
28
  "dependencies": {
29
29
  "@polkadot-api/utils": "^0.2.0",
30
30
  "@polkadot-api/json-rpc-provider": "^0.0.4",
31
- "@novasamatech/host-api": "0.5.4-4",
31
+ "@novasamatech/host-api": "0.5.4-6",
32
32
  "nanoid": "5.1.6"
33
33
  },
34
34
  "devDependencies": {