mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
Remove unused methods in the transaction controller (#20194)
This commit is contained in:
parent
7013b60259
commit
553da10bea
@ -557,54 +557,6 @@ export default class TransactionController extends EventEmitter {
|
|||||||
return this._getTransaction(txId);
|
return this._getTransaction(txId);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* updates the estimate base fees of the transaction with id if the transaction state is unapproved
|
|
||||||
*
|
|
||||||
* @param {string} txId - transaction id
|
|
||||||
* @param {object} txEstimateBaseFees - holds the estimate base fees parameters
|
|
||||||
* @param {string} txEstimateBaseFees.estimatedBaseFee
|
|
||||||
* @param {string} txEstimateBaseFees.decEstimatedBaseFee
|
|
||||||
* @returns {TransactionMeta} the txMeta of the updated transaction
|
|
||||||
*/
|
|
||||||
updateTransactionEstimatedBaseFee(
|
|
||||||
txId,
|
|
||||||
{ estimatedBaseFee, decEstimatedBaseFee },
|
|
||||||
) {
|
|
||||||
this._throwErrorIfNotUnapprovedTx(
|
|
||||||
txId,
|
|
||||||
'updateTransactionEstimatedBaseFee',
|
|
||||||
);
|
|
||||||
|
|
||||||
let txEstimateBaseFees = { estimatedBaseFee, decEstimatedBaseFee };
|
|
||||||
// only update what is defined
|
|
||||||
txEstimateBaseFees = pickBy(txEstimateBaseFees);
|
|
||||||
|
|
||||||
const note = `Update Transaction Estimated Base Fees for ${txId}`;
|
|
||||||
this._updateTransaction(txId, txEstimateBaseFees, note);
|
|
||||||
return this._getTransaction(txId);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* updates a transaction's user settings only if the transaction state is unapproved
|
|
||||||
*
|
|
||||||
* @param {string} txId
|
|
||||||
* @param {object} userSettings - holds the metadata
|
|
||||||
* @param {string} userSettings.userEditedGasLimit
|
|
||||||
* @param {string} userSettings.userFeeLevel
|
|
||||||
* @returns {TransactionMeta} the txMeta of the updated transaction
|
|
||||||
*/
|
|
||||||
updateTransactionUserSettings(txId, { userEditedGasLimit, userFeeLevel }) {
|
|
||||||
this._throwErrorIfNotUnapprovedTx(txId, 'updateTransactionUserSettings');
|
|
||||||
|
|
||||||
let userSettings = { userEditedGasLimit, userFeeLevel };
|
|
||||||
// only update what is defined
|
|
||||||
userSettings = pickBy(userSettings);
|
|
||||||
|
|
||||||
const note = `Update User Settings for ${txId}`;
|
|
||||||
this._updateTransaction(txId, userSettings, note);
|
|
||||||
return this._getTransaction(txId);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* append new sendFlowHistory to the transaction with id if the transaction
|
* append new sendFlowHistory to the transaction with id if the transaction
|
||||||
* state is unapproved. Returns the updated transaction.
|
* state is unapproved. Returns the updated transaction.
|
||||||
|
@ -3021,27 +3021,6 @@ describe('Transaction Controller', function () {
|
|||||||
assert.equal(result.estimateUsed, '0x0055');
|
assert.equal(result.estimateUsed, '0x0055');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('updates estimated base fee', function () {
|
|
||||||
txController.updateTransactionEstimatedBaseFee('1', {
|
|
||||||
estimatedBaseFee: '0x0066',
|
|
||||||
decEstimatedBaseFee: '66',
|
|
||||||
});
|
|
||||||
const result = txStateManager.getTransaction('1');
|
|
||||||
assert.equal(result.estimatedBaseFee, '0x0066');
|
|
||||||
assert.equal(result.decEstimatedBaseFee, '66');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('updates transaction user settings', function () {
|
|
||||||
txController.updateTransactionUserSettings('1', {
|
|
||||||
userEditedGasLimit: '0x0088',
|
|
||||||
userFeeLevel: 'high',
|
|
||||||
});
|
|
||||||
|
|
||||||
const result = txStateManager.getTransaction('1');
|
|
||||||
assert.equal(result.userEditedGasLimit, '0x0088');
|
|
||||||
assert.equal(result.userFeeLevel, 'high');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should not update and should throw error if status is not type "unapproved"', function () {
|
it('should not update and should throw error if status is not type "unapproved"', function () {
|
||||||
txStateManager.addTransaction({
|
txStateManager.addTransaction({
|
||||||
id: '4',
|
id: '4',
|
||||||
|
Loading…
Reference in New Issue
Block a user