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

feat: upgrade transaction controller to get incoming transactions using accounts API #12419

Merged
merged 26 commits into from
Dec 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
33e2207
Use preview build
matthewwalsh0 Nov 17, 2024
7bc1d9b
Fix unit tests
matthewwalsh0 Nov 17, 2024
abbaa54
Add global network unit tests
matthewwalsh0 Nov 18, 2024
93dde7c
Add network client ID to addTransaction calls
matthewwalsh0 Nov 18, 2024
753e7a4
Update incoming transaction polling
matthewwalsh0 Nov 18, 2024
0ec8217
Add network client ID to Redux transaction
matthewwalsh0 Nov 19, 2024
3d7675d
Use preview build
matthewwalsh0 Nov 22, 2024
d52d8b3
Add initial E2E test
matthewwalsh0 Nov 23, 2024
16fb43c
Add E2E tests
matthewwalsh0 Nov 25, 2024
3b8800d
Update yarn lock
matthewwalsh0 Nov 25, 2024
6e7d2e0
Merge branch 'main' into feat/incoming-transactions-accounts-api
matthewwalsh0 Nov 25, 2024
77e1f90
Fix unit tests and linting
matthewwalsh0 Nov 25, 2024
3d85274
Fix linting
matthewwalsh0 Nov 25, 2024
22db95c
Fix nonce bug
matthewwalsh0 Nov 26, 2024
ad5b14a
Merge branch 'main' into feat/incoming-transactions-accounts-api
matthewwalsh0 Nov 26, 2024
173aa38
Merge branch 'main' into refactor/transaction-controller-remove-globa…
matthewwalsh0 Nov 26, 2024
1c70add
Fix incoming transaction notifications
matthewwalsh0 Nov 26, 2024
0082698
Merge branch 'main' into refactor/transaction-controller-remove-globa…
matthewwalsh0 Nov 26, 2024
b7e5bc7
Merge branch 'refactor/transaction-controller-remove-global-network' …
matthewwalsh0 Nov 26, 2024
15501d1
Fix E2E tests
matthewwalsh0 Nov 26, 2024
5e79585
Add notification E2E test
matthewwalsh0 Nov 27, 2024
cefe61f
Merge branch 'main' into feat/incoming-transactions-accounts-api
matthewwalsh0 Dec 7, 2024
60d2b91
Update Yarn lock
matthewwalsh0 Dec 7, 2024
9225952
Fix linting
matthewwalsh0 Dec 7, 2024
687abdc
Fix E2E tests
matthewwalsh0 Dec 7, 2024
b9d4e82
Fix E2E tests
matthewwalsh0 Dec 9, 2024
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 .js.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
export MM_PUBNUB_SUB_KEY=""
export MM_PUBNUB_PUB_KEY=""
export MM_OPENSEA_KEY=""
export MM_ETHERSCAN_KEY=""
export MM_FOX_CODE="EXAMPLE_FOX_CODE"

# NOTE: Non-MetaMask only, will need to create an account and generate
Expand Down
6 changes: 3 additions & 3 deletions app/components/Nav/Main/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ const Main = (props) => {
stopIncomingTransactionPolling();

if (showIncomingTransactionsNetworks[chainId]) {
startIncomingTransactionPolling([networkClientId]);
startIncomingTransactionPolling([chainId]);
}
}, [chainId, networkClientId, showIncomingTransactionsNetworks]);

Expand Down Expand Up @@ -178,11 +178,11 @@ const Main = (props) => {
removeNotVisibleNotifications();

BackgroundTimer.runBackgroundTimer(async () => {
await updateIncomingTransactions([props.networkClientId]);
await updateIncomingTransactions([props.chainId]);
}, AppConstants.TX_CHECK_BACKGROUND_FREQUENCY);
}
},
[backgroundMode, removeNotVisibleNotifications, props.networkClientId],
[backgroundMode, removeNotVisibleNotifications, props.chainId],
);

