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: incoming transactions by network #7154

Merged
merged 19 commits into from
Oct 19, 2023
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
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
7 changes: 0 additions & 7 deletions app/actions/privacy/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,6 @@ export function rejectHost(hostname) {
};
}

export function setThirdPartyApiMode(enabled) {
return {
type: 'SET_THIRD_PARTY_API_MODE',
enabled,
};
}

export function recordSRPRevealTimestamp(timestamp) {
return {
type: 'RECORD_SRP_REVEAL_TIMESTAMP',
Expand Down
20 changes: 15 additions & 5 deletions app/components/Nav/Main/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,16 @@ import { useEnableAutomaticSecurityChecks } from '../../hooks/EnableAutomaticSec
import { useMinimumVersions } from '../../hooks/MinimumVersions';
import navigateTermsOfUse from '../../../util/termsOfUse/termsOfUse';
import {
selectChainId,
selectProviderConfig,
selectProviderType,
} from '../../../selectors/networkController';
import WarningAlert from '../../../components/UI/WarningAlert/WarningAlert';
import { LINEA_MAINNET } from '../../../constants/network';
import jsonRpcRequest from '../../../util/jsonRpcRequest';
import { LINEA_MAINNET_RPC_URL } from '../../../constants/urls';
import { selectShowIncomingTransactionNetworks } from '../../../selectors/preferencesController';
import { toHexadecimal } from '../../../util/number';

const Stack = createStackNavigator();

Expand Down Expand Up @@ -106,13 +109,14 @@ const Main = (props) => {

useEffect(() => {
const { TransactionController } = Engine.context;
const currentHexChainId = `0x${toHexadecimal(props.chainId)}`;
tommasini marked this conversation as resolved.
Show resolved Hide resolved

if (props.thirdPartyApiMode) {
if (props.showIncomingTransactionsNetworks[currentHexChainId]) {
TransactionController.startIncomingTransactionPolling();
} else {
TransactionController.stopIncomingTransactionPolling();
}
}, [props.thirdPartyApiMode]);
}, [props.showIncomingTransactionsNetworks, props.chainId]);

const connectionChangeHandler = useCallback(
(state) => {
Expand Down Expand Up @@ -395,9 +399,9 @@ Main.propTypes = {
hideCurrentNotification: PropTypes.func,
removeNotificationById: PropTypes.func,
/**
* Indicates whether third party API mode is enabled
* Indicates whether networks allows incoming transactions
*/
thirdPartyApiMode: PropTypes.bool,
showIncomingTransactionsNetworks: PropTypes.object,
/**
* Network provider type
*/
Expand All @@ -418,11 +422,17 @@ Main.propTypes = {
* Object that represents the current route info like params passed to it
*/
route: PropTypes.object,
/**
* Current chain id
*/
chainId: PropTypes.string,
};

const mapStateToProps = (state) => ({
thirdPartyApiMode: state.privacy.thirdPartyApiMode,
showIncomingTransactionsNetworks:
selectShowIncomingTransactionNetworks(state),
providerType: selectProviderType(state),
chainId: selectChainId(state),
});

const mapDispatchToProps = (dispatch) => ({
Expand Down
3 changes: 0 additions & 3 deletions app/components/UI/Transactions/index.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@ const initialState = {
engine: {
backgroundState: initialBackgroundState,
},
privacy: {
thirdPartyApiMode: true,
},
settings: {
primaryCurrency: 'USD',
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ jest.mock('../../../core/Engine', () => ({

const initialState = {
navigation: { currentBottomNavRoute: 'Wallet' },
privacy: { thirdPartyApiMode: true },
settings: {
primaryCurrency: 'usd',
},
Expand Down Expand Up @@ -149,7 +148,6 @@ describe('Network Selector', () => {
it('toggle test network is disabled and is on when a testnet is selected', () => {
const { getByTestId } = renderComponent({
navigation: { currentBottomNavRoute: 'Wallet' },
privacy: { thirdPartyApiMode: true },
settings: {
primaryCurrency: 'usd',
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -242,10 +242,6 @@ class NetworkSettings extends PureComponent {
* returns an array of onboarded networks
*/
networkOnboardedState: PropTypes.object,
/**
* Indicates whether third party API mode is enabled
*/
thirdPartyApiMode: PropTypes.bool,
/**
* Checks if adding custom mainnet.
*/
Expand Down Expand Up @@ -1157,7 +1153,6 @@ const mapStateToProps = (state) => ({
providerConfig: selectProviderConfig(state),
networkConfigurations: selectNetworkConfigurations(state),
networkOnboardedState: state.networkOnboarded.networkOnboardedState,
thirdPartyApiMode: state.privacy.thirdPartyApiMode,
});

export default connect(mapStateToProps, mapDispatchToProps)(NetworkSettings);
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@ const initialState = {
networkOnboarded: {
networkOnboardedState: { '1': true },
},
privacy: {
thirdPartyApiMode: true,
},
};
const store = mockStore(initialState);

Expand Down
5 changes: 0 additions & 5 deletions app/components/Views/Settings/NetworksSettings/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,10 +133,6 @@ class NetworksSettings extends PureComponent {
* Current network provider configuration
*/
providerConfig: PropTypes.object,
/**
* Indicates whether third party API mode is enabled
*/
thirdPartyApiMode: PropTypes.bool,
};

actionSheet = null;
Expand Down Expand Up @@ -537,7 +533,6 @@ NetworksSettings.contextType = ThemeContext;
const mapStateToProps = (state) => ({
providerConfig: selectProviderConfig(state),
networkConfigurations: selectNetworkConfigurations(state),
thirdPartyApiMode: state.privacy.thirdPartyApiMode,
});

export default connect(mapStateToProps)(NetworksSettings);
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@ const initialState = {
engine: {
backgroundState: initialBackgroundState,
},
privacy: {
thirdPartyApiMode: true,
},
};
const store = mockStore(initialState);

Expand Down
Loading