@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.
Files changed (83) hide show
  1. package/background/KoniTypes.d.ts +13 -1
  2. package/background/KoniTypes.js +5 -0
  3. package/background/errors/BalanceError.js +7 -5
  4. package/background/errors/EvmProviderError.js +10 -8
  5. package/background/errors/ProviderError.js +5 -4
  6. package/background/errors/TransactionError.js +22 -17
  7. package/background/handlers/Extension.js +18 -18
  8. package/background/handlers/State.js +5 -5
  9. package/background/handlers/Tabs.js +1 -1
  10. package/background/warnings/TransactionWarning.js +4 -2
  11. package/cjs/background/KoniTypes.js +7 -1
  12. package/cjs/background/errors/BalanceError.js +7 -5
  13. package/cjs/background/errors/EvmProviderError.js +10 -8
  14. package/cjs/background/errors/ProviderError.js +5 -4
  15. package/cjs/background/errors/TransactionError.js +22 -17
  16. package/cjs/background/handlers/Extension.js +18 -18
  17. package/cjs/background/handlers/State.js +5 -5
  18. package/cjs/background/handlers/Tabs.js +1 -1
  19. package/cjs/background/warnings/TransactionWarning.js +4 -2
  20. package/cjs/constants/i18n.js +4 -1
  21. package/cjs/constants/index.js +12 -0
  22. package/cjs/constants/storage.js +11 -0
  23. package/cjs/koni/api/dotsama/parseTransaction.js +2 -1
  24. package/cjs/koni/api/staking/bonding/paraChain.js +10 -6
  25. package/cjs/koni/api/staking/bonding/relayChain.js +16 -7
  26. package/cjs/koni/api/staking/bonding/utils.js +80 -7
  27. package/cjs/koni/background/handlers/Extension.js +206 -170
  28. package/cjs/koni/background/handlers/State.js +19 -14
  29. package/cjs/koni/background/handlers/Tabs.js +15 -14
  30. package/cjs/packageInfo.js +1 -1
  31. package/cjs/services/balance-service/index.js +12 -3
  32. package/cjs/services/request-service/handler/AuthRequestHandler.js +4 -4
  33. package/cjs/services/request-service/handler/EvmRequestHandler.js +11 -10
  34. package/cjs/services/setting-service/SettingService.js +20 -7
  35. package/cjs/services/setting-service/constants.js +5 -1
  36. package/cjs/services/setting-service/i18n/Backend.js +42 -0
  37. package/cjs/services/setting-service/i18n/cache.js +12 -0
  38. package/cjs/services/setting-service/i18n/extend.js +16 -0
  39. package/cjs/services/setting-service/i18n/i18n.js +29 -0
  40. package/cjs/services/transaction-service/index.js +25 -16
  41. package/cjs/services/wallet-connect-service/handler/PolkadotRequestHandler.js +0 -1
  42. package/cjs/utils/eth/parseTransaction/base.js +1 -1
  43. package/cjs/utils/eth/parseTransaction/index.js +2 -1
  44. package/cjs/utils/index.js +2 -1
  45. package/constants/i18n.js +4 -1
  46. package/constants/index.d.ts +1 -0
  47. package/constants/index.js +2 -1
  48. package/constants/storage.d.ts +1 -0
  49. package/constants/storage.js +4 -0
  50. package/koni/api/dotsama/parseTransaction.js +2 -1
  51. package/koni/api/staking/bonding/paraChain.js +11 -7
  52. package/koni/api/staking/bonding/relayChain.js +17 -8
  53. package/koni/api/staking/bonding/utils.d.ts +4 -0
  54. package/koni/api/staking/bonding/utils.js +70 -2
  55. package/koni/background/handlers/Extension.d.ts +1 -0
  56. package/koni/background/handlers/Extension.js +85 -50
  57. package/koni/background/handlers/State.js +19 -14
  58. package/koni/background/handlers/Tabs.js +15 -14
  59. package/package.json +31 -11
  60. package/packageInfo.js +1 -1
  61. package/services/balance-service/index.js +12 -3
  62. package/services/request-service/handler/AuthRequestHandler.js +4 -4
  63. package/services/request-service/handler/EvmRequestHandler.js +11 -10
  64. package/services/setting-service/SettingService.d.ts +1 -0
  65. package/services/setting-service/SettingService.js +17 -5
  66. package/services/setting-service/constants.d.ts +2 -1
  67. package/services/setting-service/constants.js +4 -1
  68. package/services/setting-service/i18n/Backend.d.ts +9 -0
  69. package/services/setting-service/i18n/Backend.js +34 -0
  70. package/services/setting-service/i18n/cache.d.ts +2 -0
  71. package/services/setting-service/i18n/cache.js +5 -0
  72. package/services/setting-service/i18n/extend.d.ts +2 -0
  73. package/services/setting-service/i18n/extend.js +8 -0
  74. package/services/setting-service/i18n/i18n.d.ts +2 -0
  75. package/services/setting-service/i18n/i18n.js +21 -0
  76. package/services/transaction-service/index.js +25 -16
  77. package/services/wallet-connect-service/handler/PolkadotRequestHandler.js +0 -1
  78. package/utils/eth/parseTransaction/base.js +1 -1
  79. package/utils/eth/parseTransaction/index.js +2 -1
  80. package/utils/index.js +2 -1
  81. package/cjs/utils/keyring.js +0 -57
  82. package/utils/keyring.d.ts +0 -4
  83. package/utils/keyring.js +0 -49
@@ -102,7 +102,6 @@ function _checkAccount2(address, accounts) {
102
102
  }
103
103
  }
104
104
  function _handleError2(topic, id, e) {
105
- console.log(e);
106
105
  let message = e.message;
107
106
  if (message.includes('User Rejected Request')) {
108
107
  message = getSdkError('USER_REJECTED').message;
@@ -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(`Invalid ABI: ${err.message}`);
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(`Cannot create tx from ${data}`);
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:')), `Invalid url ${url}, expected to start with http: or https: or ipfs: or 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
  };
@@ -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;
@@ -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
- };