Refactor token selectors (#8671)
Unused token selectors have been removed, and the remaining token selector has been moved to the `metamask` Redux store.feature/default_network_editable
parent
606618ee28
commit
88bed7181f
@ -1,28 +0,0 @@ |
||||
import assert from 'assert' |
||||
import { selectedTokenSelector } from '../tokens' |
||||
|
||||
const metaToken = { |
||||
'address': '0x617b3f8050a0bd94b6b1da02b4384ee5b4df13f4', |
||||
'symbol': 'META', |
||||
'decimals': 18, |
||||
} |
||||
|
||||
const state = { |
||||
metamask: { |
||||
selectedTokenAddress: '0x617b3f8050a0bd94b6b1da02b4384ee5b4df13f4', |
||||
tokens: [ |
||||
{ |
||||
'address': '0x06012c8cf97bead5deae237070f9587f8e7a266d', |
||||
'symbol': 'CK', |
||||
'decimals': 0, |
||||
}, |
||||
metaToken, |
||||
], |
||||
}, |
||||
} |
||||
describe('Selected Token Selector', function () { |
||||
it('selects token info from tokens based on selectedTokenAddress in state', function () { |
||||
const tokenInfo = selectedTokenSelector(state) |
||||
assert.equal(tokenInfo, metaToken) |
||||
}) |
||||
}) |
@ -1,11 +0,0 @@ |
||||
import { createSelector } from 'reselect' |
||||
|
||||
export const selectedTokenAddressSelector = (state) => state.metamask.selectedTokenAddress |
||||
export const tokenSelector = (state) => state.metamask.tokens |
||||
export const selectedTokenSelector = createSelector( |
||||
tokenSelector, |
||||
selectedTokenAddressSelector, |
||||
(tokens = [], selectedTokenAddress = '') => { |
||||
return tokens.find(({ address }) => address === selectedTokenAddress) |
||||
} |
||||
) |
Loading…
Reference in new issue