@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
|
@@ -87,7 +87,7 @@ export class InputDataDecoder {
|
|
|
87
87
|
try {
|
|
88
88
|
this.abi = JSON.parse(prop);
|
|
89
89
|
} catch (err) {
|
|
90
|
-
throw new Error(
|
|
90
|
+
throw new Error('Invalid ABI: ' + err.message);
|
|
91
91
|
}
|
|
92
92
|
} else if (checkArrayAbiItems(prop)) {
|
|
93
93
|
this.abi = prop;
|
|
@@ -7,6 +7,7 @@ import { createTransactionFromRLP } from '@subwallet/extension-base/utils/eth';
|
|
|
7
7
|
import { InputDataDecoder } from '@subwallet/extension-base/utils/eth/parseTransaction/base';
|
|
8
8
|
import axios from 'axios';
|
|
9
9
|
import BigN from 'bignumber.js';
|
|
10
|
+
import { t } from 'i18next';
|
|
10
11
|
|
|
11
12
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
12
13
|
const ABIs = [_ERC20_ABI, _ERC721_ABI];
|
|
@@ -181,7 +182,7 @@ const getChainInfoByChainId = (networkMap, chainId) => {
|
|
|
181
182
|
export const parseEvmRlp = async (data, networkMap, evmApiMap) => {
|
|
182
183
|
const tx = createTransactionFromRLP(data);
|
|
183
184
|
if (!tx) {
|
|
184
|
-
throw new Error(
|
|
185
|
+
throw new Error(t('Failed to decode data. Please use a valid QR code'));
|
|
185
186
|
}
|
|
186
187
|
const result = {
|
|
187
188
|
input: tx.data,
|
package/utils/index.js
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
import { CrowdloanParaState, MobileOS } from '@subwallet/extension-base/background/KoniTypes';
|
|
5
5
|
import { ALL_ACCOUNT_KEY } from '@subwallet/extension-base/constants';
|
|
6
6
|
import { getOS } from '@subwallet/extension-base/utils/environment';
|
|
7
|
+
import { t } from 'i18next';
|
|
7
8
|
import { assert, BN, hexToU8a, isHex } from '@polkadot/util';
|
|
8
9
|
import { decodeAddress, encodeAddress, ethereumEncode, isEthereumAddress } from '@polkadot/util-crypto';
|
|
9
10
|
export { canDerive } from "./canDerive.js";
|
|
@@ -282,7 +283,7 @@ export async function waitTimeout(ms) {
|
|
|
282
283
|
return new Promise(resolve => setTimeout(resolve, ms));
|
|
283
284
|
}
|
|
284
285
|
export const stripUrl = url => {
|
|
285
|
-
assert(url && (url.startsWith('http:') || url.startsWith('https:') || url.startsWith('ipfs:') || url.startsWith('ipns:')),
|
|
286
|
+
assert(url && (url.startsWith('http:') || url.startsWith('https:') || url.startsWith('ipfs:') || url.startsWith('ipns:')), t('Invalid URL for provider'));
|
|
286
287
|
const parts = url.split('/');
|
|
287
288
|
return parts[2];
|
|
288
289
|
};
|
package/cjs/utils/keyring.js
DELETED
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.extractPrivateKey = extractPrivateKey;
|
|
7
|
-
exports.unlockAccount = exports.lockAccount = void 0;
|
|
8
|
-
var _uiKeyring = require("@subwallet/ui-keyring");
|
|
9
|
-
// Copyright 2019-2022 @subwallet/extension-base
|
|
10
|
-
// SPDX-License-Identifier: Apache-2.0
|
|
11
|
-
|
|
12
|
-
// import _decode from '@polkadot/keyring/pair/decode';
|
|
13
|
-
|
|
14
|
-
function extract(address) {
|
|
15
|
-
// @ts-ignore
|
|
16
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-member-access,@typescript-eslint/no-unsafe-assignment
|
|
17
|
-
const rs = this.getPair(address);
|
|
18
|
-
|
|
19
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
20
|
-
console.log(rs.publicKey);
|
|
21
|
-
}
|
|
22
|
-
function extractPrivateKey(keyring, address, password) {
|
|
23
|
-
extract.call(keyring, address);
|
|
24
|
-
}
|
|
25
|
-
const unlockAccount = signAddress => {
|
|
26
|
-
let publicKey;
|
|
27
|
-
try {
|
|
28
|
-
publicKey = _uiKeyring.keyring.decodeAddress(signAddress);
|
|
29
|
-
} catch (error) {
|
|
30
|
-
console.error(error);
|
|
31
|
-
return 'Unable to decode address';
|
|
32
|
-
}
|
|
33
|
-
const pair = _uiKeyring.keyring.getPair(publicKey);
|
|
34
|
-
if (!pair) {
|
|
35
|
-
return 'Unable to find pair';
|
|
36
|
-
}
|
|
37
|
-
if (pair.isLocked) {
|
|
38
|
-
try {
|
|
39
|
-
_uiKeyring.keyring.unlockPair(pair.address);
|
|
40
|
-
} catch (e) {
|
|
41
|
-
return e.message;
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
return null;
|
|
45
|
-
};
|
|
46
|
-
exports.unlockAccount = unlockAccount;
|
|
47
|
-
const lockAccount = address => {
|
|
48
|
-
try {
|
|
49
|
-
const pair = _uiKeyring.keyring.getPair(address);
|
|
50
|
-
if (pair) {
|
|
51
|
-
pair.lock();
|
|
52
|
-
}
|
|
53
|
-
} catch (error) {
|
|
54
|
-
console.error('Unable to lock account', error);
|
|
55
|
-
}
|
|
56
|
-
};
|
|
57
|
-
exports.lockAccount = lockAccount;
|
package/utils/keyring.d.ts
DELETED
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import { Keyring } from '@subwallet/keyring';
|
|
2
|
-
export declare function extractPrivateKey(keyring: Keyring, address: string, password: string): void;
|
|
3
|
-
export declare const unlockAccount: (signAddress: string) => string | null;
|
|
4
|
-
export declare const lockAccount: (address: string) => void;
|
package/utils/keyring.js
DELETED
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
// Copyright 2019-2022 @subwallet/extension-base
|
|
2
|
-
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
-
|
|
4
|
-
import { keyring } from '@subwallet/ui-keyring';
|
|
5
|
-
|
|
6
|
-
// import _decode from '@polkadot/keyring/pair/decode';
|
|
7
|
-
|
|
8
|
-
function extract(address) {
|
|
9
|
-
// @ts-ignore
|
|
10
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-member-access,@typescript-eslint/no-unsafe-assignment
|
|
11
|
-
const rs = this.getPair(address);
|
|
12
|
-
|
|
13
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
14
|
-
console.log(rs.publicKey);
|
|
15
|
-
}
|
|
16
|
-
export function extractPrivateKey(keyring, address, password) {
|
|
17
|
-
extract.call(keyring, address);
|
|
18
|
-
}
|
|
19
|
-
export const unlockAccount = signAddress => {
|
|
20
|
-
let publicKey;
|
|
21
|
-
try {
|
|
22
|
-
publicKey = keyring.decodeAddress(signAddress);
|
|
23
|
-
} catch (error) {
|
|
24
|
-
console.error(error);
|
|
25
|
-
return 'Unable to decode address';
|
|
26
|
-
}
|
|
27
|
-
const pair = keyring.getPair(publicKey);
|
|
28
|
-
if (!pair) {
|
|
29
|
-
return 'Unable to find pair';
|
|
30
|
-
}
|
|
31
|
-
if (pair.isLocked) {
|
|
32
|
-
try {
|
|
33
|
-
keyring.unlockPair(pair.address);
|
|
34
|
-
} catch (e) {
|
|
35
|
-
return e.message;
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
return null;
|
|
39
|
-
};
|
|
40
|
-
export const lockAccount = address => {
|
|
41
|
-
try {
|
|
42
|
-
const pair = keyring.getPair(address);
|
|
43
|
-
if (pair) {
|
|
44
|
-
pair.lock();
|
|
45
|
-
}
|
|
46
|
-
} catch (error) {
|
|
47
|
-
console.error('Unable to lock account', error);
|
|
48
|
-
}
|
|
49
|
-
};
|