From f75f6f732ceba72885d8b6f3b46a96d89a6a1004 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A1n=20Jakub=20Nani=C5=A1ta?= Date: Fri, 1 Mar 2024 15:29:13 -0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=A7=B9=20Enforce=20curly=20braces=20(#444?= =?UTF-8?q?)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .eslintrc.json | 4 +- .../create-lz-oapp/src/utilities/terminal.ts | 7 +++- packages/devtools-evm-hardhat/src/config.ts | 4 +- .../src/internal/assertions.ts | 4 +- packages/devtools-evm-hardhat/src/runtime.ts | 8 +++- .../devtools-evm-hardhat/src/tasks/deploy.ts | 15 +++++-- .../transactions/subtask.sign-and-send.ts | 11 +++-- packages/devtools-evm/src/errors/parser.ts | 16 ++++++-- packages/devtools/src/common/promise.ts | 12 ++++-- packages/devtools/src/transactions/signer.ts | 4 +- packages/export-deployments/src/common/fs.ts | 4 +- packages/export-deployments/src/index.ts | 15 +++++-- packages/io-devtools/src/language/plurals.ts | 4 +- packages/io-devtools/src/stdio/printer.ts | 8 +++- packages/protocol-devtools/src/dvn/config.ts | 4 +- .../src/endpointv2/config.ts | 12 ++++-- .../protocol-devtools/src/executor/config.ts | 4 +- .../protocol-devtools/src/priceFeed/config.ts | 4 +- .../src/tasks/oapp/config.get.default.ts | 4 +- .../src/tasks/oapp/config.get.executor.ts | 4 +- .../src/tasks/oapp/config.get.ts | 4 +- .../src/utils/taskHelpers.ts | 31 ++++++++++---- packages/ua-devtools-evm/src/lzapp/sdk.ts | 4 +- packages/ua-devtools/src/lzapp/config.ts | 4 +- packages/ua-devtools/src/oapp/config.ts | 40 ++++++++++++++----- packages/verify-contract/src/common/abi.ts | 8 +++- packages/verify-contract/src/common/config.ts | 4 +- .../verify-contract/src/common/etherscan.ts | 26 ++++++++---- .../verify-contract/src/common/licenses.ts | 4 +- packages/verify-contract/src/common/logger.ts | 4 +- packages/verify-contract/src/common/url.ts | 4 +- .../src/hardhat-deploy/config.ts | 4 +- .../test/__utils__/endpointV2.ts | 4 +- .../test/task/oapp/config.get.default.test.ts | 8 +++- .../task/oapp/config.get.executor.test.ts | 8 +++- .../test/task/oapp/config.get.test.ts | 4 +- .../test/task/oapp/config.init.test.ts | 4 +- 37 files changed, 231 insertions(+), 82 deletions(-) diff --git a/.eslintrc.json b/.eslintrc.json index 2458b5c83..03121ee03 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -30,7 +30,7 @@ "ignorePatterns": ["node_modules/", "dist/", ".turbo/"], "rules": { "prettier/prettier": "error", - + "curly": "error", // This rule needs to be disabled otherwise ESLint will error out // on things like TypeScript enums or function types "no-unused-vars": "off", @@ -41,9 +41,7 @@ "varsIgnorePattern": "^_" } ], - "@typescript-eslint/no-explicit-any": "warn", - // Since none of our environment variables affect the build output, we're safe // to ignore any errors related to undeclared environment variables "turbo/no-undeclared-env-vars": "warn" diff --git a/packages/create-lz-oapp/src/utilities/terminal.ts b/packages/create-lz-oapp/src/utilities/terminal.ts index 6aa347d36..86b6491e1 100644 --- a/packages/create-lz-oapp/src/utilities/terminal.ts +++ b/packages/create-lz-oapp/src/utilities/terminal.ts @@ -10,8 +10,11 @@ const EXIT_ALT_SCREEN_ANSI = '\x1b[?1049l' const createWrite = (socket: NodeJS.WriteStream) => (content: string) => { return new Promise((resolve, reject) => { socket.write(content, (error) => { - if (error != null) reject(error) - else resolve() + if (error != null) { + reject(error) + } else { + resolve() + } }) }) } diff --git a/packages/devtools-evm-hardhat/src/config.ts b/packages/devtools-evm-hardhat/src/config.ts index b5ef23338..7d6a66f8e 100644 --- a/packages/devtools-evm-hardhat/src/config.ts +++ b/packages/devtools-evm-hardhat/src/config.ts @@ -154,7 +154,9 @@ export const withLayerZeroArtifacts = (...packageNames: string[]) => { const newArtifacts = new Set( resolvedArtifactsDirectories.filter((artifact) => !existingArtifacts.has(artifact)) ) - if (newArtifacts.size === 0) return config + if (newArtifacts.size === 0) { + return config + } return { ...config, diff --git a/packages/devtools-evm-hardhat/src/internal/assertions.ts b/packages/devtools-evm-hardhat/src/internal/assertions.ts index 82d81c398..a5e9f2b02 100644 --- a/packages/devtools-evm-hardhat/src/internal/assertions.ts +++ b/packages/devtools-evm-hardhat/src/internal/assertions.ts @@ -33,7 +33,9 @@ export function assertDefinedNetworks>( const definedNetworkNames = new Set(Object.keys(getEidsByNetworkName(hre))) for (const networkName of networkNames) { - if (definedNetworkNames.has(networkName)) continue + if (definedNetworkNames.has(networkName)) { + continue + } throw new AssertionError({ message: `Network '${networkName}' has not been defined. Defined networks are ${Array.from(definedNetworkNames).join(', ')}`, diff --git a/packages/devtools-evm-hardhat/src/runtime.ts b/packages/devtools-evm-hardhat/src/runtime.ts index 4c74768fb..61bf47654 100644 --- a/packages/devtools-evm-hardhat/src/runtime.ts +++ b/packages/devtools-evm-hardhat/src/runtime.ts @@ -172,7 +172,9 @@ export const getNetworkNameForEid = ( const eidsByNetworkName = getEidsByNetworkName(hre) for (const [networkName, networkEid] of Object.entries(eidsByNetworkName)) { - if (networkEid === eid) return networkName + if (networkEid === eid) { + return networkName + } } // Here we error out if there are no networks with this eid @@ -211,7 +213,9 @@ export const getEidsByNetworkName = memoize( const allNetworkNames = new Set(Object.keys(definedEidsByNetworkName)) // If the number of unique networks matches the number of unique endpoint IDs, there are no duplicates - if (allDefinedEids.size === allNetworkNames.size) return eidsByNetworkName + if (allDefinedEids.size === allNetworkNames.size) { + return eidsByNetworkName + } // At this point the number of defined endpoint IDs can only be lower than // the number of defined network names (since network names are taken from the keys diff --git a/packages/devtools-evm-hardhat/src/tasks/deploy.ts b/packages/devtools-evm-hardhat/src/tasks/deploy.ts index 6b5a40060..0cf24c183 100644 --- a/packages/devtools-evm-hardhat/src/tasks/deploy.ts +++ b/packages/devtools-evm-hardhat/src/tasks/deploy.ts @@ -134,7 +134,9 @@ const action: ActionType = async ( } // If no networks have been selected, we exit - if (selectedNetworks.length === 0) return logger.warn(`No networks selected, exiting`), {} + if (selectedNetworks.length === 0) { + return logger.warn(`No networks selected, exiting`), {} + } // We'll tell the user what's about to happen logger.info( @@ -154,7 +156,9 @@ const action: ActionType = async ( // Now we confirm with the user that they want to continue const shouldDeploy = isInteractive ? await promptToContinue() : true - if (!shouldDeploy) return logger.verbose(`User cancelled the operation, exiting`), {} + if (!shouldDeploy) { + return logger.verbose(`User cancelled the operation, exiting`), {} + } // We talk we talk we talk logger.verbose(`Running deployment scripts`) @@ -244,7 +248,9 @@ const action: ActionType = async ( ) // If nothing went wrong we just exit - if (errors.length === 0) return logger.info(`${printBoolean(true)} Your contracts are now deployed`), results + if (errors.length === 0) { + return logger.info(`${printBoolean(true)} Your contracts are now deployed`), results + } // We log the fact that there were some errors logger.error( @@ -253,13 +259,14 @@ const action: ActionType = async ( // If some of the deployments failed, we let the user know const previewErrors = isInteractive ? await promptToContinue(`Would you like to see the deployment errors?`) : true - if (previewErrors) + if (previewErrors) { printRecords( errors.map(({ networkName, error }) => ({ Network: networkName, Error: String(error), })) ) + } // Mark the process as unsuccessful (only if it has not yet been marked as such) process.exitCode = process.exitCode || 1 diff --git a/packages/devtools-evm-hardhat/src/tasks/transactions/subtask.sign-and-send.ts b/packages/devtools-evm-hardhat/src/tasks/transactions/subtask.sign-and-send.ts index d797e5014..c8694a288 100644 --- a/packages/devtools-evm-hardhat/src/tasks/transactions/subtask.sign-and-send.ts +++ b/packages/devtools-evm-hardhat/src/tasks/transactions/subtask.sign-and-send.ts @@ -46,7 +46,9 @@ const action: ActionType = async ({ const previewTransactions = isInteractive ? await promptToContinue(`Would you like to preview the transactions before continuing?`) : true - if (previewTransactions) printRecords(transactions.map(formatOmniTransaction)) + if (previewTransactions) { + printRecords(transactions.map(formatOmniTransaction)) + } // Now ask the user whether they want to go ahead with signing them // @@ -54,7 +56,9 @@ const action: ActionType = async ({ const shouldSubmit = isInteractive ? await promptToContinue(`Would you like to submit the required transactions?`) : true - if (!shouldSubmit) return subtaskLogger.verbose(`User cancelled the operation, exiting`), [[], [], transactions] + if (!shouldSubmit) { + return subtaskLogger.verbose(`User cancelled the operation, exiting`), [[], [], transactions] + } subtaskLogger.verbose(`Signing and sending transactions:\n\n${printJson(transactions)}`) @@ -141,13 +145,14 @@ const action: ActionType = async ({ const previewErrors = isInteractive ? await promptToContinue(`Would you like to preview the failed transactions?`) : true - if (previewErrors) + if (previewErrors) { printRecords( errors.map(({ error, transaction }) => ({ error: String(error), ...formatOmniTransaction(transaction), })) ) + } // We'll ask the user if they want to retry if we're in interactive mode // diff --git a/packages/devtools-evm/src/errors/parser.ts b/packages/devtools-evm/src/errors/parser.ts index 63c51f5db..49e955170 100644 --- a/packages/devtools-evm/src/errors/parser.ts +++ b/packages/devtools-evm/src/errors/parser.ts @@ -22,7 +22,9 @@ export const createContractErrorParser: OmniContractErrorParserFactory = (contra export const parseContractError = (error: unknown, contract: Contract): ContractError | undefined => { // If the error already is a ContractError, we'll continue - if (error instanceof ContractError) return error + if (error instanceof ContractError) { + return error + } try { // If the error is unknown we'll try to decode basic errors @@ -37,7 +39,9 @@ export const parseContractError = (error: unknown, contract: Contract): Contract export const parseGenericError = (error: unknown): ContractError | undefined => { // If the error already is a ContractError, we'll continue - if (error instanceof ContractError) return error + if (error instanceof ContractError) { + return error + } try { // If the error is unknown we'll try to decode basic errors @@ -64,14 +68,18 @@ const PANIC_ERROR_PREFIX = '0x4e487b71' * @returns `ContractError[]` Decoded errors, if any */ const basicDecoder = (data: string): ContractError[] => { - if (data === '' || data === '0x') return [new UnknownError(`Reverted with empty data`)] + if (data === '' || data === '0x') { + return [new UnknownError(`Reverted with empty data`)] + } // This covers the case for assert() if (data.startsWith(PANIC_ERROR_PREFIX)) { const reason = data.slice(PANIC_ERROR_PREFIX.length) // If the reason is empty, we'll assume the default 0 exit code - if (reason === '') return [new PanicError(BigInt(0))] + if (reason === '') { + return [new PanicError(BigInt(0))] + } try { // The codes should follow the docs here https://docs.soliditylang.org/en/latest/control-structures.html#error-handling-assert-require-revert-and-exceptions diff --git a/packages/devtools/src/common/promise.ts b/packages/devtools/src/common/promise.ts index ca4ddb8cd..d5dcaf691 100644 --- a/packages/devtools/src/common/promise.ts +++ b/packages/devtools/src/common/promise.ts @@ -168,7 +168,9 @@ export const createRetryFactory = const strategyOutput = await strategy(attempt, error, currentInput, input) // The strategy can simply return true/false, in which case we'll not be adjusting the input at all - if (typeof strategyOutput === 'boolean') return strategyOutput + if (typeof strategyOutput === 'boolean') { + return strategyOutput + } // If we got an input back, we'll adjust it and keep trying return (currentInput = strategyOutput), true @@ -197,8 +199,12 @@ export const createSimpleRetryStrategy = ( assert(numAttempts > 0, `Number of attempts for a strategy must be larger than 0`) return (attempt, error, previousInput, originalInput) => { - if (attempt > numAttempts) return false - if (wrappedStrategy == null) return true + if (attempt > numAttempts) { + return false + } + if (wrappedStrategy == null) { + return true + } return wrappedStrategy(attempt, error, previousInput, originalInput) } diff --git a/packages/devtools/src/transactions/signer.ts b/packages/devtools/src/transactions/signer.ts index eb9d6be42..28bdcc29f 100644 --- a/packages/devtools/src/transactions/signer.ts +++ b/packages/devtools/src/transactions/signer.ts @@ -29,7 +29,9 @@ export const createSignAndSend = const n = transactions.length // Just exit when there is nothing to sign - if (n === 0) return logger.debug(`No transactions to sign, exiting`), [[], [], []] + if (n === 0) { + return logger.debug(`No transactions to sign, exiting`), [[], [], []] + } // Tell the user how many we are signing logger.debug(`Signing ${n} ${pluralizeNoun(n, 'transaction')}`) diff --git a/packages/export-deployments/src/common/fs.ts b/packages/export-deployments/src/common/fs.ts index c3a5a7222..04f025e4c 100644 --- a/packages/export-deployments/src/common/fs.ts +++ b/packages/export-deployments/src/common/fs.ts @@ -28,7 +28,9 @@ export const listEntriesSafe = (predicate: Predicate) => const subDirectories: string[] = [] while ((subDirectory = dir.readSync())) { - if (predicate(subDirectory)) subDirectories.push(resolve(path, subDirectory.name)) + if (predicate(subDirectory)) { + subDirectories.push(resolve(path, subDirectory.name)) + } } return subDirectories diff --git a/packages/export-deployments/src/index.ts b/packages/export-deployments/src/index.ts index 48061941f..5867e6455 100644 --- a/packages/export-deployments/src/index.ts +++ b/packages/export-deployments/src/index.ts @@ -72,8 +72,11 @@ export const generateSafe = ({ export const generate = (options: ExportDeploymentsOptions) => { const result = generateSafe(options) - if (E.isLeft(result)) throw result.left - else return result.right + if (E.isLeft(result)) { + throw result.left + } else { + return result.right + } } /** @@ -94,8 +97,12 @@ export const createIncludeDirent = const nameW = dir.name const nameWo = basename(nameW, '.json') - if (exclude?.includes(nameW) || exclude?.includes(nameWo)) return false - if (include == null) return true + if (exclude?.includes(nameW) || exclude?.includes(nameWo)) { + return false + } + if (include == null) { + return true + } return include.includes(nameW) || include.includes(nameWo) } diff --git a/packages/io-devtools/src/language/plurals.ts b/packages/io-devtools/src/language/plurals.ts index 6d1d6488b..3c4fb2aa2 100644 --- a/packages/io-devtools/src/language/plurals.ts +++ b/packages/io-devtools/src/language/plurals.ts @@ -45,7 +45,9 @@ export const pluralizeOrdinal = (n: number): string => { */ export const pluralizeNoun = (n: number, singular: string, plural: string = `${singular}s`): string => { const rule = cardinalRules.select(n) - if (rule === 'one') return singular + if (rule === 'one') { + return singular + } return plural } diff --git a/packages/io-devtools/src/stdio/printer.ts b/packages/io-devtools/src/stdio/printer.ts index 741baa1ee..fcc44c9d1 100644 --- a/packages/io-devtools/src/stdio/printer.ts +++ b/packages/io-devtools/src/stdio/printer.ts @@ -121,7 +121,9 @@ export const printCrossTable = for (const property of properties) { // If we already added this one, we continue - if (!propertiesLeft.has(property)) continue + if (!propertiesLeft.has(property)) { + continue + } // Now we mark the property as added propertiesLeft.delete(property) @@ -160,7 +162,9 @@ export const printZodErrors = (error: ZodError): string => { // of the property on which they happened, if any const errors = error.flatten((issue) => { const propertyPath = issue.path?.join('.') ?? '' - if (propertyPath === '') return issue.message + if (propertyPath === '') { + return issue.message + } return `Property '${propertyPath}': ${issue.message}` }) diff --git a/packages/protocol-devtools/src/dvn/config.ts b/packages/protocol-devtools/src/dvn/config.ts index 18b5b33cd..21d13cace 100644 --- a/packages/protocol-devtools/src/dvn/config.ts +++ b/packages/protocol-devtools/src/dvn/config.ts @@ -14,7 +14,9 @@ export const configureDVNDstConfig: DVNConfigurator = async (graph, createSdk) = const dstConfig = await sdk.getDstConfig(to.eid) // TODO Normalize the config values using a schema before comparing them - if (isDeepEqual(dstConfig, config.dstConfig)) return [] + if (isDeepEqual(dstConfig, config.dstConfig)) { + return [] + } return [await sdk.setDstConfig(to.eid, config.dstConfig)] }) diff --git a/packages/protocol-devtools/src/endpointv2/config.ts b/packages/protocol-devtools/src/endpointv2/config.ts index 3f4943c42..89792ac3d 100644 --- a/packages/protocol-devtools/src/endpointv2/config.ts +++ b/packages/protocol-devtools/src/endpointv2/config.ts @@ -45,7 +45,9 @@ export const configureEndpointV2DefaultReceiveLibraries: EndpointV2Configurator const address = await sdk.getDefaultReceiveLibrary(to.eid) // If the library is already set as default, do nothing - if (config.defaultReceiveLibrary === address) return [] + if (config.defaultReceiveLibrary === address) { + return [] + } return [ await sdk.setDefaultReceiveLibrary( @@ -66,7 +68,9 @@ export const configureEndpointV2DefaultSendLibraries: EndpointV2Configurator = a const address = await sdk.getDefaultSendLibrary(to.eid) // If the library is already set as default, do nothing - if (config.defaultSendLibrary === address) return [] + if (config.defaultSendLibrary === address) { + return [] + } return [await sdk.setDefaultSendLibrary(to.eid, config.defaultSendLibrary)] }) @@ -79,7 +83,9 @@ const registerLibraries = async (sdk: IEndpointV2, libraries: string[]): Promise libraries.map(async (address) => { const isRegistered = await sdk.isRegisteredLibrary(address) - if (isRegistered) return [] + if (isRegistered) { + return [] + } return [await sdk.registerLibrary(address)] }) ) diff --git a/packages/protocol-devtools/src/executor/config.ts b/packages/protocol-devtools/src/executor/config.ts index 0e2343715..9dc7c8a8b 100644 --- a/packages/protocol-devtools/src/executor/config.ts +++ b/packages/protocol-devtools/src/executor/config.ts @@ -14,7 +14,9 @@ export const configureExecutorDstConfig: ExecutorConfigurator = async (graph, cr const dstConfig = await sdk.getDstConfig(to.eid) // TODO Normalize the config values using a schema before comparing them - if (isDeepEqual(dstConfig, config.dstConfig)) return [] + if (isDeepEqual(dstConfig, config.dstConfig)) { + return [] + } return [await sdk.setDstConfig(to.eid, config.dstConfig)] }) diff --git a/packages/protocol-devtools/src/priceFeed/config.ts b/packages/protocol-devtools/src/priceFeed/config.ts index b7f0a25f6..944c2eb44 100644 --- a/packages/protocol-devtools/src/priceFeed/config.ts +++ b/packages/protocol-devtools/src/priceFeed/config.ts @@ -17,7 +17,9 @@ export const configurePriceFeedPriceData: PriceFeedConfigurator = async (graph, const priceData = await sdk.getPrice(to.eid) // TODO Normalize the config values using a schema before comparing them - if (isDeepEqual(priceData, config.priceData)) return [] + if (isDeepEqual(priceData, config.priceData)) { + return [] + } return [await sdk.setPrice(to.eid, config.priceData)] }) diff --git a/packages/ua-devtools-evm-hardhat/src/tasks/oapp/config.get.default.ts b/packages/ua-devtools-evm-hardhat/src/tasks/oapp/config.get.default.ts index 65ec58f08..48b703c93 100644 --- a/packages/ua-devtools-evm-hardhat/src/tasks/oapp/config.get.default.ts +++ b/packages/ua-devtools-evm-hardhat/src/tasks/oapp/config.get.default.ts @@ -33,7 +33,9 @@ const action: ActionType = async ({ logLevel = 'info', networks: netwo for (const localNetworkName of networks) { configs[localNetworkName] = {} for (const remoteNetworkName of networks) { - if (remoteNetworkName === localNetworkName) continue + if (remoteNetworkName === localNetworkName) { + continue + } const receiveConfig = await getReceiveConfig(localNetworkName, remoteNetworkName) const sendConfig = await getSendConfig(localNetworkName, remoteNetworkName) diff --git a/packages/ua-devtools-evm-hardhat/src/tasks/oapp/config.get.executor.ts b/packages/ua-devtools-evm-hardhat/src/tasks/oapp/config.get.executor.ts index 05abffc99..0f4e655e4 100644 --- a/packages/ua-devtools-evm-hardhat/src/tasks/oapp/config.get.executor.ts +++ b/packages/ua-devtools-evm-hardhat/src/tasks/oapp/config.get.executor.ts @@ -25,7 +25,9 @@ const action: ActionType = async ({ logLevel = 'info', networks: netwo for (const localNetworkName of networks) { configs[localNetworkName] = {} for (const remoteNetworkName of networks) { - if (remoteNetworkName === localNetworkName) continue + if (remoteNetworkName === localNetworkName) { + continue + } const executorDstConfig = await getExecutorDstConfig(localNetworkName, remoteNetworkName) configs[localNetworkName]![remoteNetworkName] = executorDstConfig diff --git a/packages/ua-devtools-evm-hardhat/src/tasks/oapp/config.get.ts b/packages/ua-devtools-evm-hardhat/src/tasks/oapp/config.get.ts index 2925c6e31..16889a1f6 100644 --- a/packages/ua-devtools-evm-hardhat/src/tasks/oapp/config.get.ts +++ b/packages/ua-devtools-evm-hardhat/src/tasks/oapp/config.get.ts @@ -36,7 +36,9 @@ const action: ActionType = async ({ logLevel = 'info', oappConfig }) = for (const [index, localNetworkName] of networks.entries()) { configs[localNetworkName] = {} for (const remoteNetworkName of networks) { - if (remoteNetworkName === localNetworkName) continue + if (remoteNetworkName === localNetworkName) { + continue + } // OApp User Set Config const receiveCustomConfig = await getReceiveConfig( diff --git a/packages/ua-devtools-evm-hardhat/src/utils/taskHelpers.ts b/packages/ua-devtools-evm-hardhat/src/utils/taskHelpers.ts index 3f5436c3f..3f7f60412 100644 --- a/packages/ua-devtools-evm-hardhat/src/utils/taskHelpers.ts +++ b/packages/ua-devtools-evm-hardhat/src/utils/taskHelpers.ts @@ -29,7 +29,9 @@ export async function getSendConfig( * if custom is true then get the custom send uln config */ if (custom) { - if (address == null) throw new Error(`Must pass in OApp address when custom param is set to true`) + if (address == null) { + throw new Error(`Must pass in OApp address when custom param is set to true`) + } const isDefault = await localEndpointSDK.isDefaultSendLibrary(address, remoteEid) /** * need to return sendLibrary == AddressZero when custom config is using default send library @@ -37,7 +39,9 @@ export async function getSendConfig( sendLibrary = isDefault ? '0x0000000000000000000000000000000000000000' : await localEndpointSDK.getSendLibrary(address, remoteEid) - if (sendLibrary == null) throw new Error(`Custom Send Library not set from ${localEid} to ${remoteEid}`) + if (sendLibrary == null) { + throw new Error(`Custom Send Library not set from ${localEid} to ${remoteEid}`) + } /** * if using a custom send library use it to retrieve the custom ULN * else get the default send library and use it to retrieve the default ULN @@ -46,7 +50,9 @@ export async function getSendConfig( localSendUlnSDK = await localEndpointSDK.getUln302SDK(sendLibrary) } else { const defaultSendLib = await localEndpointSDK.getDefaultSendLibrary(remoteEid) - if (defaultSendLib == null) throw new Error(`Default Send Library not set from ${localEid} to ${remoteEid}`) + if (defaultSendLib == null) { + throw new Error(`Default Send Library not set from ${localEid} to ${remoteEid}`) + } localSendUlnSDK = await localEndpointSDK.getUln302SDK(defaultSendLib) } } else { @@ -58,7 +64,9 @@ export async function getSendConfig( address == null ? await localEndpointSDK.getDefaultSendLibrary(remoteEid) : await localEndpointSDK.getSendLibrary(address, remoteEid) - if (sendLibrary == null) throw new Error(`Default Send Library not set from ${localEid} to ${remoteEid}`) + if (sendLibrary == null) { + throw new Error(`Default Send Library not set from ${localEid} to ${remoteEid}`) + } localSendUlnSDK = await localEndpointSDK.getUln302SDK(sendLibrary) } @@ -95,7 +103,9 @@ export async function getReceiveConfig( * if custom is true then get the custom receive uln config */ if (custom) { - if (address == null) throw new Error(`Must pass in OApp address when custom param is set to true`) + if (address == null) { + throw new Error(`Must pass in OApp address when custom param is set to true`) + } /** * getReceiveLibrary returns a custom receive library if set else it returns the default retrieve library */ @@ -104,9 +114,12 @@ export async function getReceiveConfig( * need to return receiveLibrary == AddressZero when custom config is using default receive library */ receiveLibrary = isDefault ? '0x0000000000000000000000000000000000000000' : receiveAppLibrary - if (receiveLibrary == null) throw new Error(`Custom Receive Library not set from ${localEid} to ${remoteEid}`) - if (receiveAppLibrary == null) + if (receiveLibrary == null) { + throw new Error(`Custom Receive Library not set from ${localEid} to ${remoteEid}`) + } + if (receiveAppLibrary == null) { throw new Error(`Default Receive Library not set from ${localEid} to ${remoteEid}`) + } /** * use receiveAppLibrary from getReceiveLibrary return to get correct uln @@ -121,7 +134,9 @@ export async function getReceiveConfig( address == null ? await localEndpointSDK.getDefaultReceiveLibrary(remoteEid) : await localEndpointSDK.getReceiveLibrary(address, remoteEid).then(([address]) => address) - if (receiveLibrary == null) throw new Error(`Default Receive Library not set from ${localEid} to ${remoteEid}`) + if (receiveLibrary == null) { + throw new Error(`Default Receive Library not set from ${localEid} to ${remoteEid}`) + } localReceiveUlnSDK = await localEndpointSDK.getUln302SDK(receiveLibrary) } /** diff --git a/packages/ua-devtools-evm/src/lzapp/sdk.ts b/packages/ua-devtools-evm/src/lzapp/sdk.ts index a5b36357b..baed9b691 100644 --- a/packages/ua-devtools-evm/src/lzapp/sdk.ts +++ b/packages/ua-devtools-evm/src/lzapp/sdk.ts @@ -26,7 +26,9 @@ export class LzApp extends OmniSDK implements ILzApp { // The method will revert if there is no trusted remote set for this path // in which case we want to return undefined instead of throwing - if (parsedError?.reason === 'LzApp: no trusted path record') return undefined + if (parsedError?.reason === 'LzApp: no trusted path record') { + return undefined + } this.logger.debug(`Got an error getting trusted remote for eid ${eid} (${formatEid(eid)}): ${error}`) diff --git a/packages/ua-devtools/src/lzapp/config.ts b/packages/ua-devtools/src/lzapp/config.ts index 39c0535cd..b9b988ebd 100644 --- a/packages/ua-devtools/src/lzapp/config.ts +++ b/packages/ua-devtools/src/lzapp/config.ts @@ -19,7 +19,9 @@ export const configureLzAppTrustedRemotes: LzAppConfigurator = async (graph, cre const hasPeer = await sdk.hasTrustedRemote(to.eid, to.address) logger.verbose(`Checked connection ${formatOmniVector({ from, to })}: ${printBoolean(hasPeer)}`) - if (hasPeer) return [] + if (hasPeer) { + return [] + } logger.verbose(`Creating a connection ${formatOmniVector({ from, to })}`) return [await sdk.setTrustedRemote(to.eid, to.address)] diff --git a/packages/ua-devtools/src/oapp/config.ts b/packages/ua-devtools/src/oapp/config.ts index b0dd06d3d..e8dc46fbb 100644 --- a/packages/ua-devtools/src/oapp/config.ts +++ b/packages/ua-devtools/src/oapp/config.ts @@ -38,7 +38,9 @@ export const configureOAppPeers: OAppConfigurator = async (graph, createSdk) => const hasPeer = await sdk.hasPeer(to.eid, to.address) logger.verbose(`Checked connection ${formatOmniVector({ from, to })}: ${printBoolean(hasPeer)}`) - if (hasPeer) return [] + if (hasPeer) { + return [] + } logger.verbose(`Creating a connection ${formatOmniVector({ from, to })}`) return [await sdk.setPeer(to.eid, to.address)] @@ -51,14 +53,18 @@ export const configureSendLibraries: OAppConfigurator = async (graph, createSdk) flattenTransactions( await Promise.all( graph.connections.map(async ({ vector: { from, to }, config }): Promise => { - if (!config?.sendLibrary) return [] + if (!config?.sendLibrary) { + return [] + } const oappSdk = await createSdk(from) const endpointSdk = await oappSdk.getEndpointSDK() const isDefaultLibrary = await endpointSdk.isDefaultSendLibrary(from.address, to.eid) const currentSendLibrary = await endpointSdk.getSendLibrary(from.address, to.eid) - if (!isDefaultLibrary && currentSendLibrary === config.sendLibrary) return [] + if (!isDefaultLibrary && currentSendLibrary === config.sendLibrary) { + return [] + } return [await endpointSdk.setSendLibrary(from.address, to.eid, config.sendLibrary)] }) ) @@ -68,7 +74,9 @@ export const configureReceiveLibraries: OAppConfigurator = async (graph, createS flattenTransactions( await Promise.all( graph.connections.map(async ({ vector: { from, to }, config }): Promise => { - if (config?.receiveLibraryConfig == null) return [] + if (config?.receiveLibraryConfig == null) { + return [] + } const oappSdk = await createSdk(from) const endpointSdk = await oappSdk.getEndpointSDK() @@ -77,7 +85,9 @@ export const configureReceiveLibraries: OAppConfigurator = async (graph, createS to.eid ) - if (!isDefaultLibrary && currentReceiveLibrary === config.receiveLibraryConfig.receiveLibrary) return [] + if (!isDefaultLibrary && currentReceiveLibrary === config.receiveLibraryConfig.receiveLibrary) { + return [] + } return [ await endpointSdk.setReceiveLibrary( from.address, @@ -94,14 +104,18 @@ export const configureReceiveLibraryTimeouts: OAppConfigurator = async (graph, c flattenTransactions( await Promise.all( graph.connections.map(async ({ vector: { from, to }, config }): Promise => { - if (config?.receiveLibraryTimeoutConfig == null) return [] + if (config?.receiveLibraryTimeoutConfig == null) { + return [] + } const { receiveLibraryTimeoutConfig } = config const oappSdk = await createSdk(from) const endpointSdk = await oappSdk.getEndpointSDK() const timeout = await endpointSdk.getReceiveLibraryTimeout(from.address, to.eid) - if (isDeepEqual(timeout, receiveLibraryTimeoutConfig)) return [] + if (isDeepEqual(timeout, receiveLibraryTimeoutConfig)) { + return [] + } return [ await endpointSdk.setReceiveLibraryTimeout( from.address, @@ -122,7 +136,9 @@ export const configureSendConfig: OAppConfigurator = async (graph, createSdk) => vector: { from, to }, config, } of graph.connections) { - if (!config?.sendConfig) continue + if (!config?.sendConfig) { + continue + } const oappSdk = await createSdk(from) const endpointSdk = await oappSdk.getEndpointSDK() const currentSendLibrary = config?.sendLibrary ?? (await endpointSdk.getSendLibrary(from.address, to.eid)) @@ -193,7 +209,9 @@ export const configureReceiveConfig: OAppConfigurator = async (graph, createSdk) vector: { from, to }, config, } of graph.connections) { - if (!config?.receiveConfig) continue + if (!config?.receiveConfig) { + continue + } const oappSdk = await createSdk(from) const endpointSdk = await oappSdk.getEndpointSDK() const [currentReceiveLibrary] = config?.receiveLibraryConfig?.receiveLibrary @@ -242,7 +260,9 @@ export const configureEnforcedOptions: OAppConfigurator = async (graph, createSd vector: { from, to }, config, } of graph.connections) { - if (config?.enforcedOptions == null) continue + if (config?.enforcedOptions == null) { + continue + } const oappSdk = await createSdk(from) // combines enforced options together by msgType diff --git a/packages/verify-contract/src/common/abi.ts b/packages/verify-contract/src/common/abi.ts index 07c6de4fb..c69b1f182 100644 --- a/packages/verify-contract/src/common/abi.ts +++ b/packages/verify-contract/src/common/abi.ts @@ -13,7 +13,9 @@ import { TypeName, type FunctionDefinition } from '@solidity-parser/parser/dist/ * @returns */ export const encodeContructorArguments = (abi: JsonFragment[], args: unknown[] | undefined): string | undefined => { - if (args == null || args.length === 0) return undefined + if (args == null || args.length === 0) { + return undefined + } const iface = new Interface(abi) const encodedConstructorArguments = iface.encodeDeploy(args) @@ -31,7 +33,9 @@ export const getContructorABIFromSource = (source: string): MinimalAbi => { let constructorDefinition: FunctionDefinition | undefined parser.visit(ast, { FunctionDefinition: (node) => { - if (node.isConstructor) constructorDefinition = node + if (node.isConstructor) { + constructorDefinition = node + } }, }) diff --git a/packages/verify-contract/src/common/config.ts b/packages/verify-contract/src/common/config.ts index 5c0ba97f3..2dd51f2a7 100644 --- a/packages/verify-contract/src/common/config.ts +++ b/packages/verify-contract/src/common/config.ts @@ -11,7 +11,9 @@ export const parseNetworksConfig = ( ): Record => { return Object.entries(partialNetworksConfig ?? {}).reduce((networksConfig, [networkName, networkConfig]) => { // In case the config is not defined let's just go to the next one - if (networkConfig == null) return networksConfig + if (networkConfig == null) { + return networksConfig + } // The API URL can either be specified: // diff --git a/packages/verify-contract/src/common/etherscan.ts b/packages/verify-contract/src/common/etherscan.ts index 13bcd1cfa..9ee7d1502 100644 --- a/packages/verify-contract/src/common/etherscan.ts +++ b/packages/verify-contract/src/common/etherscan.ts @@ -140,15 +140,17 @@ class Verification extends EventEmitter implements IVerification { const result = await checkGuid(this.props.apiUrl, guid) this.logger.verbose(`Received raw polling response from ${this.props.apiUrl}:\n\n${JSON.stringify(result)}`) - if (result.status === 1) + if (result.status === 1) { return { alreadyVerified: false, } + } - if (isAlreadyVerifiedResult(result.result)) + if (isAlreadyVerifiedResult(result.result)) { return { alreadyVerified: true, } + } if (isPendingResult(result.result)) { await sleep(10_000) @@ -242,11 +244,21 @@ const createVerificationRequest = ({ sourceCode, } - if (apiKey != null) request.apikey = apiKey - if (optimizerRuns != null) request.runs = String(optimizerRuns) - if (constructorArguments != null) request.constructorArguements = constructorArguments - if (evmVersion != null) request.evmversion = evmVersion - if (licenseType != null) request.licenseType = String(licenseType) + if (apiKey != null) { + request.apikey = apiKey + } + if (optimizerRuns != null) { + request.runs = String(optimizerRuns) + } + if (constructorArguments != null) { + request.constructorArguements = constructorArguments + } + if (evmVersion != null) { + request.evmversion = evmVersion + } + if (licenseType != null) { + request.licenseType = String(licenseType) + } return request } diff --git a/packages/verify-contract/src/common/licenses.ts b/packages/verify-contract/src/common/licenses.ts index ba3da775d..63a3008f3 100644 --- a/packages/verify-contract/src/common/licenses.ts +++ b/packages/verify-contract/src/common/licenses.ts @@ -25,7 +25,9 @@ export const findLicenseType = (sourceCode: string): LicenseType => { const matches = sourceCode.match(/\/\/\s*SPDX-License-Identifier:\s*(.*)\s*/i) const licenseName = matches?.[1] - if (licenseName == null) return LicenseType.None + if (licenseName == null) { + return LicenseType.None + } if (!(licenseName in LicenseType)) { console.warn('Found unknown SPDX license identifier: %s', licenseName) } diff --git a/packages/verify-contract/src/common/logger.ts b/packages/verify-contract/src/common/logger.ts index 3c768a3e1..956ba72c7 100644 --- a/packages/verify-contract/src/common/logger.ts +++ b/packages/verify-contract/src/common/logger.ts @@ -57,7 +57,9 @@ export const createRecordLogger = } const formatLoggableValue = (value: LoggableValue): string => { - if (value == null) return '-' + if (value == null) { + return '-' + } switch (typeof value) { case 'boolean': diff --git a/packages/verify-contract/src/common/url.ts b/packages/verify-contract/src/common/url.ts index ccfd29267..ee02b498f 100644 --- a/packages/verify-contract/src/common/url.ts +++ b/packages/verify-contract/src/common/url.ts @@ -13,7 +13,9 @@ export const getDefaultScanApiUrl = (networkName: string): string | undefined => export const tryGetScanBrowserUrlFromScanUrl = (scanApiUrl: string): string | undefined => { try { const urlObject = new URL(scanApiUrl) - if (!urlObject.hostname.startsWith('api.') && !urlObject.hostname.startsWith('api-')) return undefined + if (!urlObject.hostname.startsWith('api.') && !urlObject.hostname.startsWith('api-')) { + return undefined + } urlObject.hostname = urlObject.hostname.replace(/^api[.-]/, '') urlObject.pathname = '/' diff --git a/packages/verify-contract/src/hardhat-deploy/config.ts b/packages/verify-contract/src/hardhat-deploy/config.ts index eaa70ef88..f71c0d074 100644 --- a/packages/verify-contract/src/hardhat-deploy/config.ts +++ b/packages/verify-contract/src/hardhat-deploy/config.ts @@ -33,7 +33,9 @@ export const parsePathsConfig = ( export const parseFilterConfig = ( filterConfig: VerifyHardhatFilterConfig | null | undefined ): VerifyHardhatFilterFunction => { - if (filterConfig == null) return () => true + if (filterConfig == null) { + return () => true + } switch (typeof filterConfig) { case 'boolean': diff --git a/tests/ua-devtools-evm-hardhat-test/test/__utils__/endpointV2.ts b/tests/ua-devtools-evm-hardhat-test/test/__utils__/endpointV2.ts index 76396549e..61741d5cc 100644 --- a/tests/ua-devtools-evm-hardhat-test/test/__utils__/endpointV2.ts +++ b/tests/ua-devtools-evm-hardhat-test/test/__utils__/endpointV2.ts @@ -622,7 +622,9 @@ const setupDefaultEndpointV2 = async (): Promise => { ] const [_, errors] = await signAndSend(transactions) - if (errors.length === 0) return + if (errors.length === 0) { + return + } const errorParser = await createErrorParser() const parsedErrors = await Promise.all(errors.map(({ error }) => errorParser(error))) diff --git a/tests/ua-devtools-evm-hardhat-test/test/task/oapp/config.get.default.test.ts b/tests/ua-devtools-evm-hardhat-test/test/task/oapp/config.get.default.test.ts index 43ebcdb5b..d0bfe031a 100644 --- a/tests/ua-devtools-evm-hardhat-test/test/task/oapp/config.get.default.test.ts +++ b/tests/ua-devtools-evm-hardhat-test/test/task/oapp/config.get.default.test.ts @@ -35,7 +35,9 @@ describe(`task ${TASK_LZ_OAPP_CONFIG_GET_DEFAULT}`, () => { for (const localNetwork of networks) { const localEid = getEidForNetworkName(localNetwork) for (const remoteNetwork of networks) { - if (localNetwork === remoteNetwork) continue + if (localNetwork === remoteNetwork) { + continue + } const defaultConfig = getDefaultConfigTask[localNetwork][remoteNetwork] const sendUln302 = await contractFactory({ contractName: 'SendUln302', eid: localEid }) @@ -63,7 +65,9 @@ describe(`task ${TASK_LZ_OAPP_CONFIG_GET_DEFAULT}`, () => { for (const localNetwork of networks) { const localEid = getEidForNetworkName(localNetwork) for (const remoteNetwork of networks) { - if (localNetwork === remoteNetwork) continue + if (localNetwork === remoteNetwork) { + continue + } const defaultConfig = getDefaultConfigTask[localNetwork][remoteNetwork] const sendUln302 = await contractFactory({ contractName: 'SendUln302', eid: localEid }) diff --git a/tests/ua-devtools-evm-hardhat-test/test/task/oapp/config.get.executor.test.ts b/tests/ua-devtools-evm-hardhat-test/test/task/oapp/config.get.executor.test.ts index 3daf2ac8c..35fb09e9a 100644 --- a/tests/ua-devtools-evm-hardhat-test/test/task/oapp/config.get.executor.test.ts +++ b/tests/ua-devtools-evm-hardhat-test/test/task/oapp/config.get.executor.test.ts @@ -12,7 +12,9 @@ describe(`task ${TASK_LZ_OAPP_CONFIG_GET_EXECUTOR}`, () => { const executorConfigReturnData = await hre.run(TASK_LZ_OAPP_CONFIG_GET_EXECUTOR, { networks }) for (const localNetwork of networks) { for (const remoteNetwork of networks) { - if (localNetwork === remoteNetwork) continue + if (localNetwork === remoteNetwork) { + continue + } const executorConfig = executorConfigReturnData[localNetwork][remoteNetwork] expect(executorConfig).toEqual(defaultExecutorDstConfig) } @@ -24,7 +26,9 @@ describe(`task ${TASK_LZ_OAPP_CONFIG_GET_EXECUTOR}`, () => { const networks = ['britney', 'vengaboys', 'tango'] for (const localNetwork of networks) { for (const remoteNetwork of networks) { - if (localNetwork === remoteNetwork) continue + if (localNetwork === remoteNetwork) { + continue + } const executorConfig = executorConfigReturnData[localNetwork][remoteNetwork] expect(executorConfig).toEqual(defaultExecutorDstConfig) } diff --git a/tests/ua-devtools-evm-hardhat-test/test/task/oapp/config.get.test.ts b/tests/ua-devtools-evm-hardhat-test/test/task/oapp/config.get.test.ts index 8ca3e9b9f..fd8213181 100644 --- a/tests/ua-devtools-evm-hardhat-test/test/task/oapp/config.get.test.ts +++ b/tests/ua-devtools-evm-hardhat-test/test/task/oapp/config.get.test.ts @@ -32,7 +32,9 @@ describe(`task ${TASK_LZ_OAPP_CONFIG_GET}`, () => { for (const localNetwork of networks) { const localEid = getEidForNetworkName(localNetwork) for (const remoteNetwork of networks) { - if (localNetwork === remoteNetwork) continue + if (localNetwork === remoteNetwork) { + continue + } const defaultConfig = getDefaultConfigTask[localNetwork][remoteNetwork] const sendUln302 = await contractFactory({ contractName: 'SendUln302', eid: localEid }) diff --git a/tests/ua-devtools-evm-hardhat-test/test/task/oapp/config.init.test.ts b/tests/ua-devtools-evm-hardhat-test/test/task/oapp/config.init.test.ts index b9bfd6f43..7dc3f0f16 100644 --- a/tests/ua-devtools-evm-hardhat-test/test/task/oapp/config.init.test.ts +++ b/tests/ua-devtools-evm-hardhat-test/test/task/oapp/config.init.test.ts @@ -206,7 +206,9 @@ async function getConnectionsArray(networks: string[]) { let connectionsContent = '' for (const from of networks) { for (const to of networks) { - if (from === to) continue + if (from === to) { + continue + } const defaultConfig = getDefaultConfigTask[from][to] connectionsContent += `{ from: ${from}Contract, to: ${to}Contract, config: ${buildDefaultConfig(defaultConfig)} }, ` }