From b597ae21ef0e34731fc45bb44c5f029c29b8df7d Mon Sep 17 00:00:00 2001 From: james-a-morris Date: Thu, 7 Sep 2023 15:08:55 -0400 Subject: [PATCH] improve: further styles --- scripts/unwrapWeth.ts | 4 ++-- scripts/utils.ts | 2 +- scripts/zkSyncDemo.ts | 4 ++-- src/clients/BalanceAllocator.ts | 7 +------ src/clients/BundleDataClient.ts | 4 ++-- src/clients/TransactionClient.ts | 2 +- src/clients/bridges/ArbitrumAdapter.ts | 2 +- src/clients/bridges/PolygonAdapter.ts | 2 +- src/dataworker/Dataworker.ts | 2 +- src/finalizer/utils/zkSync.ts | 2 +- src/monitor/Monitor.ts | 6 +++--- src/scripts/testUBAClient.ts | 2 +- src/scripts/validateRootBundle.ts | 2 +- src/scripts/validateRunningBalances.ts | 2 +- src/utils/ProviderUtils.ts | 6 +++--- test/AdapterManager.SendTokensCrossChain.ts | 2 +- ...rManager.getOutstandingCrossChainTokenTransferAmount.ts | 4 ++-- test/BalanceAllocator.ts | 6 +++--- test/BaseClass.isUpdated.ts | 2 +- 19 files changed, 29 insertions(+), 34 deletions(-) diff --git a/scripts/unwrapWeth.ts b/scripts/unwrapWeth.ts index cb6cd4de49..7a63927d8c 100644 --- a/scripts/unwrapWeth.ts +++ b/scripts/unwrapWeth.ts @@ -88,11 +88,11 @@ export async function run(): Promise { if (require.main === module) { run() - .then(async () => { + .then(() => { // eslint-disable-next-line no-process-exit process.exit(0); }) - .catch(async (error) => { + .catch((error) => { console.error("Process exited with", error); // eslint-disable-next-line no-process-exit process.exit(1); diff --git a/scripts/utils.ts b/scripts/utils.ts index 7a104888e4..66a6f72215 100644 --- a/scripts/utils.ts +++ b/scripts/utils.ts @@ -1,6 +1,6 @@ import readline from "readline"; -async function askQuestion(query: string) { +function askQuestion(query: string) { const rl = readline.createInterface({ input: process.stdin, output: process.stdout }); return new Promise((resolve) => diff --git a/scripts/zkSyncDemo.ts b/scripts/zkSyncDemo.ts index e284031662..82ccbbba3b 100644 --- a/scripts/zkSyncDemo.ts +++ b/scripts/zkSyncDemo.ts @@ -175,11 +175,11 @@ export async function run(): Promise { if (require.main === module) { run() - .then(async () => { + .then(() => { // eslint-disable-next-line no-process-exit process.exit(0); }) - .catch(async (error) => { + .catch((error) => { console.error("Process exited with", error); // eslint-disable-next-line no-process-exit process.exit(1); diff --git a/src/clients/BalanceAllocator.ts b/src/clients/BalanceAllocator.ts index d86bf1c270..2d53eb0344 100644 --- a/src/clients/BalanceAllocator.ts +++ b/src/clients/BalanceAllocator.ts @@ -88,12 +88,7 @@ export class BalanceAllocator { return true; } - async requestBalanceAllocation( - chainId: number, - tokens: string[], - holder: string, - amount: BigNumber - ): Promise { + requestBalanceAllocation(chainId: number, tokens: string[], holder: string, amount: BigNumber): Promise { return this.requestBalanceAllocations([{ chainId, tokens, holder, amount }]); } diff --git a/src/clients/BundleDataClient.ts b/src/clients/BundleDataClient.ts index ff792ef404..39a6f285b5 100644 --- a/src/clients/BundleDataClient.ts +++ b/src/clients/BundleDataClient.ts @@ -166,7 +166,7 @@ export class BundleDataClient { // Common data re-formatting logic shared across all data worker public functions. // User must pass in spoke pool to search event data against. This allows the user to refund relays and fill deposits // on deprecated spoke pools. - async loadData( + loadData( blockRangesForChains: number[][], spokePoolClients: { [chainId: number]: SpokePoolClient }, logData = true @@ -391,7 +391,7 @@ export class BundleDataClient { this.chainIdListForBundleEvaluationBlockNumbers ); const refundRequests = originClient.getRefundRequests(blockRangeForChain[0], blockRangeForChain[1]); - await Promise.all(refundRequests.map(async (refundRequest) => validateRefundRequestAndSaveData(refundRequest))); + await Promise.all(refundRequests.map((refundRequest) => validateRefundRequestAndSaveData(refundRequest))); } } diff --git a/src/clients/TransactionClient.ts b/src/clients/TransactionClient.ts index ebba1e3d00..737c86150f 100644 --- a/src/clients/TransactionClient.ts +++ b/src/clients/TransactionClient.ts @@ -47,7 +47,7 @@ export class TransactionClient { return Promise.all(txns.map((txn: AugmentedTransaction) => this._simulate(txn))); } - protected async _submit(txn: AugmentedTransaction, nonce: number | null = null): Promise { + protected _submit(txn: AugmentedTransaction, nonce: number | null = null): Promise { const { contract, method, args, value, gasLimit } = txn; return runTransaction(this.logger, contract, method, args, value, gasLimit, nonce); } diff --git a/src/clients/bridges/ArbitrumAdapter.ts b/src/clients/bridges/ArbitrumAdapter.ts index 823a701a00..b596a33fd4 100644 --- a/src/clients/bridges/ArbitrumAdapter.ts +++ b/src/clients/bridges/ArbitrumAdapter.ts @@ -195,7 +195,7 @@ export class ArbitrumAdapter extends BaseAdapter { ); } - async wrapEthIfAboveThreshold(): Promise { + wrapEthIfAboveThreshold(): Promise { throw new Error("Unnecessary to wrap ETH on Arbitrum"); } diff --git a/src/clients/bridges/PolygonAdapter.ts b/src/clients/bridges/PolygonAdapter.ts index 9f05ef7254..67d9cd7156 100644 --- a/src/clients/bridges/PolygonAdapter.ts +++ b/src/clients/bridges/PolygonAdapter.ts @@ -288,7 +288,7 @@ export class PolygonAdapter extends BaseAdapter { ); } - async wrapEthIfAboveThreshold(): Promise { + wrapEthIfAboveThreshold(): Promise { throw new Error("Unneccessary to wrap ETH on Polygon"); } } diff --git a/src/dataworker/Dataworker.ts b/src/dataworker/Dataworker.ts index e0c91dea3c..d2b1d32704 100644 --- a/src/dataworker/Dataworker.ts +++ b/src/dataworker/Dataworker.ts @@ -1873,7 +1873,7 @@ export class Dataworker { }); } - async _updateExchangeRates(l1Tokens: string[], submitExecution: boolean): Promise { + _updateExchangeRates(l1Tokens: string[], submitExecution: boolean): void { const syncedL1Tokens: string[] = []; l1Tokens.forEach((l1Token) => { // Exit early if we already synced this l1 token on this loop diff --git a/src/finalizer/utils/zkSync.ts b/src/finalizer/utils/zkSync.ts index da054dbade..d5080ee8e7 100644 --- a/src/finalizer/utils/zkSync.ts +++ b/src/finalizer/utils/zkSync.ts @@ -204,7 +204,7 @@ async function prepareFinalizations( const l1ERC20Bridge = getL1ERC20Bridge(l1ChainId); const ethAddr = getEthAddressForChain(l2ChainId); - return await sdkUtils.mapAsync(withdrawalParams, async (withdrawal) => + return await sdkUtils.mapAsync(withdrawalParams, (withdrawal) => prepareFinalization(withdrawal, ethAddr, l1Mailbox, l1ERC20Bridge) ); } diff --git a/src/monitor/Monitor.ts b/src/monitor/Monitor.ts index cfcbea01f6..3e9c95dc36 100644 --- a/src/monitor/Monitor.ts +++ b/src/monitor/Monitor.ts @@ -142,7 +142,7 @@ export class Monitor { } } - async checkUnknownRootBundleCallers(): Promise { + checkUnknownRootBundleCallers(): void { this.logger.debug({ at: "Monitor#RootBundleCallers", message: "Checking for unknown root bundle callers" }); const proposedBundles = this.clients.hubPoolClient.getProposedRootBundlesInBlockRange( @@ -169,7 +169,7 @@ export class Monitor { } } - async checkUnknownRelayers(): Promise { + checkUnknownRelayers(): void { const chainIds = this.monitorChains; this.logger.debug({ at: "Monitor#checkUnknownRelayers", message: "Checking for unknown relayers", chainIds }); for (const chainId of chainIds) { @@ -509,7 +509,7 @@ export class Monitor { // transfers stuck for longer than 1 bundle and the current time is within the last bundle execution + grace period. // But this should be okay as we should address any stuck transactions immediately so realistically no transfers // should stay unstuck for longer than one bundle. - async checkStuckRebalances(): Promise { + checkStuckRebalances(): void { const hubPoolClient = this.clients.hubPoolClient; const lastFullyExecutedBundle = hubPoolClient.getLatestFullyExecutedRootBundle(hubPoolClient.latestBlockNumber); // This case shouldn't happen outside of tests as Across V2 has already launched. diff --git a/src/scripts/testUBAClient.ts b/src/scripts/testUBAClient.ts index 6f02cb7c94..44f10cfb8a 100644 --- a/src/scripts/testUBAClient.ts +++ b/src/scripts/testUBAClient.ts @@ -146,4 +146,4 @@ export async function run(_logger: winston.Logger): Promise { } // eslint-disable-next-line no-process-exit -void run(Logger).then(async () => process.exit(0)); +void run(Logger).then(() => process.exit(0)); diff --git a/src/scripts/validateRootBundle.ts b/src/scripts/validateRootBundle.ts index 3a61434e68..578cd74780 100644 --- a/src/scripts/validateRootBundle.ts +++ b/src/scripts/validateRootBundle.ts @@ -207,4 +207,4 @@ export async function run(_logger: winston.Logger): Promise { } // eslint-disable-next-line no-process-exit -void run(Logger).then(async () => process.exit(0)); +void run(Logger).then(() => process.exit(0)); diff --git a/src/scripts/validateRunningBalances.ts b/src/scripts/validateRunningBalances.ts index e8d43985d9..b77997d798 100644 --- a/src/scripts/validateRunningBalances.ts +++ b/src/scripts/validateRunningBalances.ts @@ -444,7 +444,7 @@ export async function runScript(_logger: winston.Logger, baseSigner: Wallet): Pr * @dev Clients are only created for chains not on disabled chain list. * @returns A dictionary of chain ID to SpokePoolClient. */ - async function _createSpokePoolClients(fromBlocks: { [chainId: number]: number }) { + function _createSpokePoolClients(fromBlocks: { [chainId: number]: number }) { return constructSpokePoolClientsWithStartBlocks(logger, clients.hubPoolClient, config, baseSigner, fromBlocks, {}); } } diff --git a/src/utils/ProviderUtils.ts b/src/utils/ProviderUtils.ts index b8716b8eaf..31a3a833df 100644 --- a/src/utils/ProviderUtils.ts +++ b/src/utils/ProviderUtils.ts @@ -57,7 +57,7 @@ class RateLimitedProvider extends ethers.providers.StaticJsonRpcProvider { }, maxConcurrency); } - override async send(method: string, params: Array): Promise { + override send(method: string, params: Array): Promise { // This simply creates a promise and adds the arguments and resolve and reject handlers to the task. return new Promise((resolve, reject) => { const task: RateLimitTask = { @@ -200,7 +200,7 @@ class CacheProvider extends RateLimitedProvider { throw new Error("CacheProvider::shouldCache toBlock cannot be smaller than fromBlock."); } - return this.canCacheInformationFromBlock(toBlock); + return await this.canCacheInformationFromBlock(toBlock); } else if ("eth_call" === method || "eth_getBlockByNumber" === method) { // Pull out the block tag from params. Its position in params is dependent on the method. // We are only interested in numeric block tags, which would be hex-encoded strings. @@ -213,7 +213,7 @@ class CacheProvider extends RateLimitedProvider { } // If the block is old enough to cache, cache the call. - return this.canCacheInformationFromBlock(blockNumber); + return await this.canCacheInformationFromBlock(blockNumber); } else { return false; } diff --git a/test/AdapterManager.SendTokensCrossChain.ts b/test/AdapterManager.SendTokensCrossChain.ts index 5b27cfe28b..fba50c853b 100644 --- a/test/AdapterManager.SendTokensCrossChain.ts +++ b/test/AdapterManager.SendTokensCrossChain.ts @@ -64,7 +64,7 @@ const addAttrib = (obj: unknown) => transactionSubmissionData: number; }; -describe("AdapterManager: Send tokens cross-chain", async function () { +describe("AdapterManager: Send tokens cross-chain", function () { beforeEach(async function () { [relayer, owner] = await ethers.getSigners(); ({ spyLogger } = createSpyLogger()); diff --git a/test/AdapterManager.getOutstandingCrossChainTokenTransferAmount.ts b/test/AdapterManager.getOutstandingCrossChainTokenTransferAmount.ts index 095963200d..0e9aa7a03f 100644 --- a/test/AdapterManager.getOutstandingCrossChainTokenTransferAmount.ts +++ b/test/AdapterManager.getOutstandingCrossChainTokenTransferAmount.ts @@ -46,8 +46,8 @@ class TestAdapter extends BaseAdapter { } let adapter: TestAdapter; -describe("AdapterManager: Get outstanding cross chain token transfer amounts", async function () { - beforeEach(async function () { +describe("AdapterManager: Get outstanding cross chain token transfer amounts", function () { + beforeEach(function () { adapter = new TestAdapter(); }); diff --git a/test/BalanceAllocator.ts b/test/BalanceAllocator.ts index 8645b15665..22abf4bc17 100644 --- a/test/BalanceAllocator.ts +++ b/test/BalanceAllocator.ts @@ -32,14 +32,14 @@ class TestBalanceAllocator extends BalanceAllocator { } } -describe("BalanceAllocator", async function () { +describe("BalanceAllocator", function () { let balanceAllocator: TestBalanceAllocator; const testToken1 = randomAddress(); const testToken2 = randomAddress(); const testAccount1 = randomAddress(); - beforeEach(async function () { + beforeEach(function () { balanceAllocator = new TestBalanceAllocator(); }); @@ -49,7 +49,7 @@ describe("BalanceAllocator", async function () { expect(balanceAllocator.getUsed(1, testToken1, testAccount1)).to.equal(BigNumber.from(0)); }); - it("Add used", async function () { + it("Add used", function () { balanceAllocator.addUsed(1, testToken1, testAccount1, BigNumber.from(100)); expect(balanceAllocator.getUsed(1, testToken1, testAccount1)).to.equal(BigNumber.from(100)); }); diff --git a/test/BaseClass.isUpdated.ts b/test/BaseClass.isUpdated.ts index 817b7929fe..e173c5c253 100644 --- a/test/BaseClass.isUpdated.ts +++ b/test/BaseClass.isUpdated.ts @@ -44,7 +44,7 @@ describe("BaseAbstractClient.isUpdated", () => { await ubaClient.update(); expect(ubaClient.isUpdated).to.be.true; }); - it("should return false if the client is not updated", async () => { + it("should return false if the client is not updated", () => { expect(ubaClient.isUpdated).to.be.false; }); });