@parity/product-sdk-host 0.11.0 → 0.12.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/index.d.ts +528 -534
- package/dist/index.js +853 -285
- package/dist/index.js.map +1 -1
- package/package.json +5 -3
- package/src/accounts.ts +544 -0
- package/src/chain-spec.ts +126 -84
- package/src/chain-transaction.ts +107 -78
- package/src/chat.ts +81 -85
- package/src/container.ts +211 -246
- package/src/entropy.ts +63 -25
- package/src/errors.ts +198 -0
- package/src/features.ts +66 -55
- package/src/index.ts +33 -22
- package/src/navigation.ts +50 -49
- package/src/notifications.ts +59 -69
- package/src/papi-provider.ts +673 -0
- package/src/payments.ts +77 -61
- package/src/permissions.ts +107 -105
- package/src/result.ts +56 -0
- package/src/theme.ts +35 -63
- package/src/transport.ts +71 -0
- package/src/truapi.ts +166 -409
- package/src/types.ts +69 -61
package/src/types.ts
CHANGED
|
@@ -3,22 +3,26 @@
|
|
|
3
3
|
/**
|
|
4
4
|
* Public types for the host wrappers.
|
|
5
5
|
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
6
|
+
* The statement-store types are re-exported from `@parity/truapi` so the Parity
|
|
7
|
+
* surface stays in lockstep with the in-house protocol codec types. Their fields
|
|
8
|
+
* are `0x`-prefixed hex strings (`HexString`) and their enums are `{ tag }` unions.
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
11
|
import type {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
12
|
+
ProductAccountId,
|
|
13
|
+
RemoteStatementStoreSubscribeItem,
|
|
14
|
+
SignedStatement,
|
|
15
|
+
Statement,
|
|
16
|
+
StatementProof,
|
|
17
|
+
Topic,
|
|
18
|
+
} from "@parity/truapi";
|
|
19
|
+
|
|
20
|
+
// Statement-store types, re-exported verbatim from `@parity/truapi` (imported
|
|
21
|
+
// above for the local signatures): `Statement` / `SignedStatement` /
|
|
22
|
+
// `StatementProof` / `Topic` / `ProductAccountId`. Their fields are
|
|
23
|
+
// `0x`-prefixed `HexString`s and their enums are `{ tag }` unions; the proof
|
|
24
|
+
// variants cover `Sr25519` / `Ed25519` / `Ecdsa` / `OnChain`.
|
|
25
|
+
export type { ProductAccountId, SignedStatement, Statement, StatementProof, Topic };
|
|
22
26
|
|
|
23
27
|
/**
|
|
24
28
|
* Persistent storage exposed by the host container, including string, JSON
|
|
@@ -27,67 +31,71 @@ import type { Subscription } from "@novasamatech/host-api";
|
|
|
27
31
|
* via {@link getHostLocalStorage} when you need raw host storage without the
|
|
28
32
|
* KV abstraction.
|
|
29
33
|
*
|
|
30
|
-
*
|
|
34
|
+
* Backed by `truApi.localStorage.*` (raw `read`/`write`/`clear` over hex bytes);
|
|
35
|
+
* {@link getHostLocalStorage} adapts that into this richer surface. `readString`
|
|
36
|
+
* resolves to `""` for a missing key and `readJSON`/`readBytes` to
|
|
37
|
+
* `null`/`undefined`.
|
|
31
38
|
*/
|
|
32
|
-
export
|
|
39
|
+
export interface HostLocalStorage {
|
|
40
|
+
/** Read a UTF-8 string value; `""` when the key is absent. */
|
|
41
|
+
readString(key: string): Promise<string>;
|
|
42
|
+
/** Write a UTF-8 string value. */
|
|
43
|
+
writeString(key: string, value: string): Promise<void>;
|
|
44
|
+
/** Read and JSON-parse a value; `null` when the key is absent. */
|
|
45
|
+
readJSON(key: string): Promise<unknown>;
|
|
46
|
+
/** JSON-stringify and write a value. */
|
|
47
|
+
writeJSON(key: string, value: unknown): Promise<void>;
|
|
48
|
+
/** Read raw bytes; `undefined` when the key is absent. */
|
|
49
|
+
readBytes(key: string): Promise<Uint8Array | undefined>;
|
|
50
|
+
/** Write raw bytes. */
|
|
51
|
+
writeBytes(key: string, value: Uint8Array): Promise<void>;
|
|
52
|
+
/** Remove a key. */
|
|
53
|
+
clear(key: string): Promise<void>;
|
|
54
|
+
}
|
|
33
55
|
|
|
34
56
|
/**
|
|
35
|
-
*
|
|
36
|
-
*
|
|
37
|
-
* signature schemes - `Sr25519`, `Ed25519`, `Ecdsa`, and `OnChain` (chain-
|
|
38
|
-
* attestation-based proofs).
|
|
57
|
+
* Topic-based subscription filter. The host delivers statements that match
|
|
58
|
+
* either *all* of the listed topics (`matchAll`) or *any* of them (`matchAny`).
|
|
39
59
|
*
|
|
40
|
-
*
|
|
41
|
-
*
|
|
60
|
+
* This is a field-discriminated form of truapi's `RemoteStatementStoreSubscribeRequest`,
|
|
61
|
+
* which is a tagged union (`{ tag: "MatchAll"; value: Topic[] } | { tag: "MatchAny"; value: Topic[] }`).
|
|
62
|
+
* The transport maps between the two.
|
|
42
63
|
*/
|
|
43
|
-
export type
|
|
44
|
-
ReturnType<ReturnType<typeof createStatementStore>["createProof"]>
|
|
45
|
-
>;
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* Topic-based subscription filter. The host delivers statements that match
|
|
49
|
-
* either *all* of the listed topics (`matchAll`) or *any* of them
|
|
50
|
-
* (`matchAny`). Re-exported from `@novasamatech/host-api-wrapper`.
|
|
51
|
-
*/
|
|
52
|
-
export type StatementTopicFilter = NovasamaStatementTopicFilter;
|
|
53
|
-
|
|
54
|
-
/** A single topic value used inside a {@link StatementTopicFilter}. Re-exported from `@novasamatech/host-api-wrapper`. */
|
|
55
|
-
export type Topic = NovasamaTopic;
|
|
56
|
-
|
|
57
|
-
/** `[ss58Address, chainPrefix]` tuple identifying a product account at the codec layer. Re-exported from `@novasamatech/host-api-wrapper`. */
|
|
58
|
-
export type ProductAccountId = NovasamaProductAccountId;
|
|
59
|
-
|
|
60
|
-
/** Unsigned statement payload. Re-exported from `@novasamatech/host-api-wrapper`. */
|
|
61
|
-
export type Statement = NovasamaStatement;
|
|
62
|
-
|
|
63
|
-
/** Statement bundled with its {@link StatementProof}. Re-exported from `@novasamatech/host-api-wrapper`. */
|
|
64
|
-
export type SignedStatement = NovasamaSignedStatement;
|
|
64
|
+
export type StatementTopicFilter = { matchAll: Topic[] } | { matchAny: Topic[] };
|
|
65
65
|
|
|
66
66
|
/**
|
|
67
67
|
* A page of signed statements delivered by {@link HostStatementStore.subscribe}.
|
|
68
68
|
*
|
|
69
|
-
*
|
|
70
|
-
*
|
|
71
|
-
*
|
|
72
|
-
*
|
|
69
|
+
* truapi's `RemoteStatementStoreSubscribeItem`, re-exported under a friendlier
|
|
70
|
+
* name. Pages arrive sequentially; `isComplete` is `false` while the host
|
|
71
|
+
* streams the historical backfill and `true` once it's done (and on every
|
|
72
|
+
* subsequent live-update page).
|
|
73
73
|
*/
|
|
74
|
-
export type StatementsPage =
|
|
74
|
+
export type StatementsPage = RemoteStatementStoreSubscribeItem;
|
|
75
75
|
|
|
76
76
|
/**
|
|
77
|
-
* Subscription handle returned by the host
|
|
78
|
-
* `
|
|
79
|
-
* `
|
|
80
|
-
* interrupts the subscription server-side.
|
|
77
|
+
* Subscription handle returned by the host. Exposes `unsubscribe()` plus an
|
|
78
|
+
* `onInterrupt` hook that fires if the host interrupts the subscription
|
|
79
|
+
* server-side; `onInterrupt` returns a function that cancels the hook.
|
|
81
80
|
*/
|
|
82
|
-
export
|
|
81
|
+
export interface HostSubscription {
|
|
82
|
+
unsubscribe(): void;
|
|
83
|
+
onInterrupt(callback: (reason?: unknown) => void): () => void;
|
|
84
|
+
}
|
|
83
85
|
|
|
84
86
|
/**
|
|
85
|
-
* Statement Store handle exposed by the host container
|
|
86
|
-
* `
|
|
87
|
-
*
|
|
88
|
-
*
|
|
89
|
-
*
|
|
90
|
-
*
|
|
91
|
-
* `@novasamatech/host-api-wrapper`.
|
|
87
|
+
* Statement Store handle exposed by the host container, backed by
|
|
88
|
+
* `truApi.statementStore.*`. `subscribe` streams matching statements;
|
|
89
|
+
* `createProofAuthorized` signs a statement with the product's RFC-10 allowance
|
|
90
|
+
* account (the sponsored path — no per-call account id); `submit` publishes a
|
|
91
|
+
* signed statement. The `statement-store` package layers a higher-level client
|
|
92
|
+
* on top.
|
|
92
93
|
*/
|
|
93
|
-
export
|
|
94
|
+
export interface HostStatementStore {
|
|
95
|
+
subscribe(
|
|
96
|
+
filter: StatementTopicFilter,
|
|
97
|
+
callback: (page: StatementsPage) => void,
|
|
98
|
+
): HostSubscription;
|
|
99
|
+
createProofAuthorized(statement: Statement): Promise<StatementProof>;
|
|
100
|
+
submit(signedStatement: SignedStatement): Promise<void>;
|
|
101
|
+
}
|