@novasamatech/product-sdk 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 CHANGED
@@ -1,449 +1 @@
1
- export declare const hostApi: {
2
- handshake: (args: {
3
- tag: "v1";
4
- value: number;
5
- }) => import("neverthrow").ResultAsync<{
6
- tag: "v1";
7
- value: undefined;
8
- }, {
9
- tag: "v1";
10
- value: import("packages/scale/dist/err.js").CodecError<{
11
- reason: string;
12
- }, "HandshakeErr::Unknown"> | import("packages/scale/dist/err.js").CodecError<undefined, "HandshakeErr::Timeout"> | import("packages/scale/dist/err.js").CodecError<undefined, "HandshakeErr::UnsupportedProtocolVersion">;
13
- }>;
14
- feature: (args: {
15
- tag: "v1";
16
- value: {
17
- tag: "Chain";
18
- value: `0x${string}`;
19
- };
20
- }) => import("neverthrow").ResultAsync<{
21
- tag: "v1";
22
- value: boolean;
23
- }, {
24
- tag: "v1";
25
- value: import("packages/scale/dist/err.js").CodecError<{
26
- reason: string;
27
- }, "GenericError">;
28
- }>;
29
- permission_request: (args: {
30
- tag: "v1";
31
- value: {
32
- tag: "ChainSubmit";
33
- value: `0x${string}`;
34
- } | {
35
- tag: "ChainConnect";
36
- value: {
37
- genesisHash: `0x${string}`;
38
- name: string;
39
- };
40
- } | {
41
- tag: "NetworkRequest";
42
- value: string[];
43
- };
44
- }) => import("neverthrow").ResultAsync<{
45
- tag: "v1";
46
- value: undefined;
47
- }, {
48
- tag: "v1";
49
- value: import("packages/scale/dist/err.js").CodecError<undefined, "PermissionErr::Rejected"> | import("packages/scale/dist/err.js").CodecError<{
50
- reason: string;
51
- }, "PermissionErr::Unknown">;
52
- }>;
53
- storage_read: (args: {
54
- tag: "v1";
55
- value: `0x${string}`;
56
- }) => import("neverthrow").ResultAsync<{
57
- tag: "v1";
58
- value: Uint8Array<ArrayBufferLike> | undefined;
59
- }, {
60
- tag: "v1";
61
- value: import("packages/scale/dist/err.js").CodecError<{
62
- reason: string;
63
- }, "StorageErr::Unknown"> | import("packages/scale/dist/err.js").CodecError<undefined, "StorageErr::Full">;
64
- }>;
65
- storage_write: (args: {
66
- tag: "v1";
67
- value: [`0x${string}`, Uint8Array<ArrayBufferLike>];
68
- }) => import("neverthrow").ResultAsync<{
69
- tag: "v1";
70
- value: undefined;
71
- }, {
72
- tag: "v1";
73
- value: import("packages/scale/dist/err.js").CodecError<undefined, "StorageErr::Full"> | import("packages/scale/dist/err.js").CodecError<{
74
- reason: string;
75
- }, "StorageErr::Unknown">;
76
- }>;
77
- storage_clear: (args: {
78
- tag: "v1";
79
- value: `0x${string}`;
80
- }) => import("neverthrow").ResultAsync<{
81
- tag: "v1";
82
- value: undefined;
83
- }, {
84
- tag: "v1";
85
- value: import("packages/scale/dist/err.js").CodecError<undefined, "StorageErr::Full"> | import("packages/scale/dist/err.js").CodecError<{
86
- reason: string;
87
- }, "StorageErr::Unknown">;
88
- }>;
89
- account_get: (args: {
90
- tag: "v1";
91
- value: [string, number];
92
- }) => import("neverthrow").ResultAsync<{
93
- tag: "v1";
94
- value: {
95
- publicKey: Uint8Array<ArrayBufferLike>;
96
- name: string | undefined;
97
- };
98
- }, {
99
- tag: "v1";
100
- value: import("packages/scale/dist/err.js").CodecError<undefined, "RequestCredentialsErr::NotConnected"> | import("packages/scale/dist/err.js").CodecError<undefined, "RequestCredentialsErr::Rejected"> | import("packages/scale/dist/err.js").CodecError<undefined, "RequestCredentialsErr::DomainNotValid"> | import("packages/scale/dist/err.js").CodecError<{
101
- reason: string;
102
- }, "RequestCredentialsErr::Unknown">;
103
- }>;
104
- account_get_alias: (args: {
105
- tag: "v1";
106
- value: [string, number];
107
- }) => import("neverthrow").ResultAsync<{
108
- tag: "v1";
109
- value: {
110
- context: Uint8Array<ArrayBufferLike>;
111
- alias: Uint8Array<ArrayBufferLike>;
112
- };
113
- }, {
114
- tag: "v1";
115
- value: import("packages/scale/dist/err.js").CodecError<undefined, "RequestCredentialsErr::NotConnected"> | import("packages/scale/dist/err.js").CodecError<undefined, "RequestCredentialsErr::Rejected"> | import("packages/scale/dist/err.js").CodecError<undefined, "RequestCredentialsErr::DomainNotValid"> | import("packages/scale/dist/err.js").CodecError<{
116
- reason: string;
117
- }, "RequestCredentialsErr::Unknown">;
118
- }>;
119
- account_create_proof: (args: {
120
- tag: "v1";
121
- value: [[string, number], {
122
- genesisHash: `0x${string}`;
123
- ringRootHash: `0x${string}`;
124
- hints: {
125
- palletInstance: number | undefined;
126
- } | undefined;
127
- }, Uint8Array<ArrayBufferLike>];
128
- }) => import("neverthrow").ResultAsync<{
129
- tag: "v1";
130
- value: Uint8Array<ArrayBufferLike>;
131
- }, {
132
- tag: "v1";
133
- value: import("packages/scale/dist/err.js").CodecError<undefined, "CreateProofErr::Rejected"> | import("packages/scale/dist/err.js").CodecError<{
134
- reason: string;
135
- }, "CreateProofErr::Unknown"> | import("packages/scale/dist/err.js").CodecError<undefined, "CreateProofErr::RingNotFound">;
136
- }>;
137
- get_non_product_accounts: (args: {
138
- tag: "v1";
139
- value: undefined;
140
- }) => import("neverthrow").ResultAsync<{
141
- tag: "v1";
142
- value: {
143
- publicKey: Uint8Array<ArrayBufferLike>;
144
- name: string | undefined;
145
- }[];
146
- }, {
147
- tag: "v1";
148
- value: import("packages/scale/dist/err.js").CodecError<undefined, "RequestCredentialsErr::NotConnected"> | import("packages/scale/dist/err.js").CodecError<undefined, "RequestCredentialsErr::Rejected"> | import("packages/scale/dist/err.js").CodecError<undefined, "RequestCredentialsErr::DomainNotValid"> | import("packages/scale/dist/err.js").CodecError<{
149
- reason: string;
150
- }, "RequestCredentialsErr::Unknown">;
151
- }>;
152
- create_transaction: (args: {
153
- tag: "v1";
154
- value: [[string, number], import("packages/host-api/dist/protocol/v1/createTransaction.js").TxPayloadV1Public];
155
- }) => import("neverthrow").ResultAsync<{
156
- tag: "v1";
157
- value: Uint8Array<ArrayBufferLike>;
158
- }, {
159
- tag: "v1";
160
- value: import("packages/scale/dist/err.js").CodecError<undefined, "CreateTransactionErr::Rejected"> | import("packages/scale/dist/err.js").CodecError<{
161
- reason: string;
162
- }, "CreateTransactionErr::Unknown"> | import("packages/scale/dist/err.js").CodecError<undefined, "CreateTransactionErr::FailedToDecode"> | import("packages/scale/dist/err.js").CodecError<string, "CreateTransactionErr::NotSupported">;
163
- }>;
164
- create_transaction_with_non_product_account: (args: {
165
- tag: "v1";
166
- value: import("packages/host-api/dist/protocol/v1/createTransaction.js").TxPayloadV1Public;
167
- }) => import("neverthrow").ResultAsync<{
168
- tag: "v1";
169
- value: Uint8Array<ArrayBufferLike>;
170
- }, {
171
- tag: "v1";
172
- value: import("packages/scale/dist/err.js").CodecError<undefined, "CreateTransactionErr::Rejected"> | import("packages/scale/dist/err.js").CodecError<undefined, "CreateTransactionErr::FailedToDecode"> | import("packages/scale/dist/err.js").CodecError<string, "CreateTransactionErr::NotSupported"> | import("packages/scale/dist/err.js").CodecError<{
173
- reason: string;
174
- }, "CreateTransactionErr::Unknown">;
175
- }>;
176
- sign_raw: (args: {
177
- tag: "v1";
178
- value: {
179
- address: string;
180
- data: {
181
- tag: "Bytes";
182
- value: Uint8Array<ArrayBufferLike>;
183
- } | {
184
- tag: "Payload";
185
- value: string;
186
- };
187
- };
188
- }) => import("neverthrow").ResultAsync<{
189
- tag: "v1";
190
- value: {
191
- signature: `0x${string}`;
192
- signedTransaction: `0x${string}` | undefined;
193
- };
194
- }, {
195
- tag: "v1";
196
- value: import("packages/scale/dist/err.js").CodecError<undefined, "SigningErr::Rejected"> | import("packages/scale/dist/err.js").CodecError<{
197
- reason: string;
198
- }, "SigningErr::Unknown"> | import("packages/scale/dist/err.js").CodecError<undefined, "SigningErr::FailedToDecode">;
199
- }>;
200
- sign_payload: (args: {
201
- tag: "v1";
202
- value: {
203
- address: string;
204
- blockHash: `0x${string}`;
205
- blockNumber: `0x${string}`;
206
- era: `0x${string}`;
207
- genesisHash: `0x${string}`;
208
- method: `0x${string}`;
209
- nonce: `0x${string}`;
210
- specVersion: `0x${string}`;
211
- tip: `0x${string}`;
212
- transactionVersion: `0x${string}`;
213
- signedExtensions: string[];
214
- version: number;
215
- assetId: `0x${string}` | undefined;
216
- metadataHash: `0x${string}` | undefined;
217
- mode: number | undefined;
218
- withSignedTransaction: boolean | undefined;
219
- };
220
- }) => import("neverthrow").ResultAsync<{
221
- tag: "v1";
222
- value: {
223
- signature: `0x${string}`;
224
- signedTransaction: `0x${string}` | undefined;
225
- };
226
- }, {
227
- tag: "v1";
228
- value: import("packages/scale/dist/err.js").CodecError<undefined, "SigningErr::Rejected"> | import("packages/scale/dist/err.js").CodecError<undefined, "SigningErr::FailedToDecode"> | import("packages/scale/dist/err.js").CodecError<{
229
- reason: string;
230
- }, "SigningErr::Unknown">;
231
- }>;
232
- chat_create_contact: (args: {
233
- tag: "v1";
234
- value: {
235
- name: string;
236
- icon: string;
237
- };
238
- }) => import("neverthrow").ResultAsync<{
239
- tag: "v1";
240
- value: "New" | "Exists";
241
- }, {
242
- tag: "v1";
243
- value: import("packages/scale/dist/err.js").CodecError<{
244
- reason: string;
245
- }, "ChatContactRegistrationErr::Unknown">;
246
- }>;
247
- chat_post_message: (args: {
248
- tag: "v1";
249
- value: {
250
- tag: "Text";
251
- value: string;
252
- } | {
253
- tag: "RichText";
254
- value: {
255
- text: string | undefined;
256
- media: {
257
- url: string;
258
- }[];
259
- };
260
- } | {
261
- tag: "Actions";
262
- value: {
263
- text: string | undefined;
264
- actions: {
265
- actionId: string;
266
- title: string;
267
- }[];
268
- layout: "Column" | "Grid";
269
- };
270
- } | {
271
- tag: "File";
272
- value: {
273
- url: string;
274
- fileName: string;
275
- mimeType: string;
276
- sizeBytes: bigint;
277
- text: string | undefined;
278
- };
279
- } | {
280
- tag: "Reaction";
281
- value: {
282
- messageId: string;
283
- emoji: string;
284
- };
285
- } | {
286
- tag: "ReactionRemoved";
287
- value: {
288
- messageId: string;
289
- emoji: string;
290
- };
291
- };
292
- }) => import("neverthrow").ResultAsync<{
293
- tag: "v1";
294
- value: {
295
- messageId: string;
296
- };
297
- }, {
298
- tag: "v1";
299
- value: import("packages/scale/dist/err.js").CodecError<{
300
- reason: string;
301
- }, "ChatMessagePostingErr::Unknown"> | import("packages/scale/dist/err.js").CodecError<undefined, "ChatMessagePostingErr::MessageTooLarge">;
302
- }>;
303
- chat_action_subscribe: (args: {
304
- tag: "v1";
305
- value: undefined;
306
- }, callback: (payload: {
307
- tag: "v1";
308
- value: {
309
- tag: "MessagePosted";
310
- value: {
311
- tag: "Text";
312
- value: string;
313
- } | {
314
- tag: "RichText";
315
- value: {
316
- text: string | undefined;
317
- media: {
318
- url: string;
319
- }[];
320
- };
321
- } | {
322
- tag: "Actions";
323
- value: {
324
- text: string | undefined;
325
- actions: {
326
- actionId: string;
327
- title: string;
328
- }[];
329
- layout: "Column" | "Grid";
330
- };
331
- } | {
332
- tag: "File";
333
- value: {
334
- url: string;
335
- fileName: string;
336
- mimeType: string;
337
- sizeBytes: bigint;
338
- text: string | undefined;
339
- };
340
- } | {
341
- tag: "Reaction";
342
- value: {
343
- messageId: string;
344
- emoji: string;
345
- };
346
- } | {
347
- tag: "ReactionRemoved";
348
- value: {
349
- messageId: string;
350
- emoji: string;
351
- };
352
- };
353
- } | {
354
- tag: "ActionTriggered";
355
- value: {
356
- messageId: string;
357
- actionId: string;
358
- };
359
- };
360
- }) => void) => import("packages/host-api/dist/types.js").Subscription;
361
- statement_store_create_proof: (args: {
362
- tag: "v1";
363
- value: [[string, number], {
364
- proof: {
365
- tag: "Sr25519";
366
- value: {
367
- signature: Uint8Array<ArrayBufferLike>;
368
- signer: Uint8Array<ArrayBufferLike>;
369
- };
370
- } | {
371
- tag: "Ed25519";
372
- value: {
373
- signature: Uint8Array<ArrayBufferLike>;
374
- signer: Uint8Array<ArrayBufferLike>;
375
- };
376
- } | {
377
- tag: "Ecdsa";
378
- value: {
379
- signature: Uint8Array<ArrayBufferLike>;
380
- signer: Uint8Array<ArrayBufferLike>;
381
- };
382
- } | {
383
- tag: "OnChain";
384
- value: {
385
- who: Uint8Array<ArrayBufferLike>;
386
- blockHash: Uint8Array<ArrayBufferLike>;
387
- event: bigint;
388
- };
389
- } | undefined;
390
- decryptionKey: Uint8Array<ArrayBufferLike> | undefined;
391
- priority: number | undefined;
392
- channel: Uint8Array<ArrayBufferLike> | undefined;
393
- topics: Uint8Array<ArrayBufferLike>[];
394
- data: Uint8Array<ArrayBufferLike> | undefined;
395
- }];
396
- }) => import("neverthrow").ResultAsync<{
397
- tag: "v1";
398
- value: {
399
- tag: "Sr25519";
400
- value: {
401
- signature: Uint8Array<ArrayBufferLike>;
402
- signer: Uint8Array<ArrayBufferLike>;
403
- };
404
- } | {
405
- tag: "Ed25519";
406
- value: {
407
- signature: Uint8Array<ArrayBufferLike>;
408
- signer: Uint8Array<ArrayBufferLike>;
409
- };
410
- } | {
411
- tag: "Ecdsa";
412
- value: {
413
- signature: Uint8Array<ArrayBufferLike>;
414
- signer: Uint8Array<ArrayBufferLike>;
415
- };
416
- } | {
417
- tag: "OnChain";
418
- value: {
419
- who: Uint8Array<ArrayBufferLike>;
420
- blockHash: Uint8Array<ArrayBufferLike>;
421
- event: bigint;
422
- };
423
- };
424
- }, {
425
- tag: "v1";
426
- value: import("packages/scale/dist/err.js").CodecError<{
427
- reason: string;
428
- }, "StatementProofErr::Unknown"> | import("packages/scale/dist/err.js").CodecError<undefined, "StatementProofErr::UnableToSign"> | import("packages/scale/dist/err.js").CodecError<undefined, "StatementProofErr::UnknownAccount">;
429
- }>;
430
- jsonrpc_message_send: (args: {
431
- tag: "v1";
432
- value: [`0x${string}`, string];
433
- }) => import("neverthrow").ResultAsync<{
434
- tag: "v1";
435
- value: undefined;
436
- }, {
437
- tag: "v1";
438
- value: import("packages/scale/dist/err.js").CodecError<{
439
- reason: string;
440
- }, "GenericError">;
441
- }>;
442
- jsonrpc_message_subscribe: (args: {
443
- tag: "v1";
444
- value: `0x${string}`;
445
- }, callback: (payload: {
446
- tag: "v1";
447
- value: string;
448
- }) => void) => import("packages/host-api/dist/types.js").Subscription;
449
- };
1
+ export declare const hostApi: import("@novasamatech/host-api").HostApi;
package/dist/hostApi.js CHANGED
@@ -1,3 +1,3 @@
1
1
  import { createHostApi } from '@novasamatech/host-api';
