@toruslabs/ethereum-controllers 5.5.1 → 5.5.3
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/dist/ethereumControllers.cjs.js +24 -17
- package/dist/ethereumControllers.cjs.js.map +1 -1
- package/dist/ethereumControllers.esm.js +26 -17
- package/dist/ethereumControllers.esm.js.map +1 -1
- package/dist/ethereumControllers.umd.min.js +1 -1
- package/dist/ethereumControllers.umd.min.js.LICENSE.txt +0 -2
- package/dist/ethereumControllers.umd.min.js.map +1 -1
- package/dist/types/utils/interfaces.d.ts +3 -0
- package/package.json +3 -3
- package/src/Block/PollingBlockTracker.ts +1 -1
- package/src/Keyring/KeyringController.ts +6 -7
- package/src/Preferences/PreferencesController.ts +2 -2
- package/src/utils/helpers.ts +18 -7
- package/src/utils/interfaces.ts +3 -0
|
@@ -2,9 +2,9 @@ import _objectSpread from '@babel/runtime/helpers/objectSpread2';
|
|
|
2
2
|
import _defineProperty from '@babel/runtime/helpers/defineProperty';
|
|
3
3
|
import { CHAIN_NAMESPACES, BaseController, randomId, TransactionStatus, TRANSACTION_TYPES, formatSmallNumbers, addressSlicer, ACTIVITY_ACTION_RECEIVE, ACTIVITY_ACTION_SEND, significantDigits, BaseBlockTracker, timeout, BaseCurrencyController, BaseKeyringController, PROVIDER_JRPC_METHODS, createFetchMiddleware, createSwappableProxy, createEventEmitterProxy, BasePreferencesController, TX_EVENTS, BaseTransactionStateManager, transactionMatchesNetwork as transactionMatchesNetwork$1 } from '@toruslabs/base-controllers';
|
|
4
4
|
import { Mutex } from 'async-mutex';
|
|
5
|
-
import { BrowserProvider, toQuantity, Contract, Interface,
|
|
5
|
+
import { BrowserProvider, toQuantity, Contract, Interface, isHexString as isHexString$1, JsonRpcProvider, keccak256 } from 'ethers';
|
|
6
6
|
import log from 'loglevel';
|
|
7
|
-
import { isHexString, addHexPrefix, isValidAddress, toChecksumAddress, stripHexPrefix, ecsign, bigIntToBytes
|
|
7
|
+
import { isHexString, addHexPrefix, isValidAddress, toChecksumAddress, stripHexPrefix, bytesToHex, privateToPublic, privateToAddress, ecsign, bigIntToBytes } from '@ethereumjs/util';
|
|
8
8
|
import BigNumber from 'bignumber.js';
|
|
9
9
|
import { rpcErrors, providerErrors } from '@metamask/rpc-errors';
|
|
10
10
|
import { get, post, remove, patch } from '@toruslabs/http-helpers';
|
|
@@ -1495,13 +1495,24 @@ const addEtherscanTransactions = async (txn, lowerCaseSelectedAddress, provider,
|
|
|
1495
1495
|
}));
|
|
1496
1496
|
const finalTxs = transactionPromises.reduce((accumulator, x) => {
|
|
1497
1497
|
var _SUPPORTED_NETWORKS$c3, _SUPPORTED_NETWORKS$c4;
|
|
1498
|
-
|
|
1498
|
+
let totalAmountString = x.value ? new BigNumber(x.value).div(new BigNumber(10).pow(new BigNumber(x.tokenDecimal || 18))).toString() : "";
|
|
1499
|
+
let type = CONTRACT_TYPE_ETH;
|
|
1500
|
+
if (x.contractAddress !== "") {
|
|
1501
|
+
if (x.tokenID) {
|
|
1502
|
+
type = x.tokenValue ? CONTRACT_TYPE_ERC1155 : CONTRACT_TYPE_ERC721;
|
|
1503
|
+
} else {
|
|
1504
|
+
type = CONTRACT_TYPE_ERC20;
|
|
1505
|
+
}
|
|
1506
|
+
}
|
|
1507
|
+
if (type === CONTRACT_TYPE_ERC1155) {
|
|
1508
|
+
totalAmountString = x.tokenValue;
|
|
1509
|
+
}
|
|
1499
1510
|
const etherscanTransaction = {
|
|
1500
1511
|
etherscanLink: getEtherScanHashLink(x.hash, chainId),
|
|
1501
|
-
type
|
|
1512
|
+
type,
|
|
1502
1513
|
type_image_link: x.type_image_link || "n/a",
|
|
1503
|
-
type_name: x.
|
|
1504
|
-
symbol: (_SUPPORTED_NETWORKS$c4 = SUPPORTED_NETWORKS[chainId]) === null || _SUPPORTED_NETWORKS$c4 === void 0 ? void 0 : _SUPPORTED_NETWORKS$c4.ticker,
|
|
1514
|
+
type_name: x.tokenName || ((_SUPPORTED_NETWORKS$c3 = SUPPORTED_NETWORKS[chainId]) === null || _SUPPORTED_NETWORKS$c3 === void 0 ? void 0 : _SUPPORTED_NETWORKS$c3.ticker) || "n/a",
|
|
1515
|
+
symbol: x.tokenSymbol || ((_SUPPORTED_NETWORKS$c4 = SUPPORTED_NETWORKS[chainId]) === null || _SUPPORTED_NETWORKS$c4 === void 0 ? void 0 : _SUPPORTED_NETWORKS$c4.ticker),
|
|
1505
1516
|
token_id: x.tokenID || "",
|
|
1506
1517
|
total_amount: totalAmountString,
|
|
1507
1518
|
created_at: new Date(Number(x.timeStamp) * 1000),
|
|
@@ -1513,8 +1524,8 @@ const addEtherscanTransactions = async (txn, lowerCaseSelectedAddress, provider,
|
|
|
1513
1524
|
input: x.input,
|
|
1514
1525
|
contract_address: x.contractAddress,
|
|
1515
1526
|
transaction_category: x.transaction_category,
|
|
1516
|
-
gas: x.
|
|
1517
|
-
gasPrice: x.gasPrice,
|
|
1527
|
+
gas: `0x${new BigNumber(x.gasUsed || 0, 10).toString(16)}`,
|
|
1528
|
+
gasPrice: `0x${new BigNumber(x.gasPrice || 0, 10).toString(16)}`,
|
|
1518
1529
|
chain_id: chainId,
|
|
1519
1530
|
currency_amount: "",
|
|
1520
1531
|
nonce: x.nonce,
|
|
@@ -2293,17 +2304,15 @@ class KeyringController extends BaseKeyringController {
|
|
|
2293
2304
|
return this.state.wallets.map(w => w.publicKey);
|
|
2294
2305
|
}
|
|
2295
2306
|
importAccount(accountPrivateKey) {
|
|
2296
|
-
const hexPrivateKey =
|
|
2297
|
-
const
|
|
2298
|
-
const
|
|
2299
|
-
const
|
|
2300
|
-
address
|
|
2301
|
-
} = wallet;
|
|
2307
|
+
const hexPrivateKey = accountPrivateKey.padStart(64, "0");
|
|
2308
|
+
const bufferPrivKey = Buffer.from(hexPrivateKey, "hex");
|
|
2309
|
+
const publicKey = bytesToHex(privateToPublic(bufferPrivKey));
|
|
2310
|
+
const address = bytesToHex(privateToAddress(bufferPrivKey));
|
|
2302
2311
|
const existingWallet = this.state.wallets.find(w => w.address === address);
|
|
2303
2312
|
if (existingWallet) return existingWallet.address;
|
|
2304
2313
|
this.update({
|
|
2305
2314
|
wallets: [...this.state.wallets, {
|
|
2306
|
-
publicKey
|
|
2315
|
+
publicKey,
|
|
2307
2316
|
privateKey: accountPrivateKey,
|
|
2308
2317
|
address
|
|
2309
2318
|
}]
|
|
@@ -4137,7 +4146,7 @@ class PreferencesController extends BasePreferencesController {
|
|
|
4137
4146
|
calledFromEmbed,
|
|
4138
4147
|
userInfo,
|
|
4139
4148
|
rehydrate,
|
|
4140
|
-
locale = "en
|
|
4149
|
+
locale = "en",
|
|
4141
4150
|
type,
|
|
4142
4151
|
signatures,
|
|
4143
4152
|
web3AuthClientId,
|
|
@@ -4241,7 +4250,7 @@ class PreferencesController extends BasePreferencesController {
|
|
|
4241
4250
|
async patchNewTx(tx, address) {
|
|
4242
4251
|
var _this$getAddressState2;
|
|
4243
4252
|
const formattedTx = formatPastTx(tx);
|
|
4244
|
-
const storePastTx = (_this$getAddressState2 = this.getAddressState(address)) === null || _this$getAddressState2 === void 0 ? void 0 : _this$getAddressState2.formattedPastTransactions;
|
|
4253
|
+
const storePastTx = ((_this$getAddressState2 = this.getAddressState(address)) === null || _this$getAddressState2 === void 0 ? void 0 : _this$getAddressState2.formattedPastTransactions) || [];
|
|
4245
4254
|
const duplicateIndex = storePastTx.findIndex(x => x.transaction_hash === tx.transaction_hash && x.chainId === tx.chain_id);
|
|
4246
4255
|
if (tx.status === TransactionStatus.submitted || tx.status === TransactionStatus.confirmed) {
|
|
4247
4256
|
if (duplicateIndex === -1) {
|