@toruslabs/ethereum-controllers 5.2.14 → 5.3.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/dist/ethereumControllers.cjs.js +38 -6
- package/dist/ethereumControllers.cjs.js.map +1 -1
- package/dist/ethereumControllers.esm.js +38 -7
- 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 +2 -2
- package/package.json +3 -3
- package/src/Preferences/PreferencesController.ts +3 -3
- package/src/utils/constants.ts +34 -0
- package/src/utils/helpers.ts +2 -2
- package/src/utils/interfaces.ts +2 -2
|
@@ -699,6 +699,7 @@ const singleBalanceCheckerAbi = [{
|
|
|
699
699
|
type: "function"
|
|
700
700
|
}];
|
|
701
701
|
;// CONCATENATED MODULE: ./src/utils/constants.ts
|
|
702
|
+
|
|
702
703
|
const LOCALHOST = "localhost";
|
|
703
704
|
const CONTRACT_TYPE_ETH = "eth";
|
|
704
705
|
const CONTRACT_TYPE_ERC20 = "erc20";
|
|
@@ -727,6 +728,8 @@ const BASE_TESTNET_CHAIN_ID = "0x14a34";
|
|
|
727
728
|
const INFURA_KEY = process.env.VITE_APP_INFURA_PROJECT_KEY;
|
|
728
729
|
const SUPPORTED_NETWORKS = {
|
|
729
730
|
[MAINNET_CHAIN_ID]: {
|
|
731
|
+
chainNamespace: base_controllers_namespaceObject.CHAIN_NAMESPACES.EIP155,
|
|
732
|
+
decimals: 18,
|
|
730
733
|
blockExplorerUrl: "https://etherscan.io",
|
|
731
734
|
chainId: MAINNET_CHAIN_ID,
|
|
732
735
|
displayName: "Ethereum",
|
|
@@ -736,6 +739,8 @@ const SUPPORTED_NETWORKS = {
|
|
|
736
739
|
tickerName: "Ethereum"
|
|
737
740
|
},
|
|
738
741
|
[POLYGON_CHAIN_ID]: {
|
|
742
|
+
chainNamespace: base_controllers_namespaceObject.CHAIN_NAMESPACES.EIP155,
|
|
743
|
+
decimals: 18,
|
|
739
744
|
blockExplorerUrl: "https://polygonscan.com",
|
|
740
745
|
chainId: POLYGON_CHAIN_ID,
|
|
741
746
|
displayName: "Polygon",
|
|
@@ -745,6 +750,8 @@ const SUPPORTED_NETWORKS = {
|
|
|
745
750
|
tickerName: "Matic Network Token"
|
|
746
751
|
},
|
|
747
752
|
[BSC_MAINNET_CHAIN_ID]: {
|
|
753
|
+
chainNamespace: base_controllers_namespaceObject.CHAIN_NAMESPACES.EIP155,
|
|
754
|
+
decimals: 18,
|
|
748
755
|
blockExplorerUrl: "https://bscscan.com",
|
|
749
756
|
chainId: BSC_MAINNET_CHAIN_ID,
|
|
750
757
|
displayName: "Binance Smart Chain (BSC)",
|
|
@@ -754,6 +761,8 @@ const SUPPORTED_NETWORKS = {
|
|
|
754
761
|
tickerName: "Binance Coin"
|
|
755
762
|
},
|
|
756
763
|
[AVALANCHE_MAINNET_CHAIN_ID]: {
|
|
764
|
+
chainNamespace: base_controllers_namespaceObject.CHAIN_NAMESPACES.EIP155,
|
|
765
|
+
decimals: 18,
|
|
757
766
|
blockExplorerUrl: "https://snowtrace.io",
|
|
758
767
|
chainId: AVALANCHE_MAINNET_CHAIN_ID,
|
|
759
768
|
displayName: "Avalanche",
|
|
@@ -763,6 +772,8 @@ const SUPPORTED_NETWORKS = {
|
|
|
763
772
|
tickerName: "Avalanche"
|
|
764
773
|
},
|
|
765
774
|
[OPTIMISM_MAINNET_CHAIN_ID]: {
|
|
775
|
+
chainNamespace: base_controllers_namespaceObject.CHAIN_NAMESPACES.EIP155,
|
|
776
|
+
decimals: 18,
|
|
766
777
|
blockExplorerUrl: "https://optimistic.etherscan.io",
|
|
767
778
|
chainId: OPTIMISM_MAINNET_CHAIN_ID,
|
|
768
779
|
displayName: "Optimism",
|
|
@@ -772,6 +783,8 @@ const SUPPORTED_NETWORKS = {
|
|
|
772
783
|
tickerName: "Ethereum"
|
|
773
784
|
},
|
|
774
785
|
[CELO_MAINNET_CHAIN_ID]: {
|
|
786
|
+
chainNamespace: base_controllers_namespaceObject.CHAIN_NAMESPACES.EIP155,
|
|
787
|
+
decimals: 18,
|
|
775
788
|
blockExplorerUrl: "https://explorer.celo.org",
|
|
776
789
|
chainId: CELO_MAINNET_CHAIN_ID,
|
|
777
790
|
displayName: "Celo Mainnet",
|
|
@@ -781,6 +794,8 @@ const SUPPORTED_NETWORKS = {
|
|
|
781
794
|
tickerName: "Celo"
|
|
782
795
|
},
|
|
783
796
|
[ARBITRUM_MAINNET_CHAIN_ID]: {
|
|
797
|
+
chainNamespace: base_controllers_namespaceObject.CHAIN_NAMESPACES.EIP155,
|
|
798
|
+
decimals: 18,
|
|
784
799
|
blockExplorerUrl: "https://arbiscan.io",
|
|
785
800
|
chainId: ARBITRUM_MAINNET_CHAIN_ID,
|
|
786
801
|
displayName: "Arbitrum One",
|
|
@@ -790,6 +805,8 @@ const SUPPORTED_NETWORKS = {
|
|
|
790
805
|
tickerName: "Ethereum"
|
|
791
806
|
},
|
|
792
807
|
[XDAI_CHAIN_ID]: {
|
|
808
|
+
chainNamespace: base_controllers_namespaceObject.CHAIN_NAMESPACES.EIP155,
|
|
809
|
+
decimals: 18,
|
|
793
810
|
blockExplorerUrl: "https://gnosis.blockscout.com",
|
|
794
811
|
chainId: XDAI_CHAIN_ID,
|
|
795
812
|
displayName: "xDai",
|
|
@@ -799,6 +816,8 @@ const SUPPORTED_NETWORKS = {
|
|
|
799
816
|
tickerName: "xDai Token"
|
|
800
817
|
},
|
|
801
818
|
[BASE_CHAIN_ID]: {
|
|
819
|
+
chainNamespace: base_controllers_namespaceObject.CHAIN_NAMESPACES.EIP155,
|
|
820
|
+
decimals: 18,
|
|
802
821
|
blockExplorerUrl: "https://basescan.org",
|
|
803
822
|
chainId: BASE_CHAIN_ID,
|
|
804
823
|
displayName: "Base",
|
|
@@ -808,6 +827,8 @@ const SUPPORTED_NETWORKS = {
|
|
|
808
827
|
tickerName: "Ethereum"
|
|
809
828
|
},
|
|
810
829
|
[SEPOLIA_CHAIN_ID]: {
|
|
830
|
+
chainNamespace: base_controllers_namespaceObject.CHAIN_NAMESPACES.EIP155,
|
|
831
|
+
decimals: 18,
|
|
811
832
|
blockExplorerUrl: "https://sepolia.etherscan.io",
|
|
812
833
|
chainId: SEPOLIA_CHAIN_ID,
|
|
813
834
|
displayName: "Sepolia Test Network",
|
|
@@ -818,6 +839,8 @@ const SUPPORTED_NETWORKS = {
|
|
|
818
839
|
isTestnet: true
|
|
819
840
|
},
|
|
820
841
|
[POLYGON_MUMBAI_CHAIN_ID]: {
|
|
842
|
+
chainNamespace: base_controllers_namespaceObject.CHAIN_NAMESPACES.EIP155,
|
|
843
|
+
decimals: 18,
|
|
821
844
|
blockExplorerUrl: "https://mumbai.polygonscan.com",
|
|
822
845
|
chainId: POLYGON_MUMBAI_CHAIN_ID,
|
|
823
846
|
displayName: "Polygon Mumbai",
|
|
@@ -828,6 +851,8 @@ const SUPPORTED_NETWORKS = {
|
|
|
828
851
|
isTestnet: true
|
|
829
852
|
},
|
|
830
853
|
[BSC_TESTNET_CHAIN_ID]: {
|
|
854
|
+
chainNamespace: base_controllers_namespaceObject.CHAIN_NAMESPACES.EIP155,
|
|
855
|
+
decimals: 18,
|
|
831
856
|
blockExplorerUrl: "https://testnet.bscscan.com",
|
|
832
857
|
chainId: BSC_TESTNET_CHAIN_ID,
|
|
833
858
|
displayName: "Binance Smart Chain Testnet",
|
|
@@ -838,6 +863,8 @@ const SUPPORTED_NETWORKS = {
|
|
|
838
863
|
isTestnet: true
|
|
839
864
|
},
|
|
840
865
|
[AVALANCHE_TESTNET_CHAIN_ID]: {
|
|
866
|
+
chainNamespace: base_controllers_namespaceObject.CHAIN_NAMESPACES.EIP155,
|
|
867
|
+
decimals: 18,
|
|
841
868
|
blockExplorerUrl: "https://testnet.snowtrace.io",
|
|
842
869
|
chainId: AVALANCHE_TESTNET_CHAIN_ID,
|
|
843
870
|
displayName: "Avalanche Testnet C-Chain",
|
|
@@ -848,6 +875,8 @@ const SUPPORTED_NETWORKS = {
|
|
|
848
875
|
isTestnet: true
|
|
849
876
|
},
|
|
850
877
|
[ARBITRUM_TESTNET_CHAIN_ID]: {
|
|
878
|
+
chainNamespace: base_controllers_namespaceObject.CHAIN_NAMESPACES.EIP155,
|
|
879
|
+
decimals: 18,
|
|
851
880
|
blockExplorerUrl: "https://sepolia.arbiscan.io",
|
|
852
881
|
chainId: ARBITRUM_TESTNET_CHAIN_ID,
|
|
853
882
|
displayName: "Arbitrum Sepolia",
|
|
@@ -858,6 +887,8 @@ const SUPPORTED_NETWORKS = {
|
|
|
858
887
|
isTestnet: true
|
|
859
888
|
},
|
|
860
889
|
[OPTIMISM_TESTNET_CHAIN_ID]: {
|
|
890
|
+
chainNamespace: base_controllers_namespaceObject.CHAIN_NAMESPACES.EIP155,
|
|
891
|
+
decimals: 18,
|
|
861
892
|
blockExplorerUrl: "https://sepolia-optimistic.etherscan.io",
|
|
862
893
|
chainId: OPTIMISM_TESTNET_CHAIN_ID,
|
|
863
894
|
displayName: "Optimism Sepolia",
|
|
@@ -868,6 +899,8 @@ const SUPPORTED_NETWORKS = {
|
|
|
868
899
|
isTestnet: true
|
|
869
900
|
},
|
|
870
901
|
[BASE_TESTNET_CHAIN_ID]: {
|
|
902
|
+
chainNamespace: base_controllers_namespaceObject.CHAIN_NAMESPACES.EIP155,
|
|
903
|
+
decimals: 18,
|
|
871
904
|
blockExplorerUrl: "https://sepolia.basescan.org",
|
|
872
905
|
chainId: BASE_TESTNET_CHAIN_ID,
|
|
873
906
|
displayName: "Base Sepolia",
|
|
@@ -1203,8 +1236,8 @@ const formatPastTx = (x, lowerCaseSelectedAddress) => {
|
|
|
1203
1236
|
currencyAmountString,
|
|
1204
1237
|
amount: `${totalAmountString} / ${currencyAmountString}`,
|
|
1205
1238
|
status: x.status,
|
|
1206
|
-
etherscanLink: getEtherScanHashLink(x.transaction_hash, x.
|
|
1207
|
-
|
|
1239
|
+
etherscanLink: getEtherScanHashLink(x.transaction_hash, x.chain_id || MAINNET_CHAIN_ID),
|
|
1240
|
+
chainId: x.chain_id,
|
|
1208
1241
|
ethRate: Number.parseFloat(x === null || x === void 0 ? void 0 : x.total_amount) && Number.parseFloat(x === null || x === void 0 ? void 0 : x.currency_amount) ? `1 ${x.symbol} = ${(0,base_controllers_namespaceObject.significantDigits)(Number.parseFloat(x.currency_amount) / Number.parseFloat(x.total_amount))}` : "",
|
|
1209
1242
|
currencyUsed: x.selected_currency,
|
|
1210
1243
|
type: x.type,
|
|
@@ -4208,7 +4241,7 @@ class PreferencesController extends base_controllers_namespaceObject.BasePrefere
|
|
|
4208
4241
|
var _this$getAddressState2;
|
|
4209
4242
|
const formattedTx = formatPastTx(tx);
|
|
4210
4243
|
const storePastTx = (_this$getAddressState2 = this.getAddressState(address)) === null || _this$getAddressState2 === void 0 ? void 0 : _this$getAddressState2.formattedPastTransactions;
|
|
4211
|
-
const duplicateIndex = storePastTx.findIndex(x => x.transaction_hash === tx.transaction_hash && x.
|
|
4244
|
+
const duplicateIndex = storePastTx.findIndex(x => x.transaction_hash === tx.transaction_hash && x.chainId === tx.chain_id);
|
|
4212
4245
|
if (tx.status === base_controllers_namespaceObject.TransactionStatus.submitted || tx.status === base_controllers_namespaceObject.TransactionStatus.confirmed) {
|
|
4213
4246
|
if (duplicateIndex === -1) {
|
|
4214
4247
|
// No duplicate found
|
|
@@ -4436,7 +4469,7 @@ class PreferencesController extends base_controllers_namespaceObject.BasePrefere
|
|
|
4436
4469
|
const pendingTx = [];
|
|
4437
4470
|
const lowerCaseSelectedAddress = address.toLowerCase();
|
|
4438
4471
|
for (const x of txs) {
|
|
4439
|
-
if (x.
|
|
4472
|
+
if (x.chain_id === SUPPORTED_NETWORKS[this.getProviderConfig().chainId].chainId && x.to && x.from && (lowerCaseSelectedAddress === x.from.toLowerCase() || lowerCaseSelectedAddress === x.to.toLowerCase())) {
|
|
4440
4473
|
if (x.status !== "confirmed") {
|
|
4441
4474
|
pendingTx.push(x);
|
|
4442
4475
|
} else {
|
|
@@ -4453,8 +4486,7 @@ class PreferencesController extends base_controllers_namespaceObject.BasePrefere
|
|
|
4453
4486
|
pastTx.push(finalObject);
|
|
4454
4487
|
if (lowerCaseSelectedAddress === element.from.toLowerCase() && finalObject.status && finalObject.status !== element.status) this.patchPastTx({
|
|
4455
4488
|
id: element.id,
|
|
4456
|
-
status: finalObject.status
|
|
4457
|
-
updated_at: new Date().toISOString()
|
|
4489
|
+
status: finalObject.status
|
|
4458
4490
|
}, address);
|
|
4459
4491
|
}
|
|
4460
4492
|
const finalTx = this.cancelTxCalculate(pastTx);
|