1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-23 09:52:26 +01:00

Merge branch 'develop' into feature/17670-cancel-speedup-popover

This commit is contained in:
George Marshall 2023-06-01 08:31:46 -07:00 committed by GitHub
commit bc03fb39cf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 71 additions and 44 deletions

View File

@ -4,13 +4,14 @@ codecov:
coverage:
round: nearest
status:
project:
global:
target: auto
threshold: 0%
base: auto
transforms:
target: 100%
threshold: 0%
paths:
- development/build/transforms/**/*.js
project: off
patch: off
# global:
# target: auto
# threshold: 0%
# base: auto
# transforms:
# target: 100%
# threshold: 0%
# paths:
# - development/build/transforms/**/*.js

View File

@ -6,10 +6,29 @@ const reports = require('istanbul-reports');
const glob = require('fast-glob');
const yargs = require('yargs/yargs');
const { hideBin } = require('yargs/helpers');
const yaml = require('js-yaml');
// Temporarily commented out as we can't rely on the commented yaml file
// Can be restored when the codecov checks are restored
// const yaml = require('js-yaml');
const codecovTargets = require('../coverage-targets');
const codecovConfig = yaml.load(fs.readFileSync('codecov.yml', 'utf8'));
// Temporarily commented out as we can't rely on the commented yaml file
// Can be restored when the codecov checks are restored. In the meantime
// the important parts of the yaml file are copied below in normal js object
// format.
// const codecovConfig = yaml.load(fs.readFileSync('codecov.yml', 'utf8'));
const codecovConfig = {
coverage: {
status: {
global: {},
project: {
transforms: {
paths: ['development/build/transforms/**/*.js'],
},
},
},
},
};
const COVERAGE_DIR = './coverage/';

View File

