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 {
|
|
|
|
title: 'Confirmation Screens',
|
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;
|
|
|
|
};
|
|
|
|
|
|
|
|
export const ConfirmEncryption = () => {
|
|
|
|
return (
|
|
|
|
<PageSet>
|
|
|
|
<ConfirmEncryptionPublicKey />
|
|
|
|
</PageSet>
|
|
|
|
);
|
|
|
|
};
|