Skip to content
This repository has been archived by the owner on Aug 30, 2024. It is now read-only.

Commit

Permalink
reject absolute paths in TS
Browse files Browse the repository at this point in the history
  • Loading branch information
alexeychr committed Oct 30, 2023
1 parent 5d23060 commit ee68d0e
Show file tree
Hide file tree
Showing 12 changed files with 25 additions and 51 deletions.
31 changes: 2 additions & 29 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 3 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand All @@ -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",
Expand All @@ -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": {
Expand Down Expand Up @@ -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": [
Expand Down
2 changes: 1 addition & 1 deletion src/chain-common/order-taker.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down
2 changes: 1 addition & 1 deletion src/chain-common/tx-builder.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down
4 changes: 2 additions & 2 deletions src/chain-evm/feeManager.ts
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
6 changes: 3 additions & 3 deletions src/chain-evm/tx-builder.ts
Original file line number Diff line number Diff line change
@@ -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
Expand Down
6 changes: 3 additions & 3 deletions src/chain-solana/tx-builder.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
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';
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
Expand Down
2 changes: 1 addition & 1 deletion src/chain-solana/tx-generators/createOrderFullfillTx.ts
Original file line number Diff line number Diff line change
@@ -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,
Expand Down
5 changes: 3 additions & 2 deletions src/executor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -53,6 +52,8 @@ import { SwapConnectorImplementationService } from './processors/swap-connector-

const DEFAULT_MIN_PROFITABILITY_BPS = 4;

type EvmClientChainConfig = ConstructorParameters<typeof Evm.DlnClient>[0]['chainConfig'];

export type DstOrderConstraints = Readonly<{
fulfillmentDelay: number;
preFulfillSwapChangeRecipient: 'taker' | 'maker';
Expand Down Expand Up @@ -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]}...`);

Expand Down
2 changes: 1 addition & 1 deletion src/processors/BatchUnlocker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion tests/conversions.test.ts
Original file line number Diff line number Diff line change
@@ -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', () => {
Expand Down
7 changes: 4 additions & 3 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -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`. */
Expand Down

0 comments on commit ee68d0e

Please sign in to comment.