@subwallet/extension-base 0.3.6-2 → 0.4.2-2
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/LICENSE +201 -201
- package/README.md +10 -10
- package/background/KoniTypes.d.ts +595 -462
- package/background/KoniTypes.js +2 -1
- package/background/RequestBytesSign.d.ts +12 -12
- package/background/RequestBytesSign.js +1 -1
- package/background/RequestExtrinsicSign.d.ts +12 -12
- package/background/RequestExtrinsicSign.js +1 -1
- package/background/handlers/Extension.d.ts +49 -49
- package/background/handlers/Extension.js +1 -1
- package/background/handlers/State.d.ts +87 -87
- package/background/handlers/State.js +1 -1
- package/background/handlers/Tabs.d.ts +24 -24
- package/background/handlers/Tabs.js +1 -1
- package/background/handlers/helpers.d.ts +1 -1
- package/background/handlers/helpers.js +1 -1
- package/background/handlers/index.d.ts +3 -3
- package/background/handlers/index.js +1 -1
- package/background/handlers/subscriptions.d.ts +5 -4
- package/background/handlers/subscriptions.js +4 -1
- package/background/types.d.ts +345 -345
- package/bundle.d.ts +1 -1
- package/bundle.js +1 -1
- package/cjs/background/KoniTypes.js +2 -1
- package/cjs/background/RequestBytesSign.js +1 -1
- package/cjs/background/RequestExtrinsicSign.js +1 -1
- package/cjs/background/handlers/Extension.js +1 -1
- package/cjs/background/handlers/State.js +1 -1
- package/cjs/background/handlers/Tabs.js +1 -1
- package/cjs/background/handlers/helpers.js +1 -1
- package/cjs/background/handlers/index.js +1 -1
- package/cjs/background/handlers/subscriptions.js +6 -1
- package/cjs/defaults.js +1 -1
- package/cjs/packageInfo.js +1 -1
- package/cjs/page/Accounts.js +1 -1
- package/cjs/page/Injected.js +1 -1
- package/cjs/page/Metadata.js +1 -1
- package/cjs/page/PostMessageProvider.js +28 -28
- package/cjs/page/Signer.js +1 -1
- package/cjs/page/index.js +1 -1
- package/cjs/stores/Accounts.js +1 -1
- package/cjs/stores/Base.js +1 -1
- package/cjs/stores/Metadata.js +1 -1
- package/cjs/utils/canDerive.js +1 -1
- package/cjs/utils/getId.js +1 -1
- package/defaults.d.ts +10 -10
- package/defaults.js +1 -1
- package/detectOther.d.ts +7 -7
- package/detectPackage.d.ts +1 -1
- package/index.d.ts +1 -1
- package/index.js +1 -1
- package/package.json +4 -4
- package/packageInfo.d.ts +6 -6
- package/packageInfo.js +1 -1
- package/page/Accounts.d.ts +7 -7
- package/page/Accounts.js +1 -1
- package/page/Injected.d.ts +13 -13
- package/page/Injected.js +1 -1
- package/page/Metadata.d.ts +7 -7
- package/page/Metadata.js +1 -1
- package/page/PostMessageProvider.d.ts +62 -62
- package/page/PostMessageProvider.js +28 -28
- package/page/Signer.d.ts +8 -8
- package/page/Signer.js +1 -1
- package/page/index.d.ts +16 -16
- package/page/index.js +1 -1
- package/page/types.d.ts +6 -6
- package/stores/Accounts.d.ts +6 -6
- package/stores/Accounts.js +1 -1
- package/stores/Base.d.ts +10 -10
- package/stores/Base.js +1 -1
- package/stores/Metadata.d.ts +5 -5
- package/stores/Metadata.js +1 -1
- package/stores/index.d.ts +2 -2
- package/stores/index.js +1 -1
- package/types.d.ts +9 -9
- package/utils/canDerive.d.ts +2 -2
- package/utils/canDerive.js +1 -1
- package/utils/getId.d.ts +1 -1
- package/utils/getId.js +1 -1
- package/utils/index.d.ts +1 -1
- package/utils/index.js +1 -1
|
@@ -1,62 +1,62 @@
|
|
|
1
|
-
import type { InjectedProvider, ProviderList, ProviderMeta } from '@subwallet/extension-inject/types';
|
|
2
|
-
import type { ProviderInterfaceEmitCb, ProviderInterfaceEmitted } from '@polkadot/rpc-provider/types';
|
|
3
|
-
import type { AnyFunction } from '@polkadot/types/types';
|
|
4
|
-
import type { SendRequest } from './types';
|
|
5
|
-
declare type CallbackHandler = (error?: null | Error, value?: unknown) => void;
|
|
6
|
-
interface SubscriptionHandler {
|
|
7
|
-
callback: CallbackHandler;
|
|
8
|
-
type: string;
|
|
9
|
-
}
|
|
10
|
-
/**
|
|
11
|
-
* @name PostMessageProvider
|
|
12
|
-
*
|
|
13
|
-
* @description Extension provider to be used by dapps
|
|
14
|
-
*/
|
|
15
|
-
export default class PostMessageProvider implements InjectedProvider {
|
|
16
|
-
#private;
|
|
17
|
-
/**
|
|
18
|
-
* @param {function} sendRequest The function to be called to send requests to the node
|
|
19
|
-
* @param {function} subscriptionNotificationHandler Channel for receiving subscription messages
|
|
20
|
-
*/
|
|
21
|
-
constructor(_sendRequest: SendRequest);
|
|
22
|
-
/**
|
|
23
|
-
* @description Returns a clone of the object
|
|
24
|
-
*/
|
|
25
|
-
clone(): PostMessageProvider;
|
|
26
|
-
/**
|
|
27
|
-
* @description Manually disconnect from the connection, clearing autoconnect logic
|
|
28
|
-
*/
|
|
29
|
-
connect(): Promise<void>;
|
|
30
|
-
/**
|
|
31
|
-
* @description Manually disconnect from the connection, clearing autoconnect logic
|
|
32
|
-
*/
|
|
33
|
-
disconnect(): Promise<void>;
|
|
34
|
-
/**
|
|
35
|
-
* @summary `true` when this provider supports subscriptions
|
|
36
|
-
*/
|
|
37
|
-
get hasSubscriptions(): boolean;
|
|
38
|
-
/**
|
|
39
|
-
* @summary Whether the node is connected or not.
|
|
40
|
-
* @return {boolean} true if connected
|
|
41
|
-
*/
|
|
42
|
-
get isConnected(): boolean;
|
|
43
|
-
listProviders(): Promise<ProviderList>;
|
|
44
|
-
/**
|
|
45
|
-
* @summary Listens on events after having subscribed using the [[subscribe]] function.
|
|
46
|
-
* @param {ProviderInterfaceEmitted} type Event
|
|
47
|
-
* @param {ProviderInterfaceEmitCb} sub Callback
|
|
48
|
-
* @return unsubscribe function
|
|
49
|
-
*/
|
|
50
|
-
on(type: ProviderInterfaceEmitted, sub: ProviderInterfaceEmitCb): () => void;
|
|
51
|
-
send(method: string, params: unknown[], _?: boolean, subscription?: SubscriptionHandler): Promise<any>;
|
|
52
|
-
/**
|
|
53
|
-
* @summary Spawn a provider on the extension background.
|
|
54
|
-
*/
|
|
55
|
-
startProvider(key: string): Promise<ProviderMeta>;
|
|
56
|
-
subscribe(type: string, method: string, params: unknown[], callback: AnyFunction): Promise<number>;
|
|
57
|
-
/**
|
|
58
|
-
* @summary Allows unsubscribing to subscriptions made with [[subscribe]].
|
|
59
|
-
*/
|
|
60
|
-
unsubscribe(type: string, method: string, id: number): Promise<boolean>;
|
|
61
|
-
}
|
|
62
|
-
export {};
|
|
1
|
+
import type { InjectedProvider, ProviderList, ProviderMeta } from '@subwallet/extension-inject/types';
|
|
2
|
+
import type { ProviderInterfaceEmitCb, ProviderInterfaceEmitted } from '@polkadot/rpc-provider/types';
|
|
3
|
+
import type { AnyFunction } from '@polkadot/types/types';
|
|
4
|
+
import type { SendRequest } from './types';
|
|
5
|
+
declare type CallbackHandler = (error?: null | Error, value?: unknown) => void;
|
|
6
|
+
interface SubscriptionHandler {
|
|
7
|
+
callback: CallbackHandler;
|
|
8
|
+
type: string;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* @name PostMessageProvider
|
|
12
|
+
*
|
|
13
|
+
* @description Extension provider to be used by dapps
|
|
14
|
+
*/
|
|
15
|
+
export default class PostMessageProvider implements InjectedProvider {
|
|
16
|
+
#private;
|
|
17
|
+
/**
|
|
18
|
+
* @param {function} sendRequest The function to be called to send requests to the node
|
|
19
|
+
* @param {function} subscriptionNotificationHandler Channel for receiving subscription messages
|
|
20
|
+
*/
|
|
21
|
+
constructor(_sendRequest: SendRequest);
|
|
22
|
+
/**
|
|
23
|
+
* @description Returns a clone of the object
|
|
24
|
+
*/
|
|
25
|
+
clone(): PostMessageProvider;
|
|
26
|
+
/**
|
|
27
|
+
* @description Manually disconnect from the connection, clearing autoconnect logic
|
|
28
|
+
*/
|
|
29
|
+
connect(): Promise<void>;
|
|
30
|
+
/**
|
|
31
|
+
* @description Manually disconnect from the connection, clearing autoconnect logic
|
|
32
|
+
*/
|
|
33
|
+
disconnect(): Promise<void>;
|
|
34
|
+
/**
|
|
35
|
+
* @summary `true` when this provider supports subscriptions
|
|
36
|
+
*/
|
|
37
|
+
get hasSubscriptions(): boolean;
|
|
38
|
+
/**
|
|
39
|
+
* @summary Whether the node is connected or not.
|
|
40
|
+
* @return {boolean} true if connected
|
|
41
|
+
*/
|
|
42
|
+
get isConnected(): boolean;
|
|
43
|
+
listProviders(): Promise<ProviderList>;
|
|
44
|
+
/**
|
|
45
|
+
* @summary Listens on events after having subscribed using the [[subscribe]] function.
|
|
46
|
+
* @param {ProviderInterfaceEmitted} type Event
|
|
47
|
+
* @param {ProviderInterfaceEmitCb} sub Callback
|
|
48
|
+
* @return unsubscribe function
|
|
49
|
+
*/
|
|
50
|
+
on(type: ProviderInterfaceEmitted, sub: ProviderInterfaceEmitCb): () => void;
|
|
51
|
+
send(method: string, params: unknown[], _?: boolean, subscription?: SubscriptionHandler): Promise<any>;
|
|
52
|
+
/**
|
|
53
|
+
* @summary Spawn a provider on the extension background.
|
|
54
|
+
*/
|
|
55
|
+
startProvider(key: string): Promise<ProviderMeta>;
|
|
56
|
+
subscribe(type: string, method: string, params: unknown[], callback: AnyFunction): Promise<number>;
|
|
57
|
+
/**
|
|
58
|
+
* @summary Allows unsubscribing to subscriptions made with [[subscribe]].
|
|
59
|
+
*/
|
|
60
|
+
unsubscribe(type: string, method: string, id: number): Promise<boolean>;
|
|
61
|
+
}
|
|
62
|
+
export {};
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
// Copyright 2019-2022 @
|
|
1
|
+
// Copyright 2019-2022 @polkadot/extension-base authors & contributors
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
import EventEmitter from 'eventemitter3';
|
|
4
4
|
import { isUndefined, logger } from '@polkadot/util';
|
|
5
5
|
const l = logger('PostMessageProvider');
|
|
6
6
|
// External to class, this.# is not private enough (yet)
|
|
7
7
|
let sendRequest;
|
|
8
|
-
/**
|
|
9
|
-
* @name PostMessageProvider
|
|
10
|
-
*
|
|
11
|
-
* @description Extension provider to be used by dapps
|
|
8
|
+
/**
|
|
9
|
+
* @name PostMessageProvider
|
|
10
|
+
*
|
|
11
|
+
* @description Extension provider to be used by dapps
|
|
12
12
|
*/
|
|
13
13
|
|
|
14
14
|
export default class PostMessageProvider {
|
|
@@ -20,25 +20,25 @@ export default class PostMessageProvider {
|
|
|
20
20
|
|
|
21
21
|
#subscriptions = {}; // {[(type,subscriptionId)]: callback}
|
|
22
22
|
|
|
23
|
-
/**
|
|
24
|
-
* @param {function} sendRequest The function to be called to send requests to the node
|
|
25
|
-
* @param {function} subscriptionNotificationHandler Channel for receiving subscription messages
|
|
23
|
+
/**
|
|
24
|
+
* @param {function} sendRequest The function to be called to send requests to the node
|
|
25
|
+
* @param {function} subscriptionNotificationHandler Channel for receiving subscription messages
|
|
26
26
|
*/
|
|
27
27
|
|
|
28
28
|
constructor(_sendRequest) {
|
|
29
29
|
this.#eventemitter = new EventEmitter();
|
|
30
30
|
sendRequest = _sendRequest;
|
|
31
31
|
}
|
|
32
|
-
/**
|
|
33
|
-
* @description Returns a clone of the object
|
|
32
|
+
/**
|
|
33
|
+
* @description Returns a clone of the object
|
|
34
34
|
*/
|
|
35
35
|
|
|
36
36
|
|
|
37
37
|
clone() {
|
|
38
38
|
return new PostMessageProvider(sendRequest);
|
|
39
39
|
}
|
|
40
|
-
/**
|
|
41
|
-
* @description Manually disconnect from the connection, clearing autoconnect logic
|
|
40
|
+
/**
|
|
41
|
+
* @description Manually disconnect from the connection, clearing autoconnect logic
|
|
42
42
|
*/
|
|
43
43
|
// eslint-disable-next-line @typescript-eslint/require-await
|
|
44
44
|
|
|
@@ -47,8 +47,8 @@ export default class PostMessageProvider {
|
|
|
47
47
|
// FIXME This should see if the extension's state's provider can disconnect
|
|
48
48
|
console.error('PostMessageProvider.disconnect() is not implemented.');
|
|
49
49
|
}
|
|
50
|
-
/**
|
|
51
|
-
* @description Manually disconnect from the connection, clearing autoconnect logic
|
|
50
|
+
/**
|
|
51
|
+
* @description Manually disconnect from the connection, clearing autoconnect logic
|
|
52
52
|
*/
|
|
53
53
|
// eslint-disable-next-line @typescript-eslint/require-await
|
|
54
54
|
|
|
@@ -57,8 +57,8 @@ export default class PostMessageProvider {
|
|
|
57
57
|
// FIXME This should see if the extension's state's provider can disconnect
|
|
58
58
|
console.error('PostMessageProvider.disconnect() is not implemented.');
|
|
59
59
|
}
|
|
60
|
-
/**
|
|
61
|
-
* @summary `true` when this provider supports subscriptions
|
|
60
|
+
/**
|
|
61
|
+
* @summary `true` when this provider supports subscriptions
|
|
62
62
|
*/
|
|
63
63
|
|
|
64
64
|
|
|
@@ -66,9 +66,9 @@ export default class PostMessageProvider {
|
|
|
66
66
|
// FIXME This should see if the extension's state's provider has subscriptions
|
|
67
67
|
return true;
|
|
68
68
|
}
|
|
69
|
-
/**
|
|
70
|
-
* @summary Whether the node is connected or not.
|
|
71
|
-
* @return {boolean} true if connected
|
|
69
|
+
/**
|
|
70
|
+
* @summary Whether the node is connected or not.
|
|
71
|
+
* @return {boolean} true if connected
|
|
72
72
|
*/
|
|
73
73
|
|
|
74
74
|
|
|
@@ -79,11 +79,11 @@ export default class PostMessageProvider {
|
|
|
79
79
|
listProviders() {
|
|
80
80
|
return sendRequest('pub(rpc.listProviders)', undefined);
|
|
81
81
|
}
|
|
82
|
-
/**
|
|
83
|
-
* @summary Listens on events after having subscribed using the [[subscribe]] function.
|
|
84
|
-
* @param {ProviderInterfaceEmitted} type Event
|
|
85
|
-
* @param {ProviderInterfaceEmitCb} sub Callback
|
|
86
|
-
* @return unsubscribe function
|
|
82
|
+
/**
|
|
83
|
+
* @summary Listens on events after having subscribed using the [[subscribe]] function.
|
|
84
|
+
* @param {ProviderInterfaceEmitted} type Event
|
|
85
|
+
* @param {ProviderInterfaceEmitCb} sub Callback
|
|
86
|
+
* @return unsubscribe function
|
|
87
87
|
*/
|
|
88
88
|
|
|
89
89
|
|
|
@@ -117,8 +117,8 @@ export default class PostMessageProvider {
|
|
|
117
117
|
params
|
|
118
118
|
});
|
|
119
119
|
}
|
|
120
|
-
/**
|
|
121
|
-
* @summary Spawn a provider on the extension background.
|
|
120
|
+
/**
|
|
121
|
+
* @summary Spawn a provider on the extension background.
|
|
122
122
|
*/
|
|
123
123
|
|
|
124
124
|
|
|
@@ -148,8 +148,8 @@ export default class PostMessageProvider {
|
|
|
148
148
|
type
|
|
149
149
|
});
|
|
150
150
|
}
|
|
151
|
-
/**
|
|
152
|
-
* @summary Allows unsubscribing to subscriptions made with [[subscribe]].
|
|
151
|
+
/**
|
|
152
|
+
* @summary Allows unsubscribing to subscriptions made with [[subscribe]].
|
|
153
153
|
*/
|
|
154
154
|
|
|
155
155
|
|
package/page/Signer.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type { Signer as SignerInterface, SignerResult } from '@polkadot/api/types';
|
|
2
|
-
import type { SignerPayloadJSON, SignerPayloadRaw } from '@polkadot/types/types';
|
|
3
|
-
import type { SendRequest } from './types';
|
|
4
|
-
export default class Signer implements SignerInterface {
|
|
5
|
-
constructor(_sendRequest: SendRequest);
|
|
6
|
-
signPayload(payload: SignerPayloadJSON): Promise<SignerResult>;
|
|
7
|
-
signRaw(payload: SignerPayloadRaw): Promise<SignerResult>;
|
|
8
|
-
}
|
|
1
|
+
import type { Signer as SignerInterface, SignerResult } from '@polkadot/api/types';
|
|
2
|
+
import type { SignerPayloadJSON, SignerPayloadRaw } from '@polkadot/types/types';
|
|
3
|
+
import type { SendRequest } from './types';
|
|
4
|
+
export default class Signer implements SignerInterface {
|
|
5
|
+
constructor(_sendRequest: SendRequest);
|
|
6
|
+
signPayload(payload: SignerPayloadJSON): Promise<SignerResult>;
|
|
7
|
+
signRaw(payload: SignerPayloadRaw): Promise<SignerResult>;
|
|
8
|
+
}
|
package/page/Signer.js
CHANGED
package/page/index.d.ts
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import type { MessageTypes, MessageTypesWithNoSubscriptions, MessageTypesWithNullRequest, MessageTypesWithSubscriptions, RequestTypes, ResponseTypes, SubscriptionMessageTypes, TransportResponseMessage } from '
|
|
2
|
-
import Injected from './Injected';
|
|
3
|
-
export interface Handler {
|
|
4
|
-
resolve: (data?: any) => void;
|
|
5
|
-
reject: (error: Error) => void;
|
|
6
|
-
subscriber?: (data: any) => void;
|
|
7
|
-
}
|
|
8
|
-
export declare type Handlers = Record<string, Handler>;
|
|
9
|
-
export declare function sendMessage<TMessageType extends MessageTypesWithNullRequest>(message: TMessageType): Promise<ResponseTypes[TMessageType]>;
|
|
10
|
-
export declare function sendMessage<TMessageType extends MessageTypesWithNoSubscriptions>(message: TMessageType, request: RequestTypes[TMessageType]): Promise<ResponseTypes[TMessageType]>;
|
|
11
|
-
export declare function sendMessage<TMessageType extends MessageTypesWithSubscriptions>(message: TMessageType, request: RequestTypes[TMessageType], subscriber: (data: SubscriptionMessageTypes[TMessageType]) => void): Promise<ResponseTypes[TMessageType]>;
|
|
12
|
-
export declare function enable(origin: string): Promise<Injected>;
|
|
13
|
-
export declare function redirectIfPhishing(): Promise<boolean>;
|
|
14
|
-
export declare function handleResponse<TMessageType extends MessageTypes>(data: TransportResponseMessage<TMessageType> & {
|
|
15
|
-
subscription?: string;
|
|
16
|
-
}): void;
|
|
1
|
+
import type { MessageTypes, MessageTypesWithNoSubscriptions, MessageTypesWithNullRequest, MessageTypesWithSubscriptions, RequestTypes, ResponseTypes, SubscriptionMessageTypes, TransportResponseMessage } from '../background/types';
|
|
2
|
+
import Injected from './Injected';
|
|
3
|
+
export interface Handler {
|
|
4
|
+
resolve: (data?: any) => void;
|
|
5
|
+
reject: (error: Error) => void;
|
|
6
|
+
subscriber?: (data: any) => void;
|
|
7
|
+
}
|
|
8
|
+
export declare type Handlers = Record<string, Handler>;
|
|
9
|
+
export declare function sendMessage<TMessageType extends MessageTypesWithNullRequest>(message: TMessageType): Promise<ResponseTypes[TMessageType]>;
|
|
10
|
+
export declare function sendMessage<TMessageType extends MessageTypesWithNoSubscriptions>(message: TMessageType, request: RequestTypes[TMessageType]): Promise<ResponseTypes[TMessageType]>;
|
|
11
|
+
export declare function sendMessage<TMessageType extends MessageTypesWithSubscriptions>(message: TMessageType, request: RequestTypes[TMessageType], subscriber: (data: SubscriptionMessageTypes[TMessageType]) => void): Promise<ResponseTypes[TMessageType]>;
|
|
12
|
+
export declare function enable(origin: string): Promise<Injected>;
|
|
13
|
+
export declare function redirectIfPhishing(): Promise<boolean>;
|
|
14
|
+
export declare function handleResponse<TMessageType extends MessageTypes>(data: TransportResponseMessage<TMessageType> & {
|
|
15
|
+
subscription?: string;
|
|
16
|
+
}): void;
|
package/page/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Copyright 2019-2022 @
|
|
1
|
+
// Copyright 2019-2022 @polkadot/extension authors & contributors
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
import { MESSAGE_ORIGIN_PAGE } from "../defaults.js";
|
|
4
4
|
import { getId } from "../utils/getId.js";
|
package/page/types.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { MessageTypesWithNoSubscriptions, MessageTypesWithNullRequest, MessageTypesWithSubscriptions, RequestTypes, ResponseTypes, SubscriptionMessageTypes } from '../background/types';
|
|
2
|
-
export interface SendRequest {
|
|
3
|
-
<TMessageType extends MessageTypesWithNullRequest>(message: TMessageType): Promise<ResponseTypes[TMessageType]>;
|
|
4
|
-
<TMessageType extends MessageTypesWithNoSubscriptions>(message: TMessageType, request: RequestTypes[TMessageType]): Promise<ResponseTypes[TMessageType]>;
|
|
5
|
-
<TMessageType extends MessageTypesWithSubscriptions>(message: TMessageType, request: RequestTypes[TMessageType], subscriber: (data: SubscriptionMessageTypes[TMessageType]) => void): Promise<ResponseTypes[TMessageType]>;
|
|
6
|
-
}
|
|
1
|
+
import type { MessageTypesWithNoSubscriptions, MessageTypesWithNullRequest, MessageTypesWithSubscriptions, RequestTypes, ResponseTypes, SubscriptionMessageTypes } from '../background/types';
|
|
2
|
+
export interface SendRequest {
|
|
3
|
+
<TMessageType extends MessageTypesWithNullRequest>(message: TMessageType): Promise<ResponseTypes[TMessageType]>;
|
|
4
|
+
<TMessageType extends MessageTypesWithNoSubscriptions>(message: TMessageType, request: RequestTypes[TMessageType]): Promise<ResponseTypes[TMessageType]>;
|
|
5
|
+
<TMessageType extends MessageTypesWithSubscriptions>(message: TMessageType, request: RequestTypes[TMessageType], subscriber: (data: SubscriptionMessageTypes[TMessageType]) => void): Promise<ResponseTypes[TMessageType]>;
|
|
6
|
+
}
|
package/stores/Accounts.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { KeyringJson, KeyringStore } from '@polkadot/ui-keyring/types';
|
|
2
|
-
import BaseStore from './Base';
|
|
3
|
-
export default class AccountsStore extends BaseStore<KeyringJson> implements KeyringStore {
|
|
4
|
-
constructor();
|
|
5
|
-
set(key: string, value: KeyringJson, update?: () => void): void;
|
|
6
|
-
}
|
|
1
|
+
import type { KeyringJson, KeyringStore } from '@polkadot/ui-keyring/types';
|
|
2
|
+
import BaseStore from './Base';
|
|
3
|
+
export default class AccountsStore extends BaseStore<KeyringJson> implements KeyringStore {
|
|
4
|
+
constructor();
|
|
5
|
+
set(key: string, value: KeyringJson, update?: () => void): void;
|
|
6
|
+
}
|
package/stores/Accounts.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Copyright 2019-2022 @
|
|
1
|
+
// Copyright 2019-2022 @polkadot/extension-base authors & contributors
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
import { EXTENSION_PREFIX } from "../defaults.js";
|
|
4
4
|
import BaseStore from "./Base.js";
|
package/stores/Base.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
export default abstract class BaseStore<T> {
|
|
2
|
-
#private;
|
|
3
|
-
constructor(prefix: string | null);
|
|
4
|
-
getPrefix(): string;
|
|
5
|
-
all(update: (key: string, value: T) => void): void;
|
|
6
|
-
allMap(update: (value: Record<string, T>) => void): void;
|
|
7
|
-
get(_key: string, update: (value: T) => void): void;
|
|
8
|
-
remove(_key: string, update?: () => void): void;
|
|
9
|
-
set(_key: string, value: T, update?: () => void): void;
|
|
10
|
-
}
|
|
1
|
+
export default abstract class BaseStore<T> {
|
|
2
|
+
#private;
|
|
3
|
+
constructor(prefix: string | null);
|
|
4
|
+
getPrefix(): string;
|
|
5
|
+
all(update: (key: string, value: T) => void): void;
|
|
6
|
+
allMap(update: (value: Record<string, T>) => void): void;
|
|
7
|
+
get(_key: string, update: (value: T) => void): void;
|
|
8
|
+
remove(_key: string, update?: () => void): void;
|
|
9
|
+
set(_key: string, value: T, update?: () => void): void;
|
|
10
|
+
}
|
package/stores/Base.js
CHANGED
package/stores/Metadata.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { MetadataDef } from '@subwallet/extension-inject/types';
|
|
2
|
-
import BaseStore from './Base';
|
|
3
|
-
export default class MetadataStore extends BaseStore<MetadataDef> {
|
|
4
|
-
constructor();
|
|
5
|
-
}
|
|
1
|
+
import type { MetadataDef } from '@subwallet/extension-inject/types';
|
|
2
|
+
import BaseStore from './Base';
|
|
3
|
+
export default class MetadataStore extends BaseStore<MetadataDef> {
|
|
4
|
+
constructor();
|
|
5
|
+
}
|
package/stores/Metadata.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Copyright 2019-2022 @
|
|
1
|
+
// Copyright 2019-2022 @polkadot/extension-base authors & contributors
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
import { EXTENSION_PREFIX } from "../defaults.js";
|
|
4
4
|
import BaseStore from "./Base.js";
|
package/stores/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { default as AccountsStore } from './Accounts';
|
|
2
|
-
export { default as MetadataStore } from './Metadata';
|
|
1
|
+
export { default as AccountsStore } from './Accounts';
|
|
2
|
+
export { default as MetadataStore } from './Metadata';
|
package/stores/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Copyright 2019-2022 @
|
|
1
|
+
// Copyright 2019-2022 @polkadot/extension-base authors & contributors
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
export { default as AccountsStore } from "./Accounts.js";
|
|
4
4
|
export { default as MetadataStore } from "./Metadata.js";
|
package/types.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
export interface Message extends MessageEvent {
|
|
2
|
-
data: {
|
|
3
|
-
error?: string;
|
|
4
|
-
id: string;
|
|
5
|
-
origin: string;
|
|
6
|
-
response?: string;
|
|
7
|
-
subscription?: string;
|
|
8
|
-
};
|
|
9
|
-
}
|
|
1
|
+
export interface Message extends MessageEvent {
|
|
2
|
+
data: {
|
|
3
|
+
error?: string;
|
|
4
|
+
id: string;
|
|
5
|
+
origin: string;
|
|
6
|
+
response?: string;
|
|
7
|
+
subscription?: string;
|
|
8
|
+
};
|
|
9
|
+
}
|
package/utils/canDerive.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type { KeypairType } from '@polkadot/util-crypto/types';
|
|
2
|
-
export declare function canDerive(type?: KeypairType): boolean;
|
|
1
|
+
import type { KeypairType } from '@polkadot/util-crypto/types';
|
|
2
|
+
export declare function canDerive(type?: KeypairType): boolean;
|
package/utils/canDerive.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Copyright 2019-2022 @
|
|
1
|
+
// Copyright 2019-2022 @polkadot/extension authors & contributors
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
export function canDerive(type) {
|
|
4
4
|
return !!type && ['ed25519', 'sr25519', 'ecdsa', 'ethereum'].includes(type);
|
package/utils/getId.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare function getId(): string;
|
|
1
|
+
export declare function getId(): string;
|
package/utils/getId.js
CHANGED
package/utils/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { canDerive } from './canDerive';
|
|
1
|
+
export { canDerive } from './canDerive';
|
package/utils/index.js
CHANGED