@novasamatech/product-sdk 0.7.1-1 → 0.7.2-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/accounts.d.ts +2 -2
- package/dist/accounts.js +5 -1
- package/dist/chat.d.ts +3 -3
- package/dist/chat.js +11 -3
- package/dist/index.d.ts +1 -1
- package/dist/papiProvider.js +1 -1
- package/dist/payments.d.ts +3 -4
- package/dist/payments.js +6 -2
- package/dist/permission.d.ts +4 -4
- package/dist/permission.js +5 -5
- package/dist/preimage.d.ts +3 -3
- package/dist/preimage.js +5 -1
- package/dist/statementStore.d.ts +2 -2
- package/dist/statementStore.js +5 -1
- package/dist/theme.d.ts +2 -5
- package/dist/theme.js +3 -2
- package/package.json +2 -2
package/dist/accounts.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { AccountConnectionStatus as AccountConnectionStatusCodec, CodecType, Transport } from '@novasamatech/host-api';
|
|
1
|
+
import type { AccountConnectionStatus as AccountConnectionStatusCodec, CodecType, Subscription, Transport } from '@novasamatech/host-api';
|
|
2
2
|
import { RingLocation } from '@novasamatech/host-api';
|
|
3
3
|
import type { PolkadotSigner } from 'polkadot-api';
|
|
4
4
|
export type ProductAccount = {
|
|
@@ -39,6 +39,6 @@ export declare const createAccountsProvider: (transport?: Transport) => {
|
|
|
39
39
|
reason: string;
|
|
40
40
|
}, "CreateProofErr::Unknown"> | import("packages/scale/src/err.js").CodecError<undefined, "CreateProofErr::RingNotFound">>;
|
|
41
41
|
getProductAccountSigner(account: ProductAccount): PolkadotSigner;
|
|
42
|
-
subscribeAccountConnectionStatus(callback: (status: AccountConnectionStatus) => void):
|
|
42
|
+
subscribeAccountConnectionStatus(callback: (status: AccountConnectionStatus) => void): Subscription<void>;
|
|
43
43
|
getLegacyAccountSigner(account: ProductAccount): PolkadotSigner;
|
|
44
44
|
};
|
package/dist/accounts.js
CHANGED
|
@@ -124,11 +124,15 @@ export const createAccountsProvider = (transport = sandboxTransport) => {
|
|
|
124
124
|
});
|
|
125
125
|
},
|
|
126
126
|
subscribeAccountConnectionStatus(callback) {
|
|
127
|
-
|
|
127
|
+
const subscriber = hostApi.accountConnectionStatusSubscribe(enumValue('v1', undefined), status => {
|
|
128
128
|
if (status.tag === 'v1') {
|
|
129
129
|
callback(status.value);
|
|
130
130
|
}
|
|
131
131
|
});
|
|
132
|
+
return {
|
|
133
|
+
unsubscribe: subscriber.unsubscribe,
|
|
134
|
+
onInterrupt: cb => subscriber.onInterrupt(v => cb(v.value)),
|
|
135
|
+
};
|
|
132
136
|
},
|
|
133
137
|
getLegacyAccountSigner(account) {
|
|
134
138
|
return getPolkadotSignerFromPjs(toHex(account.publicKey), async (payload) => {
|
package/dist/chat.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ChatBotRegistrationStatus as ChatBotRegistrationStatusCodec, ChatMessageContent as ChatMessageContentCodec, ChatRoom as ChatRoomCodec, ChatRoomRegistrationStatus as ChatRoomRegistrationStatusCodec, CodecType, ReceivedChatAction as ReceivedChatActionCodec, Transport } from '@novasamatech/host-api';
|
|
1
|
+
import type { ChatBotRegistrationStatus as ChatBotRegistrationStatusCodec, ChatMessageContent as ChatMessageContentCodec, ChatRoom as ChatRoomCodec, ChatRoomRegistrationStatus as ChatRoomRegistrationStatusCodec, CodecType, ReceivedChatAction as ReceivedChatActionCodec, Subscription, Transport } from '@novasamatech/host-api';
|
|
2
2
|
import { CustomRendererNode } from '@novasamatech/host-api';
|
|
3
3
|
export type ChatMessageContent = CodecType<typeof ChatMessageContentCodec>;
|
|
4
4
|
export type ChatReceivedAction = CodecType<typeof ReceivedChatActionCodec>;
|
|
@@ -26,8 +26,8 @@ export declare const createProductChatManager: (transport?: Transport) => {
|
|
|
26
26
|
sendMessage(roomId: string, payload: ChatMessageContent): Promise<{
|
|
27
27
|
messageId: string;
|
|
28
28
|
}>;
|
|
29
|
-
subscribeChatList(callback: (rooms: ChatRoom[]) => void):
|
|
30
|
-
subscribeAction(callback: (action: ChatReceivedAction) => void):
|
|
29
|
+
subscribeChatList(callback: (rooms: ChatRoom[]) => void): Subscription<void>;
|
|
30
|
+
subscribeAction(callback: (action: ChatReceivedAction) => void): Subscription<void>;
|
|
31
31
|
onCustomMessageRenderingRequest(callback: ChatCustomMessageRenderer): VoidFunction;
|
|
32
32
|
};
|
|
33
33
|
export declare function matchChatCustomRenderers(map: Record<string, ChatCustomMessageRenderer>): ChatCustomMessageRenderer;
|
package/dist/chat.js
CHANGED
|
@@ -58,14 +58,18 @@ export const createProductChatManager = (transport = sandboxTransport) => {
|
|
|
58
58
|
});
|
|
59
59
|
},
|
|
60
60
|
subscribeChatList(callback) {
|
|
61
|
-
|
|
61
|
+
const subscriber = hostApi.chatListSubscribe(enumValue('v1', undefined), action => {
|
|
62
62
|
if (action.tag === 'v1') {
|
|
63
63
|
callback(action.value);
|
|
64
64
|
}
|
|
65
65
|
});
|
|
66
|
+
return {
|
|
67
|
+
unsubscribe: subscriber.unsubscribe,
|
|
68
|
+
onInterrupt: cb => subscriber.onInterrupt(v => cb(v.value)),
|
|
69
|
+
};
|
|
66
70
|
},
|
|
67
71
|
subscribeAction(callback) {
|
|
68
|
-
|
|
72
|
+
const subscriber = hostApi.chatActionSubscribe(enumValue('v1', undefined), action => {
|
|
69
73
|
switch (action.tag) {
|
|
70
74
|
case 'v1':
|
|
71
75
|
callback(action.value);
|
|
@@ -74,12 +78,16 @@ export const createProductChatManager = (transport = sandboxTransport) => {
|
|
|
74
78
|
console.error(`Unknown message version ${action.tag}`);
|
|
75
79
|
}
|
|
76
80
|
});
|
|
81
|
+
return {
|
|
82
|
+
unsubscribe: subscriber.unsubscribe,
|
|
83
|
+
onInterrupt: cb => subscriber.onInterrupt(v => cb(v.value)),
|
|
84
|
+
};
|
|
77
85
|
},
|
|
78
86
|
onCustomMessageRenderingRequest(callback) {
|
|
79
87
|
return transport.handleSubscription('product_chat_custom_message_render_subscribe', (params, send, interrupt) => {
|
|
80
88
|
if (params.tag !== 'v1') {
|
|
81
89
|
// unsupported version
|
|
82
|
-
interrupt();
|
|
90
|
+
interrupt(enumValue('v1', undefined));
|
|
83
91
|
return () => {
|
|
84
92
|
/* empty */
|
|
85
93
|
};
|
package/dist/index.d.ts
CHANGED
|
@@ -10,7 +10,7 @@ export type { ProductAccountId, SignedStatement, Statement, StatementTopicFilter
|
|
|
10
10
|
export { createStatementStore } from './statementStore.js';
|
|
11
11
|
export type { AccountConnectionStatus, ProductAccount } from './accounts.js';
|
|
12
12
|
export { createAccountsProvider } from './accounts.js';
|
|
13
|
-
export type { ThemeMode
|
|
13
|
+
export type { ThemeMode } from './theme.js';
|
|
14
14
|
export { createThemeProvider } from './theme.js';
|
|
15
15
|
export { createLocalStorage, hostLocalStorage } from './localStorage.js';
|
|
16
16
|
export { createPreimageManager, preimageManager } from './preimage.js';
|
package/dist/papiProvider.js
CHANGED
|
@@ -152,7 +152,7 @@ __fallback, internal) {
|
|
|
152
152
|
case 'chainHead_v1_follow': {
|
|
153
153
|
const [withRuntime] = params;
|
|
154
154
|
const syntheticSubId = getNextSubId();
|
|
155
|
-
const subscription = hostApi.
|
|
155
|
+
const subscription = hostApi.chainHeadFollowSubscribe(enumValue(version, { genesisHash, withRuntime }), payload => {
|
|
156
156
|
if (payload.tag === version) {
|
|
157
157
|
const jsonRpcEvent = convertTypedEventToJsonRpc(payload.value);
|
|
158
158
|
sendFollowEvent(syntheticSubId, jsonRpcEvent);
|
package/dist/payments.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Subscription, Transport } from '@novasamatech/host-api';
|
|
1
|
+
import type { CodecType, PaymentBalanceErr, Subscription, Transport } from '@novasamatech/host-api';
|
|
2
2
|
export type PaymentBalance = {
|
|
3
3
|
available: bigint;
|
|
4
4
|
};
|
|
@@ -12,14 +12,13 @@ export type PaymentStatus = {
|
|
|
12
12
|
};
|
|
13
13
|
export type TopUpSource = {
|
|
14
14
|
type: 'productAccount';
|
|
15
|
-
dotNsIdentifier: string;
|
|
16
15
|
derivationIndex: number;
|
|
17
16
|
} | {
|
|
18
17
|
type: 'privateKey';
|
|
19
18
|
key: Uint8Array;
|
|
20
19
|
};
|
|
21
20
|
export declare const createPaymentManager: (transport?: Transport) => {
|
|
22
|
-
subscribeBalance(callback: (balance: PaymentBalance) => void): Subscription
|
|
21
|
+
subscribeBalance(callback: (balance: PaymentBalance) => void): Subscription<CodecType<typeof PaymentBalanceErr>>;
|
|
23
22
|
topUp(amount: bigint, source: TopUpSource): Promise<void>;
|
|
24
23
|
requestPayment(amount: bigint, destination: Uint8Array): Promise<{
|
|
25
24
|
id: string;
|
|
@@ -27,7 +26,7 @@ export declare const createPaymentManager: (transport?: Transport) => {
|
|
|
27
26
|
subscribePaymentStatus(id: string, callback: (status: PaymentStatus) => void): Subscription;
|
|
28
27
|
};
|
|
29
28
|
export declare const paymentManager: {
|
|
30
|
-
subscribeBalance(callback: (balance: PaymentBalance) => void): Subscription
|
|
29
|
+
subscribeBalance(callback: (balance: PaymentBalance) => void): Subscription<CodecType<typeof PaymentBalanceErr>>;
|
|
31
30
|
topUp(amount: bigint, source: TopUpSource): Promise<void>;
|
|
32
31
|
requestPayment(amount: bigint, destination: Uint8Array): Promise<{
|
|
33
32
|
id: string;
|
package/dist/payments.js
CHANGED
|
@@ -6,17 +6,21 @@ export const createPaymentManager = (transport = sandboxTransport) => {
|
|
|
6
6
|
const version = 'v1';
|
|
7
7
|
return {
|
|
8
8
|
subscribeBalance(callback) {
|
|
9
|
-
|
|
9
|
+
const subscriber = hostApi.paymentBalanceSubscribe(enumValue(version, undefined), payload => {
|
|
10
10
|
if (payload.tag === version) {
|
|
11
11
|
callback(payload.value);
|
|
12
12
|
}
|
|
13
13
|
});
|
|
14
|
+
return {
|
|
15
|
+
unsubscribe: subscriber.unsubscribe,
|
|
16
|
+
onInterrupt: cb => subscriber.onInterrupt(v => cb(v.value)),
|
|
17
|
+
};
|
|
14
18
|
},
|
|
15
19
|
topUp(amount, source) {
|
|
16
20
|
const sourceCodec = source.type === 'productAccount'
|
|
17
21
|
? {
|
|
18
22
|
tag: 'ProductAccount',
|
|
19
|
-
value:
|
|
23
|
+
value: source.derivationIndex,
|
|
20
24
|
}
|
|
21
25
|
: { tag: 'PrivateKey', value: source.key };
|
|
22
26
|
return resultToPromise(unwrapVersionedResult(version, hostApi.paymentTopUp(enumValue(version, { amount, source: sourceCodec }))));
|
package/dist/permission.d.ts
CHANGED
|
@@ -13,12 +13,12 @@ export declare function requestDevicePermission(permission: DevicePermissionKind
|
|
|
13
13
|
reason: string;
|
|
14
14
|
}, "GenericError">>;
|
|
15
15
|
/**
|
|
16
|
-
* Request
|
|
16
|
+
* Request remote permission from the host.
|
|
17
17
|
* Returns ResultAsync<boolean, GenericError>:
|
|
18
|
-
* - ok(true) —
|
|
19
|
-
* - ok(false) —
|
|
18
|
+
* - ok(true) — permission granted
|
|
19
|
+
* - ok(false) — permission denied by the user
|
|
20
20
|
* - err(...) — transport or encoding error
|
|
21
21
|
*/
|
|
22
|
-
export declare function requestPermission(
|
|
22
|
+
export declare function requestPermission(permission: RemotePermissionItem): import("neverthrow").ResultAsync<boolean, import("packages/scale/src/err.js").CodecError<{
|
|
23
23
|
reason: string;
|
|
24
24
|
}, "GenericError">>;
|
package/dist/permission.js
CHANGED
|
@@ -14,15 +14,15 @@ export function requestDevicePermission(permission) {
|
|
|
14
14
|
.mapErr(e => e.value);
|
|
15
15
|
}
|
|
16
16
|
/**
|
|
17
|
-
* Request
|
|
17
|
+
* Request remote permission from the host.
|
|
18
18
|
* Returns ResultAsync<boolean, GenericError>:
|
|
19
|
-
* - ok(true) —
|
|
20
|
-
* - ok(false) —
|
|
19
|
+
* - ok(true) — permission granted
|
|
20
|
+
* - ok(false) — permission denied by the user
|
|
21
21
|
* - err(...) — transport or encoding error
|
|
22
22
|
*/
|
|
23
|
-
export function requestPermission(
|
|
23
|
+
export function requestPermission(permission) {
|
|
24
24
|
return hostApi
|
|
25
|
-
.permission(enumValue('v1',
|
|
25
|
+
.permission(enumValue('v1', permission))
|
|
26
26
|
.map(r => r.value)
|
|
27
27
|
.mapErr(e => e.value);
|
|
28
28
|
}
|
package/dist/preimage.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import type { HexString } from '@novasamatech/host-api';
|
|
1
|
+
import type { HexString, Subscription } from '@novasamatech/host-api';
|
|
2
2
|
export declare const createPreimageManager: (transport?: import("@novasamatech/host-api").Transport) => {
|
|
3
|
-
lookup(key: HexString, callback: (preimage: Uint8Array | null) => void):
|
|
3
|
+
lookup(key: HexString, callback: (preimage: Uint8Array | null) => void): Subscription<void>;
|
|
4
4
|
submit(value: Uint8Array): Promise<`0x${string}`>;
|
|
5
5
|
};
|
|
6
6
|
export declare const preimageManager: {
|
|
7
|
-
lookup(key: HexString, callback: (preimage: Uint8Array | null) => void):
|
|
7
|
+
lookup(key: HexString, callback: (preimage: Uint8Array | null) => void): Subscription<void>;
|
|
8
8
|
submit(value: Uint8Array): Promise<`0x${string}`>;
|
|
9
9
|
};
|
package/dist/preimage.js
CHANGED
|
@@ -6,11 +6,15 @@ export const createPreimageManager = (transport = sandboxTransport) => {
|
|
|
6
6
|
const hostApi = createHostApi(transport);
|
|
7
7
|
return {
|
|
8
8
|
lookup(key, callback) {
|
|
9
|
-
|
|
9
|
+
const subscriber = hostApi.preimageLookupSubscribe(enumValue(supportedVersion, key), payload => {
|
|
10
10
|
if (payload.tag === supportedVersion) {
|
|
11
11
|
callback(payload.value);
|
|
12
12
|
}
|
|
13
13
|
});
|
|
14
|
+
return {
|
|
15
|
+
unsubscribe: subscriber.unsubscribe,
|
|
16
|
+
onInterrupt: cb => subscriber.onInterrupt(v => cb(v.value)),
|
|
17
|
+
};
|
|
14
18
|
},
|
|
15
19
|
submit(value) {
|
|
16
20
|
return resultToPromise(unwrapVersionedResult(supportedVersion, hostApi.preimageSubmit(enumValue(supportedVersion, value))));
|
package/dist/statementStore.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { CodecType, ProductAccountId as ProductAccountIdCodec, SignedStatement as SignedStatementCodec, Statement as StatementCodec, Topic as TopicCodec, Transport } from '@novasamatech/host-api';
|
|
1
|
+
import type { CodecType, ProductAccountId as ProductAccountIdCodec, SignedStatement as SignedStatementCodec, Statement as StatementCodec, Subscription, Topic as TopicCodec, Transport } from '@novasamatech/host-api';
|
|
2
2
|
export type Statement = CodecType<typeof StatementCodec>;
|
|
3
3
|
export type SignedStatement = CodecType<typeof SignedStatementCodec>;
|
|
4
4
|
export type Topic = CodecType<typeof TopicCodec>;
|
|
@@ -13,7 +13,7 @@ export type StatementsPage = {
|
|
|
13
13
|
isComplete: boolean;
|
|
14
14
|
};
|
|
15
15
|
export declare const createStatementStore: (transport?: Transport) => {
|
|
16
|
-
subscribe(filter: StatementTopicFilter, callback: (page: StatementsPage) => void):
|
|
16
|
+
subscribe(filter: StatementTopicFilter, callback: (page: StatementsPage) => void): Subscription<void>;
|
|
17
17
|
createProof(accountId: ProductAccountId, statement: Statement): Promise<{
|
|
18
18
|
tag: "Sr25519";
|
|
19
19
|
value: {
|
package/dist/statementStore.js
CHANGED
|
@@ -5,11 +5,15 @@ export const createStatementStore = (transport = sandboxTransport) => {
|
|
|
5
5
|
return {
|
|
6
6
|
subscribe(filter, callback) {
|
|
7
7
|
const scaleFilter = 'matchAll' in filter ? enumValue('MatchAll', filter.matchAll) : enumValue('MatchAny', filter.matchAny);
|
|
8
|
-
|
|
8
|
+
const subscriber = hostApi.statementStoreSubscribe(enumValue('v1', scaleFilter), payload => {
|
|
9
9
|
if (payload.tag === 'v1') {
|
|
10
10
|
callback(payload.value);
|
|
11
11
|
}
|
|
12
12
|
});
|
|
13
|
+
return {
|
|
14
|
+
unsubscribe: subscriber.unsubscribe,
|
|
15
|
+
onInterrupt: cb => subscriber.onInterrupt(v => cb(v.value)),
|
|
16
|
+
};
|
|
13
17
|
},
|
|
14
18
|
async createProof(accountId, statement) {
|
|
15
19
|
const result = await hostApi.statementStoreCreateProof(enumValue('v1', [accountId, statement]));
|
package/dist/theme.d.ts
CHANGED
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
import type { CodecType, Transport } from '@novasamatech/host-api';
|
|
1
|
+
import type { CodecType, Subscription, Transport } from '@novasamatech/host-api';
|
|
2
2
|
import { Theme } from '@novasamatech/host-api';
|
|
3
3
|
export type ThemeMode = CodecType<typeof Theme>;
|
|
4
|
-
export type ThemeSubscription = {
|
|
5
|
-
unsubscribe: VoidFunction;
|
|
6
|
-
};
|
|
7
4
|
export declare function createThemeProvider(transport?: Transport): {
|
|
8
|
-
subscribeTheme(callback: (theme: ThemeMode) => void):
|
|
5
|
+
subscribeTheme(callback: (theme: ThemeMode) => void): Subscription<void>;
|
|
9
6
|
};
|
package/dist/theme.js
CHANGED
|
@@ -4,13 +4,14 @@ export function createThemeProvider(transport = sandboxTransport) {
|
|
|
4
4
|
const hostApi = createHostApi(transport);
|
|
5
5
|
return {
|
|
6
6
|
subscribeTheme(callback) {
|
|
7
|
-
const
|
|
7
|
+
const subscriber = hostApi.themeSubscribe(enumValue('v1', undefined), value => {
|
|
8
8
|
if (value.tag === 'v1') {
|
|
9
9
|
callback(value.value);
|
|
10
10
|
}
|
|
11
11
|
});
|
|
12
12
|
return {
|
|
13
|
-
unsubscribe:
|
|
13
|
+
unsubscribe: subscriber.unsubscribe,
|
|
14
|
+
onInterrupt: cb => subscriber.onInterrupt(v => cb(v.value)),
|
|
14
15
|
};
|
|
15
16
|
},
|
|
16
17
|
};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@novasamatech/product-sdk",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.7.
|
|
4
|
+
"version": "0.7.2-0",
|
|
5
5
|
"description": "Polkadot product SDK: integrate and run your product inside Polkadot browser.",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"repository": {
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"dependencies": {
|
|
28
28
|
"@polkadot/extension-inject": "^0.63.1",
|
|
29
29
|
"@polkadot-api/json-rpc-provider-proxy": "^0.4.0",
|
|
30
|
-
"@novasamatech/host-api": "0.7.
|
|
30
|
+
"@novasamatech/host-api": "0.7.2-0",
|
|
31
31
|
"polkadot-api": ">=2",
|
|
32
32
|
"neverthrow": "^8.2.0"
|
|
33
33
|
},
|