2
- import { defaultTransport } from './defaultTransport.js';
3
- export const hostApi = createHostApi(defaultTransport);
2
+ import { sandboxTransport } from './sandboxTransport.js';
3
+ export const hostApi = createHostApi(sandboxTransport);
package/dist/index.d.ts CHANGED
@@ -1,8 +1,12 @@
1
1
  export { SpektrExtensionName, WellKnownChain } from './constants.js';
2
- export { defaultProvider, defaultTransport } from './defaultTransport.js';
2
+ export { sandboxProvider, sandboxTransport } from './sandboxTransport.js';
3
3
  export { hostApi } from './hostApi.js';
4
- export { createMetaProvider, metaProvider } from './createMetaProvider.js';
5
- export { createExtensionEnableFactory, injectSpektrExtension } from './injectSpektrExtension.js';
6
- export { createPapiProvider } from './createPapiProvider.js';
7
- export type { ChatMessage, ReceivedChatAction } from './chat.js';
4
+ export { createMetaProvider, metaProvider } from './metaProvider.js';
5
+ export { createNonProductExtensionEnableFactory, injectSpektrExtension } from './injectWeb3.js';
6
+ export { createPapiProvider } from './papiProvider.js';
7
+ export type { ChatMessageContent, ReceivedChatAction } from './chat.js';
8
8
  export { createChat } from './chat.js';
