@novasamatech/host-container 0.6.7 → 0.6.9

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.
@@ -2,6 +2,22 @@ import { ChatBotRegistrationErr, ChatMessagePostingErr, ChatRoomRegistrationErr,
2
2
  import { err, errAsync, ok, okAsync } from 'neverthrow';
3
3
  import { createChainConnectionManager } from './chainConnectionManager.js';
4
4
  const UNSUPPORTED_MESSAGE_FORMAT_ERROR = 'Unsupported message format';
5
+ const NOT_IMPLEMENTED = 'Not implemented';
6
+ function makeSlot(registerDefault) {
7
+ let cleanup = registerDefault();
8
+ return (registerUser) => {
9
+ cleanup();
10
+ cleanup = registerUser();
11
+ let active = true;
12
+ return () => {
13
+ if (!active)
14
+ return;
15
+ active = false;
16
+ cleanup();
17
+ cleanup = registerDefault();
18
+ };
19
+ };
20
+ }
5
21
  function guardVersion(value, tag, error) {
6
22
  if (isEnumVariant(value, tag)) {
7
23
  return ok(value.value);
@@ -17,10 +33,133 @@ export function createContainer(provider) {
17
33
  // init status subscription
18
34
  transport.isReady();
19
35
  }
36
+ // account slots
37
+ const handleAccountGetSlot = makeSlot(() => transport.handleRequest('host_account_get', async (_params) => {
38
+ const error = new RequestCredentialsErr.Unknown({ reason: NOT_IMPLEMENTED });
39
+ return enumValue('v1', resultErr(error));
40
+ }));
41
+ const handleAccountGetAliasSlot = makeSlot(() => transport.handleRequest('host_account_get_alias', async (_params) => {
42
+ const error = new RequestCredentialsErr.Unknown({ reason: NOT_IMPLEMENTED });
43
+ return enumValue('v1', resultErr(error));
44
+ }));
45
+ const handleGetNonProductAccountsSlot = makeSlot(() => transport.handleRequest('host_get_non_product_accounts', async (_params) => {
46
+ const error = new RequestCredentialsErr.Unknown({ reason: NOT_IMPLEMENTED });
47
+ return enumValue('v1', resultErr(error));
48
+ }));
49
+ const handleAccountCreateProofSlot = makeSlot(() => transport.handleRequest('host_account_create_proof', async (_params) => {
50
+ const error = new CreateProofErr.Unknown({ reason: NOT_IMPLEMENTED });
51
+ return enumValue('v1', resultErr(error));
52
+ }));
53
+ // storage slots
54
+ const handleLocalStorageReadSlot = makeSlot(() => transport.handleRequest('host_local_storage_read', async (_params) => {
55
+ const error = new StorageErr.Unknown({ reason: NOT_IMPLEMENTED });
56
+ return enumValue('v1', resultErr(error));
57
+ }));
58
+ const handleLocalStorageWriteSlot = makeSlot(() => transport.handleRequest('host_local_storage_write', async (_params) => {
59
+ const error = new StorageErr.Unknown({ reason: NOT_IMPLEMENTED });
60
+ return enumValue('v1', resultErr(error));
61
+ }));
62
+ const handleLocalStorageClearSlot = makeSlot(() => transport.handleRequest('host_local_storage_clear', async (_params) => {
63
+ const error = new StorageErr.Unknown({ reason: NOT_IMPLEMENTED });
64
+ return enumValue('v1', resultErr(error));
65
+ }));
66
+ // signing slots
67
+ const handleSignRawSlot = makeSlot(() => transport.handleRequest('host_sign_raw', async (_params) => {
68
+ const error = new SigningErr.Unknown({ reason: NOT_IMPLEMENTED });
69
+ return enumValue('v1', resultErr(error));
70
+ }));
71
+ const handleSignPayloadSlot = makeSlot(() => transport.handleRequest('host_sign_payload', async (_params) => {
72
+ const error = new SigningErr.Unknown({ reason: NOT_IMPLEMENTED });
73
+ return enumValue('v1', resultErr(error));
74
+ }));
75
+ const handleCreateTransactionSlot = makeSlot(() => transport.handleRequest('host_create_transaction', async (_params) => {
76
+ const error = new CreateTransactionErr.Unknown({ reason: NOT_IMPLEMENTED });
77
+ return enumValue('v1', resultErr(error));
78
+ }));
79
+ const handleCreateTransactionWithNonProductAccountSlot = makeSlot(() => transport.handleRequest('host_create_transaction_with_non_product_account', async (_params) => {
80
+ const error = new CreateTransactionErr.Unknown({ reason: NOT_IMPLEMENTED });
81
+ return enumValue('v1', resultErr(error));
82
+ }));
83
+ const handleFeatureSupportedSlot = makeSlot(() => transport.handleRequest('host_feature_supported', async (_params) => {
84
+ const error = new GenericError({ reason: NOT_IMPLEMENTED });
85
+ return enumValue('v1', resultErr(error));
86
+ }));
87
+ const handleDevicePermissionSlot = makeSlot(() => transport.handleRequest('host_device_permission', async (_params) => {
88
+ const error = new GenericError({ reason: NOT_IMPLEMENTED });
89
+ return enumValue('v1', resultErr(error));
90
+ }));
91
+ const handlePermissionSlot = makeSlot(() => transport.handleRequest('remote_permission', async (_params) => {
92
+ const error = new GenericError({ reason: NOT_IMPLEMENTED });
93
+ return enumValue('v1', resultErr(error));
94
+ }));
95
+ const handlePushNotificationSlot = makeSlot(() => transport.handleRequest('host_push_notification', async (_params) => {
96
+ const error = new GenericError({ reason: NOT_IMPLEMENTED });
97
+ return enumValue('v1', resultErr(error));
98
+ }));
99
+ const handleNavigateToSlot = makeSlot(() => transport.handleRequest('host_navigate_to', async (_params) => {
100
+ const error = new NavigateToErr.Unknown({ reason: NOT_IMPLEMENTED });
101
+ return enumValue('v1', resultErr(error));
102
+ }));
103
+ const handleChatCreateRoomSlot = makeSlot(() => transport.handleRequest('host_chat_create_room', async (_params) => {
104
+ const error = new ChatRoomRegistrationErr.Unknown({ reason: NOT_IMPLEMENTED });
105
+ return enumValue('v1', resultErr(error));
106
+ }));
107
+ const handleChatBotRegistrationSlot = makeSlot(() => transport.handleRequest('host_chat_register_bot', async (_params) => {
108
+ const error = new ChatBotRegistrationErr.Unknown({ reason: NOT_IMPLEMENTED });
109
+ return enumValue('v1', resultErr(error));
110
+ }));
111
+ const handleChatPostMessageSlot = makeSlot(() => transport.handleRequest('host_chat_post_message', async (_params) => {
112
+ const error = new ChatMessagePostingErr.Unknown({ reason: NOT_IMPLEMENTED });
113
+ return enumValue('v1', resultErr(error));
114
+ }));
115
+ const handleStatementStoreSubmitSlot = makeSlot(() => transport.handleRequest('remote_statement_store_submit', async (_params) => {
116
+ const error = new GenericError({ reason: NOT_IMPLEMENTED });
117
+ return enumValue('v1', resultErr(error));
118
+ }));
119
+ const handleStatementStoreCreateProofSlot = makeSlot(() => transport.handleRequest('remote_statement_store_create_proof', async (_params) => {
120
+ const error = new StatementProofErr.Unknown({ reason: NOT_IMPLEMENTED });
121
+ return enumValue('v1', resultErr(error));
122
+ }));
123
+ const handlePreimageSubmitSlot = makeSlot(() => transport.handleRequest('remote_preimage_submit', async (_params) => {
124
+ const error = new PreimageSubmitErr.Unknown({ reason: NOT_IMPLEMENTED });
125
+ return enumValue('v1', resultErr(error));
126
+ }));
127
+ // subscription slots — default interrupts on next microtask so that
128
+ // the caller has a chance to register an onInterrupt listener first
129
+ const handleAccountConnectionStatusSubscribeSlot = makeSlot(() => transport.handleSubscription('host_account_connection_status_subscribe', (_params, _send, interrupt) => {
130
+ queueMicrotask(interrupt);
131
+ return () => {
132
+ /* nothing to clean up */
133
+ };
134
+ }));
135
+ const handleChatListSubscribeSlot = makeSlot(() => transport.handleSubscription('host_chat_list_subscribe', (_params, _send, interrupt) => {
136
+ queueMicrotask(interrupt);
137
+ return () => {
138
+ /* nothing to clean up */
139
+ };
140
+ }));
141
+ const handleChatActionSubscribeSlot = makeSlot(() => transport.handleSubscription('host_chat_action_subscribe', (_params, _send, interrupt) => {
142
+ queueMicrotask(interrupt);
143
+ return () => {
144
+ /* nothing to clean up */
145
+ };
146
+ }));
147
+ const handleStatementStoreSubscribeSlot = makeSlot(() => transport.handleSubscription('remote_statement_store_subscribe', (_params, _send, interrupt) => {
148
+ queueMicrotask(interrupt);
149
+ return () => {
150
+ /* nothing to clean up */
151
+ };
152
+ }));
153
+ const handlePreimageLookupSubscribeSlot = makeSlot(() => transport.handleSubscription('remote_preimage_lookup_subscribe', (_params, _send, interrupt) => {
154
+ queueMicrotask(interrupt);
155
+ return () => {
156
+ /* nothing to clean up */
157
+ };
158
+ }));
20
159
  return {
21
160
  handleFeatureSupported(handler) {
22
161
  init();
23
- return transport.handleRequest('host_feature_supported', async (message) => {
162
+ return handleFeatureSupportedSlot(() => transport.handleRequest('host_feature_supported', async (message) => {
24
163
  const version = 'v1';
25
164
  const error = new GenericError({ reason: UNSUPPORTED_MESSAGE_FORMAT_ERROR });
26
165
  return guardVersion(message, version, error)
@@ -28,11 +167,11 @@ export function createContainer(provider) {
28
167
  .andThen(r => r.map(r => enumValue(version, resultOk(r))))
29
168
  .orElse(r => ok(enumValue(version, resultErr(r))))
30
169
  .unwrapOr(enumValue(version, resultErr(error)));
31
- });
170
+ }));
32
171
  },
33
172
  handleDevicePermission(handler) {
34
173
  init();
35
- return transport.handleRequest('host_device_permission', async (message) => {
174
+ return handleDevicePermissionSlot(() => transport.handleRequest('host_device_permission', async (message) => {
36
175
  const version = 'v1';
37
176
  const error = new GenericError({ reason: UNSUPPORTED_MESSAGE_FORMAT_ERROR });
38
177
  return guardVersion(message, version, error)
@@ -40,11 +179,11 @@ export function createContainer(provider) {
40
179
  .andThen(r => r.map(r => enumValue(version, resultOk(r))))
41
180
  .orElse(r => ok(enumValue(version, resultErr(r))))
42
181
  .unwrapOr(enumValue(version, resultErr(error)));
43
- });
182
+ }));
44
183
  },
45
184
  handlePermission(handler) {
46
185
  init();
47
- return transport.handleRequest('remote_permission', async (message) => {
186
+ return handlePermissionSlot(() => transport.handleRequest('remote_permission', async (message) => {
48
187
  const version = 'v1';
49
188
  const error = new GenericError({ reason: UNSUPPORTED_MESSAGE_FORMAT_ERROR });
50
189
  return guardVersion(message, version, error)
@@ -52,11 +191,11 @@ export function createContainer(provider) {
52
191
  .andThen(r => r.map(r => enumValue(version, resultOk(r))))
53
192
  .orElse(r => ok(enumValue(version, resultErr(r))))
54
193
  .unwrapOr(enumValue(version, resultErr(error)));
55
- });
194
+ }));
56
195
  },
57
196
  handlePushNotification(handler) {
58
197
  init();
59
- return transport.handleRequest('host_push_notification', async (message) => {
198
+ return handlePushNotificationSlot(() => transport.handleRequest('host_push_notification', async (message) => {
60
199
  const version = 'v1';
61
200
  const error = new GenericError({ reason: UNSUPPORTED_MESSAGE_FORMAT_ERROR });
62
201
  return guardVersion(message, version, error)
@@ -64,11 +203,11 @@ export function createContainer(provider) {
64
203
  .andThen(r => r.map(r => enumValue(version, resultOk(r))))
65
204
  .orElse(r => ok(enumValue(version, resultErr(r))))
66
205
  .unwrapOr(enumValue(version, resultErr(error)));
67
- });
206
+ }));
68
207
  },
69
208
  handleNavigateTo(handler) {
70
209
  init();
71
- return transport.handleRequest('host_navigate_to', async (message) => {
210
+ return handleNavigateToSlot(() => transport.handleRequest('host_navigate_to', async (message) => {
72
211
  const version = 'v1';
73
212
  const error = new NavigateToErr.Unknown({ reason: UNSUPPORTED_MESSAGE_FORMAT_ERROR });
74
213
  return guardVersion(message, version, error)
@@ -76,11 +215,11 @@ export function createContainer(provider) {
76
215
  .andThen(r => r.map(r => enumValue(version, resultOk(r))))
77
216
  .orElse(r => ok(enumValue(version, resultErr(r))))
78
217
  .unwrapOr(enumValue(version, resultErr(error)));
79
- });
218
+ }));
80
219
  },
81
220
  handleLocalStorageRead(handler) {
82
221
  init();
83
- return transport.handleRequest('host_local_storage_read', async (message) => {
222
+ return handleLocalStorageReadSlot(() => transport.handleRequest('host_local_storage_read', async (message) => {
84
223
  const version = 'v1';
85
224
  const error = new StorageErr.Unknown({ reason: UNSUPPORTED_MESSAGE_FORMAT_ERROR });
86
225
  return guardVersion(message, version, error)
@@ -88,11 +227,11 @@ export function createContainer(provider) {
88
227
  .andThen(r => r.map(r => enumValue(version, resultOk(r))))
89
228
  .orElse(r => ok(enumValue(version, resultErr(r))))
90
229
  .unwrapOr(enumValue(version, resultErr(error)));
91
- });
230
+ }));
92
231
  },
93
232
  handleLocalStorageWrite(handler) {
94
233
  init();
95
- return transport.handleRequest('host_local_storage_write', async (message) => {
234
+ return handleLocalStorageWriteSlot(() => transport.handleRequest('host_local_storage_write', async (message) => {
96
235
  const version = 'v1';
97
236
  const error = new StorageErr.Unknown({ reason: UNSUPPORTED_MESSAGE_FORMAT_ERROR });
98
237
  return guardVersion(message, version, error)
@@ -100,11 +239,11 @@ export function createContainer(provider) {
100
239
  .andThen(r => r.map(r => enumValue(version, resultOk(r))))
101
240
  .orElse(r => ok(enumValue(version, resultErr(r))))
102
241
  .unwrapOr(enumValue(version, resultErr(error)));
103
- });
242
+ }));
104
243
  },
105
244
  handleLocalStorageClear(handler) {
106
245
  init();
107
- return transport.handleRequest('host_local_storage_clear', async (message) => {
246
+ return handleLocalStorageClearSlot(() => transport.handleRequest('host_local_storage_clear', async (message) => {
108
247
  const version = 'v1';
109
248
  const error = new StorageErr.Unknown({ reason: UNSUPPORTED_MESSAGE_FORMAT_ERROR });
110
249
  return guardVersion(message, version, error)
@@ -112,11 +251,11 @@ export function createContainer(provider) {
112
251
  .andThen(r => r.map(r => enumValue(version, resultOk(r))))
113
252
  .orElse(r => ok(enumValue(version, resultErr(r))))
114
253
  .unwrapOr(enumValue(version, resultErr(error)));
115
- });
254
+ }));
116
255
  },
117
256
  handleAccountConnectionStatusSubscribe(handler) {
118
257
  init();
119
- return transport.handleSubscription('host_account_connection_status_subscribe', (params, send, interrupt) => {
258
+ return handleAccountConnectionStatusSubscribeSlot(() => transport.handleSubscription('host_account_connection_status_subscribe', (params, send, interrupt) => {
120
259
  const version = 'v1';
121
260
  return guardVersion(params, version, null)
122
261
  .map(params => handler(params, payload => send(enumValue(version, payload)), interrupt))
@@ -124,11 +263,11 @@ export function createContainer(provider) {
124
263
  .unwrapOr(() => {
125
264
  /* empty */
126
265
  });
127
- });
266
+ }));
128
267
  },
129
268
  handleAccountGet(handler) {
130
269
  init();
131
- return transport.handleRequest('host_account_get', async (params) => {
270
+ return handleAccountGetSlot(() => transport.handleRequest('host_account_get', async (params) => {
132
271
  const version = 'v1';
133
272
  const error = new RequestCredentialsErr.Unknown({ reason: UNSUPPORTED_MESSAGE_FORMAT_ERROR });
134
273
  return guardVersion(params, version, error)
@@ -136,11 +275,11 @@ export function createContainer(provider) {
136
275
  .andThen(r => r.map(r => enumValue(version, resultOk(r))))
137
276
  .orElse(r => ok(enumValue(version, resultErr(r))))
138
277
  .unwrapOr(enumValue(version, resultErr(error)));
139
- });
278
+ }));
140
279
  },
141
280
  handleAccountGetAlias(handler) {
142
281
  init();
143
- return transport.handleRequest('host_account_get_alias', async (params) => {
282
+ return handleAccountGetAliasSlot(() => transport.handleRequest('host_account_get_alias', async (params) => {
144
283
  const version = 'v1';
145
284
  const error = new RequestCredentialsErr.Unknown({ reason: UNSUPPORTED_MESSAGE_FORMAT_ERROR });
146
285
  return guardVersion(params, version, error)
@@ -148,11 +287,11 @@ export function createContainer(provider) {
148
287
  .andThen(r => r.map(r => enumValue(version, resultOk(r))))
149
288
  .orElse(r => ok(enumValue(version, resultErr(r))))
150
289
  .unwrapOr(enumValue(version, resultErr(error)));
151
- });
290
+ }));
152
291
  },
153
292
  handleAccountCreateProof(handler) {
154
293
  init();
155
- return transport.handleRequest('host_account_create_proof', async (params) => {
294
+ return handleAccountCreateProofSlot(() => transport.handleRequest('host_account_create_proof', async (params) => {
156
295
  const version = 'v1';
157
296
  const error = new CreateProofErr.Unknown({ reason: UNSUPPORTED_MESSAGE_FORMAT_ERROR });
158
297
  return guardVersion(params, version, error)
@@ -160,11 +299,11 @@ export function createContainer(provider) {
160
299
  .andThen(r => r.map(r => enumValue(version, resultOk(r))))
161
300
  .orElse(r => ok(enumValue(version, resultErr(r))))
162
301
  .unwrapOr(enumValue(version, resultErr(error)));
163
- });
302
+ }));
164
303
  },
165
304
  handleGetNonProductAccounts(handler) {
166
305
  init();
167
- return transport.handleRequest('host_get_non_product_accounts', async (params) => {
306
+ return handleGetNonProductAccountsSlot(() => transport.handleRequest('host_get_non_product_accounts', async (params) => {
168
307
  const version = 'v1';
169
308
  const error = new RequestCredentialsErr.Unknown({ reason: UNSUPPORTED_MESSAGE_FORMAT_ERROR });
170
309
  return guardVersion(params, version, error)
@@ -172,11 +311,11 @@ export function createContainer(provider) {
172
311
  .andThen(r => r.map(r => enumValue(version, resultOk(r))))
173
312
  .orElse(r => ok(enumValue(version, resultErr(r))))
174
313
  .unwrapOr(enumValue(version, resultErr(error)));
175
- });
314
+ }));
176
315
  },
177
316
  handleCreateTransaction(handler) {
178
317
  init();
179
- return transport.handleRequest('host_create_transaction', async (params) => {
318
+ return handleCreateTransactionSlot(() => transport.handleRequest('host_create_transaction', async (params) => {
180
319
  const version = 'v1';
181
320
  const error = new CreateTransactionErr.Unknown({ reason: UNSUPPORTED_MESSAGE_FORMAT_ERROR });
182
321
  return guardVersion(params, version, error)
@@ -184,11 +323,11 @@ export function createContainer(provider) {
184
323
  .andThen(r => r.map(r => enumValue(version, resultOk(r))))
185
324
  .orElse(r => ok(enumValue(version, resultErr(r))))
186
325
  .unwrapOr(enumValue(version, resultErr(error)));
187
- });
326
+ }));
188
327
  },
189
328
  handleCreateTransactionWithNonProductAccount(handler) {
190
329
  init();
191
- return transport.handleRequest('host_create_transaction_with_non_product_account', async (params) => {
330
+ return handleCreateTransactionWithNonProductAccountSlot(() => transport.handleRequest('host_create_transaction_with_non_product_account', async (params) => {
192
331
  const version = 'v1';
193
332
  const error = new CreateTransactionErr.Unknown({ reason: UNSUPPORTED_MESSAGE_FORMAT_ERROR });
194
333
  return guardVersion(params, version, error)
@@ -196,11 +335,11 @@ export function createContainer(provider) {
196
335
  .andThen(r => r.map(r => enumValue(version, resultOk(r))))
197
336
  .orElse(r => ok(enumValue(version, resultErr(r))))
198
337
  .unwrapOr(enumValue(version, resultErr(error)));
199
- });
338
+ }));
200
339
  },
201
340
  handleSignRaw(handler) {
202
341
  init();
203
- return transport.handleRequest('host_sign_raw', async (params) => {
342
+ return handleSignRawSlot(() => transport.handleRequest('host_sign_raw', async (params) => {
204
343
  const version = 'v1';
205
344
  const error = new SigningErr.Unknown({ reason: UNSUPPORTED_MESSAGE_FORMAT_ERROR });
206
345
  return guardVersion(params, version, error)
@@ -208,11 +347,11 @@ export function createContainer(provider) {
208
347
  .andThen(r => r.map(r => enumValue(version, resultOk(r))))
209
348
  .orElse(r => ok(enumValue(version, resultErr(r))))
210
349
  .unwrapOr(enumValue(version, resultErr(error)));
211
- });
350
+ }));
212
351
  },
213
352
  handleSignPayload(handler) {
214
353
  init();
215
- return transport.handleRequest('host_sign_payload', async (params) => {
354
+ return handleSignPayloadSlot(() => transport.handleRequest('host_sign_payload', async (params) => {
216
355
  const version = 'v1';
217
356
  const error = new SigningErr.Unknown({ reason: UNSUPPORTED_MESSAGE_FORMAT_ERROR });
218
357
  return guardVersion(params, version, error)
@@ -220,11 +359,11 @@ export function createContainer(provider) {
220
359
  .andThen(r => r.map(r => enumValue(version, resultOk(r))))
221
360
  .orElse(r => ok(enumValue(version, resultErr(r))))
222
361
  .unwrapOr(enumValue(version, resultErr(error)));
223
- });
362
+ }));
224
363
  },
225
364
  handleChatCreateRoom(handler) {
226
365
  init();
227
- return transport.handleRequest('host_chat_create_room', async (params) => {
366
+ return handleChatCreateRoomSlot(() => transport.handleRequest('host_chat_create_room', async (params) => {
228
367
  const version = 'v1';
229
368
  const error = new ChatRoomRegistrationErr.Unknown({ reason: UNSUPPORTED_MESSAGE_FORMAT_ERROR });
230
369
  return guardVersion(params, version, error)
@@ -232,11 +371,11 @@ export function createContainer(provider) {
232
371
  .andThen(r => r.map(r => enumValue(version, resultOk(r))))
233
372
  .orElse(r => ok(enumValue(version, resultErr(r))))
234
373
  .unwrapOr(enumValue(version, resultErr(error)));
235
- });
374
+ }));
236
375
  },
237
376
  handleChatBotRegistration(handler) {
238
377
  init();
239
- return transport.handleRequest('host_chat_register_bot', async (params) => {
378
+ return handleChatBotRegistrationSlot(() => transport.handleRequest('host_chat_register_bot', async (params) => {
240
379
  const version = 'v1';
241
380
  const error = new ChatBotRegistrationErr.Unknown({ reason: UNSUPPORTED_MESSAGE_FORMAT_ERROR });
242
381
  return guardVersion(params, version, error)
@@ -244,11 +383,11 @@ export function createContainer(provider) {
244
383
  .andThen(r => r.map(r => enumValue(version, resultOk(r))))
245
384
  .orElse(r => ok(enumValue(version, resultErr(r))))
246
385
  .unwrapOr(enumValue(version, resultErr(error)));
247
- });
386
+ }));
248
387
  },
249
388
  handleChatListSubscribe(handler) {
250
389
  init();
251
- return transport.handleSubscription('host_chat_list_subscribe', (params, send, interrupt) => {
390
+ return handleChatListSubscribeSlot(() => transport.handleSubscription('host_chat_list_subscribe', (params, send, interrupt) => {
252
391
  const version = 'v1';
253
392
  return guardVersion(params, version, null)
254
393
  .map(params => handler(params, payload => send(enumValue(version, payload)), interrupt))
@@ -256,11 +395,11 @@ export function createContainer(provider) {
256
395
  .unwrapOr(() => {
257
396
  /* empty */
258
397
  });
259
- });
398
+ }));
260
399
  },
261
400
  handleChatPostMessage(handler) {
262
401
  init();
263
- return transport.handleRequest('host_chat_post_message', async (params) => {
402
+ return handleChatPostMessageSlot(() => transport.handleRequest('host_chat_post_message', async (params) => {
264
403
  const version = 'v1';
265
404
  const error = new ChatMessagePostingErr.Unknown({ reason: UNSUPPORTED_MESSAGE_FORMAT_ERROR });
266
405
  return guardVersion(params, version, error)
@@ -268,11 +407,11 @@ export function createContainer(provider) {
268
407
  .andThen(r => r.map(r => enumValue(version, resultOk(r))))
269
408
  .orElse(r => ok(enumValue(version, resultErr(r))))
270
409
  .unwrapOr(enumValue(version, resultErr(error)));
271
- });
410
+ }));
272
411
  },
273
412
  handleChatActionSubscribe(handler) {
274
413
  init();
275
- return transport.handleSubscription('host_chat_action_subscribe', (params, send, interrupt) => {
414
+ return handleChatActionSubscribeSlot(() => transport.handleSubscription('host_chat_action_subscribe', (params, send, interrupt) => {
276
415
  const version = 'v1';
277
416
  return guardVersion(params, version, null)
278
417
  .map(params => handler(params, payload => send(enumValue(version, payload)), interrupt))
@@ -280,7 +419,7 @@ export function createContainer(provider) {
280
419
  .unwrapOr(() => {
281
420
  /* empty */
282
421
  });
283
- });
422
+ }));
284
423
  },
285
424
  renderChatCustomMessage({ messageId, messageType, payload }, callback) {
286
425
  init();
@@ -292,7 +431,7 @@ export function createContainer(provider) {
292
431
  },
293
432
  handleStatementStoreSubscribe(handler) {
294
433
  init();
295
- return transport.handleSubscription('remote_statement_store_subscribe', (params, send, interrupt) => {
434
+ return handleStatementStoreSubscribeSlot(() => transport.handleSubscription('remote_statement_store_subscribe', (params, send, interrupt) => {
296
435
  const version = 'v1';
297
436
  return guardVersion(params, version, null)
298
437
  .map(params => handler(params, payload => send(enumValue(version, payload)), interrupt))
@@ -300,11 +439,11 @@ export function createContainer(provider) {
300
439
  .unwrapOr(() => {
301
440
  /* empty */
302
441
  });
303
- });
442
+ }));
304
443
  },
305
444
  handleStatementStoreCreateProof(handler) {
306
445
  init();
307
- return transport.handleRequest('remote_statement_store_create_proof', async (params) => {
446
+ return handleStatementStoreCreateProofSlot(() => transport.handleRequest('remote_statement_store_create_proof', async (params) => {
308
447
  const version = 'v1';
309
448
  const error = new StatementProofErr.Unknown({ reason: UNSUPPORTED_MESSAGE_FORMAT_ERROR });
310
449
  return guardVersion(params, version, error)
@@ -312,11 +451,11 @@ export function createContainer(provider) {
312
451
  .andThen(r => r.map(r => enumValue(version, resultOk(r))))
313
452
  .orElse(r => ok(enumValue(version, resultErr(r))))
314
453
  .unwrapOr(enumValue(version, resultErr(error)));
315
- });
454
+ }));
316
455
  },
317
456
  handleStatementStoreSubmit(handler) {
318
457
  init();
319
- return transport.handleRequest('remote_statement_store_submit', async (params) => {
458
+ return handleStatementStoreSubmitSlot(() => transport.handleRequest('remote_statement_store_submit', async (params) => {
320
459
  const version = 'v1';
321
460
  const error = new GenericError({ reason: UNSUPPORTED_MESSAGE_FORMAT_ERROR });
322
461
  return guardVersion(params, version, error)
@@ -324,11 +463,11 @@ export function createContainer(provider) {
324
463
  .andThen(r => r.map(r => enumValue(version, resultOk(r))))
325
464
  .orElse(r => ok(enumValue(version, resultErr(r))))
326
465
  .unwrapOr(enumValue(version, resultErr(error)));
327
- });
466
+ }));
328
467
  },
329
468
  handlePreimageLookupSubscribe(handler) {
330
469
  init();
331
- return transport.handleSubscription('remote_preimage_lookup_subscribe', (params, send, interrupt) => {
470
+ return handlePreimageLookupSubscribeSlot(() => transport.handleSubscription('remote_preimage_lookup_subscribe', (params, send, interrupt) => {
332
471
  const version = 'v1';
333
472
  return guardVersion(params, version, null)
334
473
  .map(params => handler(params, payload => send(enumValue(version, payload)), interrupt))
@@ -336,11 +475,11 @@ export function createContainer(provider) {
336
475
  .unwrapOr(() => {
337
476
  /* empty */
338
477
  });
339
- });
478
+ }));
340
479
  },
341
480
  handlePreimageSubmit(handler) {
342
481
  init();
343
- return transport.handleRequest('remote_preimage_submit', async (params) => {
482
+ return handlePreimageSubmitSlot(() => transport.handleRequest('remote_preimage_submit', async (params) => {
344
483
  const version = 'v1';
345
484
  const error = new PreimageSubmitErr.Unknown({ reason: UNSUPPORTED_MESSAGE_FORMAT_ERROR });
346
485
  return guardVersion(params, version, error)
@@ -348,7 +487,7 @@ export function createContainer(provider) {
348
487
  .andThen(r => r.map(r => enumValue(version, resultOk(r))))
349
488
  .orElse(r => ok(enumValue(version, resultErr(r))))
350
489
  .unwrapOr(enumValue(version, resultErr(error)));
351
- });
490
+ }));
352
491
  },
353
492
  // chain interaction
354
493
  handleChainConnection(factory) {
@@ -86,6 +86,7 @@ export function createWebviewProvider({ webview, logger, openDevTools }) {
86
86
  subscribers.clear();
87
87
  if (port) {
88
88
  port.removeEventListener('message', messageHandler);
89
+ port.close();
89
90
  }
90
91
  port = null;
91
92
  },
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@novasamatech/host-container",
3
3
  "type": "module",
4
- "version": "0.6.7",
4
+ "version": "0.6.9",
5
5
  "description": "Host container for hosting and managing products within the Polkadot ecosystem.",
6
6
  "license": "Apache-2.0",
7
7
  "repository": {
@@ -27,7 +27,7 @@
27
27
  "dependencies": {
28
28
  "@polkadot-api/utils": "^0.2.0",
29
29
  "@polkadot-api/json-rpc-provider": "^0.0.4",
30
- "@novasamatech/host-api": "0.6.7",
30
+ "@novasamatech/host-api": "0.6.9",
31
31
  "nanoid": "5.1.7"
32
32
  },
33
33
  "devDependencies": {