@novasamatech/host-api 0.9.3 → 0.10.0
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/hostApi.js +87 -3
- package/dist/index.d.ts +5 -1
- package/dist/index.js +4 -1
- package/dist/protocol/callError.d.ts +63 -0
- package/dist/protocol/callError.js +57 -0
- package/dist/protocol/impl.d.ts +349 -54
- package/dist/protocol/impl.js +70 -10
- package/dist/protocol/messageCodec.d.ts +820 -109
- package/dist/protocol/v1/accounts.d.ts +10 -10
- package/dist/protocol/v1/accounts.js +12 -11
- package/dist/protocol/v1/chainInteraction.d.ts +44 -12
- package/dist/protocol/v1/chainInteraction.js +25 -15
- package/dist/protocol/v1/chat.d.ts +3 -3
- package/dist/protocol/v1/chat.js +5 -4
- package/dist/protocol/v1/coinPayment.d.ts +345 -0
- package/dist/protocol/v1/coinPayment.js +105 -0
- package/dist/protocol/v1/createTransaction.d.ts +9 -9
- package/dist/protocol/v1/createTransaction.js +4 -3
- package/dist/protocol/v1/deriveEntropy.d.ts +1 -1
- package/dist/protocol/v1/deriveEntropy.js +2 -2
- package/dist/protocol/v1/devicePermission.d.ts +1 -1
- package/dist/protocol/v1/devicePermission.js +3 -2
- package/dist/protocol/v1/feature.d.ts +1 -1
- package/dist/protocol/v1/feature.js +3 -2
- package/dist/protocol/v1/handshake.d.ts +1 -1
- package/dist/protocol/v1/handshake.js +3 -2
- package/dist/protocol/v1/localStorage.d.ts +10 -3
- package/dist/protocol/v1/localStorage.js +10 -4
- package/dist/protocol/v1/navigation.d.ts +1 -1
- package/dist/protocol/v1/navigation.js +3 -2
- package/dist/protocol/v1/notification.d.ts +2 -2
- package/dist/protocol/v1/notification.js +4 -3
- package/dist/protocol/v1/payments.d.ts +8 -8
- package/dist/protocol/v1/payments.js +4 -3
- package/dist/protocol/v1/preimage.d.ts +1 -1
- package/dist/protocol/v1/preimage.js +3 -2
- package/dist/protocol/v1/remotePermission.d.ts +1 -1
- package/dist/protocol/v1/remotePermission.js +3 -2
- package/dist/protocol/v1/resourceAllocation.d.ts +1 -1
- package/dist/protocol/v1/resourceAllocation.js +3 -2
- package/dist/protocol/v1/sign.d.ts +4 -4
- package/dist/protocol/v1/sign.js +6 -5
- package/dist/protocol/v1/statementStore.d.ts +3 -3
- package/dist/protocol/v1/statementStore.js +5 -4
- package/dist/protocol/v1/worker.d.ts +37 -0
- package/dist/protocol/v1/worker.js +20 -0
- package/dist/transport.js +16 -2
- package/dist/transport.spec.js +18 -0
- package/package.json +2 -2
package/dist/protocol/impl.js
CHANGED
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
import { Enum } from '@novasamatech/scale';
|
|
2
|
+
import { _void } from 'scale-ts';
|
|
3
|
+
import { interruptError } from './callError.js';
|
|
2
4
|
import { AccountConnectionStatusV1_interrupt, AccountConnectionStatusV1_receive, AccountConnectionStatusV1_start, AccountCreateProofV1_request, AccountCreateProofV1_response, AccountGetAliasV1_request, AccountGetAliasV1_response, AccountGetV1_request, AccountGetV1_response, AccountListRingVrfKeysV1_request, AccountListRingVrfKeysV1_response, AccountRegisterRingVrfKeyV1_request, AccountRegisterRingVrfKeyV1_response, AccountRingVrfSignV1_request, AccountRingVrfSignV1_response, AccountSignVrfV1_request, AccountSignVrfV1_response, GetLegacyAccountsV1_request, GetLegacyAccountsV1_response, GetUserIdV1_request, GetUserIdV1_response, RequestLoginV1_request, RequestLoginV1_response, } from './v1/accounts.js';
|
|
3
|
-
import { ChainHeadBodyV1_request, ChainHeadBodyV1_response, ChainHeadCallV1_request, ChainHeadCallV1_response, ChainHeadContinueV1_request, ChainHeadContinueV1_response, ChainHeadFollowV1_interrupt, ChainHeadFollowV1_receive, ChainHeadFollowV1_start, ChainHeadHeaderV1_request, ChainHeadHeaderV1_response, ChainHeadStopOperationV1_request, ChainHeadStopOperationV1_response, ChainHeadStorageV1_request, ChainHeadStorageV1_response, ChainHeadUnpinV1_request, ChainHeadUnpinV1_response, ChainSpecChainNameV1_request, ChainSpecChainNameV1_response, ChainSpecGenesisHashV1_request, ChainSpecGenesisHashV1_response, ChainSpecPropertiesV1_request, ChainSpecPropertiesV1_response, TransactionBroadcastV1_request, TransactionBroadcastV1_response, TransactionStopV1_request, TransactionStopV1_response, } from './v1/chainInteraction.js';
|
|
5
|
+
import { ChainHeadBodyV1_request, ChainHeadBodyV1_response, ChainHeadCallV1_request, ChainHeadCallV1_response, ChainHeadContinueV1_request, ChainHeadContinueV1_response, ChainHeadFollowV1_interrupt, ChainHeadFollowV1_receive, ChainHeadFollowV1_start, ChainHeadHeaderV1_request, ChainHeadHeaderV1_response, ChainHeadStopOperationV1_request, ChainHeadStopOperationV1_response, ChainHeadStorageV1_request, ChainHeadStorageV1_response, ChainHeadUnpinV1_request, ChainHeadUnpinV1_response, ChainInfoV1_request, ChainInfoV1_response, ChainSpecChainNameV1_request, ChainSpecChainNameV1_response, ChainSpecGenesisHashV1_request, ChainSpecGenesisHashV1_response, ChainSpecPropertiesV1_request, ChainSpecPropertiesV1_response, TransactionBroadcastV1_request, TransactionBroadcastV1_response, TransactionStopV1_request, TransactionStopV1_response, } from './v1/chainInteraction.js';
|
|
4
6
|
import { ChatActionSubscribeV1_interrupt, ChatActionSubscribeV1_receive, ChatActionSubscribeV1_start, ChatCreateRoomV1_request, ChatCreateRoomV1_response, ChatCustomMessageRenderingV1_interrupt, ChatCustomMessageRenderingV1_receive, ChatCustomMessageRenderingV1_start, ChatListSubscribeV1_interrupt, ChatListSubscribeV1_receive, ChatListSubscribeV1_start, ChatPostMessageV1_request, ChatPostMessageV1_response, ChatRegisterBotV1_request, ChatRegisterBotV1_response, } from './v1/chat.js';
|
|
7
|
+
import { CoinPaymentCreateChequeV1_request, CoinPaymentCreateChequeV1_response, CoinPaymentCreatePurseV1_request, CoinPaymentCreatePurseV1_response, CoinPaymentCreateReceivableV1_request, CoinPaymentCreateReceivableV1_response, CoinPaymentDeletePurseV1_interrupt, CoinPaymentDeletePurseV1_receive, CoinPaymentDeletePurseV1_start, CoinPaymentDepositV1_interrupt, CoinPaymentDepositV1_receive, CoinPaymentDepositV1_start, CoinPaymentListenForPaymentV1_interrupt, CoinPaymentListenForPaymentV1_receive, CoinPaymentListenForPaymentV1_start, CoinPaymentQueryPurseV1_request, CoinPaymentQueryPurseV1_response, CoinPaymentRebalancePurseV1_interrupt, CoinPaymentRebalancePurseV1_receive, CoinPaymentRebalancePurseV1_start, CoinPaymentRefundV1_interrupt, CoinPaymentRefundV1_receive, CoinPaymentRefundV1_start, } from './v1/coinPayment.js';
|
|
5
8
|
import { CreateTransactionV1_request, CreateTransactionV1_response, CreateTransactionWithLegacyAccountV1_request, CreateTransactionWithLegacyAccountV1_response, } from './v1/createTransaction.js';
|
|
6
9
|
import { DeriveEntropyV1_request, DeriveEntropyV1_response } from './v1/deriveEntropy.js';
|
|
7
10
|
import { DevicePermissionV1_request, DevicePermissionV1_response } from './v1/devicePermission.js';
|
|
8
11
|
import { FeatureV1_request, FeatureV1_response } from './v1/feature.js';
|
|
9
12
|
import { HandshakeV1_request, HandshakeV1_response } from './v1/handshake.js';
|
|
10
|
-
import { StorageClearV1_request, StorageClearV1_response, StorageReadV1_request, StorageReadV1_response, StorageWriteV1_request, StorageWriteV1_response, } from './v1/localStorage.js';
|
|
13
|
+
import { StorageClearV1_request, StorageClearV1_response, StorageReadV1_request, StorageReadV1_response, StorageSubscribeV1_interrupt, StorageSubscribeV1_receive, StorageSubscribeV1_start, StorageWriteV1_request, StorageWriteV1_response, } from './v1/localStorage.js';
|
|
11
14
|
import { NavigateToV1_request, NavigateToV1_response } from './v1/navigation.js';
|
|
12
15
|
import { PushNotificationCancelV1_request, PushNotificationCancelV1_response, PushNotificationV1_request, PushNotificationV1_response, } from './v1/notification.js';
|
|
13
16
|
import { PaymentBalanceSubscribeV1_interrupt, PaymentBalanceSubscribeV1_receive, PaymentBalanceSubscribeV1_start, PaymentRequestV1_request, PaymentRequestV1_response, PaymentStatusSubscribeV1_interrupt, PaymentStatusSubscribeV1_receive, PaymentStatusSubscribeV1_start, PaymentTopUpV1_request, PaymentTopUpV1_response, } from './v1/payments.js';
|
|
@@ -17,6 +20,7 @@ import { RequestResourceAllocationV1_request, RequestResourceAllocationV1_respon
|
|
|
17
20
|
import { SignPayloadV1_request, SignPayloadV1_response, SignPayloadWithLegacyAccountV1_request, SignPayloadWithLegacyAccountV1_response, SignRawV1_request, SignRawV1_response, SignRawWithLegacyAccountV1_request, SignRawWithLegacyAccountV1_response, } from './v1/sign.js';
|
|
18
21
|
import { StatementStoreCreateProofAuthorizedV1_request, StatementStoreCreateProofAuthorizedV1_response, StatementStoreCreateProofV1_request, StatementStoreCreateProofV1_response, StatementStoreSubmitV1_request, StatementStoreSubmitV1_response, StatementStoreSubscribeV1_interrupt, StatementStoreSubscribeV1_receive, StatementStoreSubscribeV1_start, } from './v1/statementStore.js';
|
|
19
22
|
import { ThemeSubscribeV1_interrupt, ThemeSubscribeV1_receive, ThemeSubscribeV1_start } from './v1/theme.js';
|
|
23
|
+
import { WorkerBeginOperationV1_request, WorkerBeginOperationV1_response, WorkerEndOperationV1_request, WorkerEndOperationV1_response, } from './v1/worker.js';
|
|
20
24
|
const enumFromArg = (enumValues, n) => {
|
|
21
25
|
return Enum(Object.fromEntries(Object.entries(enumValues).map(([key, value]) => [key, value[n]])));
|
|
22
26
|
};
|
|
@@ -28,13 +32,21 @@ const versionedRequest = (index, values) => {
|
|
|
28
32
|
response: enumFromArg(values, 1),
|
|
29
33
|
};
|
|
30
34
|
};
|
|
35
|
+
// Applies the transport-level `CallError` envelope to each typed interrupt
|
|
36
|
+
// codec (leaving `_void` interrupts, which carry no payload, untouched). The
|
|
37
|
+
// wrapped codec decodes back to the plain domain reason, so the static
|
|
38
|
+
// interrupt type is unchanged; only the wire bytes gain the `CallError` layer.
|
|
39
|
+
const wrapInterrupts = (values) => Object.fromEntries(Object.entries(values).map(([key, [start, receive, interrupt]]) => [
|
|
40
|
+
key,
|
|
41
|
+
[start, receive, interrupt === _void ? interrupt : interruptError(interrupt)],
|
|
42
|
+
]));
|
|
31
43
|
const versionedSubscription = (index, values) => {
|
|
32
44
|
return {
|
|
33
45
|
method: 'subscribe',
|
|
34
46
|
index,
|
|
35
47
|
start: enumFromArg(values, 0),
|
|
36
48
|
receive: enumFromArg(values, 1),
|
|
37
|
-
interrupt: enumFromArg(values, 2),
|
|
49
|
+
interrupt: enumFromArg(wrapInterrupts(values), 2),
|
|
38
50
|
};
|
|
39
51
|
};
|
|
40
52
|
// Hands out contiguous serialization indices. Each call reserves the action's
|
|
@@ -223,15 +235,51 @@ export const hostApiProtocol = {
|
|
|
223
235
|
host_push_notification_cancel: versionedRequest(indexer.request(), {
|
|
224
236
|
v1: [PushNotificationCancelV1_request, PushNotificationCancelV1_response],
|
|
225
237
|
}),
|
|
226
|
-
//
|
|
227
|
-
//
|
|
228
|
-
// `request_id = 164` (RFC-0023).
|
|
229
|
-
|
|
238
|
+
// RFC 0017 CoinPayment — ids 136-163. Kept in wire order and directly before
|
|
239
|
+
// `sign_vrf` so the running index fills 136-163 and `sign_vrf` lands on its
|
|
240
|
+
// specified `request_id = 164` (RFC-0023) without a skip.
|
|
241
|
+
host_coin_payment_create_purse: versionedRequest(indexer.request(), {
|
|
242
|
+
v1: [CoinPaymentCreatePurseV1_request, CoinPaymentCreatePurseV1_response],
|
|
243
|
+
}),
|
|
244
|
+
host_coin_payment_query_purse: versionedRequest(indexer.request(), {
|
|
245
|
+
v1: [CoinPaymentQueryPurseV1_request, CoinPaymentQueryPurseV1_response],
|
|
246
|
+
}),
|
|
247
|
+
host_coin_payment_rebalance_purse: versionedSubscription(indexer.subscription(), {
|
|
248
|
+
v1: [CoinPaymentRebalancePurseV1_start, CoinPaymentRebalancePurseV1_receive, CoinPaymentRebalancePurseV1_interrupt],
|
|
249
|
+
}),
|
|
250
|
+
host_coin_payment_delete_purse: versionedSubscription(indexer.subscription(), {
|
|
251
|
+
v1: [CoinPaymentDeletePurseV1_start, CoinPaymentDeletePurseV1_receive, CoinPaymentDeletePurseV1_interrupt],
|
|
252
|
+
}),
|
|
253
|
+
host_coin_payment_create_receivable: versionedRequest(indexer.request(), {
|
|
254
|
+
v1: [CoinPaymentCreateReceivableV1_request, CoinPaymentCreateReceivableV1_response],
|
|
255
|
+
}),
|
|
256
|
+
host_coin_payment_create_cheque: versionedRequest(indexer.request(), {
|
|
257
|
+
v1: [CoinPaymentCreateChequeV1_request, CoinPaymentCreateChequeV1_response],
|
|
258
|
+
}),
|
|
259
|
+
host_coin_payment_deposit: versionedSubscription(indexer.subscription(), {
|
|
260
|
+
v1: [CoinPaymentDepositV1_start, CoinPaymentDepositV1_receive, CoinPaymentDepositV1_interrupt],
|
|
261
|
+
}),
|
|
262
|
+
host_coin_payment_refund: versionedSubscription(indexer.subscription(), {
|
|
263
|
+
v1: [CoinPaymentRefundV1_start, CoinPaymentRefundV1_receive, CoinPaymentRefundV1_interrupt],
|
|
264
|
+
}),
|
|
265
|
+
host_coin_payment_listen_for_payment: versionedSubscription(indexer.subscription(), {
|
|
266
|
+
v1: [
|
|
267
|
+
CoinPaymentListenForPaymentV1_start,
|
|
268
|
+
CoinPaymentListenForPaymentV1_receive,
|
|
269
|
+
CoinPaymentListenForPaymentV1_interrupt,
|
|
270
|
+
],
|
|
271
|
+
}),
|
|
272
|
+
host_account_sign_vrf: versionedRequest(indexer.request(), {
|
|
230
273
|
v1: [AccountSignVrfV1_request, AccountSignVrfV1_response],
|
|
231
274
|
}),
|
|
232
|
-
//
|
|
233
|
-
//
|
|
234
|
-
//
|
|
275
|
+
// Resolves a logical chain role (relay, asset hub, ...) to its network and
|
|
276
|
+
// genesis hash. truapi places it at `request_id = 166`, between `sign_vrf`
|
|
277
|
+
// and the ring-VRF block, so it must keep this position to hold that id.
|
|
278
|
+
remote_chain_get_chain_info: versionedRequest(indexer.request(), {
|
|
279
|
+
v1: [ChainInfoV1_request, ChainInfoV1_response],
|
|
280
|
+
}),
|
|
281
|
+
// RFC-0024 — explicit ring VRF key management. `create_proof` / `get_alias`
|
|
282
|
+
// changed shape in place instead, since a key handle is now mandatory there.
|
|
235
283
|
host_account_register_ring_vrf_key: versionedRequest(indexer.request(), {
|
|
236
284
|
v1: [AccountRegisterRingVrfKeyV1_request, AccountRegisterRingVrfKeyV1_response],
|
|
237
285
|
}),
|
|
@@ -241,4 +289,16 @@ export const hostApiProtocol = {
|
|
|
241
289
|
host_account_ring_vrf_sign: versionedRequest(indexer.request(), {
|
|
242
290
|
v1: [AccountRingVrfSignV1_request, AccountRingVrfSignV1_response],
|
|
243
291
|
}),
|
|
292
|
+
// truapi places localStorage.subscribe at start_id = 174, which the running
|
|
293
|
+
// index reaches naturally once every preceding method is in place.
|
|
294
|
+
host_local_storage_subscribe: versionedSubscription(indexer.subscription(), {
|
|
295
|
+
v1: [StorageSubscribeV1_start, StorageSubscribeV1_receive, StorageSubscribeV1_interrupt],
|
|
296
|
+
}),
|
|
297
|
+
// Worker background-operation keep-alive (truapi request_id 178 / 180).
|
|
298
|
+
host_worker_begin_operation: versionedRequest(indexer.request(), {
|
|
299
|
+
v1: [WorkerBeginOperationV1_request, WorkerBeginOperationV1_response],
|
|
300
|
+
}),
|
|
301
|
+
host_worker_end_operation: versionedRequest(indexer.request(), {
|
|
302
|
+
v1: [WorkerEndOperationV1_request, WorkerEndOperationV1_response],
|
|
303
|
+
}),
|
|
244
304
|
};
|