Fixing confirm-add-suggested-token storybook entry (#12261)

feature/default_network_editable
ryanml 3 years ago committed by GitHub
parent 9355fb21c7
commit c14f46eb92
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 148
      .storybook/initial-states/approval-screens/add-suggested-token.js
  2. 2
      .storybook/test-data.js
  3. 22
      ui/pages/confirm-add-suggested-token/confirm-add-suggested-token.stories.js

@ -1,65 +1,83 @@
export const suggestedTokens = { export const suggestedAssets = [
"0x6b175474e89094c44da98b954eedeac495271d0f": { {
"address": "0x6b175474e89094c44da98b954eedeac495271d0f", asset: {
"symbol": "META", address: '0x6b175474e89094c44da98b954eedeac495271d0f',
"decimals": 18, symbol: 'META',
"image": "metamark.svg", decimals: 18,
"unlisted": false image: 'metamark.svg',
}, unlisted: false
"0xB8c77482e45F1F44dE1745F52C74426C631bDD52": { },
"address": "0xB8c77482e45F1F44dE1745F52C74426C631bDD52", },
"symbol": "0X", {
"decimals": 18, asset: {
"image": "0x.svg", 'address': '0xB8c77482e45F1F44dE1745F52C74426C631bDD52',
"unlisted": false 'symbol': '0X',
}, 'decimals': 18,
"0x1f9840a85d5af5bf1d1762f925bdaddc4201f984": { 'image': '0x.svg',
"address": "0x1f9840a85d5af5bf1d1762f925bdaddc4201f984", 'unlisted': false
"symbol": "AST", },
"decimals": 18, },
"image": "ast.png", {
"unlisted": false asset: {
}, 'address': '0x1f9840a85d5af5bf1d1762f925bdaddc4201f984',
"0x9f8f72aa9304c8b593d555f12ef6589cc3a579a2": { 'symbol': 'AST',
"address": "0x9f8f72aa9304c8b593d555f12ef6589cc3a579a2", 'decimals': 18,
"symbol": "BAT", 'image': 'ast.png',
"decimals": 18, 'unlisted': false
"image": "BAT_icon.svg", },
"unlisted": false },
}, {
"0xe83cccfabd4ed148903bf36d4283ee7c8b3494d1": { asset: {
"address": "0xe83cccfabd4ed148903bf36d4283ee7c8b3494d1", 'address': '0x9f8f72aa9304c8b593d555f12ef6589cc3a579a2',
"symbol": "CVL", 'symbol': 'BAT',
"decimals": 18, 'decimals': 18,
"image": "CVL_token.svg", 'image': 'BAT_icon.svg',
"unlisted": false 'unlisted': false
}, },
"0x0bc529c00C6401aEF6D220BE8C6Ea1667F6Ad93e": { },
"address": "0x0bc529c00C6401aEF6D220BE8C6Ea1667F6Ad93e", {
"symbol": "GLA", asset: {
"decimals": 18, 'address': '0xe83cccfabd4ed148903bf36d4283ee7c8b3494d1',
"image": "gladius.svg", 'symbol': 'CVL',
"unlisted": false 'decimals': 18,
}, 'image': 'CVL_token.svg',
"0x467Bccd9d29f223BcE8043b84E8C8B282827790F": { 'unlisted': false
"address": "0x467Bccd9d29f223BcE8043b84E8C8B282827790F", },
"symbol": "GNO", },
"decimals": 18, {
"image": "gnosis.svg", asset: {
"unlisted": false 'address': '0x0bc529c00C6401aEF6D220BE8C6Ea1667F6Ad93e',
}, 'symbol': 'GLA',
"0xff20817765cb7f73d4bde2e66e067e58d11095c2": { 'decimals': 18,
"address": "0xff20817765cb7f73d4bde2e66e067e58d11095c2", 'image': 'gladius.svg',
"symbol": "OMG", 'unlisted': false
"decimals": 18, },
"image": "omg.jpg", },
"unlisted": false {
}, asset: {
"0x8e870d67f660d95d5be530380d0ec0bd388289e1": { 'address': '0x467Bccd9d29f223BcE8043b84E8C8B282827790F',
"address": "0x8e870d67f660d95d5be530380d0ec0bd388289e1", 'symbol': 'GNO',
"symbol": "WED", 'decimals': 18,
"decimals": 18, 'image': 'gnosis.svg',
"image": "wed.png", 'unlisted': false
"unlisted": false },
}, },
} {
asset: {
'address': '0xff20817765cb7f73d4bde2e66e067e58d11095c2',
'symbol': 'OMG',
'decimals': 18,
'image': 'omg.jpg',
'unlisted': false
},
},
{
asset: {
'address': '0x8e870d67f660d95d5be530380d0ec0bd388289e1',
'symbol': 'WED',
'decimals': 18,
'image': 'wed.png',
'unlisted': false
},
},
]

@ -816,7 +816,7 @@ const state = {
'0xaD6D458402F60fD3Bd25163575031ACDce07538D': './sai.svg', '0xaD6D458402F60fD3Bd25163575031ACDce07538D': './sai.svg',
}, },
hiddenTokens: [], hiddenTokens: [],
suggestedTokens: {}, suggestedAssets: {},
useNonceField: false, useNonceField: false,
usePhishDetect: true, usePhishDetect: true,
lostIdentities: {}, lostIdentities: {},

