@subwallet/extension-base 0.3.6-1 → 0.4.2-1
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 +590 -462
- package/background/KoniTypes.js +1 -0
- package/background/RequestBytesSign.d.ts +12 -12
- package/background/RequestExtrinsicSign.d.ts +12 -12
- package/background/handlers/Extension.d.ts +49 -49
- package/background/handlers/State.d.ts +87 -87
- package/background/handlers/Tabs.d.ts +24 -24
- package/background/handlers/helpers.d.ts +1 -1
- package/background/handlers/index.d.ts +3 -3
- package/background/handlers/subscriptions.d.ts +5 -4
- package/background/handlers/subscriptions.js +3 -0
- package/background/types.d.ts +345 -345
- package/bundle.d.ts +1 -1
- package/cjs/background/KoniTypes.js +1 -0
- package/cjs/background/handlers/subscriptions.js +5 -0
- package/cjs/packageInfo.js +1 -1
- package/cjs/page/PostMessageProvider.js +27 -27
- package/defaults.d.ts +10 -10
- package/detectOther.d.ts +7 -7
- package/detectPackage.d.ts +1 -1
- package/index.d.ts +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/Injected.d.ts +13 -13
- package/page/Metadata.d.ts +7 -7
- package/page/PostMessageProvider.d.ts +62 -62
- package/page/PostMessageProvider.js +27 -27
- package/page/Signer.d.ts +8 -8
- package/page/index.d.ts +16 -16
- package/page/types.d.ts +6 -6
- package/stores/Accounts.d.ts +6 -6
- package/stores/Base.d.ts +10 -10
- package/stores/Metadata.d.ts +5 -5
- package/stores/index.d.ts +2 -2
- package/types.d.ts +9 -9
- package/utils/canDerive.d.ts +2 -2
- package/utils/getId.d.ts +1 -1
- package/utils/index.d.ts +1 -1
package/bundle.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { packageInfo } from './packageInfo';
|
|
1
|
+
export { packageInfo } from './packageInfo';
|
|
@@ -55,6 +55,7 @@ exports.TransferErrorCode = TransferErrorCode;
|
|
|
55
55
|
TransferErrorCode["KEYRING_ERROR"] = "keyringError";
|
|
56
56
|
TransferErrorCode["TRANSFER_ERROR"] = "transferError";
|
|
57
57
|
TransferErrorCode["TIMEOUT"] = "timeout";
|
|
58
|
+
TransferErrorCode["UNSUPPORTED"] = "unsupported";
|
|
58
59
|
})(TransferErrorCode || (exports.TransferErrorCode = TransferErrorCode = {}));
|
|
59
60
|
|
|
60
61
|
let TransferStep;
|
|
@@ -4,6 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.createSubscription = createSubscription;
|
|
7
|
+
exports.isSubscriptionRunning = isSubscriptionRunning;
|
|
7
8
|
exports.unsubscribe = unsubscribe;
|
|
8
9
|
// Copyright 2019-2022 @subwallet/extension authors & contributors
|
|
9
10
|
// SPDX-License-Identifier: Apache-2.0
|
|
@@ -19,6 +20,10 @@ function createSubscription(id, port) {
|
|
|
19
20
|
});
|
|
20
21
|
}
|
|
21
22
|
};
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function isSubscriptionRunning(id) {
|
|
26
|
+
return !!subscriptions[id];
|
|
22
27
|
} // clear a previous subscriber
|
|
23
28
|
|
|
24
29
|
|
package/cjs/packageInfo.js
CHANGED
|
@@ -16,10 +16,10 @@ var _util = require("@polkadot/util");
|
|
|
16
16
|
const l = (0, _util.logger)('PostMessageProvider');
|
|
17
17
|
// External to class, this.# is not private enough (yet)
|
|
18
18
|
let sendRequest;
|
|
19
|
-
/**
|
|
20
|
-
* @name PostMessageProvider
|
|
21
|
-
*
|
|
22
|
-
* @description Extension provider to be used by dapps
|
|
19
|
+
/**
|
|
20
|
+
* @name PostMessageProvider
|
|
21
|
+
*
|
|
22
|
+
* @description Extension provider to be used by dapps
|
|
23
23
|
*/
|
|
24
24
|
|
|
25
25
|
class PostMessageProvider {
|
|
@@ -31,25 +31,25 @@ class PostMessageProvider {
|
|
|
31
31
|
|
|
32
32
|
#subscriptions = {}; // {[(type,subscriptionId)]: callback}
|
|
33
33
|
|
|
34
|
-
/**
|
|
35
|
-
* @param {function} sendRequest The function to be called to send requests to the node
|
|
36
|
-
* @param {function} subscriptionNotificationHandler Channel for receiving subscription messages
|
|
34
|
+
/**
|
|
35
|
+
* @param {function} sendRequest The function to be called to send requests to the node
|
|
36
|
+
* @param {function} subscriptionNotificationHandler Channel for receiving subscription messages
|
|
37
37
|
*/
|
|
38
38
|
|
|
39
39
|
constructor(_sendRequest) {
|
|
40
40
|
this.#eventemitter = new _eventemitter.default();
|
|
41
41
|
sendRequest = _sendRequest;
|
|
42
42
|
}
|
|
43
|
-
/**
|
|
44
|
-
* @description Returns a clone of the object
|
|
43
|
+
/**
|
|
44
|
+
* @description Returns a clone of the object
|
|
45
45
|
*/
|
|
46
46
|
|
|
47
47
|
|
|
48
48
|
clone() {
|
|
49
49
|
return new PostMessageProvider(sendRequest);
|
|
50
50
|
}
|
|
51
|
-
/**
|
|
52
|
-
* @description Manually disconnect from the connection, clearing autoconnect logic
|
|
51
|
+
/**
|
|
52
|
+
* @description Manually disconnect from the connection, clearing autoconnect logic
|
|
53
53
|
*/
|
|
54
54
|
// eslint-disable-next-line @typescript-eslint/require-await
|
|
55
55
|
|
|
@@ -58,8 +58,8 @@ class PostMessageProvider {
|
|
|
58
58
|
// FIXME This should see if the extension's state's provider can disconnect
|
|
59
59
|
console.error('PostMessageProvider.disconnect() is not implemented.');
|
|
60
60
|
}
|
|
61
|
-
/**
|
|
62
|
-
* @description Manually disconnect from the connection, clearing autoconnect logic
|
|
61
|
+
/**
|
|
62
|
+
* @description Manually disconnect from the connection, clearing autoconnect logic
|
|
63
63
|
*/
|
|
64
64
|
// eslint-disable-next-line @typescript-eslint/require-await
|
|
65
65
|
|
|
@@ -68,8 +68,8 @@ class PostMessageProvider {
|
|
|
68
68
|
// FIXME This should see if the extension's state's provider can disconnect
|
|
69
69
|
console.error('PostMessageProvider.disconnect() is not implemented.');
|
|
70
70
|
}
|
|
71
|
-
/**
|
|
72
|
-
* @summary `true` when this provider supports subscriptions
|
|
71
|
+
/**
|
|
72
|
+
* @summary `true` when this provider supports subscriptions
|
|
73
73
|
*/
|
|
74
74
|
|
|
75
75
|
|
|
@@ -77,9 +77,9 @@ class PostMessageProvider {
|
|
|
77
77
|
// FIXME This should see if the extension's state's provider has subscriptions
|
|
78
78
|
return true;
|
|
79
79
|
}
|
|
80
|
-
/**
|
|
81
|
-
* @summary Whether the node is connected or not.
|
|
82
|
-
* @return {boolean} true if connected
|
|
80
|
+
/**
|
|
81
|
+
* @summary Whether the node is connected or not.
|
|
82
|
+
* @return {boolean} true if connected
|
|
83
83
|
*/
|
|
84
84
|
|
|
85
85
|
|
|
@@ -90,11 +90,11 @@ class PostMessageProvider {
|
|
|
90
90
|
listProviders() {
|
|
91
91
|
return sendRequest('pub(rpc.listProviders)', undefined);
|
|
92
92
|
}
|
|
93
|
-
/**
|
|
94
|
-
* @summary Listens on events after having subscribed using the [[subscribe]] function.
|
|
95
|
-
* @param {ProviderInterfaceEmitted} type Event
|
|
96
|
-
* @param {ProviderInterfaceEmitCb} sub Callback
|
|
97
|
-
* @return unsubscribe function
|
|
93
|
+
/**
|
|
94
|
+
* @summary Listens on events after having subscribed using the [[subscribe]] function.
|
|
95
|
+
* @param {ProviderInterfaceEmitted} type Event
|
|
96
|
+
* @param {ProviderInterfaceEmitCb} sub Callback
|
|
97
|
+
* @return unsubscribe function
|
|
98
98
|
*/
|
|
99
99
|
|
|
100
100
|
|
|
@@ -128,8 +128,8 @@ class PostMessageProvider {
|
|
|
128
128
|
params
|
|
129
129
|
});
|
|
130
130
|
}
|
|
131
|
-
/**
|
|
132
|
-
* @summary Spawn a provider on the extension background.
|
|
131
|
+
/**
|
|
132
|
+
* @summary Spawn a provider on the extension background.
|
|
133
133
|
*/
|
|
134
134
|
|
|
135
135
|
|
|
@@ -159,8 +159,8 @@ class PostMessageProvider {
|
|
|
159
159
|
type
|
|
160
160
|
});
|
|
161
161
|
}
|
|
162
|
-
/**
|
|
163
|
-
* @summary Allows unsubscribing to subscriptions made with [[subscribe]].
|
|
162
|
+
/**
|
|
163
|
+
* @summary Allows unsubscribing to subscriptions made with [[subscribe]].
|
|
164
164
|
*/
|
|
165
165
|
|
|
166
166
|
|
package/defaults.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
declare const ALLOWED_PATH: readonly ["/", "/account/import-ledger", "/account/restore-json", "/account/create"];
|
|
2
|
-
declare const PHISHING_PAGE_REDIRECT = "/phishing-page-detected";
|
|
3
|
-
declare const EXTENSION_PREFIX: string;
|
|
4
|
-
declare const PORT_CONTENT: string;
|
|
5
|
-
declare const PORT_EXTENSION: string;
|
|
6
|
-
declare const MESSAGE_ORIGIN_PAGE: string;
|
|
7
|
-
declare const MESSAGE_ORIGIN_CONTENT: string;
|
|
8
|
-
declare const PASSWORD_EXPIRY_MIN = 15;
|
|
9
|
-
declare const PASSWORD_EXPIRY_MS: number;
|
|
10
|
-
export { ALLOWED_PATH, PASSWORD_EXPIRY_MIN, PASSWORD_EXPIRY_MS, PHISHING_PAGE_REDIRECT, EXTENSION_PREFIX, PORT_CONTENT, PORT_EXTENSION, MESSAGE_ORIGIN_PAGE, MESSAGE_ORIGIN_CONTENT };
|
|
1
|
+
declare const ALLOWED_PATH: readonly ["/", "/account/import-ledger", "/account/restore-json", "/account/create"];
|
|
2
|
+
declare const PHISHING_PAGE_REDIRECT = "/phishing-page-detected";
|
|
3
|
+
declare const EXTENSION_PREFIX: string;
|
|
4
|
+
declare const PORT_CONTENT: string;
|
|
5
|
+
declare const PORT_EXTENSION: string;
|
|
6
|
+
declare const MESSAGE_ORIGIN_PAGE: string;
|
|
7
|
+
declare const MESSAGE_ORIGIN_CONTENT: string;
|
|
8
|
+
declare const PASSWORD_EXPIRY_MIN = 15;
|
|
9
|
+
declare const PASSWORD_EXPIRY_MS: number;
|
|
10
|
+
export { ALLOWED_PATH, PASSWORD_EXPIRY_MIN, PASSWORD_EXPIRY_MS, PHISHING_PAGE_REDIRECT, EXTENSION_PREFIX, PORT_CONTENT, PORT_EXTENSION, MESSAGE_ORIGIN_PAGE, MESSAGE_ORIGIN_CONTENT };
|
package/detectOther.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
declare const _default: {
|
|
2
|
-
name: string;
|
|
3
|
-
path: string;
|
|
4
|
-
type: string;
|
|
5
|
-
version: string;
|
|
6
|
-
}[];
|
|
7
|
-
export default _default;
|
|
1
|
+
declare const _default: {
|
|
2
|
+
name: string;
|
|
3
|
+
path: string;
|
|
4
|
+
type: string;
|
|
5
|
+
version: string;
|
|
6
|
+
}[];
|
|
7
|
+
export default _default;
|
package/detectPackage.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export {};
|
|
1
|
+
export {};
|
package/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from './bundle';
|
|
1
|
+
export * from './bundle';
|
package/package.json
CHANGED
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"./cjs/detectPackage.js"
|
|
18
18
|
],
|
|
19
19
|
"type": "module",
|
|
20
|
-
"version": "0.
|
|
20
|
+
"version": "0.4.2-1",
|
|
21
21
|
"main": "./cjs/index.js",
|
|
22
22
|
"module": "./index.js",
|
|
23
23
|
"types": "./index.d.ts",
|
|
@@ -199,9 +199,9 @@
|
|
|
199
199
|
"@polkadot/ui-settings": "^0.89.1",
|
|
200
200
|
"@polkadot/util": "^8.3.1",
|
|
201
201
|
"@polkadot/util-crypto": "^8.3.1",
|
|
202
|
-
"@subwallet/extension-chains": "^0.
|
|
203
|
-
"@subwallet/extension-dapp": "^0.
|
|
204
|
-
"@subwallet/extension-inject": "^0.
|
|
202
|
+
"@subwallet/extension-chains": "^0.4.2-1",
|
|
203
|
+
"@subwallet/extension-dapp": "^0.4.2-1",
|
|
204
|
+
"@subwallet/extension-inject": "^0.4.2-1",
|
|
205
205
|
"ethereumjs-tx": "^2.1.2",
|
|
206
206
|
"eventemitter3": "^4.0.7",
|
|
207
207
|
"rxjs": "^7.5.1",
|
package/packageInfo.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export declare const packageInfo: {
|
|
2
|
-
name: string;
|
|
3
|
-
path: string;
|
|
4
|
-
type: string;
|
|
5
|
-
version: string;
|
|
6
|
-
};
|
|
1
|
+
export declare const packageInfo: {
|
|
2
|
+
name: string;
|
|
3
|
+
path: string;
|
|
4
|
+
type: string;
|
|
5
|
+
version: string;
|
|
6
|
+
};
|
package/packageInfo.js
CHANGED
|
@@ -5,5 +5,5 @@ export const packageInfo = {
|
|
|
5
5
|
name: '@subwallet/extension-base',
|
|
6
6
|
path: (import.meta && import.meta.url) ? new URL(import.meta.url).pathname.substring(0, new URL(import.meta.url).pathname.lastIndexOf('/') + 1) : 'auto',
|
|
7
7
|
type: 'esm',
|
|
8
|
-
version: '0.
|
|
8
|
+
version: '0.4.2-1'
|
|
9
9
|
};
|
package/page/Accounts.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { InjectedAccount, InjectedAccounts, Unsubcall } from '@subwallet/extension-inject/types';
|
|
2
|
-
import type { SendRequest } from './types';
|
|
3
|
-
export default class Accounts implements InjectedAccounts {
|
|
4
|
-
constructor(_sendRequest: SendRequest);
|
|
5
|
-
get(anyType?: boolean): Promise<InjectedAccount[]>;
|
|
6
|
-
subscribe(cb: (accounts: InjectedAccount[]) => unknown): Unsubcall;
|
|
7
|
-
}
|
|
1
|
+
import type { InjectedAccount, InjectedAccounts, Unsubcall } from '@subwallet/extension-inject/types';
|
|
2
|
+
import type { SendRequest } from './types';
|
|
3
|
+
export default class Accounts implements InjectedAccounts {
|
|
4
|
+
constructor(_sendRequest: SendRequest);
|
|
5
|
+
get(anyType?: boolean): Promise<InjectedAccount[]>;
|
|
6
|
+
subscribe(cb: (accounts: InjectedAccount[]) => unknown): Unsubcall;
|
|
7
|
+
}
|
package/page/Injected.d.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import type { Injected } from '@subwallet/extension-inject/types';
|
|
2
|
-
import type { SendRequest } from './types';
|
|
3
|
-
import Accounts from './Accounts';
|
|
4
|
-
import Metadata from './Metadata';
|
|
5
|
-
import PostMessageProvider from './PostMessageProvider';
|
|
6
|
-
import Signer from './Signer';
|
|
7
|
-
export default class implements Injected {
|
|
8
|
-
readonly accounts: Accounts;
|
|
9
|
-
readonly metadata: Metadata;
|
|
10
|
-
readonly provider: PostMessageProvider;
|
|
11
|
-
readonly signer: Signer;
|
|
12
|
-
constructor(sendRequest: SendRequest);
|
|
13
|
-
}
|
|
1
|
+
import type { Injected } from '@subwallet/extension-inject/types';
|
|
2
|
+
import type { SendRequest } from './types';
|
|
3
|
+
import Accounts from './Accounts';
|
|
4
|
+
import Metadata from './Metadata';
|
|
5
|
+
import PostMessageProvider from './PostMessageProvider';
|
|
6
|
+
import Signer from './Signer';
|
|
7
|
+
export default class implements Injected {
|
|
8
|
+
readonly accounts: Accounts;
|
|
9
|
+
readonly metadata: Metadata;
|
|
10
|
+
readonly provider: PostMessageProvider;
|
|
11
|
+
readonly signer: Signer;
|
|
12
|
+
constructor(sendRequest: SendRequest);
|
|
13
|
+
}
|
package/page/Metadata.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { InjectedMetadata, InjectedMetadataKnown, MetadataDef } from '@subwallet/extension-inject/types';
|
|
2
|
-
import type { SendRequest } from './types';
|
|
3
|
-
export default class Metadata implements InjectedMetadata {
|
|
4
|
-
constructor(_sendRequest: SendRequest);
|
|
5
|
-
get(): Promise<InjectedMetadataKnown[]>;
|
|
6
|
-
provide(definition: MetadataDef): Promise<boolean>;
|
|
7
|
-
}
|
|
1
|
+
import type { InjectedMetadata, InjectedMetadataKnown, MetadataDef } from '@subwallet/extension-inject/types';
|
|
2
|
+
import type { SendRequest } from './types';
|
|
3
|
+
export default class Metadata implements InjectedMetadata {
|
|
4
|
+
constructor(_sendRequest: SendRequest);
|
|
5
|
+
get(): Promise<InjectedMetadataKnown[]>;
|
|
6
|
+
provide(definition: MetadataDef): Promise<boolean>;
|
|
7
|
+
}
|
|
@@ -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 {};
|
|
@@ -5,10 +5,10 @@ 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/index.d.ts
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
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;
|
|
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/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
|
+
}
|