2021-08-17 07:33:46 +02:00
|
|
|
/* eslint-disable react/prop-types */
|
|
|
|
import React, { useEffect } from 'react';
|
|
|
|
|
|
|
|
import { createBrowserHistory } from 'history';
|
|
|
|
import { text } from '@storybook/addon-knobs';
|
2021-10-04 15:46:18 +02:00
|
|
|
import { store, getNewState } from '../../../.storybook/preview';
|
2021-08-17 07:33:46 +02:00
|
|
|
import { tokens } from '../../../.storybook/initial-states/approval-screens/add-token';
|
|
|
|
import { updateMetamaskState } from '../../store/actions';
|
|
|
|
import ConfirmAddToken from '.';
|
|
|
|
|
|
|
|
export default {
|
|
|
|
title: 'Confirmation Screens',
|
2021-09-15 20:55:48 +02:00
|
|
|
id: __filename,
|
2021-08-17 07:33:46 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
const history = createBrowserHistory();
|
|
|
|
|
|
|
|
const PageSet = ({ children }) => {
|
|
|
|
const symbol = text('symbol', 'TRDT');
|
|
|
|
const state = store.getState();
|
|
|
|
const pendingTokensState = state.metamask.pendingTokens;
|
|
|
|
// only change the first token in the list
|
|
|
|
useEffect(() => {
|
2021-09-10 22:21:04 +02:00
|
|
|
const pendingTokens = { ...pendingTokensState };
|
|
|
|
pendingTokens['0x33f90dee07c6e8b9682dd20f73e6c358b2ed0f03'].symbol = symbol;
|
2021-10-04 15:46:18 +02:00
|
|
|
store.dispatch(
|
|
|
|
updateMetamaskState(
|
|
|
|
getNewState(state.metamask, {
|
|
|
|
pendingTokens,
|
|
|
|
}),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}, [symbol, pendingTokensState, state.metamask]);
|
2021-08-17 07:33:46 +02:00
|
|
|
|
|
|
|
return children;
|
|
|
|
};
|
|
|
|
|
|
|
|
export const AddToken = () => {
|
2021-10-04 15:46:18 +02:00
|
|
|
const { metamask: state } = store.getState();
|
|
|
|
store.dispatch(
|
|
|
|
updateMetamaskState(
|
|
|
|
getNewState(state, {
|
|
|
|
pendingTokens: tokens,
|
|
|
|
}),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
|
2021-08-17 07:33:46 +02:00
|
|
|
return (
|
|
|
|
<PageSet>
|
|
|
|
<ConfirmAddToken history={history} />
|
|
|
|
</PageSet>
|
|
|
|
);
|
|
|
|
};
|