From ee68d0e9ea061fb628ada3fbd72ffb96749451e0 Mon Sep 17 00:00:00 2001 From: Alexey Churkin Date: Mon, 30 Oct 2023 18:05:55 +0100 Subject: [PATCH] reject absolute paths in TS --- package-lock.json | 31 ++----------------- package.json | 7 ++--- src/chain-common/order-taker.ts | 2 +- src/chain-common/tx-builder.ts | 2 +- src/chain-evm/feeManager.ts | 4 +-- src/chain-evm/tx-builder.ts | 6 ++-- src/chain-solana/tx-builder.ts | 6 ++-- .../tx-generators/createOrderFullfillTx.ts | 2 +- src/executor.ts | 5 +-- src/processors/BatchUnlocker.ts | 2 +- tests/conversions.test.ts | 2 +- tsconfig.json | 7 +++-- 12 files changed, 25 insertions(+), 51 deletions(-) diff --git a/package-lock.json b/package-lock.json index 80e75318..48c1b79d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@debridge-finance/dln-taker", - "version": "3.0.0-rc.0", + "version": "3.0.0-rc.1", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@debridge-finance/dln-taker", - "version": "3.0.0-rc.0", + "version": "3.0.0-rc.1", "license": "GPL-3.0-only", "dependencies": { "@debridge-finance/dln-client": "8.2.1", @@ -47,7 +47,6 @@ "prettier-package-json": "^2.8.0", "rimraf": "3.0.2", "ts-node": "10.9.1", - "tsconfig-paths": "^4.2.0", "typescript": "~5.1.6" }, "engines": { @@ -7020,18 +7019,6 @@ "resolved": "https://registry.npmjs.org/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz", "integrity": "sha512-ZClg6AaYvamvYEE82d3Iyd3vSSIjQ+odgjaTzRuO3s7toCdFKczob2i0zCh7JE8kWn17yvAWhUVxvqGwUalsRA==" }, - "node_modules/json5": { - "version": "2.2.3", - "resolved": "https://registry.npmjs.org/json5/-/json5-2.2.3.tgz", - "integrity": "sha512-XmOWe7eyHYH14cLdVPoyg+GOH3rYX++KpzrylJwSW98t3Nk+U8XOl8FWKOgwtzdb8lXGf6zYwDUzeHMWfxasyg==", - "dev": true, - "bin": { - "json5": "lib/cli.js" - }, - "engines": { - "node": ">=6" - } - }, "node_modules/jsonfile": { "version": "6.1.0", "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-6.1.0.tgz", @@ -10430,20 +10417,6 @@ "node": ">=0.3.1" } }, - "node_modules/tsconfig-paths": { - "version": "4.2.0", - "resolved": "https://registry.npmjs.org/tsconfig-paths/-/tsconfig-paths-4.2.0.tgz", - "integrity": "sha512-NoZ4roiN7LnbKn9QqE1amc9DJfzvZXxF4xDavcOWt1BPkdx+m+0gJuPM+S0vCe7zTJMYUP0R8pO2XMr+Y8oLIg==", - "dev": true, - "dependencies": { - "json5": "^2.2.2", - "minimist": "^1.2.6", - "strip-bom": "^3.0.0" - }, - "engines": { - "node": ">=6" - } - }, "node_modules/tslib": { "version": "2.6.2", "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.6.2.tgz", diff --git a/package.json b/package.json index 2da09c1e..545f1f58 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@debridge-finance/dln-taker", - "version": "3.0.0-rc.0", + "version": "3.0.0-rc.1", "description": "DLN executor is the rule-based daemon service developed to automatically execute orders placed on the deSwap Liquidity Network (DLN) across supported blockchains", "license": "GPL-3.0-only", "author": "deBridge", @@ -17,7 +17,7 @@ "build": "npm-run-all clean compile && chmod +x ./dist/cli/bootstrap.js", "clean": "rimraf ./dist", "compile": "tsc -P tsconfig.build.json", - "executor": "ts-node -r tsconfig-paths/register -P tsconfig.dev.json ./src/cli/bootstrap.ts", + "executor": "ts-node -P tsconfig.dev.json ./src/cli/bootstrap.ts", "format": "npm-run-all lint pretty", "lint": "npm-run-all lint:ts lint:tsc", "lint:ts": "eslint --fix \"{src,tests}/**/*.ts\" sample.config.ts", @@ -28,7 +28,7 @@ "pretty:package": "prettier-package-json --write", "pretty:ts": "prettier --write \"{src,tests}/**/*.ts\" sample.config.ts", "start:compiled": "./dist/cli/bootstrap.js", - "test": "mocha -r ts-node/register -r tsconfig-paths/register -b -t 100000 ./tests/**/*.test.ts" + "test": "mocha -r ts-node/register -b -t 100000 ./tests/**/*.test.ts" }, "types": "./dist/index.d.ts", "dependencies": { @@ -79,7 +79,6 @@ "prettier-package-json": "^2.8.0", "rimraf": "3.0.2", "ts-node": "10.9.1", - "tsconfig-paths": "^4.2.0", "typescript": "~5.1.6" }, "keywords": [ diff --git a/src/chain-common/order-taker.ts b/src/chain-common/order-taker.ts index 3d56930a..f30fbfc3 100644 --- a/src/chain-common/order-taker.ts +++ b/src/chain-common/order-taker.ts @@ -1,7 +1,7 @@ import { Logger } from 'pino'; -import { Authority } from 'src/interfaces'; import { assert } from '../errors'; import { PostponingReason, RejectionReason } from '../hooks/HookEnums'; +import { Authority } from '../interfaces'; import { CreatedOrder } from './order'; import { explainEstimation, OrderEstimation } from './order-estimator'; diff --git a/src/chain-common/tx-builder.ts b/src/chain-common/tx-builder.ts index 6c0a3672..2147b7ff 100644 --- a/src/chain-common/tx-builder.ts +++ b/src/chain-common/tx-builder.ts @@ -1,6 +1,6 @@ import { OrderDataWithId } from '@debridge-finance/dln-client'; import { Logger, LoggerOptions } from 'pino'; -import { InitTransactionBuilder } from 'src/processor'; +import { InitTransactionBuilder } from '../processor'; import { BatchUnlockTransactionBuilder } from '../processors/BatchUnlocker'; import { OrderEstimation } from './order-estimator'; import { FulfillTransactionBuilder } from './order-taker'; diff --git a/src/chain-evm/feeManager.ts b/src/chain-evm/feeManager.ts index 61a115a8..f2f4c34d 100644 --- a/src/chain-evm/feeManager.ts +++ b/src/chain-evm/feeManager.ts @@ -1,7 +1,7 @@ import { ChainId } from '@debridge-finance/dln-client'; -import { SupportedChain } from 'src/config'; -import { assert } from 'src/errors'; import Web3 from 'web3'; +import { SupportedChain } from '../config'; +import { assert } from '../errors'; export type EIP1551Fee = { baseFee: bigint; diff --git a/src/chain-evm/tx-builder.ts b/src/chain-evm/tx-builder.ts index de221b7b..e50beba6 100644 --- a/src/chain-evm/tx-builder.ts +++ b/src/chain-evm/tx-builder.ts @@ -1,15 +1,15 @@ import { ChainId, OrderDataWithId } from '@debridge-finance/dln-client'; import { Logger } from 'pino'; import Web3 from 'web3'; -import { InitTransactionBuilder } from 'src/processor'; -import { FulfillTransactionBuilder } from 'src/chain-common/order-taker'; -import { BatchUnlockTransactionBuilder } from 'src/processors/BatchUnlocker'; import { OrderEstimation } from '../chain-common/order-estimator'; import { IExecutor } from '../executor'; import { EvmTxSigner } from './signer'; import { createERC20ApproveTxs } from './tx-generators/createERC20ApproveTxs'; import { createBatchOrderUnlockTx } from './tx-generators/createBatchOrderUnlockTx'; import { createOrderFullfillTx } from './tx-generators/createOrderFullfillTx'; +import { InitTransactionBuilder } from '../processor'; +import { BatchUnlockTransactionBuilder } from '../processors/BatchUnlocker'; +import { FulfillTransactionBuilder } from '../chain-common/order-taker'; export class EvmTransactionBuilder implements InitTransactionBuilder, FulfillTransactionBuilder, BatchUnlockTransactionBuilder diff --git a/src/chain-solana/tx-builder.ts b/src/chain-solana/tx-builder.ts index e18c3518..e3fe9a21 100644 --- a/src/chain-solana/tx-builder.ts +++ b/src/chain-solana/tx-builder.ts @@ -1,8 +1,5 @@ import { ChainId, OrderDataWithId, Solana } from '@debridge-finance/dln-client'; import { Logger } from 'pino'; -import { InitTransactionBuilder } from 'src/processor'; -import { FulfillTransactionBuilder } from 'src/chain-common/order-taker'; -import { BatchUnlockTransactionBuilder } from 'src/processors/BatchUnlocker'; import { setTimeout } from 'timers/promises'; import { createBatchOrderUnlockTx } from './tx-generators/createBatchOrderUnlockTx'; import { tryInitTakerALT } from './tx-generators/tryInitTakerALT'; @@ -10,6 +7,9 @@ import { createOrderFullfillTx } from './tx-generators/createOrderFullfillTx'; import { SolanaTxSigner } from './signer'; import { IExecutor } from '../executor'; import { OrderEstimation } from '../chain-common/order-estimator'; +import { InitTransactionBuilder } from '../processor'; +import { FulfillTransactionBuilder } from '../chain-common/order-taker'; +import { BatchUnlockTransactionBuilder } from '../processors/BatchUnlocker'; export class SolanaTransactionBuilder implements InitTransactionBuilder, FulfillTransactionBuilder, BatchUnlockTransactionBuilder diff --git a/src/chain-solana/tx-generators/createOrderFullfillTx.ts b/src/chain-solana/tx-generators/createOrderFullfillTx.ts index 2069dc20..78fa20d8 100644 --- a/src/chain-solana/tx-generators/createOrderFullfillTx.ts +++ b/src/chain-solana/tx-generators/createOrderFullfillTx.ts @@ -1,9 +1,9 @@ import { ChainEngine } from '@debridge-finance/dln-client'; import { Logger } from 'pino'; import { VersionedTransaction } from '@solana/web3.js'; -import { assert } from 'src/errors'; import { createClientLogger } from '../../dln-ts-client.utils'; import { OrderEstimation } from '../../chain-common/order-estimator'; +import { assert } from '../../errors'; export async function createOrderFullfillTx( estimation: OrderEstimation, diff --git a/src/executor.ts b/src/executor.ts index eb33f26f..dea0613c 100644 --- a/src/executor.ts +++ b/src/executor.ts @@ -21,7 +21,6 @@ import { Logger } from 'pino'; import { TokensBucket, setSlippageOverloader } from '@debridge-finance/legacy-dln-profitability'; import BigNumber from 'bignumber.js'; import Web3 from 'web3'; -import { DlnConfig } from 'node_modules/@debridge-finance/dln-client/dist/types/evm/index'; import { ChainDefinition, ExecutorLaunchConfig, @@ -53,6 +52,8 @@ import { SwapConnectorImplementationService } from './processors/swap-connector- const DEFAULT_MIN_PROFITABILITY_BPS = 4; +type EvmClientChainConfig = ConstructorParameters[0]['chainConfig']; + export type DstOrderConstraints = Readonly<{ fulfillmentDelay: number; preFulfillSwapChangeRecipient: 'taker' | 'maker'; @@ -272,7 +273,7 @@ export class Executor implements IExecutor { } const clients: ClientImplementation[] = []; - const evmChainConfig: DlnConfig['chainConfig'] = {}; + const evmChainConfig: EvmClientChainConfig = {}; for (const chain of config.chains) { this.logger.info(`initializing ${ChainId[chain.chain]}...`); diff --git a/src/processors/BatchUnlocker.ts b/src/processors/BatchUnlocker.ts index bfe4b545..572b2ad7 100644 --- a/src/processors/BatchUnlocker.ts +++ b/src/processors/BatchUnlocker.ts @@ -9,9 +9,9 @@ import { import { Logger } from 'pino'; import { helpers } from '@debridge-finance/solana-utils'; -import { Authority } from 'src/interfaces'; import { TransactionSender } from '../chain-common/tx-builder'; import { ExecutorSupportedChain, IExecutor } from '../executor'; +import { Authority } from '../interfaces'; export interface BatchUnlockTransactionBuilder { unlockAuthority: Authority; diff --git a/tests/conversions.test.ts b/tests/conversions.test.ts index 4c0a28ca..a9af8482 100644 --- a/tests/conversions.test.ts +++ b/tests/conversions.test.ts @@ -1,7 +1,7 @@ import { helpers } from '@debridge-finance/solana-utils'; import assert from 'assert'; import 'mocha'; -import { U256 } from 'src/orderFeeds/u256-utils'; +import { U256 } from '../src/orderFeeds/u256-utils'; function testConversion() { it('can convert hex to bigint', () => { diff --git a/tsconfig.json b/tsconfig.json index abf95f46..4b52af66 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -28,11 +28,12 @@ /* Modules */ "module": "Node16", /* Specify what module code is generated. */ // "rootDir": "./", /* Specify the root folder within your source files. */ - "moduleResolution": "Node16", /* Specify how TypeScript looks up a file from a given module specifier. */ - "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */ + "moduleResolution": "NodeNext", /* Specify how TypeScript looks up a file from a given module specifier. */ + + // remove it so that tsc will break on every absolute import + // "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */ "paths": { "@debridge-finance/dln-taker": ["./src"], // this is needed to create a verifiable sample.config.ts referencing src as a package - "src/*": ["src/*"] }, /* Specify a set of entries that re-map imports to additional lookup locations. */ // "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */ // "typeRoots": [], /* Specify multiple folders that act like `./node_modules/@types`. */