mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
add eip-1559 fields to event schema (#11408)
* add eip-1559 fields to event schema * add gas_limit to all
This commit is contained in:
parent
6280b849ad
commit
4e0bfbc463
@ -24,6 +24,7 @@ import {
|
|||||||
} from '../../../../shared/constants/transaction';
|
} from '../../../../shared/constants/transaction';
|
||||||
import { METAMASK_CONTROLLER_EVENTS } from '../../metamask-controller';
|
import { METAMASK_CONTROLLER_EVENTS } from '../../metamask-controller';
|
||||||
import { GAS_LIMITS } from '../../../../shared/constants/gas';
|
import { GAS_LIMITS } from '../../../../shared/constants/gas';
|
||||||
|
import { isEIP1559Transaction } from '../../../../shared/modules/transaction.utils';
|
||||||
import TransactionStateManager from './tx-state-manager';
|
import TransactionStateManager from './tx-state-manager';
|
||||||
import TxGasUtil from './tx-gas-utils';
|
import TxGasUtil from './tx-gas-utils';
|
||||||
import PendingTransactionTracker from './pending-tx-tracker';
|
import PendingTransactionTracker from './pending-tx-tracker';
|
||||||
@ -626,10 +627,7 @@ export default class TransactionController extends EventEmitter {
|
|||||||
|
|
||||||
this.txStateManager.setTxStatusSubmitted(txId);
|
this.txStateManager.setTxStatusSubmitted(txId);
|
||||||
|
|
||||||
const { gas } = txMeta.txParams;
|
this._trackTransactionMetricsEvent(txMeta, TRANSACTION_EVENTS.SUBMITTED);
|
||||||
this._trackTransactionMetricsEvent(txMeta, TRANSACTION_EVENTS.SUBMITTED, {
|
|
||||||
gas_limit: gas,
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1064,11 +1062,20 @@ export default class TransactionController extends EventEmitter {
|
|||||||
status,
|
status,
|
||||||
chainId,
|
chainId,
|
||||||
origin: referrer,
|
origin: referrer,
|
||||||
txParams: { gasPrice },
|
txParams: { gasPrice, gas: gasLimit, maxFeePerGas, maxPriorityFeePerGas },
|
||||||
metamaskNetworkId: network,
|
metamaskNetworkId: network,
|
||||||
} = txMeta;
|
} = txMeta;
|
||||||
const source = referrer === 'metamask' ? 'user' : 'dapp';
|
const source = referrer === 'metamask' ? 'user' : 'dapp';
|
||||||
|
|
||||||
|
const gasParams = {};
|
||||||
|
|
||||||
|
if (isEIP1559Transaction(txMeta)) {
|
||||||
|
gasParams.max_fee_per_gas = maxFeePerGas;
|
||||||
|
gasParams.max_priority_fee_per_gas = maxPriorityFeePerGas;
|
||||||
|
} else {
|
||||||
|
gasParams.gas_price = gasPrice;
|
||||||
|
}
|
||||||
|
|
||||||
this._trackMetaMetricsEvent({
|
this._trackMetaMetricsEvent({
|
||||||
event,
|
event,
|
||||||
category: 'Transactions',
|
category: 'Transactions',
|
||||||
@ -1079,8 +1086,12 @@ export default class TransactionController extends EventEmitter {
|
|||||||
source,
|
source,
|
||||||
network,
|
network,
|
||||||
chain_id: chainId,
|
chain_id: chainId,
|
||||||
gas_price: gasPrice,
|
transaction_envelope_type: isEIP1559Transaction(txMeta)
|
||||||
|
? 'fee-market'
|
||||||
|
: 'legacy',
|
||||||
first_seen: time,
|
first_seen: time,
|
||||||
|
gas_limit: gasLimit,
|
||||||
|
...gasParams,
|
||||||
...extraParams,
|
...extraParams,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
@ -478,6 +478,7 @@ describe('Transaction Controller', function () {
|
|||||||
nonce: '0x4b',
|
nonce: '0x4b',
|
||||||
},
|
},
|
||||||
type: 'sentEther',
|
type: 'sentEther',
|
||||||
|
transaction_envelope_type: 'legacy',
|
||||||
origin: 'metamask',
|
origin: 'metamask',
|
||||||
chainId: currentChainId,
|
chainId: currentChainId,
|
||||||
time: 1624408066355,
|
time: 1624408066355,
|
||||||
@ -834,9 +835,6 @@ describe('Transaction Controller', function () {
|
|||||||
trackTransactionMetricsEventSpy.getCall(0).args[1],
|
trackTransactionMetricsEventSpy.getCall(0).args[1],
|
||||||
TRANSACTION_EVENTS.SUBMITTED,
|
TRANSACTION_EVENTS.SUBMITTED,
|
||||||
);
|
);
|
||||||
assert.deepEqual(trackTransactionMetricsEventSpy.getCall(0).args[2], {
|
|
||||||
gas_limit: txMeta.txParams.gas,
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -1217,7 +1215,9 @@ describe('Transaction Controller', function () {
|
|||||||
sensitiveProperties: {
|
sensitiveProperties: {
|
||||||
chain_id: '0x2a',
|
chain_id: '0x2a',
|
||||||
gas_price: '0x77359400',
|
gas_price: '0x77359400',
|
||||||
|
gas_limit: '0x7b0d',
|
||||||
first_seen: 1624408066355,
|
first_seen: 1624408066355,
|
||||||
|
transaction_envelope_type: 'legacy',
|
||||||
network: '42',
|
network: '42',
|
||||||
referrer: 'metamask',
|
referrer: 'metamask',
|
||||||
source: 'user',
|
source: 'user',
|
||||||
@ -1260,7 +1260,9 @@ describe('Transaction Controller', function () {
|
|||||||
sensitiveProperties: {
|
sensitiveProperties: {
|
||||||
chain_id: '0x2a',
|
chain_id: '0x2a',
|
||||||
gas_price: '0x77359400',
|
gas_price: '0x77359400',
|
||||||
|
gas_limit: '0x7b0d',
|
||||||
first_seen: 1624408066355,
|
first_seen: 1624408066355,
|
||||||
|
transaction_envelope_type: 'legacy',
|
||||||
network: '42',
|
network: '42',
|
||||||
referrer: 'other',
|
referrer: 'other',
|
||||||
source: 'dapp',
|
source: 'dapp',
|
||||||
@ -1305,7 +1307,62 @@ describe('Transaction Controller', function () {
|
|||||||
foo: 'bar',
|
foo: 'bar',
|
||||||
chain_id: '0x2a',
|
chain_id: '0x2a',
|
||||||
gas_price: '0x77359400',
|
gas_price: '0x77359400',
|
||||||
|
gas_limit: '0x7b0d',
|
||||||
first_seen: 1624408066355,
|
first_seen: 1624408066355,
|
||||||
|
transaction_envelope_type: 'legacy',
|
||||||
|
network: '42',
|
||||||
|
referrer: 'other',
|
||||||
|
source: 'dapp',
|
||||||
|
status: 'unapproved',
|
||||||
|
type: 'sentEther',
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
txController._trackTransactionMetricsEvent(
|
||||||
|
txMeta,
|
||||||
|
TRANSACTION_EVENTS.ADDED,
|
||||||
|
{
|
||||||
|
baz: 3.0,
|
||||||
|
foo: 'bar',
|
||||||
|
},
|
||||||
|
);
|
||||||
|
assert.equal(trackMetaMetricsEventSpy.callCount, 1);
|
||||||
|
assert.deepEqual(
|
||||||
|
trackMetaMetricsEventSpy.getCall(0).args[0],
|
||||||
|
expectedPayload,
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should call _trackMetaMetricsEvent with the correct payload (EIP-1559)', function () {
|
||||||
|
const txMeta = {
|
||||||
|
id: 1,
|
||||||
|
status: TRANSACTION_STATUSES.UNAPPROVED,
|
||||||
|
txParams: {
|
||||||
|
from: fromAccount.address,
|
||||||
|
to: '0x1678a085c290ebd122dc42cba69373b5953b831d',
|
||||||
|
maxFeePerGas: '0x77359400',
|
||||||
|
maxPriorityFeePerGas: '0x77359400',
|
||||||
|
gas: '0x7b0d',
|
||||||
|
nonce: '0x4b',
|
||||||
|
},
|
||||||
|
type: 'sentEther',
|
||||||
|
origin: 'other',
|
||||||
|
chainId: currentChainId,
|
||||||
|
time: 1624408066355,
|
||||||
|
metamaskNetworkId: currentNetworkId,
|
||||||
|
};
|
||||||
|
const expectedPayload = {
|
||||||
|
event: 'Transaction Added',
|
||||||
|
category: 'Transactions',
|
||||||
|
sensitiveProperties: {
|
||||||
|
baz: 3.0,
|
||||||
|
foo: 'bar',
|
||||||
|
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',
|
network: '42',
|
||||||
referrer: 'other',
|
referrer: 'other',
|
||||||
source: 'dapp',
|
source: 'dapp',
|
||||||
|
Loading…
Reference in New Issue
Block a user