mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-11-22 09:57:02 +01:00
fix(17857): show correctly converted account balance in sign&encrypt windows (#17973)
Co-authored-by: Dan J Miller <danjm.com@gmail.com>
This commit is contained in:
parent
5018329cd8
commit
47d9964a89
@ -193,7 +193,7 @@
|
|||||||
"selectedAddress": "0x0dcd5d886577d5081b0c52e242ef29e70be3e7bc",
|
"selectedAddress": "0x0dcd5d886577d5081b0c52e242ef29e70be3e7bc",
|
||||||
"accounts": {
|
"accounts": {
|
||||||
"0x0dcd5d886577d5081b0c52e242ef29e70be3e7bc": {
|
"0x0dcd5d886577d5081b0c52e242ef29e70be3e7bc": {
|
||||||
"balance": "0x0",
|
"balance": "0x346ba7725f412cbfdb",
|
||||||
"address": "0x0dcd5d886577d5081b0c52e242ef29e70be3e7bc"
|
"address": "0x0dcd5d886577d5081b0c52e242ef29e70be3e7bc"
|
||||||
},
|
},
|
||||||
"0xec1adf982415d2ef5ec55899b9bfb8bc0f29251b": {
|
"0xec1adf982415d2ef5ec55899b9bfb8bc0f29251b": {
|
||||||
|
@ -30,7 +30,7 @@ describe('Encrypt Decrypt', function () {
|
|||||||
await driver.press('#password', driver.Key.ENTER);
|
await driver.press('#password', driver.Key.ENTER);
|
||||||
await driver.openNewPage('http://127.0.0.1:8080');
|
await driver.openNewPage('http://127.0.0.1:8080');
|
||||||
|
|
||||||
// Get Encryption key
|
// ------ Get Encryption key ------
|
||||||
await driver.clickElement('#getEncryptionKeyButton');
|
await driver.clickElement('#getEncryptionKeyButton');
|
||||||
await driver.waitUntilXWindowHandles(3);
|
await driver.waitUntilXWindowHandles(3);
|
||||||
let windowHandles = await driver.getAllWindowHandles();
|
let windowHandles = await driver.getAllWindowHandles();
|
||||||
@ -42,6 +42,11 @@ describe('Encrypt Decrypt', function () {
|
|||||||
css: '.request-encryption-public-key__header__text',
|
css: '.request-encryption-public-key__header__text',
|
||||||
text: 'Request encryption public key',
|
text: 'Request encryption public key',
|
||||||
});
|
});
|
||||||
|
// Account balance is converted properly
|
||||||
|
const accountBalanceLabel = await driver.findElement(
|
||||||
|
'.request-encryption-public-key__balance-value',
|
||||||
|
);
|
||||||
|
assert.equal(await accountBalanceLabel.getText(), '25 ETH');
|
||||||
await driver.clickElement({ text: 'Provide', tag: 'button' });
|
await driver.clickElement({ text: 'Provide', tag: 'button' });
|
||||||
await driver.waitUntilXWindowHandles(2);
|
await driver.waitUntilXWindowHandles(2);
|
||||||
windowHandles = await driver.getAllWindowHandles();
|
windowHandles = await driver.getAllWindowHandles();
|
||||||
@ -51,7 +56,7 @@ describe('Encrypt Decrypt', function () {
|
|||||||
);
|
);
|
||||||
assert.equal(await encryptionKeyLabel.getText(), encryptionKey);
|
assert.equal(await encryptionKeyLabel.getText(), encryptionKey);
|
||||||
|
|
||||||
// Encrypt
|
// ------ Encrypt ------
|
||||||
await driver.fill('#encryptMessageInput', message);
|
await driver.fill('#encryptMessageInput', message);
|
||||||
await driver.clickElement('#encryptButton');
|
await driver.clickElement('#encryptButton');
|
||||||
await driver.waitForSelector({
|
await driver.waitForSelector({
|
||||||
@ -59,7 +64,7 @@ describe('Encrypt Decrypt', function () {
|
|||||||
text: '0x',
|
text: '0x',
|
||||||
});
|
});
|
||||||
|
|
||||||
// Decrypt
|
// ------ Decrypt ------
|
||||||
await driver.clickElement('#decryptButton');
|
await driver.clickElement('#decryptButton');
|
||||||
await driver.waitUntilXWindowHandles(3);
|
await driver.waitUntilXWindowHandles(3);
|
||||||
windowHandles = await driver.getAllWindowHandles();
|
windowHandles = await driver.getAllWindowHandles();
|
||||||
@ -71,7 +76,11 @@ describe('Encrypt Decrypt', function () {
|
|||||||
css: '.request-decrypt-message__header__text',
|
css: '.request-decrypt-message__header__text',
|
||||||
text: 'Decrypt request',
|
text: 'Decrypt request',
|
||||||
});
|
});
|
||||||
|
// Account balance is converted properly
|
||||||
|
const decryptAccountBalanceLabel = await driver.findElement(
|
||||||
|
'.request-decrypt-message__balance-value',
|
||||||
|
);
|
||||||
|
assert.equal(await decryptAccountBalanceLabel.getText(), '25 ETH');
|
||||||
// Verify message in MetaMask Notification
|
// Verify message in MetaMask Notification
|
||||||
await driver.clickElement({ text: 'Decrypt message', tag: 'div' });
|
await driver.clickElement({ text: 'Decrypt message', tag: 'div' });
|
||||||
const notificationMessage = await driver.isElementPresent({
|
const notificationMessage = await driver.isElementPresent({
|
||||||
|
@ -167,7 +167,7 @@ exports[`SignatureRequestOriginal should match snapshot 1`] = `
|
|||||||
<h6
|
<h6
|
||||||
class="box box--margin-bottom-1 box--flex-direction-row typography typography--h6 typography--weight-bold typography--style-normal typography--align-end typography--color-text-default"
|
class="box box--margin-bottom-1 box--flex-direction-row typography typography--h6 typography--weight-bold typography--style-normal typography--align-end typography--color-text-default"
|
||||||
>
|
>
|
||||||
0
|
966.987986
|
||||||
|
|
||||||
ETH
|
ETH
|
||||||
</h6>
|
</h6>
|
||||||
|
@ -62,7 +62,6 @@ export default class SignatureRequest extends PureComponent {
|
|||||||
* RPC prefs of the current network
|
* RPC prefs of the current network
|
||||||
*/
|
*/
|
||||||
rpcPrefs: PropTypes.object,
|
rpcPrefs: PropTypes.object,
|
||||||
conversionRate: PropTypes.number,
|
|
||||||
nativeCurrency: PropTypes.string,
|
nativeCurrency: PropTypes.string,
|
||||||
currentCurrency: PropTypes.string.isRequired,
|
currentCurrency: PropTypes.string.isRequired,
|
||||||
useNativeCurrencyAsPrimaryCurrency: PropTypes.bool.isRequired,
|
useNativeCurrencyAsPrimaryCurrency: PropTypes.bool.isRequired,
|
||||||
@ -157,7 +156,6 @@ export default class SignatureRequest extends PureComponent {
|
|||||||
rpcPrefs,
|
rpcPrefs,
|
||||||
txData,
|
txData,
|
||||||
subjectMetadata,
|
subjectMetadata,
|
||||||
conversionRate,
|
|
||||||
nativeCurrency,
|
nativeCurrency,
|
||||||
currentCurrency,
|
currentCurrency,
|
||||||
useNativeCurrencyAsPrimaryCurrency,
|
useNativeCurrencyAsPrimaryCurrency,
|
||||||
@ -177,7 +175,6 @@ export default class SignatureRequest extends PureComponent {
|
|||||||
|
|
||||||
const balanceInBaseAsset = new Numeric(balance, 16, EtherDenomination.WEI)
|
const balanceInBaseAsset = new Numeric(balance, 16, EtherDenomination.WEI)
|
||||||
.toDenomination(EtherDenomination.ETH)
|
.toDenomination(EtherDenomination.ETH)
|
||||||
.applyConversionRate(conversionRate)
|
|
||||||
.round(6)
|
.round(6)
|
||||||
.toBase(10)
|
.toBase(10)
|
||||||
.toString();
|
.toString();
|
||||||
|
@ -4,7 +4,6 @@ import {
|
|||||||
doesAddressRequireLedgerHidConnection,
|
doesAddressRequireLedgerHidConnection,
|
||||||
getCurrentChainId,
|
getCurrentChainId,
|
||||||
getRpcPrefsForCurrentProvider,
|
getRpcPrefsForCurrentProvider,
|
||||||
conversionRateSelector,
|
|
||||||
getSubjectMetadata,
|
getSubjectMetadata,
|
||||||
unconfirmedMessagesHashSelector,
|
unconfirmedMessagesHashSelector,
|
||||||
getTotalUnapprovedMessagesCount,
|
getTotalUnapprovedMessagesCount,
|
||||||
@ -47,7 +46,6 @@ function mapStateToProps(state, ownProps) {
|
|||||||
unconfirmedMessagesList,
|
unconfirmedMessagesList,
|
||||||
unapprovedMessagesCount,
|
unapprovedMessagesCount,
|
||||||
mostRecentOverviewPage: getMostRecentOverviewPage(state),
|
mostRecentOverviewPage: getMostRecentOverviewPage(state),
|
||||||
conversionRate: conversionRateSelector(state),
|
|
||||||
nativeCurrency: getNativeCurrency(state),
|
nativeCurrency: getNativeCurrency(state),
|
||||||
currentCurrency: getCurrentCurrency(state),
|
currentCurrency: getCurrentCurrency(state),
|
||||||
useNativeCurrencyAsPrimaryCurrency,
|
useNativeCurrencyAsPrimaryCurrency,
|
||||||
@ -85,7 +83,6 @@ function mergeProps(stateProps, dispatchProps, ownProps) {
|
|||||||
hardwareWalletRequiresConnection,
|
hardwareWalletRequiresConnection,
|
||||||
chainId,
|
chainId,
|
||||||
rpcPrefs,
|
rpcPrefs,
|
||||||
conversionRate,
|
|
||||||
nativeCurrency,
|
nativeCurrency,
|
||||||
currentCurrency,
|
currentCurrency,
|
||||||
useNativeCurrencyAsPrimaryCurrency,
|
useNativeCurrencyAsPrimaryCurrency,
|
||||||
@ -139,7 +136,6 @@ function mergeProps(stateProps, dispatchProps, ownProps) {
|
|||||||
hardwareWalletRequiresConnection,
|
hardwareWalletRequiresConnection,
|
||||||
chainId,
|
chainId,
|
||||||
rpcPrefs,
|
rpcPrefs,
|
||||||
conversionRate,
|
|
||||||
nativeCurrency,
|
nativeCurrency,
|
||||||
currentCurrency,
|
currentCurrency,
|
||||||
useNativeCurrencyAsPrimaryCurrency,
|
useNativeCurrencyAsPrimaryCurrency,
|
||||||
|
@ -32,7 +32,6 @@ export default class ConfirmDecryptMessage extends Component {
|
|||||||
cancelDecryptMessage: PropTypes.func.isRequired,
|
cancelDecryptMessage: PropTypes.func.isRequired,
|
||||||
decryptMessage: PropTypes.func.isRequired,
|
decryptMessage: PropTypes.func.isRequired,
|
||||||
decryptMessageInline: PropTypes.func.isRequired,
|
decryptMessageInline: PropTypes.func.isRequired,
|
||||||
conversionRate: PropTypes.number,
|
|
||||||
history: PropTypes.object.isRequired,
|
history: PropTypes.object.isRequired,
|
||||||
mostRecentOverviewPage: PropTypes.string.isRequired,
|
mostRecentOverviewPage: PropTypes.string.isRequired,
|
||||||
requesterAddress: PropTypes.string,
|
requesterAddress: PropTypes.string,
|
||||||
@ -95,7 +94,7 @@ export default class ConfirmDecryptMessage extends Component {
|
|||||||
};
|
};
|
||||||
|
|
||||||
renderBalance = () => {
|
renderBalance = () => {
|
||||||
const { conversionRate, nativeCurrency } = this.props;
|
const { nativeCurrency } = this.props;
|
||||||
const {
|
const {
|
||||||
fromAccount: { balance },
|
fromAccount: { balance },
|
||||||
} = this.state;
|
} = this.state;
|
||||||
@ -106,7 +105,7 @@ export default class ConfirmDecryptMessage extends Component {
|
|||||||
16,
|
16,
|
||||||
EtherDenomination.WEI,
|
EtherDenomination.WEI,
|
||||||
)
|
)
|
||||||
.applyConversionRate(conversionRate)
|
.toDenomination(EtherDenomination.ETH)
|
||||||
.round(6)
|
.round(6)
|
||||||
.toBase(10);
|
.toBase(10);
|
||||||
|
|
||||||
|
@ -12,7 +12,6 @@ import {
|
|||||||
import {
|
import {
|
||||||
getTargetAccountWithSendEtherInfo,
|
getTargetAccountWithSendEtherInfo,
|
||||||
unconfirmedTransactionsListSelector,
|
unconfirmedTransactionsListSelector,
|
||||||
conversionRateSelector,
|
|
||||||
} from '../../selectors';
|
} from '../../selectors';
|
||||||
import { clearConfirmTransaction } from '../../ducks/confirm-transaction/confirm-transaction.duck';
|
import { clearConfirmTransaction } from '../../ducks/confirm-transaction/confirm-transaction.duck';
|
||||||
import { getMostRecentOverviewPage } from '../../ducks/history/history';
|
import { getMostRecentOverviewPage } from '../../ducks/history/history';
|
||||||
@ -39,7 +38,6 @@ function mapStateToProps(state) {
|
|||||||
fromAccount,
|
fromAccount,
|
||||||
requester: null,
|
requester: null,
|
||||||
requesterAddress: null,
|
requesterAddress: null,
|
||||||
conversionRate: conversionRateSelector(state),
|
|
||||||
mostRecentOverviewPage: getMostRecentOverviewPage(state),
|
mostRecentOverviewPage: getMostRecentOverviewPage(state),
|
||||||
nativeCurrency: getNativeCurrency(state),
|
nativeCurrency: getNativeCurrency(state),
|
||||||
};
|
};
|
||||||
|
@ -26,7 +26,6 @@ export default class ConfirmEncryptionPublicKey extends Component {
|
|||||||
clearConfirmTransaction: PropTypes.func.isRequired,
|
clearConfirmTransaction: PropTypes.func.isRequired,
|
||||||
cancelEncryptionPublicKey: PropTypes.func.isRequired,
|
cancelEncryptionPublicKey: PropTypes.func.isRequired,
|
||||||
encryptionPublicKey: PropTypes.func.isRequired,
|
encryptionPublicKey: PropTypes.func.isRequired,
|
||||||
conversionRate: PropTypes.number,
|
|
||||||
history: PropTypes.object.isRequired,
|
history: PropTypes.object.isRequired,
|
||||||
requesterAddress: PropTypes.string,
|
requesterAddress: PropTypes.string,
|
||||||
txData: PropTypes.object,
|
txData: PropTypes.object,
|
||||||
@ -70,7 +69,6 @@ export default class ConfirmEncryptionPublicKey extends Component {
|
|||||||
|
|
||||||
renderBalance = () => {
|
renderBalance = () => {
|
||||||
const {
|
const {
|
||||||
conversionRate,
|
|
||||||
nativeCurrency,
|
nativeCurrency,
|
||||||
fromAccount: { balance },
|
fromAccount: { balance },
|
||||||
} = this.props;
|
} = this.props;
|
||||||
@ -81,7 +79,7 @@ export default class ConfirmEncryptionPublicKey extends Component {
|
|||||||
16,
|
16,
|
||||||
EtherDenomination.WEI,
|
EtherDenomination.WEI,
|
||||||
)
|
)
|
||||||
.applyConversionRate(conversionRate)
|
.toDenomination(EtherDenomination.ETH)
|
||||||
.round(6)
|
.round(6)
|
||||||
.toBase(10);
|
.toBase(10);
|
||||||
|
|
||||||
|
@ -9,7 +9,6 @@ import {
|
|||||||
} from '../../store/actions';
|
} from '../../store/actions';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
conversionRateSelector,
|
|
||||||
unconfirmedTransactionsListSelector,
|
unconfirmedTransactionsListSelector,
|
||||||
getTargetAccountWithSendEtherInfo,
|
getTargetAccountWithSendEtherInfo,
|
||||||
} from '../../selectors';
|
} from '../../selectors';
|
||||||
@ -39,7 +38,6 @@ function mapStateToProps(state) {
|
|||||||
fromAccount,
|
fromAccount,
|
||||||
requester: null,
|
requester: null,
|
||||||
requesterAddress: null,
|
requesterAddress: null,
|
||||||
conversionRate: conversionRateSelector(state),
|
|
||||||
mostRecentOverviewPage: getMostRecentOverviewPage(state),
|
mostRecentOverviewPage: getMostRecentOverviewPage(state),
|
||||||
nativeCurrency: getNativeCurrency(state),
|
nativeCurrency: getNativeCurrency(state),
|
||||||
};
|
};
|
||||||
|
@ -28,11 +28,6 @@ export default {
|
|||||||
encryptionPublicKey: {
|
encryptionPublicKey: {
|
||||||
action: 'encryptionPublicKey',
|
action: 'encryptionPublicKey',
|
||||||
},
|
},
|
||||||
conversionRate: {
|
|
||||||
control: {
|
|
||||||
type: 'number',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
history: {
|
history: {
|
||||||
control: {
|
control: {
|
||||||
type: 'object',
|
type: 'object',
|
||||||
@ -66,7 +61,6 @@ export default {
|
|||||||
},
|
},
|
||||||
args: {
|
args: {
|
||||||
fromAccount: metamask.accountArray[0],
|
fromAccount: metamask.accountArray[0],
|
||||||
conversionRate: metamask.conversionRate,
|
|
||||||
history: {
|
history: {
|
||||||
push: action('history.push()'),
|
push: action('history.push()'),
|
||||||
},
|
},
|
||||||
|
@ -63,7 +63,7 @@ describe('Selectors', () => {
|
|||||||
|
|
||||||
it('returns selected account', () => {
|
it('returns selected account', () => {
|
||||||
const account = selectors.getSelectedAccount(mockState);
|
const account = selectors.getSelectedAccount(mockState);
|
||||||
expect(account.balance).toStrictEqual('0x0');
|
expect(account.balance).toStrictEqual('0x346ba7725f412cbfdb');
|
||||||
expect(account.address).toStrictEqual(
|
expect(account.address).toStrictEqual(
|
||||||
'0x0dcd5d886577d5081b0c52e242ef29e70be3e7bc',
|
'0x0dcd5d886577d5081b0c52e242ef29e70be3e7bc',
|
||||||
);
|
);
|
||||||
@ -138,7 +138,9 @@ describe('Selectors', () => {
|
|||||||
const accountsWithSendEther =
|
const accountsWithSendEther =
|
||||||
selectors.accountsWithSendEtherInfoSelector(mockState);
|
selectors.accountsWithSendEtherInfoSelector(mockState);
|
||||||
expect(accountsWithSendEther).toHaveLength(4);
|
expect(accountsWithSendEther).toHaveLength(4);
|
||||||
expect(accountsWithSendEther[0].balance).toStrictEqual('0x0');
|
expect(accountsWithSendEther[0].balance).toStrictEqual(
|
||||||
|
'0x346ba7725f412cbfdb',
|
||||||
|
);
|
||||||
expect(accountsWithSendEther[0].address).toStrictEqual(
|
expect(accountsWithSendEther[0].address).toStrictEqual(
|
||||||
'0x0dcd5d886577d5081b0c52e242ef29e70be3e7bc',
|
'0x0dcd5d886577d5081b0c52e242ef29e70be3e7bc',
|
||||||
);
|
);
|
||||||
@ -148,7 +150,9 @@ describe('Selectors', () => {
|
|||||||
it('returns selected account with balance, address, and name from accountsWithSendEtherInfoSelector', () => {
|
it('returns selected account with balance, address, and name from accountsWithSendEtherInfoSelector', () => {
|
||||||
const currentAccountwithSendEther =
|
const currentAccountwithSendEther =
|
||||||
selectors.getCurrentAccountWithSendEtherInfo(mockState);
|
selectors.getCurrentAccountWithSendEtherInfo(mockState);
|
||||||
expect(currentAccountwithSendEther.balance).toStrictEqual('0x0');
|
expect(currentAccountwithSendEther.balance).toStrictEqual(
|
||||||
|
'0x346ba7725f412cbfdb',
|
||||||
|
);
|
||||||
expect(currentAccountwithSendEther.address).toStrictEqual(
|
expect(currentAccountwithSendEther.address).toStrictEqual(
|
||||||
'0x0dcd5d886577d5081b0c52e242ef29e70be3e7bc',
|
'0x0dcd5d886577d5081b0c52e242ef29e70be3e7bc',
|
||||||
);
|
);
|
||||||
|
Loading…
Reference in New Issue
Block a user