Skip to content

Commit d893875

Browse files
committed
chore: 👷 update years, fix conflicts
2 parents 5406191 + 75c0ca6 commit d893875

File tree

20 files changed

+1003
-1349
lines changed

20 files changed

+1003
-1349
lines changed

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2015 - 2021 MyEtherWallet
3+
Copyright (c) 2015 - 2022 MyEtherWallet
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

changelog/devop-3696.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* Added toBNSafe that safely converts numbers to BN

changelog/fix-3697.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
fetch tokens when network is changed

changelog/fix-3705.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
fix icons and link in module confirmation, hide notification dropdown if theres no notifications

package-lock.json

Lines changed: 914 additions & 1292 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/assets/styles/GlobalStyles.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ div {
9696
padding: 0;
9797
margin: 0;
9898
font-size: 1rem;
99-
line-height: 1.357rem;
99+
// line-height: 1.357rem;
100100
font-weight: 400;
101101
}
102102

src/core/helpers/numberFormatHelper.js

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
import BigNumber from 'bignumber.js';
2+
import { isNull, isUndefined } from 'lodash';
3+
import { toBN } from 'web3-utils';
24
import { fromWei } from 'web3-utils';
35
/**
46
* ---------------------------------
@@ -478,12 +480,26 @@ const getRoundNumber = (value, round, hasTrailingZeros = false) => {
478480
};
479481
};
480482

483+
/*****************************************
484+
* handeles edgecases for web3 util toBN
485+
* @param {number} number - expects number, handles non numbers
486+
* @return {BigNumber} BN from web3
487+
*****************************************/
488+
489+
const toBNSafe = number => {
490+
if (isNaN(number) || isNull(number) || isUndefined(number) || number === '')
491+
number = 0;
492+
number = toBN(new BigNumber(number).toFixed(0));
493+
return number;
494+
};
495+
481496
export {
482497
formatIntegerToString,
483498
formatIntegerValue,
484499
formatFloatingPointValue,
485500
formatFiatValue,
486501
formatBalanceEthValue,
487502
formatPercentageValue,
488-
formatGasValue
503+
formatGasValue,
504+
toBNSafe
489505
};

src/core/store/global/actions.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { toBN } from 'web3-utils';
1+
import { toBNSafe } from '@/core/helpers/numberFormatHelper';
22

33
const setOnlineStatus = function ({ commit, dispatch }, val) {
44
if (val) dispatch('wallet/setWeb3Instance', null, { root: true });
@@ -13,14 +13,16 @@ const updateGasPrice = function ({ rootState, dispatch, getters, state }) {
1313
const web3 = rootState.wallet.web3;
1414
if (!getters.isEIP1559SupportedNetwork) {
1515
return web3.eth.getGasPrice().then(res => {
16-
const modifiedGasPrice = toBN(res).muln(
16+
const modifiedGasPrice = toBNSafe(res).muln(
1717
getters.network.type.gasPriceMultiplier
1818
);
1919
return dispatch('setGasPrice', modifiedGasPrice.toString());
2020
});
2121
}
2222
return web3.eth.getGasPrice().then(gasPrice => {
23-
const priorityFee = toBN(gasPrice).sub(toBN(state.eip1559.baseFeePerGas));
23+
const priorityFee = toBNSafe(gasPrice).sub(
24+
toBNSafe(state.eip1559.baseFeePerGas)
25+
);
2426
return dispatch('setMaxPriorityFeePerGas', priorityFee);
2527
});
2628
};
@@ -31,8 +33,9 @@ const setGasPrice = function ({ commit }, gasPrice) {
3133
const setGasPriceType = function ({ commit }, type) {
3234
commit('SET_GAS_PRICE_TYPE', type);
3335
};
34-
const setNetwork = function ({ commit }, networkObj) {
36+
const setNetwork = function ({ commit, dispatch }, networkObj) {
3537
commit('SET_NETWORK', networkObj);
38+
dispatch('swap/resetPrefetch', null, { root: true });
3639
};
3740
const addLocalContract = function ({ commit }, localContract) {
3841
commit('ADD_LOCAL_CONTRACT', localContract);

src/core/store/swap/actions.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,7 @@
55
const setSwapTokens = function ({ commit }, tokens) {
66
commit('SET_SWAP_TOKENS', tokens);
77
};
8-
export default { setSwapTokens };
8+
const resetPrefetch = function ({ commit }) {
9+
commit('SET_PREFETCH', false);
10+
};
11+
export default { setSwapTokens, resetPrefetch };

src/core/store/swap/mutations.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,8 @@ const SET_SWAP_TOKENS = async function (state, tokens) {
33
state.prefetched = true;
44
};
55

6-
export default { SET_SWAP_TOKENS };
6+
const SET_PREFETCH = async function (state, prefetch) {
7+
state.prefetched = prefetch;
8+
};
9+
10+
export default { SET_SWAP_TOKENS, SET_PREFETCH };

0 commit comments

Comments
 (0)