2021-08-17 07:33:46 +02:00
|
|
|
/* eslint-disable react/prop-types */
|
|
|
|
import React, { useEffect } from 'react';
|
|
|
|
import { text } from '@storybook/addon-knobs';
|
2021-09-08 01:51:41 +02:00
|
|
|
import { store, getNewState } from '../../../.storybook/preview';
|
2021-08-17 07:33:46 +02:00
|
|
|
import { suggestedTokens } from '../../../.storybook/initial-states/approval-screens/add-suggested-token';
|
|
|
|
import { updateMetamaskState } from '../../store/actions';
|
|
|
|
import ConfirmAddSuggestedToken from '.';
|
|
|
|
|
|
|
|
export default {
|
|
|
|
title: 'Confirmation Screens',
|
|
|
|
};
|
|
|
|
|
|
|
|
const PageSet = ({ children }) => {
|
|
|
|
const symbol = text('symbol', 'META');
|
|
|
|
const image = text('Icon URL', 'metamark.svg');
|
|
|
|
|
|
|
|
const state = store.getState();
|
|
|
|
const suggestedTokensState = state.metamask.suggestedTokens;
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
suggestedTokensState[
|
|
|
|
'0x6b175474e89094c44da98b954eedeac495271d0f'
|
|
|
|
].symbol = symbol;
|
|
|
|
store.dispatch(
|
2021-09-08 01:51:41 +02:00
|
|
|
updateMetamaskState(
|
|
|
|
getNewState(state.metamask, {
|
|
|
|
suggestedTokens: suggestedTokensState,
|
|
|
|
}),
|
|
|
|
),
|
2021-08-17 07:33:46 +02:00
|
|
|
);
|
2021-09-08 01:51:41 +02:00
|
|
|
}, [symbol, suggestedTokensState, state.metamask]);
|
2021-08-17 07:33:46 +02:00
|
|
|
useEffect(() => {
|
|
|
|
suggestedTokensState[
|
|
|
|
'0x6b175474e89094c44da98b954eedeac495271d0f'
|
|
|
|
].image = image;
|
|
|
|
store.dispatch(
|
2021-09-08 01:51:41 +02:00
|
|
|
updateMetamaskState(
|
|
|
|
getNewState(state.metamask, {
|
|
|
|
suggestedTokens: suggestedTokensState,
|
|
|
|
}),
|
|
|
|
),
|
2021-08-17 07:33:46 +02:00
|
|
|
);
|
2021-09-08 01:51:41 +02:00
|
|
|
}, [image, suggestedTokensState, state.metamask]);
|
2021-08-17 07:33:46 +02:00
|
|
|
|
|
|
|
return children;
|
|
|
|
};
|
|
|
|
|
|
|
|
export const AddSuggestedToken = () => {
|
2021-09-08 01:51:41 +02:00
|
|
|
const state = store.getState();
|
|
|
|
store.dispatch(
|
|
|
|
updateMetamaskState(
|
|
|
|
getNewState(state.metamask, {
|
|
|
|
suggestedTokens,
|
|
|
|
}),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
|
2021-08-17 07:33:46 +02:00
|
|
|
return (
|
|
|
|
<PageSet>
|
|
|
|
<ConfirmAddSuggestedToken />
|
|
|
|
</PageSet>
|
|
|
|
);
|
|
|
|
};
|