Skip to content

feat: fetch asset metadata on search #31258

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 91 commits into from
Mar 28, 2025
Merged
Show file tree
Hide file tree
Changes from 90 commits
Commits
Show all changes
91 commits
Select commit Hold shift + click to select a range
e46a4c1
feat: migrate to @metamask/bridge-controller
micaelae Mar 14, 2025
a6c7317
refactor: replace solana conditions with isSolanaChainId
micaelae Mar 17, 2025
2f3c227
refactor: rm BridgeController
micaelae Mar 17, 2025
2229022
refactor: import bridge types, constants and utils from core
micaelae Mar 17, 2025
6eb3f7b
refactor: remove bridgeState from controller state
micaelae Mar 17, 2025
5e47b24
fix: type errors
micaelae Mar 17, 2025
54f8d43
refactor: use SWAPS_CHAINID_DEFAULT_TOKEN_MAP from core
micaelae Mar 18, 2025
4aced8e
fix: use bridge token endpoint for solana
micaelae Mar 18, 2025
734c9d8
fix: token alerts payload
micaelae Mar 18, 2025
6fcc731
chore: use token types from bridge-controller
micaelae Mar 18, 2025
2e47491
chore: clean up comments
micaelae Mar 18, 2025
ac7af48
refactor: use getNativeAssetForChainId
micaelae Mar 19, 2025
22c4039
fix: undo using bridge-controller constants in useSwapDefaultToToken
micaelae Mar 19, 2025
b660414
fix: invalid type imports
micaelae Mar 19, 2025
b0e8b37
refactor: caip formatter updates
micaelae Mar 19, 2025
7e85f3b
chore: package updates
micaelae Mar 19, 2025
c47fe68
chore: use preview bridge-controller build
micaelae Mar 19, 2025
1e00869
fix: e2e constants for bridge feature flags
micaelae Mar 19, 2025
3621570
fix: circular dependency
micaelae Mar 19, 2025
0f3a67d
fix: getDefaultBridgeControllerState
micaelae Mar 19, 2025
62a4469
fix: lavamoat policy
micaelae Mar 20, 2025
68dd678
fix: unit tests
micaelae Mar 20, 2025
789bd4b
Merge branch 'main' into mms2102-bridge-migration
micaelae Mar 20, 2025
2d57163
fix: missing import
micaelae Mar 20, 2025
8ba857c
fix: bridge-status mocks
micaelae Mar 20, 2025
30da773
fix: bridge selectors unit tests
micaelae Mar 20, 2025
bff378d
fix: getFromToken selector
micaelae Mar 20, 2025
fd34aba
chore: bump bridge-controller
micaelae Mar 21, 2025
8ee4016
fix: unit tests
micaelae Mar 21, 2025
b86bba9
fix: lavamoat
micaelae Mar 21, 2025
d5cb20e
fix: MultichainBridgeQuoteCard storybook
micaelae Mar 21, 2025
e02517f
fix: useLatestBalance
micaelae Mar 21, 2025
43af28b
chore: undo calcLatestSrcBalance change
micaelae Mar 21, 2025
b775b67
chore: bump bridge-controller
micaelae Mar 21, 2025
930c10d
Merge branch 'main' into mms2102-bridge-migration
micaelae Mar 21, 2025
e6783d0
Merge branch 'main' into mms2102-bridge-migration
micaelae Mar 21, 2025
5349aef
fix: bridge-cta-button warnings
micaelae Mar 22, 2025
0647524
chore: memoize native assets
micaelae Mar 22, 2025
9e51d60
fix: warnings in useTokensWithFiltering
micaelae Mar 24, 2025
7e27cca
refactor: rm chainId from useLatestBalance
micaelae Mar 24, 2025
1c23acc
chore: use @metamask/bridge-controller 11.0.0
micaelae Mar 24, 2025
4c50bae
fix: useTokensWithFiltering tests
micaelae Mar 24, 2025
8fe7c86
Merge branch 'main' into mms2102-bridge-migration
micaelae Mar 24, 2025
a7f22a4
chore: update lavamoat
micaelae Mar 24, 2025
5d76a55
Merge branch 'main' into mms2102-bridge-migration
micaelae Mar 24, 2025
3d9cca1
Merge branch 'main' into mms2102-bridge-migration
micaelae Mar 24, 2025
ae416fb
fix: sentry tests
micaelae Mar 24, 2025
8cd2a89
fix: lavamoat
micaelae Mar 24, 2025
229be94
Merge branch 'main' into mms2102-bridge-migration
micaelae Mar 24, 2025
71629c7
fix: e2e tests
micaelae Mar 24, 2025
5e6856e
chore: mock bridge calls
micaelae Mar 24, 2025
004122b
fix: add bridge featureFlags to allowed e2e urls
micaelae Mar 25, 2025
736f937
fix: sentry tests
micaelae Mar 25, 2025
7bb0763
feat: add asset-utils module
micaelae Mar 21, 2025
51c48b7
chore: add useAssetMetadata hoook
micaelae Mar 24, 2025
da851d4
test: add unit tests for asset-picker-modal
micaelae Mar 25, 2025
3586769
feat: use asset metadata in asset-picker
micaelae Mar 25, 2025
6c6453a
fix: use solana assetId
micaelae Mar 25, 2025
aa4e211
chore: add unit test for useAssetMetadata call
micaelae Mar 25, 2025
504ea1b
fix: duplicate native assets
micaelae Mar 25, 2025
2a00f22
chore: debounce search input
micaelae Mar 25, 2025
3c7a116
fix: reset searchQuery on network change
micaelae Mar 25, 2025
008f37e
fix: unit tests
micaelae Mar 25, 2025
7fde7f2
refactor: move useAssetMetadata
micaelae Mar 25, 2025
4d65492
chore: abort asset metadata fetch when searchQuery changes
micaelae Mar 25, 2025
3528a76
chore: show selected asset at the top of list
micaelae Mar 25, 2025
8bb76e4
chore: toAssetId util
micaelae Mar 26, 2025
f241f10
fix: useAssetMetadata tests
micaelae Mar 26, 2025
4327e19
fix: propagate abort signal to fetch function
micaelae Mar 26, 2025
8ba6a0b
Merge branch 'main' into mms2102-bridge-migration
micaelae Mar 26, 2025
b63cd39
chore: add useMemo dep
micaelae Mar 26, 2025
2e9cd29
Merge branch 'main' into mms2102-bridge-migration
micaelae Mar 26, 2025
6ac2edc
Merge branch 'main' into mms2102-bridge-migration
micaelae Mar 26, 2025
b7309b8
fix: show selected asset first
micaelae Mar 26, 2025
232d284
Merge branch 'main' into mms2102-bridge-migration
micaelae Mar 27, 2025
2b51240
Merge branch 'mms2102-bridge-migration' into mms2094-token-metadata-o…
micaelae Mar 27, 2025
98d828d
Merge branch 'main' into mms2102-bridge-migration
micaelae Mar 27, 2025
0f271a8
fix: asset-picker-modal unit tests
micaelae Mar 27, 2025
5a1b44a
Merge branch 'main' into mms2102-bridge-migration
micaelae Mar 27, 2025
02acb64
Merge branch 'mms2102-bridge-migration' into mms2094-token-metadata-o…
micaelae Mar 27, 2025
4e84191
fix: swap-send e2e test
micaelae Mar 27, 2025
c7611e0
chore: add constants for network names
micaelae Mar 27, 2025
c472f8d
fix: export const
micaelae Mar 27, 2025
c4fd0d2
Merge branch 'main' into mms2102-bridge-migration
micaelae Mar 27, 2025
f853cb0
Merge branch 'mms2102-bridge-migration' into mms-add-network-names-fo…
micaelae Mar 27, 2025
d8caa9b
Merge branch 'mms-add-network-names-for-caip-chainids' into mms2094-t…
micaelae Mar 27, 2025
5136ff3
fix: asset-picker test
micaelae Mar 27, 2025
53ddea6
chore: add network names for caip chainids (#31372)
micaelae Mar 27, 2025
b640b2f
Merge branch 'mms2102-bridge-migration' into mms2094-token-metadata-o…
micaelae Mar 27, 2025
8b51664
chore: simplify asset metadata abort call
micaelae Mar 27, 2025
dd3baa7
Merge branch 'main' into mms2094-token-metadata-on-paste
micaelae Mar 27, 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
1 change: 0 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,6 @@ module.exports = {
'app/scripts/controllers/alert-controller.test.ts',
'app/scripts/metamask-controller.actions.test.js',
'app/scripts/detect-multiple-instances.test.js',
'app/scripts/controllers/bridge.test.ts',
'app/scripts/controllers/swaps/**/*.test.js',
'app/scripts/controllers/swaps/**/*.test.ts',
'app/scripts/controllers/metametrics.test.js',
Expand Down
41 changes: 20 additions & 21 deletions app/scripts/constants/sentry-state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,29 +112,28 @@ export const SENTRY_BACKGROUND_STATE = {
assetsRates: false,
},
BridgeController: {
bridgeState: {
bridgeFeatureFlags: {
extensionConfig: {
support: false,
chains: {},
},
bridgeFeatureFlags: {
extensionConfig: {
support: false,
chains: {},
},
quoteRequest: {
walletAddress: false,
srcTokenAddress: true,
slippage: true,
srcChainId: true,
destChainId: true,
destTokenAddress: true,
srcTokenAmount: true,
},
quotes: [],
quotesInitialLoadTime: true,
quotesLastFetched: true,
quotesLoadingStatus: true,
quoteFetchError: true,
quotesRefreshCount: true,
mobileConfig: false,
},
quoteRequest: {
walletAddress: false,
srcTokenAddress: true,
slippage: true,
srcChainId: true,
destChainId: true,
destTokenAddress: true,
srcTokenAmount: true,
},
quotes: [],
quotesInitialLoadTime: true,
quotesLastFetched: true,
quotesLoadingStatus: true,
quoteFetchError: true,
quotesRefreshCount: true,
},
BridgeStatusController: {
bridgeStatusState: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ exports[`BridgeStatusController constructor rehydrates the tx history state 1`]
],
"destAsset": {
"address": "0x0000000000000000000000000000000000000000",
"assetId": "eip155:10/slip44:60",
"chainId": 10,
"coinKey": "ETH",
"decimals": 18,
Expand All @@ -36,6 +37,7 @@ exports[`BridgeStatusController constructor rehydrates the tx history state 1`]
"amount": "8750000000000",
"asset": {
"address": "0x0000000000000000000000000000000000000000",
"assetId": "eip155:42161/slip44:60",
"chainId": 42161,
"coinKey": "ETH",
"decimals": 18,
Expand All @@ -50,6 +52,7 @@ exports[`BridgeStatusController constructor rehydrates the tx history state 1`]
"requestId": "197c402f-cb96-4096-9f8c-54aed84ca776",
"srcAsset": {
"address": "0x0000000000000000000000000000000000000000",
"assetId": "eip155:42161/slip44:60",
"chainId": 42161,
"coinKey": "ETH",
"decimals": 18,
Expand All @@ -67,6 +70,7 @@ exports[`BridgeStatusController constructor rehydrates the tx history state 1`]
"destAmount": "990654755978612",
"destAsset": {
"address": "0x0000000000000000000000000000000000000000",
"assetId": "eip155:10/slip44:60",
"chainId": 10,
"coinKey": "ETH",
"decimals": 18,
Expand All @@ -85,6 +89,7 @@ exports[`BridgeStatusController constructor rehydrates the tx history state 1`]
"srcAmount": "991250000000000",
"srcAsset": {
"address": "0x0000000000000000000000000000000000000000",
"assetId": "eip155:42161/slip44:60",
"chainId": 42161,
"coinKey": "ETH",
"decimals": 18,
Expand Down Expand Up @@ -133,6 +138,7 @@ exports[`BridgeStatusController startPollingForBridgeTxStatus sets the inital tx
],
"destAsset": {
"address": "0x0000000000000000000000000000000000000000",
"assetId": "eip155:10/slip44:60",
"chainId": 10,
"coinKey": "ETH",
"decimals": 18,
Expand All @@ -149,6 +155,7 @@ exports[`BridgeStatusController startPollingForBridgeTxStatus sets the inital tx
"amount": "8750000000000",
"asset": {
"address": "0x0000000000000000000000000000000000000000",
"assetId": "eip155:42161/slip44:60",
"chainId": 42161,
"coinKey": "ETH",
"decimals": 18,
Expand All @@ -163,6 +170,7 @@ exports[`BridgeStatusController startPollingForBridgeTxStatus sets the inital tx
"requestId": "197c402f-cb96-4096-9f8c-54aed84ca776",
"srcAsset": {
"address": "0x0000000000000000000000000000000000000000",
"assetId": "eip155:42161/slip44:60",
"chainId": 42161,
"coinKey": "ETH",
"decimals": 18,
Expand All @@ -180,6 +188,7 @@ exports[`BridgeStatusController startPollingForBridgeTxStatus sets the inital tx
"destAmount": "990654755978612",
"destAsset": {
"address": "0x0000000000000000000000000000000000000000",
"assetId": "eip155:10/slip44:60",
"chainId": 10,
"coinKey": "ETH",
"decimals": 18,
Expand All @@ -198,6 +207,7 @@ exports[`BridgeStatusController startPollingForBridgeTxStatus sets the inital tx
"srcAmount": "991250000000000",
"srcAsset": {
"address": "0x0000000000000000000000000000000000000000",
"assetId": "eip155:42161/slip44:60",
"chainId": 42161,
"coinKey": "ETH",
"decimals": 18,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { ChainId } from '@metamask/bridge-controller';
import { flushPromises } from '../../../../test/lib/timer-helpers';
import { Numeric } from '../../../../shared/modules/Numeric';
import BridgeStatusController from './bridge-status-controller';
Expand Down Expand Up @@ -358,7 +359,7 @@ describe('BridgeStatusController', () => {
srcTxHash: '0xsrcTxHash2',
txMetaId: 'bridgeTxMetaId2',
srcChainId: 10,
destChainId: 123,
destChainId: ChainId.SOLANA,
}),
);
jest.advanceTimersByTime(10_000);
Expand All @@ -381,7 +382,7 @@ describe('BridgeStatusController', () => {
expect(
bridgeStatusController.state.bridgeStatusState.txHistory.bridgeTxMetaId2
.quote.destChainId,
).toEqual(123);
).toEqual(1151111081099710);

bridgeStatusController.wipeBridgeStatus({
address: '0xaccount1',
Expand Down Expand Up @@ -455,7 +456,7 @@ describe('BridgeStatusController', () => {
srcTxHash: '0xsrcTxHash2',
txMetaId: 'bridgeTxMetaId2',
srcChainId: 10,
destChainId: 123,
destChainId: 137,
}),
);
jest.advanceTimersByTime(10_000);
Expand All @@ -478,7 +479,7 @@ describe('BridgeStatusController', () => {
expect(
bridgeStatusController.state.bridgeStatusState.txHistory.bridgeTxMetaId2
.quote.destChainId,
).toEqual(123);
).toEqual(137);

bridgeStatusController.wipeBridgeStatus({
address: '0xaccount1',
Expand All @@ -491,7 +492,7 @@ describe('BridgeStatusController', () => {
);
expect(txHistoryItems).toHaveLength(1);
expect(txHistoryItems[0].quote.srcChainId).toEqual(10);
expect(txHistoryItems[0].quote.destChainId).toEqual(123);
expect(txHistoryItems[0].quote.destChainId).toEqual(137);
});
});
});
6 changes: 6 additions & 0 deletions app/scripts/controllers/bridge-status/mocks.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { TransactionMeta } from '@metamask/transaction-controller';
import { getNativeAssetForChainId } from '@metamask/bridge-controller';
import {
BridgeId,
StatusResponse,
Expand Down Expand Up @@ -123,6 +124,7 @@ export const getMockQuote = ({
srcTokenAmount: '991250000000000',
srcAsset: {
address: '0x0000000000000000000000000000000000000000',
assetId: getNativeAssetForChainId(srcChainId).assetId,
chainId: srcChainId,
symbol: 'ETH',
decimals: 18,
Expand All @@ -137,6 +139,7 @@ export const getMockQuote = ({
destTokenAmount: '990654755978612',
destAsset: {
address: '0x0000000000000000000000000000000000000000',
assetId: getNativeAssetForChainId(destChainId).assetId,
chainId: destChainId,
symbol: 'ETH',
decimals: 18,
Expand All @@ -152,6 +155,7 @@ export const getMockQuote = ({
amount: '8750000000000',
asset: {
address: '0x0000000000000000000000000000000000000000',
assetId: getNativeAssetForChainId(srcChainId).assetId,
chainId: srcChainId,
symbol: 'ETH',
decimals: 18,
Expand All @@ -178,6 +182,7 @@ export const getMockQuote = ({
},
srcAsset: {
address: '0x0000000000000000000000000000000000000000',
assetId: getNativeAssetForChainId(srcChainId).assetId,
chainId: srcChainId,
symbol: 'ETH',
decimals: 18,
Expand All @@ -190,6 +195,7 @@ export const getMockQuote = ({
},
destAsset: {
address: '0x0000000000000000000000000000000000000000',
assetId: getNativeAssetForChainId(destChainId).assetId,
chainId: destChainId,
symbol: 'ETH',
decimals: 18,
Expand Down
5 changes: 2 additions & 3 deletions app/scripts/controllers/bridge-status/utils.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
import { BRIDGE_CLIENT_ID } from '../../../../shared/constants/bridge';
import { BridgeClientId, type Quote } from '@metamask/bridge-controller';
import fetchWithCache from '../../../../shared/lib/fetch-with-cache';
import {
StatusResponse,
StatusRequestWithSrcTxHash,
StatusRequestDto,
} from '../../../../shared/types/bridge-status';
import type { Quote } from '../../../../shared/types/bridge';
import { validateResponse, validators } from './validators';
import { BRIDGE_STATUS_BASE_URL } from './constants';

const CLIENT_ID_HEADER = { 'X-Client-Id': BRIDGE_CLIENT_ID };
const CLIENT_ID_HEADER = { 'X-Client-Id': BridgeClientId.EXTENSION };

export const getStatusRequestDto = (
statusRequest: StatusRequestWithSrcTxHash,
Expand Down
Loading
Loading