@ -2,7 +2,7 @@
import React, { useEffect } from 'react'; import React, { useEffect } from 'react';
import { text } from '@storybook/addon-knobs'; import { text } from '@storybook/addon-knobs';
import { store, getNewState } from '../../../.storybook/preview'; import { store, getNewState } from '../../../.storybook/preview';
import { suggestedTokens } from '../../../.storybook/initial-states/approval-screens/add-suggested-token'; import { suggestedAssets } from '../../../.storybook/initial-states/approval-screens/add-suggested-token';
import { updateMetamaskState } from '../../store/actions'; import { updateMetamaskState } from '../../store/actions';
import ConfirmAddSuggestedToken from '.'; import ConfirmAddSuggestedToken from '.';
@ -16,32 +16,28 @@ const PageSet = ({ children }) => {
const image = text('Icon URL', 'metamark.svg'); const image = text('Icon URL', 'metamark.svg');
const state = store.getState(); const state = store.getState();
const suggestedTokensState = state.metamask.suggestedTokens; const suggestedAssetsState = state.metamask.suggestedAssets;
useEffect(() => { useEffect(() => {
suggestedTokensState[ suggestedAssetsState[0].symbol = symbol;
'0x6b175474e89094c44da98b954eedeac495271d0f'
].symbol = symbol;
store.dispatch( store.dispatch(
updateMetamaskState( updateMetamaskState(
getNewState(state.metamask, { getNewState(state.metamask, {
suggestedTokens: suggestedTokensState, suggestedAssets: suggestedAssetsState,
}), }),
), ),
); );
}, [symbol, suggestedTokensState, state.metamask]); }, [symbol, suggestedAssetsState, state.metamask]);
useEffect(() => { useEffect(() => {
suggestedTokensState[ suggestedAssetsState[0].image = image;
'0x6b175474e89094c44da98b954eedeac495271d0f'
].image = image;
store.dispatch( store.dispatch(
updateMetamaskState( updateMetamaskState(
getNewState(state.metamask, { getNewState(state.metamask, {
suggestedTokens: suggestedTokensState, suggestedAssets: suggestedAssetsState,
}), }),
), ),
); );
}, [image, suggestedTokensState, state.metamask]); }, [image, suggestedAssetsState, state.metamask]);
return children; return children;
}; };
@ -51,7 +47,7 @@ export const AddSuggestedToken = () => {
store.dispatch( store.dispatch(
updateMetamaskState( updateMetamaskState(
getNewState(state.metamask, { getNewState(state.metamask, {
suggestedTokens, suggestedAssets,
}), }),
), ),
); );

Loading…
Cancel
Save