Skip to content

Commit

Permalink
feat: enforce single import block (#913)
Browse files Browse the repository at this point in the history
* feat: enforce single import block

* chore: collapse into one import block

---------

Co-authored-by: Paul <[email protected]>
  • Loading branch information
james-a-morris and pxrl authored Aug 31, 2023
1 parent 723bdcf commit 7bbb495
Show file tree
Hide file tree
Showing 46 changed files with 699 additions and 372 deletions.
1 change: 1 addition & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ module.exports = {
// Disable warnings for { a, b, ...rest } variables, since this is typically used to remove variables.
"@typescript-eslint/no-unused-vars": ["error", { ignoreRestSiblings: true }],
"chai-expect/missing-assertion": 2,
"no-duplicate-imports": "error",
},
settings: {
node: {
Expand Down
6 changes: 3 additions & 3 deletions src/clients/BundleDataClient.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { winston, BigNumber, toBN } from "../utils";
import * as _ from "lodash";
import {
DepositWithBlock,
Expand All @@ -11,12 +10,13 @@ import {
} from "../interfaces";
import { SpokePoolClient } from "../clients";
import {
winston,
BigNumber,
toBN,
assignValidFillToFillsToRefund,
getRefundInformationFromFill,
updateTotalRefundAmount,
updateTotalRealizedLpFeePct,
} from "../utils";
import {
flattenAndFilterUnfilledDepositsByOriginChain,
updateUnfilledDepositsWithMatchedDeposit,
getUniqueDepositsInRange,
Expand Down
15 changes: 13 additions & 2 deletions src/clients/TokenClient.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,18 @@
import { BigNumber, winston, assign, ERC20, Contract, toBN, MAX_SAFE_ALLOWANCE } from "../utils";
import { runTransaction, getNetworkName, blockExplorerLink, MAX_UINT_VAL } from "../utils";
import { HubPoolClient, SpokePoolClient } from ".";
import { Deposit } from "../interfaces";
import {
BigNumber,
Contract,
ERC20,
MAX_SAFE_ALLOWANCE,
MAX_UINT_VAL,
assign,
blockExplorerLink,
getNetworkName,
runTransaction,
toBN,
winston,
} from "../utils";

type TokenDataType = { [chainId: number]: { [token: string]: { balance: BigNumber; allowance: BigNumber } } };
type TokenShortfallType = {
Expand Down
8 changes: 5 additions & 3 deletions src/clients/bridges/ArbitrumAdapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,15 @@ import {
isDefined,
TransactionResponse,
resolveTokenSymbols,
toBN,
toWei,
paginatedEventQuery,
Event,
} from "../../utils";
import { toBN, toWei, paginatedEventQuery, Event } from "../../utils";
import { SpokePoolClient } from "../../clients";
import { BaseAdapter } from "./BaseAdapter";
import { SortableEvent } from "../../interfaces";
import { SortableEvent, OutstandingTransfers } from "../../interfaces";
import { constants } from "@across-protocol/sdk-v2";
import { OutstandingTransfers } from "../../interfaces";
import { CONTRACT_ADDRESSES } from "../../common";
const { TOKEN_SYMBOLS_MAP, CHAIN_IDs } = constants;

Expand Down
25 changes: 14 additions & 11 deletions src/clients/bridges/BaseAdapter.ts
Original file line number Diff line number Diff line change
@@ -1,32 +1,35 @@
/* eslint-disable @typescript-eslint/ban-types */
import { constants as sdkConstants } from "@across-protocol/sdk-v2";
import { Provider } from "@ethersproject/abstract-provider";
import { Signer } from "@ethersproject/abstract-signer";
import { constants as sdkConstants } from "@across-protocol/sdk-v2";
import { AugmentedTransaction, SpokePoolClient, TransactionClient } from "../../clients";
import {
toBN,
MAX_SAFE_ALLOWANCE,
AnyObject,
BigNumber,
Contract,
DefaultLogLevels,
ERC20,
winston,
EventSearchConfig,
DefaultLogLevels,
MAX_SAFE_ALLOWANCE,
MAX_UINT_VAL,
MakeOptional,
AnyObject,
BigNumber,
matchTokenSymbol,
TransactionResponse,
ZERO_ADDRESS,
assert,
blockExplorerLink,
compareAddressesSimple,
formatUnitsForToken,
getNetworkName,
matchTokenSymbol,
runTransaction,
toBN,
winston,
createFormatFunction,
BigNumberish,
} from "../../utils";
import { blockExplorerLink, getNetworkName, MAX_UINT_VAL, runTransaction } from "../../utils";

import { OutstandingTransfers, SortableEvent } from "../../interfaces";
import { TransactionResponse } from "../../utils";
import { CONTRACT_ADDRESSES } from "../../common";
import { OutstandingTransfers, SortableEvent } from "../../interfaces";
interface DepositEvent extends SortableEvent {
amount: BigNumber;
to: string;
Expand Down
7 changes: 4 additions & 3 deletions src/clients/bridges/PolygonAdapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,14 @@ import {
BigNumberish,
TransactionResponse,
resolveTokenSymbols,
ZERO_ADDRESS,
spreadEventWithBlockNumber,
paginatedEventQuery,
} from "../../utils";
import { ZERO_ADDRESS, spreadEventWithBlockNumber, paginatedEventQuery } from "../../utils";
import { SpokePoolClient } from "../../clients";
import { BaseAdapter } from "./";
import { SortableEvent } from "../../interfaces";
import { SortableEvent, OutstandingTransfers } from "../../interfaces";
import { constants } from "@across-protocol/sdk-v2";
import { OutstandingTransfers } from "../../interfaces";
import { CONTRACT_ADDRESSES } from "../../common";
const { TOKEN_SYMBOLS_MAP, CHAIN_IDs } = constants;

Expand Down
7 changes: 4 additions & 3 deletions src/clients/bridges/op-stack/OpStackAdapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,13 @@ import {
Event,
checkAddressChecksum,
ethers,
spreadEventWithBlockNumber,
assign,
winston,
} from "../../../utils";
import { spreadEventWithBlockNumber, assign, winston } from "../../../utils";
import { SpokePoolClient } from "../..";
import { BaseAdapter } from "..";
import { SortableEvent } from "../../../interfaces";
import { OutstandingTransfers } from "../../../interfaces";
import { SortableEvent, OutstandingTransfers } from "../../../interfaces";
import { CONTRACT_ADDRESSES } from "../../../common";
import { constants } from "@across-protocol/sdk-v2";
import { OpStackBridge } from "./OpStackBridgeInterface";
Expand Down
9 changes: 4 additions & 5 deletions src/dataworker/Dataworker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@ import {
isDefined,
buildPoolRebalanceLeafTree,
updateTotalRefundAmountRaw,
toBNWei,
getFillsInRange,
ZERO_ADDRESS,
} from "../utils";
import { toBNWei, getFillsInRange, ZERO_ADDRESS } from "../utils";
import {
DepositWithBlock,
FillsToRefund,
Expand All @@ -22,16 +24,14 @@ import {
SlowFillLeaf,
SpokePoolClientsByChain,
UnfilledDeposit,
} from "../interfaces";
import {
PendingRootBundle,
RunningBalances,
PoolRebalanceLeaf,
RelayerRefundLeaf,
BigNumberForToken,
} from "../interfaces";
import { DataworkerClients } from "./DataworkerClientHelper";
import { SpokePoolClient, UBAClient } from "../clients";
import { SpokePoolClient, UBAClient, BalanceAllocator } from "../clients";
import * as PoolRebalanceUtils from "./PoolRebalanceUtils";
import {
blockRangesAreInvalidForSpokeClients,
Expand All @@ -45,7 +45,6 @@ import {
_buildRelayerRefundRoot,
_buildSlowRelayRoot,
} from "./DataworkerUtils";
import { BalanceAllocator } from "../clients";
import _ from "lodash";
import { spokePoolClientsToProviders } from "../common";
import * as sdk from "@across-protocol/sdk-v2";
Expand Down
37 changes: 25 additions & 12 deletions src/dataworker/DataworkerUtils.ts
Original file line number Diff line number Diff line change
@@ -1,36 +1,49 @@
import { utils } from "@across-protocol/sdk-v2";
import { SpokePoolClient } from "../clients";
import { spokesThatHoldEthAndWeth } from "../common/Constants";
import { CONTRACT_ADDRESSES } from "../common/ContractAddresses";
import {
BigNumberForToken,
DepositWithBlock,
FillsToRefund,
FillWithBlock,
PoolRebalanceLeaf,
RelayerRefundLeaf,
RelayerRefundLeafWithGroup,
RunningBalances,
SlowFillLeaf,
SpokePoolClientsByChain,
UnfilledDeposit,
} from "../interfaces";
import { RelayerRefundLeaf } from "../interfaces";
import { RelayerRefundLeafWithGroup, RunningBalances, UnfilledDeposit } from "../interfaces";
import {
AnyObject,
buildPoolRebalanceLeafTree,
buildRelayerRefundTree,
buildSlowRelayTree,
getDepositPath,
getFillsInRange,
groupObjectCountsByProp,
groupObjectCountsByTwoProps,
isDefined,
MerkleTree,
toBN,
winston,
} from "../utils";
import { getDepositPath, getFillsInRange, groupObjectCountsByProp, groupObjectCountsByTwoProps, toBN } from "../utils";
import { PoolRebalanceRoot } from "./Dataworker";
import { DataworkerClients } from "./DataworkerClientHelper";
import { addSlowFillsToRunningBalances, initializeRunningBalancesFromRelayerRepayments } from "./PoolRebalanceUtils";
import { addLastRunningBalance, constructPoolRebalanceLeaves } from "./PoolRebalanceUtils";
import { updateRunningBalanceForDeposit } from "./PoolRebalanceUtils";
import { subtractExcessFromPreviousSlowFillsFromRunningBalances } from "./PoolRebalanceUtils";
import { getAmountToReturnForRelayerRefundLeaf } from "./RelayerRefundUtils";
import { sortRefundAddresses, sortRelayerRefundLeaves } from "./RelayerRefundUtils";
import { utils } from "@across-protocol/sdk-v2";
import { CONTRACT_ADDRESSES } from "../common/ContractAddresses";
import { spokesThatHoldEthAndWeth } from "../common/Constants";
import {
addLastRunningBalance,
addSlowFillsToRunningBalances,
constructPoolRebalanceLeaves,
initializeRunningBalancesFromRelayerRepayments,
subtractExcessFromPreviousSlowFillsFromRunningBalances,
updateRunningBalanceForDeposit,
} from "./PoolRebalanceUtils";
import {
getAmountToReturnForRelayerRefundLeaf,
sortRefundAddresses,
sortRelayerRefundLeaves,
} from "./RelayerRefundUtils";
export const { getImpliedBundleBlockRanges, getBlockRangeForChain, getBlockForChain } = utils;

export function getEndBlockBuffers(
Expand Down
24 changes: 12 additions & 12 deletions src/dataworker/PoolRebalanceUtils.ts
Original file line number Diff line number Diff line change
@@ -1,34 +1,34 @@
import { ConfigStoreClient, HubPoolClient, SpokePoolClient } from "../clients";
import { Clients } from "../common";
import * as interfaces from "../interfaces";
import {
BigNumberForToken,
PendingRootBundle,
PoolRebalanceLeaf,
RelayerRefundLeaf,
PendingRootBundle,
RunningBalances,
UnfilledDeposit,
SpokePoolTargetBalance,
SpokePoolClientsByChain,
SlowFillLeaf,
SpokePoolClientsByChain,
SpokePoolTargetBalance,
UnfilledDeposit,
} from "../interfaces";
import {
assign,
AnyObject,
BigNumber,
MerkleTree,
assign,
compareAddresses,
convertFromWei,
formatFeePct,
getFillDataForSlowFillFromPreviousRootBundle,
getRefund,
shortenHexString,
shortenHexStrings,
toBN,
MerkleTree,
winston,
toBNWei,
formatFeePct,
getRefund,
AnyObject,
winston,
} from "../utils";
import { DataworkerClients } from "./DataworkerClientHelper";
import { getFillDataForSlowFillFromPreviousRootBundle } from "../utils";
import { Clients } from "../common";

export function updateRunningBalance(
runningBalances: interfaces.RunningBalances,
Expand Down
7 changes: 3 additions & 4 deletions src/finalizer/utils/zkSync.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import { interfaces, utils as sdkUtils } from "@across-protocol/sdk-v2";
import { Contract, ethers, Wallet } from "ethers";
import { Provider as zksProvider, types as zkTypes, utils as zkUtils, Wallet as zkWallet } from "zksync-web3";
import { groupBy } from "lodash";
import { interfaces, utils as sdkUtils } from "@across-protocol/sdk-v2";
import { Provider as zksProvider, types as zkTypes, utils as zkUtils, Wallet as zkWallet } from "zksync-web3";
import { HubPoolClient, SpokePoolClient } from "../../clients";
import { CONTRACT_ADDRESSES, Multicall2Call } from "../../common";
import { convertFromWei, getEthAddressForChain, winston } from "../../utils";
import { zkSync as zkSyncUtils } from "../../utils";
import { convertFromWei, getEthAddressForChain, winston, zkSync as zkSyncUtils } from "../../utils";
import { FinalizerPromise, Withdrawal } from "../types";

type Provider = ethers.providers.Provider;
Expand Down
22 changes: 13 additions & 9 deletions src/relayer/Relayer.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,26 @@
import { utils as sdkUtils } from "@across-protocol/sdk-v2";
import { constants as ethersConstants } from "ethers";
import { groupBy } from "lodash";
import { utils as sdkUtils } from "@across-protocol/sdk-v2";
import { Deposit, DepositWithBlock, FillWithBlock, L1Token, RefundRequestWithBlock } from "../interfaces";
import {
BigNumber,
isDefined,
winston,
RelayerUnfilledDeposit,
blockExplorerLink,
buildFillRelayProps,
getNetworkName,
buildFillRelayWithUpdatedFeeProps,
createFormatFunction,
formatFeePct,
getBlockForTimestamp,
getUnfilledDeposits,
getCurrentTime,
buildFillRelayWithUpdatedFeeProps,
getNetworkName,
getUnfilledDeposits,
isDefined,
isDepositSpedUp,
RelayerUnfilledDeposit,
toBN,
toBNWei,
winston,
} from "../utils";
import { createFormatFunction, blockExplorerLink, formatFeePct, toBN, toBNWei } from "../utils";
import { RelayerClients } from "./RelayerClientHelper";
import { Deposit, DepositWithBlock, FillWithBlock, L1Token, RefundRequestWithBlock } from "../interfaces";
import { RelayerConfig } from "./RelayerConfig";

const UNPROFITABLE_DEPOSIT_NOTICE_PERIOD = 60 * 60; // 1 hour
Expand Down
18 changes: 12 additions & 6 deletions src/relayer/RelayerClientHelper.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
import { clients as sdkClients, utils as sdkUtils } from "@across-protocol/sdk-v2";
import winston from "winston";
import { utils as sdkUtils, clients as sdkClients } from "@across-protocol/sdk-v2";
import { Wallet } from "../utils";
import { TokenClient, ProfitClient, BundleDataClient, InventoryClient, AcrossApiClient, UBAClient } from "../clients";
import { AcrossApiClient, BundleDataClient, InventoryClient, ProfitClient, TokenClient, UBAClient } from "../clients";
import { AdapterManager, CrossChainTransferClient } from "../clients/bridges";
import { RelayerConfig } from "./RelayerConfig";
import { CONTRACT_ADDRESSES, Clients, constructClients, updateClients, updateSpokePoolClients } from "../common";
import {
CONTRACT_ADDRESSES,
Clients,
constructClients,
constructSpokePoolClientsWithLookback,
updateClients,
updateSpokePoolClients,
} from "../common";
import { SpokePoolClientsByChain } from "../interfaces";
import { constructSpokePoolClientsWithLookback } from "../common";
import { Wallet } from "../utils";
import { RelayerConfig } from "./RelayerConfig";

export interface RelayerClients extends Clients {
spokePoolClients: SpokePoolClientsByChain;
Expand Down
Loading

0 comments on commit 7bbb495

Please sign in to comment.