@novasamatech/host-api 0.8.0-1 → 0.8.1
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/README.md +1 -1
- package/dist/constants.d.ts +1 -1
- package/dist/constants.js +1 -1
- package/dist/hostApi.js +0 -9
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/protocol/impl.d.ts +22 -11
- package/dist/protocol/impl.js +75 -66
- package/dist/protocol/messageCodec.d.ts +37 -54
- package/dist/protocol/messageCodec.js +11 -1
- package/dist/protocol/messageCodec.spec.d.ts +1 -0
- package/dist/protocol/messageCodec.spec.js +29 -0
- package/dist/protocol/v1/chainInteraction.d.ts +2 -2
- package/dist/protocol/v1/chainInteraction.js +1 -1
- package/dist/protocol/v1/customRenderer.d.ts +9 -9
- package/dist/protocol/v1/customRenderer.js +2 -2
- package/dist/protocol/v1/handshake.d.ts +1 -1
- package/dist/protocol/v1/handshake.js +1 -1
- package/dist/protocol/v1/payments.d.ts +6 -1
- package/dist/protocol/v1/payments.js +8 -2
- package/dist/protocol/v1/remotePermission.d.ts +2 -2
- package/dist/protocol/v1/remotePermission.js +1 -1
- package/dist/protocol/v1/resourceAllocation.d.ts +2 -2
- package/dist/protocol/v1/resourceAllocation.js +1 -1
- package/dist/protocol/v1/theme.d.ts +28 -2
- package/dist/protocol/v1/theme.js +11 -3
- package/dist/protocol/v1/theme.spec.d.ts +1 -0
- package/dist/protocol/v1/theme.spec.js +37 -0
- package/dist/transport.js +4 -4
- package/dist/transport.spec.js +2 -2
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -11,7 +11,7 @@ npm install @novasamatech/host-api --save -E
|
|
|
11
11
|
## Usage
|
|
12
12
|
|
|
13
13
|
The Host API package is composed of four main parts:
|
|
14
|
-
* **Protocol** —
|
|
14
|
+
* **Protocol** — SCALE codecs;
|
|
15
15
|
* **Provider** — IPC interface, depends on environment;
|
|
16
16
|
* **Transport** — wrapper around protocol for making actual calls;
|
|
17
17
|
* **Host API** — wrapper around transport for direct usage of business methods.
|
package/dist/constants.d.ts
CHANGED
package/dist/constants.js
CHANGED
package/dist/hostApi.js
CHANGED
|
@@ -317,15 +317,6 @@ export function createHostApi(transport) {
|
|
|
317
317
|
value: new GenericError({ reason }),
|
|
318
318
|
}));
|
|
319
319
|
},
|
|
320
|
-
jsonrpcMessageSend(payload) {
|
|
321
|
-
return makeRequest(transport.request('host_jsonrpc_message_send', payload), () => ({
|
|
322
|
-
tag: payload.tag,
|
|
323
|
-
value: undefined,
|
|
324
|
-
}));
|
|
325
|
-
},
|
|
326
|
-
jsonrpcMessageSubscribe(args, callback) {
|
|
327
|
-
return transport.subscribe('host_jsonrpc_message_subscribe', args, callback);
|
|
328
|
-
},
|
|
329
320
|
};
|
|
330
321
|
}
|
|
331
322
|
function makeRequest(promise, mapErr) {
|
package/dist/index.d.ts
CHANGED
|
@@ -29,4 +29,4 @@ export { AllocatableResource, AllocationOutcome, ResourceAllocationErr } from '.
|
|
|
29
29
|
export { PaymentBalance, PaymentBalanceErr, PaymentId, PaymentReceipt, PaymentRequestErr, PaymentStatus, PaymentStatusErr, PaymentTopUpErr, PaymentTopUpSource, } from './protocol/v1/payments.js';
|
|
30
30
|
export { Arrangement, BorderStyle, ButtonVariant, ColorToken, ContentAlignment, CustomRendererNode, Dimensions, HorizontalAlignment, Modifier, Shape, Size, TypographyStyle, VerticalAlignment, } from './protocol/v1/customRenderer.js';
|
|
31
31
|
export { ChainHeadEvent, ChainHeadFollowV1_start, OperationStartedResult, RuntimeType, StorageQueryItem, StorageQueryType, StorageResultItem, TransactionBroadcastV1_request, TransactionBroadcastV1_response, TransactionStopV1_request, TransactionStopV1_response, } from './protocol/v1/chainInteraction.js';
|
|
32
|
-
export { Theme } from './protocol/v1/theme.js';
|
|
32
|
+
export { Theme, ThemeName, ThemeVariant } from './protocol/v1/theme.js';
|
package/dist/index.js
CHANGED
|
@@ -23,4 +23,4 @@ export { AllocatableResource, AllocationOutcome, ResourceAllocationErr } from '.
|
|
|
23
23
|
export { PaymentBalance, PaymentBalanceErr, PaymentId, PaymentReceipt, PaymentRequestErr, PaymentStatus, PaymentStatusErr, PaymentTopUpErr, PaymentTopUpSource, } from './protocol/v1/payments.js';
|
|
24
24
|
export { Arrangement, BorderStyle, ButtonVariant, ColorToken, ContentAlignment, CustomRendererNode, Dimensions, HorizontalAlignment, Modifier, Shape, Size, TypographyStyle, VerticalAlignment, } from './protocol/v1/customRenderer.js';
|
|
25
25
|
export { ChainHeadEvent, ChainHeadFollowV1_start, OperationStartedResult, RuntimeType, StorageQueryItem, StorageQueryType, StorageResultItem, TransactionBroadcastV1_request, TransactionBroadcastV1_response, TransactionStopV1_request, TransactionStopV1_response, } from './protocol/v1/chainInteraction.js';
|
|
26
|
-
export { Theme } from './protocol/v1/theme.js';
|
|
26
|
+
export { Theme, ThemeName, ThemeVariant } from './protocol/v1/theme.js';
|
package/dist/protocol/impl.d.ts
CHANGED
|
@@ -8,11 +8,15 @@ type InferVersionedArgument<EnumValues extends Record<string, Codec<any>[]>, N e
|
|
|
8
8
|
};
|
|
9
9
|
export type VersionedProtocolRequest<T extends VersionedRequestArguments = VersionedRequestArguments> = {
|
|
10
10
|
method: 'request';
|
|
11
|
+
/** Base serialization index; `request` takes it, `response` takes `index + 1`. */
|
|
12
|
+
index: number;
|
|
11
13
|
request: EnumCodec<InferVersionedArgument<T, 0>>;
|
|
12
14
|
response: EnumCodec<InferVersionedArgument<T, 1>>;
|
|
13
15
|
};
|
|
14
16
|
export type VersionedProtocolSubscription<T extends VersionedSubscriptionArguments = VersionedSubscriptionArguments> = {
|
|
15
17
|
method: 'subscribe';
|
|
18
|
+
/** Base serialization index; `start`/`stop`/`interrupt`/`receive` take `index + 0..3`. */
|
|
19
|
+
index: number;
|
|
16
20
|
start: EnumCodec<InferVersionedArgument<T, 0>>;
|
|
17
21
|
receive: EnumCodec<InferVersionedArgument<T, 1>>;
|
|
18
22
|
interrupt: EnumCodec<InferVersionedArgument<T, 2>>;
|
|
@@ -56,7 +60,7 @@ export declare const hostApiProtocol: {
|
|
|
56
60
|
tag: "Remote";
|
|
57
61
|
value: string[];
|
|
58
62
|
} | {
|
|
59
|
-
tag: "
|
|
63
|
+
tag: "WebRtc";
|
|
60
64
|
value: undefined;
|
|
61
65
|
} | {
|
|
62
66
|
tag: "ChainSubmit";
|
|
@@ -512,12 +516,6 @@ export declare const hostApiProtocol: {
|
|
|
512
516
|
reason: string;
|
|
513
517
|
}, "PreimageSubmitErr::Unknown">>>];
|
|
514
518
|
}>;
|
|
515
|
-
readonly host_jsonrpc_message_send: VersionedProtocolRequest<{
|
|
516
|
-
readonly v1: [Codec<undefined>, Codec<import("scale-ts").ResultPayload<undefined, undefined>>];
|
|
517
|
-
}>;
|
|
518
|
-
readonly host_jsonrpc_message_subscribe: VersionedProtocolSubscription<{
|
|
519
|
-
readonly v1: [Codec<undefined>, Codec<undefined>, Codec<undefined>];
|
|
520
|
-
}>;
|
|
521
519
|
readonly remote_chain_head_follow_subscribe: VersionedProtocolSubscription<{
|
|
522
520
|
readonly v1: [Codec<{
|
|
523
521
|
genesisHash: `0x${string}`;
|
|
@@ -658,7 +656,7 @@ export declare const hostApiProtocol: {
|
|
|
658
656
|
hash: `0x${string}`;
|
|
659
657
|
items: {
|
|
660
658
|
key: `0x${string}`;
|
|
661
|
-
|
|
659
|
+
queryType: "Value" | "Hash" | "ClosestDescendantMerkleValue" | "DescendantsValues" | "DescendantsHashes";
|
|
662
660
|
}[];
|
|
663
661
|
childTrie: `0x${string}` | null;
|
|
664
662
|
}>, Codec<import("scale-ts").ResultPayload<{
|
|
@@ -751,7 +749,16 @@ export declare const hostApiProtocol: {
|
|
|
751
749
|
}, "GenericError">>>];
|
|
752
750
|
}>;
|
|
753
751
|
readonly host_theme_subscribe: VersionedProtocolSubscription<{
|
|
754
|
-
readonly v1: [Codec<undefined>, Codec<
|
|
752
|
+
readonly v1: [Codec<undefined>, Codec<{
|
|
753
|
+
name: {
|
|
754
|
+
tag: "Custom";
|
|
755
|
+
value: string;
|
|
756
|
+
} | {
|
|
757
|
+
tag: "Default";
|
|
758
|
+
value: undefined;
|
|
759
|
+
};
|
|
760
|
+
variant: "Light" | "Dark";
|
|
761
|
+
}>, Codec<undefined>];
|
|
755
762
|
}>;
|
|
756
763
|
readonly host_derive_entropy: VersionedProtocolRequest<{
|
|
757
764
|
readonly v1: [Codec<Uint8Array<ArrayBufferLike>>, Codec<import("scale-ts").ResultPayload<Uint8Array<ArrayBufferLike>, import("@novasamatech/scale").CodecError<{
|
|
@@ -815,7 +822,9 @@ export declare const hostApiProtocol: {
|
|
|
815
822
|
}, "SigningErr::Unknown"> | import("@novasamatech/scale").CodecError<undefined, "SigningErr::PermissionDenied"> | import("@novasamatech/scale").CodecError<undefined, "SigningErr::FailedToDecode">>>];
|
|
816
823
|
}>;
|
|
817
824
|
readonly host_payment_balance_subscribe: VersionedProtocolSubscription<{
|
|
818
|
-
readonly v1: [Codec<
|
|
825
|
+
readonly v1: [Codec<{
|
|
826
|
+
purse: number | undefined;
|
|
827
|
+
}>, Codec<{
|
|
819
828
|
available: bigint;
|
|
820
829
|
}>, [import("scale-ts").Encoder<import("@novasamatech/scale").CodecError<{
|
|
821
830
|
reason: string;
|
|
@@ -841,6 +850,7 @@ export declare const hostApiProtocol: {
|
|
|
841
850
|
}>;
|
|
842
851
|
readonly host_payment_top_up: VersionedProtocolRequest<{
|
|
843
852
|
readonly v1: [Codec<{
|
|
853
|
+
into: number | undefined;
|
|
844
854
|
amount: bigint;
|
|
845
855
|
source: {
|
|
846
856
|
tag: "ProductAccount";
|
|
@@ -855,6 +865,7 @@ export declare const hostApiProtocol: {
|
|
|
855
865
|
}>;
|
|
856
866
|
readonly host_payment_request: VersionedProtocolRequest<{
|
|
857
867
|
readonly v1: [Codec<{
|
|
868
|
+
from: number | undefined;
|
|
858
869
|
amount: bigint;
|
|
859
870
|
destination: Uint8Array<ArrayBufferLike>;
|
|
860
871
|
}>, Codec<import("scale-ts").ResultPayload<{
|
|
@@ -900,7 +911,7 @@ export declare const hostApiProtocol: {
|
|
|
900
911
|
tag: "StatementStoreAllowance";
|
|
901
912
|
value: undefined;
|
|
902
913
|
} | {
|
|
903
|
-
tag: "
|
|
914
|
+
tag: "BulletinAllowance";
|
|
904
915
|
value: undefined;
|
|
905
916
|
} | {
|
|
906
917
|
tag: "SmartContractAllowance";
|
package/dist/protocol/impl.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { Enum } from '@novasamatech/scale';
|
|
2
|
-
import { Result, _void } from 'scale-ts';
|
|
3
2
|
import { AccountConnectionStatusV1_interrupt, AccountConnectionStatusV1_receive, AccountConnectionStatusV1_start, AccountCreateProofV1_request, AccountCreateProofV1_response, AccountGetAliasV1_request, AccountGetAliasV1_response, AccountGetV1_request, AccountGetV1_response, GetLegacyAccountsV1_request, GetLegacyAccountsV1_response, GetUserIdV1_request, GetUserIdV1_response, RequestLoginV1_request, RequestLoginV1_response, } from './v1/accounts.js';
|
|
4
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
4
|
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';
|
|
@@ -21,197 +20,207 @@ import { ThemeSubscribeV1_interrupt, ThemeSubscribeV1_receive, ThemeSubscribeV1_
|
|
|
21
20
|
const enumFromArg = (enumValues, n) => {
|
|
22
21
|
return Enum(Object.fromEntries(Object.entries(enumValues).map(([key, value]) => [key, value[n]])));
|
|
23
22
|
};
|
|
24
|
-
const versionedRequest = (values) => {
|
|
23
|
+
const versionedRequest = (index, values) => {
|
|
25
24
|
return {
|
|
26
25
|
method: 'request',
|
|
26
|
+
index,
|
|
27
27
|
request: enumFromArg(values, 0),
|
|
28
28
|
response: enumFromArg(values, 1),
|
|
29
29
|
};
|
|
30
30
|
};
|
|
31
|
-
const versionedSubscription = (values) => {
|
|
31
|
+
const versionedSubscription = (index, values) => {
|
|
32
32
|
return {
|
|
33
33
|
method: 'subscribe',
|
|
34
|
+
index,
|
|
34
35
|
start: enumFromArg(values, 0),
|
|
35
36
|
receive: enumFromArg(values, 1),
|
|
36
37
|
interrupt: enumFromArg(values, 2),
|
|
37
38
|
};
|
|
38
39
|
};
|
|
40
|
+
// Hands out contiguous serialization indices. Each call reserves the action's
|
|
41
|
+
// own slots (request = 2, subscription = 4) and returns its base index, so the
|
|
42
|
+
// ABI is self-contained: a method's index depends only on what precedes it.
|
|
43
|
+
function createIndexer() {
|
|
44
|
+
let offset = 0;
|
|
45
|
+
const take = (width, prefix = 0) => {
|
|
46
|
+
const index = offset;
|
|
47
|
+
offset += prefix + width;
|
|
48
|
+
return prefix + index;
|
|
49
|
+
};
|
|
50
|
+
return {
|
|
51
|
+
request: (prefix) => take(2, prefix),
|
|
52
|
+
subscription: (prefix) => take(4, prefix),
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
const indexer = createIndexer();
|
|
39
56
|
export const hostApiProtocol = {
|
|
40
|
-
host_handshake: versionedRequest({
|
|
57
|
+
host_handshake: versionedRequest(indexer.request(), {
|
|
41
58
|
v1: [HandshakeV1_request, HandshakeV1_response],
|
|
42
59
|
}),
|
|
43
|
-
host_feature_supported: versionedRequest({
|
|
60
|
+
host_feature_supported: versionedRequest(indexer.request(), {
|
|
44
61
|
v1: [FeatureV1_request, FeatureV1_response],
|
|
45
62
|
}),
|
|
46
|
-
host_push_notification: versionedRequest({
|
|
63
|
+
host_push_notification: versionedRequest(indexer.request(), {
|
|
47
64
|
v1: [PushNotificationV1_request, PushNotificationV1_response],
|
|
48
65
|
}),
|
|
49
|
-
host_navigate_to: versionedRequest({
|
|
66
|
+
host_navigate_to: versionedRequest(indexer.request(), {
|
|
50
67
|
v1: [NavigateToV1_request, NavigateToV1_response],
|
|
51
68
|
}),
|
|
52
|
-
host_device_permission: versionedRequest({
|
|
69
|
+
host_device_permission: versionedRequest(indexer.request(), {
|
|
53
70
|
v1: [DevicePermissionV1_request, DevicePermissionV1_response],
|
|
54
71
|
}),
|
|
55
|
-
remote_permission: versionedRequest({
|
|
72
|
+
remote_permission: versionedRequest(indexer.request(), {
|
|
56
73
|
v1: [RemotePermissionV1_request, RemotePermissionV1_response],
|
|
57
74
|
}),
|
|
58
|
-
host_local_storage_read: versionedRequest({
|
|
75
|
+
host_local_storage_read: versionedRequest(indexer.request(), {
|
|
59
76
|
v1: [StorageReadV1_request, StorageReadV1_response],
|
|
60
77
|
}),
|
|
61
|
-
host_local_storage_write: versionedRequest({
|
|
78
|
+
host_local_storage_write: versionedRequest(indexer.request(), {
|
|
62
79
|
v1: [StorageWriteV1_request, StorageWriteV1_response],
|
|
63
80
|
}),
|
|
64
|
-
host_local_storage_clear: versionedRequest({
|
|
81
|
+
host_local_storage_clear: versionedRequest(indexer.request(), {
|
|
65
82
|
v1: [StorageClearV1_request, StorageClearV1_response],
|
|
66
83
|
}),
|
|
67
|
-
host_account_connection_status_subscribe: versionedSubscription({
|
|
84
|
+
host_account_connection_status_subscribe: versionedSubscription(indexer.subscription(), {
|
|
68
85
|
v1: [AccountConnectionStatusV1_start, AccountConnectionStatusV1_receive, AccountConnectionStatusV1_interrupt],
|
|
69
86
|
}),
|
|
70
|
-
host_account_get: versionedRequest({
|
|
87
|
+
host_account_get: versionedRequest(indexer.request(), {
|
|
71
88
|
v1: [AccountGetV1_request, AccountGetV1_response],
|
|
72
89
|
}),
|
|
73
|
-
host_account_get_alias: versionedRequest({
|
|
90
|
+
host_account_get_alias: versionedRequest(indexer.request(), {
|
|
74
91
|
v1: [AccountGetAliasV1_request, AccountGetAliasV1_response],
|
|
75
92
|
}),
|
|
76
|
-
host_account_create_proof: versionedRequest({
|
|
93
|
+
host_account_create_proof: versionedRequest(indexer.request(), {
|
|
77
94
|
v1: [AccountCreateProofV1_request, AccountCreateProofV1_response],
|
|
78
95
|
}),
|
|
79
|
-
host_get_legacy_accounts: versionedRequest({
|
|
96
|
+
host_get_legacy_accounts: versionedRequest(indexer.request(), {
|
|
80
97
|
v1: [GetLegacyAccountsV1_request, GetLegacyAccountsV1_response],
|
|
81
98
|
}),
|
|
82
|
-
host_create_transaction: versionedRequest({
|
|
99
|
+
host_create_transaction: versionedRequest(indexer.request(), {
|
|
83
100
|
v1: [CreateTransactionV1_request, CreateTransactionV1_response],
|
|
84
101
|
}),
|
|
85
|
-
host_create_transaction_with_legacy_account: versionedRequest({
|
|
102
|
+
host_create_transaction_with_legacy_account: versionedRequest(indexer.request(), {
|
|
86
103
|
v1: [CreateTransactionWithLegacyAccountV1_request, CreateTransactionWithLegacyAccountV1_response],
|
|
87
104
|
}),
|
|
88
|
-
host_sign_raw_with_legacy_account: versionedRequest({
|
|
105
|
+
host_sign_raw_with_legacy_account: versionedRequest(indexer.request(), {
|
|
89
106
|
v1: [SignRawWithLegacyAccountV1_request, SignRawWithLegacyAccountV1_response],
|
|
90
107
|
}),
|
|
91
|
-
host_sign_payload_with_legacy_account: versionedRequest({
|
|
108
|
+
host_sign_payload_with_legacy_account: versionedRequest(indexer.request(), {
|
|
92
109
|
v1: [SignPayloadWithLegacyAccountV1_request, SignPayloadWithLegacyAccountV1_response],
|
|
93
110
|
}),
|
|
94
|
-
host_chat_create_room: versionedRequest({
|
|
111
|
+
host_chat_create_room: versionedRequest(indexer.request(), {
|
|
95
112
|
v1: [ChatCreateRoomV1_request, ChatCreateRoomV1_response],
|
|
96
113
|
}),
|
|
97
|
-
host_chat_register_bot: versionedRequest({
|
|
114
|
+
host_chat_register_bot: versionedRequest(indexer.request(), {
|
|
98
115
|
v1: [ChatRegisterBotV1_request, ChatRegisterBotV1_response],
|
|
99
116
|
}),
|
|
100
|
-
host_chat_list_subscribe: versionedSubscription({
|
|
117
|
+
host_chat_list_subscribe: versionedSubscription(indexer.subscription(), {
|
|
101
118
|
v1: [ChatListSubscribeV1_start, ChatListSubscribeV1_receive, ChatListSubscribeV1_interrupt],
|
|
102
119
|
}),
|
|
103
|
-
host_chat_post_message: versionedRequest({
|
|
120
|
+
host_chat_post_message: versionedRequest(indexer.request(), {
|
|
104
121
|
v1: [ChatPostMessageV1_request, ChatPostMessageV1_response],
|
|
105
122
|
}),
|
|
106
|
-
host_chat_action_subscribe: versionedSubscription({
|
|
123
|
+
host_chat_action_subscribe: versionedSubscription(indexer.subscription(), {
|
|
107
124
|
v1: [ChatActionSubscribeV1_start, ChatActionSubscribeV1_receive, ChatActionSubscribeV1_interrupt],
|
|
108
125
|
}),
|
|
109
|
-
product_chat_custom_message_render_subscribe: versionedSubscription({
|
|
126
|
+
product_chat_custom_message_render_subscribe: versionedSubscription(indexer.subscription(), {
|
|
110
127
|
v1: [
|
|
111
128
|
ChatCustomMessageRenderingV1_start,
|
|
112
129
|
ChatCustomMessageRenderingV1_receive,
|
|
113
130
|
ChatCustomMessageRenderingV1_interrupt,
|
|
114
131
|
],
|
|
115
132
|
}),
|
|
116
|
-
remote_statement_store_subscribe: versionedSubscription({
|
|
133
|
+
remote_statement_store_subscribe: versionedSubscription(indexer.subscription(), {
|
|
117
134
|
v1: [StatementStoreSubscribeV1_start, StatementStoreSubscribeV1_receive, StatementStoreSubscribeV1_interrupt],
|
|
118
135
|
}),
|
|
119
|
-
remote_statement_store_create_proof: versionedRequest({
|
|
136
|
+
remote_statement_store_create_proof: versionedRequest(indexer.request(), {
|
|
120
137
|
v1: [StatementStoreCreateProofV1_request, StatementStoreCreateProofV1_response],
|
|
121
138
|
}),
|
|
122
|
-
remote_statement_store_submit: versionedRequest({
|
|
139
|
+
remote_statement_store_submit: versionedRequest(indexer.request(), {
|
|
123
140
|
v1: [StatementStoreSubmitV1_request, StatementStoreSubmitV1_response],
|
|
124
141
|
}),
|
|
125
|
-
remote_preimage_lookup_subscribe: versionedSubscription({
|
|
142
|
+
remote_preimage_lookup_subscribe: versionedSubscription(indexer.subscription(), {
|
|
126
143
|
v1: [PreimageLookupSubscribeV1_start, PreimageLookupSubscribeV1_receive, PreimageLookupSubscribeV1_interrupt],
|
|
127
144
|
}),
|
|
128
|
-
remote_preimage_submit: versionedRequest({
|
|
145
|
+
remote_preimage_submit: versionedRequest(indexer.request(), {
|
|
129
146
|
v1: [PreimageSubmitV1_request, PreimageSubmitV1_response],
|
|
130
147
|
}),
|
|
131
|
-
|
|
132
|
-
host_jsonrpc_message_send: versionedRequest({
|
|
133
|
-
v1: [_void, Result(_void, _void)],
|
|
134
|
-
}),
|
|
135
|
-
// json rpc (deprecated: use remote_chain_* methods instead)
|
|
136
|
-
host_jsonrpc_message_subscribe: versionedSubscription({
|
|
137
|
-
v1: [_void, _void, _void],
|
|
138
|
-
}),
|
|
139
|
-
remote_chain_head_follow_subscribe: versionedSubscription({
|
|
148
|
+
remote_chain_head_follow_subscribe: versionedSubscription(indexer.subscription(6), {
|
|
140
149
|
v1: [ChainHeadFollowV1_start, ChainHeadFollowV1_receive, ChainHeadFollowV1_interrupt],
|
|
141
150
|
}),
|
|
142
|
-
remote_chain_head_header: versionedRequest({
|
|
151
|
+
remote_chain_head_header: versionedRequest(indexer.request(), {
|
|
143
152
|
v1: [ChainHeadHeaderV1_request, ChainHeadHeaderV1_response],
|
|
144
153
|
}),
|
|
145
|
-
remote_chain_head_body: versionedRequest({
|
|
154
|
+
remote_chain_head_body: versionedRequest(indexer.request(), {
|
|
146
155
|
v1: [ChainHeadBodyV1_request, ChainHeadBodyV1_response],
|
|
147
156
|
}),
|
|
148
|
-
remote_chain_head_storage: versionedRequest({
|
|
157
|
+
remote_chain_head_storage: versionedRequest(indexer.request(), {
|
|
149
158
|
v1: [ChainHeadStorageV1_request, ChainHeadStorageV1_response],
|
|
150
159
|
}),
|
|
151
|
-
remote_chain_head_call: versionedRequest({
|
|
160
|
+
remote_chain_head_call: versionedRequest(indexer.request(), {
|
|
152
161
|
v1: [ChainHeadCallV1_request, ChainHeadCallV1_response],
|
|
153
162
|
}),
|
|
154
|
-
remote_chain_head_unpin: versionedRequest({
|
|
163
|
+
remote_chain_head_unpin: versionedRequest(indexer.request(), {
|
|
155
164
|
v1: [ChainHeadUnpinV1_request, ChainHeadUnpinV1_response],
|
|
156
165
|
}),
|
|
157
|
-
remote_chain_head_continue: versionedRequest({
|
|
166
|
+
remote_chain_head_continue: versionedRequest(indexer.request(), {
|
|
158
167
|
v1: [ChainHeadContinueV1_request, ChainHeadContinueV1_response],
|
|
159
168
|
}),
|
|
160
|
-
remote_chain_head_stop_operation: versionedRequest({
|
|
169
|
+
remote_chain_head_stop_operation: versionedRequest(indexer.request(), {
|
|
161
170
|
v1: [ChainHeadStopOperationV1_request, ChainHeadStopOperationV1_response],
|
|
162
171
|
}),
|
|
163
|
-
remote_chain_spec_genesis_hash: versionedRequest({
|
|
172
|
+
remote_chain_spec_genesis_hash: versionedRequest(indexer.request(), {
|
|
164
173
|
v1: [ChainSpecGenesisHashV1_request, ChainSpecGenesisHashV1_response],
|
|
165
174
|
}),
|
|
166
|
-
remote_chain_spec_chain_name: versionedRequest({
|
|
175
|
+
remote_chain_spec_chain_name: versionedRequest(indexer.request(), {
|
|
167
176
|
v1: [ChainSpecChainNameV1_request, ChainSpecChainNameV1_response],
|
|
168
177
|
}),
|
|
169
|
-
remote_chain_spec_properties: versionedRequest({
|
|
178
|
+
remote_chain_spec_properties: versionedRequest(indexer.request(), {
|
|
170
179
|
v1: [ChainSpecPropertiesV1_request, ChainSpecPropertiesV1_response],
|
|
171
180
|
}),
|
|
172
|
-
remote_chain_transaction_broadcast: versionedRequest({
|
|
181
|
+
remote_chain_transaction_broadcast: versionedRequest(indexer.request(), {
|
|
173
182
|
v1: [TransactionBroadcastV1_request, TransactionBroadcastV1_response],
|
|
174
183
|
}),
|
|
175
|
-
remote_chain_transaction_stop: versionedRequest({
|
|
184
|
+
remote_chain_transaction_stop: versionedRequest(indexer.request(), {
|
|
176
185
|
v1: [TransactionStopV1_request, TransactionStopV1_response],
|
|
177
186
|
}),
|
|
178
|
-
host_theme_subscribe: versionedSubscription({
|
|
187
|
+
host_theme_subscribe: versionedSubscription(indexer.subscription(), {
|
|
179
188
|
v1: [ThemeSubscribeV1_start, ThemeSubscribeV1_receive, ThemeSubscribeV1_interrupt],
|
|
180
189
|
}),
|
|
181
|
-
host_derive_entropy: versionedRequest({
|
|
190
|
+
host_derive_entropy: versionedRequest(indexer.request(), {
|
|
182
191
|
v1: [DeriveEntropyV1_request, DeriveEntropyV1_response],
|
|
183
192
|
}),
|
|
184
|
-
host_get_user_id: versionedRequest({
|
|
193
|
+
host_get_user_id: versionedRequest(indexer.request(), {
|
|
185
194
|
v1: [GetUserIdV1_request, GetUserIdV1_response],
|
|
186
195
|
}),
|
|
187
|
-
host_request_login: versionedRequest({
|
|
196
|
+
host_request_login: versionedRequest(indexer.request(), {
|
|
188
197
|
v1: [RequestLoginV1_request, RequestLoginV1_response],
|
|
189
198
|
}),
|
|
190
|
-
host_sign_raw: versionedRequest({
|
|
199
|
+
host_sign_raw: versionedRequest(indexer.request(), {
|
|
191
200
|
v1: [SignRawV1_request, SignRawV1_response],
|
|
192
201
|
}),
|
|
193
|
-
host_sign_payload: versionedRequest({
|
|
202
|
+
host_sign_payload: versionedRequest(indexer.request(), {
|
|
194
203
|
v1: [SignPayloadV1_request, SignPayloadV1_response],
|
|
195
204
|
}),
|
|
196
|
-
host_payment_balance_subscribe: versionedSubscription({
|
|
205
|
+
host_payment_balance_subscribe: versionedSubscription(indexer.subscription(), {
|
|
197
206
|
v1: [PaymentBalanceSubscribeV1_start, PaymentBalanceSubscribeV1_receive, PaymentBalanceSubscribeV1_interrupt],
|
|
198
207
|
}),
|
|
199
|
-
host_payment_top_up: versionedRequest({
|
|
208
|
+
host_payment_top_up: versionedRequest(indexer.request(), {
|
|
200
209
|
v1: [PaymentTopUpV1_request, PaymentTopUpV1_response],
|
|
201
210
|
}),
|
|
202
|
-
host_payment_request: versionedRequest({
|
|
211
|
+
host_payment_request: versionedRequest(indexer.request(), {
|
|
203
212
|
v1: [PaymentRequestV1_request, PaymentRequestV1_response],
|
|
204
213
|
}),
|
|
205
|
-
host_payment_status_subscribe: versionedSubscription({
|
|
214
|
+
host_payment_status_subscribe: versionedSubscription(indexer.subscription(), {
|
|
206
215
|
v1: [PaymentStatusSubscribeV1_start, PaymentStatusSubscribeV1_receive, PaymentStatusSubscribeV1_interrupt],
|
|
207
216
|
}),
|
|
208
|
-
host_request_resource_allocation: versionedRequest({
|
|
217
|
+
host_request_resource_allocation: versionedRequest(indexer.request(), {
|
|
209
218
|
v1: [RequestResourceAllocationV1_request, RequestResourceAllocationV1_response],
|
|
210
219
|
}),
|
|
211
|
-
remote_statement_store_create_proof_authorized: versionedRequest({
|
|
220
|
+
remote_statement_store_create_proof_authorized: versionedRequest(indexer.request(), {
|
|
212
221
|
v1: [StatementStoreCreateProofAuthorizedV1_request, StatementStoreCreateProofAuthorizedV1_response],
|
|
213
222
|
}),
|
|
214
|
-
host_push_notification_cancel: versionedRequest({
|
|
223
|
+
host_push_notification_cancel: versionedRequest(indexer.request(), {
|
|
215
224
|
v1: [PushNotificationCancelV1_request, PushNotificationCancelV1_response],
|
|
216
225
|
}),
|
|
217
226
|
};
|
|
@@ -51,7 +51,7 @@ export declare const MessagePayload: EnumCodec<Record<"host_handshake_request",
|
|
|
51
51
|
tag: "Remote";
|
|
52
52
|
value: string[];
|
|
53
53
|
} | {
|
|
54
|
-
tag: "
|
|
54
|
+
tag: "WebRtc";
|
|
55
55
|
value: undefined;
|
|
56
56
|
} | {
|
|
57
57
|
tag: "ChainSubmit";
|
|
@@ -543,17 +543,7 @@ export declare const MessagePayload: EnumCodec<Record<"host_handshake_request",
|
|
|
543
543
|
readonly v1: Codec<import("scale-ts").ResultPayload<`0x${string}`, import("@novasamatech/scale").CodecError<{
|
|
544
544
|
reason: string;
|
|
545
545
|
}, "PreimageSubmitErr::Unknown">>>;
|
|
546
|
-
}>> & Record<"
|
|
547
|
-
readonly v1: Codec<undefined>;
|
|
548
|
-
}>> & Record<"host_jsonrpc_message_send_response", EnumCodec<{
|
|
549
|
-
readonly v1: Codec<import("scale-ts").ResultPayload<undefined, undefined>>;
|
|
550
|
-
}>> & Record<"host_jsonrpc_message_subscribe_start", EnumCodec<{
|
|
551
|
-
readonly v1: Codec<undefined>;
|
|
552
|
-
}>> & Record<"host_jsonrpc_message_subscribe_receive", EnumCodec<{
|
|
553
|
-
readonly v1: Codec<undefined>;
|
|
554
|
-
}>> & Record<"host_jsonrpc_message_subscribe_interrupt", EnumCodec<{
|
|
555
|
-
readonly v1: Codec<undefined>;
|
|
556
|
-
}>> & Record<"host_jsonrpc_message_subscribe_stop", Codec<undefined>> & Record<"remote_chain_head_follow_subscribe_start", EnumCodec<{
|
|
546
|
+
}>> & Record<"remote_chain_head_follow_subscribe_start", EnumCodec<{
|
|
557
547
|
readonly v1: Codec<{
|
|
558
548
|
genesisHash: `0x${string}`;
|
|
559
549
|
withRuntime: boolean;
|
|
@@ -698,7 +688,7 @@ export declare const MessagePayload: EnumCodec<Record<"host_handshake_request",
|
|
|
698
688
|
hash: `0x${string}`;
|
|
699
689
|
items: {
|
|
700
690
|
key: `0x${string}`;
|
|
701
|
-
|
|
691
|
+
queryType: "Value" | "Hash" | "ClosestDescendantMerkleValue" | "DescendantsValues" | "DescendantsHashes";
|
|
702
692
|
}[];
|
|
703
693
|
childTrie: `0x${string}` | null;
|
|
704
694
|
}>;
|
|
@@ -803,7 +793,16 @@ export declare const MessagePayload: EnumCodec<Record<"host_handshake_request",
|
|
|
803
793
|
}>> & Record<"host_theme_subscribe_start", EnumCodec<{
|
|
804
794
|
readonly v1: Codec<undefined>;
|
|
805
795
|
}>> & Record<"host_theme_subscribe_receive", EnumCodec<{
|
|
806
|
-
readonly v1: Codec<
|
|
796
|
+
readonly v1: Codec<{
|
|
797
|
+
name: {
|
|
798
|
+
tag: "Custom";
|
|
799
|
+
value: string;
|
|
800
|
+
} | {
|
|
801
|
+
tag: "Default";
|
|
802
|
+
value: undefined;
|
|
803
|
+
};
|
|
804
|
+
variant: "Light" | "Dark";
|
|
805
|
+
}>;
|
|
807
806
|
}>> & Record<"host_theme_subscribe_interrupt", EnumCodec<{
|
|
808
807
|
readonly v1: Codec<undefined>;
|
|
809
808
|
}>> & Record<"host_theme_subscribe_stop", Codec<undefined>> & Record<"host_derive_entropy_request", EnumCodec<{
|
|
@@ -873,7 +872,9 @@ export declare const MessagePayload: EnumCodec<Record<"host_handshake_request",
|
|
|
873
872
|
reason: string;
|
|
874
873
|
}, "SigningErr::Unknown"> | import("@novasamatech/scale").CodecError<undefined, "SigningErr::PermissionDenied"> | import("@novasamatech/scale").CodecError<undefined, "SigningErr::FailedToDecode">>>;
|
|
875
874
|
}>> & Record<"host_payment_balance_subscribe_start", EnumCodec<{
|
|
876
|
-
readonly v1: Codec<
|
|
875
|
+
readonly v1: Codec<{
|
|
876
|
+
purse: number | undefined;
|
|
877
|
+
}>;
|
|
877
878
|
}>> & Record<"host_payment_balance_subscribe_receive", EnumCodec<{
|
|
878
879
|
readonly v1: Codec<{
|
|
879
880
|
available: bigint;
|
|
@@ -902,6 +903,7 @@ export declare const MessagePayload: EnumCodec<Record<"host_handshake_request",
|
|
|
902
903
|
};
|
|
903
904
|
}>> & Record<"host_payment_balance_subscribe_stop", Codec<undefined>> & Record<"host_payment_top_up_request", EnumCodec<{
|
|
904
905
|
readonly v1: Codec<{
|
|
906
|
+
into: number | undefined;
|
|
905
907
|
amount: bigint;
|
|
906
908
|
source: {
|
|
907
909
|
tag: "ProductAccount";
|
|
@@ -917,6 +919,7 @@ export declare const MessagePayload: EnumCodec<Record<"host_handshake_request",
|
|
|
917
919
|
}, "PaymentTopUpErr::Unknown"> | import("@novasamatech/scale").CodecError<undefined, "PaymentTopUpErr::InsufficientFunds"> | import("@novasamatech/scale").CodecError<undefined, "PaymentTopUpErr::InvalidSource">>>;
|
|
918
920
|
}>> & Record<"host_payment_request_request", EnumCodec<{
|
|
919
921
|
readonly v1: Codec<{
|
|
922
|
+
from: number | undefined;
|
|
920
923
|
amount: bigint;
|
|
921
924
|
destination: Uint8Array<ArrayBufferLike>;
|
|
922
925
|
}>;
|
|
@@ -966,7 +969,7 @@ export declare const MessagePayload: EnumCodec<Record<"host_handshake_request",
|
|
|
966
969
|
tag: "StatementStoreAllowance";
|
|
967
970
|
value: undefined;
|
|
968
971
|
} | {
|
|
969
|
-
tag: "
|
|
972
|
+
tag: "BulletinAllowance";
|
|
970
973
|
value: undefined;
|
|
971
974
|
} | {
|
|
972
975
|
tag: "SmartContractAllowance";
|
|
@@ -1145,7 +1148,7 @@ export declare const Message: Codec<{
|
|
|
1145
1148
|
tag: "Remote";
|
|
1146
1149
|
value: string[];
|
|
1147
1150
|
} | {
|
|
1148
|
-
tag: "
|
|
1151
|
+
tag: "WebRtc";
|
|
1149
1152
|
value: undefined;
|
|
1150
1153
|
} | {
|
|
1151
1154
|
tag: "ChainSubmit";
|
|
@@ -1868,39 +1871,6 @@ export declare const Message: Codec<{
|
|
|
1868
1871
|
reason: string;
|
|
1869
1872
|
}, "PreimageSubmitErr::Unknown">>;
|
|
1870
1873
|
};
|
|
1871
|
-
} | {
|
|
1872
|
-
tag: "host_jsonrpc_message_send_request";
|
|
1873
|
-
value: {
|
|
1874
|
-
tag: "v1";
|
|
1875
|
-
value: undefined;
|
|
1876
|
-
};
|
|
1877
|
-
} | {
|
|
1878
|
-
tag: "host_jsonrpc_message_send_response";
|
|
1879
|
-
value: {
|
|
1880
|
-
tag: "v1";
|
|
1881
|
-
value: import("scale-ts").ResultPayload<undefined, undefined>;
|
|
1882
|
-
};
|
|
1883
|
-
} | {
|
|
1884
|
-
tag: "host_jsonrpc_message_subscribe_start";
|
|
1885
|
-
value: {
|
|
1886
|
-
tag: "v1";
|
|
1887
|
-
value: undefined;
|
|
1888
|
-
};
|
|
1889
|
-
} | {
|
|
1890
|
-
tag: "host_jsonrpc_message_subscribe_receive";
|
|
1891
|
-
value: {
|
|
1892
|
-
tag: "v1";
|
|
1893
|
-
value: undefined;
|
|
1894
|
-
};
|
|
1895
|
-
} | {
|
|
1896
|
-
tag: "host_jsonrpc_message_subscribe_interrupt";
|
|
1897
|
-
value: {
|
|
1898
|
-
tag: "v1";
|
|
1899
|
-
value: undefined;
|
|
1900
|
-
};
|
|
1901
|
-
} | {
|
|
1902
|
-
tag: "host_jsonrpc_message_subscribe_stop";
|
|
1903
|
-
value: undefined;
|
|
1904
1874
|
} | {
|
|
1905
1875
|
tag: "remote_chain_head_follow_subscribe_start";
|
|
1906
1876
|
value: {
|
|
@@ -2080,7 +2050,7 @@ export declare const Message: Codec<{
|
|
|
2080
2050
|
hash: `0x${string}`;
|
|
2081
2051
|
items: {
|
|
2082
2052
|
key: `0x${string}`;
|
|
2083
|
-
|
|
2053
|
+
queryType: "Value" | "Hash" | "ClosestDescendantMerkleValue" | "DescendantsValues" | "DescendantsHashes";
|
|
2084
2054
|
}[];
|
|
2085
2055
|
childTrie: `0x${string}` | null;
|
|
2086
2056
|
};
|
|
@@ -2269,7 +2239,16 @@ export declare const Message: Codec<{
|
|
|
2269
2239
|
tag: "host_theme_subscribe_receive";
|
|
2270
2240
|
value: {
|
|
2271
2241
|
tag: "v1";
|
|
2272
|
-
value:
|
|
2242
|
+
value: {
|
|
2243
|
+
name: {
|
|
2244
|
+
tag: "Custom";
|
|
2245
|
+
value: string;
|
|
2246
|
+
} | {
|
|
2247
|
+
tag: "Default";
|
|
2248
|
+
value: undefined;
|
|
2249
|
+
};
|
|
2250
|
+
variant: "Light" | "Dark";
|
|
2251
|
+
};
|
|
2273
2252
|
};
|
|
2274
2253
|
} | {
|
|
2275
2254
|
tag: "host_theme_subscribe_interrupt";
|
|
@@ -2390,7 +2369,9 @@ export declare const Message: Codec<{
|
|
|
2390
2369
|
tag: "host_payment_balance_subscribe_start";
|
|
2391
2370
|
value: {
|
|
2392
2371
|
tag: "v1";
|
|
2393
|
-
value:
|
|
2372
|
+
value: {
|
|
2373
|
+
purse: number | undefined;
|
|
2374
|
+
};
|
|
2394
2375
|
};
|
|
2395
2376
|
} | {
|
|
2396
2377
|
tag: "host_payment_balance_subscribe_receive";
|
|
@@ -2416,6 +2397,7 @@ export declare const Message: Codec<{
|
|
|
2416
2397
|
value: {
|
|
2417
2398
|
tag: "v1";
|
|
2418
2399
|
value: {
|
|
2400
|
+
into: number | undefined;
|
|
2419
2401
|
amount: bigint;
|
|
2420
2402
|
source: {
|
|
2421
2403
|
tag: "ProductAccount";
|
|
@@ -2439,6 +2421,7 @@ export declare const Message: Codec<{
|
|
|
2439
2421
|
value: {
|
|
2440
2422
|
tag: "v1";
|
|
2441
2423
|
value: {
|
|
2424
|
+
from: number | undefined;
|
|
2442
2425
|
amount: bigint;
|
|
2443
2426
|
destination: Uint8Array<ArrayBufferLike>;
|
|
2444
2427
|
};
|
|
@@ -2493,7 +2476,7 @@ export declare const Message: Codec<{
|
|
|
2493
2476
|
tag: "StatementStoreAllowance";
|
|
2494
2477
|
value: undefined;
|
|
2495
2478
|
} | {
|
|
2496
|
-
tag: "
|
|
2479
|
+
tag: "BulletinAllowance";
|
|
2497
2480
|
value: undefined;
|
|
2498
2481
|
} | {
|
|
2499
2482
|
tag: "SmartContractAllowance";
|
|
@@ -3,19 +3,29 @@ import { Struct, _void, str } from 'scale-ts';
|
|
|
3
3
|
import { hostApiProtocol } from './impl.js';
|
|
4
4
|
const createPayload = (hostApi) => {
|
|
5
5
|
const fields = {};
|
|
6
|
+
// Serialization index per field, kept positionally in lockstep with `fields`
|
|
7
|
+
// so the on-wire ABI is pinned by each method's explicit base index rather
|
|
8
|
+
// than by object iteration order.
|
|
9
|
+
const indexes = [];
|
|
6
10
|
for (const [method, payload] of Object.entries(hostApi)) {
|
|
7
11
|
if (payload.method === 'request') {
|
|
8
12
|
fields[`${method}_request`] = payload.request;
|
|
13
|
+
indexes.push(payload.index);
|
|
9
14
|
fields[`${method}_response`] = payload.response;
|
|
15
|
+
indexes.push(payload.index + 1);
|
|
10
16
|
}
|
|
11
17
|
if (payload.method === 'subscribe') {
|
|
12
18
|
fields[`${method}_start`] = payload.start;
|
|
19
|
+
indexes.push(payload.index);
|
|
13
20
|
fields[`${method}_stop`] = _void;
|
|
21
|
+
indexes.push(payload.index + 1);
|
|
14
22
|
fields[`${method}_interrupt`] = payload.interrupt;
|
|
23
|
+
indexes.push(payload.index + 2);
|
|
15
24
|
fields[`${method}_receive`] = payload.receive;
|
|
25
|
+
indexes.push(payload.index + 3);
|
|
16
26
|
}
|
|
17
27
|
}
|
|
18
|
-
return Enum(fields);
|
|
28
|
+
return Enum(fields, indexes);
|
|
19
29
|
};
|
|
20
30
|
export const MessagePayload = createPayload(hostApiProtocol);
|
|
21
31
|
export const Message = Struct({
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { describe, expect, it } from 'vitest';
|
|
2
|
+
import { hostApiProtocol } from './impl.js';
|
|
3
|
+
import { MessagePayload } from './messageCodec.js';
|
|
4
|
+
describe('MessagePayload ABI', () => {
|
|
5
|
+
it('declares an explicit base index per method matching contiguous serialization order', () => {
|
|
6
|
+
let next = 0;
|
|
7
|
+
for (const payload of Object.values(hostApiProtocol)) {
|
|
8
|
+
expect(payload.index).toBe(next);
|
|
9
|
+
// requests expand to 2 actions (request/response),
|
|
10
|
+
// subscriptions to 4 (start/stop/interrupt/receive)
|
|
11
|
+
next += payload.method === 'subscribe' ? 4 : 2;
|
|
12
|
+
}
|
|
13
|
+
});
|
|
14
|
+
it('encodes the first action with leading index byte 0', () => {
|
|
15
|
+
const bytes = MessagePayload.enc({ tag: 'host_handshake_request', value: { tag: 'v1', value: 1 } });
|
|
16
|
+
expect(bytes[0]).toBe(0);
|
|
17
|
+
});
|
|
18
|
+
it('encodes the last action with its explicit index byte', () => {
|
|
19
|
+
const bytes = MessagePayload.enc({
|
|
20
|
+
tag: 'host_push_notification_cancel_response',
|
|
21
|
+
value: { tag: 'v1', value: { success: true, value: undefined } },
|
|
22
|
+
});
|
|
23
|
+
expect(bytes[0]).toBe(129);
|
|
24
|
+
});
|
|
25
|
+
it('round-trips an action through its explicit index', () => {
|
|
26
|
+
const value = { tag: 'host_handshake_request', value: { tag: 'v1', value: 7 } };
|
|
27
|
+
expect(MessagePayload.dec(MessagePayload.enc(value))).toEqual(value);
|
|
28
|
+
});
|
|
29
|
+
});
|
|
@@ -17,7 +17,7 @@ export declare const RuntimeType: import("scale-ts").Codec<{
|
|
|
17
17
|
export declare const StorageQueryType: import("scale-ts").Codec<"Value" | "Hash" | "ClosestDescendantMerkleValue" | "DescendantsValues" | "DescendantsHashes">;
|
|
18
18
|
export declare const StorageQueryItem: import("scale-ts").Codec<{
|
|
19
19
|
key: `0x${string}`;
|
|
20
|
-
|
|
20
|
+
queryType: "Value" | "Hash" | "ClosestDescendantMerkleValue" | "DescendantsValues" | "DescendantsHashes";
|
|
21
21
|
}>;
|
|
22
22
|
export declare const StorageResultItem: import("scale-ts").Codec<{
|
|
23
23
|
key: `0x${string}`;
|
|
@@ -273,7 +273,7 @@ export declare const ChainHeadStorageV1_request: import("scale-ts").Codec<{
|
|
|
273
273
|
hash: `0x${string}`;
|
|
274
274
|
items: {
|
|
275
275
|
key: `0x${string}`;
|
|
276
|
-
|
|
276
|
+
queryType: "Value" | "Hash" | "ClosestDescendantMerkleValue" | "DescendantsValues" | "DescendantsHashes";
|
|
277
277
|
}[];
|
|
278
278
|
childTrie: `0x${string}` | null;
|
|
279
279
|
}>;
|
|
@@ -22,7 +22,7 @@ export const RuntimeType = Enum({
|
|
|
22
22
|
export const StorageQueryType = Status('Value', 'Hash', 'ClosestDescendantMerkleValue', 'DescendantsValues', 'DescendantsHashes');
|
|
23
23
|
export const StorageQueryItem = Struct({
|
|
24
24
|
key: Hex(),
|
|
25
|
-
|
|
25
|
+
queryType: StorageQueryType,
|
|
26
26
|
});
|
|
27
27
|
export const StorageResultItem = Struct({
|
|
28
28
|
key: Hex(),
|
|
@@ -2,9 +2,9 @@ import type { Codec, CodecType } from 'scale-ts';
|
|
|
2
2
|
import { _void } from 'scale-ts';
|
|
3
3
|
export declare const Size: Codec<number | bigint>;
|
|
4
4
|
export declare const Dimensions: Codec<[number | bigint, number | bigint, number | bigint | undefined, number | bigint | undefined]>;
|
|
5
|
-
export declare const TypographyStyle: Codec<"
|
|
5
|
+
export declare const TypographyStyle: Codec<"headline.large" | "title.medium.regular" | "body.large.regular" | "body.medium.regular" | "body.small.regular">;
|
|
6
6
|
export declare const ButtonVariant: Codec<"primary" | "secondary" | "text">;
|
|
7
|
-
export declare const ColorToken: Codec<"
|
|
7
|
+
export declare const ColorToken: Codec<"fg.primary" | "fg.secondary" | "fg.tertiary" | "bg.surface.main" | "bg.surface.container" | "bg.surface.nested" | "fg.success" | "fg.error" | "fg.warning">;
|
|
8
8
|
export declare const ContentAlignment: Codec<"topStart" | "topCenter" | "topEnd" | "centerStart" | "center" | "centerEnd" | "bottomStart" | "bottomCenter" | "bottomEnd">;
|
|
9
9
|
export declare const HorizontalAlignment: Codec<"center" | "start" | "end">;
|
|
10
10
|
export declare const VerticalAlignment: Codec<"center" | "top" | "bottom">;
|
|
@@ -18,7 +18,7 @@ export declare const Shape: Codec<{
|
|
|
18
18
|
}>;
|
|
19
19
|
export declare const BorderStyle: Codec<{
|
|
20
20
|
width: number | bigint;
|
|
21
|
-
color: "
|
|
21
|
+
color: "fg.primary" | "fg.secondary" | "fg.tertiary" | "bg.surface.main" | "bg.surface.container" | "bg.surface.nested" | "fg.success" | "fg.error" | "fg.warning";
|
|
22
22
|
shape: {
|
|
23
23
|
tag: "Rounded";
|
|
24
24
|
value: number | bigint;
|
|
@@ -39,7 +39,7 @@ export declare const Modifier: Codec<{
|
|
|
39
39
|
} | {
|
|
40
40
|
tag: "background";
|
|
41
41
|
value: {
|
|
42
|
-
color: "
|
|
42
|
+
color: "fg.primary" | "fg.secondary" | "fg.tertiary" | "bg.surface.main" | "bg.surface.container" | "bg.surface.nested" | "fg.success" | "fg.error" | "fg.warning";
|
|
43
43
|
shape: {
|
|
44
44
|
tag: "Rounded";
|
|
45
45
|
value: number | bigint;
|
|
@@ -52,7 +52,7 @@ export declare const Modifier: Codec<{
|
|
|
52
52
|
tag: "border";
|
|
53
53
|
value: {
|
|
54
54
|
width: number | bigint;
|
|
55
|
-
color: "
|
|
55
|
+
color: "fg.primary" | "fg.secondary" | "fg.tertiary" | "bg.surface.main" | "bg.surface.container" | "bg.surface.nested" | "fg.success" | "fg.error" | "fg.warning";
|
|
56
56
|
shape: {
|
|
57
57
|
tag: "Rounded";
|
|
58
58
|
value: number | bigint;
|
|
@@ -97,7 +97,7 @@ declare function Component<Props extends Codec<any>>(props: Props): Codec<{
|
|
|
97
97
|
} | {
|
|
98
98
|
tag: "background";
|
|
99
99
|
value: {
|
|
100
|
-
color: "
|
|
100
|
+
color: "fg.primary" | "fg.secondary" | "fg.tertiary" | "bg.surface.main" | "bg.surface.container" | "bg.surface.nested" | "fg.success" | "fg.error" | "fg.warning";
|
|
101
101
|
shape: {
|
|
102
102
|
tag: "Rounded";
|
|
103
103
|
value: number | bigint;
|
|
@@ -110,7 +110,7 @@ declare function Component<Props extends Codec<any>>(props: Props): Codec<{
|
|
|
110
110
|
tag: "border";
|
|
111
111
|
value: {
|
|
112
112
|
width: number | bigint;
|
|
113
|
-
color: "
|
|
113
|
+
color: "fg.primary" | "fg.secondary" | "fg.tertiary" | "bg.surface.main" | "bg.surface.container" | "bg.surface.nested" | "fg.success" | "fg.error" | "fg.warning";
|
|
114
114
|
shape: {
|
|
115
115
|
tag: "Rounded";
|
|
116
116
|
value: number | bigint;
|
|
@@ -150,8 +150,8 @@ export declare const RowProps: Codec<{
|
|
|
150
150
|
horizontalArrangement: "center" | "start" | "end" | "spaceBetween" | "spaceAround" | "spaceEvenly" | undefined;
|
|
151
151
|
}>;
|
|
152
152
|
export declare const TextProps: Codec<{
|
|
153
|
-
style: "
|
|
154
|
-
color: "
|
|
153
|
+
style: "headline.large" | "title.medium.regular" | "body.large.regular" | "body.medium.regular" | "body.small.regular" | undefined;
|
|
154
|
+
color: "fg.primary" | "fg.secondary" | "fg.tertiary" | "bg.surface.main" | "bg.surface.container" | "bg.surface.nested" | "fg.success" | "fg.error" | "fg.warning" | undefined;
|
|
155
155
|
}>;
|
|
156
156
|
export declare const ButtonProps: Codec<{
|
|
157
157
|
text: string;
|
|
@@ -2,9 +2,9 @@ import { Enum, OptionBool, Status, lazy } from '@novasamatech/scale';
|
|
|
2
2
|
import { Option, Struct, Tuple, Vector, _void, bool, compact, str } from 'scale-ts';
|
|
3
3
|
export const Size = compact;
|
|
4
4
|
export const Dimensions = Tuple(Size, Size, Option(Size), Option(Size));
|
|
5
|
-
export const TypographyStyle = Status('
|
|
5
|
+
export const TypographyStyle = Status('headline.large', 'title.medium.regular', 'body.large.regular', 'body.medium.regular', 'body.small.regular');
|
|
6
6
|
export const ButtonVariant = Status('primary', 'secondary', 'text');
|
|
7
|
-
export const ColorToken = Status('
|
|
7
|
+
export const ColorToken = Status('fg.primary', 'fg.secondary', 'fg.tertiary', 'bg.surface.main', 'bg.surface.container', 'bg.surface.nested', 'fg.success', 'fg.error', 'fg.warning');
|
|
8
8
|
export const ContentAlignment = Status('topStart', 'topCenter', 'topEnd', 'centerStart', 'center', 'centerEnd', 'bottomStart', 'bottomCenter', 'bottomEnd');
|
|
9
9
|
export const HorizontalAlignment = Status('start', 'center', 'end');
|
|
10
10
|
export const VerticalAlignment = Status('top', 'center', 'bottom');
|
|
@@ -21,7 +21,7 @@ export declare const HandshakeErr: [import("scale-ts").Encoder<import("@novasama
|
|
|
21
21
|
}, "HandshakeErr::Unknown"> | import("@novasamatech/scale").CodecError<undefined, "HandshakeErr::Timeout"> | import("@novasamatech/scale").CodecError<undefined, "HandshakeErr::UnsupportedProtocolVersion">;
|
|
22
22
|
};
|
|
23
23
|
/**
|
|
24
|
-
* HandshakeV1_request = 1 -
|
|
24
|
+
* HandshakeV1_request = 1 - SCALE codec
|
|
25
25
|
*/
|
|
26
26
|
export declare const HandshakeV1_request: import("scale-ts").Codec<number>;
|
|
27
27
|
export declare const HandshakeV1_response: import("scale-ts").Codec<import("scale-ts").ResultPayload<undefined, import("@novasamatech/scale").CodecError<{
|
|
@@ -7,7 +7,7 @@ export const HandshakeErr = ErrEnum('HandshakeErr', {
|
|
|
7
7
|
Unknown: [GenericErr, 'Handshake: unknown error'],
|
|
8
8
|
});
|
|
9
9
|
/**
|
|
10
|
-
* HandshakeV1_request = 1 -
|
|
10
|
+
* HandshakeV1_request = 1 - SCALE codec
|
|
11
11
|
*/
|
|
12
12
|
export const HandshakeV1_request = u8;
|
|
13
13
|
export const HandshakeV1_response = Result(_void, HandshakeErr);
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export declare const Ed25519PrivateKey: import("scale-ts").Codec<Uint8Array<ArrayBufferLike>>;
|
|
2
2
|
export declare const PaymentId: import("scale-ts").Codec<string>;
|
|
3
|
+
export declare const CoinPaymentPurseId: import("scale-ts").Codec<number>;
|
|
3
4
|
export declare const PaymentTopUpSource: import("scale-ts").Codec<{
|
|
4
5
|
tag: "ProductAccount";
|
|
5
6
|
value: number;
|
|
@@ -109,7 +110,9 @@ export declare const PaymentStatusErr: [import("scale-ts").Encoder<import("@nova
|
|
|
109
110
|
reason: string;
|
|
110
111
|
}, "PaymentStatusErr::Unknown"> | import("@novasamatech/scale").CodecError<undefined, "PaymentStatusErr::PaymentNotFound">;
|
|
111
112
|
};
|
|
112
|
-
export declare const PaymentBalanceSubscribeV1_start: import("scale-ts").Codec<
|
|
113
|
+
export declare const PaymentBalanceSubscribeV1_start: import("scale-ts").Codec<{
|
|
114
|
+
purse: number | undefined;
|
|
115
|
+
}>;
|
|
113
116
|
export declare const PaymentBalanceSubscribeV1_receive: import("scale-ts").Codec<{
|
|
114
117
|
available: bigint;
|
|
115
118
|
}>;
|
|
@@ -135,6 +138,7 @@ export declare const PaymentBalanceSubscribeV1_interrupt: [import("scale-ts").En
|
|
|
135
138
|
}, "PaymentBalanceErr::Unknown"> | import("@novasamatech/scale").CodecError<undefined, "PaymentBalanceErr::PermissionDenied">;
|
|
136
139
|
};
|
|
137
140
|
export declare const PaymentTopUpV1_request: import("scale-ts").Codec<{
|
|
141
|
+
into: number | undefined;
|
|
138
142
|
amount: bigint;
|
|
139
143
|
source: {
|
|
140
144
|
tag: "ProductAccount";
|
|
@@ -148,6 +152,7 @@ export declare const PaymentTopUpV1_response: import("scale-ts").Codec<import("s
|
|
|
148
152
|
reason: string;
|
|
149
153
|
}, "PaymentTopUpErr::Unknown"> | import("@novasamatech/scale").CodecError<undefined, "PaymentTopUpErr::InsufficientFunds"> | import("@novasamatech/scale").CodecError<undefined, "PaymentTopUpErr::InvalidSource">>>;
|
|
150
154
|
export declare const PaymentRequestV1_request: import("scale-ts").Codec<{
|
|
155
|
+
from: number | undefined;
|
|
151
156
|
amount: bigint;
|
|
152
157
|
destination: Uint8Array<ArrayBufferLike>;
|
|
153
158
|
}>;
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { Enum, ErrEnum } from '@novasamatech/scale';
|
|
2
|
-
import { Bytes, Result, Struct, _void, str, u128 } from 'scale-ts';
|
|
2
|
+
import { Bytes, Option, Result, Struct, _void, str, u128, u32 } from 'scale-ts';
|
|
3
3
|
import { GenericErr } from '../commonCodecs.js';
|
|
4
4
|
import { DerivationIndex } from './accounts.js';
|
|
5
5
|
// common types
|
|
6
6
|
export const Ed25519PrivateKey = Bytes(32);
|
|
7
7
|
export const PaymentId = str;
|
|
8
|
+
// Optional purse selector (RFC 0017). `undefined` (None) targets MAIN_PURSE.
|
|
9
|
+
export const CoinPaymentPurseId = u32;
|
|
8
10
|
export const PaymentTopUpSource = Enum({
|
|
9
11
|
ProductAccount: DerivationIndex,
|
|
10
12
|
PrivateKey: Ed25519PrivateKey,
|
|
@@ -40,17 +42,21 @@ export const PaymentStatusErr = ErrEnum('PaymentStatusErr', {
|
|
|
40
42
|
Unknown: [GenericErr, 'unknown error'],
|
|
41
43
|
});
|
|
42
44
|
// host_payment_balance_subscribe
|
|
43
|
-
export const PaymentBalanceSubscribeV1_start =
|
|
45
|
+
export const PaymentBalanceSubscribeV1_start = Struct({
|
|
46
|
+
purse: Option(CoinPaymentPurseId),
|
|
47
|
+
});
|
|
44
48
|
export const PaymentBalanceSubscribeV1_receive = PaymentBalance;
|
|
45
49
|
export const PaymentBalanceSubscribeV1_interrupt = PaymentBalanceErr;
|
|
46
50
|
// host_payment_top_up
|
|
47
51
|
export const PaymentTopUpV1_request = Struct({
|
|
52
|
+
into: Option(CoinPaymentPurseId),
|
|
48
53
|
amount: u128,
|
|
49
54
|
source: PaymentTopUpSource,
|
|
50
55
|
});
|
|
51
56
|
export const PaymentTopUpV1_response = Result(_void, PaymentTopUpErr);
|
|
52
57
|
// host_payment_request
|
|
53
58
|
export const PaymentRequestV1_request = Struct({
|
|
59
|
+
from: Option(CoinPaymentPurseId),
|
|
54
60
|
amount: u128,
|
|
55
61
|
destination: Bytes(32),
|
|
56
62
|
});
|
|
@@ -2,7 +2,7 @@ export declare const RemotePermission: import("scale-ts").Codec<{
|
|
|
2
2
|
tag: "Remote";
|
|
3
3
|
value: string[];
|
|
4
4
|
} | {
|
|
5
|
-
tag: "
|
|
5
|
+
tag: "WebRtc";
|
|
6
6
|
value: undefined;
|
|
7
7
|
} | {
|
|
8
8
|
tag: "ChainSubmit";
|
|
@@ -18,7 +18,7 @@ export declare const RemotePermissionV1_request: import("scale-ts").Codec<{
|
|
|
18
18
|
tag: "Remote";
|
|
19
19
|
value: string[];
|
|
20
20
|
} | {
|
|
21
|
-
tag: "
|
|
21
|
+
tag: "WebRtc";
|
|
22
22
|
value: undefined;
|
|
23
23
|
} | {
|
|
24
24
|
tag: "ChainSubmit";
|
|
@@ -3,7 +3,7 @@ import { Result, Vector, _void, bool, str } from 'scale-ts';
|
|
|
3
3
|
import { GenericError } from '../commonCodecs.js';
|
|
4
4
|
export const RemotePermission = Enum({
|
|
5
5
|
Remote: Vector(str),
|
|
6
|
-
|
|
6
|
+
WebRtc: _void,
|
|
7
7
|
ChainSubmit: _void,
|
|
8
8
|
PreimageSubmit: _void,
|
|
9
9
|
StatementSubmit: _void,
|
|
@@ -2,7 +2,7 @@ export declare const AllocatableResource: import("scale-ts").Codec<{
|
|
|
2
2
|
tag: "StatementStoreAllowance";
|
|
3
3
|
value: undefined;
|
|
4
4
|
} | {
|
|
5
|
-
tag: "
|
|
5
|
+
tag: "BulletinAllowance";
|
|
6
6
|
value: undefined;
|
|
7
7
|
} | {
|
|
8
8
|
tag: "SmartContractAllowance";
|
|
@@ -45,7 +45,7 @@ export declare const RequestResourceAllocationV1_request: import("scale-ts").Cod
|
|
|
45
45
|
tag: "StatementStoreAllowance";
|
|
46
46
|
value: undefined;
|
|
47
47
|
} | {
|
|
48
|
-
tag: "
|
|
48
|
+
tag: "BulletinAllowance";
|
|
49
49
|
value: undefined;
|
|
50
50
|
} | {
|
|
51
51
|
tag: "SmartContractAllowance";
|
|
@@ -5,7 +5,7 @@ import { DerivationIndex } from './accounts.js';
|
|
|
5
5
|
// resources requested by a product
|
|
6
6
|
export const AllocatableResource = Enum({
|
|
7
7
|
StatementStoreAllowance: _void,
|
|
8
|
-
|
|
8
|
+
BulletinAllowance: _void,
|
|
9
9
|
SmartContractAllowance: DerivationIndex,
|
|
10
10
|
AutoSigning: _void,
|
|
11
11
|
});
|
|
@@ -1,4 +1,30 @@
|
|
|
1
|
-
export declare const
|
|
1
|
+
export declare const ThemeName: import("scale-ts").Codec<{
|
|
2
|
+
tag: "Custom";
|
|
3
|
+
value: string;
|
|
4
|
+
} | {
|
|
5
|
+
tag: "Default";
|
|
6
|
+
value: undefined;
|
|
7
|
+
}>;
|
|
8
|
+
export declare const ThemeVariant: import("scale-ts").Codec<"Light" | "Dark">;
|
|
9
|
+
export declare const Theme: import("scale-ts").Codec<{
|
|
10
|
+
name: {
|
|
11
|
+
tag: "Custom";
|
|
12
|
+
value: string;
|
|
13
|
+
} | {
|
|
14
|
+
tag: "Default";
|
|
15
|
+
value: undefined;
|
|
16
|
+
};
|
|
17
|
+
variant: "Light" | "Dark";
|
|
18
|
+
}>;
|
|
2
19
|
export declare const ThemeSubscribeV1_start: import("scale-ts").Codec<undefined>;
|
|
3
|
-
export declare const ThemeSubscribeV1_receive: import("scale-ts").Codec<
|
|
20
|
+
export declare const ThemeSubscribeV1_receive: import("scale-ts").Codec<{
|
|
21
|
+
name: {
|
|
22
|
+
tag: "Custom";
|
|
23
|
+
value: string;
|
|
24
|
+
} | {
|
|
25
|
+
tag: "Default";
|
|
26
|
+
value: undefined;
|
|
27
|
+
};
|
|
28
|
+
variant: "Light" | "Dark";
|
|
29
|
+
}>;
|
|
4
30
|
export declare const ThemeSubscribeV1_interrupt: import("scale-ts").Codec<undefined>;
|
|
@@ -1,6 +1,14 @@
|
|
|
1
|
-
import { Status } from '@novasamatech/scale';
|
|
2
|
-
import { _void } from 'scale-ts';
|
|
3
|
-
export const
|
|
1
|
+
import { Enum, Status } from '@novasamatech/scale';
|
|
2
|
+
import { Struct, _void, str } from 'scale-ts';
|
|
3
|
+
export const ThemeName = Enum({
|
|
4
|
+
Custom: str,
|
|
5
|
+
Default: _void,
|
|
6
|
+
});
|
|
7
|
+
export const ThemeVariant = Status('Light', 'Dark');
|
|
8
|
+
export const Theme = Struct({
|
|
9
|
+
name: ThemeName,
|
|
10
|
+
variant: ThemeVariant,
|
|
11
|
+
});
|
|
4
12
|
export const ThemeSubscribeV1_start = _void;
|
|
5
13
|
export const ThemeSubscribeV1_receive = Theme;
|
|
6
14
|
export const ThemeSubscribeV1_interrupt = _void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { describe, expect, it } from 'vitest';
|
|
2
|
+
import { Theme, ThemeName, ThemeVariant } from './theme.js';
|
|
3
|
+
describe('ThemeName', () => {
|
|
4
|
+
it('encodes/decodes the Custom variant with its string payload', () => {
|
|
5
|
+
const value = { tag: 'Custom', value: 'midnight' };
|
|
6
|
+
expect(ThemeName.dec(ThemeName.enc(value))).toEqual(value);
|
|
7
|
+
});
|
|
8
|
+
it('encodes/decodes the Default variant', () => {
|
|
9
|
+
const value = { tag: 'Default', value: undefined };
|
|
10
|
+
expect(ThemeName.dec(ThemeName.enc(value))).toEqual(value);
|
|
11
|
+
});
|
|
12
|
+
it('pins the wire indexes: Custom=0, Default=1', () => {
|
|
13
|
+
// Custom('x'): tag byte 0, then SCALE compact-prefixed string "x"
|
|
14
|
+
expect(ThemeName.enc({ tag: 'Custom', value: 'x' })).toEqual(new Uint8Array([0, 4, 120]));
|
|
15
|
+
expect(ThemeName.enc({ tag: 'Default', value: undefined })).toEqual(new Uint8Array([1]));
|
|
16
|
+
});
|
|
17
|
+
});
|
|
18
|
+
describe('ThemeVariant', () => {
|
|
19
|
+
it('encodes/decodes Light and Dark', () => {
|
|
20
|
+
expect(ThemeVariant.enc('Light')).toEqual(new Uint8Array([0]));
|
|
21
|
+
expect(ThemeVariant.enc('Dark')).toEqual(new Uint8Array([1]));
|
|
22
|
+
expect(ThemeVariant.dec(new Uint8Array([0]))).toEqual('Light');
|
|
23
|
+
expect(ThemeVariant.dec(new Uint8Array([1]))).toEqual('Dark');
|
|
24
|
+
});
|
|
25
|
+
});
|
|
26
|
+
describe('Theme', () => {
|
|
27
|
+
it('round-trips a Default/Light theme', () => {
|
|
28
|
+
const value = { name: { tag: 'Default', value: undefined }, variant: 'Light' };
|
|
29
|
+
expect(Theme.dec(Theme.enc(value))).toEqual(value);
|
|
30
|
+
});
|
|
31
|
+
it('round-trips a Custom/Dark theme and pins its byte layout', () => {
|
|
32
|
+
const value = { name: { tag: 'Custom', value: 'dark' }, variant: 'Dark' };
|
|
33
|
+
// name: Custom(0) + compact(4)=0x10 + "dark"; variant: Dark(1)
|
|
34
|
+
expect(Theme.enc(value)).toEqual(new Uint8Array([0, 16, 100, 97, 114, 107, 1]));
|
|
35
|
+
expect(Theme.dec(Theme.enc(value))).toEqual(value);
|
|
36
|
+
});
|
|
37
|
+
});
|
package/dist/transport.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { enumValue, isEnumVariant, resultErr, resultOk, toHex } from '@novasamatech/scale';
|
|
2
2
|
import { createNanoEvents } from 'nanoevents';
|
|
3
|
-
import { HANDSHAKE_INTERVAL, HANDSHAKE_TIMEOUT,
|
|
3
|
+
import { HANDSHAKE_INTERVAL, HANDSHAKE_TIMEOUT, SCALE_CODEC_PROTOCOL_ID } from './constants.js';
|
|
4
4
|
import { composeAction, createRequestId, delay, promiseWithResolvers } from './helpers.js';
|
|
5
5
|
import { Message, MessagePayload } from './protocol/messageCodec.js';
|
|
6
6
|
import { HandshakeErr } from './protocol/v1/handshake.js';
|
|
@@ -43,7 +43,7 @@ function createMessageProvider(provider) {
|
|
|
43
43
|
};
|
|
44
44
|
}
|
|
45
45
|
export function createTransport(provider) {
|
|
46
|
-
let codecVersion =
|
|
46
|
+
let codecVersion = SCALE_CODEC_PROTOCOL_ID;
|
|
47
47
|
const handshakeAbortController = new AbortController();
|
|
48
48
|
let handshakePromise = null;
|
|
49
49
|
let connectionStatusResolved = false;
|
|
@@ -67,7 +67,7 @@ export function createTransport(provider) {
|
|
|
67
67
|
}
|
|
68
68
|
}
|
|
69
69
|
function throwIfInvalidCodecVersion() {
|
|
70
|
-
if (codecVersion !==
|
|
70
|
+
if (codecVersion !== SCALE_CODEC_PROTOCOL_ID) {
|
|
71
71
|
throw new Error(`Unsupported codec version: ${codecVersion}`);
|
|
72
72
|
}
|
|
73
73
|
}
|
|
@@ -380,7 +380,7 @@ export function createTransport(provider) {
|
|
|
380
380
|
case 'v1': {
|
|
381
381
|
codecVersion = version.value;
|
|
382
382
|
switch (version.value) {
|
|
383
|
-
case
|
|
383
|
+
case SCALE_CODEC_PROTOCOL_ID:
|
|
384
384
|
return enumValue(version.tag, resultOk(undefined));
|
|
385
385
|
default:
|
|
386
386
|
return enumValue(version.tag, resultErr(new HandshakeErr.UnsupportedProtocolVersion(undefined)));
|
package/dist/transport.spec.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { enumValue } from '@novasamatech/scale';
|
|
2
2
|
import { createNanoEvents } from 'nanoevents';
|
|
3
3
|
import { describe, expect, it, vi } from 'vitest';
|
|
4
|
-
import {
|
|
4
|
+
import { SCALE_CODEC_PROTOCOL_ID } from './constants.js';
|
|
5
5
|
import { createDefaultLogger } from './logger.js';
|
|
6
6
|
import { createTransport } from './transport.js';
|
|
7
7
|
function createProviders() {
|
|
@@ -20,7 +20,7 @@ function createProviders() {
|
|
|
20
20
|
sdk: createProvider('toSdk', 'toHost'),
|
|
21
21
|
};
|
|
22
22
|
}
|
|
23
|
-
const samplePayload = () => enumValue('host_handshake_request', enumValue('v1',
|
|
23
|
+
const samplePayload = () => enumValue('host_handshake_request', enumValue('v1', SCALE_CODEC_PROTOCOL_ID));
|
|
24
24
|
describe('transport', () => {
|
|
25
25
|
describe('subscription', () => {
|
|
26
26
|
it('should multiplex subscriptions', () => {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@novasamatech/host-api",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.8.
|
|
4
|
+
"version": "0.8.1",
|
|
5
5
|
"description": "Host API: transport implementation for host - product integration.",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"repository": {
|
|
@@ -22,9 +22,9 @@
|
|
|
22
22
|
"README.md"
|
|
23
23
|
],
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@novasamatech/scale": "0.8.
|
|
25
|
+
"@novasamatech/scale": "0.8.1",
|
|
26
26
|
"nanoevents": "9.1.0",
|
|
27
|
-
"nanoid": "5.1.
|
|
27
|
+
"nanoid": "5.1.11",
|
|
28
28
|
"neverthrow": "^8.2.0",
|
|
29
29
|
"scale-ts": "1.6.1"
|
|
30
30
|
},
|