Skip to content

Commit 1a2619a

Browse files
chore: bump bridge controllers (#35596)
<!-- Please submit this PR as a draft initially. Do not mark it as "Ready for review" until the template has been completely filled out, and PR status checks have passed at least once. --> ## **Description** Changes - Support for EIP-7702 gasless txs - Metrics - Fix `actual_time_minutes` and `error_message` event properties - Update calculations for Completed, Failed and Submitted event properties - Pulish StatusValidationFailed and QuotesValidationFailed events - Set Solana txHistory key to tx signature so bridge transactions can be looked up and displayed (migration included) - `minDestTokenAmount` quote response field <!-- Write a short description of the changes included in this pull request, also include relevant motivation and context. Have in mind the following questions: 1. What is the reason for the change? 2. What is the improvement/solution? --> [![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/MetaMask/metamask-extension/pull/35596?quickstart=1) ## **Changelog** <!-- If this PR is not End-User-Facing and should not show up in the CHANGELOG, you can choose to either: 1. Write `CHANGELOG entry: null` 2. Label with `no-changelog` If this PR is End-User-Facing, please write a short User-Facing description in the past tense like: `CHANGELOG entry: Added a new tab for users to see their NFTs` `CHANGELOG entry: Fixed a bug that was causing some NFTs to flicker` (This helps the Release Engineer do their job more quickly and accurately) --> CHANGELOG entry: ## **Related issues** Fixes: metrics bugs, solana tx history key, new response validation events ## **Manual testing steps** 1. Old solana bridge txs should appear as Bridge transactions (no more `Swap to ` entries in activity log) 2. New solana bridge txs should appear as Bridge transactions 3. EVM transaction activity list should not be affected ## **Screenshots/Recordings** <!-- If applicable, add screenshots and/or recordings to visualize the before and after of your change. --> ### **Before** <!-- [screenshots/recordings] --> ### **After** <!-- [screenshots/recordings] --> ## **Pre-merge author checklist** - [ ] I've followed [MetaMask Contributor Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Extension Coding Standards](https://github.com/MetaMask/metamask-extension/blob/main/.github/guidelines/CODING_GUIDELINES.md). - [ ] I've completed the PR template to the best of my ability - [ ] I’ve included tests if applicable - [ ] I’ve documented my code using [JSDoc](https://jsdoc.app/) format if applicable - [ ] I’ve applied the right labels on the PR (see [labeling guidelines](https://github.com/MetaMask/metamask-extension/blob/main/.github/guidelines/LABELING_GUIDELINES.md)). Not required for external contributors. ## **Pre-merge reviewer checklist** - [ ] I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed). - [ ] I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots. --------- Co-authored-by: MetaMask Bot <metamaskbot@users.noreply.github.com>
1 parent 8f653e8 commit 1a2619a

File tree

16 files changed

+921
-210
lines changed

16 files changed

+921
-210
lines changed

app/scripts/migrations/174.test.ts

Lines changed: 497 additions & 0 deletions
Large diffs are not rendered by default.

app/scripts/migrations/174.ts

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
import { isSolanaChainId } from '@metamask/bridge-controller';
2+
import { type BridgeStatusControllerState } from '@metamask/bridge-status-controller';
3+
import { cloneDeep } from 'lodash';
4+
5+
export const version = 174;
6+
7+
/**
8+
* This migration fixes txHistory entries that were added with keys that were not valid
9+
* Solana tx signatures.
10+
*
11+
* For existing txs with invalid keys, the migration will remove the txHistory entry and add
12+
* it back with a valid key.
13+
*
14+
* @param originalVersionedData - Versioned MetaMask extension state, exactly what we persist to dist.
15+
* @param originalVersionedData.meta - State metadata.
16+
* @param originalVersionedData.meta.version - The current state version.
17+
* @param originalVersionedData.data - The persisted MetaMask state, keyed by controller.
18+
* @returns Updated versioned MetaMask extension state.
19+
*/
20+
export async function migrate(originalVersionedData: {
21+
meta: { version: number };
22+
data: Record<string, unknown>;
23+
}) {
24+
const versionedData = cloneDeep(originalVersionedData);
25+
versionedData.meta.version = version;
26+
versionedData.data = transformState(versionedData.data);
27+
return versionedData;
28+
}
29+
30+
function transformState(state: Record<string, unknown>) {
31+
const bridgeStatusControllerState = state?.BridgeStatusController;
32+
33+
if (
34+
!bridgeStatusControllerState ||
35+
typeof bridgeStatusControllerState !== 'object'
36+
) {
37+
return state;
38+
}
39+
40+
const { txHistory } =
41+
bridgeStatusControllerState as BridgeStatusControllerState;
42+
43+
if (!txHistory || Object.keys(txHistory).length === 0) {
44+
return state;
45+
}
46+
47+
const newTxHistory = Object.entries<
48+
BridgeStatusControllerState['txHistory'][string]
49+
>(txHistory as unknown as BridgeStatusControllerState['txHistory']).reduce<
50+
Record<string, BridgeStatusControllerState['txHistory'][string]>
51+
>((acc, [key, historyItem]) => {
52+
// Check if src chain is solana
53+
const srcChainId =
54+
historyItem.status?.srcChain?.chainId ?? historyItem.quote?.srcChainId;
55+
const isSolanaTx = isSolanaChainId(srcChainId);
56+
// If solana tx, use the src chain tx hash as the key
57+
const newKey = isSolanaTx ? historyItem.status?.srcChain?.txHash : key;
58+
59+
return {
60+
...acc,
61+
[newKey ?? key]: { ...historyItem },
62+
};
63+
}, {});
64+
65+
const newState = {
66+
...state,
67+
BridgeStatusController: {
68+
...bridgeStatusControllerState,
69+
txHistory: newTxHistory,
70+
},
71+
};
72+
73+
return newState;
74+
}

app/scripts/migrations/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,7 @@ const migrations = [
207207
require('./171'),
208208
require('./172'),
209209
require('./173'),
210+
require('./174'),
210211
];
211212

212213
export default migrations;

lavamoat/browserify/beta/policy.json

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -935,7 +935,7 @@
935935
"@metamask/controller-utils": true,
936936
"@metamask/keyring-api": true,
937937
"@metamask/metamask-eth-abis": true,
938-
"@metamask/multichain-network-controller": true,
938+
"@metamask/bridge-controller>@metamask/multichain-network-controller": true,
939939
"@metamask/bridge-controller>@metamask/polling-controller": true,
940940
"@metamask/superstruct": true,
941941
"@metamask/utils": true,
@@ -948,8 +948,7 @@
948948
"@metamask/bridge-status-controller": {
949949
"globals": {
950950
"URLSearchParams": true,
951-
"console.error": true,
952-
"console.log": true,
951+
"console.warn": true,
953952
"setTimeout": true
954953
},
955954
"packages": {
@@ -1497,6 +1496,19 @@
14971496
"lodash": true
14981497
}
14991498
},
1499+
"@metamask/bridge-controller>@metamask/multichain-network-controller": {
1500+
"globals": {
1501+
"URL": true
1502+
},
1503+
"packages": {
1504+
"@metamask/base-controller": true,
1505+
"@metamask/keyring-api": true,
1506+
"@metamask/network-controller": true,
1507+
"@metamask/superstruct": true,
1508+
"@metamask/utils": true,
1509+
"lodash": true
1510+
}
1511+
},
15001512
"@metamask/multichain-transactions-controller": {
15011513
"globals": {
15021514
"console.error": true

lavamoat/browserify/experimental/policy.json

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -935,7 +935,7 @@
935935
"@metamask/controller-utils": true,
936936
"@metamask/keyring-api": true,
937937
"@metamask/metamask-eth-abis": true,
938-
"@metamask/multichain-network-controller": true,
938+
"@metamask/bridge-controller>@metamask/multichain-network-controller": true,
939939
"@metamask/bridge-controller>@metamask/polling-controller": true,
940940
"@metamask/superstruct": true,
941941
"@metamask/utils": true,
@@ -948,8 +948,7 @@
948948
"@metamask/bridge-status-controller": {
949949
"globals": {
950950
"URLSearchParams": true,
951-
"console.error": true,
952-
"console.log": true,
951+
"console.warn": true,
953952
"setTimeout": true
954953
},
955954
"packages": {
@@ -1497,6 +1496,19 @@
14971496
"lodash": true
14981497
}
14991498
},
1499+
"@metamask/bridge-controller>@metamask/multichain-network-controller": {
1500+
"globals": {
1501+
"URL": true
1502+
},
1503+
"packages": {
1504+
"@metamask/base-controller": true,
1505+
"@metamask/keyring-api": true,
1506+
"@metamask/network-controller": true,
1507+
"@metamask/superstruct": true,
1508+
"@metamask/utils": true,
1509+
"lodash": true
1510+
}
1511+
},
15001512
"@metamask/multichain-transactions-controller": {
15011513
"globals": {
15021514
"console.error": true

lavamoat/browserify/flask/policy.json

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -935,7 +935,7 @@
935935
"@metamask/controller-utils": true,
936936
"@metamask/keyring-api": true,
937937
"@metamask/metamask-eth-abis": true,
938-
"@metamask/multichain-network-controller": true,
938+
"@metamask/bridge-controller>@metamask/multichain-network-controller": true,
939939
"@metamask/bridge-controller>@metamask/polling-controller": true,
940940
"@metamask/superstruct": true,
941941
"@metamask/utils": true,
@@ -948,8 +948,7 @@
948948
"@metamask/bridge-status-controller": {
949949
"globals": {
950950
"URLSearchParams": true,
951-
"console.error": true,
952-
"console.log": true,
951+
"console.warn": true,
953952
"setTimeout": true
954953
},
955954
"packages": {
@@ -1497,6 +1496,19 @@
14971496
"lodash": true
14981497
}
14991498
},
1499+
"@metamask/bridge-controller>@metamask/multichain-network-controller": {
1500+
"globals": {
1501+
"URL": true
1502+
},
1503+
"packages": {
1504+
"@metamask/base-controller": true,
1505+
"@metamask/keyring-api": true,
1506+
"@metamask/network-controller": true,
1507+
"@metamask/superstruct": true,
1508+
"@metamask/utils": true,
1509+
"lodash": true
1510+
}
1511+
},
15001512
"@metamask/multichain-transactions-controller": {
15011513
"globals": {
15021514
"console.error": true

lavamoat/browserify/main/policy.json

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -935,7 +935,7 @@
935935
"@metamask/controller-utils": true,
936936
"@metamask/keyring-api": true,
937937
"@metamask/metamask-eth-abis": true,
938-
"@metamask/multichain-network-controller": true,
938+
"@metamask/bridge-controller>@metamask/multichain-network-controller": true,
939939
"@metamask/bridge-controller>@metamask/polling-controller": true,
940940
"@metamask/superstruct": true,
941941
"@metamask/utils": true,
@@ -948,8 +948,7 @@
948948
"@metamask/bridge-status-controller": {
949949
"globals": {
950950
"URLSearchParams": true,
951-
"console.error": true,
952-
"console.log": true,
951+
"console.warn": true,
953952
"setTimeout": true
954953
},
955954
"packages": {
@@ -1497,6 +1496,19 @@
14971496
"lodash": true
14981497
}
14991498
},
1499+
"@metamask/bridge-controller>@metamask/multichain-network-controller": {
1500+
"globals": {
1501+
"URL": true
1502+
},
1503+
"packages": {
1504+
"@metamask/base-controller": true,
1505+
"@metamask/keyring-api": true,
1506+
"@metamask/network-controller": true,
1507+
"@metamask/superstruct": true,
1508+
"@metamask/utils": true,
1509+
"lodash": true
1510+
}
1511+
},
15001512
"@metamask/multichain-transactions-controller": {
15011513
"globals": {
15021514
"console.error": true

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -272,8 +272,8 @@
272272
"@metamask/assets-controllers": "patch:@metamask/assets-controllers@npm%3A74.3.1#~/.yarn/patches/@metamask-assets-controllers-npm-74.3.1-900afb3754.patch",
273273
"@metamask/base-controller": "^8.2.0",
274274
"@metamask/bitcoin-wallet-snap": "^1.0.0",
275-
"@metamask/bridge-controller": "^39.1.0",
276-
"@metamask/bridge-status-controller": "^38.1.0",
275+
"@metamask/bridge-controller": "^41.4.0",
276+
"@metamask/bridge-status-controller": "^41.0.0",
277277
"@metamask/browser-passworder": "^4.3.0",
278278
"@metamask/chain-agnostic-permission": "^1.1.0",
279279
"@metamask/contract-metadata": "^2.5.0",

test/data/bridge/mock-quotes-erc20-erc20.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
{
33
"quote": {
44
"requestId": "90ae8e69-f03a-4cf6-bab7-ed4e3431eb37",
5+
"minDestTokenAmount": "13984280",
56
"srcChainId": 10,
67
"srcAsset": {
78
"chainId": 10,
@@ -126,6 +127,7 @@
126127
},
127128
{
128129
"quote": {
130+
"minDestTokenAmount": "13800000",
129131
"requestId": "0b6caac9-456d-47e6-8982-1945ae81ae82",
130132
"srcChainId": 10,
131133
"srcAsset": {

test/data/bridge/mock-quotes-erc20-native.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
{
33
"quote": {
44
"requestId": "a63df72a-75ae-4416-a8ab-aff02596c75c",
5+
"minDestTokenAmount": "900000000000000000",
56
"srcChainId": 10,
67
"srcTokenAmount": "991250000000000000",
78
"srcAsset": {
@@ -103,6 +104,7 @@
103104
},
104105
{
105106
"quote": {
107+
"minDestTokenAmount": "900000000000000000",
106108
"requestId": "aad73198-a64d-4310-b12d-9dcc81c412e2",
107109
"srcChainId": 10,
108110
"srcTokenAmount": "991250000000000000",
@@ -205,6 +207,7 @@
205207
},
206208
{
207209
"quote": {
210+
"minDestTokenAmount": "900000000000000000",
208211
"requestId": "6cfd4952-c9b2-4aec-9349-af39c212f84b",
209212
"srcChainId": 10,
210213
"srcTokenAmount": "991250000000000000",
@@ -307,6 +310,7 @@
307310
},
308311
{
309312
"quote": {
313+
"minDestTokenAmount": "900000000000000000",
310314
"requestId": "2c2ba7d8-3922-4081-9f27-63b7d5cc1986",
311315
"srcChainId": 10,
312316
"srcTokenAmount": "991250000000000000",
@@ -409,6 +413,7 @@
409413
},
410414
{
411415
"quote": {
416+
"minDestTokenAmount": "900000000000000000",
412417
"requestId": "a77bc7b2-e8c8-4463-89db-5dd239d6aacc",
413418
"srcChainId": 10,
414419
"srcAsset": {
@@ -506,6 +511,7 @@
506511
},
507512
{
508513
"quote": {
514+
"minDestTokenAmount": "900000000000000000",
509515
"requestId": "4f2154d9b330221b2ad461adf63acc2c",
510516
"srcChainId": 10,
511517
"srcTokenAmount": "991250000000000000",

0 commit comments

Comments
 (0)