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

Nonce management #1771

Merged
merged 13 commits into from
Dec 11, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
20 changes: 0 additions & 20 deletions e2e/parallel/shortcuts-settings.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -328,26 +328,6 @@ describe.runIf(browser !== 'firefox')(
expect(fastGasLabel).toBe(true);
});

it('should be able to toggle flashbots', async () => {
const defaultToggleStatus = await toggleStatus(
'flashbots-transactions-toggle',
driver,
);
expect(defaultToggleStatus).toBe('false');
await executePerformShortcut({
driver,
key: 'TAB',
timesToPress: 3,
});
await executePerformShortcut({ driver, key: 'ENTER' });
await delayTime('long');
const changedToggleStatus = await toggleStatus(
'flashbots-transactions-toggle',
driver,
);
expect(changedToggleStatus).toBe('true');
});

it('should be able navigate to currencies', async () => {
await executePerformShortcut({ driver, key: 'ARROW_LEFT' });
await executePerformShortcut({
Expand Down
56 changes: 0 additions & 56 deletions e2e/serial/swap/1_swapFlow1.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,43 +134,6 @@ it('should be able to go to swap settings and check rows are visible', async ()
driver,
});
expect(slippageRow).toBeTruthy();
await findElementByTestIdAndClick({
id: 'swap-settings-done',
driver,
});
});

it('should be able to go to settings and turn on flashbots', async () => {
await findElementByTestIdAndClick({ id: 'navbar-button-with-back', driver });
await findElementByTestIdAndClick({ id: 'home-page-header-right', driver });
await findElementByTestIdAndClick({ id: 'settings-link', driver });
await findElementByTestIdAndClick({ id: 'settings-transactions', driver });
await findElementByTestIdAndClick({
id: 'flashbots-transactions-toggle',
driver,
});
await findElementByTestIdAndClick({
id: 'navbar-button-with-back',
driver,
});
await findElementByTestIdAndClick({
id: 'navbar-button-with-back',
driver,
});
await findElementByTestIdAndClick({ id: 'header-link-swap', driver });
});

it('should be able to go to swap settings and check flashbots row is visible', async () => {
await findElementByTestIdAndClick({
id: 'swap-settings-navbar-button',
driver,
});

const flashbotsRow = await findElementByTestId({
id: 'swap-settings-flashbots-row',
driver,
});
expect(flashbotsRow).toBeTruthy();
});

it('should be able to interact with route settings', async () => {
Expand All @@ -192,25 +155,6 @@ it('should be able to interact with route settings', async () => {
});
});

it('should be able to interact with flashbots settings', async () => {
await findElementByTestIdAndClick({
id: 'swap-settings-flashbots-label',
driver,
});
await findElementByTestIdAndClick({
id: 'explainer-action-button',
driver,
});
await findElementByTestIdAndClick({
id: 'swap-settings-flashbots-toggle',
driver,
});
await findElementByTestIdAndClick({
id: 'swap-settings-flashbots-toggle',
driver,
});
});

it('should be able to interact with slippage settings', async () => {
await findElementByTestIdAndClick({
id: 'swap-settings-slippage-label',
Expand Down
11 changes: 0 additions & 11 deletions e2e/serial/swap/2_swapFlow2.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -570,17 +570,6 @@ describe('Swap Flow 2', () => {
driver,
});

// const flashbotsEnabledDetailsRow = await findElementByTestId({
// id: `flashbots-enabled-details-row`,
// driver,
// });
// expect(flashbotsEnabledDetailsRow).toBeTruthy();
// await findElementByTestIdAndClick({
// id: 'swap-review-flashbots-info-button',
// driver,
// });
// await findElementByTestIdAndClick({ id: 'explainer-action-button', driver });

const moreDetailsHiddendDetailsRow = await findElementByTestId({
id: `more-details-hidden-details-row`,
driver,
Expand Down
18 changes: 0 additions & 18 deletions src/analytics/event.ts
Original file line number Diff line number Diff line change
Expand Up @@ -193,14 +193,6 @@ export const event = {
* Called when user enables tracking in Settings.
*/
settingsAnalyticsTrackingEnabled: 'settings.analytics_tracking.enabled',
/**
* Called when user disables global Flashbots setting in Settings.
*/
settingsFlashbotsDisabled: 'settings.flashbots.disabled',
/**
* Called when user enables global Flashbots setting in Settings.
*/
settingsFlashbotsEnabled: 'settings.flashbots.enabled',
/**
* Called when user disables Rainbow as default provider in Settings.
*/
Expand Down Expand Up @@ -296,10 +288,6 @@ export type EventProperties = {
* Mainnet contract address of the mapped assets.
*/
mainnetAddress: string;
/**
* Whether Flashbots was used for the swap.
*/
flashbots: boolean;
/**
* The estimated USD value of the swap.
*/
Expand Down Expand Up @@ -782,8 +770,6 @@ export type EventProperties = {
[event.settingsAnalyticsTrackingEnabled]: undefined;
[event.settingsRainbowDefaultProviderDisabled]: undefined;
[event.settingsRainbowDefaultProviderEnabled]: undefined;
[event.settingsFlashbotsDisabled]: undefined;
[event.settingsFlashbotsEnabled]: undefined;
[event.swapOpened]: {
/**
* Entrypoint of the swaps flow.
Expand Down Expand Up @@ -851,10 +837,6 @@ export type EventProperties = {
* Whether the swap was a cross-chain swap.
*/
crosschain: boolean;
/**
* Whether Flashbots was used for the swap.
*/
flashbots: boolean;
/**
* The estimated USD value of the swap.
*/
Expand Down
3 changes: 0 additions & 3 deletions src/core/firebase/remoteConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ export interface RainbowConfig extends Record<string, any> {
send_enabled: boolean;
swaps_enabled: boolean;
tx_requests_enabled: boolean;
flashbots_enabled: boolean;
rpc_proxy_enabled: boolean;
points_enabled: boolean;
defi_positions_enabled: boolean;
Expand Down Expand Up @@ -51,7 +50,6 @@ const DEFAULT_CONFIG = {
send_enabled: true,
swaps_enabled: true,
tx_requests_enabled: true,
flashbots_enabled: true,
rpc_proxy_enabled: true,
points_enabled: true,
defi_positions_enabled: false,
Expand Down Expand Up @@ -116,7 +114,6 @@ export const init = async () => {
key === 'BX_send_enabled' ||
key === 'BX_swaps_enabled' ||
key === 'BX_tx_requests_enabled' ||
key === 'BX_flashbots_enabled' ||
key === 'BX_rpc_proxy_enabled' ||
key === 'BX_points_enabled' ||
key === 'BX_defi_positions_enabled' ||
Expand Down
1 change: 0 additions & 1 deletion src/core/raps/actions/claimBridge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,6 @@ export async function claimBridge({
nonce: swap.nonce,
status: 'pending',
type: 'bridge',
flashbots: false,
...gasParams,
} satisfies NewTransaction;

Expand Down
1 change: 0 additions & 1 deletion src/core/raps/actions/crosschainSwap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,6 @@ export const crosschainSwap = async ({
nonce: swap.nonce,
status: 'pending',
type: isBridge ? 'bridge' : 'swap',
flashbots: parameters.flashbots,
...gasParams,
} satisfies NewTransaction;

Expand Down
1 change: 0 additions & 1 deletion src/core/raps/actions/swap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,6 @@ export const swap = async ({
nonce: swap.nonce,
status: 'pending',
type: 'swap',
flashbots: parameters.flashbots,
...gasParams,
} satisfies NewTransaction;

Expand Down
6 changes: 1 addition & 5 deletions src/core/raps/execute.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,23 +70,21 @@ export async function executeAction<T extends RapActionTypes>({
index,
baseNonce,
rapName,
flashbots,
}: {
action: RapAction<T>;
wallet: Signer;
rap: Rap;
index: number;
baseNonce?: number;
rapName: string;
flashbots?: boolean;
}): Promise<RapActionResponse> {
const { type, parameters } = action;
try {
const actionProps = {
wallet,
currentRap: rap,
index,
parameters: { ...parameters, flashbots },
parameters,
baseNonce,
};
const { nonce, hash } = (await typeAction<T>(
Expand Down Expand Up @@ -169,7 +167,6 @@ export const walletExecuteRap = async (
index: 0,
baseNonce: nonce,
rapName,
flashbots: parameters?.flashbots,
};
const {
baseNonce,
Expand All @@ -192,7 +189,6 @@ export const walletExecuteRap = async (
index,
baseNonce,
rapName,
flashbots: parameters?.flashbots,
};
const { hash } = await executeAction(actionParams);
latestHash = hash;
Expand Down
1 change: 0 additions & 1 deletion src/core/raps/references.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ export interface RapSwapActionParameters<
assetToSell: ParsedAsset;
assetToBuy: ParsedAsset;
nonce?: number;
flashbots?: boolean;
quote: QuoteTypeMap[T];
address?: Address;
}
Expand Down
12 changes: 12 additions & 0 deletions src/core/references/chains.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ const BACKEND_CHAINS = transformBackendNetworksToChains(
backendNetworks.networks,
);

const DEFAULT_PRIVATE_MEMPOOL_TIMEOUT = 2 * 60 * 1_000; // 2 minutes

export const SUPPORTED_CHAINS: Chain[] = IS_TESTING
? [...BACKEND_CHAINS, chainHardhat, chainHardhatOptimism]
: BACKEND_CHAINS;
Expand Down Expand Up @@ -52,6 +54,16 @@ export const chainsLabel: Record<number, string> =
{} as Record<number, string>,
);

export const chainsPrivateMempoolTimeout: Record<number, number> =
backendNetworks.networks.reduce(
(acc, backendNetwork: BackendNetwork) => {
acc[parseInt(backendNetwork.id, 10)] =
backendNetwork.privateMempoolTimeout || DEFAULT_PRIVATE_MEMPOOL_TIMEOUT;
return acc;
},
{} as Record<number, number>,
);

export const chainsName: Record<number, string> =
backendNetworks.networks.reduce(
(acc, backendNetwork: BackendNetwork) => {
Expand Down
59 changes: 0 additions & 59 deletions src/core/state/currentSettings/flashbotsEnabled.ts

This file was deleted.

4 changes: 0 additions & 4 deletions src/core/state/currentSettings/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,6 @@ export {
currentThemeStore,
useCurrentThemeStore,
} from './currentTheme';
export {
flashbotsEnabledStore,
useFlashbotsEnabledStore,
} from './flashbotsEnabled';
export {
isDefaultWalletStore,
useIsDefaultWalletStore,
Expand Down
2 changes: 0 additions & 2 deletions src/core/state/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,12 @@ export {
currentCurrencyStore,
currentLanguageStore,
currentThemeStore,
flashbotsEnabledStore,
isDefaultWalletStore,
useCurrentAddressStore,
useCurrentChainIdStore,
useCurrentCurrencyStore,
useCurrentLanguageStore,
useCurrentThemeStore,
useFlashbotsEnabledStore,
useIsDefaultWalletStore,
} from './currentSettings';
export { deviceIdStore, useDeviceIdStore } from './device';
Expand Down
Loading
Loading