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