1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-10-22 11:22:43 +02:00

Merge pull request #11517 from MetaMask/Version-v9.8.1

Version v9.8.1 RC
This commit is contained in:
ryanml 2021-07-16 11:49:59 -07:00 committed by GitHub
commit 458483ed10
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 126 additions and 58 deletions

View File

@ -6,6 +6,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]
## [9.8.1]
### Changed
- Adjusting transaction metrics values
### Fixed
- [11538](https://github.com/MetaMask/metamask-extension/pull/11538): Fixed bug that prevented users from continuing to swap after going 'back' from the View Quote page of the swaps flow.
## [9.8.0]
### Added
- [#11435](https://github.com/MetaMask/metamask-extension/pull/11435): Add gas limit buffers for optimism network
@ -2329,7 +2336,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Uncategorized
- Added the ability to restore accounts from seed words.
[Unreleased]: https://github.com/MetaMask/metamask-extension/compare/v9.8.0...HEAD
[Unreleased]: https://github.com/MetaMask/metamask-extension/compare/v9.8.1...HEAD
[9.8.1]: https://github.com/MetaMask/metamask-extension/compare/v9.8.0...v9.8.1
[9.8.0]: https://github.com/MetaMask/metamask-extension/compare/v9.7.1...v9.8.0
[9.7.1]: https://github.com/MetaMask/metamask-extension/compare/v9.7.0...v9.7.1
[9.7.0]: https://github.com/MetaMask/metamask-extension/compare/v9.6.1...v9.7.0

View File

@ -130,8 +130,10 @@ export default class SwapsController {
console.error('Request for swaps quote refresh time failed: ', e);
}
const { swapsState: latestSwapsState } = this.store.getState();
this.store.updateState({
swapsState: { ...swapsState, swapsQuoteRefreshTime },
swapsState: { ...latestSwapsState, swapsQuoteRefreshTime },
});
}

View File

@ -1,7 +1,7 @@
import EventEmitter from 'safe-event-emitter';
import { ObservableStore } from '@metamask/obs-store';
import { bufferToHex, keccak, toBuffer } from 'ethereumjs-util';
import Transaction from 'ethereumjs-tx';
import { bufferToHex, keccak, toBuffer, isHexString } from 'ethereumjs-util';
import EthQuery from 'ethjs-query';
import { ethErrors } from 'eth-rpc-errors';
import abi from 'human-standard-token-abi';
@ -19,6 +19,7 @@ import {
} from '../../lib/util';
import { TRANSACTION_NO_CONTRACT_ERROR_KEY } from '../../../../ui/helpers/constants/error-keys';
import { getSwapsTokensReceivedFromTxMeta } from '../../../../ui/pages/swaps/swaps.util';
import { hexWEIToDecGWEI } from '../../../../ui/helpers/utils/conversions.util';
import {
TRANSACTION_STATUSES,
TRANSACTION_TYPES,
@ -669,15 +670,12 @@ export default class TransactionController extends EventEmitter {
this._markNonceDuplicatesDropped(txId);
const { submittedTime } = txMeta;
const { blockNumber } = txReceipt;
const metricsParams = { gas_used: gasUsed };
const completionTime = await this._getTransactionCompletionTime(
blockNumber,
submittedTime,
);
if (completionTime) {
metricsParams.completion_time = completionTime;
if (submittedTime) {
metricsParams.completion_time = this._getTransactionCompletionTime(
submittedTime,
);
}
if (txReceipt.status === '0x0') {
@ -1084,41 +1082,43 @@ export default class TransactionController extends EventEmitter {
gasParams.gas_price = gasPrice;
}
const gasParamsInGwei = this._getGasValuesInGWEI(gasParams);
this._trackMetaMetricsEvent({
event,
category: 'Transactions',
sensitiveProperties: {
type,
status,
properties: {
chain_id: chainId,
referrer,
source,
network,
chain_id: chainId,
type,
},
sensitiveProperties: {
status,
transaction_envelope_type: isEIP1559Transaction(txMeta)
? 'fee-market'
: 'legacy',
first_seen: time,
gas_limit: gasLimit,
...gasParams,
...gasParamsInGwei,
...extraParams,
},
});
}
async _getTransactionCompletionTime(blockNumber, submittedTime) {
const transactionBlock = await this.query.getBlockByNumber(
blockNumber.toString(16),
false,
);
_getTransactionCompletionTime(submittedTime) {
return Math.round((Date.now() - submittedTime) / 1000).toString();
}
if (!transactionBlock) {
return '';
_getGasValuesInGWEI(gasParams) {
const gasValuesInGwei = {};
for (const param in gasParams) {
if (isHexString(gasParams[param])) {
gasValuesInGwei[param] = hexWEIToDecGWEI(gasParams[param]);
}
}
return new BigNumber(transactionBlock.timestamp, 10)
.minus(submittedTime / 1000)
.round()
.toString(10);
return gasValuesInGwei;
}
_failTransaction(txId, error) {

View File

@ -1212,18 +1212,20 @@ describe('Transaction Controller', function () {
const expectedPayload = {
event: 'Transaction Added',
category: 'Transactions',
sensitiveProperties: {
properties: {
chain_id: '0x2a',
gas_price: '0x77359400',
gas_limit: '0x7b0d',
first_seen: 1624408066355,
transaction_envelope_type: 'legacy',
network: '42',
referrer: 'metamask',
source: 'user',
status: 'unapproved',
type: 'sentEther',
},
sensitiveProperties: {
gas_price: '2',
gas_limit: '0x7b0d',
first_seen: 1624408066355,
transaction_envelope_type: 'legacy',
status: 'unapproved',
},
};
txController._trackTransactionMetricsEvent(
@ -1257,18 +1259,20 @@ describe('Transaction Controller', function () {
const expectedPayload = {
event: 'Transaction Added',
category: 'Transactions',
sensitiveProperties: {
properties: {
chain_id: '0x2a',
gas_price: '0x77359400',
gas_limit: '0x7b0d',
first_seen: 1624408066355,
transaction_envelope_type: 'legacy',
network: '42',
referrer: 'other',
source: 'dapp',
status: 'unapproved',
type: 'sentEther',
},
sensitiveProperties: {
gas_price: '2',
gas_limit: '0x7b0d',
first_seen: 1624408066355,
transaction_envelope_type: 'legacy',
status: 'unapproved',
},
};
txController._trackTransactionMetricsEvent(
@ -1302,19 +1306,21 @@ describe('Transaction Controller', function () {
const expectedPayload = {
event: 'Transaction Added',
category: 'Transactions',
sensitiveProperties: {
baz: 3.0,
foo: 'bar',
chain_id: '0x2a',
gas_price: '0x77359400',
gas_limit: '0x7b0d',
first_seen: 1624408066355,
transaction_envelope_type: 'legacy',
properties: {
network: '42',
referrer: 'other',
source: 'dapp',
status: 'unapproved',
type: 'sentEther',
chain_id: '0x2a',
},
sensitiveProperties: {
baz: 3.0,
foo: 'bar',
gas_price: '2',
gas_limit: '0x7b0d',
first_seen: 1624408066355,
transaction_envelope_type: 'legacy',
status: 'unapproved',
},
};
@ -1354,21 +1360,23 @@ describe('Transaction Controller', function () {
const expectedPayload = {
event: 'Transaction Added',
category: 'Transactions',
sensitiveProperties: {
baz: 3.0,
foo: 'bar',
properties: {
chain_id: '0x2a',
max_fee_per_gas: '0x77359400',
max_priority_fee_per_gas: '0x77359400',
gas_limit: '0x7b0d',
first_seen: 1624408066355,
transaction_envelope_type: 'fee-market',
network: '42',
referrer: 'other',
source: 'dapp',
status: 'unapproved',
type: 'sentEther',
},
sensitiveProperties: {
baz: 3.0,
foo: 'bar',
max_fee_per_gas: '2',
max_priority_fee_per_gas: '2',
gas_limit: '0x7b0d',
first_seen: 1624408066355,
transaction_envelope_type: 'fee-market',
status: 'unapproved',
},
};
txController._trackTransactionMetricsEvent(
@ -1386,4 +1394,54 @@ describe('Transaction Controller', function () {
);
});
});
describe('#_getTransactionCompletionTime', function () {
let nowStub;
beforeEach(function () {
nowStub = sinon.stub(Date, 'now').returns(1625782016341);
});
afterEach(function () {
nowStub.restore();
});
it('calculates completion time (one)', function () {
const submittedTime = 1625781997397;
const result = txController._getTransactionCompletionTime(submittedTime);
assert.equal(result, '19');
});
it('calculates completion time (two)', function () {
const submittedTime = 1625781995397;
const result = txController._getTransactionCompletionTime(submittedTime);
assert.equal(result, '21');
});
});
describe('#_getGasValuesInGWEI', function () {
it('converts gas values in hex GWEi to dec GWEI (EIP-1559)', function () {
const params = {
max_fee_per_gas: '0x77359400',
max_priority_fee_per_gas: '0x77359400',
};
const expectedParams = {
max_fee_per_gas: '2',
max_priority_fee_per_gas: '2',
};
const result = txController._getGasValuesInGWEI(params);
assert.deepEqual(result, expectedParams);
});
it('converts gas values in hex GWEi to dec GWEI (non EIP-1559)', function () {
const params = {
gas_price: '0x37e11d600',
};
const expectedParams = {
gas_price: '15',
};
const result = txController._getGasValuesInGWEI(params);
assert.deepEqual(result, expectedParams);
});
});
});

View File

@ -1,6 +1,6 @@
{
"name": "metamask-crx",
"version": "9.8.0",
"version": "9.8.1",
"private": true,
"repository": {
"type": "git",