mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-11-22 09:57:02 +01:00
add confirm-encryption-public-key component to Storybook (#11364)
* confirm-encryption-public-key * lintfix * lintfix
This commit is contained in:
parent
284c03879e
commit
96b0730a89
@ -15,9 +15,9 @@ const state = {
|
|||||||
"isAccountMenuOpen": false,
|
"isAccountMenuOpen": false,
|
||||||
"rpcUrl": "https://rawtestrpc.metamask.io/",
|
"rpcUrl": "https://rawtestrpc.metamask.io/",
|
||||||
"identities": {
|
"identities": {
|
||||||
"0x983211ce699ea5ab57cc528086154b6db1ad8e55": {
|
"0x64a845a5b02460acf8a3d84503b0d68d028b4bb4": {
|
||||||
"name": "Account 1",
|
"name": "This is a Really Long Account Name",
|
||||||
"address": "0x983211ce699ea5ab57cc528086154b6db1ad8e55"
|
"address": "0x64a845a5b02460acf8a3d84503b0d68d028b4bb4"
|
||||||
},
|
},
|
||||||
"0xb19ac54efa18cc3a14a5b821bfec73d284bf0c5e": {
|
"0xb19ac54efa18cc3a14a5b821bfec73d284bf0c5e": {
|
||||||
"name": "Account 2",
|
"name": "Account 2",
|
||||||
@ -160,8 +160,8 @@ const state = {
|
|||||||
},
|
},
|
||||||
"network": "3",
|
"network": "3",
|
||||||
"accounts": {
|
"accounts": {
|
||||||
"0x983211ce699ea5ab57cc528086154b6db1ad8e55": {
|
"0x64a845a5b02460acf8a3d84503b0d68d028b4bb4": {
|
||||||
"address": "0x983211ce699ea5ab57cc528086154b6db1ad8e55",
|
"address": "0x64a845a5b02460acf8a3d84503b0d68d028b4bb4",
|
||||||
"balance": "0x176e5b6f173ebe66"
|
"balance": "0x176e5b6f173ebe66"
|
||||||
},
|
},
|
||||||
"0xb19ac54efa18cc3a14a5b821bfec73d284bf0c5e": {
|
"0xb19ac54efa18cc3a14a5b821bfec73d284bf0c5e": {
|
||||||
@ -200,7 +200,16 @@ const state = {
|
|||||||
"unapprovedPersonalMsgCount": 0,
|
"unapprovedPersonalMsgCount": 0,
|
||||||
"unapprovedDecryptMsgs": {},
|
"unapprovedDecryptMsgs": {},
|
||||||
"unapprovedDecryptMsgCount": 0,
|
"unapprovedDecryptMsgCount": 0,
|
||||||
"unapprovedEncryptionPublicKeyMsgs": {},
|
"unapprovedEncryptionPublicKeyMsgs": {
|
||||||
|
"7786962153682822": {
|
||||||
|
"id": 7786962153682822,
|
||||||
|
"msgParams": "0x64a845a5b02460acf8a3d84503b0d68d028b4bb4",
|
||||||
|
"time": 1622687544054,
|
||||||
|
"status": "unapproved",
|
||||||
|
"type": "eth_getEncryptionPublicKey",
|
||||||
|
"origin": "https://metamask.github.io"
|
||||||
|
}
|
||||||
|
},
|
||||||
"unapprovedEncryptionPublicKeyMsgCount": 0,
|
"unapprovedEncryptionPublicKeyMsgCount": 0,
|
||||||
"unapprovedTypedMessages": {},
|
"unapprovedTypedMessages": {},
|
||||||
"unapprovedTypedMessagesCount": 0,
|
"unapprovedTypedMessagesCount": 0,
|
||||||
|
@ -33,10 +33,6 @@ export default class ConfirmEncryptionPublicKey extends Component {
|
|||||||
nativeCurrency: PropTypes.string.isRequired,
|
nativeCurrency: PropTypes.string.isRequired,
|
||||||
};
|
};
|
||||||
|
|
||||||
state = {
|
|
||||||
fromAccount: this.props.fromAccount,
|
|
||||||
};
|
|
||||||
|
|
||||||
componentDidMount = () => {
|
componentDidMount = () => {
|
||||||
if (
|
if (
|
||||||
getEnvironmentType(window.location.href) === ENVIRONMENT_TYPE_NOTIFICATION
|
getEnvironmentType(window.location.href) === ENVIRONMENT_TYPE_NOTIFICATION
|
||||||
@ -92,7 +88,7 @@ export default class ConfirmEncryptionPublicKey extends Component {
|
|||||||
};
|
};
|
||||||
|
|
||||||
renderAccount = () => {
|
renderAccount = () => {
|
||||||
const { fromAccount } = this.state;
|
const { fromAccount } = this.props;
|
||||||
const { t } = this.context;
|
const { t } = this.context;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@ -109,11 +105,12 @@ export default class ConfirmEncryptionPublicKey extends Component {
|
|||||||
};
|
};
|
||||||
|
|
||||||
renderBalance = () => {
|
renderBalance = () => {
|
||||||
const { conversionRate, nativeCurrency } = this.props;
|
|
||||||
const { t } = this.context;
|
|
||||||
const {
|
const {
|
||||||
|
conversionRate,
|
||||||
|
nativeCurrency,
|
||||||
fromAccount: { balance },
|
fromAccount: { balance },
|
||||||
} = this.state;
|
} = this.props;
|
||||||
|
const { t } = this.context;
|
||||||
|
|
||||||
const nativeCurrencyBalance = conversionUtil(balance, {
|
const nativeCurrencyBalance = conversionUtil(balance, {
|
||||||
fromNumericBase: 'hex',
|
fromNumericBase: 'hex',
|
||||||
|
@ -0,0 +1,45 @@
|
|||||||
|
import React, { useEffect } from 'react';
|
||||||
|
import { select } from '@storybook/addon-knobs';
|
||||||
|
|
||||||
|
import { store } from '../../../.storybook/preview';
|
||||||
|
import { updateMetamaskState } from '../../store/actions';
|
||||||
|
import ConfirmEncryptionPublicKey from '.';
|
||||||
|
|
||||||
|
export default {
|
||||||
|
title: 'Confirmation Screens',
|
||||||
|
};
|
||||||
|
|
||||||
|
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(
|
||||||
|
updateMetamaskState({
|
||||||
|
unapprovedEncryptionPublicKeyMsgs,
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
}, [account, unapprovedEncryptionPublicKeyMsgs]);
|
||||||
|
|
||||||
|
return children;
|
||||||
|
};
|
||||||
|
|
||||||
|
export const ConfirmEncryption = () => {
|
||||||
|
store.dispatch(updateMetamaskState({ unapprovedTxs: {} }));
|
||||||
|
return (
|
||||||
|
<PageSet>
|
||||||
|
<ConfirmEncryptionPublicKey />
|
||||||
|
</PageSet>
|
||||||
|
);
|
||||||
|
};
|
Loading…
Reference in New Issue
Block a user