mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
Delete amountConversionRate and selectors (#8503)
This commit is contained in:
parent
898feee69b
commit
5b06bf795b
@ -103,7 +103,7 @@ initialize().catch(log.error)
|
|||||||
* @property {Array} frequentRpcList - A list of frequently used RPCs, including custom user-provided ones.
|
* @property {Array} frequentRpcList - A list of frequently used RPCs, including custom user-provided ones.
|
||||||
* @property {Array} addressBook - A list of previously sent to addresses.
|
* @property {Array} addressBook - A list of previously sent to addresses.
|
||||||
* @property {address} selectedTokenAddress - Used to indicate if a token is globally selected. Should be deprecated in favor of UI-centric token selection.
|
* @property {address} selectedTokenAddress - Used to indicate if a token is globally selected. Should be deprecated in favor of UI-centric token selection.
|
||||||
* @property {Object} tokenExchangeRates - Info about current token prices.
|
* @property {Object} contractExchangeRates - Info about current token prices.
|
||||||
* @property {Array} tokens - Tokens held by the current user, including their balances.
|
* @property {Array} tokens - Tokens held by the current user, including their balances.
|
||||||
* @property {Object} send - TODO: Document
|
* @property {Object} send - TODO: Document
|
||||||
* @property {Object} coinOptions - TODO: Document
|
* @property {Object} coinOptions - TODO: Document
|
||||||
|
@ -46,30 +46,6 @@ describe('Selectors', function () {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
describe('#getTokenExchangeRate', function () {
|
|
||||||
let missingTokenRate
|
|
||||||
|
|
||||||
beforeEach(function () {
|
|
||||||
missingTokenRate = {
|
|
||||||
metamask: {
|
|
||||||
'contractExchangeRates': {},
|
|
||||||
},
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
it('returns 0 token exchange rate for a token not in state', function () {
|
|
||||||
const tokenRate = selectors.getTokenExchangeRate(missingTokenRate, '0xd8f6a2ffb0fc5952d16c9768b71cfd35b6399aa5')
|
|
||||||
assert.equal(tokenRate, 0)
|
|
||||||
})
|
|
||||||
|
|
||||||
it('returns token exchange rate for specified token in state', function () {
|
|
||||||
const tokenRate = selectors.getTokenExchangeRate(mockState, '0xd8f6a2ffb0fc5952d16c9768b71cfd35b6399aa5')
|
|
||||||
assert.equal(tokenRate, 0.00008189274407698049)
|
|
||||||
})
|
|
||||||
|
|
||||||
})
|
|
||||||
|
|
||||||
it('returns conversionRate from state', function () {
|
it('returns conversionRate from state', function () {
|
||||||
assert.equal(selectors.conversionRateSelector(mockState), 556.12)
|
assert.equal(selectors.conversionRateSelector(mockState), 556.12)
|
||||||
})
|
})
|
||||||
|
@ -1,6 +1,11 @@
|
|||||||
import { connect } from 'react-redux'
|
import { connect } from 'react-redux'
|
||||||
import TokenInput from './token-input.component'
|
import TokenInput from './token-input.component'
|
||||||
import { getIsMainnet, getSelectedToken, getSelectedTokenExchangeRate, preferencesSelector } from '../../../selectors'
|
import {
|
||||||
|
getIsMainnet,
|
||||||
|
getSelectedToken,
|
||||||
|
getSelectedTokenExchangeRate,
|
||||||
|
preferencesSelector,
|
||||||
|
} from '../../../selectors'
|
||||||
|
|
||||||
const mapStateToProps = (state) => {
|
const mapStateToProps = (state) => {
|
||||||
const { metamask: { currentCurrency } } = state
|
const { metamask: { currentCurrency } } = state
|
||||||
|
@ -12,7 +12,6 @@ export default function reduceMetamask (state = {}, action) {
|
|||||||
addressBook: [],
|
addressBook: [],
|
||||||
selectedTokenAddress: null,
|
selectedTokenAddress: null,
|
||||||
contractExchangeRates: {},
|
contractExchangeRates: {},
|
||||||
tokenExchangeRates: {},
|
|
||||||
tokens: [],
|
tokens: [],
|
||||||
pendingTokens: {},
|
pendingTokens: {},
|
||||||
customNonceValue: '',
|
customNonceValue: '',
|
||||||
|
@ -10,10 +10,6 @@ export default class SendAmountRow extends Component {
|
|||||||
|
|
||||||
static propTypes = {
|
static propTypes = {
|
||||||
amount: PropTypes.string,
|
amount: PropTypes.string,
|
||||||
amountConversionRate: PropTypes.oneOfType([
|
|
||||||
PropTypes.string,
|
|
||||||
PropTypes.number,
|
|
||||||
]),
|
|
||||||
balance: PropTypes.string,
|
balance: PropTypes.string,
|
||||||
conversionRate: PropTypes.number,
|
conversionRate: PropTypes.number,
|
||||||
gasTotal: PropTypes.string,
|
gasTotal: PropTypes.string,
|
||||||
@ -50,7 +46,6 @@ export default class SendAmountRow extends Component {
|
|||||||
|
|
||||||
validateAmount (amount) {
|
validateAmount (amount) {
|
||||||
const {
|
const {
|
||||||
amountConversionRate,
|
|
||||||
balance,
|
balance,
|
||||||
conversionRate,
|
conversionRate,
|
||||||
gasTotal,
|
gasTotal,
|
||||||
@ -63,7 +58,6 @@ export default class SendAmountRow extends Component {
|
|||||||
|
|
||||||
updateSendAmountError({
|
updateSendAmountError({
|
||||||
amount,
|
amount,
|
||||||
amountConversionRate,
|
|
||||||
balance,
|
balance,
|
||||||
conversionRate,
|
conversionRate,
|
||||||
gasTotal,
|
gasTotal,
|
||||||
@ -74,7 +68,6 @@ export default class SendAmountRow extends Component {
|
|||||||
|
|
||||||
if (selectedToken) {
|
if (selectedToken) {
|
||||||
updateGasFeeError({
|
updateGasFeeError({
|
||||||
amountConversionRate,
|
|
||||||
balance,
|
balance,
|
||||||
conversionRate,
|
conversionRate,
|
||||||
gasTotal,
|
gasTotal,
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
import { connect } from 'react-redux'
|
import { connect } from 'react-redux'
|
||||||
import {
|
import {
|
||||||
getAmountConversionRate,
|
|
||||||
getConversionRate,
|
getConversionRate,
|
||||||
getGasTotal,
|
getGasTotal,
|
||||||
getPrimaryCurrency,
|
getPrimaryCurrency,
|
||||||
@ -26,7 +25,6 @@ export default connect(mapStateToProps, mapDispatchToProps)(SendAmountRow)
|
|||||||
function mapStateToProps (state) {
|
function mapStateToProps (state) {
|
||||||
return {
|
return {
|
||||||
amount: getSendAmount(state),
|
amount: getSendAmount(state),
|
||||||
amountConversionRate: getAmountConversionRate(state),
|
|
||||||
balance: getSendFromBalance(state),
|
balance: getSendFromBalance(state),
|
||||||
conversionRate: getConversionRate(state),
|
conversionRate: getConversionRate(state),
|
||||||
gasTotal: getGasTotal(state),
|
gasTotal: getGasTotal(state),
|
||||||
|
@ -19,7 +19,6 @@ describe('SendAmountRow Component', function () {
|
|||||||
|
|
||||||
assert.ok(updateSendAmountError.calledOnceWithExactly({
|
assert.ok(updateSendAmountError.calledOnceWithExactly({
|
||||||
amount: 'someAmount',
|
amount: 'someAmount',
|
||||||
amountConversionRate: 'mockAmountConversionRate',
|
|
||||||
balance: 'mockBalance',
|
balance: 'mockBalance',
|
||||||
conversionRate: 7,
|
conversionRate: 7,
|
||||||
gasTotal: 'mockGasTotal',
|
gasTotal: 'mockGasTotal',
|
||||||
@ -37,7 +36,6 @@ describe('SendAmountRow Component', function () {
|
|||||||
instance.validateAmount('someAmount')
|
instance.validateAmount('someAmount')
|
||||||
|
|
||||||
assert.ok(updateGasFeeError.calledOnceWithExactly({
|
assert.ok(updateGasFeeError.calledOnceWithExactly({
|
||||||
amountConversionRate: 'mockAmountConversionRate',
|
|
||||||
balance: 'mockBalance',
|
balance: 'mockBalance',
|
||||||
conversionRate: 7,
|
conversionRate: 7,
|
||||||
gasTotal: 'mockGasTotal',
|
gasTotal: 'mockGasTotal',
|
||||||
@ -148,7 +146,6 @@ function shallowRenderSendAmountRow () {
|
|||||||
const wrapper = shallow((
|
const wrapper = shallow((
|
||||||
<SendAmountRow
|
<SendAmountRow
|
||||||
amount="mockAmount"
|
amount="mockAmount"
|
||||||
amountConversionRate="mockAmountConversionRate"
|
|
||||||
balance="mockBalance"
|
balance="mockBalance"
|
||||||
conversionRate={7}
|
conversionRate={7}
|
||||||
convertedCurrency="mockConvertedCurrency"
|
convertedCurrency="mockConvertedCurrency"
|
||||||
|
@ -20,10 +20,6 @@ export default class SendTransactionScreen extends Component {
|
|||||||
static propTypes = {
|
static propTypes = {
|
||||||
addressBook: PropTypes.arrayOf(PropTypes.object),
|
addressBook: PropTypes.arrayOf(PropTypes.object),
|
||||||
amount: PropTypes.string,
|
amount: PropTypes.string,
|
||||||
amountConversionRate: PropTypes.oneOfType([
|
|
||||||
PropTypes.string,
|
|
||||||
PropTypes.number,
|
|
||||||
]),
|
|
||||||
blockGasLimit: PropTypes.string,
|
blockGasLimit: PropTypes.string,
|
||||||
conversionRate: PropTypes.number,
|
conversionRate: PropTypes.number,
|
||||||
editingTransactionId: PropTypes.string,
|
editingTransactionId: PropTypes.string,
|
||||||
@ -77,7 +73,6 @@ export default class SendTransactionScreen extends Component {
|
|||||||
componentDidUpdate (prevProps) {
|
componentDidUpdate (prevProps) {
|
||||||
const {
|
const {
|
||||||
amount,
|
amount,
|
||||||
amountConversionRate,
|
|
||||||
conversionRate,
|
conversionRate,
|
||||||
from: { address, balance },
|
from: { address, balance },
|
||||||
gasTotal,
|
gasTotal,
|
||||||
@ -122,7 +117,6 @@ export default class SendTransactionScreen extends Component {
|
|||||||
if (amountErrorRequiresUpdate) {
|
if (amountErrorRequiresUpdate) {
|
||||||
const amountErrorObject = getAmountErrorObject({
|
const amountErrorObject = getAmountErrorObject({
|
||||||
amount,
|
amount,
|
||||||
amountConversionRate,
|
|
||||||
balance,
|
balance,
|
||||||
conversionRate,
|
conversionRate,
|
||||||
gasTotal,
|
gasTotal,
|
||||||
@ -132,7 +126,6 @@ export default class SendTransactionScreen extends Component {
|
|||||||
})
|
})
|
||||||
const gasFeeErrorObject = selectedToken
|
const gasFeeErrorObject = selectedToken
|
||||||
? getGasFeeErrorObject({
|
? getGasFeeErrorObject({
|
||||||
amountConversionRate,
|
|
||||||
balance,
|
balance,
|
||||||
conversionRate,
|
conversionRate,
|
||||||
gasTotal,
|
gasTotal,
|
||||||
|
@ -4,7 +4,6 @@ import { withRouter } from 'react-router-dom'
|
|||||||
import { compose } from 'redux'
|
import { compose } from 'redux'
|
||||||
|
|
||||||
import {
|
import {
|
||||||
getAmountConversionRate,
|
|
||||||
getBlockGasLimit,
|
getBlockGasLimit,
|
||||||
getConversionRate,
|
getConversionRate,
|
||||||
getCurrentNetwork,
|
getCurrentNetwork,
|
||||||
@ -59,7 +58,6 @@ function mapStateToProps (state) {
|
|||||||
return {
|
return {
|
||||||
addressBook: getAddressBook(state),
|
addressBook: getAddressBook(state),
|
||||||
amount: getSendAmount(state),
|
amount: getSendAmount(state),
|
||||||
amountConversionRate: getAmountConversionRate(state),
|
|
||||||
blockGasLimit: getBlockGasLimit(state),
|
blockGasLimit: getBlockGasLimit(state),
|
||||||
conversionRate: getConversionRate(state),
|
conversionRate: getConversionRate(state),
|
||||||
editingTransactionId,
|
editingTransactionId,
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
import abi from 'human-standard-token-abi'
|
import abi from 'human-standard-token-abi'
|
||||||
import { multiplyCurrencies } from '../../helpers/utils/conversion-util'
|
|
||||||
import {
|
import {
|
||||||
accountsWithSendEtherInfoSelector,
|
accountsWithSendEtherInfoSelector,
|
||||||
getAddressBook,
|
getAddressBook,
|
||||||
@ -10,12 +9,6 @@ import {
|
|||||||
} from '../../selectors'
|
} from '../../selectors'
|
||||||
import { estimateGasPriceFromRecentBlocks, calcGasTotal } from './send.utils'
|
import { estimateGasPriceFromRecentBlocks, calcGasTotal } from './send.utils'
|
||||||
|
|
||||||
export function getAmountConversionRate (state) {
|
|
||||||
return getSelectedToken(state)
|
|
||||||
? getSelectedTokenToFiatRate(state)
|
|
||||||
: getConversionRate(state)
|
|
||||||
}
|
|
||||||
|
|
||||||
export function getBlockGasLimit (state) {
|
export function getBlockGasLimit (state) {
|
||||||
return state.metamask.currentBlockGasLimit
|
return state.metamask.currentBlockGasLimit
|
||||||
}
|
}
|
||||||
@ -85,29 +78,6 @@ export function getSelectedTokenContract (state) {
|
|||||||
: null
|
: null
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getSelectedTokenExchangeRate (state) {
|
|
||||||
const tokenExchangeRates = state.metamask.tokenExchangeRates
|
|
||||||
const selectedToken = getSelectedToken(state) || {}
|
|
||||||
const { symbol = '' } = selectedToken
|
|
||||||
const pair = `${symbol.toLowerCase()}_eth`
|
|
||||||
const { rate: tokenExchangeRate = 0 } = (tokenExchangeRates && tokenExchangeRates[pair]) || {}
|
|
||||||
|
|
||||||
return tokenExchangeRate
|
|
||||||
}
|
|
||||||
|
|
||||||
export function getSelectedTokenToFiatRate (state) {
|
|
||||||
const selectedTokenExchangeRate = getSelectedTokenExchangeRate(state)
|
|
||||||
const conversionRate = getConversionRate(state)
|
|
||||||
|
|
||||||
const tokenToFiatRate = multiplyCurrencies(
|
|
||||||
conversionRate,
|
|
||||||
selectedTokenExchangeRate,
|
|
||||||
{ toNumericBase: 'dec' }
|
|
||||||
)
|
|
||||||
|
|
||||||
return tokenToFiatRate
|
|
||||||
}
|
|
||||||
|
|
||||||
export function getSendAmount (state) {
|
export function getSendAmount (state) {
|
||||||
return state.metamask.send.amount
|
return state.metamask.send.amount
|
||||||
}
|
}
|
||||||
@ -177,14 +147,6 @@ export function getSendEnsResolutionError (state) {
|
|||||||
return state.metamask.send.ensResolutionError
|
return state.metamask.send.ensResolutionError
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getTokenExchangeRate (state, tokenSymbol) {
|
|
||||||
const pair = `${tokenSymbol.toLowerCase()}_eth`
|
|
||||||
const tokenExchangeRates = state.metamask.tokenExchangeRates
|
|
||||||
const { rate: tokenExchangeRate = 0 } = tokenExchangeRates[pair] || {}
|
|
||||||
|
|
||||||
return tokenExchangeRate
|
|
||||||
}
|
|
||||||
|
|
||||||
export function getUnapprovedTxs (state) {
|
export function getUnapprovedTxs (state) {
|
||||||
return state.metamask.unapprovedTxs
|
return state.metamask.unapprovedTxs
|
||||||
}
|
}
|
||||||
|
@ -50,7 +50,6 @@ function calcGasTotal (gasLimit = '0', gasPrice = '0') {
|
|||||||
|
|
||||||
function isBalanceSufficient ({
|
function isBalanceSufficient ({
|
||||||
amount = '0x0',
|
amount = '0x0',
|
||||||
amountConversionRate = 1,
|
|
||||||
balance = '0x0',
|
balance = '0x0',
|
||||||
conversionRate = 1,
|
conversionRate = 1,
|
||||||
gasTotal = '0x0',
|
gasTotal = '0x0',
|
||||||
@ -72,7 +71,7 @@ function isBalanceSufficient ({
|
|||||||
{
|
{
|
||||||
value: totalAmount,
|
value: totalAmount,
|
||||||
fromNumericBase: 'hex',
|
fromNumericBase: 'hex',
|
||||||
conversionRate: Number(amountConversionRate) || conversionRate,
|
conversionRate: conversionRate,
|
||||||
fromCurrency: primaryCurrency,
|
fromCurrency: primaryCurrency,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
@ -104,7 +103,6 @@ function isTokenBalanceSufficient ({
|
|||||||
|
|
||||||
function getAmountErrorObject ({
|
function getAmountErrorObject ({
|
||||||
amount,
|
amount,
|
||||||
amountConversionRate,
|
|
||||||
balance,
|
balance,
|
||||||
conversionRate,
|
conversionRate,
|
||||||
gasTotal,
|
gasTotal,
|
||||||
@ -116,7 +114,6 @@ function getAmountErrorObject ({
|
|||||||
if (gasTotal && conversionRate && !selectedToken) {
|
if (gasTotal && conversionRate && !selectedToken) {
|
||||||
insufficientFunds = !isBalanceSufficient({
|
insufficientFunds = !isBalanceSufficient({
|
||||||
amount,
|
amount,
|
||||||
amountConversionRate,
|
|
||||||
balance,
|
balance,
|
||||||
conversionRate,
|
conversionRate,
|
||||||
gasTotal,
|
gasTotal,
|
||||||
@ -153,7 +150,6 @@ function getAmountErrorObject ({
|
|||||||
}
|
}
|
||||||
|
|
||||||
function getGasFeeErrorObject ({
|
function getGasFeeErrorObject ({
|
||||||
amountConversionRate,
|
|
||||||
balance,
|
balance,
|
||||||
conversionRate,
|
conversionRate,
|
||||||
gasTotal,
|
gasTotal,
|
||||||
@ -164,7 +160,6 @@ function getGasFeeErrorObject ({
|
|||||||
if (gasTotal && conversionRate) {
|
if (gasTotal && conversionRate) {
|
||||||
const insufficientFunds = !isBalanceSufficient({
|
const insufficientFunds = !isBalanceSufficient({
|
||||||
amount: '0x0',
|
amount: '0x0',
|
||||||
amountConversionRate,
|
|
||||||
balance,
|
balance,
|
||||||
conversionRate,
|
conversionRate,
|
||||||
gasTotal,
|
gasTotal,
|
||||||
|
@ -45,7 +45,6 @@ describe('Send Component', function () {
|
|||||||
wrapper = shallow((
|
wrapper = shallow((
|
||||||
<SendTransactionScreen
|
<SendTransactionScreen
|
||||||
amount="mockAmount"
|
amount="mockAmount"
|
||||||
amountConversionRate="mockAmountConversionRate"
|
|
||||||
blockGasLimit="mockBlockGasLimit"
|
blockGasLimit="mockBlockGasLimit"
|
||||||
conversionRate={10}
|
conversionRate={10}
|
||||||
editingTransactionId="mockEditingTransactionId"
|
editingTransactionId="mockEditingTransactionId"
|
||||||
@ -171,7 +170,6 @@ describe('Send Component', function () {
|
|||||||
utilsMethodStubs.getAmountErrorObject.getCall(0).args[0],
|
utilsMethodStubs.getAmountErrorObject.getCall(0).args[0],
|
||||||
{
|
{
|
||||||
amount: 'mockAmount',
|
amount: 'mockAmount',
|
||||||
amountConversionRate: 'mockAmountConversionRate',
|
|
||||||
balance: 'mockBalance',
|
balance: 'mockBalance',
|
||||||
conversionRate: 10,
|
conversionRate: 10,
|
||||||
gasTotal: 'mockGasTotal',
|
gasTotal: 'mockGasTotal',
|
||||||
@ -193,7 +191,6 @@ describe('Send Component', function () {
|
|||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
utilsMethodStubs.getGasFeeErrorObject.getCall(0).args[0],
|
utilsMethodStubs.getGasFeeErrorObject.getCall(0).args[0],
|
||||||
{
|
{
|
||||||
amountConversionRate: 'mockAmountConversionRate',
|
|
||||||
balance: 'mockBalance',
|
balance: 'mockBalance',
|
||||||
conversionRate: 10,
|
conversionRate: 10,
|
||||||
gasTotal: 'mockGasTotal',
|
gasTotal: 'mockGasTotal',
|
||||||
|
@ -82,14 +82,6 @@ export default {
|
|||||||
'symbol': 'GHI',
|
'symbol': 'GHI',
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
'tokenExchangeRates': {
|
|
||||||
'def_eth': {
|
|
||||||
rate: 2.0,
|
|
||||||
},
|
|
||||||
'ghi_eth': {
|
|
||||||
rate: 31.01,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
'transactions': {},
|
'transactions': {},
|
||||||
'currentNetworkTxList': [
|
'currentNetworkTxList': [
|
||||||
{
|
{
|
||||||
|
@ -6,7 +6,6 @@ import {
|
|||||||
} from '../../../selectors'
|
} from '../../../selectors'
|
||||||
import {
|
import {
|
||||||
getBlockGasLimit,
|
getBlockGasLimit,
|
||||||
getAmountConversionRate,
|
|
||||||
getConversionRate,
|
getConversionRate,
|
||||||
getCurrentCurrency,
|
getCurrentCurrency,
|
||||||
getCurrentNetwork,
|
getCurrentNetwork,
|
||||||
@ -19,8 +18,6 @@ import {
|
|||||||
getSelectedIdentity,
|
getSelectedIdentity,
|
||||||
getSelectedToken,
|
getSelectedToken,
|
||||||
getSelectedTokenContract,
|
getSelectedTokenContract,
|
||||||
getSelectedTokenExchangeRate,
|
|
||||||
getSelectedTokenToFiatRate,
|
|
||||||
getSendAmount,
|
getSendAmount,
|
||||||
sendAmountIsInError,
|
sendAmountIsInError,
|
||||||
getSendEditingTransactionId,
|
getSendEditingTransactionId,
|
||||||
@ -33,7 +30,6 @@ import {
|
|||||||
getSendTo,
|
getSendTo,
|
||||||
getSendToAccounts,
|
getSendToAccounts,
|
||||||
getTokenBalance,
|
getTokenBalance,
|
||||||
getTokenExchangeRate,
|
|
||||||
getUnapprovedTxs,
|
getUnapprovedTxs,
|
||||||
gasFeeIsInError,
|
gasFeeIsInError,
|
||||||
getGasLoadingError,
|
getGasLoadingError,
|
||||||
@ -96,34 +92,6 @@ describe('send selectors', function () {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
// describe('autoAddToBetaUI()', () => {
|
|
||||||
// it('should', () => {
|
|
||||||
// assert.deepEqual(
|
|
||||||
// autoAddToBetaUI(mockState),
|
|
||||||
|
|
||||||
// )
|
|
||||||
// })
|
|
||||||
// })
|
|
||||||
|
|
||||||
describe('getAmountConversionRate()', function () {
|
|
||||||
it('should return the token conversion rate if a token is selected', function () {
|
|
||||||
assert.equal(
|
|
||||||
getAmountConversionRate(mockState),
|
|
||||||
2401.76400654
|
|
||||||
)
|
|
||||||
})
|
|
||||||
|
|
||||||
it('should return the eth conversion rate if no token is selected', function () {
|
|
||||||
const editedMockState = {
|
|
||||||
metamask: Object.assign({}, mockState.metamask, { selectedTokenAddress: null }),
|
|
||||||
}
|
|
||||||
assert.equal(
|
|
||||||
getAmountConversionRate(editedMockState),
|
|
||||||
1200.88200327
|
|
||||||
)
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
describe('getBlockGasLimit', function () {
|
describe('getBlockGasLimit', function () {
|
||||||
it('should return the current block gas limit', function () {
|
it('should return the current block gas limit', function () {
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
@ -291,24 +259,6 @@ describe('send selectors', function () {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('getSelectedTokenExchangeRate()', function () {
|
|
||||||
it('should return the exchange rate for the selected token', function () {
|
|
||||||
assert.equal(
|
|
||||||
getSelectedTokenExchangeRate(mockState),
|
|
||||||
2.0
|
|
||||||
)
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
describe('getSelectedTokenToFiatRate()', function () {
|
|
||||||
it('should return rate for converting the selected token to fiat', function () {
|
|
||||||
assert.equal(
|
|
||||||
getSelectedTokenToFiatRate(mockState),
|
|
||||||
2401.76400654
|
|
||||||
)
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
describe('getSendAmount()', function () {
|
describe('getSendAmount()', function () {
|
||||||
it('should return the send.amount', function () {
|
it('should return the send.amount', function () {
|
||||||
assert.equal(
|
assert.equal(
|
||||||
@ -480,15 +430,6 @@ describe('send selectors', function () {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('getTokenExchangeRate()', function () {
|
|
||||||
it('should return the passed tokens exchange rates', function () {
|
|
||||||
assert.equal(
|
|
||||||
getTokenExchangeRate(mockState, 'GHI'),
|
|
||||||
31.01
|
|
||||||
)
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
describe('getUnapprovedTxs()', function () {
|
describe('getUnapprovedTxs()', function () {
|
||||||
it('should return the unapproved txs', function () {
|
it('should return the unapproved txs', function () {
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
|
@ -140,7 +140,6 @@ describe('send utils', function () {
|
|||||||
const config = {
|
const config = {
|
||||||
'should return insufficientFunds error if isBalanceSufficient returns false': {
|
'should return insufficientFunds error if isBalanceSufficient returns false': {
|
||||||
amount: 15,
|
amount: 15,
|
||||||
amountConversionRate: 2,
|
|
||||||
balance: 1,
|
balance: 1,
|
||||||
conversionRate: 3,
|
conversionRate: 3,
|
||||||
gasTotal: 17,
|
gasTotal: 17,
|
||||||
@ -149,7 +148,6 @@ describe('send utils', function () {
|
|||||||
},
|
},
|
||||||
'should not return insufficientFunds error if selectedToken is truthy': {
|
'should not return insufficientFunds error if selectedToken is truthy': {
|
||||||
amount: '0x0',
|
amount: '0x0',
|
||||||
amountConversionRate: 2,
|
|
||||||
balance: 1,
|
balance: 1,
|
||||||
conversionRate: 3,
|
conversionRate: 3,
|
||||||
gasTotal: 17,
|
gasTotal: 17,
|
||||||
@ -161,7 +159,6 @@ describe('send utils', function () {
|
|||||||
},
|
},
|
||||||
'should return insufficientTokens error if token is selected and isTokenBalanceSufficient returns false': {
|
'should return insufficientTokens error if token is selected and isTokenBalanceSufficient returns false': {
|
||||||
amount: '0x10',
|
amount: '0x10',
|
||||||
amountConversionRate: 2,
|
|
||||||
balance: 100,
|
balance: 100,
|
||||||
conversionRate: 3,
|
conversionRate: 3,
|
||||||
decimals: 10,
|
decimals: 10,
|
||||||
@ -182,7 +179,6 @@ describe('send utils', function () {
|
|||||||
describe('getGasFeeErrorObject()', function () {
|
describe('getGasFeeErrorObject()', function () {
|
||||||
const config = {
|
const config = {
|
||||||
'should return insufficientFunds error if isBalanceSufficient returns false': {
|
'should return insufficientFunds error if isBalanceSufficient returns false': {
|
||||||
amountConversionRate: 2,
|
|
||||||
balance: 16,
|
balance: 16,
|
||||||
conversionRate: 3,
|
conversionRate: 3,
|
||||||
gasTotal: 17,
|
gasTotal: 17,
|
||||||
@ -190,7 +186,6 @@ describe('send utils', function () {
|
|||||||
expectedResult: { gasFee: INSUFFICIENT_FUNDS_ERROR },
|
expectedResult: { gasFee: INSUFFICIENT_FUNDS_ERROR },
|
||||||
},
|
},
|
||||||
'should return null error if isBalanceSufficient returns true': {
|
'should return null error if isBalanceSufficient returns true': {
|
||||||
amountConversionRate: 2,
|
|
||||||
balance: 16,
|
balance: 16,
|
||||||
conversionRate: 3,
|
conversionRate: 3,
|
||||||
gasTotal: 15,
|
gasTotal: 15,
|
||||||
@ -223,7 +218,6 @@ describe('send utils', function () {
|
|||||||
stubs.conversionGTE.resetHistory()
|
stubs.conversionGTE.resetHistory()
|
||||||
const result = isBalanceSufficient({
|
const result = isBalanceSufficient({
|
||||||
amount: 15,
|
amount: 15,
|
||||||
amountConversionRate: 2,
|
|
||||||
balance: 100,
|
balance: 100,
|
||||||
conversionRate: 3,
|
conversionRate: 3,
|
||||||
gasTotal: 17,
|
gasTotal: 17,
|
||||||
@ -251,7 +245,7 @@ describe('send utils', function () {
|
|||||||
{
|
{
|
||||||
value: 32,
|
value: 32,
|
||||||
fromNumericBase: 'hex',
|
fromNumericBase: 'hex',
|
||||||
conversionRate: 2,
|
conversionRate: 3,
|
||||||
fromCurrency: 'ABC',
|
fromCurrency: 'ABC',
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
|
@ -184,11 +184,6 @@ export function getAssetImages (state) {
|
|||||||
return assetImages
|
return assetImages
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getTokenExchangeRate (state, address) {
|
|
||||||
const contractExchangeRates = state.metamask.contractExchangeRates
|
|
||||||
return contractExchangeRates[address] || 0
|
|
||||||
}
|
|
||||||
|
|
||||||
export function getAddressBook (state) {
|
export function getAddressBook (state) {
|
||||||
const network = state.metamask.network
|
const network = state.metamask.network
|
||||||
if (!state.metamask.addressBook[network]) {
|
if (!state.metamask.addressBook[network]) {
|
||||||
|
@ -84,13 +84,9 @@ export default {
|
|||||||
'symbol': 'GHI',
|
'symbol': 'GHI',
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
'tokenExchangeRates': {
|
'contractExchangeRates': {
|
||||||
'def_eth': {
|
'0x8d6b81208414189a58339873ab429b6c47ab92d3': 0.00039345803819379796,
|
||||||
rate: 2.0,
|
'0xd8f6a2ffb0fc5952d16c9768b71cfd35b6399aa5': 0.00008189274407698049,
|
||||||
},
|
|
||||||
'ghi_eth': {
|
|
||||||
rate: 31.01,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
'transactions': {},
|
'transactions': {},
|
||||||
'currentNetworkTxList': [
|
'currentNetworkTxList': [
|
||||||
|
Loading…
Reference in New Issue
Block a user