const initForceReload = () => {
Expand Down
10 changes: 4 additions & 6 deletions app/components/UI/NetworkCell/NetworkCell.tsx
Original file line number Diff line number Diff line change
@@ -1,23 +1,21 @@
import React from 'react';
import { Switch, ImageSourcePropType } from 'react-native';
import { ETHERSCAN_SUPPORTED_NETWORKS } from '@metamask/transaction-controller';
import { useStyles } from '../../../component-library/hooks';
import Cell from '../../../component-library/components/Cells/Cell/Cell';
import { CellVariant } from '../../../component-library/components/Cells/Cell';
import { AvatarVariant } from '../../../component-library/components/Avatars/Avatar/Avatar.types';
import { useTheme } from '../../../util/theme';
import { EtherscanSupportedHexChainId } from '@metamask/preferences-controller';
import styleSheet from './NetworkCell.styles';
import { Hex } from '@metamask/utils';

const supportedNetworks = ETHERSCAN_SUPPORTED_NETWORKS;
interface NetworkCellProps {
name: string;
chainId: EtherscanSupportedHexChainId | keyof typeof supportedNetworks;
chainId: Hex;
imageSource: ImageSourcePropType;
secondaryText: string;
secondaryText?: string;
showIncomingTransactionsNetworks: Record<string, boolean>;
toggleEnableIncomingTransactions: (
chainId: EtherscanSupportedHexChainId,
chainId: Hex,
value: boolean,
) => void;
testID?: string;
Expand Down
2 changes: 1 addition & 1 deletion app/components/UI/Notification/BaseNotification/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ const getTitle = (status, { nonce, amount, assetType }) => {
};

export const getDescription = (status, { amount = null, type = null }) => {
if (amount && typeof amount !== 'object') {
if (amount && typeof amount !== 'object' && type) {
return strings(`notifications.${type}_${status}_message`, { amount });
}
return strings(`notifications.${status}_message`);
Expand Down
10 changes: 4 additions & 6 deletions app/components/UI/Transactions/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ import {
} from '../../../util/transaction-controller';
import { selectGasFeeEstimates } from '../../../selectors/confirmTransaction';
import { decGWEIToHexWEI } from '../../../util/conversions';
import { ActivitiesViewSelectorsIDs } from '../../../../e2e/selectors/Transactions/ActivitiesView.selectors';

const createStyles = (colors, typography) =>
StyleSheet.create({
Expand Down Expand Up @@ -207,10 +208,6 @@ class Transactions extends PureComponent {
*/
onScrollThroughContent: PropTypes.func,
gasFeeEstimates: PropTypes.object,
/**
* ID of the global network client
*/
networkClientId: PropTypes.string,
};

static defaultProps = {
Expand Down Expand Up @@ -346,11 +343,11 @@ class Transactions extends PureComponent {
};

onRefresh = async () => {
const { networkClientId } = this.props;
const { chainId } = this.props;

this.setState({ refreshing: true });

await updateIncomingTransactions([networkClientId]);
await updateIncomingTransactions([chainId]);

this.setState({ refreshing: false });
};
Expand Down Expand Up @@ -785,6 +782,7 @@ class Transactions extends PureComponent {
<PriceChartContext.Consumer>
{({ isChartBeingTouched }) => (
<FlatList
testID={ActivitiesViewSelectorsIDs.CONTAINER}
ref={this.flatList}
getItemLayout={this.getItemLayout}
data={transactions}
Expand Down
8 changes: 2 additions & 6 deletions app/components/Views/Asset/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -165,10 +165,6 @@ class Asset extends PureComponent {
* Boolean that indicates if native token is supported to buy
*/
isNetworkBuyNativeTokenSupported: PropTypes.bool,
/**
* ID of the global network client
*/
networkClientId: PropTypes.string,
};

state = {
Expand Down Expand Up @@ -441,11 +437,11 @@ class Asset extends PureComponent {
};

onRefresh = async () => {
const { networkClientId } = this.props;
const { chainId } = this.props;

this.setState({ refreshing: true });

await updateIncomingTransactions([networkClientId]);
await updateIncomingTransactions([chainId]);

this.setState({ refreshing: false });
};
Expand Down
2 changes: 1 addition & 1 deletion app/components/Views/NetworkSelector/NetworkSelector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ const NetworkSelector = () => {
AccountTrackerController.refresh();

setTimeout(async () => {
await updateIncomingTransactions([clientId]);
await updateIncomingTransactions([networkConfiguration.chainId]);
}, 1000);
}

Expand Down
Loading
Loading