@subwallet/extension-base 1.1.10-0 → 1.1.11-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/cjs/constants/i18n.js +1 -1
- package/cjs/defaults.js +3 -1
- package/cjs/koni/api/nft/config.js +10 -12
- package/cjs/koni/background/handlers/Extension.js +50 -13
- package/cjs/packageInfo.js +1 -1
- package/cjs/services/chain-service/constants.js +3 -2
- package/cjs/services/keyring-service/index.js +4 -0
- package/cjs/services/request-service/handler/EvmRequestHandler.js +13 -1
- package/cjs/services/request-service/handler/SubstrateRequestHandler.js +10 -2
- package/cjs/services/request-service/index.js +1 -1
- package/cjs/services/setting-service/SettingService.js +9 -0
- package/cjs/utils/getId.js +1 -1
- package/constants/i18n.js +1 -1
- package/defaults.d.ts +2 -1
- package/defaults.js +2 -1
- package/koni/api/nft/config.d.ts +1 -1
- package/koni/api/nft/config.js +8 -10
- package/koni/background/handlers/Extension.js +50 -13
- package/package.json +6 -6
- package/packageInfo.js +1 -1
- package/services/chain-service/constants.js +3 -2
- package/services/keyring-service/index.d.ts +1 -0
- package/services/keyring-service/index.js +4 -0
- package/services/request-service/handler/EvmRequestHandler.js +13 -1
- package/services/request-service/handler/SubstrateRequestHandler.js +10 -2
- package/services/request-service/index.d.ts +1 -1
- package/services/request-service/index.js +1 -1
- package/services/setting-service/SettingService.d.ts +1 -0
- package/services/setting-service/SettingService.js +9 -0
- package/services/transaction-service/index.d.ts +3 -3
- package/utils/getId.js +2 -2
package/cjs/constants/i18n.js
CHANGED
package/cjs/defaults.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.PORT_MOBILE = exports.PORT_EXTENSION = exports.PORT_CONTENT = exports.PHISHING_PAGE_REDIRECT = exports.PASSWORD_EXPIRY_MS = exports.PASSWORD_EXPIRY_MIN = exports.MESSAGE_ORIGIN_PAGE = exports.MESSAGE_ORIGIN_CONTENT = exports.EXTENSION_PREFIX = exports.ALLOWED_PATH = void 0;
|
|
6
|
+
exports.PORT_MOBILE = exports.PORT_EXTENSION = exports.PORT_CONTENT = exports.PHISHING_PAGE_REDIRECT = exports.PASSWORD_EXPIRY_MS = exports.PASSWORD_EXPIRY_MIN = exports.MESSAGE_ORIGIN_PAGE = exports.MESSAGE_ORIGIN_CONTENT = exports.ID_PREFIX = exports.EXTENSION_PREFIX = exports.ALLOWED_PATH = void 0;
|
|
7
7
|
// Copyright 2019-2022 @polkadot/extension-base authors & contributors
|
|
8
8
|
// SPDX-License-Identifier: Apache-2.0
|
|
9
9
|
|
|
@@ -13,6 +13,8 @@ const PHISHING_PAGE_REDIRECT = '/phishing-page-detected';
|
|
|
13
13
|
exports.PHISHING_PAGE_REDIRECT = PHISHING_PAGE_REDIRECT;
|
|
14
14
|
const EXTENSION_PREFIX = process.env.EXTENSION_PREFIX || '';
|
|
15
15
|
exports.EXTENSION_PREFIX = EXTENSION_PREFIX;
|
|
16
|
+
const ID_PREFIX = process.env.ID_PREFIX || EXTENSION_PREFIX || '';
|
|
17
|
+
exports.ID_PREFIX = ID_PREFIX;
|
|
16
18
|
const PORT_MOBILE = `${EXTENSION_PREFIX}mobile`;
|
|
17
19
|
exports.PORT_MOBILE = PORT_MOBILE;
|
|
18
20
|
const PORT_CONTENT = `${EXTENSION_PREFIX}koni-content`;
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.UNIQUE_SCAN_ENDPOINT = exports.UNIQUE_IPFS_GATEWAY = exports.TRANSFER_CHAIN_ID = exports.SUPPORTED_TRANSFER_SUBSTRATE_CHAIN_NAME = exports.SUPPORTED_TRANSFER_EVM_CHAIN_NAME = exports.SUPPORTED_TRANSFER_EVM_CHAIN = exports.SUPPORTED_NFT_NETWORKS = exports.SINGULAR_V2_ENDPOINT = exports.SINGULAR_V2_COLLECTION_ENDPOINT = exports.SINGULAR_V1_ENDPOINT = exports.SINGULAR_V1_COLLECTION_ENDPOINT = exports.RMRK_PINATA_SERVER = exports.QUARTZ_SCAN_ENDPOINT = exports.PINATA_IPFS_GATEWAY = exports.NFT_STORAGE_GATEWAY = exports.KANARIA_EXTERNAL_SERVER = exports.KANARIA_ENDPOINT = exports.IPFS_W3S_LINK = exports.
|
|
6
|
+
exports.UNIQUE_SCAN_ENDPOINT = exports.UNIQUE_IPFS_GATEWAY = exports.TRANSFER_CHAIN_ID = exports.SUPPORTED_TRANSFER_SUBSTRATE_CHAIN_NAME = exports.SUPPORTED_TRANSFER_EVM_CHAIN_NAME = exports.SUPPORTED_TRANSFER_EVM_CHAIN = exports.SUPPORTED_NFT_NETWORKS = exports.SINGULAR_V2_ENDPOINT = exports.SINGULAR_V2_COLLECTION_ENDPOINT = exports.SINGULAR_V1_ENDPOINT = exports.SINGULAR_V1_COLLECTION_ENDPOINT = exports.RMRK_PINATA_SERVER = exports.QUARTZ_SCAN_ENDPOINT = exports.PINATA_IPFS_GATEWAY = exports.NFT_STORAGE_GATEWAY = exports.KANARIA_EXTERNAL_SERVER = exports.KANARIA_ENDPOINT = exports.IPFS_W3S_LINK = exports.IPFS_IO = exports.IPFS_GATEWAY_4EVERLAND = exports.IPFS_FLEEK = exports.GATEWAY_IPFS_IO = exports.DWEB_LINK = exports.CLOUDFLARE_PINATA_SERVER = exports.CF_IPFS_GATEWAY = exports.BIT_COUNTRY_THUMBNAIL_RESOLVER = exports.BIT_COUNTRY_LAND_ESTATE_METADATA_API = exports.BIT_COUNTRY_IPFS_SERVER = void 0;
|
|
7
7
|
exports.getRandomIpfsGateway = getRandomIpfsGateway;
|
|
8
8
|
var _utils = require("@subwallet/extension-base/utils");
|
|
9
9
|
// Copyright 2019-2022 @subwallet/extension-koni authors & contributors
|
|
@@ -47,14 +47,14 @@ const IPFS_W3S_LINK = 'https://w3s.link/ipfs/';
|
|
|
47
47
|
exports.IPFS_W3S_LINK = IPFS_W3S_LINK;
|
|
48
48
|
const GATEWAY_IPFS_IO = 'https://gateway.ipfs.io/ipfs/';
|
|
49
49
|
exports.GATEWAY_IPFS_IO = GATEWAY_IPFS_IO;
|
|
50
|
+
const IPFS_IO = 'https://ipfs.io/ipfs/';
|
|
51
|
+
exports.IPFS_IO = IPFS_IO;
|
|
50
52
|
const DWEB_LINK = 'https://dweb.link/ipfs/';
|
|
51
53
|
exports.DWEB_LINK = DWEB_LINK;
|
|
52
54
|
const IPFS_GATEWAY_4EVERLAND = 'https://4everland.io/ipfs/';
|
|
53
55
|
exports.IPFS_GATEWAY_4EVERLAND = IPFS_GATEWAY_4EVERLAND;
|
|
54
56
|
const IPFS_FLEEK = 'https://ipfs.fleek.co/ipfs/';
|
|
55
57
|
exports.IPFS_FLEEK = IPFS_FLEEK;
|
|
56
|
-
const IPFS_HARDBIN = 'https://hardbin.com/ipfs/';
|
|
57
|
-
exports.IPFS_HARDBIN = IPFS_HARDBIN;
|
|
58
58
|
let SUPPORTED_NFT_NETWORKS;
|
|
59
59
|
exports.SUPPORTED_NFT_NETWORKS = SUPPORTED_NFT_NETWORKS;
|
|
60
60
|
(function (SUPPORTED_NFT_NETWORKS) {
|
|
@@ -111,26 +111,24 @@ const RANDOM_IPFS_GATEWAY_SETTING = [{
|
|
|
111
111
|
}, {
|
|
112
112
|
provider: PINATA_IPFS_GATEWAY,
|
|
113
113
|
weight: 1 // Rate limit too low
|
|
114
|
+
}, {
|
|
115
|
+
provider: DWEB_LINK,
|
|
116
|
+
weight: 5
|
|
114
117
|
}, {
|
|
115
118
|
provider: GATEWAY_IPFS_IO,
|
|
116
119
|
weight: 5
|
|
117
120
|
}, {
|
|
118
|
-
provider:
|
|
121
|
+
provider: IPFS_IO,
|
|
119
122
|
weight: 5
|
|
123
|
+
}, {
|
|
124
|
+
provider: NFT_STORAGE_GATEWAY,
|
|
125
|
+
weight: 50
|
|
120
126
|
}];
|
|
121
127
|
if (!_utils.RuntimeInfo.protocol || _utils.RuntimeInfo.protocol && !_utils.RuntimeInfo.protocol.startsWith('http')) {
|
|
122
|
-
RANDOM_IPFS_GATEWAY_SETTING.push({
|
|
123
|
-
provider: NFT_STORAGE_GATEWAY,
|
|
124
|
-
weight: 50
|
|
125
|
-
});
|
|
126
128
|
RANDOM_IPFS_GATEWAY_SETTING.push({
|
|
127
129
|
provider: IPFS_FLEEK,
|
|
128
130
|
weight: 4
|
|
129
131
|
});
|
|
130
|
-
RANDOM_IPFS_GATEWAY_SETTING.push({
|
|
131
|
-
provider: IPFS_HARDBIN,
|
|
132
|
-
weight: 1
|
|
133
|
-
});
|
|
134
132
|
RANDOM_IPFS_GATEWAY_SETTING.push({
|
|
135
133
|
provider: IPFS_GATEWAY_4EVERLAND,
|
|
136
134
|
weight: 2
|
|
@@ -78,16 +78,31 @@ class KoniExtension {
|
|
|
78
78
|
#koniState;
|
|
79
79
|
#timeAutoLock = _constants4.DEFAULT_AUTO_LOCK_TIME;
|
|
80
80
|
#skipAutoLock = false;
|
|
81
|
+
#alwaysLock = false;
|
|
82
|
+
#firstTime = true;
|
|
81
83
|
constructor(state) {
|
|
82
84
|
this.#koniState = state;
|
|
83
85
|
const updateTimeAutoLock = rs => {
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
86
|
+
// Check time auto lock change
|
|
87
|
+
if (this.#timeAutoLock !== rs.timeAutoLock) {
|
|
88
|
+
this.#timeAutoLock = rs.timeAutoLock;
|
|
89
|
+
this.#alwaysLock = !rs.timeAutoLock;
|
|
90
|
+
clearTimeout(this.#lockTimeOut);
|
|
91
|
+
if (this.#timeAutoLock > 0) {
|
|
92
|
+
this.#lockTimeOut = setTimeout(() => {
|
|
93
|
+
if (!this.#skipAutoLock) {
|
|
94
|
+
this.keyringLock();
|
|
95
|
+
}
|
|
96
|
+
}, this.#timeAutoLock * 60 * 1000);
|
|
97
|
+
} else if (this.#alwaysLock) {
|
|
98
|
+
if (!this.#firstTime) {
|
|
99
|
+
this.keyringLock();
|
|
100
|
+
}
|
|
89
101
|
}
|
|
90
|
-
}
|
|
102
|
+
}
|
|
103
|
+
if (this.#firstTime) {
|
|
104
|
+
this.#firstTime = false;
|
|
105
|
+
}
|
|
91
106
|
};
|
|
92
107
|
this.#koniState.settingService.getSettings(updateTimeAutoLock);
|
|
93
108
|
this.#koniState.settingService.getSubject().subscribe({
|
|
@@ -1170,6 +1185,9 @@ class KoniExtension {
|
|
|
1170
1185
|
resolve();
|
|
1171
1186
|
});
|
|
1172
1187
|
});
|
|
1188
|
+
if (this.#alwaysLock) {
|
|
1189
|
+
this.keyringLock();
|
|
1190
|
+
}
|
|
1173
1191
|
return addressDict;
|
|
1174
1192
|
}
|
|
1175
1193
|
async accountsForgetOverride(_ref36) {
|
|
@@ -1348,6 +1366,9 @@ class KoniExtension {
|
|
|
1348
1366
|
_uiKeyring.keyring.restoreAccount(file, password, withMasterPassword);
|
|
1349
1367
|
this._addAddressToAuthList(address, isAllowed);
|
|
1350
1368
|
});
|
|
1369
|
+
if (this.#alwaysLock) {
|
|
1370
|
+
this.keyringLock();
|
|
1371
|
+
}
|
|
1351
1372
|
} catch (error) {
|
|
1352
1373
|
throw new Error(error.message);
|
|
1353
1374
|
}
|
|
@@ -1370,6 +1391,9 @@ class KoniExtension {
|
|
|
1370
1391
|
_uiKeyring.keyring.restoreAccounts(file, password);
|
|
1371
1392
|
this._addAddressesToAuthList(addressList, isAllowed);
|
|
1372
1393
|
});
|
|
1394
|
+
if (this.#alwaysLock) {
|
|
1395
|
+
this.keyringLock();
|
|
1396
|
+
}
|
|
1373
1397
|
} catch (error) {
|
|
1374
1398
|
throw new Error(error.message);
|
|
1375
1399
|
}
|
|
@@ -2245,6 +2269,9 @@ class KoniExtension {
|
|
|
2245
2269
|
resolve();
|
|
2246
2270
|
});
|
|
2247
2271
|
});
|
|
2272
|
+
if (this.#alwaysLock) {
|
|
2273
|
+
this.keyringLock();
|
|
2274
|
+
}
|
|
2248
2275
|
return {
|
|
2249
2276
|
errors: [],
|
|
2250
2277
|
success: true
|
|
@@ -2768,6 +2795,9 @@ class KoniExtension {
|
|
|
2768
2795
|
};
|
|
2769
2796
|
}
|
|
2770
2797
|
this.#koniState.updateKeyringState();
|
|
2798
|
+
if (this.#alwaysLock) {
|
|
2799
|
+
this.keyringLock();
|
|
2800
|
+
}
|
|
2771
2801
|
return {
|
|
2772
2802
|
status: true,
|
|
2773
2803
|
errors: []
|
|
@@ -2821,8 +2851,7 @@ class KoniExtension {
|
|
|
2821
2851
|
// Lock wallet
|
|
2822
2852
|
|
|
2823
2853
|
keyringLock() {
|
|
2824
|
-
|
|
2825
|
-
this.#koniState.updateKeyringState();
|
|
2854
|
+
this.#koniState.keyringService.lock();
|
|
2826
2855
|
clearTimeout(this.#lockTimeOut);
|
|
2827
2856
|
}
|
|
2828
2857
|
|
|
@@ -2921,6 +2950,9 @@ class KoniExtension {
|
|
|
2921
2950
|
// In case evm chain, must be cut 2 character after 0x
|
|
2922
2951
|
signature: isEvm ? `0x${result.signature.slice(4)}` : result.signature
|
|
2923
2952
|
});
|
|
2953
|
+
if (this.#alwaysLock) {
|
|
2954
|
+
this.keyringLock();
|
|
2955
|
+
}
|
|
2924
2956
|
return true;
|
|
2925
2957
|
}
|
|
2926
2958
|
|
|
@@ -3020,6 +3052,9 @@ class KoniExtension {
|
|
|
3020
3052
|
_uiKeyring.keyring.addPair(childPair, true);
|
|
3021
3053
|
this._addAddressToAuthList(address, true);
|
|
3022
3054
|
});
|
|
3055
|
+
if (this.#alwaysLock) {
|
|
3056
|
+
this.keyringLock();
|
|
3057
|
+
}
|
|
3023
3058
|
return true;
|
|
3024
3059
|
}
|
|
3025
3060
|
validateDerivePath(_ref74) {
|
|
@@ -3542,11 +3577,13 @@ class KoniExtension {
|
|
|
3542
3577
|
// eslint-disable-next-line @typescript-eslint/require-await
|
|
3543
3578
|
async handle(id, type, request, port) {
|
|
3544
3579
|
clearTimeout(this.#lockTimeOut);
|
|
3545
|
-
this.#
|
|
3546
|
-
|
|
3547
|
-
this
|
|
3548
|
-
|
|
3549
|
-
|
|
3580
|
+
if (this.#timeAutoLock > 0) {
|
|
3581
|
+
this.#lockTimeOut = setTimeout(() => {
|
|
3582
|
+
if (!this.#skipAutoLock) {
|
|
3583
|
+
this.keyringLock();
|
|
3584
|
+
}
|
|
3585
|
+
}, this.#timeAutoLock * 60 * 1000);
|
|
3586
|
+
}
|
|
3550
3587
|
switch (type) {
|
|
3551
3588
|
/// Clone from PolkadotJs
|
|
3552
3589
|
case 'pri(accounts.create.external)':
|
package/cjs/packageInfo.js
CHANGED
|
@@ -61,7 +61,7 @@ const _NFT_CHAIN_GROUP = {
|
|
|
61
61
|
// Staking--------------------------------------------------------------------------------------------------------------
|
|
62
62
|
exports._NFT_CHAIN_GROUP = _NFT_CHAIN_GROUP;
|
|
63
63
|
const _STAKING_CHAIN_GROUP = {
|
|
64
|
-
relay: ['polkadot', 'kusama', 'aleph', 'polkadex', 'ternoa', 'ternoa_alphanet', 'alephTest', 'polkadexTest', 'westend', 'kate', 'edgeware'],
|
|
64
|
+
relay: ['polkadot', 'kusama', 'aleph', 'polkadex', 'ternoa', 'ternoa_alphanet', 'alephTest', 'polkadexTest', 'westend', 'kate', 'edgeware', 'creditcoin'],
|
|
65
65
|
para: ['moonbeam', 'moonriver', 'moonbase', 'turing', 'turingStaging', 'bifrost', 'bifrost_testnet', 'calamari_test', 'calamari'],
|
|
66
66
|
astar: ['astar', 'shiden', 'shibuya'],
|
|
67
67
|
amplitude: ['amplitude', 'amplitude_test', 'kilt', 'kilt_peregrine', 'pendulum'],
|
|
@@ -102,7 +102,8 @@ const _STAKING_ERA_LENGTH_MAP = {
|
|
|
102
102
|
kilt: 2,
|
|
103
103
|
kilt_peregrine: 2,
|
|
104
104
|
edgeware: 6,
|
|
105
|
-
kate: 6
|
|
105
|
+
kate: 6,
|
|
106
|
+
creditcoin: 24
|
|
106
107
|
};
|
|
107
108
|
exports._STAKING_ERA_LENGTH_MAP = _STAKING_ERA_LENGTH_MAP;
|
|
108
109
|
const _PARACHAIN_INFLATION_DISTRIBUTION = {
|
|
@@ -94,6 +94,10 @@ class KeyringService {
|
|
|
94
94
|
this.eventService.emit('account.updateCurrent', currentAccountData);
|
|
95
95
|
this.currentAccountStore.set('CurrentAccountInfo', currentAccountData);
|
|
96
96
|
}
|
|
97
|
+
lock() {
|
|
98
|
+
_uiKeyring.keyring.lockAll();
|
|
99
|
+
this.updateKeyringState();
|
|
100
|
+
}
|
|
97
101
|
resetWallet(resetAll) {
|
|
98
102
|
_uiKeyring.keyring.resetWallet(resetAll);
|
|
99
103
|
this.updateKeyringState();
|
|
@@ -45,13 +45,19 @@ class EvmRequestHandler {
|
|
|
45
45
|
getConfirmationsQueueSubject() {
|
|
46
46
|
return this.confirmationsQueueSubject;
|
|
47
47
|
}
|
|
48
|
-
addConfirmation(id, url, type, payload) {
|
|
48
|
+
async addConfirmation(id, url, type, payload) {
|
|
49
49
|
let options = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {};
|
|
50
50
|
let validator = arguments.length > 5 ? arguments[5] : undefined;
|
|
51
51
|
const confirmations = this.confirmationsQueueSubject.getValue();
|
|
52
52
|
const confirmationType = confirmations[type];
|
|
53
53
|
const payloadJson = JSON.stringify(payload);
|
|
54
54
|
const isInternal = (0, _request.isInternalRequest)(url);
|
|
55
|
+
if (['evmSignatureRequest', 'evmSendTransactionRequest'].includes(type)) {
|
|
56
|
+
const isAlwaysRequired = await this.#requestService.settingService.isAlwaysRequired;
|
|
57
|
+
if (isAlwaysRequired) {
|
|
58
|
+
this.#requestService.keyringService.lock();
|
|
59
|
+
}
|
|
60
|
+
}
|
|
55
61
|
|
|
56
62
|
// Check duplicate request
|
|
57
63
|
const duplicated = Object.values(confirmationType).find(c => c.url === url && c.payloadJson === payloadJson);
|
|
@@ -193,6 +199,12 @@ class EvmRequestHandler {
|
|
|
193
199
|
} else if (t === 'evmSendTransactionRequest') {
|
|
194
200
|
result.payload = await this.signTransaction(request);
|
|
195
201
|
}
|
|
202
|
+
if (t === 'evmSignatureRequest' || t === 'evmSendTransactionRequest') {
|
|
203
|
+
const isAlwaysRequired = await this.#requestService.settingService.isAlwaysRequired;
|
|
204
|
+
if (isAlwaysRequired) {
|
|
205
|
+
this.#requestService.keyringService.lock();
|
|
206
|
+
}
|
|
207
|
+
}
|
|
196
208
|
}
|
|
197
209
|
}
|
|
198
210
|
async completeConfirmation(request) {
|
|
@@ -67,8 +67,12 @@ class SubstrateRequestHandler {
|
|
|
67
67
|
get numSubstrateRequests() {
|
|
68
68
|
return Object.keys(this.#substrateRequests).length;
|
|
69
69
|
}
|
|
70
|
-
sign(url, request, account, _id) {
|
|
70
|
+
async sign(url, request, account, _id) {
|
|
71
71
|
const id = _id || (0, _getId.getId)();
|
|
72
|
+
const isAlwaysRequired = await this.#requestService.settingService.isAlwaysRequired;
|
|
73
|
+
if (isAlwaysRequired) {
|
|
74
|
+
this.#requestService.keyringService.lock();
|
|
75
|
+
}
|
|
72
76
|
return new Promise((resolve, reject) => {
|
|
73
77
|
this.#substrateRequests[id] = {
|
|
74
78
|
...this.signComplete(id, resolve, reject),
|
|
@@ -81,7 +85,11 @@ class SubstrateRequestHandler {
|
|
|
81
85
|
this.#requestService.popupOpen();
|
|
82
86
|
});
|
|
83
87
|
}
|
|
84
|
-
signTransaction(id, address, url, payload) {
|
|
88
|
+
async signTransaction(id, address, url, payload) {
|
|
89
|
+
const isAlwaysRequired = await this.#requestService.settingService.isAlwaysRequired;
|
|
90
|
+
if (isAlwaysRequired) {
|
|
91
|
+
this.#requestService.keyringService.lock();
|
|
92
|
+
}
|
|
85
93
|
return new Promise((resolve, reject) => {
|
|
86
94
|
const pair = _uiKeyring.default.getPair(address);
|
|
87
95
|
const account = {
|
|
@@ -21,9 +21,9 @@ class RequestService {
|
|
|
21
21
|
|
|
22
22
|
// Common
|
|
23
23
|
constructor(chainService, settingService, keyringService) {
|
|
24
|
-
this.keyringService = keyringService;
|
|
25
24
|
this.#chainService = chainService;
|
|
26
25
|
this.settingService = settingService;
|
|
26
|
+
this.keyringService = keyringService;
|
|
27
27
|
this.#popupHandler = new _handler.PopupHandler(this);
|
|
28
28
|
this.#metadataRequestHandler = new _handler.MetadataRequestHandler(this);
|
|
29
29
|
this.#authRequestHandler = new _handler.AuthRequestHandler(this, this.#chainService, this.keyringService);
|
|
@@ -53,6 +53,15 @@ class SettingService {
|
|
|
53
53
|
setPassPhishing(data, callback) {
|
|
54
54
|
this.passPhishingStore.set('PassPhishing', data, callback);
|
|
55
55
|
}
|
|
56
|
+
|
|
57
|
+
// Use for mobile only
|
|
58
|
+
get isAlwaysRequired() {
|
|
59
|
+
return new Promise(resolve => {
|
|
60
|
+
this.settingsStore.get('Settings', value => {
|
|
61
|
+
resolve(!value.timeAutoLock);
|
|
62
|
+
});
|
|
63
|
+
});
|
|
64
|
+
}
|
|
56
65
|
resetWallet() {
|
|
57
66
|
this.settingsStore.set('Settings', _constants2.DEFAULT_SETTING);
|
|
58
67
|
this.passPhishingStore.set('PassPhishing', {});
|
package/cjs/utils/getId.js
CHANGED
package/constants/i18n.js
CHANGED
package/defaults.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
declare const ALLOWED_PATH: readonly ["/", "/settings/security", "/accounts/connect-ledger", "/accounts/restore-json", "/accounts/detail", "/accounts/new-seed-phrase"];
|
|
2
2
|
declare const PHISHING_PAGE_REDIRECT = "/phishing-page-detected";
|
|
3
3
|
declare const EXTENSION_PREFIX: string;
|
|
4
|
+
declare const ID_PREFIX: string;
|
|
4
5
|
declare const PORT_MOBILE: string;
|
|
5
6
|
declare const PORT_CONTENT: string;
|
|
6
7
|
declare const PORT_EXTENSION: string;
|
|
@@ -8,4 +9,4 @@ declare const MESSAGE_ORIGIN_PAGE: string;
|
|
|
8
9
|
declare const MESSAGE_ORIGIN_CONTENT: string;
|
|
9
10
|
declare const PASSWORD_EXPIRY_MIN = 15;
|
|
10
11
|
declare const PASSWORD_EXPIRY_MS: number;
|
|
11
|
-
export { ALLOWED_PATH, PASSWORD_EXPIRY_MIN, PASSWORD_EXPIRY_MS, PHISHING_PAGE_REDIRECT, EXTENSION_PREFIX, PORT_MOBILE, PORT_CONTENT, PORT_EXTENSION, MESSAGE_ORIGIN_PAGE, MESSAGE_ORIGIN_CONTENT };
|
|
12
|
+
export { ALLOWED_PATH, PASSWORD_EXPIRY_MIN, PASSWORD_EXPIRY_MS, PHISHING_PAGE_REDIRECT, EXTENSION_PREFIX, ID_PREFIX, PORT_MOBILE, PORT_CONTENT, PORT_EXTENSION, MESSAGE_ORIGIN_PAGE, MESSAGE_ORIGIN_CONTENT };
|
package/defaults.js
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
const ALLOWED_PATH = ['/', '/settings/security', '/accounts/connect-ledger', '/accounts/restore-json', '/accounts/detail', '/accounts/new-seed-phrase'];
|
|
5
5
|
const PHISHING_PAGE_REDIRECT = '/phishing-page-detected';
|
|
6
6
|
const EXTENSION_PREFIX = process.env.EXTENSION_PREFIX || '';
|
|
7
|
+
const ID_PREFIX = process.env.ID_PREFIX || EXTENSION_PREFIX || '';
|
|
7
8
|
const PORT_MOBILE = `${EXTENSION_PREFIX}mobile`;
|
|
8
9
|
const PORT_CONTENT = `${EXTENSION_PREFIX}koni-content`;
|
|
9
10
|
const PORT_EXTENSION = `${EXTENSION_PREFIX}koni-extension`;
|
|
@@ -11,4 +12,4 @@ const MESSAGE_ORIGIN_PAGE = `${EXTENSION_PREFIX}koni-page`;
|
|
|
11
12
|
const MESSAGE_ORIGIN_CONTENT = `${EXTENSION_PREFIX}koni-content`;
|
|
12
13
|
const PASSWORD_EXPIRY_MIN = 15;
|
|
13
14
|
const PASSWORD_EXPIRY_MS = PASSWORD_EXPIRY_MIN * 60 * 1000;
|
|
14
|
-
export { ALLOWED_PATH, PASSWORD_EXPIRY_MIN, PASSWORD_EXPIRY_MS, PHISHING_PAGE_REDIRECT, EXTENSION_PREFIX, PORT_MOBILE, PORT_CONTENT, PORT_EXTENSION, MESSAGE_ORIGIN_PAGE, MESSAGE_ORIGIN_CONTENT };
|
|
15
|
+
export { ALLOWED_PATH, PASSWORD_EXPIRY_MIN, PASSWORD_EXPIRY_MS, PHISHING_PAGE_REDIRECT, EXTENSION_PREFIX, ID_PREFIX, PORT_MOBILE, PORT_CONTENT, PORT_EXTENSION, MESSAGE_ORIGIN_PAGE, MESSAGE_ORIGIN_CONTENT };
|
package/koni/api/nft/config.d.ts
CHANGED
|
@@ -17,10 +17,10 @@ export declare const UNIQUE_IPFS_GATEWAY = "https://ipfs.unique.network/ipfs/";
|
|
|
17
17
|
export declare const NFT_STORAGE_GATEWAY = "https://nftstorage.link/ipfs/";
|
|
18
18
|
export declare const IPFS_W3S_LINK = "https://w3s.link/ipfs/";
|
|
19
19
|
export declare const GATEWAY_IPFS_IO = "https://gateway.ipfs.io/ipfs/";
|
|
20
|
+
export declare const IPFS_IO = "https://ipfs.io/ipfs/";
|
|
20
21
|
export declare const DWEB_LINK = "https://dweb.link/ipfs/";
|
|
21
22
|
export declare const IPFS_GATEWAY_4EVERLAND = "https://4everland.io/ipfs/";
|
|
22
23
|
export declare const IPFS_FLEEK = "https://ipfs.fleek.co/ipfs/";
|
|
23
|
-
export declare const IPFS_HARDBIN = "https://hardbin.com/ipfs/";
|
|
24
24
|
export declare enum SUPPORTED_NFT_NETWORKS {
|
|
25
25
|
karura = "karura",
|
|
26
26
|
acala = "acala",
|
package/koni/api/nft/config.js
CHANGED
|
@@ -21,10 +21,10 @@ export const UNIQUE_IPFS_GATEWAY = 'https://ipfs.unique.network/ipfs/';
|
|
|
21
21
|
export const NFT_STORAGE_GATEWAY = 'https://nftstorage.link/ipfs/';
|
|
22
22
|
export const IPFS_W3S_LINK = 'https://w3s.link/ipfs/';
|
|
23
23
|
export const GATEWAY_IPFS_IO = 'https://gateway.ipfs.io/ipfs/';
|
|
24
|
+
export const IPFS_IO = 'https://ipfs.io/ipfs/';
|
|
24
25
|
export const DWEB_LINK = 'https://dweb.link/ipfs/';
|
|
25
26
|
export const IPFS_GATEWAY_4EVERLAND = 'https://4everland.io/ipfs/';
|
|
26
27
|
export const IPFS_FLEEK = 'https://ipfs.fleek.co/ipfs/';
|
|
27
|
-
export const IPFS_HARDBIN = 'https://hardbin.com/ipfs/';
|
|
28
28
|
export let SUPPORTED_NFT_NETWORKS;
|
|
29
29
|
(function (SUPPORTED_NFT_NETWORKS) {
|
|
30
30
|
SUPPORTED_NFT_NETWORKS["karura"] = "karura";
|
|
@@ -76,26 +76,24 @@ const RANDOM_IPFS_GATEWAY_SETTING = [{
|
|
|
76
76
|
}, {
|
|
77
77
|
provider: PINATA_IPFS_GATEWAY,
|
|
78
78
|
weight: 1 // Rate limit too low
|
|
79
|
+
}, {
|
|
80
|
+
provider: DWEB_LINK,
|
|
81
|
+
weight: 5
|
|
79
82
|
}, {
|
|
80
83
|
provider: GATEWAY_IPFS_IO,
|
|
81
84
|
weight: 5
|
|
82
85
|
}, {
|
|
83
|
-
provider:
|
|
86
|
+
provider: IPFS_IO,
|
|
84
87
|
weight: 5
|
|
88
|
+
}, {
|
|
89
|
+
provider: NFT_STORAGE_GATEWAY,
|
|
90
|
+
weight: 50
|
|
85
91
|
}];
|
|
86
92
|
if (!RuntimeInfo.protocol || RuntimeInfo.protocol && !RuntimeInfo.protocol.startsWith('http')) {
|
|
87
|
-
RANDOM_IPFS_GATEWAY_SETTING.push({
|
|
88
|
-
provider: NFT_STORAGE_GATEWAY,
|
|
89
|
-
weight: 50
|
|
90
|
-
});
|
|
91
93
|
RANDOM_IPFS_GATEWAY_SETTING.push({
|
|
92
94
|
provider: IPFS_FLEEK,
|
|
93
95
|
weight: 4
|
|
94
96
|
});
|
|
95
|
-
RANDOM_IPFS_GATEWAY_SETTING.push({
|
|
96
|
-
provider: IPFS_HARDBIN,
|
|
97
|
-
weight: 1
|
|
98
|
-
});
|
|
99
97
|
RANDOM_IPFS_GATEWAY_SETTING.push({
|
|
100
98
|
provider: IPFS_GATEWAY_4EVERLAND,
|
|
101
99
|
weight: 2
|
|
@@ -68,16 +68,31 @@ export default class KoniExtension {
|
|
|
68
68
|
#koniState;
|
|
69
69
|
#timeAutoLock = DEFAULT_AUTO_LOCK_TIME;
|
|
70
70
|
#skipAutoLock = false;
|
|
71
|
+
#alwaysLock = false;
|
|
72
|
+
#firstTime = true;
|
|
71
73
|
constructor(state) {
|
|
72
74
|
this.#koniState = state;
|
|
73
75
|
const updateTimeAutoLock = rs => {
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
76
|
+
// Check time auto lock change
|
|
77
|
+
if (this.#timeAutoLock !== rs.timeAutoLock) {
|
|
78
|
+
this.#timeAutoLock = rs.timeAutoLock;
|
|
79
|
+
this.#alwaysLock = !rs.timeAutoLock;
|
|
80
|
+
clearTimeout(this.#lockTimeOut);
|
|
81
|
+
if (this.#timeAutoLock > 0) {
|
|
82
|
+
this.#lockTimeOut = setTimeout(() => {
|
|
83
|
+
if (!this.#skipAutoLock) {
|
|
84
|
+
this.keyringLock();
|
|
85
|
+
}
|
|
86
|
+
}, this.#timeAutoLock * 60 * 1000);
|
|
87
|
+
} else if (this.#alwaysLock) {
|
|
88
|
+
if (!this.#firstTime) {
|
|
89
|
+
this.keyringLock();
|
|
90
|
+
}
|
|
79
91
|
}
|
|
80
|
-
}
|
|
92
|
+
}
|
|
93
|
+
if (this.#firstTime) {
|
|
94
|
+
this.#firstTime = false;
|
|
95
|
+
}
|
|
81
96
|
};
|
|
82
97
|
this.#koniState.settingService.getSettings(updateTimeAutoLock);
|
|
83
98
|
this.#koniState.settingService.getSubject().subscribe({
|
|
@@ -1126,6 +1141,9 @@ export default class KoniExtension {
|
|
|
1126
1141
|
resolve();
|
|
1127
1142
|
});
|
|
1128
1143
|
});
|
|
1144
|
+
if (this.#alwaysLock) {
|
|
1145
|
+
this.keyringLock();
|
|
1146
|
+
}
|
|
1129
1147
|
return addressDict;
|
|
1130
1148
|
}
|
|
1131
1149
|
async accountsForgetOverride({
|
|
@@ -1296,6 +1314,9 @@ export default class KoniExtension {
|
|
|
1296
1314
|
keyring.restoreAccount(file, password, withMasterPassword);
|
|
1297
1315
|
this._addAddressToAuthList(address, isAllowed);
|
|
1298
1316
|
});
|
|
1317
|
+
if (this.#alwaysLock) {
|
|
1318
|
+
this.keyringLock();
|
|
1319
|
+
}
|
|
1299
1320
|
} catch (error) {
|
|
1300
1321
|
throw new Error(error.message);
|
|
1301
1322
|
}
|
|
@@ -1317,6 +1338,9 @@ export default class KoniExtension {
|
|
|
1317
1338
|
keyring.restoreAccounts(file, password);
|
|
1318
1339
|
this._addAddressesToAuthList(addressList, isAllowed);
|
|
1319
1340
|
});
|
|
1341
|
+
if (this.#alwaysLock) {
|
|
1342
|
+
this.keyringLock();
|
|
1343
|
+
}
|
|
1320
1344
|
} catch (error) {
|
|
1321
1345
|
throw new Error(error.message);
|
|
1322
1346
|
}
|
|
@@ -2177,6 +2201,9 @@ export default class KoniExtension {
|
|
|
2177
2201
|
resolve();
|
|
2178
2202
|
});
|
|
2179
2203
|
});
|
|
2204
|
+
if (this.#alwaysLock) {
|
|
2205
|
+
this.keyringLock();
|
|
2206
|
+
}
|
|
2180
2207
|
return {
|
|
2181
2208
|
errors: [],
|
|
2182
2209
|
success: true
|
|
@@ -2693,6 +2720,9 @@ export default class KoniExtension {
|
|
|
2693
2720
|
};
|
|
2694
2721
|
}
|
|
2695
2722
|
this.#koniState.updateKeyringState();
|
|
2723
|
+
if (this.#alwaysLock) {
|
|
2724
|
+
this.keyringLock();
|
|
2725
|
+
}
|
|
2696
2726
|
return {
|
|
2697
2727
|
status: true,
|
|
2698
2728
|
errors: []
|
|
@@ -2744,8 +2774,7 @@ export default class KoniExtension {
|
|
|
2744
2774
|
// Lock wallet
|
|
2745
2775
|
|
|
2746
2776
|
keyringLock() {
|
|
2747
|
-
|
|
2748
|
-
this.#koniState.updateKeyringState();
|
|
2777
|
+
this.#koniState.keyringService.lock();
|
|
2749
2778
|
clearTimeout(this.#lockTimeOut);
|
|
2750
2779
|
}
|
|
2751
2780
|
|
|
@@ -2841,6 +2870,9 @@ export default class KoniExtension {
|
|
|
2841
2870
|
// In case evm chain, must be cut 2 character after 0x
|
|
2842
2871
|
signature: isEvm ? `0x${result.signature.slice(4)}` : result.signature
|
|
2843
2872
|
});
|
|
2873
|
+
if (this.#alwaysLock) {
|
|
2874
|
+
this.keyringLock();
|
|
2875
|
+
}
|
|
2844
2876
|
return true;
|
|
2845
2877
|
}
|
|
2846
2878
|
|
|
@@ -2937,6 +2969,9 @@ export default class KoniExtension {
|
|
|
2937
2969
|
keyring.addPair(childPair, true);
|
|
2938
2970
|
this._addAddressToAuthList(address, true);
|
|
2939
2971
|
});
|
|
2972
|
+
if (this.#alwaysLock) {
|
|
2973
|
+
this.keyringLock();
|
|
2974
|
+
}
|
|
2940
2975
|
return true;
|
|
2941
2976
|
}
|
|
2942
2977
|
validateDerivePath({
|
|
@@ -3442,11 +3477,13 @@ export default class KoniExtension {
|
|
|
3442
3477
|
// eslint-disable-next-line @typescript-eslint/require-await
|
|
3443
3478
|
async handle(id, type, request, port) {
|
|
3444
3479
|
clearTimeout(this.#lockTimeOut);
|
|
3445
|
-
this.#
|
|
3446
|
-
|
|
3447
|
-
this
|
|
3448
|
-
|
|
3449
|
-
|
|
3480
|
+
if (this.#timeAutoLock > 0) {
|
|
3481
|
+
this.#lockTimeOut = setTimeout(() => {
|
|
3482
|
+
if (!this.#skipAutoLock) {
|
|
3483
|
+
this.keyringLock();
|
|
3484
|
+
}
|
|
3485
|
+
}, this.#timeAutoLock * 60 * 1000);
|
|
3486
|
+
}
|
|
3450
3487
|
switch (type) {
|
|
3451
3488
|
/// Clone from PolkadotJs
|
|
3452
3489
|
case 'pri(accounts.create.external)':
|
package/package.json
CHANGED
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"./cjs/detectPackage.js"
|
|
18
18
|
],
|
|
19
19
|
"type": "module",
|
|
20
|
-
"version": "1.1.
|
|
20
|
+
"version": "1.1.11-1",
|
|
21
21
|
"main": "./cjs/index.js",
|
|
22
22
|
"module": "./index.js",
|
|
23
23
|
"types": "./index.d.ts",
|
|
@@ -1221,11 +1221,11 @@
|
|
|
1221
1221
|
"@reduxjs/toolkit": "^1.9.1",
|
|
1222
1222
|
"@sora-substrate/type-definitions": "^1.17.7",
|
|
1223
1223
|
"@substrate/connect": "^0.7.26",
|
|
1224
|
-
"@subwallet/chain-list": "0.2.
|
|
1225
|
-
"@subwallet/extension-base": "^1.1.
|
|
1226
|
-
"@subwallet/extension-chains": "^1.1.
|
|
1227
|
-
"@subwallet/extension-dapp": "^1.1.
|
|
1228
|
-
"@subwallet/extension-inject": "^1.1.
|
|
1224
|
+
"@subwallet/chain-list": "0.2.13",
|
|
1225
|
+
"@subwallet/extension-base": "^1.1.11-1",
|
|
1226
|
+
"@subwallet/extension-chains": "^1.1.11-1",
|
|
1227
|
+
"@subwallet/extension-dapp": "^1.1.11-1",
|
|
1228
|
+
"@subwallet/extension-inject": "^1.1.11-1",
|
|
1229
1229
|
"@subwallet/keyring": "^0.0.10",
|
|
1230
1230
|
"@subwallet/ui-keyring": "^0.0.10",
|
|
1231
1231
|
"@walletconnect/sign-client": "^2.8.4",
|
package/packageInfo.js
CHANGED
|
@@ -7,5 +7,5 @@ export const packageInfo = {
|
|
|
7
7
|
name: '@subwallet/extension-base',
|
|
8
8
|
path: (import.meta && import.meta.url) ? new URL(import.meta.url).pathname.substring(0, new URL(import.meta.url).pathname.lastIndexOf('/') + 1) : 'auto',
|
|
9
9
|
type: 'esm',
|
|
10
|
-
version: '1.1.
|
|
10
|
+
version: '1.1.11-1'
|
|
11
11
|
};
|
|
@@ -49,7 +49,7 @@ export const _NFT_CHAIN_GROUP = {
|
|
|
49
49
|
// Staking--------------------------------------------------------------------------------------------------------------
|
|
50
50
|
|
|
51
51
|
export const _STAKING_CHAIN_GROUP = {
|
|
52
|
-
relay: ['polkadot', 'kusama', 'aleph', 'polkadex', 'ternoa', 'ternoa_alphanet', 'alephTest', 'polkadexTest', 'westend', 'kate', 'edgeware'],
|
|
52
|
+
relay: ['polkadot', 'kusama', 'aleph', 'polkadex', 'ternoa', 'ternoa_alphanet', 'alephTest', 'polkadexTest', 'westend', 'kate', 'edgeware', 'creditcoin'],
|
|
53
53
|
para: ['moonbeam', 'moonriver', 'moonbase', 'turing', 'turingStaging', 'bifrost', 'bifrost_testnet', 'calamari_test', 'calamari'],
|
|
54
54
|
astar: ['astar', 'shiden', 'shibuya'],
|
|
55
55
|
amplitude: ['amplitude', 'amplitude_test', 'kilt', 'kilt_peregrine', 'pendulum'],
|
|
@@ -89,7 +89,8 @@ export const _STAKING_ERA_LENGTH_MAP = {
|
|
|
89
89
|
kilt: 2,
|
|
90
90
|
kilt_peregrine: 2,
|
|
91
91
|
edgeware: 6,
|
|
92
|
-
kate: 6
|
|
92
|
+
kate: 6,
|
|
93
|
+
creditcoin: 24
|
|
93
94
|
};
|
|
94
95
|
export const _PARACHAIN_INFLATION_DISTRIBUTION = {
|
|
95
96
|
moonbeam: {
|
|
@@ -87,6 +87,10 @@ export class KeyringService {
|
|
|
87
87
|
this.eventService.emit('account.updateCurrent', currentAccountData);
|
|
88
88
|
this.currentAccountStore.set('CurrentAccountInfo', currentAccountData);
|
|
89
89
|
}
|
|
90
|
+
lock() {
|
|
91
|
+
keyring.lockAll();
|
|
92
|
+
this.updateKeyringState();
|
|
93
|
+
}
|
|
90
94
|
resetWallet(resetAll) {
|
|
91
95
|
keyring.resetWallet(resetAll);
|
|
92
96
|
this.updateKeyringState();
|
|
@@ -38,11 +38,17 @@ export default class EvmRequestHandler {
|
|
|
38
38
|
getConfirmationsQueueSubject() {
|
|
39
39
|
return this.confirmationsQueueSubject;
|
|
40
40
|
}
|
|
41
|
-
addConfirmation(id, url, type, payload, options = {}, validator) {
|
|
41
|
+
async addConfirmation(id, url, type, payload, options = {}, validator) {
|
|
42
42
|
const confirmations = this.confirmationsQueueSubject.getValue();
|
|
43
43
|
const confirmationType = confirmations[type];
|
|
44
44
|
const payloadJson = JSON.stringify(payload);
|
|
45
45
|
const isInternal = isInternalRequest(url);
|
|
46
|
+
if (['evmSignatureRequest', 'evmSendTransactionRequest'].includes(type)) {
|
|
47
|
+
const isAlwaysRequired = await this.#requestService.settingService.isAlwaysRequired;
|
|
48
|
+
if (isAlwaysRequired) {
|
|
49
|
+
this.#requestService.keyringService.lock();
|
|
50
|
+
}
|
|
51
|
+
}
|
|
46
52
|
|
|
47
53
|
// Check duplicate request
|
|
48
54
|
const duplicated = Object.values(confirmationType).find(c => c.url === url && c.payloadJson === payloadJson);
|
|
@@ -182,6 +188,12 @@ export default class EvmRequestHandler {
|
|
|
182
188
|
} else if (t === 'evmSendTransactionRequest') {
|
|
183
189
|
result.payload = await this.signTransaction(request);
|
|
184
190
|
}
|
|
191
|
+
if (t === 'evmSignatureRequest' || t === 'evmSendTransactionRequest') {
|
|
192
|
+
const isAlwaysRequired = await this.#requestService.settingService.isAlwaysRequired;
|
|
193
|
+
if (isAlwaysRequired) {
|
|
194
|
+
this.#requestService.keyringService.lock();
|
|
195
|
+
}
|
|
196
|
+
}
|
|
185
197
|
}
|
|
186
198
|
}
|
|
187
199
|
async completeConfirmation(request) {
|
|
@@ -57,8 +57,12 @@ export default class SubstrateRequestHandler {
|
|
|
57
57
|
get numSubstrateRequests() {
|
|
58
58
|
return Object.keys(this.#substrateRequests).length;
|
|
59
59
|
}
|
|
60
|
-
sign(url, request, account, _id) {
|
|
60
|
+
async sign(url, request, account, _id) {
|
|
61
61
|
const id = _id || getId();
|
|
62
|
+
const isAlwaysRequired = await this.#requestService.settingService.isAlwaysRequired;
|
|
63
|
+
if (isAlwaysRequired) {
|
|
64
|
+
this.#requestService.keyringService.lock();
|
|
65
|
+
}
|
|
62
66
|
return new Promise((resolve, reject) => {
|
|
63
67
|
this.#substrateRequests[id] = {
|
|
64
68
|
...this.signComplete(id, resolve, reject),
|
|
@@ -71,7 +75,11 @@ export default class SubstrateRequestHandler {
|
|
|
71
75
|
this.#requestService.popupOpen();
|
|
72
76
|
});
|
|
73
77
|
}
|
|
74
|
-
signTransaction(id, address, url, payload) {
|
|
78
|
+
async signTransaction(id, address, url, payload) {
|
|
79
|
+
const isAlwaysRequired = await this.#requestService.settingService.isAlwaysRequired;
|
|
80
|
+
if (isAlwaysRequired) {
|
|
81
|
+
this.#requestService.keyringService.lock();
|
|
82
|
+
}
|
|
75
83
|
return new Promise((resolve, reject) => {
|
|
76
84
|
const pair = keyring.getPair(address);
|
|
77
85
|
const account = {
|
|
@@ -10,8 +10,8 @@ import { SignerPayloadJSON } from '@polkadot/types/types/extrinsic';
|
|
|
10
10
|
import { AuthUrls, MetaRequest } from './types';
|
|
11
11
|
export default class RequestService {
|
|
12
12
|
#private;
|
|
13
|
-
private keyringService;
|
|
14
13
|
readonly settingService: SettingService;
|
|
14
|
+
readonly keyringService: KeyringService;
|
|
15
15
|
constructor(chainService: ChainService, settingService: SettingService, keyringService: KeyringService);
|
|
16
16
|
get numAllRequests(): number;
|
|
17
17
|
updateIconV2(shouldClose?: boolean): void;
|
|
@@ -15,9 +15,9 @@ export default class RequestService {
|
|
|
15
15
|
|
|
16
16
|
// Common
|
|
17
17
|
constructor(chainService, settingService, keyringService) {
|
|
18
|
-
this.keyringService = keyringService;
|
|
19
18
|
this.#chainService = chainService;
|
|
20
19
|
this.settingService = settingService;
|
|
20
|
+
this.keyringService = keyringService;
|
|
21
21
|
this.#popupHandler = new PopupHandler(this);
|
|
22
22
|
this.#metadataRequestHandler = new MetadataRequestHandler(this);
|
|
23
23
|
this.#authRequestHandler = new AuthRequestHandler(this, this.#chainService, this.keyringService);
|
|
@@ -10,5 +10,6 @@ export default class SettingService {
|
|
|
10
10
|
passPhishingSubject(): Subject<Record<string, PassPhishing>>;
|
|
11
11
|
getPassPhishingList(update: (value: Record<string, PassPhishing>) => void): void;
|
|
12
12
|
setPassPhishing(data: Record<string, PassPhishing>, callback?: () => void): void;
|
|
13
|
+
get isAlwaysRequired(): Promise<boolean>;
|
|
13
14
|
resetWallet(): void;
|
|
14
15
|
}
|
|
@@ -45,6 +45,15 @@ export default class SettingService {
|
|
|
45
45
|
setPassPhishing(data, callback) {
|
|
46
46
|
this.passPhishingStore.set('PassPhishing', data, callback);
|
|
47
47
|
}
|
|
48
|
+
|
|
49
|
+
// Use for mobile only
|
|
50
|
+
get isAlwaysRequired() {
|
|
51
|
+
return new Promise(resolve => {
|
|
52
|
+
this.settingsStore.get('Settings', value => {
|
|
53
|
+
resolve(!value.timeAutoLock);
|
|
54
|
+
});
|
|
55
|
+
});
|
|
56
|
+
}
|
|
48
57
|
resetWallet() {
|
|
49
58
|
this.settingsStore.set('Settings', DEFAULT_SETTING);
|
|
50
59
|
this.passPhishingStore.set('PassPhishing', {});
|
|
@@ -11,13 +11,13 @@ import { BehaviorSubject } from 'rxjs';
|
|
|
11
11
|
import { TransactionConfig } from 'web3-core';
|
|
12
12
|
import { HexString } from '@polkadot/util/types';
|
|
13
13
|
export default class TransactionService {
|
|
14
|
+
private readonly balanceService;
|
|
14
15
|
private readonly chainService;
|
|
15
|
-
private readonly eventService;
|
|
16
16
|
private readonly databaseService;
|
|
17
|
-
private readonly
|
|
18
|
-
private readonly balanceService;
|
|
17
|
+
private readonly eventService;
|
|
19
18
|
private readonly historyService;
|
|
20
19
|
private readonly notificationService;
|
|
20
|
+
private readonly requestService;
|
|
21
21
|
private readonly transactionSubject;
|
|
22
22
|
private get transactions();
|
|
23
23
|
constructor(chainService: ChainService, eventService: EventService, requestService: RequestService, balanceService: BalanceService, historyService: HistoryService, notificationService: NotificationService, databaseService: DatabaseService);
|
package/utils/getId.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
// Copyright 2019-2022 @polkadot/extension authors & contributors
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
|
-
import {
|
|
4
|
+
import { ID_PREFIX } from "../defaults.js";
|
|
5
5
|
let counter = 0;
|
|
6
6
|
export function getId() {
|
|
7
|
-
return `${
|
|
7
|
+
return `${ID_PREFIX}.${Date.now()}.${++counter}`;
|
|
8
8
|
}
|