Skip to content
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

chore: Bump @metamask/swaps-controller to 12.0.0 #12378

Merged
merged 32 commits into from
Jan 8, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
5f144ec
Upgrade `@metamask/swaps-controller` to 12.0.0
mcmire Nov 21, 2024
e29501d
Try disabling sharp everywhere to see if CI will pass
mcmire Dec 9, 2024
642155c
Remove duplicate pollCountLimit option
mcmire Dec 9, 2024
657e5a9
Remove node-addon-api
mcmire Dec 9, 2024
30996a3
Merge branch 'main' into bump-swaps-controller
mcmire Dec 10, 2024
0028c5e
Attempt to delete these patches and see what happens
mcmire Dec 10, 2024
cee60bb
It should not be necessary to disable sharp
mcmire Dec 10, 2024
6408c06
Revert "Attempt to delete these patches and see what happens"
mcmire Dec 10, 2024
1d5554f
Reapply "Attempt to delete these patches and see what happens"
mcmire Dec 10, 2024
b9bcce0
Bring this patch back
mcmire Dec 10, 2024
f0b8d7d
Merge branch 'main' into bump-swaps-controller
mcmire Dec 11, 2024
1c2a362
Revert this code and see what happens
mcmire Dec 11, 2024
f3c4cc2
Merge branch 'main' into bump-swaps-controller
mcmire Dec 11, 2024
7c32a0e
Fix fetching quotes on Optimism
mcmire Dec 12, 2024
3ed887b
Fix lint violation
mcmire Dec 12, 2024
3b9fc3d
Fix another lint violation
mcmire Dec 12, 2024
24e1a95
TEMP - Remove Goerli and Linea Goerli from state to prevent bad requests
mcmire Dec 12, 2024
07e1194
Merge branch 'main' into bump-swaps-controller
mcmire Dec 12, 2024
e7c3256
fixup! 24e1a95ff3fdd65d173d3a5122c82af5c5e39e87
mcmire Dec 12, 2024
d235bd1
fixup! 24e1a95ff3fdd65d173d3a5122c82af5c5e39e87
mcmire Dec 12, 2024
5e5fc9c
Merge branch 'main' into bump-swaps-controller
mcmire Dec 18, 2024
a47d8bf
Speed it up
mcmire Dec 18, 2024
c908f73
Clean up
mcmire Dec 18, 2024
a9e4fc3
Drop extra swaps-controller entry
mcmire Dec 18, 2024
64675c4
Use selectSelectedNetworkClientId consistently
mcmire Dec 19, 2024
3b6e4f3
Revert some changes to Engine.ts
mcmire Dec 19, 2024
45fe068
Fix lint violation
mcmire Dec 19, 2024
f435fde
Fix failing unit test
mcmire Dec 19, 2024
3b961a3
Add more test coverage
mcmire Dec 19, 2024
e7d331d
Merge branch 'main' into bump-swaps-controller
mcmire Dec 19, 2024
937f122
Merge branch 'main' into bump-swaps-controller
mcmire Jan 6, 2025
b906633
Merge branch 'main' into bump-swaps-controller
mcmire Jan 6, 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
16 changes: 9 additions & 7 deletions app/components/UI/AssetOverview/AssetOverview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@ import AppConstants from '../../../core/AppConstants';
import Engine from '../../../core/Engine';
import {
selectChainId,
selectTicker,
selectNativeCurrencyByChainId,
selectSelectedNetworkClientId,
selectTicker,
} from '../../../selectors/networkController';
import {
selectConversionRate,
Expand Down Expand Up @@ -58,7 +59,7 @@ import Routes from '../../../constants/navigation/Routes';
import TokenDetails from './TokenDetails';
import { RootState } from '../../../reducers';
import useGoToBridge from '../Bridge/utils/useGoToBridge';
import SwapsController, { swapsUtils } from '@metamask/swaps-controller';
import { swapsUtils } from '@metamask/swaps-controller';
import { MetaMetricsEvents } from '../../../core/Analytics';
import {
getDecimalChainId,
Expand Down Expand Up @@ -114,6 +115,7 @@ const AssetOverview: React.FC<AssetOverviewProps> = ({
? (asset.chainId as Hex)
: selectedChainId;
const ticker = isPortfolioViewEnabled() ? nativeCurrency : selectedTicker;
const selectedNetworkClientId = useSelector(selectSelectedNetworkClientId);

let currentAddress: Hex;

Expand All @@ -136,12 +138,12 @@ const AssetOverview: React.FC<AssetOverviewProps> = ({
const dispatch = useDispatch();

useEffect(() => {
const { SwapsController: SwapsControllerFromEngine } = Engine.context as {
SwapsController: SwapsController;
};
const { SwapsController } = Engine.context;
const fetchTokenWithCache = async () => {
try {
await SwapsControllerFromEngine.fetchTokenWithCache();
await SwapsController.fetchTokenWithCache({
networkClientId: selectedNetworkClientId,
});
// TODO: Replace "any" with type
// eslint-disable-next-line @typescript-eslint/no-explicit-any
} catch (error: any) {
Expand All @@ -152,7 +154,7 @@ const AssetOverview: React.FC<AssetOverviewProps> = ({
}
};
fetchTokenWithCache();
}, []);
}, [selectedNetworkClientId]);

const onReceive = () => {
navigation.navigate(Routes.QR_TAB_SWITCHER, {
Expand Down
14 changes: 11 additions & 3 deletions app/components/UI/Swaps/QuotesView.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
TouchableOpacity,
Linking,
} from 'react-native';
import { connect } from 'react-redux';
import { connect, useSelector } from 'react-redux';
import IonicIcon from 'react-native-vector-icons/Ionicons';
import MaterialCommunityIcons from 'react-native-vector-icons/MaterialCommunityIcons';
import BigNumber from 'bignumber.js';
Expand Down Expand Up @@ -96,7 +96,7 @@ import {
import {
selectChainId,
selectIsEIP1559Network,
selectNetworkClientId,
selectSelectedNetworkClientId,
selectTicker,
} from '../../../selectors/networkController';
import {
Expand Down Expand Up @@ -304,6 +304,7 @@ async function resetAndStartPolling({
destinationToken,
sourceAmount,
walletAddress,
networkClientId,
}) {
if (!sourceToken || !destinationToken) {
return;
Expand All @@ -316,6 +317,7 @@ async function resetAndStartPolling({
destinationToken,
sourceAmount,
walletAddress,
networkClientId,
});
await SwapsController.stopPollingAndResetState();
await SwapsController.startFetchAndSetQuotes(
Expand Down Expand Up @@ -762,6 +764,8 @@ function SwapsQuotesView({
}
}, [error, navigation]);

const selectedNetworkClientId = useSelector(selectSelectedNetworkClientId);

const handleRetryFetchQuotes = useCallback(() => {
if (error?.key === swapsUtils.SwapsError.QUOTES_EXPIRED_ERROR) {
navigation.setParams({ leftAction: strings('navigation.back') });
Expand All @@ -776,6 +780,7 @@ function SwapsQuotesView({
destinationToken,
sourceAmount,
walletAddress: selectedAddress,
networkClientId: selectedNetworkClientId,
});
} else {
navigation.pop();
Expand All @@ -788,6 +793,7 @@ function SwapsQuotesView({
sourceAmount,
selectedAddress,
navigation,
selectedNetworkClientId,
]);

const updateSwapsTransactions = useCallback(
Expand Down Expand Up @@ -1412,6 +1418,7 @@ function SwapsQuotesView({
destinationToken,
sourceAmount,
walletAddress: selectedAddress,
networkClientId: selectedNetworkClientId,
});

return () => {
Expand All @@ -1425,6 +1432,7 @@ function SwapsQuotesView({
slippage,
sourceAmount,
sourceToken.address,
selectedNetworkClientId,
]);

/** selectedQuote alert effect */
Expand Down Expand Up @@ -2403,7 +2411,7 @@ SwapsQuotesView.propTypes = {
const mapStateToProps = (state) => ({
accounts: selectAccounts(state),
chainId: selectChainId(state),
networkClientId: selectNetworkClientId(state),
networkClientId: selectSelectedNetworkClientId(state),
ticker: selectTicker(state),
balances: selectContractBalances(state),
selectedAddress: selectSelectedInternalAccountFormattedAddress(state),
Expand Down
10 changes: 9 additions & 1 deletion app/components/UI/Swaps/QuotesView.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import {
} from '../../../util/test/accountsControllerTestUtils';
import { SwapsViewSelectors } from '../../../../e2e/selectors/swaps/SwapsView.selectors';
import Engine from '../../../core/Engine';
import { RpcEndpointType } from '@metamask/network-controller';

jest.mock('../../../core/Engine', () => ({
context: {
Expand Down Expand Up @@ -203,7 +204,14 @@ const mockInitialState: DeepPartial<RootState> = {
defaultRpcEndpointIndex: 0,
name: 'Ethereum Mainnet',
nativeCurrency: 'ETH',
rpcEndpoints: [],
rpcEndpoints: [
{
name: 'Ethereum Mainnet',
networkClientId: 'mainnet',
type: RpcEndpointType.Infura,
url: 'https://mainnet.infura.io/v3/{infuraProjectId}',
},
],
},
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ exports[`QuotesView should render quote screen 1`] = `
}
}
>
Private Network
Ethereum Main Network
</Text>
</View>
</TouchableOpacity>
Expand Down
Loading
Loading