@toruslabs/ethereum-controllers 5.5.2 → 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 +19 -9
- package/dist/ethereumControllers.cjs.js.map +1 -1
- package/dist/ethereumControllers.esm.js +20 -9
- package/dist/ethereumControllers.esm.js.map +1 -1
- package/dist/ethereumControllers.umd.min.js +1 -1
- 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/Preferences/PreferencesController.ts +2 -2
- package/src/utils/helpers.ts +18 -7
- package/src/utils/interfaces.ts +3 -0
|
@@ -1564,7 +1564,6 @@ async function determineTransactionType(txParams, provider) {
|
|
|
1564
1564
|
|
|
1565
1565
|
|
|
1566
1566
|
|
|
1567
|
-
|
|
1568
1567
|
function getEtherScanHashLink(txHash, chainId) {
|
|
1569
1568
|
if (!SUPPORTED_NETWORKS[chainId]) return "";
|
|
1570
1569
|
return `${SUPPORTED_NETWORKS[chainId].blockExplorerUrl}/tx/${txHash}`;
|
|
@@ -1718,13 +1717,24 @@ const addEtherscanTransactions = async (txn, lowerCaseSelectedAddress, provider,
|
|
|
1718
1717
|
}));
|
|
1719
1718
|
const finalTxs = transactionPromises.reduce((accumulator, x) => {
|
|
1720
1719
|
var _SUPPORTED_NETWORKS$c3, _SUPPORTED_NETWORKS$c4;
|
|
1721
|
-
|
|
1720
|
+
let totalAmountString = x.value ? new (external_bignumber_js_default())(x.value).div(new (external_bignumber_js_default())(10).pow(new (external_bignumber_js_default())(x.tokenDecimal || 18))).toString() : "";
|
|
1721
|
+
let type = CONTRACT_TYPE_ETH;
|
|
1722
|
+
if (x.contractAddress !== "") {
|
|
1723
|
+
if (x.tokenID) {
|
|
1724
|
+
type = x.tokenValue ? CONTRACT_TYPE_ERC1155 : CONTRACT_TYPE_ERC721;
|
|
1725
|
+
} else {
|
|
1726
|
+
type = CONTRACT_TYPE_ERC20;
|
|
1727
|
+
}
|
|
1728
|
+
}
|
|
1729
|
+
if (type === CONTRACT_TYPE_ERC1155) {
|
|
1730
|
+
totalAmountString = x.tokenValue;
|
|
1731
|
+
}
|
|
1722
1732
|
const etherscanTransaction = {
|
|
1723
1733
|
etherscanLink: getEtherScanHashLink(x.hash, chainId),
|
|
1724
|
-
type
|
|
1734
|
+
type,
|
|
1725
1735
|
type_image_link: x.type_image_link || "n/a",
|
|
1726
|
-
type_name: x.
|
|
1727
|
-
symbol: (_SUPPORTED_NETWORKS$c4 = SUPPORTED_NETWORKS[chainId]) === null || _SUPPORTED_NETWORKS$c4 === void 0 ? void 0 : _SUPPORTED_NETWORKS$c4.ticker,
|
|
1736
|
+
type_name: x.tokenName || ((_SUPPORTED_NETWORKS$c3 = SUPPORTED_NETWORKS[chainId]) === null || _SUPPORTED_NETWORKS$c3 === void 0 ? void 0 : _SUPPORTED_NETWORKS$c3.ticker) || "n/a",
|
|
1737
|
+
symbol: x.tokenSymbol || ((_SUPPORTED_NETWORKS$c4 = SUPPORTED_NETWORKS[chainId]) === null || _SUPPORTED_NETWORKS$c4 === void 0 ? void 0 : _SUPPORTED_NETWORKS$c4.ticker),
|
|
1728
1738
|
token_id: x.tokenID || "",
|
|
1729
1739
|
total_amount: totalAmountString,
|
|
1730
1740
|
created_at: new Date(Number(x.timeStamp) * 1000),
|
|
@@ -1736,8 +1746,8 @@ const addEtherscanTransactions = async (txn, lowerCaseSelectedAddress, provider,
|
|
|
1736
1746
|
input: x.input,
|
|
1737
1747
|
contract_address: x.contractAddress,
|
|
1738
1748
|
transaction_category: x.transaction_category,
|
|
1739
|
-
gas: x.
|
|
1740
|
-
gasPrice: x.gasPrice,
|
|
1749
|
+
gas: `0x${new (external_bignumber_js_default())(x.gasUsed || 0, 10).toString(16)}`,
|
|
1750
|
+
gasPrice: `0x${new (external_bignumber_js_default())(x.gasPrice || 0, 10).toString(16)}`,
|
|
1741
1751
|
chain_id: chainId,
|
|
1742
1752
|
currency_amount: "",
|
|
1743
1753
|
nonce: x.nonce,
|
|
@@ -4537,7 +4547,7 @@ class PreferencesController extends base_controllers_namespaceObject.BasePrefere
|
|
|
4537
4547
|
calledFromEmbed,
|
|
4538
4548
|
userInfo,
|
|
4539
4549
|
rehydrate,
|
|
4540
|
-
locale = "en
|
|
4550
|
+
locale = "en",
|
|
4541
4551
|
type,
|
|
4542
4552
|
signatures,
|
|
4543
4553
|
web3AuthClientId,
|
|
@@ -4641,7 +4651,7 @@ class PreferencesController extends base_controllers_namespaceObject.BasePrefere
|
|
|
4641
4651
|
async patchNewTx(tx, address) {
|
|
4642
4652
|
var _this$getAddressState2;
|
|
4643
4653
|
const formattedTx = formatPastTx(tx);
|
|
4644
|
-
const storePastTx = (_this$getAddressState2 = this.getAddressState(address)) === null || _this$getAddressState2 === void 0 ? void 0 : _this$getAddressState2.formattedPastTransactions;
|
|
4654
|
+
const storePastTx = ((_this$getAddressState2 = this.getAddressState(address)) === null || _this$getAddressState2 === void 0 ? void 0 : _this$getAddressState2.formattedPastTransactions) || [];
|
|
4645
4655
|
const duplicateIndex = storePastTx.findIndex(x => x.transaction_hash === tx.transaction_hash && x.chainId === tx.chain_id);
|
|
4646
4656
|
if (tx.status === base_controllers_namespaceObject.TransactionStatus.submitted || tx.status === base_controllers_namespaceObject.TransactionStatus.confirmed) {
|
|
4647
4657
|
if (duplicateIndex === -1) {
|