Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
b3499c7
Initial commit
matthewwalsh0 Sep 24, 2025
4b0daf0
Add publish hook
matthewwalsh0 Sep 24, 2025
673c93e
Parse token transfer as required token
matthewwalsh0 Sep 24, 2025
ec460d0
Update tokens on transaction change
matthewwalsh0 Sep 25, 2025
cdf9e52
Fetch quotes
matthewwalsh0 Sep 26, 2025
b1d1f4b
Add update payment token unit tests
matthewwalsh0 Sep 26, 2025
afe1b4a
Add source amount unit tests
matthewwalsh0 Sep 26, 2025
94da96a
Add dust and fee calculation
matthewwalsh0 Sep 26, 2025
7f22ff5
Add required assets to transaction controller
matthewwalsh0 Sep 28, 2025
5c4734d
Pass required assets from middleware
matthewwalsh0 Sep 28, 2025
c69f50f
Parse required tokens from required assets
matthewwalsh0 Sep 28, 2025
338968b
Add quote metadata
matthewwalsh0 Sep 28, 2025
60be69f
Update bridge status controller
matthewwalsh0 Sep 28, 2025
6122dc7
Add totals to state
matthewwalsh0 Sep 29, 2025
47bf79c
Support abstract pay strategy
matthewwalsh0 Oct 12, 2025
e2b5c97
Add strategy constructor callback
matthewwalsh0 Oct 12, 2025
cd6d6f5
Add bridge strategy
matthewwalsh0 Oct 12, 2025
aec162c
Add bridge unit tests
matthewwalsh0 Oct 12, 2025
f9e7f2a
Add bridge quotes unit tests
matthewwalsh0 Oct 12, 2025
9590ac5
Incude amount in totals
matthewwalsh0 Oct 12, 2025
1094977
Handle no source amounts
matthewwalsh0 Oct 12, 2025
72d2367
Fix linting
matthewwalsh0 Oct 13, 2025
c15bbb2
Fix linting
matthewwalsh0 Oct 13, 2025
03f0532
Remove unnecessary changes
matthewwalsh0 Oct 13, 2025
e885e88
Add type
matthewwalsh0 Oct 13, 2025
c6a4cc0
Update changelog
matthewwalsh0 Oct 13, 2025
5489d31
Add unit test coverage
matthewwalsh0 Oct 13, 2025
1b9a3a3
Add Relay strategy
matthewwalsh0 Oct 13, 2025
4c6b861
Add relay quotes unit tests
matthewwalsh0 Oct 13, 2025
179cead
Add relay submit unit tests
matthewwalsh0 Oct 20, 2025
dfdd62c
Support swaps via batch transactions
matthewwalsh0 Oct 21, 2025
fe66f80
Update metric properties
matthewwalsh0 Oct 21, 2025
3484512
Update required transaction IDs
matthewwalsh0 Oct 21, 2025
a82d996
Add gas fee controller
matthewwalsh0 Oct 21, 2025
c41f0f1
Add transaction to quotes request
matthewwalsh0 Oct 22, 2025
576689a
Add relay quotes unit tests
matthewwalsh0 Oct 22, 2025
b431eaa
Use feature ID
matthewwalsh0 Oct 23, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
/packages/name-controller @MetaMask/confirmations
/packages/signature-controller @MetaMask/confirmations
/packages/transaction-controller @MetaMask/confirmations
/packages/transaction-pay-controller @MetaMask/confirmations
/packages/user-operation-controller @MetaMask/confirmations

## Delegation Team
Expand Down Expand Up @@ -149,6 +150,8 @@
/packages/signature-controller/CHANGELOG.md @MetaMask/confirmations @MetaMask/core-platform
/packages/transaction-controller/package.json @MetaMask/confirmations @MetaMask/core-platform
/packages/transaction-controller/CHANGELOG.md @MetaMask/confirmations @MetaMask/core-platform
/packages/transaction-pay-controller/package.json @MetaMask/confirmations @MetaMask/core-platform
/packages/transaction-pay-controller/CHANGELOG.md @MetaMask/confirmations @MetaMask/core-platform
/packages/user-operation-controller/package.json @MetaMask/confirmations @MetaMask/core-platform
/packages/user-operation-controller/CHANGELOG.md @MetaMask/confirmations @MetaMask/core-platform
/packages/multichain-transactions-controller/package.json @MetaMask/accounts-engineers @MetaMask/core-platform
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,12 @@ export class PendingTransactionTracker {
}

