2021-07-20 18:29:38 +02:00
|
|
|
import React, { useEffect } from 'react';
|
|
|
|
import { select } from '@storybook/addon-knobs';
|
|
|
|
|
2021-09-08 01:51:41 +02:00
|
|
|
import { store, getNewState } from '../../../.storybook/preview';
|
2021-07-20 18:29:38 +02:00
|
|
|
import { updateMetamaskState } from '../../store/actions';
|
|
|
|
import ConfirmEncryptionPublicKey from '.';
|
|
|
|
|
|
|
|
export default {
|
2021-12-01 20:27:57 +01:00
|
|
|
title: 'Pages/ConfirmEncryptionPublicKey',
|
2021-09-15 20:55:48 +02:00
|
|
|
id: __filename,
|
2021-07-20 18:29:38 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
const PageSet = ({ children }) => {
|
|
|
|
const state = store.getState();
|
|
|
|
const options = [];
|
|
|
|
const { identities, unapprovedEncryptionPublicKeyMsgs } = state.metamask;
|
|
|
|
Object.keys(identities).forEach(function (key) {
|
|
|
|
options.push({
|
|
|
|
label: identities[key].name,
|
|
|
|
name: identities[key].name,
|
|
|
|
address: key,
|
|
|
|
});
|
|
|
|
});
|
|
|
|
const account = select('Account', options, options[0]);
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
unapprovedEncryptionPublicKeyMsgs['7786962153682822'].msgParams =
|
|
|
|
account.address;
|
|
|
|
store.dispatch(
|
2021-09-08 01:51:41 +02:00
|
|
|
updateMetamaskState(
|
|
|
|
getNewState(state.metamask, {
|
|
|
|
unapprovedEncryptionPublicKeyMsgs,
|
|
|
|
}),
|
|
|
|
),
|
2021-07-20 18:29:38 +02:00
|
|
|
);
|
2021-09-08 01:51:41 +02:00
|
|
|
}, [account, unapprovedEncryptionPublicKeyMsgs, state.metamask]);
|
2021-07-20 18:29:38 +02:00
|
|
|
|
|
|
|
return children;
|
|
|
|
};
|
|
|
|
|
2021-12-01 20:27:57 +01:00
|
|
|
export const DefaultStory = () => {
|
2021-07-20 18:29:38 +02:00
|
|
|
return (
|
|
|
|
<PageSet>
|
|
|
|
<ConfirmEncryptionPublicKey />
|
|
|
|
</PageSet>
|
|
|
|
);
|
|
|
|
};
|
2021-12-01 20:27:57 +01:00
|
|
|
|
|
|
|
DefaultStory.storyName = 'Default';
|