Skip to content

Commit

Permalink
Remove cancelMultiplier & speedUpMultiplier option from `Transact…
Browse files Browse the repository at this point in the history
…ionController` (#3909)

## Explanation

This PR aims to remove `cancelMultiplier` option from constructor
options of `TransactionController`.

## References

<!--
Are there any issues that this pull request is tied to? Are there other
links that reviewers should consult to understand these changes better?

For example:

* Fixes #12345
* Related to #67890
-->

Fixes: MetaMask/MetaMask-planning#1929

## Changelog

<!--
If you're making any consumer-facing changes, list those changes here as
if you were updating a changelog, using the template below as a guide.

(CATEGORY is one of BREAKING, ADDED, CHANGED, DEPRECATED, REMOVED, or
FIXED. For security-related issues, follow the Security Advisory
process.)

Please take care to name the exact pieces of the API you've added or
changed (e.g. types, interfaces, functions, or methods).

If there are any breaking changes, make sure to offer a solution for
consumers to follow once they upgrade to the changes.

Finally, if you're only making changes to development scripts or tests,
you may replace the template below with "None".
-->

### `@metamask/transaction-controller`

- **REMOVED**: The `cancelMultiplier` & `speedUpMultiplier` parameters
has been eliminated from the `TransactionController` constructor. Its
value is now set as a hardcoded global constant of `1.1`.

## Checklist

- [X] I've updated the test suite for new or updated code as appropriate
- [X] I've updated documentation (JSDoc, Markdown, etc.) for new or
updated code as appropriate
- [] I've highlighted breaking changes using the "BREAKING" category
above as appropriate
  • Loading branch information
OGPoyraz authored Feb 13, 2024
1 parent 81ac379 commit 78cabd0
Showing 1 changed file with 7 additions and 19 deletions.
26 changes: 7 additions & 19 deletions packages/transaction-controller/src/TransactionController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ export interface TransactionState extends BaseState {
/**
* Multiplier used to determine a transaction's increased gas fee during cancellation
*/
export const CANCEL_RATE = 1.5;
export const CANCEL_RATE = 1.1;

/**
* Multiplier used to determine a transaction's increased gas fee during speed up
Expand Down Expand Up @@ -269,10 +269,6 @@ export class TransactionController extends BaseControllerV1<

private readonly pendingTransactionTracker: PendingTransactionTracker;

private readonly cancelMultiplier: number;

private readonly speedUpMultiplier: number;

private readonly signAbortCallbacks: Map<string, () => void> = new Map();

private readonly afterSign: (
Expand Down Expand Up @@ -352,7 +348,6 @@ export class TransactionController extends BaseControllerV1<
*
* @param options - The controller options.
* @param options.blockTracker - The block tracker used to poll for new blocks data.
* @param options.cancelMultiplier - Multiplier used to determine a transaction's increased gas fee during cancellation.
* @param options.disableHistory - Whether to disable storing history in transaction metadata.
* @param options.disableSendFlowHistory - Explicitly disable transaction metadata history.
* @param options.disableSwaps - Whether to disable additional processing on swaps transactions.
Expand All @@ -375,7 +370,6 @@ export class TransactionController extends BaseControllerV1<
* @param options.pendingTransactions.isResubmitEnabled - Whether transaction publishing is automatically retried.
* @param options.provider - The provider used to create the underlying EthQuery instance.
* @param options.securityProviderRequest - A function for verifying a transaction, whether it is malicious or not.
* @param options.speedUpMultiplier - Multiplier used to determine a transaction's increased gas fee during speed up.
* @param options.hooks - The controller hooks.
* @param options.hooks.afterSign - Additional logic to execute after signing a transaction. Return false to not change the status to signed.
* @param options.hooks.beforeApproveOnInit - Additional logic to execute before starting an approval flow for a transaction during initialization. Return false to skip the transaction.
Expand All @@ -389,7 +383,6 @@ export class TransactionController extends BaseControllerV1<
constructor(
{
blockTracker,
cancelMultiplier,
disableHistory,
disableSendFlowHistory,
disableSwaps,
Expand All @@ -407,11 +400,9 @@ export class TransactionController extends BaseControllerV1<
pendingTransactions = {},
provider,
securityProviderRequest,
speedUpMultiplier,
hooks = {},
}: {
blockTracker: BlockTracker;
cancelMultiplier?: number;
disableHistory: boolean;
disableSendFlowHistory: boolean;
disableSwaps: boolean;
Expand All @@ -438,7 +429,6 @@ export class TransactionController extends BaseControllerV1<
};
provider: Provider;
securityProviderRequest?: SecurityProviderRequest;
speedUpMultiplier?: number;
hooks: {
afterSign?: (
transactionMeta: TransactionMeta,
Expand Down Expand Up @@ -495,8 +485,6 @@ export class TransactionController extends BaseControllerV1<
this.getExternalPendingTransactions =
getExternalPendingTransactions ?? (() => []);
this.securityProviderRequest = securityProviderRequest;
this.cancelMultiplier = cancelMultiplier ?? CANCEL_RATE;
this.speedUpMultiplier = speedUpMultiplier ?? SPEED_UP_RATE;

this.afterSign = hooks?.afterSign ?? (() => true);
this.beforeApproveOnInit = hooks?.beforeApproveOnInit ?? (() => true);
Expand Down Expand Up @@ -794,7 +782,7 @@ export class TransactionController extends BaseControllerV1<
// gasPrice (legacy non EIP1559)
const minGasPrice = getIncreasedPriceFromExisting(
transactionMeta.txParams.gasPrice,
this.cancelMultiplier,
CANCEL_RATE,
);

const gasPriceFromValues = isGasPriceValue(gasValues) && gasValues.gasPrice;
Expand All @@ -808,7 +796,7 @@ export class TransactionController extends BaseControllerV1<
const existingMaxFeePerGas = transactionMeta.txParams?.maxFeePerGas;
const minMaxFeePerGas = getIncreasedPriceFromExisting(
existingMaxFeePerGas,
this.cancelMultiplier,
CANCEL_RATE,
);
const maxFeePerGasValues =
isFeeMarketEIP1559Values(gasValues) && gasValues.maxFeePerGas;
Expand All @@ -822,7 +810,7 @@ export class TransactionController extends BaseControllerV1<
transactionMeta.txParams?.maxPriorityFeePerGas;
const minMaxPriorityFeePerGas = getIncreasedPriceFromExisting(
existingMaxPriorityFeePerGas,
this.cancelMultiplier,
CANCEL_RATE,
);
const maxPriorityFeePerGasValues =
isFeeMarketEIP1559Values(gasValues) && gasValues.maxPriorityFeePerGas;
Expand Down Expand Up @@ -955,7 +943,7 @@ export class TransactionController extends BaseControllerV1<
// gasPrice (legacy non EIP1559)
const minGasPrice = getIncreasedPriceFromExisting(
transactionMeta.txParams.gasPrice,
this.speedUpMultiplier,
SPEED_UP_RATE,
);

const gasPriceFromValues = isGasPriceValue(gasValues) && gasValues.gasPrice;
Expand All @@ -969,7 +957,7 @@ export class TransactionController extends BaseControllerV1<
const existingMaxFeePerGas = transactionMeta.txParams?.maxFeePerGas;
const minMaxFeePerGas = getIncreasedPriceFromExisting(
existingMaxFeePerGas,
this.speedUpMultiplier,
SPEED_UP_RATE,
);
const maxFeePerGasValues =
isFeeMarketEIP1559Values(gasValues) && gasValues.maxFeePerGas;
Expand All @@ -983,7 +971,7 @@ export class TransactionController extends BaseControllerV1<
transactionMeta.txParams?.maxPriorityFeePerGas;
const minMaxPriorityFeePerGas = getIncreasedPriceFromExisting(
existingMaxPriorityFeePerGas,
this.speedUpMultiplier,
SPEED_UP_RATE,
);
const maxPriorityFeePerGasValues =
isFeeMarketEIP1559Values(gasValues) && gasValues.maxPriorityFeePerGas;
Expand Down

0 comments on commit 78cabd0

Please sign in to comment.