@ -23,7 +23,7 @@ const ConfirmPageContainerNavigation = () => {
const unapprovedEncryptionPublicKeyMsgs = useSelector(
unapprovedEncryptionPublicKeyMsgsSelector,
);
const uncofirmedTransactions = useSelector(
const unconfirmedTransactions = useSelector(
unconfirmedTransactionsHashSelector,
);
@ -36,7 +36,7 @@ const ConfirmPageContainerNavigation = () => {
...enumUnapprovedEncryptMsgsKey,
];
const enumUnapprovedTxs = Object.keys(uncofirmedTransactions).filter(
const enumUnapprovedTxs = Object.keys(unconfirmedTransactions).filter(
(key) => enumDecryptAndEncryptMsgs.includes(key) === false,
);
@ -54,7 +54,7 @@ const ConfirmPageContainerNavigation = () => {
if (txId) {
dispatch(clearConfirmTransaction());
history.push(
uncofirmedTransactions[txId]?.msgParams
unconfirmedTransactions[txId]?.msgParams
? `${CONFIRM_TRANSACTION_ROUTE}/${txId}${SIGNATURE_REQUEST_PATH}`
: `${CONFIRM_TRANSACTION_ROUTE}/${txId}`,
);

View File

@ -5,15 +5,21 @@ describe('txHelper', () => {
it('always shows the oldest tx first', () => {
const metamaskNetworkId = NETWORK_IDS.MAINNET;
const chainId = CHAIN_IDS.MAINNET;
const txs = {
const mockUnapprovedTxs = {
a: { metamaskNetworkId, time: 3 },
b: { metamaskNetworkId, time: 1 },
b: { metamaskNetworkId, time: 6 },
c: { metamaskNetworkId, time: 2 },
};
const mockUnapprovedMsgs = {
d: { metamaskNetworkId, time: 4 },
e: { metamaskNetworkId, time: 1 },
f: { metamaskNetworkId, time: 5 },
};
const sorted = txHelper(
txs,
null,
mockUnapprovedTxs,
mockUnapprovedMsgs,
null,
null,
null,
@ -21,7 +27,9 @@ describe('txHelper', () => {
metamaskNetworkId,
chainId,
);
expect(sorted[0].time).toStrictEqual(1);
expect(sorted[2].time).toStrictEqual(3);
expect(sorted[5].time).toStrictEqual(6);
});
});

View File

@ -29,35 +29,33 @@ export default function txHelper(
transactionMatchesNetwork(txMeta, chainId, networkId),
)
: valuesFor(unapprovedTxs);
log.debug(`tx helper found ${txValues.length} unapproved txs`);
const msgValues = valuesFor(unapprovedMsgs);
log.debug(`tx helper found ${msgValues.length} unsigned messages`);
let allValues = txValues.concat(msgValues);
const personalValues = valuesFor(personalMsgs);
log.debug(
`tx helper found ${personalValues.length} unsigned personal messages`,
);
allValues = allValues.concat(personalValues);
const decryptValues = valuesFor(decryptMsgs);
log.debug(`tx helper found ${decryptValues.length} decrypt requests`);
allValues = allValues.concat(decryptValues);
const encryptionPublicKeyValues = valuesFor(encryptionPublicKeyMsgs);
log.debug(
`tx helper found ${encryptionPublicKeyValues.length} encryptionPublicKey requests`,
);
allValues = allValues.concat(encryptionPublicKeyValues);
const typedValues = valuesFor(typedMessages);
log.debug(`tx helper found ${typedValues.length} unsigned typed messages`);
allValues = allValues.concat(typedValues);
allValues = allValues.sort((a, b) => {
const allValues = txValues
.concat(msgValues)
.concat(personalValues)
.concat(decryptValues)
.concat(encryptionPublicKeyValues)
.concat(typedValues)
.sort((a, b) => {
return a.time - b.time;
});
log.debug(`tx helper found ${txValues.length} unapproved txs`);
log.debug(`tx helper found ${msgValues.length} unsigned messages`);
log.debug(
`tx helper found ${personalValues.length} unsigned personal messages`,
);
log.debug(`tx helper found ${decryptValues.length} decrypt requests`);
log.debug(
`tx helper found ${encryptionPublicKeyValues.length} encryptionPublicKey requests`,
);
log.debug(`tx helper found ${typedValues.length} unsigned typed messages`);
return allValues;
}

View File

@ -4,6 +4,7 @@
align-items: center;
width: 100%;
font-style: normal;
flex: 1 1 auto;
&__warning {
padding: 0 24px 16px 24px;

View File

@ -57,22 +57,22 @@ const ConfirmTransaction = () => {
const mostRecentOverviewPage = useSelector(getMostRecentOverviewPage);
const sendTo = useSelector(getSendTo);
const unapprovedTxs = useSelector(getUnapprovedTransactions);
const unconfirmedTxs = useSelector(unconfirmedTransactionsListSelector);
const unconfirmedMessages = useSelector(unconfirmedTransactionsHashSelector);
const unconfirmedTxsSorted = useSelector(unconfirmedTransactionsListSelector);
const unconfirmedTxs = useSelector(unconfirmedTransactionsHashSelector);
const totalUnapproved = unconfirmedTxs.length || 0;
const totalUnapproved = unconfirmedTxsSorted.length || 0;
const getTransaction = useCallback(() => {
return totalUnapproved
? unapprovedTxs[paramsTransactionId] ||
unconfirmedMessages[paramsTransactionId] ||
unconfirmedTxs[0]
unconfirmedTxs[paramsTransactionId] ||
unconfirmedTxsSorted[0]
: {};
}, [
paramsTransactionId,
totalUnapproved,
unapprovedTxs,
unconfirmedMessages,
unconfirmedTxs,
unconfirmedTxsSorted,
]);
const [transaction, setTransaction] = useState(getTransaction);
@ -88,8 +88,8 @@ const ConfirmTransaction = () => {
paramsTransactionId,
totalUnapproved,
unapprovedTxs,
unconfirmedMessages,
unconfirmedTxs,
unconfirmedTxsSorted,
]);
const { id, type } = transaction;