@subwallet/extension-base 1.0.9-1 → 1.0.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 (54) hide show
  1. package/background/KoniTypes.d.ts +5 -1
  2. package/background/types.d.ts +2 -1
  3. package/cjs/koni/api/dotsama/transfer.js +16 -7
  4. package/cjs/koni/api/staking/bonding/paraChain.js +3 -2
  5. package/cjs/koni/api/staking/bonding/relayChain.js +3 -2
  6. package/cjs/koni/api/staking/bonding/utils.js +1 -1
  7. package/cjs/koni/api/xcm/polkadotXcm.js +5 -4
  8. package/cjs/koni/api/xcm/xTokens.js +1 -1
  9. package/cjs/koni/api/xcm/xcmPallet.js +1 -1
  10. package/cjs/koni/background/handlers/Extension.js +57 -18
  11. package/cjs/koni/background/handlers/State.js +3 -3
  12. package/cjs/packageInfo.js +1 -1
  13. package/cjs/services/chain-service/constants.js +2 -1
  14. package/cjs/services/chain-service/helper/api-helper/spec/dataavail.js +152 -0
  15. package/cjs/services/chain-service/helper/api-helper/spec/index.js +2 -0
  16. package/cjs/services/chain-service/index.js +1 -1
  17. package/cjs/services/migration-service/scripts/MigrateLedgerAccount.js +42 -0
  18. package/cjs/services/migration-service/scripts/index.js +3 -1
  19. package/cjs/services/transaction-service/index.js +15 -15
  20. package/cjs/signers/web3/QrSigner.js +14 -6
  21. package/cjs/utils/eth/mergeTransactionAndSignature.js +22 -13
  22. package/cjs/utils/eth/parseTransaction/base.js +6 -6
  23. package/cjs/utils/eth/parseTransaction/index.js +4 -5
  24. package/cjs/utils/eth.js +14 -18
  25. package/koni/api/dotsama/transfer.js +16 -7
  26. package/koni/api/staking/bonding/paraChain.js +3 -2
  27. package/koni/api/staking/bonding/relayChain.js +3 -2
  28. package/koni/api/staking/bonding/utils.js +1 -1
  29. package/koni/api/xcm/polkadotXcm.js +5 -4
  30. package/koni/api/xcm/xTokens.js +1 -1
  31. package/koni/api/xcm/xcmPallet.js +1 -1
  32. package/koni/background/handlers/Extension.d.ts +0 -1
  33. package/koni/background/handlers/Extension.js +57 -18
  34. package/koni/background/handlers/State.js +3 -3
  35. package/package.json +17 -8
  36. package/packageInfo.js +1 -1
  37. package/services/chain-service/constants.d.ts +1 -0
  38. package/services/chain-service/constants.js +2 -1
  39. package/services/chain-service/helper/api-helper/spec/dataavail.d.ts +3 -0
  40. package/services/chain-service/helper/api-helper/spec/dataavail.js +145 -0
  41. package/services/chain-service/helper/api-helper/spec/index.js +2 -0
  42. package/services/chain-service/index.js +1 -1
  43. package/services/migration-service/scripts/MigrateLedgerAccount.d.ts +4 -0
  44. package/services/migration-service/scripts/MigrateLedgerAccount.js +33 -0
  45. package/services/migration-service/scripts/index.js +3 -1
  46. package/services/transaction-service/index.js +17 -17
  47. package/signers/types.d.ts +1 -1
  48. package/signers/web3/QrSigner.js +14 -5
  49. package/utils/eth/mergeTransactionAndSignature.d.ts +1 -1
  50. package/utils/eth/mergeTransactionAndSignature.js +20 -10
  51. package/utils/eth/parseTransaction/base.js +6 -6
  52. package/utils/eth/parseTransaction/index.js +4 -5
  53. package/utils/eth.d.ts +2 -3
  54. package/utils/eth.js +14 -17
package/utils/eth.js CHANGED
@@ -2,8 +2,8 @@
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
 
4
4
  import BigN from 'bignumber.js';
5
- import RLP from 'rlp';
6
- import { hexStripPrefix, numberToHex, u8aToHex } from '@polkadot/util';
5
+ import { ethers } from 'ethers';
6
+ import { hexStripPrefix, numberToHex } from '@polkadot/util';
7
7
  const hexToNumberString = s => {
8
8
  const temp = parseInt(s, 16);
9
9
  if (isNaN(temp)) {
@@ -13,11 +13,11 @@ const hexToNumberString = s => {
13
13
  }
14
14
  };
15
15
  export class Transaction {
16
- constructor(nonce, gasPrice, gas, action, value, data, ethereumChainId) {
16
+ constructor(nonce, gasPrice, gas, to, value, data, ethereumChainId) {
17
17
  this.nonce = hexToNumberString(nonce);
18
18
  this.gasPrice = hexToNumberString(gasPrice);
19
19
  this.gas = hexToNumberString(gas);
20
- this.action = action;
20
+ this.to = to;
21
21
  this.value = hexToNumberString(value);
22
22
  this.data = data || '';
23
23
  this.ethereumChainId = parseInt(ethereumChainId, 16).toString();
@@ -33,21 +33,18 @@ export const anyNumberToBN = value => {
33
33
  return new BigN(value.toNumber());
34
34
  }
35
35
  };
36
- export const rlpItem = (rlp, position) => {
37
- const decodeArr = RLP.decode(rlp);
38
- const u8a = decodeArr[position] || [0];
39
- return u8aToHex(u8a);
40
- };
41
36
  export const createTransactionFromRLP = rlp => {
42
37
  try {
43
- const nonce = rlpItem(rlp, 0);
44
- const gasPrice = rlpItem(rlp, 1);
45
- const gas = rlpItem(rlp, 2);
46
- const action = rlpItem(rlp, 3);
47
- const value = rlpItem(rlp, 4);
48
- const data = rlpItem(rlp, 5);
49
- const ethereumChainId = rlpItem(rlp, 6);
50
- return new Transaction(nonce, gasPrice, gas, action, value, data, ethereumChainId);
38
+ var _transaction$gasPrice;
39
+ const transaction = ethers.Transaction.from(rlp);
40
+ const nonce = transaction.nonce.toString(16);
41
+ const gasPrice = ((_transaction$gasPrice = transaction.gasPrice) === null || _transaction$gasPrice === void 0 ? void 0 : _transaction$gasPrice.toString(16)) || '';
42
+ const gas = transaction.gasLimit.toString(16);
43
+ const to = transaction.to || '';
44
+ const value = transaction.value.toString(16);
45
+ const data = transaction.data;
46
+ const ethereumChainId = transaction.chainId.toString(16);
47
+ return new Transaction(nonce, gasPrice, gas, to, value, data, ethereumChainId);
51
48
  } catch (e) {
52
49
  console.log(e.message);
53
50
  return null;