@subwallet/extension-base 1.1.9-0 → 1.1.10-0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/background/KoniTypes.d.ts +13 -1
- package/background/KoniTypes.js +5 -0
- package/background/errors/BalanceError.js +7 -5
- package/background/errors/EvmProviderError.js +10 -8
- package/background/errors/ProviderError.js +5 -4
- package/background/errors/TransactionError.js +22 -17
- package/background/handlers/Extension.js +18 -18
- package/background/handlers/State.js +5 -5
- package/background/handlers/Tabs.js +1 -1
- package/background/warnings/TransactionWarning.js +4 -2
- package/cjs/background/KoniTypes.js +7 -1
- package/cjs/background/errors/BalanceError.js +7 -5
- package/cjs/background/errors/EvmProviderError.js +10 -8
- package/cjs/background/errors/ProviderError.js +5 -4
- package/cjs/background/errors/TransactionError.js +22 -17
- package/cjs/background/handlers/Extension.js +18 -18
- package/cjs/background/handlers/State.js +5 -5
- package/cjs/background/handlers/Tabs.js +1 -1
- package/cjs/background/warnings/TransactionWarning.js +4 -2
- package/cjs/constants/i18n.js +4 -1
- package/cjs/constants/index.js +12 -0
- package/cjs/constants/storage.js +11 -0
- package/cjs/koni/api/dotsama/parseTransaction.js +2 -1
- package/cjs/koni/api/staking/bonding/paraChain.js +10 -6
- package/cjs/koni/api/staking/bonding/relayChain.js +16 -7
- package/cjs/koni/api/staking/bonding/utils.js +80 -7
- package/cjs/koni/background/handlers/Extension.js +206 -170
- package/cjs/koni/background/handlers/State.js +19 -14
- package/cjs/koni/background/handlers/Tabs.js +15 -14
- package/cjs/packageInfo.js +1 -1
- package/cjs/services/balance-service/index.js +12 -3
- package/cjs/services/request-service/handler/AuthRequestHandler.js +4 -4
- package/cjs/services/request-service/handler/EvmRequestHandler.js +11 -10
- package/cjs/services/setting-service/SettingService.js +20 -7
- package/cjs/services/setting-service/constants.js +5 -1
- package/cjs/services/setting-service/i18n/Backend.js +42 -0
- package/cjs/services/setting-service/i18n/cache.js +12 -0
- package/cjs/services/setting-service/i18n/extend.js +16 -0
- package/cjs/services/setting-service/i18n/i18n.js +29 -0
- package/cjs/services/transaction-service/index.js +25 -16
- package/cjs/services/wallet-connect-service/handler/PolkadotRequestHandler.js +0 -1
- package/cjs/utils/eth/parseTransaction/base.js +1 -1
- package/cjs/utils/eth/parseTransaction/index.js +2 -1
- package/cjs/utils/index.js +2 -1
- package/constants/i18n.js +4 -1
- package/constants/index.d.ts +1 -0
- package/constants/index.js +2 -1
- package/constants/storage.d.ts +1 -0
- package/constants/storage.js +4 -0
- package/koni/api/dotsama/parseTransaction.js +2 -1
- package/koni/api/staking/bonding/paraChain.js +11 -7
- package/koni/api/staking/bonding/relayChain.js +17 -8
- package/koni/api/staking/bonding/utils.d.ts +4 -0
- package/koni/api/staking/bonding/utils.js +70 -2
- package/koni/background/handlers/Extension.d.ts +1 -0
- package/koni/background/handlers/Extension.js +85 -50
- package/koni/background/handlers/State.js +19 -14
- package/koni/background/handlers/Tabs.js +15 -14
- package/package.json +31 -11
- package/packageInfo.js +1 -1
- package/services/balance-service/index.js +12 -3
- package/services/request-service/handler/AuthRequestHandler.js +4 -4
- package/services/request-service/handler/EvmRequestHandler.js +11 -10
- package/services/setting-service/SettingService.d.ts +1 -0
- package/services/setting-service/SettingService.js +17 -5
- package/services/setting-service/constants.d.ts +2 -1
- package/services/setting-service/constants.js +4 -1
- package/services/setting-service/i18n/Backend.d.ts +9 -0
- package/services/setting-service/i18n/Backend.js +34 -0
- package/services/setting-service/i18n/cache.d.ts +2 -0
- package/services/setting-service/i18n/cache.js +5 -0
- package/services/setting-service/i18n/extend.d.ts +2 -0
- package/services/setting-service/i18n/extend.js +8 -0
- package/services/setting-service/i18n/i18n.d.ts +2 -0
- package/services/setting-service/i18n/i18n.js +21 -0
- package/services/transaction-service/index.js +25 -16
- package/services/wallet-connect-service/handler/PolkadotRequestHandler.js +0 -1
- package/utils/eth/parseTransaction/base.js +1 -1
- package/utils/eth/parseTransaction/index.js +2 -1
- package/utils/index.js +2 -1
- package/cjs/utils/keyring.js +0 -57
- package/utils/keyring.d.ts +0 -4
- package/utils/keyring.js +0 -49
|
@@ -304,12 +304,16 @@ export interface CurrentAccountInfo {
|
|
|
304
304
|
currentGenesisHash: string | null;
|
|
305
305
|
allGenesisHash?: string;
|
|
306
306
|
}
|
|
307
|
-
export declare type LanguageType = 'en' | 'zh' | 'fr' | 'tr' | 'pl' | 'th' | 'ur' | 'vi' | 'ja';
|
|
307
|
+
export declare type LanguageType = 'en' | 'zh' | 'fr' | 'tr' | 'pl' | 'th' | 'ur' | 'vi' | 'ja' | 'ru';
|
|
308
308
|
export declare type LanguageOptionType = {
|
|
309
309
|
text: string;
|
|
310
310
|
value: LanguageType;
|
|
311
311
|
};
|
|
312
312
|
export declare type BrowserConfirmationType = 'extension' | 'popup' | 'window';
|
|
313
|
+
export declare enum WalletUnlockType {
|
|
314
|
+
ALWAYS_REQUIRED = "always_required",
|
|
315
|
+
WHEN_NEEDED = "when_needed"
|
|
316
|
+
}
|
|
313
317
|
export interface UiSettings {
|
|
314
318
|
language: LanguageType;
|
|
315
319
|
browserConfirmationType: BrowserConfirmationType;
|
|
@@ -319,6 +323,7 @@ export interface UiSettings {
|
|
|
319
323
|
theme: ThemeNames;
|
|
320
324
|
camera: boolean;
|
|
321
325
|
timeAutoLock: number;
|
|
326
|
+
unlockType: WalletUnlockType;
|
|
322
327
|
enableChainPatrol: boolean;
|
|
323
328
|
walletReference: string;
|
|
324
329
|
}
|
|
@@ -329,6 +334,9 @@ export declare type RequestCameraSettings = {
|
|
|
329
334
|
export declare type RequestChangeTimeAutoLock = {
|
|
330
335
|
autoLockTime: number;
|
|
331
336
|
};
|
|
337
|
+
export declare type RequestUnlockType = {
|
|
338
|
+
unlockType: WalletUnlockType;
|
|
339
|
+
};
|
|
332
340
|
export declare type RequestChangeEnableChainPatrol = {
|
|
333
341
|
enable: boolean;
|
|
334
342
|
};
|
|
@@ -1337,6 +1345,9 @@ export interface KeyringState {
|
|
|
1337
1345
|
hasMasterPassword: boolean;
|
|
1338
1346
|
isLocked: boolean;
|
|
1339
1347
|
}
|
|
1348
|
+
export interface UIViewState {
|
|
1349
|
+
isUILocked: boolean;
|
|
1350
|
+
}
|
|
1340
1351
|
export interface AddressBookState {
|
|
1341
1352
|
contacts: AddressJson[];
|
|
1342
1353
|
recent: AddressJson[];
|
|
@@ -1624,6 +1635,7 @@ export interface KoniRequestSignatures {
|
|
|
1624
1635
|
'pri(settings.saveBrowserConfirmationType)': [BrowserConfirmationType, boolean];
|
|
1625
1636
|
'pri(settings.saveCamera)': [RequestCameraSettings, boolean];
|
|
1626
1637
|
'pri(settings.saveAutoLockTime)': [RequestChangeTimeAutoLock, boolean];
|
|
1638
|
+
'pri(settings.saveUnlockType)': [RequestUnlockType, boolean];
|
|
1627
1639
|
'pri(settings.saveEnableChainPatrol)': [RequestChangeEnableChainPatrol, boolean];
|
|
1628
1640
|
'pri(settings.saveLanguage)': [RequestChangeLanguage, boolean];
|
|
1629
1641
|
'pri(settings.saveShowZeroBalance)': [RequestChangeShowZeroBalance, boolean];
|
package/background/KoniTypes.js
CHANGED
|
@@ -42,6 +42,11 @@ export let ContractType;
|
|
|
42
42
|
ContractType["wasm"] = "wasm";
|
|
43
43
|
ContractType["evm"] = "evm";
|
|
44
44
|
})(ContractType || (ContractType = {}));
|
|
45
|
+
export let WalletUnlockType;
|
|
46
|
+
(function (WalletUnlockType) {
|
|
47
|
+
WalletUnlockType["ALWAYS_REQUIRED"] = "always_required";
|
|
48
|
+
WalletUnlockType["WHEN_NEEDED"] = "when_needed";
|
|
49
|
+
})(WalletUnlockType || (WalletUnlockType = {}));
|
|
45
50
|
export let TransactionDirection;
|
|
46
51
|
(function (TransactionDirection) {
|
|
47
52
|
TransactionDirection["SEND"] = "send";
|
|
@@ -3,30 +3,32 @@
|
|
|
3
3
|
|
|
4
4
|
import { SWError } from '@subwallet/extension-base/background/errors/SWError';
|
|
5
5
|
import { BalanceErrorType } from '@subwallet/extension-base/background/KoniTypes';
|
|
6
|
+
import { detectTranslate } from '@subwallet/extension-base/utils';
|
|
7
|
+
import { t } from 'i18next';
|
|
6
8
|
|
|
7
9
|
// Todo: finish this map in the future
|
|
8
10
|
const defaultErrorMap = {
|
|
9
11
|
[BalanceErrorType.NETWORK_ERROR]: {
|
|
10
|
-
message: '
|
|
12
|
+
message: detectTranslate('Network is inactive. Please enable network'),
|
|
11
13
|
code: undefined
|
|
12
14
|
},
|
|
13
15
|
[BalanceErrorType.TOKEN_ERROR]: {
|
|
14
|
-
message: 'Token is not supported',
|
|
16
|
+
message: detectTranslate('Token is not supported'),
|
|
15
17
|
code: undefined
|
|
16
18
|
},
|
|
17
19
|
[BalanceErrorType.TIMEOUT]: {
|
|
18
|
-
message: '
|
|
20
|
+
message: detectTranslate('Unable to get balance. Please re-enable the network'),
|
|
19
21
|
code: undefined
|
|
20
22
|
},
|
|
21
23
|
[BalanceErrorType.GET_BALANCE_ERROR]: {
|
|
22
|
-
message: '
|
|
24
|
+
message: detectTranslate('Unable to get balance. Please re-enable the network'),
|
|
23
25
|
code: undefined
|
|
24
26
|
}
|
|
25
27
|
};
|
|
26
28
|
export class BalanceError extends SWError {
|
|
27
29
|
constructor(errorType, errMessage, data) {
|
|
28
30
|
const defaultErr = defaultErrorMap[errorType];
|
|
29
|
-
const message = errMessage || (defaultErr === null || defaultErr === void 0 ? void 0 : defaultErr.message) || errorType;
|
|
31
|
+
const message = errMessage || t((defaultErr === null || defaultErr === void 0 ? void 0 : defaultErr.message) || '') || errorType;
|
|
30
32
|
super(errorType, message, defaultErr === null || defaultErr === void 0 ? void 0 : defaultErr.code, data);
|
|
31
33
|
this.errorType = errorType;
|
|
32
34
|
}
|
|
@@ -2,33 +2,35 @@
|
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
4
|
import { SWError } from '@subwallet/extension-base/background/errors/SWError';
|
|
5
|
+
import { detectTranslate } from '@subwallet/extension-base/utils';
|
|
6
|
+
import { t } from 'i18next';
|
|
5
7
|
const defaultErrorMap = {
|
|
6
8
|
USER_REJECTED_REQUEST: {
|
|
7
|
-
message: 'User Rejected Request',
|
|
9
|
+
message: detectTranslate('User Rejected Request'),
|
|
8
10
|
code: 4001
|
|
9
11
|
},
|
|
10
12
|
UNAUTHORIZED: {
|
|
11
|
-
message: '
|
|
13
|
+
message: detectTranslate('Failed to sign'),
|
|
12
14
|
code: 4100
|
|
13
15
|
},
|
|
14
16
|
UNSUPPORTED_METHOD: {
|
|
15
|
-
message: 'Unsupported Method',
|
|
17
|
+
message: detectTranslate('Unsupported Method'),
|
|
16
18
|
code: 4200
|
|
17
19
|
},
|
|
18
20
|
DISCONNECTED: {
|
|
19
|
-
message: '
|
|
21
|
+
message: detectTranslate('Network is disconnected'),
|
|
20
22
|
code: 4900
|
|
21
23
|
},
|
|
22
24
|
CHAIN_DISCONNECTED: {
|
|
23
|
-
message: '
|
|
25
|
+
message: detectTranslate('Network is disconnected'),
|
|
24
26
|
code: 4901
|
|
25
27
|
},
|
|
26
28
|
INVALID_PARAMS: {
|
|
27
|
-
message: '
|
|
29
|
+
message: detectTranslate('Undefined error. Please contact SubWallet support'),
|
|
28
30
|
code: -32602
|
|
29
31
|
},
|
|
30
32
|
INTERNAL_ERROR: {
|
|
31
|
-
message: '
|
|
33
|
+
message: detectTranslate('Undefined error. Please contact SubWallet support'),
|
|
32
34
|
code: -32603
|
|
33
35
|
}
|
|
34
36
|
};
|
|
@@ -38,7 +40,7 @@ export class EvmProviderError extends SWError {
|
|
|
38
40
|
code,
|
|
39
41
|
message
|
|
40
42
|
} = defaultErrorMap[errorType];
|
|
41
|
-
const finalMessage = errMessage
|
|
43
|
+
const finalMessage = errMessage || t(message || '') || errorType;
|
|
42
44
|
super(errorType, finalMessage, code, data);
|
|
43
45
|
this.errorType = errorType;
|
|
44
46
|
}
|
|
@@ -2,21 +2,22 @@
|
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
4
|
import { SWError } from '@subwallet/extension-base/background/errors/SWError';
|
|
5
|
+
import { detectTranslate } from '@subwallet/extension-base/utils';
|
|
5
6
|
const defaultErrorMap = {
|
|
6
7
|
CHAIN_DISCONNECTED: {
|
|
7
|
-
message: '
|
|
8
|
+
message: detectTranslate('Network is disconnected'),
|
|
8
9
|
code: undefined
|
|
9
10
|
},
|
|
10
11
|
INVALID_PARAMS: {
|
|
11
|
-
message: '
|
|
12
|
+
message: detectTranslate('Undefined error. Please contact SubWallet support'),
|
|
12
13
|
code: undefined
|
|
13
14
|
},
|
|
14
15
|
INTERNAL_ERROR: {
|
|
15
|
-
message: '
|
|
16
|
+
message: detectTranslate('Undefined error. Please contact SubWallet support'),
|
|
16
17
|
code: undefined
|
|
17
18
|
},
|
|
18
19
|
USER_REJECT: {
|
|
19
|
-
message: '
|
|
20
|
+
message: detectTranslate('Rejected by user'),
|
|
20
21
|
code: undefined
|
|
21
22
|
}
|
|
22
23
|
};
|
|
@@ -3,90 +3,95 @@
|
|
|
3
3
|
|
|
4
4
|
import { SWError } from '@subwallet/extension-base/background/errors/SWError';
|
|
5
5
|
import { BasicTxErrorType, StakingTxErrorType, TransferTxErrorType } from '@subwallet/extension-base/background/KoniTypes';
|
|
6
|
+
import { detectTranslate } from '@subwallet/extension-base/utils';
|
|
7
|
+
import { t } from 'i18next';
|
|
6
8
|
|
|
7
9
|
// Todo: finish this map in the future
|
|
8
10
|
const defaultErrorMap = {
|
|
9
11
|
NOT_ENOUGH_BALANCE: {
|
|
10
|
-
message: '
|
|
12
|
+
message: detectTranslate('Insufficient balance'),
|
|
11
13
|
code: undefined
|
|
12
14
|
},
|
|
13
15
|
CHAIN_DISCONNECTED: {
|
|
14
|
-
message: '
|
|
16
|
+
message: detectTranslate('Network is disconnected'),
|
|
15
17
|
code: undefined
|
|
16
18
|
},
|
|
17
19
|
INVALID_PARAMS: {
|
|
18
|
-
message: '
|
|
20
|
+
message: detectTranslate('Undefined error. Please contact SubWallet support'),
|
|
19
21
|
code: undefined
|
|
20
22
|
},
|
|
21
23
|
INTERNAL_ERROR: {
|
|
22
|
-
message: '
|
|
24
|
+
message: detectTranslate('Undefined error. Please contact SubWallet support'),
|
|
23
25
|
code: undefined
|
|
24
26
|
},
|
|
25
27
|
DUPLICATE_TRANSACTION: {
|
|
26
|
-
message: '
|
|
28
|
+
message: detectTranslate('Another transaction is in queue. Please try again later'),
|
|
27
29
|
code: undefined
|
|
28
30
|
},
|
|
29
31
|
UNABLE_TO_SIGN: {
|
|
30
|
-
message: 'Unable to sign',
|
|
32
|
+
message: detectTranslate('Unable to sign'),
|
|
31
33
|
code: undefined
|
|
32
34
|
},
|
|
33
35
|
USER_REJECT_REQUEST: {
|
|
34
|
-
message: '
|
|
36
|
+
message: detectTranslate('Rejected by user'),
|
|
35
37
|
code: undefined
|
|
36
38
|
},
|
|
37
39
|
UNABLE_TO_SEND: {
|
|
38
|
-
message: 'Unable to send',
|
|
40
|
+
message: detectTranslate('Unable to send'),
|
|
39
41
|
code: undefined
|
|
40
42
|
},
|
|
41
43
|
SEND_TRANSACTION_FAILED: {
|
|
42
|
-
message: 'Send transaction failed',
|
|
44
|
+
message: detectTranslate('Send transaction failed'),
|
|
43
45
|
code: undefined
|
|
44
46
|
},
|
|
45
47
|
NOT_ENOUGH_EXISTENTIAL_DEPOSIT: {
|
|
46
|
-
message: '
|
|
48
|
+
message: detectTranslate('Insufficient balance to cover existential deposit. Please decrease the transaction amount or increase your current balance'),
|
|
47
49
|
code: undefined
|
|
48
50
|
},
|
|
49
51
|
[BasicTxErrorType.UNSUPPORTED]: {
|
|
50
|
-
message: 'This
|
|
52
|
+
message: detectTranslate('This feature is not available with this token'),
|
|
51
53
|
code: undefined
|
|
52
54
|
},
|
|
53
55
|
[BasicTxErrorType.TIMEOUT]: {
|
|
54
|
-
message: 'Transaction timeout',
|
|
56
|
+
message: detectTranslate('Transaction timeout'),
|
|
55
57
|
code: undefined
|
|
56
58
|
},
|
|
57
59
|
[StakingTxErrorType.NOT_ENOUGH_MIN_STAKE]: {
|
|
58
60
|
message: 'Not enough min stake',
|
|
61
|
+
// Message specific to each case
|
|
59
62
|
code: undefined
|
|
60
63
|
},
|
|
61
64
|
[StakingTxErrorType.EXCEED_MAX_NOMINATIONS]: {
|
|
62
65
|
message: 'Exceed max nominations',
|
|
66
|
+
// Message specific to each case
|
|
63
67
|
code: undefined
|
|
64
68
|
},
|
|
65
69
|
[StakingTxErrorType.EXIST_UNSTAKING_REQUEST]: {
|
|
66
70
|
message: 'Exist unstaking request',
|
|
71
|
+
// Message specific to each case
|
|
67
72
|
code: undefined
|
|
68
73
|
},
|
|
69
74
|
[StakingTxErrorType.INVALID_ACTIVE_STAKE]: {
|
|
70
|
-
message: 'Invalid active stake',
|
|
75
|
+
message: detectTranslate('Invalid. If you unstake this amount your active stake would fall below minimum active threshold'),
|
|
71
76
|
code: undefined
|
|
72
77
|
},
|
|
73
78
|
[StakingTxErrorType.EXCEED_MAX_UNSTAKING]: {
|
|
74
|
-
message: '
|
|
79
|
+
message: detectTranslate('You reached the maximum number of unstake requests'),
|
|
75
80
|
code: undefined
|
|
76
81
|
},
|
|
77
82
|
[StakingTxErrorType.INACTIVE_NOMINATION_POOL]: {
|
|
78
|
-
message: '
|
|
83
|
+
message: detectTranslate('Invalid. Inactive nomination pool'),
|
|
79
84
|
code: undefined
|
|
80
85
|
},
|
|
81
86
|
[TransferTxErrorType.RECEIVER_NOT_ENOUGH_EXISTENTIAL_DEPOSIT]: {
|
|
82
|
-
message: 'Receiver is not enough existential deposit',
|
|
87
|
+
message: detectTranslate('Receiver is not enough existential deposit'),
|
|
83
88
|
code: undefined
|
|
84
89
|
}
|
|
85
90
|
};
|
|
86
91
|
export class TransactionError extends SWError {
|
|
87
92
|
constructor(errorType, errMessage, data) {
|
|
88
93
|
const defaultErr = defaultErrorMap[errorType];
|
|
89
|
-
const message = errMessage || (defaultErr === null || defaultErr === void 0 ? void 0 : defaultErr.message) || errorType;
|
|
94
|
+
const message = errMessage || t((defaultErr === null || defaultErr === void 0 ? void 0 : defaultErr.message) || '') || errorType;
|
|
90
95
|
super(errorType, message, defaultErr === null || defaultErr === void 0 ? void 0 : defaultErr.code, data);
|
|
91
96
|
this.errorType = errorType;
|
|
92
97
|
}
|
|
@@ -85,14 +85,14 @@ export default class Extension {
|
|
|
85
85
|
oldPass
|
|
86
86
|
}) {
|
|
87
87
|
const pair = keyring.getPair(address);
|
|
88
|
-
assert(pair, 'Unable to find
|
|
88
|
+
assert(pair, 'Unable to find account');
|
|
89
89
|
try {
|
|
90
90
|
if (!pair.isLocked) {
|
|
91
91
|
pair.lock();
|
|
92
92
|
}
|
|
93
93
|
pair.decodePkcs8(oldPass);
|
|
94
94
|
} catch (error) {
|
|
95
|
-
throw new Error('
|
|
95
|
+
throw new Error('Wrong password');
|
|
96
96
|
}
|
|
97
97
|
keyring.encryptAccount(pair, newPass);
|
|
98
98
|
return true;
|
|
@@ -102,7 +102,7 @@ export default class Extension {
|
|
|
102
102
|
name
|
|
103
103
|
}) {
|
|
104
104
|
const pair = keyring.getPair(address);
|
|
105
|
-
assert(pair, 'Unable to find
|
|
105
|
+
assert(pair, 'Unable to find account');
|
|
106
106
|
keyring.saveAccountMeta(pair, {
|
|
107
107
|
...pair.meta,
|
|
108
108
|
name
|
|
@@ -148,7 +148,7 @@ export default class Extension {
|
|
|
148
148
|
isShowing
|
|
149
149
|
}) {
|
|
150
150
|
const pair = keyring.getPair(address);
|
|
151
|
-
assert(pair, 'Unable to find
|
|
151
|
+
assert(pair, 'Unable to find account');
|
|
152
152
|
keyring.saveAccountMeta(pair, {
|
|
153
153
|
...pair.meta,
|
|
154
154
|
isHidden: !isShowing
|
|
@@ -160,7 +160,7 @@ export default class Extension {
|
|
|
160
160
|
genesisHash
|
|
161
161
|
}) {
|
|
162
162
|
const pair = keyring.getPair(address);
|
|
163
|
-
assert(pair, 'Unable to find
|
|
163
|
+
assert(pair, 'Unable to find account');
|
|
164
164
|
keyring.saveAccountMeta(pair, {
|
|
165
165
|
...pair.meta,
|
|
166
166
|
genesisHash
|
|
@@ -193,7 +193,7 @@ export default class Extension {
|
|
|
193
193
|
id
|
|
194
194
|
}) {
|
|
195
195
|
const queued = this.#state.getAuthRequest(id);
|
|
196
|
-
assert(queued, 'Unable to
|
|
196
|
+
assert(queued, 'Unable to proceed. Please try again');
|
|
197
197
|
const {
|
|
198
198
|
resolve
|
|
199
199
|
} = queued;
|
|
@@ -209,7 +209,7 @@ export default class Extension {
|
|
|
209
209
|
id
|
|
210
210
|
}) {
|
|
211
211
|
const queued = this.#state.getAuthRequest(id);
|
|
212
|
-
assert(queued, 'Unable to
|
|
212
|
+
assert(queued, 'Unable to proceed. Please try again');
|
|
213
213
|
const {
|
|
214
214
|
reject
|
|
215
215
|
} = queued;
|
|
@@ -231,7 +231,7 @@ export default class Extension {
|
|
|
231
231
|
id
|
|
232
232
|
}) {
|
|
233
233
|
const queued = this.#state.getMetaRequest(id);
|
|
234
|
-
assert(queued, 'Unable to
|
|
234
|
+
assert(queued, 'Unable to proceed. Please try again');
|
|
235
235
|
const {
|
|
236
236
|
request,
|
|
237
237
|
resolve
|
|
@@ -250,7 +250,7 @@ export default class Extension {
|
|
|
250
250
|
id
|
|
251
251
|
}) {
|
|
252
252
|
const queued = this.#state.getMetaRequest(id);
|
|
253
|
-
assert(queued, 'Unable to
|
|
253
|
+
assert(queued, 'Unable to proceed. Please try again');
|
|
254
254
|
const {
|
|
255
255
|
reject
|
|
256
256
|
} = queued;
|
|
@@ -326,11 +326,11 @@ export default class Extension {
|
|
|
326
326
|
phrase
|
|
327
327
|
} = keyExtractSuri(suri);
|
|
328
328
|
if (isHex(phrase)) {
|
|
329
|
-
assert(isHex(phrase, 256), '
|
|
329
|
+
assert(isHex(phrase, 256), 'Invalid seed phrase. Please try again.');
|
|
330
330
|
} else {
|
|
331
331
|
// sadly isHex detects as string, so we need a cast here
|
|
332
332
|
assert(SEED_LENGTHS.includes(phrase.split(' ').length), `Mnemonic needs to contain ${SEED_LENGTHS.join(', ')} words`);
|
|
333
|
-
assert(mnemonicValidate(phrase), '
|
|
333
|
+
assert(mnemonicValidate(phrase), 'Invalid seed phrase. Please try again.');
|
|
334
334
|
}
|
|
335
335
|
return {
|
|
336
336
|
address: keyring.createFromUri(getSuri(suri, type), {}, type).address,
|
|
@@ -343,7 +343,7 @@ export default class Extension {
|
|
|
343
343
|
savePass
|
|
344
344
|
}) {
|
|
345
345
|
const queued = this.#state.getSignRequest(id);
|
|
346
|
-
assert(queued, 'Unable to
|
|
346
|
+
assert(queued, 'Unable to proceed. Please try again');
|
|
347
347
|
const {
|
|
348
348
|
reject,
|
|
349
349
|
request,
|
|
@@ -358,7 +358,7 @@ export default class Extension {
|
|
|
358
358
|
address
|
|
359
359
|
} = pair;
|
|
360
360
|
if (!pair) {
|
|
361
|
-
reject(new Error('Unable to find
|
|
361
|
+
reject(new Error('Unable to find account'));
|
|
362
362
|
return false;
|
|
363
363
|
}
|
|
364
364
|
this.refreshAccountPasswordCache(pair);
|
|
@@ -400,7 +400,7 @@ export default class Extension {
|
|
|
400
400
|
signature
|
|
401
401
|
}) {
|
|
402
402
|
const queued = this.#state.getSignRequest(id);
|
|
403
|
-
assert(queued, 'Unable to
|
|
403
|
+
assert(queued, 'Unable to proceed. Please try again');
|
|
404
404
|
const {
|
|
405
405
|
resolve
|
|
406
406
|
} = queued;
|
|
@@ -414,7 +414,7 @@ export default class Extension {
|
|
|
414
414
|
id
|
|
415
415
|
}) {
|
|
416
416
|
const queued = this.#state.getSignRequest(id);
|
|
417
|
-
assert(queued, 'Unable to
|
|
417
|
+
assert(queued, 'Unable to proceed. Please try again');
|
|
418
418
|
const {
|
|
419
419
|
reject
|
|
420
420
|
} = queued;
|
|
@@ -425,10 +425,10 @@ export default class Extension {
|
|
|
425
425
|
id
|
|
426
426
|
}) {
|
|
427
427
|
const queued = this.#state.getSignRequest(id);
|
|
428
|
-
assert(queued, 'Unable to
|
|
428
|
+
assert(queued, 'Unable to proceed. Please try again');
|
|
429
429
|
const address = queued.request.payload.address;
|
|
430
430
|
const pair = keyring.getPair(address);
|
|
431
|
-
assert(pair, 'Unable to find
|
|
431
|
+
assert(pair, 'Unable to find account');
|
|
432
432
|
const remainingTime = this.refreshAccountPasswordCache(pair);
|
|
433
433
|
return {
|
|
434
434
|
isLocked: pair.isLocked,
|
|
@@ -477,7 +477,7 @@ export default class Extension {
|
|
|
477
477
|
try {
|
|
478
478
|
parentPair.decodePkcs8(password);
|
|
479
479
|
} catch (e) {
|
|
480
|
-
throw new Error('
|
|
480
|
+
throw new Error('Wrong password');
|
|
481
481
|
}
|
|
482
482
|
try {
|
|
483
483
|
return parentPair.derive(suri, metadata);
|
|
@@ -304,10 +304,10 @@ export default class State {
|
|
|
304
304
|
|
|
305
305
|
// Do not enqueue duplicate authorization requests.
|
|
306
306
|
const isDuplicate = Object.values(this.#authRequests).some(request => request.idStr === idStr);
|
|
307
|
-
assert(!isDuplicate,
|
|
307
|
+
assert(!isDuplicate, 'The source {{url}} has a pending authorization request'.replace('{{url}}', url));
|
|
308
308
|
if (this.#authUrls[idStr]) {
|
|
309
309
|
// this url was seen in the past
|
|
310
|
-
assert(this.#authUrls[idStr].isAllowed,
|
|
310
|
+
assert(this.#authUrls[idStr].isAllowed, 'The source {{url}} is not allowed to interact with this extension'.replace('{{url}}', url));
|
|
311
311
|
return false;
|
|
312
312
|
}
|
|
313
313
|
return new Promise((resolve, reject) => {
|
|
@@ -325,8 +325,8 @@ export default class State {
|
|
|
325
325
|
}
|
|
326
326
|
ensureUrlAuthorized(url) {
|
|
327
327
|
const entry = this.#authUrls[stripUrl(url)];
|
|
328
|
-
assert(entry,
|
|
329
|
-
assert(entry.isAllowed,
|
|
328
|
+
assert(entry, 'The source {{url}} has not been authorized yet'.replace('{{url}}', url));
|
|
329
|
+
assert(entry.isAllowed, 'The source {{url}} is not allowed to interact with this extension'.replace('{{url}}', url));
|
|
330
330
|
return true;
|
|
331
331
|
}
|
|
332
332
|
injectMetadata(url, request) {
|
|
@@ -367,7 +367,7 @@ export default class State {
|
|
|
367
367
|
|
|
368
368
|
// Start a provider, return its meta
|
|
369
369
|
rpcStartProvider(key, port) {
|
|
370
|
-
assert(Object.keys(this.#providers).includes(key),
|
|
370
|
+
assert(Object.keys(this.#providers).includes(key), 'Provider cannot be found.');
|
|
371
371
|
if (this.#injectedProviders.get(port)) {
|
|
372
372
|
return Promise.resolve(this.#providers[key].meta);
|
|
373
373
|
}
|
|
@@ -3,16 +3,18 @@
|
|
|
3
3
|
|
|
4
4
|
import { BasicTxWarningCode } from '@subwallet/extension-base/background/KoniTypes';
|
|
5
5
|
import { SWWarning } from '@subwallet/extension-base/background/warnings/SWWarning';
|
|
6
|
+
import { detectTranslate } from '@subwallet/extension-base/utils';
|
|
7
|
+
import { t } from 'i18next';
|
|
6
8
|
const defaultWarningMap = {
|
|
7
9
|
[BasicTxWarningCode.NOT_ENOUGH_EXISTENTIAL_DEPOSIT]: {
|
|
8
|
-
message: '
|
|
10
|
+
message: detectTranslate('Insufficient balance to cover existential deposit. Please decrease the transaction amount or increase your current balance'),
|
|
9
11
|
code: undefined
|
|
10
12
|
}
|
|
11
13
|
};
|
|
12
14
|
export class TransactionWarning extends SWWarning {
|
|
13
15
|
constructor(warningType, message, code, data) {
|
|
14
16
|
var _defaultWarningMap$wa, _defaultWarningMap$wa2;
|
|
15
|
-
const warningMessage = message || ((_defaultWarningMap$wa = defaultWarningMap[warningType]) === null || _defaultWarningMap$wa === void 0 ? void 0 : _defaultWarningMap$wa.message) || warningType;
|
|
17
|
+
const warningMessage = message || t(((_defaultWarningMap$wa = defaultWarningMap[warningType]) === null || _defaultWarningMap$wa === void 0 ? void 0 : _defaultWarningMap$wa.message) || '') || warningType;
|
|
16
18
|
super(warningType, warningMessage, (_defaultWarningMap$wa2 = defaultWarningMap[warningType]) === null || _defaultWarningMap$wa2 === void 0 ? void 0 : _defaultWarningMap$wa2.code, data);
|
|
17
19
|
this.warningType = warningType;
|
|
18
20
|
}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.UnstakingStatus = exports.TransferTxErrorType = exports.TransactionDirection = exports.ThemeNames = exports.StakingType = exports.StakingTxErrorType = exports.StakingStatus = exports.RuntimeEnvironment = exports.RMRK_VER = exports.ProviderErrorType = exports.NotificationType = exports.NETWORK_STATUS = exports.NETWORK_ERROR = exports.MobileOS = exports.MantaPayEnableMessage = exports.ExtrinsicType = exports.ExtrinsicStatus = exports.ExternalRequestPromiseStatus = exports.EvmProviderErrorType = exports.CrowdloanParaState = exports.ContractType = exports.ChainType = exports.ChainEditStandard = exports.BasicTxWarningCode = exports.BasicTxErrorType = exports.BalanceErrorType = exports.AccountExternalErrorCode = exports.APIItemState = void 0;
|
|
6
|
+
exports.WalletUnlockType = exports.UnstakingStatus = exports.TransferTxErrorType = exports.TransactionDirection = exports.ThemeNames = exports.StakingType = exports.StakingTxErrorType = exports.StakingStatus = exports.RuntimeEnvironment = exports.RMRK_VER = exports.ProviderErrorType = exports.NotificationType = exports.NETWORK_STATUS = exports.NETWORK_ERROR = exports.MobileOS = exports.MantaPayEnableMessage = exports.ExtrinsicType = exports.ExtrinsicStatus = exports.ExternalRequestPromiseStatus = exports.EvmProviderErrorType = exports.CrowdloanParaState = exports.ContractType = exports.ChainType = exports.ChainEditStandard = exports.BasicTxWarningCode = exports.BasicTxErrorType = exports.BalanceErrorType = exports.AccountExternalErrorCode = exports.APIItemState = void 0;
|
|
7
7
|
// Copyright 2019-2022 @polkadot/extension-koni authors & contributors
|
|
8
8
|
// SPDX-License-Identifier: Apache-2.0
|
|
9
9
|
let RuntimeEnvironment;
|
|
@@ -52,6 +52,12 @@ exports.ContractType = ContractType;
|
|
|
52
52
|
ContractType["wasm"] = "wasm";
|
|
53
53
|
ContractType["evm"] = "evm";
|
|
54
54
|
})(ContractType || (exports.ContractType = ContractType = {}));
|
|
55
|
+
let WalletUnlockType;
|
|
56
|
+
exports.WalletUnlockType = WalletUnlockType;
|
|
57
|
+
(function (WalletUnlockType) {
|
|
58
|
+
WalletUnlockType["ALWAYS_REQUIRED"] = "always_required";
|
|
59
|
+
WalletUnlockType["WHEN_NEEDED"] = "when_needed";
|
|
60
|
+
})(WalletUnlockType || (exports.WalletUnlockType = WalletUnlockType = {}));
|
|
55
61
|
let TransactionDirection;
|
|
56
62
|
exports.TransactionDirection = TransactionDirection;
|
|
57
63
|
(function (TransactionDirection) {
|
|
@@ -6,32 +6,34 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.BalanceError = void 0;
|
|
7
7
|
var _SWError = require("@subwallet/extension-base/background/errors/SWError");
|
|
8
8
|
var _KoniTypes = require("@subwallet/extension-base/background/KoniTypes");
|
|
9
|
+
var _utils = require("@subwallet/extension-base/utils");
|
|
10
|
+
var _i18next = require("i18next");
|
|
9
11
|
// Copyright 2019-2022 @subwallet/extension-koni authors & contributors
|
|
10
12
|
// SPDX-License-Identifier: Apache-2.0
|
|
11
13
|
|
|
12
14
|
// Todo: finish this map in the future
|
|
13
15
|
const defaultErrorMap = {
|
|
14
16
|
[_KoniTypes.BalanceErrorType.NETWORK_ERROR]: {
|
|
15
|
-
message: '
|
|
17
|
+
message: (0, _utils.detectTranslate)('Network is inactive. Please enable network'),
|
|
16
18
|
code: undefined
|
|
17
19
|
},
|
|
18
20
|
[_KoniTypes.BalanceErrorType.TOKEN_ERROR]: {
|
|
19
|
-
message: 'Token is not supported',
|
|
21
|
+
message: (0, _utils.detectTranslate)('Token is not supported'),
|
|
20
22
|
code: undefined
|
|
21
23
|
},
|
|
22
24
|
[_KoniTypes.BalanceErrorType.TIMEOUT]: {
|
|
23
|
-
message: '
|
|
25
|
+
message: (0, _utils.detectTranslate)('Unable to get balance. Please re-enable the network'),
|
|
24
26
|
code: undefined
|
|
25
27
|
},
|
|
26
28
|
[_KoniTypes.BalanceErrorType.GET_BALANCE_ERROR]: {
|
|
27
|
-
message: '
|
|
29
|
+
message: (0, _utils.detectTranslate)('Unable to get balance. Please re-enable the network'),
|
|
28
30
|
code: undefined
|
|
29
31
|
}
|
|
30
32
|
};
|
|
31
33
|
class BalanceError extends _SWError.SWError {
|
|
32
34
|
constructor(errorType, errMessage, data) {
|
|
33
35
|
const defaultErr = defaultErrorMap[errorType];
|
|
34
|
-
const message = errMessage || (defaultErr === null || defaultErr === void 0 ? void 0 : defaultErr.message) || errorType;
|
|
36
|
+
const message = errMessage || (0, _i18next.t)((defaultErr === null || defaultErr === void 0 ? void 0 : defaultErr.message) || '') || errorType;
|
|
35
37
|
super(errorType, message, defaultErr === null || defaultErr === void 0 ? void 0 : defaultErr.code, data);
|
|
36
38
|
this.errorType = errorType;
|
|
37
39
|
}
|
|
@@ -5,36 +5,38 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.EvmProviderError = void 0;
|
|
7
7
|
var _SWError = require("@subwallet/extension-base/background/errors/SWError");
|
|
8
|
+
var _utils = require("@subwallet/extension-base/utils");
|
|
9
|
+
var _i18next = require("i18next");
|
|
8
10
|
// Copyright 2019-2022 @subwallet/extension-koni authors & contributors
|
|
9
11
|
// SPDX-License-Identifier: Apache-2.0
|
|
10
12
|
|
|
11
13
|
const defaultErrorMap = {
|
|
12
14
|
USER_REJECTED_REQUEST: {
|
|
13
|
-
message: 'User Rejected Request',
|
|
15
|
+
message: (0, _utils.detectTranslate)('User Rejected Request'),
|
|
14
16
|
code: 4001
|
|
15
17
|
},
|
|
16
18
|
UNAUTHORIZED: {
|
|
17
|
-
message: '
|
|
19
|
+
message: (0, _utils.detectTranslate)('Failed to sign'),
|
|
18
20
|
code: 4100
|
|
19
21
|
},
|
|
20
22
|
UNSUPPORTED_METHOD: {
|
|
21
|
-
message: 'Unsupported Method',
|
|
23
|
+
message: (0, _utils.detectTranslate)('Unsupported Method'),
|
|
22
24
|
code: 4200
|
|
23
25
|
},
|
|
24
26
|
DISCONNECTED: {
|
|
25
|
-
message: '
|
|
27
|
+
message: (0, _utils.detectTranslate)('Network is disconnected'),
|
|
26
28
|
code: 4900
|
|
27
29
|
},
|
|
28
30
|
CHAIN_DISCONNECTED: {
|
|
29
|
-
message: '
|
|
31
|
+
message: (0, _utils.detectTranslate)('Network is disconnected'),
|
|
30
32
|
code: 4901
|
|
31
33
|
},
|
|
32
34
|
INVALID_PARAMS: {
|
|
33
|
-
message: '
|
|
35
|
+
message: (0, _utils.detectTranslate)('Undefined error. Please contact SubWallet support'),
|
|
34
36
|
code: -32602
|
|
35
37
|
},
|
|
36
38
|
INTERNAL_ERROR: {
|
|
37
|
-
message: '
|
|
39
|
+
message: (0, _utils.detectTranslate)('Undefined error. Please contact SubWallet support'),
|
|
38
40
|
code: -32603
|
|
39
41
|
}
|
|
40
42
|
};
|
|
@@ -44,7 +46,7 @@ class EvmProviderError extends _SWError.SWError {
|
|
|
44
46
|
code,
|
|
45
47
|
message
|
|
46
48
|
} = defaultErrorMap[errorType];
|
|
47
|
-
const finalMessage = errMessage
|
|
49
|
+
const finalMessage = errMessage || (0, _i18next.t)(message || '') || errorType;
|
|
48
50
|
super(errorType, finalMessage, code, data);
|
|
49
51
|
this.errorType = errorType;
|
|
50
52
|
}
|