9
+ export type { ProductAccountId, SignedStatement, Statement, Topic } from './statementStore.js';
10
+ export { createStatementStore } from './statementStore.js';
11
+ export type { ProductAccount } from './accounts.js';
12
+ export { createAccountsProvider } from './accounts.js';
package/dist/index.js CHANGED
@@ -1,7 +1,9 @@
1
1
  export { SpektrExtensionName, WellKnownChain } from './constants.js';
2
- export { defaultProvider, defaultTransport } from './defaultTransport.js';
2
+ export { sandboxProvider, sandboxTransport } from './sandboxTransport.js';
3
3
  export { hostApi } from './hostApi.js';
4
- export { createMetaProvider, metaProvider } from './createMetaProvider.js';
5
- export { createExtensionEnableFactory, injectSpektrExtension } from './injectSpektrExtension.js';
6
- export { createPapiProvider } from './createPapiProvider.js';
4
+ export { createMetaProvider, metaProvider } from './metaProvider.js';
5
+ export { createNonProductExtensionEnableFactory, injectSpektrExtension } from './injectWeb3.js';
6
+ export { createPapiProvider } from './papiProvider.js';
7
7
  export { createChat } from './chat.js';
8
+ export { createStatementStore } from './statementStore.js';
9
+ export { createAccountsProvider } from './accounts.js';
@@ -12,7 +12,7 @@ export async function createExtensionEnableFactory(transport) {
12
12
  const accountId = AccountId();
13
13
  async function enable() {
14
14
  async function getAccounts() {
15
- const response = await hostApi.get_non_product_accounts(enumValue('v1', undefined));
15
+ const response = await hostApi.getNonProductAccounts(enumValue('v1', undefined));
16
16
  return response.match(response => {
17
17
  assertEnumVariant(response, 'v1', UNSUPPORTED_VERSION_ERROR);
18
18
  return response.value.map(account => ({
@@ -51,7 +51,7 @@ export async function createExtensionEnableFactory(transport) {
51
51
  value: raw.data,
52
52
  },
53
53
  };
54
- const response = await hostApi.sign_raw(enumValue('v1', payload));
54
+ const response = await hostApi.signRaw(enumValue('v1', payload));
55
55
  return response.match(response => {
56
56
  assertEnumVariant(response, 'v1', UNSUPPORTED_VERSION_ERROR);
57
57
  return {
@@ -73,7 +73,7 @@ export async function createExtensionEnableFactory(transport) {
73
73
  withSignedTransaction: payload.withSignedTransaction,
74
74
  metadataHash: payload.metadataHash,
75
75
  };
76
- const response = await hostApi.sign_payload(enumValue('v1', codecPayload));
76
+ const response = await hostApi.signPayload(enumValue('v1', codecPayload));
77
77
  return response.match(response => {
78
78
  assertEnumVariant(response, 'v1', UNSUPPORTED_VERSION_ERROR);
79
79
  return {
@@ -87,7 +87,7 @@ export async function createExtensionEnableFactory(transport) {
87
87
  });
88
88
  },
89
89
  async createTransaction(payload) {
90
- const response = await hostApi.create_transaction_with_non_product_account(enumValue('v1', payload));
90
+ const response = await hostApi.createTransactionWithNonProductAccount(enumValue('v1', payload));
91
91
  return response.match(response => {
92
92
  assertEnumVariant(response, 'v1', UNSUPPORTED_VERSION_ERROR);
93
93
  return toHex(response.value);
@@ -0,0 +1,24 @@
1
+ import type { CodecType, HexString, Transport, VersionedPublicTxPayload } from '@novasamatech/host-api';
2
+ import type { InjectedAccounts } from '@polkadot/extension-inject/types';
3
+ import type { SignerPayloadJSON, SignerPayloadRaw, SignerResult } from '@polkadot/types/types/extrinsic';
4
+ interface Signer {
5
+ /**
6
+ * @description signs an extrinsic payload from a serialized form
7
+ */
8
+ signPayload?: (payload: SignerPayloadJSON) => Promise<SignerResult>;
9
+ /**
10
+ * @description signs a raw payload, only the bytes data as supplied
11
+ */
12
+ signRaw?: (raw: SignerPayloadRaw) => Promise<SignerResult>;
13
+ /**
14
+ * @description signs a transaction according to https://github.com/polkadot-js/api/issues/6213
15
+ */
16
+ createTransaction?: (payload: CodecType<typeof VersionedPublicTxPayload>) => Promise<HexString>;
17
+ }
18
+ interface Injected {
19
+ accounts: InjectedAccounts;
20
+ signer: Signer;
21
+ }
22
+ export declare function createNonProductExtensionEnableFactory(transport: Transport): Promise<(() => Promise<Injected>) | null>;
23
+ export declare function injectSpektrExtension(transport?: Transport | null): Promise<boolean>;
24
+ export {};
@@ -0,0 +1,121 @@
1
+ import { assertEnumVariant, createHostApi, enumValue, fromHex, toHex } from '@novasamatech/host-api';
2
+ import { injectExtension } from '@polkadot/extension-inject';
3
+ import { AccountId } from '@polkadot-api/substrate-bindings';
4
+ import { SpektrExtensionName, Version } from './constants.js';
5
+ import { sandboxTransport } from './sandboxTransport.js';
6
+ const UNSUPPORTED_VERSION_ERROR = 'Unsupported message version';
7
+ export async function createNonProductExtensionEnableFactory(transport) {
8
+ const ready = await transport.isReady();
9
+ if (!ready)
10
+ return null;
11
+ const hostApi = createHostApi(transport);
12
+ const accountId = AccountId();
13
+ async function enable() {
14
+ async function getAccounts() {
15
+ const response = await hostApi.getNonProductAccounts(enumValue('v1', undefined));
16
+ return response.match(response => {
17
+ assertEnumVariant(response, 'v1', UNSUPPORTED_VERSION_ERROR);
18
+ return response.value.map(account => ({
19
+ name: account.name,
20
+ address: accountId.dec(account.publicKey),
21
+ type: 'sr25519',
22
+ }));
23
+ }, err => {
24
+ assertEnumVariant(err, 'v1', UNSUPPORTED_VERSION_ERROR);
25
+ throw err.value;
26
+ });
27
+ }
28
+ return {
29
+ accounts: {
30
+ async get() {
31
+ return getAccounts();
32
+ },
33
+ subscribe(callback) {
34
+ getAccounts().then(callback);
35
+ return () => {
36
+ // empty
37
+ };
38
+ },
39
+ },
40
+ signer: {
41
+ async signRaw(raw) {
42
+ const payload = {
43
+ address: raw.address,
44
+ data: raw.type === 'bytes'
45
+ ? {
46
+ tag: 'Bytes',
47
+ value: fromHex(raw.data),
48
+ }
49
+ : {
50
+ tag: 'Payload',
51
+ value: raw.data,
52
+ },
53
+ };
54
+ const response = await hostApi.signRaw(enumValue('v1', payload));
55
+ return response.match(response => {
56
+ assertEnumVariant(response, 'v1', UNSUPPORTED_VERSION_ERROR);
57
+ return {
58
+ id: 0,
59
+ signature: response.value.signature,
60
+ signedTransaction: response.value.signedTransaction,
61
+ };
62
+ }, err => {
63
+ assertEnumVariant(err, 'v1', UNSUPPORTED_VERSION_ERROR);
64
+ throw err.value;
65
+ });
66
+ },
67
+ async signPayload(payload) {
68
+ const codecPayload = {
69
+ ...payload,
70
+ method: payload.method,
71
+ assetId: payload.assetId,
72
+ mode: payload.mode,
73
+ withSignedTransaction: payload.withSignedTransaction,
74
+ metadataHash: payload.metadataHash,
75
+ };
76
+ const response = await hostApi.signPayload(enumValue('v1', codecPayload));
77
+ return response.match(response => {
78
+ assertEnumVariant(response, 'v1', UNSUPPORTED_VERSION_ERROR);
79
+ return {
80
+ id: 0,
81
+ signature: response.value.signature,
82
+ signedTransaction: response.value.signedTransaction,
83
+ };
84
+ }, err => {
85
+ assertEnumVariant(err, 'v1', UNSUPPORTED_VERSION_ERROR);
86
+ throw err.value;
87
+ });
88
+ },
89
+ async createTransaction(payload) {
90
+ const response = await hostApi.createTransactionWithNonProductAccount(enumValue('v1', payload));
91
+ return response.match(response => {
92
+ assertEnumVariant(response, 'v1', UNSUPPORTED_VERSION_ERROR);
93
+ return toHex(response.value);
94
+ }, err => {
95
+ assertEnumVariant(err, 'v1', UNSUPPORTED_VERSION_ERROR);
96
+ throw err.value;
97
+ });
98
+ },
99
+ },
100
+ };
101
+ }
102
+ return enable;
103
+ }
104
+ export async function injectSpektrExtension(transport = sandboxTransport) {
105
+ if (!transport)
106
+ return false;
107
+ try {
108
+ const enable = await createNonProductExtensionEnableFactory(transport);
109
+ if (enable) {
110
+ injectExtension(enable, { name: SpektrExtensionName, version: Version });
111
+ return true;
112
+ }
113
+ else {
114
+ return false;
115
+ }
116
+ }
117
+ catch (e) {
118
+ transport.provider.logger.error('Error injecting extension', e);
119
+ return false;
120
+ }
121
+ }
@@ -0,0 +1,7 @@
1
+ import type { ConnectionStatus, Transport } from '@novasamatech/host-api';
2
+ export declare function createMetaProvider(transport?: Transport): {
3
+ subscribeConnectionStatus(callback: (connectionStatus: ConnectionStatus) => void): VoidFunction;
4
+ };
5
+ export declare const metaProvider: {
6
+ subscribeConnectionStatus(callback: (connectionStatus: ConnectionStatus) => void): VoidFunction;
7
+ };