async #checkTransaction(txMeta: TransactionMeta) {
const { hash, id } = txMeta;
const { hash, id, isIntentComplete } = txMeta;

if (isIntentComplete) {
await this.#onTransactionConfirmed(txMeta);
return;
}

if (!hash && (await this.#beforeCheckPendingTransaction(txMeta))) {
const error = new Error(
Expand Down Expand Up @@ -450,10 +455,10 @@ export class PendingTransactionTracker {

async #onTransactionConfirmed(
txMeta: TransactionMeta,
receipt: SuccessfulTransactionReceipt,
receipt?: SuccessfulTransactionReceipt,
) {
const { id } = txMeta;
const { blockHash } = receipt;
const { blockHash } = receipt ?? {};

this.#log('Transaction confirmed', id);

Expand All @@ -463,19 +468,23 @@ export class PendingTransactionTracker {
return;
}

const { baseFeePerGas, timestamp: blockTimestamp } =
await this.#getBlockByHash(blockHash, false);

const updatedTxMeta = cloneDeep(txMeta);
updatedTxMeta.baseFeePerGas = baseFeePerGas;
updatedTxMeta.blockTimestamp = blockTimestamp;

if (receipt && blockHash) {
const { baseFeePerGas, timestamp: blockTimestamp } =
await this.#getBlockByHash(blockHash, false);

updatedTxMeta.baseFeePerGas = baseFeePerGas;
updatedTxMeta.blockTimestamp = blockTimestamp;
updatedTxMeta.txParams = {
...updatedTxMeta.txParams,
gasUsed: receipt.gasUsed,
};
updatedTxMeta.txReceipt = receipt;
updatedTxMeta.verifiedOnBlockchain = true;
}

updatedTxMeta.status = TransactionStatus.confirmed;
updatedTxMeta.txParams = {
...updatedTxMeta.txParams,
gasUsed: receipt.gasUsed,
};
updatedTxMeta.txReceipt = receipt;
updatedTxMeta.verifiedOnBlockchain = true;

this.#updateTransaction(
updatedTxMeta,
Expand Down
3 changes: 3 additions & 0 deletions packages/transaction-controller/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,9 @@ export type TransactionMeta = {
/** Whether MetaMask will be compensated for the gas fee by the transaction. */
isGasFeeIncluded?: boolean;

/** Whether the intent of the transaction was achieved via an alternate route or chain. */
isIntentComplete?: boolean;

/**
* Whether the transaction is an incoming token transfer.
*/
Expand Down
14 changes: 14 additions & 0 deletions packages/transaction-pay-controller/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Changelog

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]

### Added

- Initial release ([#6820](https://github.com/MetaMask/core/pull/6820))

[Unreleased]: https://github.com/MetaMask/core/
20 changes: 20 additions & 0 deletions packages/transaction-pay-controller/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
MIT License

Copyright (c) 2025 MetaMask

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19 changes: 19 additions & 0 deletions packages/transaction-pay-controller/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# `@metamask/transaction-pay-controller`

Manages alternate payment strategies to provide required funds for transactions in MetaMask.

## Installation

`yarn add @metamask/transaction-pay-controller`

or

`npm install @metamask/transaction-pay-controller`

## Compatibility

This package relies implicitly upon the `EventEmitter` module. This module is available natively in Node.js, but when using this package for the browser, make sure to use a polyfill such as `events`.

## Contributing

This package is part of a monorepo. Instructions for contributing can be found in the [monorepo README](https://github.com/MetaMask/core#readme).
26 changes: 26 additions & 0 deletions packages/transaction-pay-controller/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*
* For a detailed explanation regarding each configuration property and type check, visit:
* https://jestjs.io/docs/configuration
*/

const merge = require('deepmerge');
const path = require('path');

const baseConfig = require('../../jest.config.packages');

const displayName = path.basename(__dirname);

module.exports = merge(baseConfig, {
// The display name when running multiple projects
displayName,

// An object that configures minimum threshold enforcement for coverage results
coverageThreshold: {
global: {
branches: 100,
functions: 100,
lines: 100,
statements: 100,
},
},
});
96 changes: 96 additions & 0 deletions packages/transaction-pay-controller/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
{
"name": "@metamask/transaction-pay-controller",
"version": "0.0.0",
"description": "Manages alternate payment strategies to provide required funds for transactions in MetaMask",
"keywords": [
"MetaMask",
"Ethereum"
],
"homepage": "https://github.com/MetaMask/core/tree/main/packages/transaction-pay-controller#readme",
"bugs": {
"url": "https://github.com/MetaMask/core/issues"
},
"repository": {
"type": "git",
"url": "https://github.com/MetaMask/core.git"
},
"license": "MIT",
"sideEffects": false,
"exports": {
".": {
"import": {
"types": "./dist/index.d.mts",
"default": "./dist/index.mjs"
},
"require": {
"types": "./dist/index.d.cts",
"default": "./dist/index.cjs"
}
},
"./package.json": "./package.json"
},
"main": "./dist/index.cjs",
"types": "./dist/index.d.cts",
"files": [
"dist/"
],
"scripts": {
"build": "ts-bridge --project tsconfig.build.json --verbose --clean --no-references",
"build:docs": "typedoc",
"changelog:update": "../../scripts/update-changelog.sh @metamask/transaction-pay-controller",
"changelog:validate": "../../scripts/validate-changelog.sh @metamask/transaction-pay-controller",
"prepare-manifest:preview": "../../scripts/prepare-preview-manifest.sh",
"publish:preview": "yarn npm publish --tag preview",
"since-latest-release": "../../scripts/since-latest-release.sh",
"test": "NODE_OPTIONS=--experimental-vm-modules jest --reporters=jest-silent-reporter",
"test:clean": "NODE_OPTIONS=--experimental-vm-modules jest --clearCache",
"test:verbose": "NODE_OPTIONS=--experimental-vm-modules jest --verbose",
"test:watch": "NODE_OPTIONS=--experimental-vm-modules jest --watch"
},
"dependencies": {
"@ethersproject/abi": "^5.7.0",
"@ethersproject/contracts": "^5.7.0",
"@metamask/base-controller": "^8.4.1",
"@metamask/controller-utils": "^11.14.1",
"@metamask/metamask-eth-abis": "^3.1.1",
"@metamask/utils": "^11.8.1",
"bignumber.js": "^9.1.2",
"bn.js": "^5.2.1",
"immer": "^9.0.6",
"lodash": "^4.17.21"
},
"devDependencies": {
"@metamask/assets-controllers": "^79.0.1",
"@metamask/auto-changelog": "^3.4.4",
"@metamask/bridge-controller": "^49.0.1",
"@metamask/bridge-status-controller": "^49.0.1",
"@metamask/gas-fee-controller": "^24.1.0",
"@metamask/network-controller": "^24.2.1",
"@metamask/remote-feature-flag-controller": "^1.8.0",
"@metamask/transaction-controller": "^60.6.1",
"@ts-bridge/cli": "^0.6.1",
"@types/jest": "^27.4.1",
"deepmerge": "^4.2.2",
"jest": "^27.5.1",
"ts-jest": "^27.1.4",
"typedoc": "^0.24.8",
"typedoc-plugin-missing-exports": "^2.0.0",
"typescript": "~5.2.2"
},
"peerDependencies": {
"@metamask/assets-controllers": "^79.0.0",
"@metamask/bridge-controller": "^49.0.0",
"@metamask/bridge-status-controller": "^49.0.0",
"@metamask/gas-fee-controller": "^24.0.0",
"@metamask/network-controller": "^24.0.0",
"@metamask/remote-feature-flag-controller": "^1.5.0",
"@metamask/transaction-controller": "^60.0.0"
},
"engines": {
"node": "^18.18 || >=20"
},
"publishConfig": {
"access": "public",
"registry": "https://registry.npmjs.org/"
}
}
Loading