@novasamatech/host-api 0.5.3-0 → 0.5.4-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.d.ts +3 -2
- package/dist/hostApi.js +65 -42
- package/dist/index.d.ts +5 -5
- package/dist/index.js +3 -4
- package/dist/protocol/impl.d.ts +19 -11
- package/dist/protocol/impl.js +20 -12
- package/dist/protocol/messageCodec.d.ts +469 -199
- package/dist/protocol/v1/chat.d.ts +209 -74
- package/dist/protocol/v1/chat.js +49 -11
- package/dist/protocol/v1/createTransaction.d.ts +7 -6
- package/dist/protocol/v1/createTransaction.js +5 -4
- package/dist/protocol/v1/sign.d.ts +7 -6
- package/dist/protocol/v1/sign.js +4 -3
- package/dist/protocol/v1/statementStore.d.ts +139 -0
- package/dist/protocol/v1/statementStore.js +17 -1
- package/dist/protocol/v1/storage.d.ts +4 -4
- package/dist/protocol/v1/storage.js +3 -3
- package/dist/types.d.ts +6 -4
- package/package.json +2 -1
|
@@ -34,6 +34,109 @@ export declare const Statement: import("scale-ts").Codec<{
|
|
|
34
34
|
topics: Uint8Array<ArrayBufferLike>[];
|
|
35
35
|
data: Uint8Array<ArrayBufferLike> | undefined;
|
|
36
36
|
}>;
|
|
37
|
+
export declare const SignedStatement: import("scale-ts").Codec<{
|
|
38
|
+
proof: {
|
|
39
|
+
tag: "Sr25519";
|
|
40
|
+
value: {
|
|
41
|
+
signature: Uint8Array<ArrayBufferLike>;
|
|
42
|
+
signer: Uint8Array<ArrayBufferLike>;
|
|
43
|
+
};
|
|
44
|
+
} | {
|
|
45
|
+
tag: "Ed25519";
|
|
46
|
+
value: {
|
|
47
|
+
signature: Uint8Array<ArrayBufferLike>;
|
|
48
|
+
signer: Uint8Array<ArrayBufferLike>;
|
|
49
|
+
};
|
|
50
|
+
} | {
|
|
51
|
+
tag: "Ecdsa";
|
|
52
|
+
value: {
|
|
53
|
+
signature: Uint8Array<ArrayBufferLike>;
|
|
54
|
+
signer: Uint8Array<ArrayBufferLike>;
|
|
55
|
+
};
|
|
56
|
+
} | {
|
|
57
|
+
tag: "OnChain";
|
|
58
|
+
value: {
|
|
59
|
+
who: Uint8Array<ArrayBufferLike>;
|
|
60
|
+
blockHash: Uint8Array<ArrayBufferLike>;
|
|
61
|
+
event: bigint;
|
|
62
|
+
};
|
|
63
|
+
};
|
|
64
|
+
decryptionKey: Uint8Array<ArrayBufferLike> | undefined;
|
|
65
|
+
priority: number | undefined;
|
|
66
|
+
channel: Uint8Array<ArrayBufferLike> | undefined;
|
|
67
|
+
topics: Uint8Array<ArrayBufferLike>[];
|
|
68
|
+
data: Uint8Array<ArrayBufferLike> | undefined;
|
|
69
|
+
}>;
|
|
70
|
+
export declare const StatementStoreQueryV1_request: import("scale-ts").Codec<Uint8Array<ArrayBufferLike>[]>;
|
|
71
|
+
export declare const StatementStoreQueryV1_response: import("scale-ts").Codec<import("scale-ts").ResultPayload<{
|
|
72
|
+
proof: {
|
|
73
|
+
tag: "Sr25519";
|
|
74
|
+
value: {
|
|
75
|
+
signature: Uint8Array<ArrayBufferLike>;
|
|
76
|
+
signer: Uint8Array<ArrayBufferLike>;
|
|
77
|
+
};
|
|
78
|
+
} | {
|
|
79
|
+
tag: "Ed25519";
|
|
80
|
+
value: {
|
|
81
|
+
signature: Uint8Array<ArrayBufferLike>;
|
|
82
|
+
signer: Uint8Array<ArrayBufferLike>;
|
|
83
|
+
};
|
|
84
|
+
} | {
|
|
85
|
+
tag: "Ecdsa";
|
|
86
|
+
value: {
|
|
87
|
+
signature: Uint8Array<ArrayBufferLike>;
|
|
88
|
+
signer: Uint8Array<ArrayBufferLike>;
|
|
89
|
+
};
|
|
90
|
+
} | {
|
|
91
|
+
tag: "OnChain";
|
|
92
|
+
value: {
|
|
93
|
+
who: Uint8Array<ArrayBufferLike>;
|
|
94
|
+
blockHash: Uint8Array<ArrayBufferLike>;
|
|
95
|
+
event: bigint;
|
|
96
|
+
};
|
|
97
|
+
};
|
|
98
|
+
decryptionKey: Uint8Array<ArrayBufferLike> | undefined;
|
|
99
|
+
priority: number | undefined;
|
|
100
|
+
channel: Uint8Array<ArrayBufferLike> | undefined;
|
|
101
|
+
topics: Uint8Array<ArrayBufferLike>[];
|
|
102
|
+
data: Uint8Array<ArrayBufferLike> | undefined;
|
|
103
|
+
}[], import("@novasamatech/scale").CodecError<{
|
|
104
|
+
reason: string;
|
|
105
|
+
}, "GenericError">>>;
|
|
106
|
+
export declare const StatementStoreSubscribeV1_start: import("scale-ts").Codec<Uint8Array<ArrayBufferLike>[]>;
|
|
107
|
+
export declare const StatementStoreSubscribeV1_receive: import("scale-ts").Codec<{
|
|
108
|
+
proof: {
|
|
109
|
+
tag: "Sr25519";
|
|
110
|
+
value: {
|
|
111
|
+
signature: Uint8Array<ArrayBufferLike>;
|
|
112
|
+
signer: Uint8Array<ArrayBufferLike>;
|
|
113
|
+
};
|
|
114
|
+
} | {
|
|
115
|
+
tag: "Ed25519";
|
|
116
|
+
value: {
|
|
117
|
+
signature: Uint8Array<ArrayBufferLike>;
|
|
118
|
+
signer: Uint8Array<ArrayBufferLike>;
|
|
119
|
+
};
|
|
120
|
+
} | {
|
|
121
|
+
tag: "Ecdsa";
|
|
122
|
+
value: {
|
|
123
|
+
signature: Uint8Array<ArrayBufferLike>;
|
|
124
|
+
signer: Uint8Array<ArrayBufferLike>;
|
|
125
|
+
};
|
|
126
|
+
} | {
|
|
127
|
+
tag: "OnChain";
|
|
128
|
+
value: {
|
|
129
|
+
who: Uint8Array<ArrayBufferLike>;
|
|
130
|
+
blockHash: Uint8Array<ArrayBufferLike>;
|
|
131
|
+
event: bigint;
|
|
132
|
+
};
|
|
133
|
+
};
|
|
134
|
+
decryptionKey: Uint8Array<ArrayBufferLike> | undefined;
|
|
135
|
+
priority: number | undefined;
|
|
136
|
+
channel: Uint8Array<ArrayBufferLike> | undefined;
|
|
137
|
+
topics: Uint8Array<ArrayBufferLike>[];
|
|
138
|
+
data: Uint8Array<ArrayBufferLike> | undefined;
|
|
139
|
+
}[]>;
|
|
37
140
|
export declare const StatementProofErr: [import("scale-ts").Encoder<import("@novasamatech/scale").CodecError<{
|
|
38
141
|
reason: string;
|
|
39
142
|
}, "StatementProofErr::Unknown"> | import("@novasamatech/scale").CodecError<undefined, "StatementProofErr::UnableToSign"> | import("@novasamatech/scale").CodecError<undefined, "StatementProofErr::UnknownAccount">>, import("scale-ts").Decoder<import("@novasamatech/scale").CodecError<{
|
|
@@ -113,3 +216,39 @@ export declare const StatementStoreCreateProofV1_response: import("scale-ts").Co
|
|
|
113
216
|
}, import("@novasamatech/scale").CodecError<{
|
|
114
217
|
reason: string;
|
|
115
218
|
}, "StatementProofErr::Unknown"> | import("@novasamatech/scale").CodecError<undefined, "StatementProofErr::UnableToSign"> | import("@novasamatech/scale").CodecError<undefined, "StatementProofErr::UnknownAccount">>>;
|
|
219
|
+
export declare const StatementStoreSubmitV1_request: import("scale-ts").Codec<{
|
|
220
|
+
proof: {
|
|
221
|
+
tag: "Sr25519";
|
|
222
|
+
value: {
|
|
223
|
+
signature: Uint8Array<ArrayBufferLike>;
|
|
224
|
+
signer: Uint8Array<ArrayBufferLike>;
|
|
225
|
+
};
|
|
226
|
+
} | {
|
|
227
|
+
tag: "Ed25519";
|
|
228
|
+
value: {
|
|
229
|
+
signature: Uint8Array<ArrayBufferLike>;
|
|
230
|
+
signer: Uint8Array<ArrayBufferLike>;
|
|
231
|
+
};
|
|
232
|
+
} | {
|
|
233
|
+
tag: "Ecdsa";
|
|
234
|
+
value: {
|
|
235
|
+
signature: Uint8Array<ArrayBufferLike>;
|
|
236
|
+
signer: Uint8Array<ArrayBufferLike>;
|
|
237
|
+
};
|
|
238
|
+
} | {
|
|
239
|
+
tag: "OnChain";
|
|
240
|
+
value: {
|
|
241
|
+
who: Uint8Array<ArrayBufferLike>;
|
|
242
|
+
blockHash: Uint8Array<ArrayBufferLike>;
|
|
243
|
+
event: bigint;
|
|
244
|
+
};
|
|
245
|
+
};
|
|
246
|
+
decryptionKey: Uint8Array<ArrayBufferLike> | undefined;
|
|
247
|
+
priority: number | undefined;
|
|
248
|
+
channel: Uint8Array<ArrayBufferLike> | undefined;
|
|
249
|
+
topics: Uint8Array<ArrayBufferLike>[];
|
|
250
|
+
data: Uint8Array<ArrayBufferLike> | undefined;
|
|
251
|
+
}>;
|
|
252
|
+
export declare const StatementStoreSubmitV1_response: import("scale-ts").Codec<import("scale-ts").ResultPayload<undefined, import("@novasamatech/scale").CodecError<{
|
|
253
|
+
reason: string;
|
|
254
|
+
}, "GenericError">>>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Enum, ErrEnum } from '@novasamatech/scale';
|
|
2
2
|
import { Bytes, Option, Result, Struct, Tuple, Vector, _void, u32, u64 } from 'scale-ts';
|
|
3
|
-
import { GenericErr } from '../commonCodecs.js';
|
|
3
|
+
import { GenericErr, GenericError } from '../commonCodecs.js';
|
|
4
4
|
import { ProductAccountId } from './accounts.js';
|
|
5
5
|
// structs definition
|
|
6
6
|
export const Topic = Bytes(32);
|
|
@@ -38,6 +38,19 @@ export const Statement = Struct({
|
|
|
38
38
|
topics: Vector(Topic),
|
|
39
39
|
data: Option(Bytes()),
|
|
40
40
|
});
|
|
41
|
+
export const SignedStatement = Struct({
|
|
42
|
+
proof: StatementProof,
|
|
43
|
+
decryptionKey: Option(DecryptionKey),
|
|
44
|
+
priority: Option(u32),
|
|
45
|
+
channel: Option(Channel),
|
|
46
|
+
topics: Vector(Topic),
|
|
47
|
+
data: Option(Bytes()),
|
|
48
|
+
});
|
|
49
|
+
// query
|
|
50
|
+
export const StatementStoreQueryV1_request = Vector(Topic);
|
|
51
|
+
export const StatementStoreQueryV1_response = Result(Vector(SignedStatement), GenericError);
|
|
52
|
+
export const StatementStoreSubscribeV1_start = Vector(Topic);
|
|
53
|
+
export const StatementStoreSubscribeV1_receive = Vector(SignedStatement);
|
|
41
54
|
// creating proof
|
|
42
55
|
export const StatementProofErr = ErrEnum('StatementProofErr', {
|
|
43
56
|
UnableToSign: [_void, 'StatementProof: unable to sign'],
|
|
@@ -46,3 +59,6 @@ export const StatementProofErr = ErrEnum('StatementProofErr', {
|
|
|
46
59
|
});
|
|
47
60
|
export const StatementStoreCreateProofV1_request = Tuple(ProductAccountId, Statement);
|
|
48
61
|
export const StatementStoreCreateProofV1_response = Result(StatementProof, StatementProofErr);
|
|
62
|
+
// submit
|
|
63
|
+
export const StatementStoreSubmitV1_request = SignedStatement;
|
|
64
|
+
export const StatementStoreSubmitV1_response = Result(_void, GenericError);
|
|
@@ -15,17 +15,17 @@ export declare const StorageErr: [import("scale-ts").Encoder<import("@novasamate
|
|
|
15
15
|
reason: string;
|
|
16
16
|
}, "StorageErr::Unknown">;
|
|
17
17
|
};
|
|
18
|
-
export declare const StorageKey: import("scale-ts").Codec
|
|
18
|
+
export declare const StorageKey: import("scale-ts").Codec<string>;
|
|
19
19
|
export declare const StorageValue: import("scale-ts").Codec<Uint8Array<ArrayBufferLike>>;
|
|
20
|
-
export declare const StorageReadV1_request: import("scale-ts").Codec
|
|
20
|
+
export declare const StorageReadV1_request: import("scale-ts").Codec<string>;
|
|
21
21
|
export declare const StorageReadV1_response: import("scale-ts").Codec<import("scale-ts").ResultPayload<Uint8Array<ArrayBufferLike> | undefined, import("@novasamatech/scale").CodecError<{
|
|
22
22
|
reason: string;
|
|
23
23
|
}, "StorageErr::Unknown"> | import("@novasamatech/scale").CodecError<undefined, "StorageErr::Full">>>;
|
|
24
|
-
export declare const StorageWriteV1_request: import("scale-ts").Codec<[
|
|
24
|
+
export declare const StorageWriteV1_request: import("scale-ts").Codec<[string, Uint8Array<ArrayBufferLike>]>;
|
|
25
25
|
export declare const StorageWriteV1_response: import("scale-ts").Codec<import("scale-ts").ResultPayload<undefined, import("@novasamatech/scale").CodecError<{
|
|
26
26
|
reason: string;
|
|
27
27
|
}, "StorageErr::Unknown"> | import("@novasamatech/scale").CodecError<undefined, "StorageErr::Full">>>;
|
|
28
|
-
export declare const StorageClearV1_request: import("scale-ts").Codec
|
|
28
|
+
export declare const StorageClearV1_request: import("scale-ts").Codec<string>;
|
|
29
29
|
export declare const StorageClearV1_response: import("scale-ts").Codec<import("scale-ts").ResultPayload<undefined, import("@novasamatech/scale").CodecError<{
|
|
30
30
|
reason: string;
|
|
31
31
|
}, "StorageErr::Unknown"> | import("@novasamatech/scale").CodecError<undefined, "StorageErr::Full">>>;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { ErrEnum
|
|
2
|
-
import { Bytes, Option, Result, Tuple, _void } from 'scale-ts';
|
|
1
|
+
import { ErrEnum } from '@novasamatech/scale';
|
|
2
|
+
import { Bytes, Option, Result, Tuple, _void, str } from 'scale-ts';
|
|
3
3
|
import { GenericErr } from '../commonCodecs.js';
|
|
4
4
|
// common structures
|
|
5
5
|
export const StorageErr = ErrEnum('StorageErr', {
|
|
6
6
|
Full: [_void, 'Storage is full'],
|
|
7
7
|
Unknown: [GenericErr, 'Unknown storage error'],
|
|
8
8
|
});
|
|
9
|
-
export const StorageKey =
|
|
9
|
+
export const StorageKey = str;
|
|
10
10
|
export const StorageValue = Bytes();
|
|
11
11
|
// actions
|
|
12
12
|
export const StorageReadV1_request = StorageKey;
|
package/dist/types.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
import type { HostApiProtocol } from './protocol/impl.js';
|
|
1
2
|
import type { ComposeMessageAction, MessageAction, MessagePayloadSchema, PickMessagePayload, PickMessagePayloadValue } from './protocol/messageCodec.js';
|
|
2
3
|
import type { Provider } from './provider.js';
|
|
4
|
+
export type HostApiMethod = keyof HostApiProtocol;
|
|
3
5
|
export type Logger = Record<'info' | 'warn' | 'error' | 'log', (...args: unknown[]) => void>;
|
|
4
6
|
export type ConnectionStatus = 'connecting' | 'connected' | 'disconnected';
|
|
5
7
|
export type RequestHandler<Method extends string> = (message: PickMessagePayloadValue<ComposeMessageAction<Method, 'request'>>) => PromiseLike<PickMessagePayloadValue<ComposeMessageAction<Method, 'response'>>>;
|
|
@@ -14,10 +16,10 @@ export type Transport = {
|
|
|
14
16
|
isReady(): Promise<boolean>;
|
|
15
17
|
onConnectionStatusChange(callback: (status: ConnectionStatus) => void): VoidFunction;
|
|
16
18
|
dispose(): void;
|
|
17
|
-
request<const Method extends
|
|
18
|
-
handleRequest<const Method extends
|
|
19
|
-
subscribe<const Method extends
|
|
20
|
-
handleSubscription<const Method extends
|
|
19
|
+
request<const Method extends HostApiMethod>(method: Method, payload: PickMessagePayloadValue<ComposeMessageAction<Method, 'request'>>, signal?: AbortSignal): Promise<PickMessagePayloadValue<ComposeMessageAction<Method, 'response'>>>;
|
|
20
|
+
handleRequest<const Method extends HostApiMethod>(method: Method, handler: RequestHandler<Method>): VoidFunction;
|
|
21
|
+
subscribe<const Method extends HostApiMethod>(method: Method, payload: PickMessagePayloadValue<ComposeMessageAction<Method, 'start'>>, callback: (payload: PickMessagePayloadValue<ComposeMessageAction<Method, 'receive'>>) => void): Subscription;
|
|
22
|
+
handleSubscription<const Method extends HostApiMethod>(method: Method, handler: SubscriptionHandler<Method>): VoidFunction;
|
|
21
23
|
postMessage(requestId: string, payload: MessagePayloadSchema): void;
|
|
22
24
|
listenMessages<const Action extends MessageAction>(action: Action, callback: (requestId: string, data: PickMessagePayload<Action>) => void, onError?: (error: unknown) => void): VoidFunction;
|
|
23
25
|
};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@novasamatech/host-api",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.5.
|
|
4
|
+
"version": "0.5.4-0",
|
|
5
5
|
"description": "Host API: transport implementation for host - product integration.",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"repository": {
|
|
@@ -21,6 +21,7 @@
|
|
|
21
21
|
"README.md"
|
|
22
22
|
],
|
|
23
23
|
"dependencies": {
|
|
24
|
+
"@novasamatech/scale": "0.5.4-0",
|
|
24
25
|
"@polkadot-api/utils": "^0.2.0",
|
|
25
26
|
"nanoevents": "9.1.0",
|
|
26
27
|
"nanoid": "5.1.6",
|